import javax.sound.midi.*; import java.io.File; import ddf.minim.*; String midiFileName = "The Son is the One Midi 113bpm.mid"; String audioFileName = "The Son is the One.mp3"; Sequencer s; MetaListener metaListener; Note[] notes = new Note[128]; int NOTE_LOW = 0, NOTE_HIGH = 29; Minim minim; AudioPlayer audioPlayer; int pw=10;int ph=10; PImage sc; //=createImage(width,height); //convolution matrix float[][] matrix = { { 0,.2, 0 }, {0, .59, 0 }, { 0, .2,0 } }; //vary size and matrix over piece //matrix comes in slowly // //overall weighting of matrix is strongly determinant //functions that map the frequency of change //stepped by the notes will tend to maximise change where the music is busiest. //map the notes to cyclers- independently - no cant be done class FMcycler { float cycleA; float cycleB; float offset; float weight; //takes a normalised coordinate and calculates a zeroed FM cycle FMcycler(float _A, float _B) { cycleA=_A; cycleB=_B; offset=0; weight=1; } FMcycler(float _A, float _B,float _offs,float _wei) { cycleA=_A; cycleB=_B; offset=_offs; weight=_wei; } float map(float f) { return offset+(weight*sin(cycleB*sin(cycleA*f*2*PI)*2*PI)); } } FMcycler off=new FMcycler(0,0,1.0,0); FMcycler[][] cyclematrix = { { off, new FMcycler(0.5,1.2,0,0), off }, { off, new FMcycler(0.5,1.2,1.0,0), off}, { off, new FMcycler(0.5,1.2,0,0), off } }; FMcycler poscycler; FMcycler scalecycler; FMcycler vertcycler; void setup(){ poscycler=new FMcycler(0.5,1.7); scalecycler=new FMcycler(0.5,3.1); vertcycler=new FMcycler(0.5,0.9); size(300, 110, P3D); frameRate(15); for(int i = NOTE_LOW; i < NOTE_HIGH; i++){ notes[i]=new Note(); } //load audio file minim = new Minim(this); audioPlayer = minim.loadFile(audioFileName, 2048); audioPlayer.play(); //audioPlayer.loop(9999999); //audioPlayer is started when midi sequencer is started startMidiFile(); sc=createImage(width,height,RGB); background(0); rectMode(CORNER); noStroke(); colorMode(RGB, 255); //app=new PlayApp(this,"localhost","Backing & Veering","Sunken Foal",153f); swidth=width-2; soffset=1; } int swidth; int soffset; float time=0; void draw(){ time+=(1f/(153f*25)); // for (int i=0;i0.6) matrix[1][1]=0.6+(sin(((time-0.6)*0.25)*PI)*0.2); sc=convolution(matrix,get(0,0,width,height)); background(0); //image(sc,1,15,width,height); image(sc,1,3.2+(vertcycler.map(time)*1.7),width-1,height); //image(sc,soffset,5,swidth,height); //image(sc,(int)(poscycler.map(time)*0)+1,5,width-2+(int)(scalecycler.map(time)*0),height); //for (int i=15*width;i0) { //draw the note colorMode(HSB, 255); fill(200-v,255,255); colorMode(RGB, 255); rect(i*pw,0,pw,ph); } } saveFrame("frames/img####.png"); if (!audioPlayer.isPlaying()) exit(); } //change rate of drop? //veering?? void startMidiFile(){ InputStream midiFileStream = createInput(midiFileName); try { s = MidiSystem.getSequencer(false); s.setSequence(MidiSystem.getSequence(midiFileStream)); //Create a MidiReceiver that listens to NOTE ON and OFF events Receiver midiReceiver = new MidiReceiver(); Transmitter midiTransmitter = s.getTransmitter(); midiTransmitter.setReceiver(midiReceiver); //Create a MetaEventListener that listens to the END OF TRACK event metaListener = new MetaListener(); s.addMetaEventListener(metaListener); s.open(); s.setTickPosition(0L); s.start(); } catch(Exception e) { println(e); background(0, 100, 100); //red screen if erro //stop(); } } void stop(){ s.stop(); } PImage convolution(float[][] matrix, PImage img) { //return img; PImage newimg=createImage(img.width,img.height,RGB); newimg.loadPixels(); int matrixsize = matrix[0].length; int offset = matrixsize / 2; for (int x=0;x