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 Details

  • 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 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)