Mercurial > hg > jslab
annotate src/samer/midi/MidiWithAftertouch.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | 5df24c91468d |
children |
rev | line source |
---|---|
samer@0 | 1 /* |
samer@0 | 2 * Copyright (c) 2000, Samer Abdallah, King's College London. |
samer@0 | 3 * All rights reserved. |
samer@0 | 4 * |
samer@0 | 5 * This software is provided AS iS and WITHOUT ANY WARRANTY; |
samer@0 | 6 * without even the implied warranty of MERCHANTABILITY or |
samer@0 | 7 * FITNESS FOR A PARTICULAR PURPOSE. |
samer@0 | 8 */ |
samer@0 | 9 |
samer@0 | 10 package samer.midi; |
samer@0 | 11 import samer.maths.*; |
samer@0 | 12 import javax.sound.midi.*; |
samer@0 | 13 |
samer@0 | 14 /** |
samer@0 | 15 When element crosses threshold upwards: note on |
samer@0 | 16 When element drops below threshold: note off |
samer@0 | 17 While element remains above threshold adjust velocity |
samer@0 | 18 */ |
samer@0 | 19 |
samer@0 | 20 public class MidiWithAftertouch extends MidiSynth |
samer@0 | 21 { |
samer@0 | 22 protected boolean [] states; |
samer@0 | 23 |
samer@0 | 24 public MidiWithAftertouch(VVector input) |
samer@0 | 25 { |
samer@0 | 26 super(input); |
samer@0 | 27 |
samer@0 | 28 states= new boolean[n]; |
samer@0 | 29 for (int i=0; i<n; i++) states[i]=false; |
samer@0 | 30 } |
samer@0 | 31 |
samer@0 | 32 public void run() |
samer@0 | 33 { |
samer@0 | 34 for (int i=0; i<n; i++) { |
samer@0 | 35 if (x[i]>0) { |
samer@0 | 36 int vel=mapVelocity(x[i]); |
samer@0 | 37 if (!states[i]) { |
samer@0 | 38 cc[chans[i]].noteOn(nnums[i]+offset.value,vel); |
samer@0 | 39 states[i]=true; |
samer@0 | 40 } else { |
samer@0 | 41 // note is still on - adjust pressure--not working |
samer@0 | 42 cc[chans[i]].setPolyPressure(nnums[i]+offset.value,vel); |
samer@0 | 43 } |
samer@0 | 44 } else if (states[i]) { // note is on but now below thresh |
samer@0 | 45 if (!pedal.value) cc[chans[i]].noteOff(nnums[i]+offset.value, 0); |
samer@0 | 46 states[i]=false; |
samer@0 | 47 } |
samer@0 | 48 } |
samer@0 | 49 } |
samer@0 | 50 } |