samer@0: /* samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.midi; samer@0: import samer.maths.*; samer@0: import javax.sound.midi.*; samer@0: samer@0: /** samer@0: When element crosses threshold upwards: note on samer@0: When element drops below threshold: note off samer@0: While element remains above threshold adjust velocity samer@0: */ samer@0: samer@0: public class MidiWithAftertouch extends MidiSynth samer@0: { samer@0: protected boolean [] states; samer@0: samer@0: public MidiWithAftertouch(VVector input) samer@0: { samer@0: super(input); samer@0: samer@0: states= new boolean[n]; samer@0: for (int i=0; i0) { samer@0: int vel=mapVelocity(x[i]); samer@0: if (!states[i]) { samer@0: cc[chans[i]].noteOn(nnums[i]+offset.value,vel); samer@0: states[i]=true; samer@0: } else { samer@0: // note is still on - adjust pressure--not working samer@0: cc[chans[i]].setPolyPressure(nnums[i]+offset.value,vel); samer@0: } samer@0: } else if (states[i]) { // note is on but now below thresh samer@0: if (!pedal.value) cc[chans[i]].noteOff(nnums[i]+offset.value, 0); samer@0: states[i]=false; samer@0: } samer@0: } samer@0: } samer@0: }