web pitch bend, mod wheel + fix smoothing in bw_env_gen
This commit is contained in:
parent
d43a54e0b0
commit
f07728d1d1
@ -65,6 +65,12 @@ class BWExample extends AudioWorkletProcessor {
|
||||
case "noteOff":
|
||||
self.module.wrapper_note_off(self.instance, e.data.note);
|
||||
break;
|
||||
case "pitchBend":
|
||||
self.module.wrapper_pitch_bend(self.instance, e.data.pitchBend);
|
||||
break;
|
||||
case "modWheel":
|
||||
self.module.wrapper_mod_wheel(self.instance, e.data.modWheel);
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -151,3 +151,15 @@ void wrapper_note_off(wrapper w, int note) {
|
||||
P_NOTE_OFF(w->instance, note);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wrapper_pitch_bend(wrapper w, int bend) {
|
||||
#ifdef P_PITCH_BEND
|
||||
P_PITCH_BEND(w->instance, bend);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wrapper_mod_wheel(wrapper w, int wheel) {
|
||||
#ifdef P_MOD_WHEEL
|
||||
P_MOD_WHEEL(w->instance, wheel);
|
||||
#endif
|
||||
}
|
||||
|
@ -291,9 +291,8 @@ void bw_example_synth_mono_process(bw_example_synth_mono instance, const float**
|
||||
else
|
||||
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state);
|
||||
|
||||
// TODO: mod wheel
|
||||
for (int j = 0; j < n; j++)
|
||||
instance->buf[1][j] = out[j] + instance->params[p_mod_mix] * (instance->buf[0][j] - out[j]);
|
||||
instance->buf[1][j] = instance->mod_wheel * (out[j] + instance->params[p_mod_mix] * (instance->buf[0][j] - out[j]));
|
||||
const float vcf_mod = 0.3f * instance->params[p_vcf_mod] * instance->buf[1][0];
|
||||
|
||||
for (int j = 0; j < n; j++)
|
||||
|
@ -119,5 +119,7 @@ static struct config_parameter config_parameters[NUM_PARAMETERS] = {
|
||||
#define P_GET_PARAMETER bw_example_synth_mono_get_parameter
|
||||
#define P_NOTE_ON bw_example_synth_mono_note_on
|
||||
#define P_NOTE_OFF bw_example_synth_mono_note_off
|
||||
#define P_PITCH_BEND bw_example_synth_mono_pitch_bend
|
||||
#define P_MOD_WHEEL bw_example_synth_mono_mod_wheel
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,8 @@ LDFLAGS= \
|
||||
-Wl,--export=wrapper_set_parameter \
|
||||
-Wl,--export=wrapper_note_on \
|
||||
-Wl,--export=wrapper_note_off \
|
||||
-Wl,--export=wrapper_pitch_bend \
|
||||
-Wl,--export=wrapper_mod_wheel \
|
||||
-Wl,-z,stack-size=$$((8*1024*1024)) \
|
||||
-nostdlib
|
||||
|
||||
|
@ -200,7 +200,7 @@ var parameters = [
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "VCA dttack",
|
||||
name: "VCA attack",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
|
@ -44,6 +44,14 @@ var Synth = {
|
||||
|
||||
noteOff: function (note) {
|
||||
this.node.port.postMessage({ type: "noteOff", note: note });
|
||||
},
|
||||
|
||||
pitchBend: function (bend) {
|
||||
this.node.port.postMessage({ type: "pitchBend", pitchBend: bend });
|
||||
},
|
||||
|
||||
modWheel: function (wheel) {
|
||||
this.node.port.postMessage({ type: "modWheel", modWheel: wheel });
|
||||
}
|
||||
};
|
||||
|
||||
@ -113,6 +121,13 @@ window.addEventListener("load", async function (e) {
|
||||
case 0x80:
|
||||
Synth.noteOff(e.data[1]);
|
||||
break;
|
||||
case 0xe0:
|
||||
Synth.pitchBend(e.data[2] << 8 | e.data[1]);
|
||||
break;
|
||||
case 0xb0:
|
||||
if (e.data[1] == 1)
|
||||
Synth.modWheel(e.data[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
midi.inputs.forEach((entry) => { entry.onmidimessage = onMIDIMessage; });
|
||||
|
@ -246,6 +246,8 @@ static inline void bw_env_gen_init(bw_env_gen_coeffs *BW_RESTRICT coeffs) {
|
||||
}
|
||||
|
||||
static inline void bw_env_gen_set_sample_rate(bw_env_gen_coeffs *BW_RESTRICT coeffs, float sample_rate) {
|
||||
bw_one_pole_set_sample_rate(&coeffs->smooth_coeffs, sample_rate);
|
||||
bw_one_pole_reset_coeffs(&coeffs->smooth_coeffs);
|
||||
coeffs->T = 1.f / sample_rate;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user