Mercurial > hg > jslab
view src/samer/midi/MidiWithAftertouch.java @ 1:5df24c91468d
Oh my what a mess.
author | samer |
---|---|
date | Fri, 05 Apr 2019 16:26:00 +0100 |
parents | bf79fb79ee13 |
children |
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.maths.*; 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() { 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; } } } }