import net.beadsproject.beads.core.*; import net.beadsproject.beads.ugens.*; import com.benitomedia.processing.display.*; import com.benitomedia.beadsext.benito1.*; import com.benitomedia.benito_beads_ext2.*; import java.util.*; AudioContext ac; Gain maingain; float mainvol = .5; Envelope pulseinterval; Clock clock; float eighthduration = 200; int pulsesper8th = 12; float pulseduration = eighthduration / pulsesper8th; PulseHandler ph; int currid; Marimba marimba; Drum bd, sd, hh; PluckedBass bass; WaveShaper bassdist; WahWah basswah; PFont smallfont, bigfont; DisplayRegime maindisp; DisplayContainer dkeys; float basepitch = 55; ScaleSubset currscale, marimbascale; ScaleSubset AMajor, DMajor, CMajor, WT0, WT1, Oct01, Oct02, Oct12; float[][][] keypatts = new float[256][][]; int currsection = 0; int drumsmode = 0; int bassmode = 0; int fxmode = 0; int keyarea = 0; void setup() { size(800, 450); AMajor = new ScaleSubset(new int[] {0, 2, 4, 5, 7, 9, 11}, 12); DMajor = AMajor.clone().rotate(5); CMajor = AMajor.clone().rotate(3); WT0 = new ScaleSubset(new int[] {0, 2, 4, 6, 8, 10}, 12); WT1 = WT0.clone().rotate(1); Oct01 = new ScaleSubset(new int[] {0, 1, 3, 4, 6, 7, 9, 10}, 12); Oct12 = Oct01.clone().rotate(1); Oct02 = Oct01.clone().rotate(2); currscale = AMajor; marimbascale = currscale; smallfont = loadFont("Aharoni-Bold-24.vlw"); bigfont = loadFont("Aharoni-Bold-32.vlw"); initDisplayObjects(); dkeys = new DisplayContainer(width * .65, height * .9); maindisp.add(dkeys); define_patterns(); ac = new AudioContext(); //ac.checkForDroppedFrames(false); pulseinterval = new Envelope(ac, eighthduration); clock = new Clock(ac, pulseinterval); println(eighthduration + " " + pulsesper8th); clock.setTicksPerBeat(pulsesper8th); ph = new PulseHandler(); clock.addMessageListener(ph); ac.out.addDependent(clock); marimba = new Marimba(ac); bd = new BassDrum(ac); sd = new SnareDrum(ac); hh = new FuzzyCymbal(ac); bass = new PluckedBass(ac); bassdist = new WaveShaper(ac); bassdist.addInput(bass); bassdist.setPreGain(10).setPostGain(.7).setLimit(.5).setWetMix(1); basswah = new WahWah(ac); basswah.addInput(bassdist); /* YAFR2 verb = new YAFR2(ac); verb.setParams(.1, .1, .1, 0); verb.in.addInput(sd.getOut()); verb.in.addInput(hh.getOut()); verb.in.addInput(bd.getOut()); verb.in.addInput(bass.getOut()); verb.in.addInput(marimba.getOut()); */ WaveShaper marimbadist = new WaveShaper(ac); marimbadist.setPreGain(2).setPostGain(.7).setLimit(1).setWetMix(1); marimbadist.addInput(marimba); Reverb rev = new Reverb(ac, 2); rev.setEarlyReflectionsLevel(.5).setLateReverbLevel(.2).setSize(.8); rev.addInput(marimbadist); rev.addInput(bd); rev.addInput(sd); rev.addInput(hh); //maingain.addInput(bass.getOut()); //maingain.addInput(bassdist); rev.addInput(basswah); maingain = new Gain(ac, 2, mainvol); //WaveShaper drumsdist = new WaveShaper(ac); //drumsdist.addInput(bd.g); maingain.addInput(marimbadist); maingain.addInput(bd); maingain.addInput(sd); maingain.addInput(hh); //maingain.addInput(bass.getOut()); //maingain.addInput(bassdist); maingain.addInput(basswah); //maingain.addInput(rev); //MaxFinder maxL = new MaxFinder(ac, "L: "); //maxL.addInput(0, maingain, 0); //MaxFinder maxR = new MaxFinder(ac, "R: "); //maxR.addInput(0, maingain, 1); //maingain.addInput(0, verb.out, 0); //maingain.addInput(1, verb.out, 1); //ac.out.addInput(0, maxL, 0); //ac.out.addInput(1, maxR, 0); ac.out.addInput(maingain); ac.start(); } void draw() { background(0); noStroke(); noSmooth(); for(int i = ph.marimbahistory.length; i > 0; i--) { int ix = (ph.marimbahistoryindex + i) % ph.marimbahistory.length; int p = ph.marimbahistory[ix]; float rx = (float)i / ph.marimbahistory.length; //fill(64, 64, 80); float dx = i * 4 - 500 * (1 - rx) * (1 - rx); if(p > 0) { fill(32 * rx, 32 * rx, 40 * rx); rect(dx - 4, 4300 - 4 * p, 15 - 2 * rx, 5); fill(64 * rx, 64 * rx, 80 * rx); rect(dx, 4300 - 4 * p, 5, 5); } p = ph.marimbaaccomphistory[ix]; if(p > 0) { fill(32 * rx, 32 * rx, 40 * rx); rect(dx - 3, 4301 - 4 * p, 13 - 2 * rx, 3); fill(64 * rx, 64 * rx, 80 * rx); rect(dx + 1, 4301 - 4 * p, 3, 3); } } maindisp.update(); } void keyPressed() { float[][] patty = keypatts[keyCode]; if(keyCode == '1') { currscale = AMajor; } else if(keyCode == '2') { currscale = DMajor; } else if(keyCode == '3') { currscale = CMajor; } else if(keyCode == '4') { currscale = WT0; } else if(keyCode == '5') { currscale = WT1; } else if(keyCode == '6') { currscale = Oct01; } else if(keyCode == '7') { currscale = Oct12; } else if(keyCode == '8') { currscale = Oct02; } else if(keyCode == ENTER) { currsection = (currsection + 1) % 4; } if(patty == null) { println("unknown keycode: " + keyCode); } else { float[][] patts = patty.clone(); Boolean reverseit; if (key >= 'A' && key <= 'Z') reverseit = true; else reverseit = false; currid = (currid + 1) % 1000; for(int i = 0; i < patts.length; i++) { patts[i] = patty[i].clone(); float[] patt = patts[i]; patt[0] = currid; if(reverseit) { for(int j = 4; j < patt.length; j += 5) { patt[j] *= -1; } } } String label = Character.toString(key); if(key == ' ') label = "_"; ph.cuePattern(patts, label); } }