diff --git a/software/apps/Music/Basic_MIDI/Basic_MIDI.ino b/software/apps/Music/Basic_MIDI/Basic_MIDI.ino deleted file mode 100644 index 4b2d95a..0000000 --- a/software/apps/Music/Basic_MIDI/Basic_MIDI.ino +++ /dev/null @@ -1,39 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include -#include - -// variables for this sketch - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // We initialize the MIDI engine by calling Midi.init() - Midi.init(); - - // Choosing the sine wave oscillator (optional since this is already the default). - Music.setSaw(); - - // Detuning the three oscillators heavily to create more movement in the sound. - Music.setDetune(0.01); - - // Enabling envelope, otherwise the synth would just play constant tones. - Music.enableEnvelope(); - -} - -void loop() { - - // The MIDI must be used with the external - // "IAC2Serial.pde" Processing sketch. - Midi.checkMidi(); - -} - diff --git a/software/apps/Music/Minimal/Minimal.ino b/software/apps/Music/Minimal/Minimal.ino deleted file mode 100644 index a36503a..0000000 --- a/software/apps/Music/Minimal/Minimal.ino +++ /dev/null @@ -1,21 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -void setup() { - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - Music.setSine(); - -} - -void loop() { - -} - diff --git a/software/apps/Music/Music_Controls/Controller_Functions.pde b/software/apps/Music/Music_Controls/Controller_Functions.pde new file mode 100644 index 0000000..7f80226 --- /dev/null +++ b/software/apps/Music/Music_Controls/Controller_Functions.pde @@ -0,0 +1,259 @@ +String[] knobName = {"FREQ1", + "SEMI1", + "DETUNE1", + "GAIN1", + "WAVE1", + "FREQ2", + "SEMI2", + "DETUNE2", + "GAIN2", + "WAVE2", + "FREQ3", + "SEMI3", + "DETUNE3", + "GAIN3", + "WAVE3", + "ATTACK", + "DECAY", + "SUSTAIN", + "RELEASE", + "DETUNE_ALL", + "WAVE_ALL" + }; + +String[] waveform = {"SINE", + "SQUARE", + "PULSE", + "TRIANGLE", + "SAW", + "FUZZ", + "DIGI1", + "DIGI2", + "DIGI3", + "DIGI4", + "NOISE", + "DIGI6", + "TAN1", + "TAN2", + "TAN3", + "TAN4" + }; + +byte[] knobMidiCC = {10,11,12,13,14,20,21,22,23,24,30,31,32,33,34,114,115,116,117,4,5}; + + +void freq1(int val) +{ + val = (int)val; + int knob = 0; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + //(2^((p-69)/12))*440 + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi1(int val) +{ + val = (int)val; + int knob = 1; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune1(int val) +{ + val = (int)val; + int knob = 2; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain1(int val) +{ + val = (int)val; + int knob = 3; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave1(int val) +{ + val = (int)val; + int knob = 4; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void freq2(int val) +{ + val = (int)val; + int knob = 5; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + //(2^((p-69)/12))*440 + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi2(int val) +{ + val = (int)val; + int knob = 6; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune2(int val) +{ + val = (int)val; + int knob = 7; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain2(int val) +{ + val = (int)val; + int knob = 8; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave2(int val) +{ + val = (int)val; + int knob = 9; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void freq3(int val) +{ + val = (int)val; + int knob = 10; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi3(int val) +{ + val = (int)val; + int knob = 11; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune3(int val) +{ + val = (int)val; + int knob = 12; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain3(int val) +{ + val = (int)val; + int knob = 13; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave3(int val) +{ + val = (int)val; + int knob = 14; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void attack(int val) +{ + val = (int)val; + int knob = 15; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void decay(int val) +{ + val = (int)val; + int knob = 16; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void sustain(int val) +{ + val = (int)val; + int knob = 17; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void release(int val) +{ + val = (int)val; + int knob = 18; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + + diff --git a/software/apps/Music/Music_Controls/Music_Controls.pde b/software/apps/Music/Music_Controls/Music_Controls.pde new file mode 100644 index 0000000..5ff2dba --- /dev/null +++ b/software/apps/Music/Music_Controls/Music_Controls.pde @@ -0,0 +1,102 @@ +import controlP5.*; +import processing.serial.*; + +ControlP5 controlP5; + +Serial port0; + +boolean printChange = true; + +int defaultMidiChannel = 9; + +int backgroundColor = color(0,0,0); +int knobColor = color(235,103,295); + +int numKnobs = 24; +int[] knobValue = new int[numKnobs]; + +int posX = 20; +int posY = 40; +int posW = 60; +int posH = 60; +int knobS = 40; + + +void setup() { + + size(400,400); + smooth(); + background(0); + + controlP5 = new ControlP5(this); + PFont p = createFont("Georgia",12); + controlP5.setControlFont(p,12); + controlP5.setColorLabel(color(255,128)); + + Textlabel labelFreq = controlP5.addTextlabel("freqLabel","FREQ",posX+posW*0+3,posY-20); + Textlabel labelSemi = controlP5.addTextlabel("semiLabel","SEMI",posX+posW*1+4,posY-20); + Textlabel labelDetune = controlP5.addTextlabel("detuneLabel","DETUNE",posX+posW*2-6,posY-20); + Textlabel labelGain = controlP5.addTextlabel("gainLabel","GAIN",posX+posW*3+4,posY-20); + Textlabel labelWave = controlP5.addTextlabel("waveLabel","WAVE",posX+posW*4+2,posY-20); + + Textlabel labelAttack = controlP5.addTextlabel("attackLabel","A",posX+16+posW*0,posY+posH*4-20); + Textlabel labelDecay = controlP5.addTextlabel("decayLabel","D",posX+16+posW*1,posY+posH*4-20); + Textlabel labelsustain = controlP5.addTextlabel("sustainLabel","S",posX+16+posW*2,posY+posH*4-20); + Textlabel labelReleasek = controlP5.addTextlabel("releaseLabel","R",posX+16+posW*3,posY+posH*4-20); + + Knob freq1 = controlP5.addKnob("freq1", 0,127,64, posX+posW*0,posY+posH*0,knobS); + Knob semi1 = controlP5.addKnob("semi1", -24,24,0, posX+posW*1,posY+posH*0,knobS); + Knob detune1 = controlP5.addKnob("detune1",0,127,64, posX+posW*2,posY+posH*0,knobS); + Knob gain1 = controlP5.addKnob("gain1", 0,127,127, posX+posW*3,posY+posH*0,knobS); + Knob wave1 = controlP5.addKnob("wave1", 0,15,0, posX+posW*4,posY+posH*0,knobS); + + Knob freq2 = controlP5.addKnob("freq2", 0,127,64, posX+posW*0,posY+posH*1,knobS); + Knob semi2 = controlP5.addKnob("semi2", -24,24,0, posX+posW*1,posY+posH*1,knobS); + Knob detune2 = controlP5.addKnob("detune2",0,127,64, posX+posW*2,posY+posH*1,knobS); + Knob gain2 = controlP5.addKnob("gain2", 0,127,127, posX+posW*3,posY+posH*1,knobS); + Knob wave2 = controlP5.addKnob("wave2", 0,15,0, posX+posW*4,posY+posH*1,knobS); + + Knob freq3 = controlP5.addKnob("freq3", 0,127,64, posX+posW*0,posY+posH*2,knobS); + Knob semi3 = controlP5.addKnob("semi3", -24,24,0, posX+posW*1,posY+posH*2,knobS); + Knob detune3 = controlP5.addKnob("detune3",0,127,64, posX+posW*2,posY+posH*2,knobS); + Knob gain3 = controlP5.addKnob("gain3", 0,127,127, posX+posW*3,posY+posH*2,knobS); + Knob wave3 = controlP5.addKnob("wave3", 0,15,0, posX+posW*4,posY+posH*2,knobS); + + Knob attack = controlP5.addKnob("attack", 0,127,0, posX+posW*0, posY+posH*4, knobS); + Knob decay = controlP5.addKnob("decay", 0,127,64, posX+posW*1, posY+posH*4, knobS); + Knob sustain = controlP5.addKnob("sustain",0,127,64, posX+posW*2, posY+posH*4, knobS); + Knob release = controlP5.addKnob("release",0,127,64, posX+posW*3, posY+posH*4, knobS); + + println(Serial.list()); + port0 = new Serial(this, Serial.list()[0], 9600); + + for(int i=0; i 0) { + //int val = port0.read(); + //float val = float(port0.read()); + char val = char(port0.read()); + println(val); + } + +} + + +void sendControlChange(byte channel, byte CC, byte value) { + + byte controlChange = byte(0xB0 | channel); + + port0.write(controlChange); + port0.write(CC); + port0.write(value); + +} diff --git a/software/apps/Music/Music_Controls_RW/Controller_Functions.pde b/software/apps/Music/Music_Controls_RW/Controller_Functions.pde new file mode 100644 index 0000000..7f80226 --- /dev/null +++ b/software/apps/Music/Music_Controls_RW/Controller_Functions.pde @@ -0,0 +1,259 @@ +String[] knobName = {"FREQ1", + "SEMI1", + "DETUNE1", + "GAIN1", + "WAVE1", + "FREQ2", + "SEMI2", + "DETUNE2", + "GAIN2", + "WAVE2", + "FREQ3", + "SEMI3", + "DETUNE3", + "GAIN3", + "WAVE3", + "ATTACK", + "DECAY", + "SUSTAIN", + "RELEASE", + "DETUNE_ALL", + "WAVE_ALL" + }; + +String[] waveform = {"SINE", + "SQUARE", + "PULSE", + "TRIANGLE", + "SAW", + "FUZZ", + "DIGI1", + "DIGI2", + "DIGI3", + "DIGI4", + "NOISE", + "DIGI6", + "TAN1", + "TAN2", + "TAN3", + "TAN4" + }; + +byte[] knobMidiCC = {10,11,12,13,14,20,21,22,23,24,30,31,32,33,34,114,115,116,117,4,5}; + + +void freq1(int val) +{ + val = (int)val; + int knob = 0; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + //(2^((p-69)/12))*440 + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi1(int val) +{ + val = (int)val; + int knob = 1; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune1(int val) +{ + val = (int)val; + int knob = 2; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain1(int val) +{ + val = (int)val; + int knob = 3; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave1(int val) +{ + val = (int)val; + int knob = 4; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void freq2(int val) +{ + val = (int)val; + int knob = 5; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + //(2^((p-69)/12))*440 + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi2(int val) +{ + val = (int)val; + int knob = 6; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune2(int val) +{ + val = (int)val; + int knob = 7; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain2(int val) +{ + val = (int)val; + int knob = 8; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave2(int val) +{ + val = (int)val; + int knob = 9; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void freq3(int val) +{ + val = (int)val; + int knob = 10; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + (int)(pow(2,(knobValue[knob]-69)/12.0)*440) + " Hz"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void semi3(int val) +{ + val = (int)val; + int knob = 11; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + int semi =(knobValue[knob]+24)*2+16; + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)semi); + } +} + +void detune3(int val) +{ + val = (int)val; + int knob = 12; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void gain3(int val) +{ + val = (int)val; + int knob = 13; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void wave3(int val) +{ + val = (int)val; + int knob = 14; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob] + " (" + waveform[knobValue[knob]] + ")"); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)(knobValue[knob]*8)); + } +} + +void attack(int val) +{ + val = (int)val; + int knob = 15; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void decay(int val) +{ + val = (int)val; + int knob = 16; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void sustain(int val) +{ + val = (int)val; + int knob = 17; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + +void release(int val) +{ + val = (int)val; + int knob = 18; + if(knobValue[knob] != val) { + knobValue[knob] = val; + if(printChange) println(knobName[knob] + " is: " + knobValue[knob]); + sendControlChange((byte)0, (byte)knobMidiCC[knob], (byte)knobValue[knob]); + } +} + + diff --git a/software/apps/Music/Music_Controls_RW/Music_Controls_RW.pde b/software/apps/Music/Music_Controls_RW/Music_Controls_RW.pde new file mode 100644 index 0000000..521f08b --- /dev/null +++ b/software/apps/Music/Music_Controls_RW/Music_Controls_RW.pde @@ -0,0 +1,166 @@ +//import oscP5.*; +//import netP5.*; +import controlP5.*; +import rwmidi.*; // watch out for this +import processing.serial.*; + +ControlP5 controlP5; + +MidiInput input; + +Serial port0; + +boolean printChange = true; + +int defaultMidiChannel = 9; + +int backgroundColor = color(0,0,0); +int knobColor = color(235,103,295); + +int numKnobs = 24; +int[] knobValue = new int[numKnobs]; + +int posX = 20; +int posY = 40; +int posW = 60; +int posH = 60; +int knobS = 40; + + +void setup() { + + size(400,400); + smooth(); + background(0); + + controlP5 = new ControlP5(this); + PFont p = createFont("Georgia",12); + controlP5.setControlFont(p,12); + controlP5.setColorLabel(color(255,128)); + + Textlabel labelFreq = controlP5.addTextlabel("freqLabel","FREQ",posX+posW*0+3,posY-20); + Textlabel labelSemi = controlP5.addTextlabel("semiLabel","SEMI",posX+posW*1+4,posY-20); + Textlabel labelDetune = controlP5.addTextlabel("detuneLabel","DETUNE",posX+posW*2-6,posY-20); + Textlabel labelGain = controlP5.addTextlabel("gainLabel","GAIN",posX+posW*3+4,posY-20); + Textlabel labelWave = controlP5.addTextlabel("waveLabel","WAVE",posX+posW*4+2,posY-20); + + Textlabel labelAttack = controlP5.addTextlabel("attackLabel","A",posX+16+posW*0,posY+posH*4-20); + Textlabel labelDecay = controlP5.addTextlabel("decayLabel","D",posX+16+posW*1,posY+posH*4-20); + Textlabel labelsustain = controlP5.addTextlabel("sustainLabel","S",posX+16+posW*2,posY+posH*4-20); + Textlabel labelReleasek = controlP5.addTextlabel("releaseLabel","R",posX+16+posW*3,posY+posH*4-20); + + Knob freq1 = controlP5.addKnob("freq1", 0,127,64, posX+posW*0,posY+posH*0,knobS); + Knob semi1 = controlP5.addKnob("semi1", -24,24,0, posX+posW*1,posY+posH*0,knobS); + Knob detune1 = controlP5.addKnob("detune1",0,127,64, posX+posW*2,posY+posH*0,knobS); + Knob gain1 = controlP5.addKnob("gain1", 0,127,127, posX+posW*3,posY+posH*0,knobS); + Knob wave1 = controlP5.addKnob("wave1", 0,15,0, posX+posW*4,posY+posH*0,knobS); + + Knob freq2 = controlP5.addKnob("freq2", 0,127,64, posX+posW*0,posY+posH*1,knobS); + Knob semi2 = controlP5.addKnob("semi2", -24,24,0, posX+posW*1,posY+posH*1,knobS); + Knob detune2 = controlP5.addKnob("detune2",0,127,64, posX+posW*2,posY+posH*1,knobS); + Knob gain2 = controlP5.addKnob("gain2", 0,127,127, posX+posW*3,posY+posH*1,knobS); + Knob wave2 = controlP5.addKnob("wave2", 0,15,0, posX+posW*4,posY+posH*1,knobS); + + Knob freq3 = controlP5.addKnob("freq3", 0,127,64, posX+posW*0,posY+posH*2,knobS); + Knob semi3 = controlP5.addKnob("semi3", -24,24,0, posX+posW*1,posY+posH*2,knobS); + Knob detune3 = controlP5.addKnob("detune3",0,127,64, posX+posW*2,posY+posH*2,knobS); + Knob gain3 = controlP5.addKnob("gain3", 0,127,127, posX+posW*3,posY+posH*2,knobS); + Knob wave3 = controlP5.addKnob("wave3", 0,15,0, posX+posW*4,posY+posH*2,knobS); + + Knob attack = controlP5.addKnob("attack", 0,127,0, posX+posW*0, posY+posH*4, knobS); + Knob decay = controlP5.addKnob("decay", 0,127,64, posX+posW*1, posY+posH*4, knobS); + Knob sustain = controlP5.addKnob("sustain",0,127,64, posX+posW*2, posY+posH*4, knobS); + Knob release = controlP5.addKnob("release",0,127,64, posX+posW*3, posY+posH*4, knobS); + + + println("print MIDI input devices:"); + println(RWMidi.getInputDeviceNames()); + input = RWMidi.getInputDevices()[0].createInput(this); + + println(Serial.list()); + port0 = new Serial(this, Serial.list()[0], 9600); + + for(int i=0; i 0) { + //int val = port0.read(); + //float val = float(port0.read()); + char val = char(port0.read()); + println(val); + } + +} + + +void noteOnReceived(Note note) { + + byte channel = byte(note.getChannel()); + byte pitch = byte(note.getPitch()); + byte velocity = byte(note.getVelocity()); + + sendNoteOn(channel, pitch, velocity); + +} + +void noteOffReceived(Note note) { + + byte channel = byte(note.getChannel()); + byte pitch = byte(note.getPitch()); + byte velocity = byte(note.getVelocity()); + + sendNoteOff(channel, pitch, velocity); + +} + +void controllerChangeReceived(rwmidi.Controller controller) { + + byte channel = byte(controller.getChannel()); + byte CC = byte(controller.getCC()); + byte value = byte(controller.getValue()); + + sendControlChange(channel, CC, value); +} + + +void sendNoteOn(byte channel, byte pitch, byte velocity) { + + byte noteOn = byte(0x90 | channel); + + port0.write(noteOn); + port0.write(pitch); + port0.write(velocity); + //println('\n' + hex(noteOn) + " " + hex(pitch) + " " + hex(velocity)); + +} + +void sendNoteOff(byte channel, byte pitch, byte velocity) { + + byte noteOff = byte(0x80 | channel); + + port0.write(noteOff); + port0.write(pitch); + port0.write(velocity); + //println('\n' + hex(noteOff) + " " + hex(pitch) + " " + hex(velocity)); + +} + +void sendControlChange(byte channel, byte CC, byte value) { + + byte controlChange = byte(0xB0 | channel); + + port0.clear(); + port0.write(controlChange); + port0.write(CC); + port0.write(value); + //println('\n' + hex(controlChange) + " " + hex(CC) + " " + hex(value)); + +} diff --git a/software/apps/Music/Repeating_note_with_envelope/Repeating_note_with_envelope.ino b/software/apps/Music/Repeating_note_with_envelope/Repeating_note_with_envelope.ino deleted file mode 100644 index 81ecd55..0000000 --- a/software/apps/Music/Repeating_note_with_envelope/Repeating_note_with_envelope.ino +++ /dev/null @@ -1,50 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -// variables for this sketch -boolean noteIsOn = false; -int note = 48; - -long time = 0; -long lastTime = 0; -long beatTime = 1000; - - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // enabling the envelope lets us define an gain envelope for the synth - // without having to specify it in our loop() or physics code. - Music.enableEnvelope(); - Music.setAttack(0x0FFF); - Music.setDecay(0x0004); - Music.setSustain(0x00FF); - Music.setRelease(0x0008); - -} - -void loop() { - - // This short routine loops note over and over again - time = millis(); - if(time - lastTime > beatTime) { - if(!noteIsOn) { - Music.noteOn(note); - noteIsOn = true; - } else { - Music.noteOff(); - noteIsOn = false; - } - lastTime = time; - } - -} - diff --git a/software/apps/Music/Spaghetti_tones/Spaghetti_tones.ino b/software/apps/Music/Spaghetti_tones/Spaghetti_tones.ino deleted file mode 100644 index 5496537..0000000 --- a/software/apps/Music/Spaghetti_tones/Spaghetti_tones.ino +++ /dev/null @@ -1,64 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -// variables for this sketch -float gain = 1.0; -float c = 220; // center frequency -float f1 = 1; -float f2 = 1; -float f3 = 1; -float m1 = 1.0011; -float m2 = 1.0012; -float m3 = 1.0013; - - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // Choosing the sine wave oscillator (optional since this is already the default). - // Music.setSine(); //Sine is default so don't need this. - - // Setting the initial frequency for all three oscillators. - Music.setFrequency(c); - - // Detuning the three oscillators slightly to create movement in the sound. - Music.setDetune(0.002); - -} - -void loop() { - - // This short routine creates a - - Music.setFrequency1(c*f1); - Music.setFrequency2(c*f2); - Music.setFrequency3(c*f3); - - f1 *= m1; - f2 *= m2; - f3 *= m3; - - if(f1 > 4.0) m1 = 0.9745; - if(f2 > 4.0) m2 = 0.9852; - if(f3 > 4.0) m3 = 0.9975; - - if(f1 < 0.25) m1 = 1.0754; - if(f2 < 0.25) m2 = 1.0573; - if(f3 < 0.25) m3 = 1.0386; - - if(millis() > 10000) { - Music.setGain(gain); - gain *= 0.999; - } - - -} - diff --git a/software/apps/Music/Up_and_down/Up_and_down.ino b/software/apps/Music/Up_and_down/Up_and_down.ino deleted file mode 100644 index d48c08a..0000000 --- a/software/apps/Music/Up_and_down/Up_and_down.ino +++ /dev/null @@ -1,62 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -// variables for this sketch -boolean noteIsOn = false; -int n = 0; -int dir = 1; -int rootNote = 48; -int note[] = {0,2,3,5,7,9,10,12,14}; - -long time = 0; -long lastTime = 0; -long beatTime = 100; - - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // enabling the envelope lets us define an gain envelope for the synth - // without having to specify it in our loop() or physics code. - Music.enableEnvelope(); - Music.setAttack(0x00FF); - Music.setDecay(0x0008); - Music.setSustain(0x00FF); - Music.setRelease(0x0008); - -} - -void loop() { - - // This short routine loops note over and over again - time = millis(); - if(time - lastTime > beatTime) { - if(!noteIsOn) { - Music.noteOn(rootNote+note[n]); - noteIsOn = true; - n = n + dir; - if(n > 7) - { - dir = -1; - } - else if(n < 1) - { - dir = 1; - } - } else { - Music.noteOff(); - noteIsOn = false; - } - lastTime = time; - } - -} - diff --git a/software/apps/Music/Up_and_down/sketch_jun26c/sketch_jun26c.ino b/software/apps/Music/Up_and_down/sketch_jun26c/sketch_jun26c.ino deleted file mode 100644 index 12ba038..0000000 --- a/software/apps/Music/Up_and_down/sketch_jun26c/sketch_jun26c.ino +++ /dev/null @@ -1,62 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -// variables for this sketch -boolean noteIsOn = false; -int n = 0; -int dir = 1; -int rootNote = 48; -int note[] = {0,2,3,5,7,9,10,12,14}; - -long time = 0; -long lastTime = 0; -long beatTime = 100; - - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // enabling the envelope lets us define an gain envelope for the synth - // without having to specify it in our loop() or physics code. - Music.enableEnvelope(); - Music.setAttack(8); - Music.setDecay(70); - Music.setSustain(24); - Music.setRelease(90); - -} - -void loop() { - - // This short routine loops note over and over again - time = millis(); - if(time - lastTime > beatTime) { - if(!noteIsOn) { - Music.noteOn(rootNote+note[n]); - noteIsOn = true; - n = n + dir; - if(n > 7) - { - dir = -1; - } - else if(n < 1) - { - dir = 1; - } - } else { - Music.noteOff(); - noteIsOn = false; - } - lastTime = time; - } - -} - diff --git a/software/apps/Music/Up_and_down__square/Up_and_down__square.ino b/software/apps/Music/Up_and_down__square/Up_and_down__square.ino deleted file mode 100644 index 0486f1d..0000000 --- a/software/apps/Music/Up_and_down__square/Up_and_down__square.ino +++ /dev/null @@ -1,68 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -// variables for this sketch -boolean noteIsOn = false; -int n = 0; -int dir = 1; -int rootNote = 26; -int note[] = {0,2,3,5,7,9,10,12,14}; - -long time = 0; -long lastTime = 0; -long beatTime = 100; - - -void setup() { - - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - // Choosing the square wave oscillator instead of the sine wave. - Music.setSquare(); - - // Detuning the three oscillators slightly to create movement in the sound. - Music.setDetune(0.008); - - // enabling the envelope lets us define an gain envelope for the synth - // without having to specify it in our loop() or physics code. - Music.enableEnvelope(); - Music.setAttack(8); - Music.setDecay(90); - Music.setSustain(48); - Music.setRelease(64); - -} - -void loop() { - - // This short routine loops note over and over again - time = millis(); - if(time - lastTime > beatTime) { - if(!noteIsOn) { - Music.noteOn(rootNote+note[n]); - noteIsOn = true; - n = n + dir; - if(n > 7) - { - dir = -1; - } - else if(n < 1) - { - dir = 1; - } - } else { - Music.noteOff(); - noteIsOn = false; - } - lastTime = time; - } - -} - diff --git a/software/apps/Music/appConnector/appConnector.ino b/software/apps/Music/appConnector/appConnector.ino deleted file mode 100644 index 3609c81..0000000 --- a/software/apps/Music/appConnector/appConnector.ino +++ /dev/null @@ -1,34 +0,0 @@ - -// This needs to be in all sketches at the moment -#include - -// The Music and Midi objects are automatically instantiated when the header file is included. -// Make calls to the Music and Midi objects with "Music.function(args)" and "Midi.function(args)" -// You still need to call Music.init() and Midi.init() in the setup() function below. -#include - -void setup() { - // We initialise the sound engine by calling Music.init() which outputs a tone - Music.init(); - - Music.setSquare(); - -} - -void loop() { - -} - -void serialEvent() { - while (Serial.available()) { - // get the new byte: - - - - int inChar = (int)Serial.read(); - if (inChar == '\n') { - stringComplete = true; - } - } -} -