Mercurial > hg > jslab
view src/samer/midi/MidiWithAftertouch.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children | 5df24c91468d |
line wrap: on
line source
/* * Copyright (c) 2000, Samer Abdallah, King's College London. * All rights reserved. * * This software is provided AS iS and WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ package samer.midi; import samer.core.*; import samer.core.types.*; import samer.core.util.heavy.*; import samer.core.util.*; import samer.tools.*; import samer.maths.*; import java.util.*; import java.io.*; import javax.sound.midi.*; /** When element crosses threshold upwards: note on When element drops below threshold: note off While element remains above threshold adjust velocity */ public class MidiWithAftertouch extends MidiSynth { protected boolean [] states; public MidiWithAftertouch(VVector input) { super(input); states= new boolean[n]; for (int i=0; i<n; i++) states[i]=false; } public void run() { if (synthesizer==null) return; for (int i=0; i<n; i++) { if (x[i]>0) { int vel=mapVelocity(x[i]); if (!states[i]) { cc[chans[i]].noteOn(nnums[i]+offset.value,vel); states[i]=true; } else { // note is still on - adjust pressure--not working cc[chans[i]].setPolyPressure(nnums[i]+offset.value,vel); } } else if (states[i]) { // note is on but now below thresh if (!pedal.value) cc[chans[i]].noteOff(nnums[i]+offset.value, 0); states[i]=false; } } } }