com.softsynth.jmsl
Class JMSLMixerContainer

java.lang.Object
  extended by com.softsynth.jmsl.JMSLMixerContainer
All Implemented Interfaces:
Mixer, PanAmpListener, XMLWritable

public class JMSLMixerContainer
extends java.lang.Object
implements Mixer, XMLWritable

A heterogenous Mixer which can accept any Instrument whose getMixerClassName() returns a valid class name. This Mixer can therefore set up faders for MidiInstruments and JSyn Instruments. It is really a container of Mixer implementations, which are created by asking the Instrument for its Mixer classname. It maintains a Hashtable of Mixer classname to Mixer instances. All instruments with the same Mixer classname will all get added to the same Mixer. The Faders on this mixer container are mapped to the faders of the Mixer implementations it contains.

Author:
Nick Didkovsky, email: didkovn@mail.rockefeller.edu, (c) 2003 Nick Didkovsky, all rights reserved.

Constructor Summary
JMSLMixerContainer()
           
 
Method Summary
 int addInstrument(Instrument ins)
          When Instruments are added to this Mixer, they are implicitely associated with an autoincrementing fader index.
 int addInstrument(Instrument ins, double pan, double amp)
          add Instrument with initial pan and amp values.
 double getAmp(int faderIndex)
           
 int[] getFaderIndexes(Instrument ins)
          faders index(es) associated with an instrument, or NULL if not found
 boolean getFaderMute(int faderNumer)
           
 boolean getFaderSolo(int faderNumer)
           
 java.awt.Component getGUIComponent()
          The GUI component is an extra component a Mixer can make available for a layout.
 Instrument getInstrument(int insIndex)
          Get instrument associated with fader index (some instruments may have more than one fader, so you cannot assume fader n goes with ins n)
 Mixer getMixer(java.lang.String mixerClassName)
           
 int getNumFaders()
           
 double getPan(int faderIndex)
           
 java.awt.Component getPanAmpControlPanel()
           
 java.awt.Component getPanAmpControlPanel(int rows, int cols)
           
 java.awt.Component getPanAmpControlPanel(int rows, int cols, int hgap, int vgap)
           
static void main(java.lang.String[] args)
           
 void muteChange(int faderIndex, boolean flag)
           
 void panAmpChange(int faderIndex, double pan, double amp)
          Pass pan/amp change for this faderindex down to the fader's associated mixer and its asociated fader number on that mixer
 void removeInstrument(Instrument ins)
          Calls removeInstrument(ins) on mixer which owns ins.
 void repatch(Instrument ins)
          Enumerate all MixerFaders.
 void setFaderMute(int faderNumber, boolean flag)
           
 void setFaderSolo(int faderNumber, boolean flag)
           
 void setFromPanAmpPairs(java.util.Vector panAmpPairs)
           
 void soloChange(int faderIndex, boolean flag)
           
 void start()
          Start all mixers in this mixer
 void stop()
          Stop all mixers in this mixer
 void writeXML(java.io.PrintWriter out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSLMixerContainer

public JMSLMixerContainer()
Method Detail

addInstrument

public int addInstrument(Instrument ins)
Description copied from interface: Mixer
When Instruments are added to this Mixer, they are implicitely associated with an autoincrementing fader index.

Specified by:
addInstrument in interface Mixer
Returns:
number of new faders added to mixer by adding this instrument

addInstrument

public int addInstrument(Instrument ins,
                         double pan,
                         double amp)
Description copied from interface: Mixer
add Instrument with initial pan and amp values. Both pan and amp range 0..1

Specified by:
addInstrument in interface Mixer

removeInstrument

public void removeInstrument(Instrument ins)
Calls removeInstrument(ins) on mixer which owns ins. Then removes its own MixerFaders associated with ins. It is the the programmer's task to refresh the GUI as a result, calling getPanAmpPanel() for example, to get a new set of valid components.

Specified by:
removeInstrument in interface Mixer

setFaderMute

public void setFaderMute(int faderNumber,
                         boolean flag)
Specified by:
setFaderMute in interface Mixer

setFaderSolo

public void setFaderSolo(int faderNumber,
                         boolean flag)
Specified by:
setFaderSolo in interface Mixer

getFaderMute

public boolean getFaderMute(int faderNumer)
Specified by:
getFaderMute in interface Mixer

getFaderSolo

public boolean getFaderSolo(int faderNumer)
Specified by:
getFaderSolo in interface Mixer

repatch

public void repatch(Instrument ins)
Enumerate all MixerFaders. For each one whose instrument equals argument, call repatch() on its Mixer implementation

Specified by:
repatch in interface Mixer

getMixer

public Mixer getMixer(java.lang.String mixerClassName)
Returns:
Mixer contained in this class with the specified classname. Could return null

getInstrument

public Instrument getInstrument(int insIndex)
Description copied from interface: Mixer
Get instrument associated with fader index (some instruments may have more than one fader, so you cannot assume fader n goes with ins n)

Specified by:
getInstrument in interface Mixer

getFaderIndexes

public int[] getFaderIndexes(Instrument ins)
Description copied from interface: Mixer
faders index(es) associated with an instrument, or NULL if not found

Specified by:
getFaderIndexes in interface Mixer

getNumFaders

public int getNumFaders()
Specified by:
getNumFaders in interface Mixer

getPan

public double getPan(int faderIndex)
Specified by:
getPan in interface Mixer

getAmp

public double getAmp(int faderIndex)
Specified by:
getAmp in interface Mixer

getGUIComponent

public java.awt.Component getGUIComponent()
The GUI component is an extra component a Mixer can make available for a layout. This method collects all components returns by getGUIComponent() by its submixers, into one grid layout

Specified by:
getGUIComponent in interface Mixer

start

public void start()
Start all mixers in this mixer

Specified by:
start in interface Mixer

stop

public void stop()
Stop all mixers in this mixer

Specified by:
stop in interface Mixer

panAmpChange

public void panAmpChange(int faderIndex,
                         double pan,
                         double amp)
Pass pan/amp change for this faderindex down to the fader's associated mixer and its asociated fader number on that mixer

Specified by:
panAmpChange in interface PanAmpListener

muteChange

public void muteChange(int faderIndex,
                       boolean flag)
Specified by:
muteChange in interface PanAmpListener

soloChange

public void soloChange(int faderIndex,
                       boolean flag)
Specified by:
soloChange in interface PanAmpListener

setFromPanAmpPairs

public void setFromPanAmpPairs(java.util.Vector panAmpPairs)

writeXML

public void writeXML(java.io.PrintWriter out)
              throws java.io.IOException
Specified by:
writeXML in interface XMLWritable
Throws:
java.io.IOException

getPanAmpControlPanel

public java.awt.Component getPanAmpControlPanel()
Returns:
Panel containing PanAmpPanels to control amp and pan for this mixer

getPanAmpControlPanel

public java.awt.Component getPanAmpControlPanel(int rows,
                                                int cols)

getPanAmpControlPanel

public java.awt.Component getPanAmpControlPanel(int rows,
                                                int cols,
                                                int hgap,
                                                int vgap)
Returns:
Panel with GridLayout containing PanAmpPanels which control this mixer. Specify rows, cols for GridLayout. Follows same rules as GridLayout, where rows=0 means rows added as needed with fixed # cols, and vice versa

main

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