From 3ea1f0b8f9eb0f15664cc3d9efae7d212944da87 Mon Sep 17 00:00:00 2001 From: Jakob Bak Date: Tue, 28 Aug 2012 23:32:27 +0200 Subject: [PATCH] updated examples folder for Arduino code --- .DS_Store | Bin 6148 -> 6148 bytes Software/.DS_Store | Bin 0 -> 6148 bytes Software/Arduino/.DS_Store | Bin 0 -> 6148 bytes Software/Arduino/CFO/CFOMidi.h | 26 +++++- Software/Arduino/CFO/CFOmidi.cpp | 53 ++++++++++- Software/Arduino/Example code/.DS_Store | Bin 0 -> 6148 bytes .../Example code/Basic_MIDI/Basic_MIDI.ino | 39 -------- .../MUSIC_LIBRARY_DOCUMENTATION.ino | 88 ------------------ .../Arduino/Example code/Minimal/Minimal.ino | 19 ---- .../Repeating_note_with_envelope.ino | 50 ---------- .../Spaghetti_tones/Spaghetti_tones.ino | 64 ------------- .../Example code/Up_and_down/Up_and_down.ino | 62 ------------ .../sketch_jun26c/sketch_jun26c.ino | 62 ------------ .../Up_and_down__square.ino | 68 -------------- .../_insect_live/_insect_live.ino | 25 +++++ .../_insect_test/_insect_test.ino | 13 +-- 16 files changed, 105 insertions(+), 464 deletions(-) create mode 100644 Software/.DS_Store create mode 100644 Software/Arduino/.DS_Store create mode 100644 Software/Arduino/Example code/.DS_Store delete mode 100644 Software/Arduino/Example code/Basic_MIDI/Basic_MIDI.ino delete mode 100644 Software/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino delete mode 100644 Software/Arduino/Example code/Minimal/Minimal.ino delete mode 100644 Software/Arduino/Example code/Repeating_note_with_envelope/Repeating_note_with_envelope.ino delete mode 100644 Software/Arduino/Example code/Spaghetti_tones/Spaghetti_tones.ino delete mode 100644 Software/Arduino/Example code/Up_and_down/Up_and_down.ino delete mode 100644 Software/Arduino/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino delete mode 100644 Software/Arduino/Example code/Up_and_down__square/Up_and_down__square.ino create mode 100644 Software/Arduino/Example code/_insect_live/_insect_live.ino diff --git a/.DS_Store b/.DS_Store index fdbd9305064457162e151e5f005089e7bdd77a5a..4d14643ddb93a8c0d817e95c7b312a2f1cda5537 100644 GIT binary patch delta 111 zcmZoMXfc@JFUrEez`)4BAi%&-&XCAZ#E_a)UR`Q$hcNVq1wX21jsfuoqU+dYO)~HJgkzN4>OgrY-Z>9%MSo4LK(vV delta 77 zcmV-T0J8stFoZCWPZa|I0003101yBGcK~4kasXvyb7O3?@dKv;0RxlU0;3c$Gb|u6 jHaC4NAbT+|Ha9FFH!wDnrUE*%%mX_Fk$}&$2MGNS<%<<< diff --git a/Software/.DS_Store b/Software/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..03b91ed631935f540f0a51edf53a6520ddc2fba1 GIT binary patch literal 6148 zcmeHK&2Jk;6o1cgo7r_gCMkuaYUx6RXsakBZQ2G3XzL_uXsKFZr%q{#S$n5s#d_Cx z)^r%uC(F(*B#K(~jaX_3ZAx^z;E2zEqALx}6Z+0dUA@oWkv`?D(y*KZ@*?GV9 z&UgR-i*0`bfCB)drZ8_)_b;OSs;!fp8BvJo905cS*SfM<3)e+w0~rGu0~?J2_3ie< zacF@LZTQ>w8`sG5L#-JGG8rHL19N@(O`H1}v)Pu#N)Y*Rw-~o0UtTCJ#obcii<;NE znCgj_v}Mt2rJl21vP7O#FUN66`l5-h1b(tqI+F(vt&BR$Q&W?qA3nUY zVp+`Mzp$N8kG(io_TF2$agPlNh&oq-Dj^sJfl7v;hT~cYU)Z^%EODKPp57fP|-VVJ)91p`%@UD=RdK|VJ zkz7c`ur<6yCSTeofJ1A{vr+xht3XAV3! z`TWb%3-!3s5K$t_k=GCxe9D<_3F`f_q^$YStBJ7uHt}ES=w-g4VqW!Ra;7OF;V&xl zbnFM00^#3zVrY0*VYmHcr4z`Y7K-_<;{3cP>mu@l=&gC0NL*$EIBN0!JI+(XyX+C$ zS{rRCub%1I!hXhoVmz0c_Gn?u;vVCD+B;z%V%)d*Cha|9Pgz`AJg>dS?3WlnW%140 zbPGksZ!^wx@ND6PrDnzvcb|Tn)`&Z9-YbJ)7y}o|um}R0a2-B^kKqQ~gso{%7|!4c=ugF{WBYp|y=-8!htk*WN7g-S?QcL{}#LDyhUBY8+r zrxNN^G*=AN=``+`IM-lLqfQ4*pG@af&Y|&zW}lP=a2vZ literal 0 HcmV?d00001 diff --git a/Software/Arduino/.DS_Store b/Software/Arduino/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..56ef54d607ff5ee3f91fda6e76d391e2d2392026 GIT binary patch literal 6148 zcmeHKK}!Nr5T2)2YZ-V6JU%*0s402qu$V@-0tF8lwd)EBn=9^$fo(1Qq5eX@qTkcZ zdk-zbqV4)JGvS@w~S|?qTl!>Gf1wEthyFuWi z3%Rvq4*W|7=-s8^0xsd&3s>J?3!cD%N0@*Q1CY>%06ZAD^Kjz&fs1AD?!+I3QK|GP zQt8aj?w)1sTe)6$H1>jdBbbf7@U}e+=IxO;aGmL$@*^jjg$-w_R&JbVh%3tP;Fp7b z&t!K;UNpSV7Z!_3`K&0bmD9K=7xj7-{aP)Kvso*f|FDjZPtLD8&U5_onrMCneSRc| z8kY7Ay&P<4Yqj@f1v|_DGr$aND+A`Fv<|klLGFtgUdl$LuW3gd)`L7?&y? zgsqV+Gr$adXMkoulsw)4tn?$)&~>8_Qi52z%RmuOs; jprfv0%%!WifT{%Jk{m?aV4@KtDEuR!Xkfz({3!!pL=#Xq literal 0 HcmV?d00001 diff --git a/Software/Arduino/CFO/CFOMidi.h b/Software/Arduino/CFO/CFOMidi.h index 609a264..d43d911 100755 --- a/Software/Arduino/CFO/CFOMidi.h +++ b/Software/Arduino/CFO/CFOMidi.h @@ -37,6 +37,9 @@ class MMidi { public: void init(); void checkMidi(); + void setChannel(uint8_t ID, uint8_t channel); + void setID(uint8_t ID); + void midiHandler(); void noteOff(uint8_t channel, uint8_t note, uint8_t vel); void noteOn(uint8_t channel, uint8_t note, uint8_t vel); @@ -45,11 +48,28 @@ public: void programChange(uint8_t channel, uint8_t number); void channelPressure(uint8_t channel, uint8_t pressure); void pitchWheel(uint8_t channel, uint8_t highBits, uint8_t lowBits); - void setChannel(uint8_t); + void sysex (uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t, + uint8_t); - -private: +private: + // ID + uint8_t cfoID; + // MIDI uint8_t data; //uint16_t midiBuffer[4]; diff --git a/Software/Arduino/CFO/CFOmidi.cpp b/Software/Arduino/CFO/CFOmidi.cpp index 4759f04..94fe9ae 100755 --- a/Software/Arduino/CFO/CFOmidi.cpp +++ b/Software/Arduino/CFO/CFOmidi.cpp @@ -83,12 +83,18 @@ void MMidi::checkMidi() } -void MMidi::setChannel(uint8_t channel) { - if(0 < channel <= 16) { - midiChannel = channel-1; +void MMidi::setChannel(uint8_t ID, uint8_t channel) { + if(ID == cfoID) { + if(1 <= channel <= 16) { + midiChannel = channel-1; + } } } +void MMidi::setID(uint8_t ID) { + cfoID = ID; +} + void MMidi::midiHandler() { @@ -136,12 +142,53 @@ void MMidi::midiHandler() { midiBuffer[1] & 0x7F, // higher bits 0-6 midiBuffer[2] & 0x7F);// lower bits 7-13 break; + case 0xF0: + sysex (midiBuffer[0] & 0x0F, // midi channel 0-16 + midiBuffer[1] & 0x7F, // higher bits 0-6 + midiBuffer[2] & 0x7F, // lower bits 7-13 + midiBuffer[3] & 0x7F, // higher bits 0-6 + midiBuffer[4] & 0x7F, // lower bits 7-13 + midiBuffer[5] & 0x7F, // higher bits 0-6 + midiBuffer[6] & 0x7F, // lower bits 7-13 + midiBuffer[7] & 0x7F, // higher bits 0-6 + midiBuffer[8] & 0x7F, // lower bits 7-13 + midiBuffer[9] & 0x7F, // higher bits 0-6 + midiBuffer[10] & 0x7F, // lower bits 7-13 + midiBuffer[11] & 0x7F, // higher bits 0-6 + midiBuffer[12] & 0x7F, // lower bits 7-13 + midiBuffer[13] & 0x7F, // higher bits 0-6 + midiBuffer[14] & 0x7F, // lower bits 7-13 + midiBuffer[15] & 0x7F);// higher bits 0-6 + break; default: break; } } +void MMidi::sysex(uint8_t val0, + uint8_t val1, + uint8_t val2, + uint8_t val3, + uint8_t val4, + uint8_t val5, + uint8_t val6, + uint8_t val7, + uint8_t val8, + uint8_t val9, + uint8_t valA, + uint8_t valB, + uint8_t valC, + uint8_t valD, + uint8_t valE, + uint8_t valF) + { + + //ADD SYSEX HANDLING HERE + +} + + void MMidi::noteOff(uint8_t channel, uint8_t note, uint8_t vel) { diff --git a/Software/Arduino/Example code/.DS_Store b/Software/Arduino/Example code/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d3e30990c509827c7bea11120990932f46cf1153 GIT binary patch literal 6148 zcmeHK%}T>S5T3176RpsTKgY#$k!maL!9yq&JPIv%u%d}6G*Ft-q!x_T_(1v$K84TY z%F`ptURDiUlx$2)?f09dx}(H1ztRhdD3aupdNmx%@72EBV#6b<5hY3Z08! z;D?h&I3D=XWvdrXT7lp7+|iYaV>cd04R@qQ&fU0&BPwo(VISj;$-W5uxOZLLNs_~A zNmlFAl1yr~GKQ7fbZXm{U3{~)_YY3a+U|YwFn!cY3jEV4+cG$V6oV|O80ke2eEUJLnKCR6~C*pcmfED<6 z3ef%_(Fq-csYbPRU_+meG@d6U!QZ5@7($n0zchJ{!BnFz z2ch1K^O!dab3+m8?bt6>ItWK2x2ymw@Lhow{aB>)|8)NS|9cTXu>!2XzfwTto2_O8 zDVei1Lypc`iGG7lMtP~m&k_vOQH;5C6z`!c!+uEtqGK@Ch&^chA)sX7h80+<0w3{n BdxQW0 literal 0 HcmV?d00001 diff --git a/Software/Arduino/Example code/Basic_MIDI/Basic_MIDI.ino b/Software/Arduino/Example code/Basic_MIDI/Basic_MIDI.ino deleted file mode 100644 index 4b2d95a..0000000 --- a/Software/Arduino/Example code/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/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino b/Software/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino deleted file mode 100644 index 3f46436..0000000 --- a/Software/Arduino/Example code/MUSIC_LIBRARY_DOCUMENTATION/MUSIC_LIBRARY_DOCUMENTATION.ino +++ /dev/null @@ -1,88 +0,0 @@ -///////////////////////////////////////////////////////////////////////// -// DON'T TRY TO RUN THIS SKETCH, IT IS FOR DOCUMENTATION PURPOSES ONLY // -///////////////////////////////////////////////////////////////////////// - -// These are the music functions that are available for you to use in you sketches. -// You can see examples of how some of them are used (the most basic ones) in the -// Apps folder that downloaded with the MM library. - -// In the following you can see the variable type that the function takes as an argument (float, uint8_t or uint16_t) -// The weirdly looking "uint16_t" and "uint8_t" is just unsigned 16 and 8 bit integers. So instead of having -// both negative and positive values, they only have positive values from 0 - 255 (8bit) and 0 - 65535 (16bit). -// If you copy a function from here to your arduino sketch, just change the word "float", "uint8_t", etc into the -// variable name that you uses in your sketch. - - -// INITIALIZER -// Use this to start the synth engine. It defaults to a sine tone at 110Hz, no envelope and no detune. -Music.init(); - - -// FREQUENCY AND DETUNE FUNCTIONS -// Use these functions to set the frequency and detune parameters of the synth. -Music.setFrequency(float); // Set frequencies of all oscillators at once. Does _not_ affect detune. -Music.setFrequency1(float); // Set frequency of individual oscillators. -Music.setFrequency2(float); // -Music.setFrequency3(float); // -Music.setDetune(float); // Set the detune of all oscillators at once. Does _not_ affect the base frequencies. -Music.setDetune2(float); // Set the detune of oscillator 2 and 3 individually (oscillator 1 stays fixed) -Music.setDetune3(float); -Music.pitchBend(float); // This function detunes the pitch without affecting the detune parameters' individual - // 'spread'. Takes a float. - - -// WAVEFORM FUNCTIONS -// Switch between the different waveforms for the oscillators. It sets all of them at once. -Music.setSine(); -Music.setSaw(); -Music.setSquare(); - - -// GAIN FUNCTIONS -// Set the gain of the oscillators all at once or individually. You can send either floats or uint16_t to the -// function and it figures out to use the correct function automagically :) -Music.setGain(float); // 0.0 - 1.0 -Music.setGain1(float); // 0.0 - 1.0 -Music.setGain2(float); // 0.0 - 1.0 -Music.setGain3(float); // 0.0 - 1.0 -// using floats in your own calculations can be heavy on the processor, so there is the option of passing 16bit integers -// instead, since this is what it gets converted to anyway internally in the sound engine. -Music.setGain(uint16_t value); // 0 - 65535 -Music.setGain1(uint16_t value); // 0 - 65535 -Music.setGain2(uint16_t value); // 0 - 65535 -Music.setGain3(uint16_t value); // 0 - 65535 - - -// NOTE FUNCTIONS -// These functions triggers a note to be played. The noteOff() functions turns the note off again. -// They come both with note and velocity information (for noteOn). If you don't know what that is, -// just use the ones with the least arguments. -// To get a proper note sound call Music.enableEnvelopes() [see below] before calling the noteOn function. -// You just have to do that once in the setup for example. -Music.noteOn(uint8_t note, uint8_t vel); // 0 - 127 -Music.noteOn(uint8_t note); // 0 - 127 -Music.noteOff(uint8_t note); // 0 - 127 -Music.noteOff(); -// This function returns the frequency of a MIDI note number sent to it. -Music.getNoteFrequency(uint8_t); // 0 - 127 - - -// ENVELOPE FUNCTIONS -// These functions enables and sets the parameters of the internal envelope which creates dynamics for the notes -// being played. You can read about ADSR envelopes here: http://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope -// When using the envelope you can only hear sound when you are triggering the notes with the note functions. In order -// to get dynamics without triggering the note object you must have the envelope turned off, for example using -// the Music.disableEnvelope() function [already set by default in the init() function]. You can then control the -// dynamics of the sound with the overall or individual setGain() functions. -Music.enableEnvelope(); -Music.disableEnvelope(); -// Setting the parameters for the envelope you send an 8bit number between 0 and 127 to the functions below. 0 is a very fast -// rise or decay in sound, whereas 127 is very long. Sustain is the sound level where 0 is silent and 127 is full gain. -// You must experiment with what suits your musical taste :) -// These parameters can of course be adjusted during the physics code for interesting results, but be aware that when -// using the sine wave oscillator (which is more processor intensive) the sound can hang or have glitches if you alter -// these parameters too quickly or set them at extremes. Try it out. -Music.setAttack(uint8_t att); // 0 - 127 -Music.setDecay(uint8_t dec); // 0 - 127 -Music.setSustain(uint8_t sus); // 0 - 127 -Music.setRelease(uint8_t rel); // 0 - 127 diff --git a/Software/Arduino/Example code/Minimal/Minimal.ino b/Software/Arduino/Example code/Minimal/Minimal.ino deleted file mode 100644 index 9eae6a3..0000000 --- a/Software/Arduino/Example code/Minimal/Minimal.ino +++ /dev/null @@ -1,19 +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(); - -} - -void loop() { - -} - diff --git a/Software/Arduino/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 deleted file mode 100644 index 81ecd55..0000000 --- a/Software/Arduino/Example code/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/Arduino/Example code/Spaghetti_tones/Spaghetti_tones.ino b/Software/Arduino/Example code/Spaghetti_tones/Spaghetti_tones.ino deleted file mode 100644 index 9c369d8..0000000 --- a/Software/Arduino/Example code/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(); - - // 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/Arduino/Example code/Up_and_down/Up_and_down.ino b/Software/Arduino/Example code/Up_and_down/Up_and_down.ino deleted file mode 100644 index d48c08a..0000000 --- a/Software/Arduino/Example code/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/Arduino/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino b/Software/Arduino/Example code/Up_and_down/sketch_jun26c/sketch_jun26c.ino deleted file mode 100644 index 12ba038..0000000 --- a/Software/Arduino/Example code/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/Arduino/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 deleted file mode 100644 index 0486f1d..0000000 --- a/Software/Arduino/Example code/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/Arduino/Example code/_insect_live/_insect_live.ino b/Software/Arduino/Example code/_insect_live/_insect_live.ino new file mode 100644 index 0000000..d17e727 --- /dev/null +++ b/Software/Arduino/Example code/_insect_live/_insect_live.ino @@ -0,0 +1,25 @@ +#define CFO_ID 0 + +#include +#include +#include + + +void setup() { + + Music.init(); + Midi.init(); + Midi.setID(CFO_ID); + Midi.setChannel(1); // channel number is 1-16 + Music.setSaw(); + Music.setDetune(0.02); + Music.enableEnvelope(); + +} + +void loop() { + + Midi.checkMidi(); + +} + diff --git a/Software/Arduino/Example code/_insect_test/_insect_test.ino b/Software/Arduino/Example code/_insect_test/_insect_test.ino index f31ad28..484f179 100644 --- a/Software/Arduino/Example code/_insect_test/_insect_test.ino +++ b/Software/Arduino/Example code/_insect_test/_insect_test.ino @@ -1,4 +1,4 @@ -//#define CFO_MIDI_CHANNEL 4 +#define CFO_ID 0 #include #include @@ -8,17 +8,18 @@ void setup() { Music.init(); - Midi.init(); - Midi.setChannel(16); // channel number is 1-16 + //Midi.init(); + //Midi.setID(CFO_ID); + //Midi.setChannel(CFO_ID, 1); // channel number is 1-16 Music.setSaw(); - Music.setDetune(0.02); - Music.enableEnvelope(); + //Music.setDetune(0.02); + //Music.enableEnvelope(); } void loop() { - Midi.checkMidi(); + //Midi.checkMidi(); }