Hey,
Still working away on my first Teensy synth.
It’s 8 voice polyphonic, so for changing the parameters across multiple voices, I’ve been using variables like this:
const float DIV127 = (1.0 / 127.0);
float pinknoisevol = 0;
float osc1vol = (20.0 * DIV127);
float osc2vol = (20.0 * DIV127);
float karplusvol = (20.0 * DIV127);
void loop() {
usbMIDI.read();
//listen for value changes
mixer1.gain(0, pinknoisevol);
mixer1.gain(1, osc1vol);
mixer1.gain(2, osc2vol);
mixer1.gain(3, karplusvol);
mixer8.gain(0, pinknoisevol);
mixer8.gain(1, osc1vol);
mixer8.gain(2, osc2vol);
mixer8.gain(3, karplusvol);
}
void myControlChange(byte channel, byte control, byte value) {
switch (control) {
case 106:
switch (value) {
//preset knob, first preset range
case 0 ... 31:
//voice mix
pinknoisevol = 0;
osc1vol = (70.0 * DIV127);
osc2vol = (70.0 * DIV127);
karplusvol = (18.0 * DIV127);
}
I was wondering what the best approach was for switching waveforms? Is there a similar sort of approach I can take?
Right now, I’m just writing out the waveform options for all the voices:
waveformMod1.begin(WAVEFORM_SINE);
waveformMod2.begin(WAVEFORM_SINE);
waveform1.begin(WAVEFORM_SINE);
waveformMod3.begin(WAVEFORM_SINE);
waveformMod4.begin(WAVEFORM_SINE);
waveform2.begin(WAVEFORM_SINE);
As there’s 8 voices, I’d rather avoid doing this and be able to just change the waves for osc 1, osc 2, and the 8 LFOs just once rather than writing it out.
Can I just create a string variable with the waveform name:
String osc1 = “WAVEFORM_SINE”
In loop:
waveformMod1.begin(osc1)
In midi loop, based on some midi value:
osc1 = “WAVEFORM_TRIANGLE”