81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
// Basic template for Sitka Instruments WS-1.0 Mozzi firmwares
|
|
|
|
#include <Mozzi.h>
|
|
#include <mozzi_midi.h> //for mtof() function
|
|
#include <MIDI.h>
|
|
|
|
//Settings
|
|
#define MIDI_CHANNEL MIDI_CHANNEL_OMNI
|
|
|
|
//Hardware Definitions
|
|
#define Knob1 A6
|
|
#define Knob2 A4
|
|
#define Knob3 A2
|
|
#define Knob4 A0
|
|
#define KnobA A5
|
|
#define KnobDR A3
|
|
#define KnobS A1
|
|
#define CVIn A7
|
|
#define GateIn 13
|
|
#define EnvSwitch 12
|
|
#define DroneSwitch 11
|
|
#define LED 5
|
|
|
|
#define MOZZI_CONTROL_RATE 128
|
|
#define MOZZI_ANALOG_READ_RESOLUTION 10
|
|
|
|
MIDI_CREATE_DEFAULT_INSTANCE();
|
|
|
|
void MIDINoteOn(byte channel, byte note, byte velocity) {
|
|
carrierFreq = mtof((int) note);
|
|
envelope.noteOn();
|
|
}
|
|
|
|
void MIDINoteOff(byte channel, byte note, byte velocity) {
|
|
envelope.noteOff();
|
|
}
|
|
|
|
void setup(){
|
|
//pinMode(LED_BUILTIN_TX,INPUT); //switch rx and tx leds of, so they don't blink on midi
|
|
//pinMode(LED_BUILTIN_RX,INPUT);
|
|
pinMode(LED, OUTPUT);
|
|
pinMode(GateIn, INPUT_PULLUP);
|
|
pinMode(EnvSwitch, INPUT_PULLUP);
|
|
pinMode(DroneSwitch, INPUT_PULLUP);
|
|
|
|
MIDI.setHandleNoteOn(MIDINoteOn);
|
|
MIDI.setHandleNoteOff(MIDINoteOff);
|
|
MIDI.begin(MIDI_CHANNEL);
|
|
|
|
startMozzi();
|
|
|
|
digitalWrite(LED, HIGH);
|
|
}
|
|
|
|
|
|
void updateControl(){
|
|
//Get Control Values
|
|
int CVInVal = mozziAnalogRead(CVIn);
|
|
int knob1Val = mozziAnalogRead(Knob1);
|
|
int knob2Val = mozziAnalogRead(Knob2);
|
|
int knob3Val = mozziAnalogRead(Knob3);
|
|
int knob4Val = mozziAnalogRead(Knob4);
|
|
int knobAVal = mozziAnalogRead(KnobA);
|
|
int knobDRVal = mozziAnalogRead(KnobDR);
|
|
int knobSVal = mozziAnalogRead(KnobS);
|
|
bool droneSwitchVal = digitalRead(DroneSwitch);
|
|
bool envSwitchVal = digitalRead(EnvSwitch);
|
|
bool gateInVal = digitalRead(GateIn);
|
|
|
|
//Do all the control-related updates here
|
|
|
|
MIDI.read();
|
|
}
|
|
|
|
AudioOutput updateAudio(){
|
|
return MonoOutput::from16Bit((int) gain * aCarrier.phMod(modulation));
|
|
}
|
|
|
|
void loop(){
|
|
audioHook();
|
|
} |