diff --git a/.DS_Store b/.DS_Store index 5b7b974..ed2944b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Software/CFO/.DS_Store b/Software/Arduino/CFO/.DS_Store similarity index 100% rename from Software/CFO/.DS_Store rename to Software/Arduino/CFO/.DS_Store diff --git a/Software/CFO/CFOMidi.h b/Software/Arduino/CFO/CFOMidi.h similarity index 100% rename from Software/CFO/CFOMidi.h rename to Software/Arduino/CFO/CFOMidi.h diff --git a/Software/CFO/CFOMusic.cpp b/Software/Arduino/CFO/CFOMusic.cpp similarity index 100% rename from Software/CFO/CFOMusic.cpp rename to Software/Arduino/CFO/CFOMusic.cpp diff --git a/Software/CFO/CFOMusic.h b/Software/Arduino/CFO/CFOMusic.h similarity index 100% rename from Software/CFO/CFOMusic.h rename to Software/Arduino/CFO/CFOMusic.h diff --git a/Software/CFO/CFOWavetable.h b/Software/Arduino/CFO/CFOWavetable.h similarity index 100% rename from Software/CFO/CFOWavetable.h rename to Software/Arduino/CFO/CFOWavetable.h diff --git a/Software/CFO/CFOmidi.cpp b/Software/Arduino/CFO/CFOmidi.cpp similarity index 100% rename from Software/CFO/CFOmidi.cpp rename to Software/Arduino/CFO/CFOmidi.cpp diff --git a/Software/Example code/Basic_MIDI/Basic_MIDI.ino b/Software/Arduino/Example code/Basic_MIDI/Basic_MIDI.ino similarity index 100% rename from Software/Example code/Basic_MIDI/Basic_MIDI.ino rename to Software/Arduino/Example code/Basic_MIDI/Basic_MIDI.ino diff --git a/Software/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino b/Software/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino similarity index 100% rename from Software/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino rename to Software/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino diff --git a/Software/Example code/Minimal/Minimal.ino b/Software/Arduino/Example code/Minimal/Minimal.ino similarity index 100% rename from Software/Example code/Minimal/Minimal.ino rename to Software/Arduino/Example code/Minimal/Minimal.ino diff --git a/Software/Example code/Repeating_note_with_envelope/Repeating_note_with_envelope.ino b/Software/Arduino/Example code/Repeating_note_with_envelope/Repeating_note_with_envelope.ino similarity index 100% rename from Software/Example code/Repeating_note_with_envelope/Repeating_note_with_envelope.ino rename to Software/Arduino/Example code/Repeating_note_with_envelope/Repeating_note_with_envelope.ino diff --git a/Software/Example code/Spaghetti_tones/Spaghetti_tones.ino b/Software/Arduino/Example code/Spaghetti_tones/Spaghetti_tones.ino similarity index 100% rename from Software/Example code/Spaghetti_tones/Spaghetti_tones.ino rename to Software/Arduino/Example code/Spaghetti_tones/Spaghetti_tones.ino diff --git a/Software/Example code/Up_and_down/Up_and_down.ino b/Software/Arduino/Example code/Up_and_down/Up_and_down.ino similarity index 100% rename from Software/Example code/Up_and_down/Up_and_down.ino rename to Software/Arduino/Example code/Up_and_down/Up_and_down.ino diff --git a/Software/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino b/Software/Arduino/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino similarity index 100% rename from Software/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino rename to Software/Arduino/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino diff --git a/Software/Example code/Up_and_down__square/Up_and_down__square.ino b/Software/Arduino/Example code/Up_and_down__square/Up_and_down__square.ino similarity index 100% rename from Software/Example code/Up_and_down__square/Up_and_down__square.ino rename to Software/Arduino/Example code/Up_and_down__square/Up_and_down__square.ino diff --git a/Software/Arduino/README b/Software/Arduino/README new file mode 100644 index 0000000..6a7eb77 --- /dev/null +++ b/Software/Arduino/README @@ -0,0 +1,9 @@ +CFO Music and MIDI library + +Work in progress + +Copy whole CFO folder to your "libraries" folder in your Arduino sketch folder. + +See example code in examples folder for utilizing the library. + +I am not 100% everything will work with the insects yet, but we'll see soon enough. \ No newline at end of file diff --git a/Software/Processing/IACMidi2Serial/IACMidi2Serial.pde b/Software/Processing/IACMidi2Serial/IACMidi2Serial.pde new file mode 100644 index 0000000..0d8f3fc --- /dev/null +++ b/Software/Processing/IACMidi2Serial/IACMidi2Serial.pde @@ -0,0 +1,142 @@ +import rwmidi.*; +import processing.serial.*; + +MidiInput input; +//MidiOutput output; //to be implemented later + +Serial port0; + +int defaultMidiChannel = 9; + +void setup() { + + size(128,128); + smooth(); + background(0); + + println("print MIDI input devices:"); + println(RWMidi.getInputDeviceNames()); + input = RWMidi.getInputDevices()[0].createInput(this); + + //println("print MIDI ouput devices:"); + //println(RWMidi.getOutputDeviceNames()); + //output = RWMidi.getOutputDevices()[0].createOutput(); // later + + println(Serial.list()); + port0 = new Serial(this, Serial.list()[0], 115200); + +} + + +void draw() { + + if(port0.available() > 0) { + //int val = port0.read(); + //float val = float(port0.read()); + int val = port0.read(); + println(val); + } + + +} + +void keyPressed() { + + if(key=='b' || key=='B') { + sendNoteOn(byte(defaultMidiChannel), (byte)36, (byte)0x7F); + } + if(key=='s' || key=='S') { + sendNoteOn(byte(defaultMidiChannel), (byte)38, (byte)0x7F); + } + if(key=='i' || key=='I') { + sendNoteOn(byte(defaultMidiChannel), (byte)42, (byte)0x7F); + } + if(key=='o' || key=='O') { + sendNoteOn(byte(defaultMidiChannel), (byte)44, (byte)0x7F); + } + +} + +void keyReleased() { + + if(key=='b' || key=='B') { + sendNoteOff(byte(defaultMidiChannel), (byte)0x00, (byte)0x7F); + } + if(key=='s' || key=='S') { + sendNoteOff(byte(defaultMidiChannel), (byte)0x01, (byte)0x7F); + } + if(key=='i' || key=='I') { + sendNoteOff(byte(defaultMidiChannel), (byte)0x02, (byte)0x7F); + } + if(key=='o' || key=='O') { + sendNoteOff(byte(defaultMidiChannel), (byte)0x03, (byte)0x7F); + } +} + +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(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); + byte endMessage = byte(0xFF); // not standard midi!!!! + + port0.write(noteOn); + port0.write(pitch); + port0.write(velocity); + port0.write(endMessage); + println('\n' + hex(noteOn) + " " + hex(pitch) + " " + hex(velocity) + " " + hex(endMessage)); + +} + +void sendNoteOff(byte channel, byte pitch, byte velocity) { + + byte noteOff = byte(0x80 | channel); + byte endMessage = byte(0xFF); // not standard midi!!!! + + port0.write(noteOff); + port0.write(pitch); + port0.write(velocity); + port0.write(endMessage); + println('\n' + hex(noteOff) + " " + hex(pitch) + " " + hex(velocity) + " " + hex(endMessage)); + +} + +void sendControlChange(byte channel, byte CC, byte value) { + + byte controlChange = byte(0xB0 | channel); + byte endMessage = byte(0xFF); // Not standard MIDI!!!! + + port0.write(controlChange); + port0.write(CC); + port0.write(value); + port0.write(endMessage); + println('\n' + hex(controlChange) + " " + hex(CC) + " " + hex(value) + " " + hex(endMessage)); + +} diff --git a/Software/README b/Software/README index 6a7eb77..b59924a 100644 --- a/Software/README +++ b/Software/README @@ -1,9 +1,15 @@ -CFO Music and MIDI library +Libraries and sketches for using and running the CFO synth and MIDI library for Arduino. Work in progress -Copy whole CFO folder to your "libraries" folder in your Arduino sketch folder. +From the Arduino folder here, copy whole CFO folder to your "libraries" folder in your Arduino sketch folder. +(on Mac it's typically ~/Documents/Arduino/Libraries/) -See example code in examples folder for utilizing the library. +See example code in the Arduino/examples folder for utilizing the library. + +In order to use MIDI you should use the IACMidi2Serial sketch in the processing folder (To get this to run you need to install Ruin & Wesen's MIDI library for processing. Look for RWMidi here: http://ruinwesen.com/files). + +Once the sketch is running you should be able to send note and controller messages from your DAW of choice to the IAC MIDI driver. The IACMidi2Serial sketch only listens to port 1 (the first instance of the IAC driver) but you can modify that in the sketch yourself. +The sketch then sends that MIDI data (slightly formatted) to the serial port which the (mini)CFO will read and act upon :) I am not 100% everything will work with the insects yet, but we'll see soon enough. \ No newline at end of file