Mercurial > hg > movesynth
view HeresyBigBangDone/IO.pde @ 50:f4c6999ecfe9 tip
added the files on my computer that aren't aiff s> these shoudl be everything for the big bang fair 2011 - heresy, and tim's file's also here
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Sat, 08 Oct 2011 22:12:49 +0100 |
parents | 0eeda0223db3 |
children |
line wrap: on
line source
void sendNote(VPNote note, int channel){ // send note function gathers info to output to max outputToMax(note.VPNotePitch, note.VPNoteVelocity, channel); } //------------------------------------------------------------------------------------------------------------------------------- void outputToMax(int note, int velocity, int channel){ // calculates the necessary note on and note offs depending on ducking and muting and sends them to max String noteOut = ""; if (!tracks[channel].mute){ if (tracks[channel].ducking){ if (velocity != 0){ noteOut = ("" + note + " " + velocity + " " + (channel+8)); } if (velocity == 0 && !tracks[channel].cycled){ noteOut = ("" + note + " " + velocity + " " + (channel+8)); OscMessage message = new OscMessage("/pitch_vel_chan"); message.add(noteOut); oscP5return.send(message, ableton); link.output(noteOut); noteOut = ("" + note + " " + velocity + " " + channel); } if (velocity == 0 && tracks[channel].cycled){ noteOut = ("" + note + " " + velocity + " " + (channel+8)); } } if (!tracks[channel].ducking){ if (velocity != 0){ noteOut = ("" + note + " " + velocity + " " + channel); } if (velocity == 0 && !tracks[channel].cycled){ noteOut = ("" + note + " " + velocity + " " + (channel+8)); OscMessage message = new OscMessage("/pitch_vel_chan"); message.add(noteOut); oscP5return.send(message, ableton); link.output(noteOut); noteOut = ("" + note + " " + velocity + " " + channel); } if (velocity == 0 && tracks[channel].cycled){ noteOut = ("" + note + " " + velocity + " " + channel); } } link.output(noteOut); OscMessage message = new OscMessage("/pitch_vel_chan"); message.add(noteOut); oscP5return.send(message, ableton); } if (tracks[channel].mute){ if (velocity == 0 && !tracks[channel].cycled){ noteOut = ("" + note + " " + velocity + " " + (channel+8)); link.output(noteOut); OscMessage message = new OscMessage("/pitch_vel_chan"); message.add(noteOut); oscP5return.send(message, ableton); noteOut = ("" + note + " " + velocity + " " + channel); OscMessage message2 = new OscMessage("/pitch_vel_chan"); message2.add(noteOut); oscP5return.send(message, ableton); link.output(noteOut); } } } //------------------------------------------------------------------------------------------------------------------------------- void mouseDragged(){ // not used } //------------------------------------------------------------------------------------------------------------------------------- void mouseReleased(){ // not used } //------------------------------------------------------------------------------------------------------------------------------- void mousePressed(){ // not used } //------------------------------------------------------------------------------------------------------------------------------- void keyPressed() { // takes keyboard input if (key == 'c' || key == 'C') { chordSelecter = !chordSelecter; if (!chordSelecter) trSelected = lastTrack; else{ lastTrack = trSelected; trSelected = 0; } } if (key == ' ') { if (trSelected != 0){ for (int i = 0; i < 16; i++){ noteOnArray[i] = false; finishNote(i); displayNoteOnArray[i] = false; } if (trSelected != 0){ for (int i = 24; i < 109; i++) outputToMax(i, 0, trSelected); } tracks[trSelected] = new Track(tracks[trSelected].name, true, tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false); imgNotes = null; } if (trSelected == 0){ for (int i = 0; i < 16; i++){ noteOnArray[i] = false; finishNote(i); displayNoteOnArray[i] = false; } heresyMinor = false; heresy7th = false; heresy9th = false; heresy11th = false; heresy13th = false; chordsTemp = new Track(tracks[trSelected].name, true, tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false); imgNotes = null; } } if (key == 'p' || key == 'P') { for (int i = 0; i < 16; i++){ for (int ii = 24; ii < 109; ii++) outputToMax(ii, 0, trSelected); noteOnArray[i] = false; displayNoteOnArray[i] = false; } } if (key == 'd' || key == 'D') { if (trSelected != 0 && trSelected != 1){ tracks[trSelected].ducking = !tracks[trSelected].ducking; tracks[trSelected].cycled = false; tracks[trSelected].cycledPosition = currentPulse%tracks[trSelected].loopLength; } } if (key == 'w' || key == 'W') { trSelected = 0; for (int i = 0; i < 16; i++){ noteOnArray[i] = false; finishNoteCutOff(i); displayNoteOnArray[i] = false; } heresyMinor = false; heresy7th = false; heresy9th = false; heresy11th = false; heresy13th = false; tracks[trSelected] = new Track(tracks[trSelected].name, true, tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false); chordsTemp = new Track(tracks[trSelected].name, true, tracks[trSelected].loopLength, tracks[trSelected].quantize, false, false); imgNotes = null; } if (key == 'q' || key == 'Q'){ quantizeValueIn = true; sendToScreen(tracks[trSelected].name + " quantize?"); } if (key == 'x' || key == 'X'){ clickTrackOn = !clickTrackOn; } if (key == 'e' || key == 'E'){ eraseOn = !eraseOn; if (!eraseOn) imgNotes = null; } if (key == 'r' || key == 'R'){ imgNotes = null; } if (key == 'l' || key == 'L'){ loopLengthValueIn = true; sendToScreen(tracks[trSelected].name + " loop length?"); } if (key == 'm' || key == 'M'){ if (trSelected != 0){ muteValueIn = true; if (!tracks[trSelected].mute) sendToScreen(tracks[trSelected].name + " mute in?"); if (tracks[trSelected].mute) sendToScreen(tracks[trSelected].name + " unmute in?"); } } if (key == '1') numberKey(1); if (key == '2') numberKey(2); if (key == '3') numberKey(3); if (key == '4') numberKey(4); if (key == '5') numberKey(5); if (key == '6') numberKey(6); if (key == '7') numberKey(7); if (key == '8') numberKey(8); if (key == '9') numberKey(9); if (key == '0') numberKey(0); if (key == CODED) { if (keyCode == UP && trSelected < Track.currentNumberOfTracks-1) trSelected++; if (keyCode == DOWN && trSelected > 1) { trSelected--; } } if (key == 's' || key == 'S'){ for (int i = 0; i < 16; i++){ for (int ii = 0; ii < tracks[0].loopLength; ii++){ if (chordsTemp.sequence[i][ii] != null) tracks[0].sequence[i][ii] = chordsTemp.sequence[i][ii]; } } } } //------------------------------------------------------------------------------------------------------------------------------- void numberKey(int input){ // if a number is enterd, this method works out what to do with it if (quantizeValueIn == true) if (input == 1 || input == 2 || input == 4 || input == 8 || input == 0){ tracks[trSelected].quantize = input; quantizeValueIn = false; aniOut = true; } if (loopLengthValueIn == true){ if (input >= 1 && input <= 8 ){ Track tempTrack = new Track(tracks[trSelected].name, tracks[trSelected].polyphonic, (input * loopLength / 2), tracks[trSelected].quantize, false, false); NoteEvent tempNote; for (int i = 0; i < 16; i++){ if (tempTrack.loopLength >= tracks[trSelected].loopLength){ for (int ii = 0; ii < tracks[trSelected].loopLength; ii++){ tempTrack.sequence[i][ii] = tracks[trSelected].sequence[i][ii]; } }else{ for (int ii = 0; ii < tempTrack.loopLength; ii++){ tempTrack.sequence[i][ii] = tracks[trSelected].sequence[i][ii]; } } } tracks[trSelected] = tempTrack; for (int i = 0; i < 16; i++) if (noteOnArray[i] = true){ noteOnArray[i] = false; finishNoteCutOff(i); displayNoteOnArray[i] = false; } loopLengthValueIn = false; aniOut = true; if (trSelected ==0){ Track tempTrack2 = new Track(chordsTemp.name, chordsTemp.polyphonic, (input * loopLength / 2), chordsTemp.quantize, false, false); NoteEvent tempNote2; for (int i = 0; i < 16; i++){ if (tempTrack2.loopLength >= chordsTemp.loopLength){ for (int ii = 0; ii < chordsTemp.loopLength; ii++){ tempTrack2.sequence[i][ii] = chordsTemp.sequence[i][ii]; } }else{ for (int ii = 0; ii < tempTrack2.loopLength; ii++){ tempTrack2.sequence[i][ii] = chordsTemp.sequence[i][ii]; } } } chordsTemp = tempTrack2; } imgNotes = null; } } if (muteValueIn == true){ tracks[trSelected].muteIn = bar + input; muteValueIn = false; tracks[trSelected].muteDone = false; aniOut = true; } } //------------------------------------------------------------------------------------------------------------------------------- void sendToScreen(String name){ // prepares a question for asking the user and turns the question on screenQuestion = name; screenAni = 0; haveQuestion = true; } //------------------------------------------------------------------------------------------------------------------------------- void checkCycled(){ // checks whether after ducking or muting all note offs are played. for (int i = 1; i < Track.currentNumberOfTracks; i++) if (tracks[i].cycled == false) if (tracks[i].cycledPosition-1 == currentPulse%tracks[trSelected].loopLength) tracks[i].cycled = true; } //------------------------------------------------------------------------------------------------------------------------------- void checkForMutes(){ // looks for mute / unmuted changes in tracks for (int i = 1; i < Track.currentNumberOfTracks; i++) if (tracks[i].muteIn == bar && !tracks[i].muteDone){ tracks[i].mute = !tracks[i].mute; tracks[i].muteDone = true; tracks[trSelected].cycled = false; tracks[trSelected].cycledPosition = currentPulse%tracks[trSelected].loopLength; } } //------------------------------------------------------------------------------------------------------------------------------- void writeQuestion(){ // animates screen questions if (screenAni < 10 && !aniOut){ screenAni++; } if (screenAni > 0 && aniOut){ screenAni--; } if (screenAni == 0){ haveQuestion = false; aniOut = false; } fill(255,0,0, screenAni*12); textSize((11-screenAni)*40); text(screenQuestion, (screenAni*50)-200,(100-screenAni*10)+150); } //------------------------------------------------------------------------------------------------------------------------------- void oscEvent(OscMessage theOscMessage) { // recieves osc messages from openFrameworks println("osc message : " + theOscMessage); if(theOscMessage.checkAddrPattern("/test")==true) { println("i1 : " + theOscMessage.get(1).intValue() + " i2 : " + theOscMessage.get(2).intValue() + " i3 : " + theOscMessage.get(3).intValue() + " i4 : " + theOscMessage.get(4).intValue()); clickTrack = false; String stringValue = theOscMessage.get(0).stringValue(); int firstValue = theOscMessage.get(1).intValue(); int secondValue = theOscMessage.get(2).intValue(); int thirdValue = theOscMessage.get(3).intValue(); //velocity int fourthValue = theOscMessage.get(4).intValue(); //channel if (secondValue == 1){ if (firstValue != 0 && fourthValue == 1){ noteOnArray[firstValue] = true; writeNote(firstValue-1, thirdValue, fourthValue); } else { noteOnArray[firstValue] = true; writeNote(firstValue, thirdValue, fourthValue); } } else if (firstValue != 0 && fourthValue == 1){ noteOnArray[firstValue] = false; writeNote(firstValue-=1, 0, fourthValue); } else{ noteOnArray[firstValue] = false; writeNote(firstValue, 0, fourthValue); } } if(theOscMessage.checkAddrPattern("/chord")==true) { chordCalc(); // writeNote(15, 80, 6); writeNote(14, 80, 6); writeNote(13, 80, 6); writeNote(12, 80, 6); writeNote(11, 80, 6); writeNote(10, 80, 6); writeNote(9, 80, 6); } }