Enable drones
This commit is contained in:
parent
8aa7312ed5
commit
7f867b3018
17
patches.h
17
patches.h
|
@ -5,6 +5,23 @@
|
|||
|
||||
// Waveform, offset, multiplier, delay, attack, holdAmp, hold, decay, sustainAmp, release
|
||||
FMPatch Bank[] = {
|
||||
{
|
||||
"Pumpkin",
|
||||
ALG_OPL2_1(0.3),
|
||||
{
|
||||
// Waveform offs mult dely attk hldA hld decy susA rels
|
||||
{WAVEFORM_SAWTOOTH, 0, 1.00, 0, 10.5, 0.8, 10.5, 10, 0.50, 5},
|
||||
{WAVEFORM_SINE, 0, 2.00, 0, 10.5, 0.4, 10.5, 10, 0.01, 5},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Sawtooth",
|
||||
ALG_SIMPLE,
|
||||
{
|
||||
// Waveform offs mult dely attk hldA hld decy susA rels
|
||||
{WAVEFORM_SAWTOOTH, 0, 1.00, 0, 10.5, 0.8, 10.5, 10, 0.50, 5},
|
||||
},
|
||||
},
|
||||
{
|
||||
"Square",
|
||||
ALG_SIMPLE,
|
||||
|
|
|
@ -5,6 +5,7 @@ void FMVoiceLoadPatch(FMVoice *v, FMPatch *p) {
|
|||
for (int i=0; i<NUM_OPERATORS; i++) {
|
||||
FMOperator op = p->operators[i];
|
||||
|
||||
v->oscillators[i].frequencyModulation(1);
|
||||
v->oscillators[i].begin(op.waveform);
|
||||
v->envelopes[i].delay(op.delayTime);
|
||||
v->envelopes[i].attack(op.attackTime);
|
||||
|
@ -35,10 +36,12 @@ void FMVoiceNoteOn(FMVoice *v, float freq) {
|
|||
for (int i=0; i<4; i++) {
|
||||
v->envelopes[i].noteOn();
|
||||
}
|
||||
v->playing = true;
|
||||
}
|
||||
|
||||
void FMVoiceNoteOff(FMVoice *v) {
|
||||
for (int i=0; i<4; i++) {
|
||||
v->envelopes[i].noteOff();
|
||||
}
|
||||
v->playing = false;
|
||||
}
|
||||
|
|
1
synth.h
1
synth.h
|
@ -86,6 +86,7 @@ typedef struct FMVoice {
|
|||
AudioEffectEnvelope envelopes[NUM_OPERATORS];
|
||||
AudioMixer4 outputMixer;
|
||||
FMPatch *patch;
|
||||
bool playing;
|
||||
} FMVoice;
|
||||
|
||||
/** FMOperatorWiring outputs AudioConnection initializers to wire one FM Operator
|
||||
|
|
32
uilleann.ino
32
uilleann.ino
|
@ -112,6 +112,18 @@ void setup() {
|
|||
AudioProcessorUsageMaxReset();
|
||||
AudioMemoryUsageMaxReset();
|
||||
|
||||
// Turn on drones
|
||||
for (int i=0; i<3; i++) {
|
||||
FMVoiceLoadPatch(&Drones[i], &Bank[0]);
|
||||
FMVoiceNoteOn(&Drones[i], JustPitches[NOTE_D4 - 12*i] + i);
|
||||
}
|
||||
|
||||
// Turn on all mixer channels
|
||||
for (int i=0; i<4; i++) {
|
||||
mixL.gain(i, 0.5);
|
||||
mixR.gain(i, 0.6);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
debug.amplitude(0.1);
|
||||
mixL.gain(3, 0.1);
|
||||
|
@ -125,11 +137,11 @@ void setup() {
|
|||
#define BUTTON_VOLUME 25
|
||||
|
||||
#define INIT_PITCH_ADJUST 0
|
||||
#define INIT_GAIN 0.1
|
||||
#define INIT_GAIN 0.7
|
||||
#define INIT_PATCH 0
|
||||
|
||||
int16_t pitchAdjust;
|
||||
float gain;
|
||||
float chanterGain;
|
||||
int patch;
|
||||
|
||||
void updateTunables(uint8_t buttons, int note) {
|
||||
|
@ -156,22 +168,22 @@ void updateTunables(uint8_t buttons, int note) {
|
|||
// Volume adjust if playing G
|
||||
switch (buttons) {
|
||||
case 3:
|
||||
gain = INIT_GAIN;
|
||||
chanterGain = INIT_GAIN;
|
||||
break;
|
||||
case 2:
|
||||
gain = min(gain+0.005, 1.0);
|
||||
chanterGain = min(chanterGain+0.005, 1.0);
|
||||
break;
|
||||
case 1:
|
||||
gain = max(gain-0.005, 0.0);
|
||||
chanterGain = max(chanterGain-0.005, 0.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
mixL.gain(i, gain);
|
||||
mixR.gain(i, gain);
|
||||
mixL.gain(i, chanterGain);
|
||||
mixR.gain(i, chanterGain);
|
||||
}
|
||||
trellis.setPixelColor(BUTTON_VOLUME, trellis.ColorHSV(uint16_t(gain * 65535), 255, 80));
|
||||
trellis.setPixelColor(BUTTON_VOLUME, trellis.ColorHSV(uint16_t(chanterGain * 65535), 255, 80));
|
||||
|
||||
if (!note || (note == NOTE_CS5)) {
|
||||
if (buttons == 3) {
|
||||
|
@ -270,7 +282,6 @@ void loop() {
|
|||
|
||||
if (silent) {
|
||||
FMVoiceNoteOff(&Chanter);
|
||||
playing = false;
|
||||
} else {
|
||||
// Calculate pitch, and glissando pitch
|
||||
uint16_t pitch = JustPitches[note];
|
||||
|
@ -288,11 +299,10 @@ void loop() {
|
|||
pitch += diff * glissandoOpenness;
|
||||
}
|
||||
|
||||
if (playing) {
|
||||
if (Chanter.playing) {
|
||||
FMVoiceSetPitch(&Chanter, pitch);
|
||||
} else {
|
||||
FMVoiceNoteOn(&Chanter, pitch);
|
||||
}
|
||||
playing = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue