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 voidaddSignalSource(java.lang.Object signalSource)voidbuildFromAttributes()intgetNumOutputs()java.lang.ObjectgetOutput()get this output (SynthOutput in the case of a JSyn Instrument, for examplejava.lang.ObjectgetOutput(int partNumber)intgetPolyphony()intgetPreset()TuninggetTuning()UnitVoiceArraygetUnitVoiceArray()java.lang.StringgetUnitVoiceClassName()com.jsyn.util.VoiceAllocatorgetVoiceAllocator()booleanisSignalProcessor()static voidmain(java.lang.String[] args)doubleplay(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.voidremoveAllSignalSources()voidsetPolyphony(int polyphony)voidsetPreset(int preset)voidsetTuning(Tuning tuning)voidsetUnitVoiceClassName(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, updateMethods 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:
getNumOutputsin interfaceOutputProvider- Overrides:
getNumOutputsin classInstrumentAdapter- Returns:
- 0
-
getOutput
public java.lang.Object getOutput()Description copied from interface:OutputProviderget this output (SynthOutput in the case of a JSyn Instrument, for example- Specified by:
getOutputin interfaceOutputProvider- Overrides:
getOutputin classInstrumentAdapter- Returns:
- null
-
getOutput
public java.lang.Object getOutput(int partNumber)- Specified by:
getOutputin interfaceOutputProvider- Overrides:
getOutputin 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:
buildFromAttributesin 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:InstrumentAdapterYou 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:
playin interfaceInstrument- Overrides:
playin classInstrumentAdapter
-
getVoiceAllocator
public com.jsyn.util.VoiceAllocator getVoiceAllocator() -
main
public static void main(java.lang.String[] args)
-