Package com.softsynth.jmsl.jsyn
Class TransposingSamplePlayingInstrument
java.lang.Object
com.softsynth.jmsl.InstrumentAdapter
com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrument
com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrumentWithLoops
com.softsynth.jmsl.jsyn.TransposingSamplePlayingInstrument
- All Implemented Interfaces:
Editable
,Instrument
,Namable
,OutputProvider
,Transposable
,UpdatableInstrument
,AttributeBuildable
,DirectorySettable
,HandleSpecialXMLTag
public class TransposingSamplePlayingInstrument extends SimpleSamplePlayingInstrumentWithLoops implements UpdatableInstrument
Deprecated.
use the pure Java JSyn2 package instead
A JMSL Instrument that loads a sequence of monophonic SynthSamples. If there
are gaps in the chromatic scale, a sample will be stretched up or down from
the closest sample. While we recommend no more than a minor third between
your samples for "believable" transposition, this is no longer enforced as of
JMSL v103. Also new to v103, pitches may be fractional.
Each sample must have exactly two cue points: loop start and release start (where release start == loop end). Sustains by simply looping until release time. For smoother sustain, see TransposingSampleSustainingInstrument which uses crossfades for smooth sustaining.
This instrument loops an integer number of times (ie does not break out of loop early in order to get exact duration). This avoids a glitch when the period of a pitched instrument is shortened by the jump from sustain loop to release portion.
IMPORTANT: For Applets, the root sample directory passed to the constructor is ignored and CODEBASE is used instead!!!! So your samples should be in your applet's CODEBASE. The use of subfolders is ok, just make everything relative to CODEBASE. So for example, if locally you have a root sample directory called F:/JMSLScoreWork/JMSLScoreSamples/ relative to which all your samples are located, and inside it is violin/C60.wav, then your applet's CODEBASE, which might be a folder called "classes", should contain violin/C60.wav
This version adds new feature of being able to map pitches to different samples based on performance data, by overriding getAlternativeSampleIndex(). See examples in jmsltestsuite
New to build 20060408,this class supports new methods loadSample(SynthSample sample, int noteIndex) for dynamically created samples. Note that you MUST set your own cue points for your sample data (see below):
Each sample must have exactly two cue points: loop start and release start (where release start == loop end). Sustains by simply looping until release time. For smoother sustain, see TransposingSampleSustainingInstrument which uses crossfades for smooth sustaining.
This instrument loops an integer number of times (ie does not break out of loop early in order to get exact duration). This avoids a glitch when the period of a pitched instrument is shortened by the jump from sustain loop to release portion.
IMPORTANT: For Applets, the root sample directory passed to the constructor is ignored and CODEBASE is used instead!!!! So your samples should be in your applet's CODEBASE. The use of subfolders is ok, just make everything relative to CODEBASE. So for example, if locally you have a root sample directory called F:/JMSLScoreWork/JMSLScoreSamples/ relative to which all your samples are located, and inside it is violin/C60.wav, then your applet's CODEBASE, which might be a folder called "classes", should contain violin/C60.wav
This version adds new feature of being able to map pitches to different samples based on performance data, by overriding getAlternativeSampleIndex(). See examples in jmsltestsuite
New to build 20060408,this class supports new methods loadSample(SynthSample sample, int noteIndex) for dynamically created samples. Note that you MUST set your own cue points for your sample data (see below):
SynthSample sample = new SynthSample(sampleData.length); sample.write(sampleData); sample.cuePoints = new java.util.Vector(); sample.cuePoints.addElement(new CuePoint(10, 1)); sample.cuePoints.addElement(new CuePoint(1000, 2)); ins.addSamplePitch(sample, 60);
- Author:
- Nick Didkovsky, nick@didkovsky.com (C) 2001 Nick Didkovsky, all rights reserved.
- See Also:
TransposingSamplePlayingInstrumentWithAmplitudeMap
,TransposingSampleSustainingInstrument
-
Field Summary
Fields inherited from class com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrument
POLYPHONY
-
Constructor Summary
Constructors Constructor Description TransposingSamplePlayingInstrument()
Deprecated.TransposingSamplePlayingInstrument(java.lang.String sampleDirectory)
Deprecated.constructor. -
Method Summary
Modifier and Type Method Description void
buildFromAttributes()
Deprecated.double
calcRateForTransposition(double audioFrameRate, double pitch, double closestSampledPitch)
Deprecated.If you have a smaple tuned to closestSampledPitch, this method calculates the playback rate to make that smaple sound at desired pitch.int
getUpdateDimension()
Deprecated.Get the dimension to match against when update() is called.static void
main(java.lang.String[] args)
Deprecated.java.lang.Object
off(double playTime, double timeStretch, double[] dar)
Deprecated.Turn off all voices that are playing the sample associated with pitchIndex dar[1].java.lang.Object
on(double playTime, double timeStretch, double[] dar)
Deprecated.Look up sample assiciated with dar[1].double
play(double playTime, double timeStretch, double[] dar)
Deprecated.If there is a sample loaded at dar[1], bang it.double
playOLD(double playTime, double timeStretch, double[] dar)
Deprecated.void
setUpdateDimension(int dim)
Deprecated.Set the dimension to match against when update() is called.Methods inherited from class com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrumentWithLoops
addSamplePitch, clear, getSampleLoopRegioner, getSampleLoopRegioners, loadSample
Methods inherited from class com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrument
addEditListener, addSamplePitch, addSamplePitch, close, edit, getAlternativeSampleIndex, getDirectory, getEditEnabled, getNumChannels, getNumOutputs, getOutput, getOutput, getPitches, getSampleFilename, getSynthSamples, getTuning, getVoices, handleSpecialTag, notifyEditListeners, open, reload, removeEditListener, setDirectory, setEditEnabled, setNumChannels, setTuning, testSampleDirectory, writeSpecialXMLTags
Methods inherited from class com.softsynth.jmsl.InstrumentAdapter
getDimensionNameSpace, getInterpreter, getMixerClassName, getMusicDevice, getName, getTransposition, noteOff, noteOn, noteOnFor, setDimensionNameSpace, setInterpreter, setMixerClassName, setMusicDevice, setName, setTransposition, toString, update
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
TransposingSamplePlayingInstrument
public TransposingSamplePlayingInstrument()Deprecated. -
TransposingSamplePlayingInstrument
public TransposingSamplePlayingInstrument(java.lang.String sampleDirectory)Deprecated.constructor. sample directory string must end in dir delimitter, ex "F:\samples\"
-
-
Method Details
-
buildFromAttributes
public void buildFromAttributes()Deprecated.- Specified by:
buildFromAttributes
in interfaceAttributeBuildable
- Overrides:
buildFromAttributes
in classSimpleSamplePlayingInstrument
-
setUpdateDimension
public void setUpdateDimension(int dim)Deprecated.Description copied from interface:UpdatableInstrument
Set the dimension to match against when update() is called. This is used to retrieve the SynthNote which was play()'ed and is currently sounding, and which wants to be updated . Defaults to 1, which is the "pitch" dimension
Used by API to support old JSyn. New JSyn uses voiceToken to look up an allocated voice so update() does not need a specific dimension to do lookup.- Specified by:
setUpdateDimension
in interfaceUpdatableInstrument
-
getUpdateDimension
public int getUpdateDimension()Deprecated.Description copied from interface:UpdatableInstrument
Get the dimension to match against when update() is called. This is used to retrieve the SynthNote which was play()'ed and is currently sounding, and which wants to be updated . Defaults to 1, which is the "pitch" dimension- Specified by:
getUpdateDimension
in interfaceUpdatableInstrument
-
on
public java.lang.Object on(double playTime, double timeStretch, double[] dar)Deprecated.Description copied from class:SimpleSamplePlayingInstrument
Look up sample assiciated with dar[1]. Allocate a FixedRateSampleReader to play it. dar[3] is not used to cut sample short if the value is less than duration of sample. This instrument imsply queues up a sample and lets it run. Use off() to terminate early.- Specified by:
on
in interfaceInstrument
- Overrides:
on
in classSimpleSamplePlayingInstrument
- Returns:
- the allocated FixedRateSampleReader or null of there is no sample associated with dar[1]
- See Also:
Instrument.on(double, double, double[])
-
off
public java.lang.Object off(double playTime, double timeStretch, double[] dar)Deprecated.Description copied from class:SimpleSamplePlayingInstrument
Turn off all voices that are playing the sample associated with pitchIndex dar[1]. These voices are stored in a hsahtable whenever play() is called. There may be more than one voice playing the sample mapped to index 60 for example. Turning off is accomplished by queuing up the last frame of the sample, with Synth.FLAG_AUTO_STOP- Specified by:
off
in interfaceInstrument
- Overrides:
off
in classSimpleSamplePlayingInstrument
- Returns:
- null
- See Also:
com.softsynth.jmsl.Instrument#off(double, Object)
-
play
public double play(double playTime, double timeStretch, double[] dar)Deprecated.Description copied from class:SimpleSamplePlayingInstrument
If there is a sample loaded at dar[1], bang it. No sustain, no transposition. Hold time is not used to terminate sample early.- Specified by:
play
in interfaceInstrument
- Overrides:
play
in classSimpleSamplePlayingInstrumentWithLoops
-
playOLD
public double playOLD(double playTime, double timeStretch, double[] dar)Deprecated. -
calcRateForTransposition
public double calcRateForTransposition(double audioFrameRate, double pitch, double closestSampledPitch)Deprecated.If you have a smaple tuned to closestSampledPitch, this method calculates the playback rate to make that smaple sound at desired pitch. If this instrument has a Tuning, this method will use it else it will use 12tet- Parameters:
audioFrameRate
-pitch
-closestSampledPitch
-- Returns:
- rate to play back sample tuned to closestSampledPitch to achieve pitch
-
main
public static void main(java.lang.String[] args)Deprecated.
-