if(synth->pitch_envelope_active)
{
actual_note += (int) (map(
sorollet_adsr_update(&synth->pitch_envelope, t),
0, 1, -12, 12)
);
}
float pitchEnv = mPitchADSR->update(bufferTime);
case PARAM_VOLUME1: vst_strncpy(label, "dB", kVstMaxParamStrLen);
break;
case PARAM_OCTAVE1: vst_strncpy(label, "Octave", kVstMaxParamStrLen);
break;
case PARAM_WAVE1: vst_strncpy(label, "Wave", kVstMaxParamStrLen);
break;
case PARAM_PHASE1: vst_strncpy(label, "", kVstMaxParamStrLen);
break;
// ...
Tedious!
<audio-context>
</audio-context>
<audio-context>
<audio-oscillator>
</audio-oscillator>
</audio-context>
<audio-context>
<audio-mixer>
<audio-oscillator frequency="220"></audio-oscillator>
<audio-oscillator frequency="440"></audio-oscillator>
</audio-mixer>
</audio-context>
<audio-context>
<audio-chain>
<audio-oscillator frequency="220"></audio-oscillator>
<audio-oscilloscope></audio-oscilloscope>
</audio-chain>
</audio-context>
<audio-context>
<audio-chain>
<audio-oscillator frequency="220"></audio-oscillator>
<audio-filter type="lowpass"></audio-filter>
</audio-chain>
</audio-context>
<audio-chain>
<audio-mixer>
<audio-oscillator></audio-oscillator>
<audio-oscillator></audio-oscillator>
</audio-mixer>
<audio-filter type="lowpass"></audio-filter>
</audio-chain>
var mixerGain = context.createGain();
var osc1 = context.createOscillator();
var osc2 = context.createOscillator();
osc1.connect(mixerGain);
osc2.connect(mixerGain);
var filter = context.createBiquadFilter();
mixerGain.connect(filter);
// output is at *filter*
start: function(when) {
var oscGain = this.oscillators.length > 0 ?
1.0 / this.oscillators.length : 1.0;
this.oscillators.forEach(function(osc) {
osc.gain = oscGain;
osc.start(when);
});
}
stop: function(when) {
this.oscillators.forEach(function(osc) {
osc.stop(when);
});
}
noteOn: function(noteNumber) {
this.oscillators.forEach(function(osc, index) {
var oscNoteNumber = noteNumber + 12 * index;
var frequency =
MIDIUtils.noteNumberToFrequency(oscNoteNumber);
osc.frequency = frequency;
});
}
<audio-keyboard octaves="2"></audio-keyboard>
keyboard.addEventListener('noteon', function(e) {
var noteIndex = e.detail.index;
minisynth.noteOn(parseInt(noteIndex, 10) + 40);
minisynth.start();
}, false);
keyboard.addEventListener('noteoff', function(e) {
minisynth.noteOff();
}, false);