Package jmsltestsuite
Class TransposingSamplePlayingInstrumentWithAmplitudeMap
java.lang.Object
com.softsynth.jmsl.InstrumentAdapter
com.softsynth.jmsl.jsyn2.JSynSimpleUnitVoiceInstrument
com.softsynth.jmsl.jsyn2.SamplePlayingInstrument
jmsltestsuite.TransposingSamplePlayingInstrumentWithAmplitudeMap
- All Implemented Interfaces:
Editable
,Instrument
,Namable
,OutputProvider
,Transposable
,AttributeBuildable
,DirectorySettable
,HandleSpecialXMLTag
,Tunable
public class TransposingSamplePlayingInstrumentWithAmplitudeMap extends SamplePlayingInstrument
This subclass of SamplePlayingInstrument overrides
getAlternativeSampleIndex() to map note 60 to three different samples based
on amplitude. Notice that one sample is mapped to 60. Two additional samples
are mapped to pitches 200 and 201, which we never expect to play directly.
They serve as convenient places to stash alternative samples within the
existing API.
The logic of mapping quiet, medium, loud versions of middle c is implemented
in getAlternativeSampleIndex()
- Author:
- Nick Didkovsky, (c) 2004 All rights reserved, Email: nick@didkovsky.com
-
Field Summary
Fields inherited from class com.softsynth.jmsl.jsyn2.SamplePlayingInstrument
POLYPHONY, SAMPLE_CROSSFADED_LOOPING, SAMPLE_LOOPING, SAMPLE_ONE_SHOT
-
Constructor Summary
Constructors Constructor Description TransposingSamplePlayingInstrumentWithAmplitudeMap(java.lang.String dir)
-
Method Summary
Modifier and Type Method Description int
getAlternativeSampleIndex(int pitchIndex, double timeStretch, double[] data)
Precondition: pitchIndex points to a valid sample, previously loaded with addSamplePitch().static void
main(java.lang.String[] args)
Methods inherited from class com.softsynth.jmsl.jsyn2.SamplePlayingInstrument
addEditListener, addSamplePitch, addSamplePitch, addSamplePitch, addSamplePitch, allSamplesSameNumberOfChannels, buildFromAttributes, clear, close, edit, getAudioSamples, getDirectory, getEditEnabled, getNumOutputs, getPitches, getPlaybackMode, getSampleDirectoryName, getSampleFilename, getTuning, handleSpecialTag, notifyEditListeners, off, off, on, open, play, reload, removeEditListener, removeSample, setDirectory, setEditEnabled, setPlaybackMode, setSampleDirectoryName, setTuning, setVoiceAllocatorUnitVoiceName, testSampleDirectory, toString, writeSpecialXMLTags
Methods inherited from class com.softsynth.jmsl.jsyn2.JSynSimpleUnitVoiceInstrument
addSignalSource, getOutput, getOutput, getPolyphony, getPreset, getUnitVoiceArray, getUnitVoiceClassName, getVoiceAllocator, isSignalProcessor, removeAllSignalSources, setPolyphony, setPreset, setUnitVoiceClassName
Methods inherited from class com.softsynth.jmsl.InstrumentAdapter
getDimensionNameSpace, getInterpreter, getMixerClassName, getMusicDevice, getName, getTransposition, noteOff, noteOn, noteOnFor, setDimensionNameSpace, setInterpreter, setMixerClassName, setMusicDevice, setName, setTransposition, update
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
TransposingSamplePlayingInstrumentWithAmplitudeMap
public TransposingSamplePlayingInstrumentWithAmplitudeMap(java.lang.String dir)
-
-
Method Details
-
getAlternativeSampleIndex
public int getAlternativeSampleIndex(int pitchIndex, double timeStretch, double[] data)Precondition: pitchIndex points to a valid sample, previously loaded with addSamplePitch(). Override this method to point to a different valid sample index. For example, you might store a loud sample at pitchIndex 60 and quiet sample at index 200 (ie some pitch index you'd never bang directly), and if the amplitude of data[] < 0.3 return 200 for this pitchIndex, else return 60)public int getAlternativeSampleIndex(int pitchIndex, double timeStretch, double[] data) { double amp = data[2]; if (pitchIndex == 60 && amp < 0.4) { return 201; } if (pitchIndex == 60 && amp > 0.7) { return 200; } return pitchIndex; }
- Overrides:
getAlternativeSampleIndex
in classSamplePlayingInstrument
- Returns:
- valid index to use instead of pitchIndex.
-
main
public static void main(java.lang.String[] args)
-