diff options
author | Phil Burk <[email protected]> | 2017-07-31 18:35:27 -0700 |
---|---|---|
committer | Phil Burk <[email protected]> | 2017-07-31 18:53:17 -0700 |
commit | d20f15b705576c129d023d2f04938b82509abf42 (patch) | |
tree | 8ad7795a5af4f0043e5a8774902d4f0cd6d652fd /src/com | |
parent | 464f3d55f7847831c5ba6acf4766260fae1e4a6d (diff) |
MultiChannelSynthesizer: add noteOn and noteOff with timestamp
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/jsyn/util/MultiChannelSynthesizer.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/com/jsyn/util/MultiChannelSynthesizer.java b/src/com/jsyn/util/MultiChannelSynthesizer.java index aff795b..b84d753 100644 --- a/src/com/jsyn/util/MultiChannelSynthesizer.java +++ b/src/com/jsyn/util/MultiChannelSynthesizer.java @@ -161,9 +161,16 @@ public class MultiChannelSynthesizer { groupContext.allocator.noteOff(noteNumber, synth.createTimeStamp()); } + void noteOff(int noteNumber, double amplitude, TimeStamp timeStamp) { + groupContext.allocator.noteOff(noteNumber, timeStamp); + } + void noteOn(int noteNumber, double amplitude) { + noteOn(noteNumber, amplitude, synth.createTimeStamp()); + } + + void noteOn(int noteNumber, double amplitude, TimeStamp timeStamp) { double frequency = AudioMath.pitchToFrequency(noteNumber); - TimeStamp timeStamp = synth.createTimeStamp(); //System.out.println("noteOn(noteNumber) -> " + frequency + " Hz"); groupContext.allocator.noteOn(noteNumber, frequency, amplitude, voiceOperation, timeStamp); } @@ -280,6 +287,17 @@ public class MultiChannelSynthesizer { } /** + * Turn off a note. + * @param channel + * @param noteNumber + * @param amplitude between 0 and 1.0, will be scaled by masterAmplitude + */ + public void noteOff(int channel, int noteNumber, double amplitude, TimeStamp timeStamp) { + ChannelContext channelContext = channels[channel]; + channelContext.noteOff(noteNumber, amplitude * mMasterAmplitude, timeStamp); + } + + /** * Turn on a note. * @param channel * @param noteNumber @@ -289,6 +307,18 @@ public class MultiChannelSynthesizer { double amplitude = velocity * (1.0 / MAX_VELOCITY); noteOn(channel, noteNumber, amplitude); } + + /** + * Turn on a note. + * @param channel + * @param noteNumber + * @param amplitude between 0 and 1.0, will be scaled by masterAmplitude + */ + public void noteOn(int channel, int noteNumber, double amplitude, TimeStamp timeStamp) { + ChannelContext channelContext = channels[channel]; + channelContext.noteOn(noteNumber, amplitude * mMasterAmplitude, timeStamp); + } + /** * Turn on a note. * @param channel |