diff --git a/examples/init_midi/init_midi.ino b/examples/init_midi/init_midi.ino new file mode 100755 index 0000000..bc06942 --- /dev/null +++ b/examples/init_midi/init_midi.ino @@ -0,0 +1,22 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + Music.enableEnvelope1(); + Music.enableEnvelope2(); + + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + Music.getPreset(19); +} + +void loop() { + usbMIDI.read(); +} diff --git a/examples/init_music/init_music.ino b/examples/init_music/init_music.ino new file mode 100755 index 0000000..ac73d26 --- /dev/null +++ b/examples/init_music/init_music.ino @@ -0,0 +1,26 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + +// These guys just have to be here... + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + +// Loading a preset from EEPROM + Music.getPreset(19); + +} + +void loop() { + +// Checking for incoming MIDI to use dashboard + usbMIDI.read(); +} diff --git a/examples/sequenced_audio/sequenced_audio.ino b/examples/sequenced_audio/sequenced_audio.ino new file mode 100755 index 0000000..1287ebd --- /dev/null +++ b/examples/sequenced_audio/sequenced_audio.ino @@ -0,0 +1,55 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +// sequence ID +int s1; +// sequence step index +int indx1 = 0; +const int nbr_notes1 = 16; +const int notes1[] = {12, 24, 7, 12, 36, 12, 24, 15, 0, 12, 48, 36, 19, 24, 3, 36}; + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + + Music.enableEnvelope1(); + Music.enableEnvelope2(); + +// These guys just have to be here... + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + +// delay(5000); + + // this is the sequencer code + Sequencer.init(140); + + //Sequencer.newSequence(CALLBACK, SUBDIV); + // create new sequence and ID (s1) + s1 = Sequencer.newSequence(&s1cb, NOTE_16); + + // start sequence 1 + Sequencer.startSequence(s1); + +// Loading a preset from EEPROM + Music.getPreset(21); +} + +void loop() { + +// Checking for incoming MIDI to use dashboard + usbMIDI.read(); + Sequencer.update(); +} + +// callback function for the step sequencer + +void s1cb() { + Music.noteOn(notes1[indx1++] + 24, 127); + if(indx1 >= nbr_notes1) indx1 = 0; +} diff --git a/examples/sequenced_audio2/sequenced_audio2.ino b/examples/sequenced_audio2/sequenced_audio2.ino new file mode 100755 index 0000000..00b4c07 --- /dev/null +++ b/examples/sequenced_audio2/sequenced_audio2.ino @@ -0,0 +1,67 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +// sequence ID +int s1, s2; +// sequence step index +int indx1 = 0; +int indx2 = 0; +const int nbr_notes1 = 16; +const int nbr_steps2 = 8; +const int notes1[] = {12, 24, 7, 12, 36, 12, 24, 15, 0, 12, 48, 36, 19, 24, 3, 36}; +const int midiCC[] = {8, 8, 11, 21, 21, 11, 21, 31, 8}; +const int midiValue[] = {0, 80, 68, 68, 68, 72, 72, 72, 0}; + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + + Music.enableEnvelope1(); + Music.enableEnvelope2(); + +// These guys just have to be here... + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + +// delay(5000); + + // this is the sequencer code + Sequencer.init(120); + + //Sequencer.newSequence(CALLBACK, SUBDIV); + // create new sequence and ID (s1) + s1 = Sequencer.newSequence(&s1cb, NOTE_16); + s2 = Sequencer.newSequence(&s2cb, NOTE_32); + + // start sequence 1 + Sequencer.startSequence(s1); + Sequencer.startSequence(s2); + +// Loading a preset from EEPROM + Music.getPreset(20); +} + +void loop() { + +// Checking for incoming MIDI to use dashboard + usbMIDI.read(); + Sequencer.update(); +} + +// callback function for the step sequencer + +void s1cb() { + Music.noteOn(notes1[indx1++] + 24, 127); + if(indx1 >= nbr_notes1) indx1 = 0; +} + +void s2cb() { + Midi.controller(MIDI_CHANNEL - 1, midiCC[indx2], midiValue[indx2]); + indx2++; + if(indx2 >= nbr_steps2) indx2 = 0; +} diff --git a/examples/sequenced_audio3/sequenced_audio3.ino b/examples/sequenced_audio3/sequenced_audio3.ino new file mode 100755 index 0000000..7c1fd0c --- /dev/null +++ b/examples/sequenced_audio3/sequenced_audio3.ino @@ -0,0 +1,85 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +// sequence ID +int s1, s2, s3; +// sequence step index +int indx1 = 0; +int indx2 = 0; +int indx3 = 0; +const int nbr_steps1 = 16; +const int nbr_steps2 = 8; +const int nbr_steps3 = 15; +const int nbr_steps4 = 4; +const int notes1[] = {12, 24, 7, 15, 36, 12, 24, 15, 0, 12, 48, 36, 19, 24, 3, 36}; +const int notes2[] = {0, 7, 15, 24, 12, 19, 3, 24}; +const int midiCC2[] = {8, 8, 11, 21, 31, 11, 21, 31, 8}; +const int midiValue2[] = {0, 80, 68, 68, 68, 72, 72, 72, 0}; +const int midiCC3[] = {14, 24, 34, 14, 34, 24, 14, 34, 24, 14, 34, 14, 24, 14, 24, 34}; +const int midiValue3[] = {1, 2, 4, 2, 1, 4, 2, 1, 4, 2, 1, 4, 2, 2, 1, 4}; +const int midiCC4[] = {11, 11, 11, 11}; +const int midiValue4[] = {64, 67, 71, 76}; + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + + Music.enableEnvelope1(); + Music.enableEnvelope2(); + +// These guys just have to be here... + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + +// delay(5000); + + // this is the sequencer code + Sequencer.init(112); + + //Sequencer.newSequence(CALLBACK, SUBDIV); + // create new sequence and ID (s1) + s1 = Sequencer.newSequence(&s1cb, NOTE_8); + s2 = Sequencer.newSequence(&s2cb, NOTE_32); + s3 = Sequencer.newSequence(&s3cb, NOTE_96); + + // start sequence 1 + Sequencer.startSequence(s1); +// Sequencer.startSequence(s2); + Sequencer.startSequence(s3); + +// Loading a preset from EEPROM + Music.getPreset(19); + Music.setGain2(0.0); + Music.setGain3(0.0); +} + +void loop() { + +// Checking for incoming MIDI to use dashboard + usbMIDI.read(); + Sequencer.update(); +} + +// callback function for the step sequencer + +void s1cb() { + Music.noteOn(notes1[indx1++] + 48, 127); + if(indx1 >= nbr_steps1) indx1 = 0; +} + +void s2cb() { + if(indx2 < nbr_steps2) Midi.controller(MIDI_CHANNEL - 1, midiCC2[indx2], midiValue2[indx2]); + indx2++; + if(indx2 >= nbr_steps2) indx2 = 0; +} + +void s3cb() { + if(indx3 < nbr_steps4) Midi.controller(MIDI_CHANNEL - 1, midiCC4[indx3], midiValue4[indx3]); + indx3++; + if(indx3 >= nbr_steps4) indx3 = 0; +} diff --git a/examples/sequenced_audio4/sequenced_audio4.ino b/examples/sequenced_audio4/sequenced_audio4.ino new file mode 100755 index 0000000..2469ba5 --- /dev/null +++ b/examples/sequenced_audio4/sequenced_audio4.ino @@ -0,0 +1,73 @@ +#define MIDI_CHANNEL 1 + +#include +#include +#include + +// sequence ID +int s1, s2; +// sequence step index +int indx1 = 0; +int indx2 = 0; +int indx3 = 0; +const int nbr_notes1 = 16; +const int nbr_notes2 = 8; +const int nbr_notes3 = 32; +const int notes1[] = {12, 24, 7, 12, 36, 12, 24, 15, 0, 12, 48, 36, 19, 24, 3, 36}; + +void setup() { + + // We initialise the sound engine by calling Music.init() which outputs a tone + Music.init(); + + Music.enableEnvelope1(); + Music.enableEnvelope2(); + +// These guys just have to be here... + usbMIDI.setHandleNoteOff(OnNoteOff); + usbMIDI.setHandleNoteOn(OnNoteOn); + usbMIDI.setHandleControlChange(OnControlChange); + +// delay(5000); + + // this is the sequencer code + Sequencer.init(128); + + //Sequencer.newSequence(CALLBACK, SUBDIV); + // create new sequence and ID (s1) + s1 = Sequencer.newSequence(&s1cb, NOTE_8); + s2 = Sequencer.newSequence(&s2cb, NOTE_6); + + // start sequence 1 + Sequencer.startSequence(s1); + Sequencer.startSequence(s2); + +// Loading a preset from EEPROM + Music.getPreset(20); + Music.setPortamento(124); +} + +void loop() { + +// Checking for incoming MIDI to use dashboard + usbMIDI.read(); + Sequencer.update(); +} + +// callback function for the step sequencer + +void s1cb() { + Music.noteOn(notes1[indx1++] + 36, 127); + if(indx2 >= nbr_notes1) indx1 = 0; + indx3++; + if(indx3 >= nbr_notes3) { + indx1 = 0; + indx2 = 0; + indx3 = 0; + } +} + +void s2cb() { + Music.noteOn(notes1[indx1++] + 48, 127); + if(indx1 >= nbr_notes2) indx2 = 0; +}