Package com.softsynth.jmsl.jsyn2
Class JSynSimpleUnitVoiceInstrument
java.lang.Object
com.softsynth.jmsl.InstrumentAdapter
com.softsynth.jmsl.jsyn2.JSynSimpleUnitVoiceInstrument
- All Implemented Interfaces:
Instrument
,Namable
,OutputProvider
,Transposable
,AttributeBuildable
,Tunable
- Direct Known Subclasses:
JSynUnitVoiceInstrument
,SamplePlayingInstrument
public class JSynSimpleUnitVoiceInstrument extends InstrumentAdapter implements AttributeBuildable, Tunable
-
Constructor Summary
Constructors Constructor Description JSynSimpleUnitVoiceInstrument()
JSynSimpleUnitVoiceInstrument(java.lang.String className, int polyphony)
JSynSimpleUnitVoiceInstrument(java.lang.String className, int polyphony, int preset)
-
Method Summary
Modifier and Type Method Description void
addSignalSource(java.lang.Object signalSource)
void
buildFromAttributes()
int
getNumOutputs()
java.lang.Object
getOutput()
get this output (SynthOutput in the case of a JSyn Instrument, for examplejava.lang.Object
getOutput(int partNumber)
int
getPolyphony()
int
getPreset()
Tuning
getTuning()
UnitVoiceArray
getUnitVoiceArray()
java.lang.String
getUnitVoiceClassName()
com.jsyn.util.VoiceAllocator
getVoiceAllocator()
boolean
isSignalProcessor()
static void
main(java.lang.String[] args)
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
removeAllSignalSources()
void
setPolyphony(int polyphony)
void
setPreset(int preset)
void
setTuning(Tuning tuning)
void
setUnitVoiceClassName(java.lang.String unitVoiceClassName)
Methods inherited from class com.softsynth.jmsl.InstrumentAdapter
close, getDimensionNameSpace, getInterpreter, getMixerClassName, getMusicDevice, getName, getTransposition, noteOff, noteOn, noteOnFor, off, on, open, 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
-
JSynSimpleUnitVoiceInstrument
public JSynSimpleUnitVoiceInstrument() -
JSynSimpleUnitVoiceInstrument
public JSynSimpleUnitVoiceInstrument(java.lang.String className, int polyphony, int preset) -
JSynSimpleUnitVoiceInstrument
public JSynSimpleUnitVoiceInstrument(java.lang.String className, int polyphony)
-
-
Method Details
-
getNumOutputs
public int getNumOutputs()- Specified by:
getNumOutputs
in interfaceOutputProvider
- Overrides:
getNumOutputs
in classInstrumentAdapter
- Returns:
- 0
-
getOutput
public java.lang.Object getOutput()Description copied from interface:OutputProvider
get this output (SynthOutput in the case of a JSyn Instrument, for example- Specified by:
getOutput
in interfaceOutputProvider
- Overrides:
getOutput
in classInstrumentAdapter
- Returns:
- null
-
getOutput
public java.lang.Object getOutput(int partNumber)- Specified by:
getOutput
in interfaceOutputProvider
- Overrides:
getOutput
in classInstrumentAdapter
- Returns:
- null
-
getPolyphony
public int getPolyphony() -
setPolyphony
public void setPolyphony(int polyphony) -
getPreset
public int getPreset()- Returns:
- the preset index
-
setPreset
public void setPreset(int preset)- Parameters:
preset
- the preset to set
-
buildFromAttributes
public void buildFromAttributes()- Specified by:
buildFromAttributes
in interfaceAttributeBuildable
-
isSignalProcessor
public boolean isSignalProcessor()- Returns:
- true if this Instrument contains UnitSinks capable of accepting signal inputs
-
addSignalSource
public void addSignalSource(java.lang.Object signalSource) -
removeAllSignalSources
public void removeAllSignalSources() -
getUnitVoiceArray
- Returns:
- a list of all instantiated voices
-
getTuning
-
setTuning
-
getUnitVoiceClassName
public java.lang.String getUnitVoiceClassName() -
setUnitVoiceClassName
public void setUnitVoiceClassName(java.lang.String unitVoiceClassName) -
play
public double play(double playTime, double timeStretch, double[] dar)Description copied from class:InstrumentAdapter
You can override this play() method with your own custom code, if you don't want to use an interpreter. Be sure to return same or updated playTime!
Source of default implementation of play():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).
RE-EMPHASIS: This return comment assumes that there is no interpreter returning an updated playTime. A stock Instrument does set its Interpreter to a default printing Interpreter which does update playTime, using dar[0] as duration. So the default Instrument.play() shown above will schedule itself as expected.- Specified by:
play
in interfaceInstrument
- Overrides:
play
in classInstrumentAdapter
-
getVoiceAllocator
public com.jsyn.util.VoiceAllocator getVoiceAllocator() -
main
public static void main(java.lang.String[] args)
-