From 6c59da55126ef19967460f53b932c4cfe1111338 Mon Sep 17 00:00:00 2001 From: jsr606 Date: Thu, 30 Aug 2012 19:56:40 +0200 Subject: [PATCH] jar composition for alt cph added bang! standalone phase goodness for several insects --- .DS_Store | Bin 6148 -> 6148 bytes Software/.DS_Store | Bin 6148 -> 6148 bytes Software/Arduino/.DS_Store | Bin 6148 -> 6148 bytes Software/Arduino/alt_cph/.DS_Store | Bin 0 -> 6148 bytes .../_jsr_for_alt_cph/_jsr_for_alt_cph.ino | 150 ++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 Software/Arduino/alt_cph/.DS_Store create mode 100644 Software/Arduino/alt_cph/_jsr_for_alt_cph/_jsr_for_alt_cph.ino diff --git a/.DS_Store b/.DS_Store index 4d14643ddb93a8c0d817e95c7b312a2f1cda5537..dba52c58e16292544955cdc91168df3509ddacc2 100644 GIT binary patch delta 124 zcmV-?0E7R8FoZCWPXPt7P`d#E1+xqS3jq|ZVsLC}b968;)&T+o1O)~M2nh+3KLSuH z7JGX!H8m_CG<_@}dp9>QEFd>DGktvt2nY!f-v|{VE<8w7VS0OfeSVX>0v`c@lg9%f elluY@40cm;ZftLEX8-^I0kiP~1q8DP2>lP=vmxmK delta 40 wcmZoMXfc@J&&aYdU^gQp%Vr)XZpO*lOj{?PVwT=4$|1xuv4L+hJI7ys0Pg<_p8x;= diff --git a/Software/.DS_Store b/Software/.DS_Store index 03b91ed631935f540f0a51edf53a6520ddc2fba1..d093723f831d888054489678866fc836edacfde9 100644 GIT binary patch delta 95 zcmZoMXfc@J&&a$nU^g=(^JE?teI`!M$+j%PGG>;>ItsdG2DLg0)#l~~Itu0{#%<1>&Fmb1`2q9v B3s(RD diff --git a/Software/Arduino/alt_cph/.DS_Store b/Software/Arduino/alt_cph/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..51af11ce7292dce88450a2b2010d332b7308d94c GIT binary patch literal 6148 zcmeHK%Sr=55Ukc50$%p$ael!+SVH^)Kfq{$h%BrabKjHS<)@|k0TNbE!Aq!yo|@_D znqlg&y$!%thus~}0a(%<@#VwZeBXU$R~0cLoo77a1tUI)PqXab1J3Q3|Au|=e)t1E z8QKrL`GxcD + +// 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; +int beatTime = 3000; +int originalBeatTime = beatTime; +int timeIncrement = -3; +int lowestBeatTime = 1500; +int highestBeatTime = 10000; + +int notes[] = {0,5,7,9}; +int octaveSpanL = -3; +int octaveSpanH = 1; +int numberOfNotes = 4; + +int randomizeNotes = 100; + +float detuning = 0.0; +float origDetuning = detuning; +float maxDetuning = 0.2; +float detuneIncrement = 0.001; + +long lastDetune = millis(); +int detuneDelay = 10; + +int randomizeWave = 100; + +int arpFrequency = 50; +int arpCounter = 0; +int arpLenght = 25; +boolean arpMode = false; +int arpDelay = 60; + +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(0); + Music.setDecay(4); + Music.setSustain(255); + Music.setRelease(255); + Music.setSaw(); + + Serial.begin(9600); +} + +void loop() { + + // This short routine loops note over and over again + time = millis(); + if(time - lastTime > beatTime) { + if(!noteIsOn) { + + if (random(randomizeNotes) == 0) { + + pickNewNote(); + + } + + Music.noteOn(note); + noteIsOn = true; + + + } else { + Music.noteOff(); + noteIsOn = false; + } + lastTime = time; + beatTime = beatTime + timeIncrement; + if (beatTime < lowestBeatTime || beatTime > highestBeatTime) { + beatTime = originalBeatTime; + } + + if (random(randomizeWave) == 0) { + int nextWave = random(4); + if (nextWave == 0) { + Music.setSaw(); + Serial.println("now saw"); + } else if (nextWave == 1) { + Music.setSine(); + Serial.println("now sine"); + } else if (nextWave == 2) { + Music.setSquare(); + Serial.println("now square"); + } + } + + if (random(arpFrequency) == 0) { + arpMode = true; + Serial.println("let the arp begin..."); + } + + + + if (lastDetune + detuneDelay < millis()) { + Music.setDetune(detuning); + detuning = detuning + detuneIncrement; + if (detuning > maxDetuning) { + detuning = origDetuning; + } + lastDetune = millis(); + } + + } + + if (arpMode) { + pickNewNote(); + Music.noteOn(note+12); + noteIsOn = true; + delay(arpDelay); + + arpCounter ++; + + if (arpCounter > arpLenght) { + + arpMode = false; + arpCounter = 0; + Serial.println("arp stopped"); + + pickNewNote(); + Music.noteOn(note-24); + noteIsOn = true; + + } + + } + +} + +void pickNewNote () { + int currentOctave = random(octaveSpanL, octaveSpanH); + Serial.println(currentOctave); + note = 48+12*currentOctave+notes[random(numberOfNotes)]; +} +