|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.softsynth.jmsl.InstrumentAdapter
public class InstrumentAdapter
An Instrument sonifies double[] data in its play() method, either directly or by invoking its Interpreter.
The double[] data may have come from a MusicShape or may be built
on the fly somewhere else (like in a MusicJob, for example,
which has an Instrument and could repeatedly assemble a double[] and hand it to its
Instrument.play()
You may provide custom interpretation of MusicShape data (ie double[]) one of two ways:
1) by providing an Instrument with an Intepreter, or
2) overriding Instrument's play() method and doing the interpretation there directly.
JMSL v102 introduced the DimensionNameSpace class. Instrument.play() can use the DimensionNameSpace to retrieve
values from the double[] by name (like "modfreq") instead of by dimension index.
InstrumentAdapter's constructor sets its DimensionNameSpace to DefaultDimensionNameSpace.instance()
Your subclasses may of course setDimensionNameSpace(yourDimNameSpace)
DefaultDimensionNameSpace,
DimensionNameSpace| Constructor Summary | |
|---|---|
InstrumentAdapter()
|
|
| Method Summary | |
|---|---|
double |
close(double playTime)
|
DimensionNameSpace |
getDimensionNameSpace()
|
Interpreter |
getInterpreter()
|
java.lang.String |
getMixerClassName()
The default implementation returns "com.softsynth.jmsl.NullMixer" |
MusicDevice |
getMusicDevice()
Get the MusicDevice associated with this Instrument |
java.lang.String |
getName()
|
int |
getNumOutputs()
|
java.lang.Object |
getOutput()
get this output (SynthOutput in the case of a JSyn Instrument, for example |
java.lang.Object |
getOutput(int partNumber)
|
double |
getTransposition()
|
static void |
main(java.lang.String[] args)
|
double |
noteOff(double playTime,
double pitch,
double velocity)
Override to provide custom functionality. |
double |
noteOn(double playTime,
double pitch,
double velocity)
Override to provide custom functionality. |
double |
noteOnFor(double playTime,
double holdtime,
double pitch,
double velocity)
Calls noteOn() and noteOff() holdtime later. |
java.lang.Object |
off(double playTime,
double timeStretch,
double[] dar)
|
java.lang.Object |
on(double playTime,
double timeStretch,
double[] dar)
turn an event on. |
double |
open(double playTime)
|
double |
play(double playTime,
double timeStretch,
double[] dar)
You can override this play() method with your own custom code, if you don't want to use an interpreter. |
void |
setDimensionNameSpace(DimensionNameSpace dns)
|
void |
setInterpreter(Interpreter interp)
Plug a custom interpreter into this instrument. |
void |
setMixerClassName(java.lang.String mixerClassName)
set the preferred Mixer class name (if any) for this Instrument |
void |
setMusicDevice(MusicDevice dev)
Set the MusicDevice associated with this Instrument |
void |
setName(java.lang.String n)
|
void |
setTransposition(double steps)
|
java.lang.String |
toString()
|
double |
update(double playTime,
double timeStretch,
double[] dar)
update is used to change parameters on a sound event that has already been sounded by play() and is currently sounding. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public InstrumentAdapter()
| Method Detail |
|---|
public void setDimensionNameSpace(DimensionNameSpace dns)
setDimensionNameSpace in interface Instrumentpublic DimensionNameSpace getDimensionNameSpace()
getDimensionNameSpace in interface Instrumentpublic void setTransposition(double steps)
setTransposition in interface Transposablepublic double getTransposition()
getTransposition in interface Transposablepublic void setInterpreter(Interpreter interp)
setInterpreter in interface Instrumentpublic Interpreter getInterpreter()
getInterpreter in interface Instrument
public double open(double playTime)
throws java.lang.InterruptedException
open in interface Instrumentjava.lang.InterruptedException
public double close(double playTime)
throws java.lang.InterruptedException
close in interface Instrumentjava.lang.InterruptedException
public double play(double playTime,
double timeStretch,
double[] dar)
public double play(double playTime, double timeStretch, double dar[])
{
if (interpreter != null) playTime = interpreter.interpret(playTime, timeStretch, dar, this );
return playTime; // note: if interpreter == null, this will return a playTime with no time delay.
}
IMPORTANT: A typical return would be return playTime + dar[0] * timeStretch; which follows a
convention of putting duration value in dar[0]. If you don't add something to playTime, play() will be
scheduled as though it took no time (unless interpreter returns a later playTime).
play in interface Instrument
public double update(double playTime,
double timeStretch,
double[] dar)
update in interface Instrument
public double noteOn(double playTime,
double pitch,
double velocity)
public double noteOff(double playTime,
double pitch,
double velocity)
public double noteOnFor(double playTime,
double holdtime,
double pitch,
double velocity)
public java.lang.String getName()
getName in interface Namablepublic void setName(java.lang.String n)
setName in interface Namablepublic java.lang.String toString()
toString in class java.lang.Objectpublic void setMusicDevice(MusicDevice dev)
Instrument
setMusicDevice in interface Instrumentpublic MusicDevice getMusicDevice()
Instrument
getMusicDevice in interface Instrumentpublic static void main(java.lang.String[] args)
public java.lang.Object getOutput()
OutputProvider
getOutput in interface OutputProviderpublic java.lang.Object getOutput(int partNumber)
getOutput in interface OutputProviderpublic int getNumOutputs()
getNumOutputs in interface OutputProviderpublic java.lang.String getMixerClassName()
getMixerClassName in interface Instrumentpublic void setMixerClassName(java.lang.String mixerClassName)
setMixerClassName in interface Instrument
public java.lang.Object on(double playTime,
double timeStretch,
double[] dar)
Instrument
on in interface InstrumentInstrument.on(double, double, double[])
public java.lang.Object off(double playTime,
double timeStretch,
double[] dar)
off in interface Instrumentcom.softsynth.jmsl.Instrument#off(double, Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||