Package com.softsynth.jmsl.max
Class MaxInstrument
java.lang.Object
com.softsynth.jmsl.InstrumentAdapter
com.softsynth.jmsl.max.MaxInstrument
- All Implemented Interfaces:
Editable
,Instrument
,Namable
,OutputProvider
,Transposable
,HandleSpecialXMLTag
public class MaxInstrument extends InstrumentAdapter implements Editable, HandleSpecialXMLTag
A MaxInstrument is a JMSL Instrument that can be used to send scheduled data to Max. Edit to give
it a custom DimensionNameSpaces for paramteric control over MSP patches, for example. The on(),
off(), play(), and update() methods pass data to Max through the static JMSLInstrumentToMax
-
Definitions of these methods are as follows.
- on() turns a voice on and lets it sound indefinitely
- off() turn a voice off
- play() turns a voice on for a specified duration (hold in JMSL parlance)
- update() looks up a voice and changes its synthesis parameters
- Author:
- Nick Didkovsky, Langdon Crawford, nick@didkovsky.com
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_INS_OFF
static int
MAX_INS_ON
static int
MAX_INS_PLAY
static int
MAX_INS_UPDATE
-
Constructor Summary
Constructors Constructor Description MaxInstrument()
-
Method Summary
Modifier and Type Method Description void
addEditListener(EditListener listener)
void
beginElement(java.lang.String tag, java.util.Hashtable attributes, boolean ifEmpty)
void
edit(java.awt.Frame f)
Bring up a Dialog for editing, for exampleboolean
getEditEnabled()
int
getInsIndex()
int
getNumOutputs()
java.lang.Object
getOutput()
get this output (SynthOutput in the case of a JSyn Instrument, for examplejava.lang.Object
getOutput(int partNumber)
boolean
handleSpecialTag(java.lang.String tag, java.util.Hashtable attributes)
static void
main(java.lang.String[] args)
java.lang.Object
off(double playTime, double timeStretch, double[] data)
Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers.java.lang.Object
on(double playTime, double timeStretch, double[] data)
Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers.double
play(double playTime, double timeStretch, double[] data)
Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers.void
removeEditListener(EditListener listener)
static void
resetInstrumentIndex()
Reset static MaxInstrument index to 0.void
setEditEnabled(boolean flag)
Set a flag.void
setInsIndex(int myInsIndex)
static void
setJmslInstrumentToMax(JMSLInstrumentToMax jmslInstrumentToMax)
double
update(double playTime, double timeStretch, double[] data)
Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers.void
writeSpecialXMLTags(java.io.PrintWriter out)
Write special tags out that do not conform to get/set bean model.Methods inherited from class com.softsynth.jmsl.InstrumentAdapter
close, getDimensionNameSpace, getInterpreter, getMixerClassName, getMusicDevice, getName, getTransposition, noteOff, noteOn, noteOnFor, open, setDimensionNameSpace, setInterpreter, setMixerClassName, setMusicDevice, setName, setTransposition, toString
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
MAX_INS_OFF
public static final int MAX_INS_OFF- See Also:
- Constant Field Values
-
MAX_INS_ON
public static final int MAX_INS_ON- See Also:
- Constant Field Values
-
MAX_INS_UPDATE
public static final int MAX_INS_UPDATE- See Also:
- Constant Field Values
-
MAX_INS_PLAY
public static final int MAX_INS_PLAY- See Also:
- Constant Field Values
-
-
Constructor Details
-
MaxInstrument
public MaxInstrument()
-
-
Method Details
-
on
public java.lang.Object on(double playTime, double timeStretch, double[] data)Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers. data[4] will be set to MAX_INS_ON = 1 to indicate the sound should allocate a new voice. (ie whatever value is in data[4] will be overwritten in this method). Unlike a call to play(), the off time of this voice is not specified. This simply starts a voice sounding.- Specified by:
on
in interfaceInstrument
- Overrides:
on
in classInstrumentAdapter
- Returns:
- data
- See Also:
Instrument.on(double, double, double[])
-
off
public java.lang.Object off(double playTime, double timeStretch, double[] data)Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers. data[4] will be set to MAX_INS_OFF = 0 to indicate the voice allocated for the indicated pitch should shut off. (ie whatever value is in data[4] will be overwritten in this method). This simply turns off an allocated voice.- Specified by:
off
in interfaceInstrument
- Overrides:
off
in classInstrumentAdapter
- Returns:
- data
- See Also:
com.softsynth.jmsl.Instrument#off(double, Object)
-
play
public double play(double playTime, double timeStretch, double[] data)Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers. data[4] will be set to MAX_INS_PLAY = 3 to indicate the sound should allocated a new voice instead of updating a sounding voice. (ie whatever value is in data[4] will be overwritten in this method)- Specified by:
play
in interfaceInstrument
- Overrides:
play
in classInstrumentAdapter
-
update
public double update(double playTime, double timeStretch, double[] data)Sends data to JMSLInstrumentToMax where it can be unpacked and sent to various MSP, CSound, etc sound makers. data[4] will be set to MAX_INS_UPDATE = 2 to indicate the data should update a sustaining voice of the matching pitch. (ie whatever value is in data[4] will be overwritten in this method)- Specified by:
update
in interfaceInstrument
- Overrides:
update
in classInstrumentAdapter
-
resetInstrumentIndex
public static void resetInstrumentIndex()Reset static MaxInstrument index to 0. Do this before creating new scores or new orchestras contianing maxInstruments so your instruments will always start being indexed at 0 -
getInsIndex
public int getInsIndex()- Returns:
- max instrument index, which is read by Max to differentiate where to send incoming data
-
setInsIndex
public void setInsIndex(int myInsIndex)- Parameters:
myInsIndex
- The myInsIndex to set.
-
edit
public void edit(java.awt.Frame f)Description copied from interface:Editable
Bring up a Dialog for editing, for example -
addEditListener
- Specified by:
addEditListener
in interfaceEditable
-
removeEditListener
- Specified by:
removeEditListener
in interfaceEditable
-
setEditEnabled
public void setEditEnabled(boolean flag)Description copied from interface:Editable
Set a flag. For example you might setEditEnabled(false) after first edit(), or you might hard code values for some Editable class and so want to disable editing.- Specified by:
setEditEnabled
in interfaceEditable
-
getEditEnabled
public boolean getEditEnabled()- Specified by:
getEditEnabled
in interfaceEditable
- Returns:
- flag
-
handleSpecialTag
public boolean handleSpecialTag(java.lang.String tag, java.util.Hashtable attributes)- Specified by:
handleSpecialTag
in interfaceHandleSpecialXMLTag
- Returns:
- true if this tag is recognized as special, false if the object permits normal bean model to handle attribute/value pairs
-
writeSpecialXMLTags
public void writeSpecialXMLTags(java.io.PrintWriter out) throws java.io.IOExceptionDescription copied from interface:HandleSpecialXMLTag
Write special tags out that do not conform to get/set bean model. Called by SimpleXMLSaver.writeXML() for objects that implement this interface- Specified by:
writeSpecialXMLTags
in interfaceHandleSpecialXMLTag
- Throws:
java.io.IOException
-
beginElement
public void beginElement(java.lang.String tag, java.util.Hashtable attributes, boolean ifEmpty) -
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
-
getNumOutputs
public int getNumOutputs()- Specified by:
getNumOutputs
in interfaceOutputProvider
- Overrides:
getNumOutputs
in classInstrumentAdapter
- Returns:
- 0
-
main
public static void main(java.lang.String[] args) -
setJmslInstrumentToMax
-