|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.InstrumentAdapter com.softsynth.jmsl.jsyn.SimpleSamplePlayingInstrument
public class SimpleSamplePlayingInstrument
A JMSL Instrument that plays SynthSamples, mapped to integer pitch values. "One shot" style. No
transposition, no loop points, plays all the way through
If loadSample() fails to find it it will open a SampleFinderDialog.
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 hr16_stereo/AlesisKick.aif, then your applet's CODEBASE,
which might be a folder called "classes", should contain hr16_stereo/AlesisKick.aif
IMPORTANT: stereo samples must be AIFF for versions of JSyn prior to 1.43 ( see
http://www.softsynth.com/jsyn/support/bugs.html#BUG0007 )
Since JMSLv103, SimpleSamplePlayingInstrument performs stereo AIF samples as well. For example:
SimpleSamplePlayingInstrument ins = new SimpleSamplePlayingInstrument("F:\\JMSLScoreWork\\JMSLScoreSamples\\"); ins.setNumChannels(2); ins.getMusicDevice().edit(f); ins.getMusicDevice().open(); ins.addSamplePitch("hr16_stereo\\AlesisKick.aif", 60); ins.addSamplePitch("hr16_stereo\\AlesisSnare.aif", 61); ins.addSamplePitch("hr16_stereo\\AlesisFloorTom.aif", 62); ins.addSamplePitch("hr16_stereo\\AlesisRackTom1.aif", 63); ins.addSamplePitch("hr16_stereo\\AlesisRackTom2.aif", 64); ins.buildFromAttributes(); JMSLMixerContainer mixer = new JMSLMixerContainer(); mixer.addInstrument(ins); mixer.start();This version adds new feature of being able to map pitches to different samples based on performance data, by overriding getAlternativeSampleIndex().
SimpleSamplePlayingInstrumentWithAmplitudeMap
Field Summary | |
---|---|
int |
POLYPHONY
max number of voices to allocate, default 32. |
Constructor Summary | |
---|---|
SimpleSamplePlayingInstrument()
|
|
SimpleSamplePlayingInstrument(java.lang.String sampleDirectory)
Sample directory string must end in file separator, ex "F:\samples\" All samples will be sought in this directory. |
Method Summary | |
---|---|
void |
addEditListener(EditListener listener)
|
void |
addSamplePitch(short[] shorts,
int pitch)
Assign a dynamically created sample to a note index. |
void |
addSamplePitch(java.lang.String filename,
int pitch)
Assign a sample to be triggered when noteIndex is passed to play(). |
void |
addSamplePitch(com.softsynth.jsyn.SynthSample sample,
int pitch)
Assign a dynamically created sample to a note index. |
void |
buildFromAttributes()
|
void |
clear()
remove all samples and pitch mappings |
double |
close(double time)
|
void |
edit(java.awt.Frame fr)
Open a Frame containing a SampleInstrumentMapperPanel for this instrument. |
int |
getAlternativeSampleIndex(int pitchIndex,
double timeStretch,
double[] data)
Precondition: pitchIndex points to a valid sample, previously loaded with addSamplePitch(). |
java.lang.String |
getDirectory()
|
boolean |
getEditEnabled()
|
int |
getNumChannels()
|
int |
getNumOutputs()
|
java.lang.Object |
getOutput()
get this output (SynthOutput in the case of a JSyn Instrument, for example |
java.lang.Object |
getOutput(int part)
same as getOutput(), only one output |
double[] |
getPitches()
|
java.lang.String |
getSampleFilename(int pitch)
|
java.util.Hashtable |
getSynthSamples()
|
Tuning |
getTuning()
|
java.util.Hashtable |
getVoices()
voices is a hashtable whose keys are synthnotes returned by allocator.steal() ( called in on() method), and whose values are the pitch which they were used to bang. |
boolean |
handleSpecialTag(java.lang.String tag,
java.util.Hashtable attributes)
HandleSpecialXMLTag interface. |
static void |
main(java.lang.String[] args)
|
void |
notifyEditListeners()
|
java.lang.Object |
off(double playTime,
double timeStretch,
double[] dar)
Turn off all voices that are playing the sample associated with pitchIndex dar[1]. |
java.lang.Object |
on(double playTime,
double timeStretch,
double[] dar)
Look up sample assiciated with dar[1]. |
double |
open(double time)
|
double |
play(double playTime,
double timeStretch,
double[] dar)
If there is a sample loaded at dar[1], bang it. |
void |
reload()
|
void |
removeEditListener(EditListener listener)
|
void |
setDirectory(java.lang.String dir)
|
void |
setEditEnabled(boolean flag)
noop |
void |
setNumChannels(int i)
|
void |
setTuning(Tuning tuning)
|
void |
testSampleDirectory()
|
void |
writeSpecialXMLTags(java.io.PrintWriter out)
write pitch / soundfilename pairs to XML file These are not covered by simple bean model since there are many such pairs. |
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 |
Field Detail |
---|
public int POLYPHONY
Constructor Detail |
---|
public SimpleSamplePlayingInstrument()
public SimpleSamplePlayingInstrument(java.lang.String sampleDirectory)
Method Detail |
---|
public void clear()
public double open(double time) throws java.lang.InterruptedException
open
in interface Instrument
open
in class InstrumentAdapter
java.lang.InterruptedException
public double close(double time) throws java.lang.InterruptedException
close
in interface Instrument
close
in class InstrumentAdapter
java.lang.InterruptedException
public void setDirectory(java.lang.String dir)
setDirectory
in interface DirectorySettable
public java.lang.String getDirectory()
getDirectory
in interface DirectorySettable
public void testSampleDirectory()
public void reload()
public java.lang.Object getOutput()
OutputProvider
getOutput
in interface OutputProvider
getOutput
in class InstrumentAdapter
public java.lang.Object getOutput(int part)
getOutput
in interface OutputProvider
getOutput
in class InstrumentAdapter
public int getNumOutputs()
getNumOutputs
in interface OutputProvider
getNumOutputs
in class InstrumentAdapter
public void addSamplePitch(java.lang.String filename, int pitch)
public void addSamplePitch(com.softsynth.jsyn.SynthSample sample, int pitch)
public void addSamplePitch(short[] shorts, int pitch)
public java.lang.String getSampleFilename(int pitch)
public java.util.Hashtable getSynthSamples()
public double[] getPitches()
public int getAlternativeSampleIndex(int pitchIndex, double timeStretch, double[] data)
public java.lang.Object on(double playTime, double timeStretch, double[] dar)
on
in interface Instrument
on
in class InstrumentAdapter
Instrument.on(double, double, double[])
public double play(double playTime, double timeStretch, double[] dar)
play
in interface Instrument
play
in class InstrumentAdapter
public java.lang.Object off(double playTime, double timeStretch, double[] dar)
off
in interface Instrument
off
in class InstrumentAdapter
com.softsynth.jmsl.Instrument#off(double, Object)
public void buildFromAttributes()
buildFromAttributes
in interface AttributeBuildable
public Tuning getTuning()
public void setTuning(Tuning tuning)
tuning
- to be stored in this instrument. Not used to perform.public boolean handleSpecialTag(java.lang.String tag, java.util.Hashtable attributes)
handleSpecialTag
in interface HandleSpecialXMLTag
HandleSpecialXMLTag.handleSpecialTag(java.lang.String,
java.util.Hashtable)
public void writeSpecialXMLTags(java.io.PrintWriter out) throws java.io.IOException
writeSpecialXMLTags
in interface HandleSpecialXMLTag
java.io.IOException
HandleSpecialXMLTag.writeSpecialXMLTags(java.io.PrintWriter)
public void notifyEditListeners()
public void addEditListener(EditListener listener)
addEditListener
in interface Editable
public void removeEditListener(EditListener listener)
removeEditListener
in interface Editable
public void edit(java.awt.Frame fr)
edit
in interface Editable
Editable.edit(java.awt.Frame)
public void setEditEnabled(boolean flag)
setEditEnabled
in interface Editable
Editable.setEditEnabled(boolean)
public boolean getEditEnabled()
getEditEnabled
in interface Editable
public static void main(java.lang.String[] args)
public int getNumChannels()
public void setNumChannels(int i)
i
- public java.util.Hashtable getVoices()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |