com.softsynth.jmsl.max
Class MaxInstrument

java.lang.Object
  extended by com.softsynth.jmsl.InstrumentAdapter
      extended by 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

Author:
Nick Didkovsky, Langdon Crawford, didkovn@mail.rockefeller.edu

Field Summary
static int MAX_INS_OFF
           
static int MAX_INS_ON
           
static int MAX_INS_PLAY
           
static int MAX_INS_UPDATE
           
 
Constructor Summary
MaxInstrument()
           
 
Method Summary
 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 example
 boolean getEditEnabled()
           
 int getInsIndex()
           
 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)
           
 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 Detail

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 Detail

MaxInstrument

public MaxInstrument()
Method Detail

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 interface Instrument
Overrides:
on in class InstrumentAdapter
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 interface Instrument
Overrides:
off in class InstrumentAdapter
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 interface Instrument
Overrides:
play in class InstrumentAdapter

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 interface Instrument
Overrides:
update in class InstrumentAdapter

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

Specified by:
edit in interface Editable

addEditListener

public void addEditListener(EditListener listener)
Specified by:
addEditListener in interface Editable

removeEditListener

public void removeEditListener(EditListener listener)
Specified by:
removeEditListener in interface Editable

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 interface Editable

getEditEnabled

public boolean getEditEnabled()
Specified by:
getEditEnabled in interface Editable
Returns:
flag

handleSpecialTag

public boolean handleSpecialTag(java.lang.String tag,
                                java.util.Hashtable attributes)
Specified by:
handleSpecialTag in interface HandleSpecialXMLTag
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.IOException
Description 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 interface HandleSpecialXMLTag
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 interface OutputProvider
Overrides:
getOutput in class InstrumentAdapter
Returns:
null

getOutput

public java.lang.Object getOutput(int partNumber)
Specified by:
getOutput in interface OutputProvider
Overrides:
getOutput in class InstrumentAdapter
Returns:
null

getNumOutputs

public int getNumOutputs()
Specified by:
getNumOutputs in interface OutputProvider
Overrides:
getNumOutputs in class InstrumentAdapter
Returns:
0

main

public static void main(java.lang.String[] args)

setJmslInstrumentToMax

public static void setJmslInstrumentToMax(JMSLInstrumentToMax jmslInstrumentToMax)