I'm trying to learn how to use the web audio api properly and I'm running into a bit of confusion.
In my project, I'm trying to replicate the functionality of an old 1982 Harman/Kardon receiver. (click link to see photo)
This receiver has separate dials for the treble and bass control. I'll just deal with treble in this question. I'm sure I can figure out the bass equivalent once I'm pointed in the right direction.
In an initialization function I create the context and filter nodes.
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
source = context.createMediaElementSource(document.getElementById('audio'));
gainNode = context.createGain();
//filter nodes
bassTurnoverFilter = context.createBiquadFilter();
trebleTurnoverFilter = context.createBiquadFilter();
loudnessTrebFilter = context.createBiquadFilter();
loudnessBassFilter = context.createBiquadFilter();
trebleLevelFilter = context.createBiquadFilter();
bassLevelFilter = context.createBiquadFilter();
I am currently using the jogDial plugin to control the dials. The dials do work and I can get a range for the "treble" variable between 0 and 1 when the dials turn from 0% to 100%.
This is the current mousemove function I am using for the treble dial:
.on("mousemove", function(event){
var treble = (event.target.rotation + 140) / 280;
if(trebleLevelFilter !== undefined){
trebleLevelFilter.disconnect();
}
source.connect(trebleLevelFilter);
trebleLevelFilter.type = "highshelf";
trebleLevelFilter.frequency.value = 200;
trebleLevelFilter.gain.value = treble;
trebleLevelFilter.connect(context.destination);
});
My question, or multi-part question is... which of the 6 types should I use? ("lowpass","highpass", "bandpass", "lowshelf", "highshelf", "peaking", "notch", "allpass") I'm guessing it is the highpass or highself.
What frequency should I set?
Is the gain.value what should be dynamic when the dial turns?
Am I going in completely the wrong direction?
I have the gain.value set to the treble variable value, and it seems like it is increasing the volume a little when turned to 100%... but i don't think that is the correct functionality I am trying to accomplish.