#include "synth.h" typedef struct Pipe { FMVoice v; short patchNumber; float gain; short pixel; } Pipe; Pipe Chanter; Pipe Drones[3]; Pipe Regulators[3]; AudioMixer4 mixDrones; AudioMixer4 mixRegulators; void PipeIncPatch(Pipe *p, int inc) { // wrap int bankSize = sizeof(Bank) / sizeof(Bank[0]); p->patchNumber = (p->patchNumber + inc + bankSize) % bankSize; FMPatch *p = &Bank[p->patchNumber]; FMVoiceLoadPatch(&Chanter, p); trellis.setPixelColor(7 - i, trellis.ColorHSV(22222, 255, (p->patchNumber)?40:0)); } void pitchAdjust(int adj) { // Pitch adjust if playing A if (!note || (note == NOTE_A4)) { switch (buttons) { case 3: pitchAdjust = INIT_PITCH_ADJUST; break; case 2: pitchAdjust += 4; break; case 1: pitchAdjust -= 4; break; } } float adj = pow(2, pitchAdjust / 32768.0); setupJustPitches(NOTE_D4, PITCH_D4*adj); trellis.setPixelColor(BUTTON_PITCH, trellis.ColorHSV(uint16_t(pitchAdjust), 255, 80)); if (!note || (note == NOTE_G4)) { // Volume adjust if playing G switch (buttons) { case 3: chanterGain = INIT_GAIN; break; case 2: chanterGain = min(chanterGain+0.005, 1.0); break; case 1: chanterGain = max(chanterGain-0.005, 0.0); break; } } for (int i=0; i<3; i++) { mixL.gain(i, chanterGain); mixR.gain(i, chanterGain); } trellis.setPixelColor(BUTTON_VOLUME, trellis.ColorHSV(uint16_t(chanterGain * 65535), 255, 80)); if (!note || (note == NOTE_CS5)) { if (buttons == 3) { patch = INIT_PATCH; } else if (trellis.justPressed(BUTTON_DOWN)) { patch -= 1; } else if (trellis.justPressed(BUTTON_UP)) { patch += 1; } oled.clear(PAGE); oled.setFontType(0); oled.setCursor(0, 0); oled.print(p->name); oled.setCursor(0, 10); oled.print("Patch "); oled.print(patch); oled.display(); } }