com.softsynth.jsyn
Class SynthDistributor

java.lang.Object
  extended by com.softsynth.jsyn.SynthPort
      extended by com.softsynth.jsyn.SynthScalarPort
          extended by com.softsynth.jsyn.SynthVariable
              extended by com.softsynth.jsyn.SynthInput
                  extended by com.softsynth.jsyn.SynthDistributor

public class SynthDistributor
extends SynthInput

SynthDistributor class for Java Audio Synthesis A SynthDistributor acts as a single input port that maps to multiple ports inside a SynthCircuit. When building a circuit, connect the SynthDistributor to all of the internal inputs that you want to drive together. You can then set() a value for the SynthDistributor with a single call and it will be passed to all of the connected ports inside the circuit. You can also connect a SynthOutput to it and a connection will automatically be made to all of the connected internal ports. If you did not use a SynthDistributor, then you would need to use an AddUnit to provide the fan-out but this would add run-time overhead to the CPU. The SynthDistributor has no run-time overhead during synthesis.

Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved

Constructor Summary
SynthDistributor(java.lang.String name)
          Use null sound, and default signal type of Synth.SIGNAL_TYPE_FULL_RANGE
SynthDistributor(java.lang.String name, int signalType)
          Use null sound for distributor that is not part of a circuit.
SynthDistributor(SynthSound sound, java.lang.String name)
          Use default signal type of Synth.SIGNAL_TYPE_FULL_RANGE
SynthDistributor(SynthSound sound, java.lang.String name, int signalType)
          An example call is:
 
Method Summary
 void connect(int partNum, SynthInput inPort, int inIndex)
          This method is illegal for SynthInput but is legal for a subclass SynthDistributor.
 void connect(int inIndex, SynthOutput outPort, int outIndex)
          Connect output port of another instrument to this input port.
 void connect(SynthInput inPort, int inIndex)
          Input port will be connected to any port that is driving this SynthDistributor.
 void connect(SynthOutput outPort, int outIndex)
          Connect output port of another instrument to this distributor.
 void disconnect()
          Disconnects any SynthOutput connected to this distributor.
 void disconnect(int index)
          Disconnects the connections made to this port.
 void disconnect(SynthInput inPort)
           
 void disconnect(SynthInput inPort, int inIndex)
          Remove record for connection to this port from internal Vector.
 double get()
           
 double get(int partIndex)
           
 int getNumParts()
          Get number of parts in a port.
 int getSignalType(int partIndex)
           
 void set(double value, int partIndex)
          Set value of all connected SynthInputs.
 void set(int time, double value, int partIndex)
          Set value of all connected SynthInputs at specified time.
 void setSignalType(int signalType, int partIndex)
          Set signalType of all connected SynthInputs.
 
Methods inherited from class com.softsynth.jsyn.SynthInput
connect, connect, multiply
 
Methods inherited from class com.softsynth.jsyn.SynthVariable
getCurrent, getCurrent, getMax, getMin, set, set, setAt, setAt, setMax, setMin, setup
 
Methods inherited from class com.softsynth.jsyn.SynthPort
getAlias, getName, getSignalType, getSound, setAlias, setSignalType, setSignalType, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynthDistributor

public SynthDistributor(SynthSound sound,
                        java.lang.String name,
                        int signalType)
                 throws SynthException
An example call is:
frequency = new SynthDistributor( this, "frequency", Synth.SIGNAL_TYPE_OSC_FREQ ); 

Throws:
SynthException - If sound or signalType is invalid.

SynthDistributor

public SynthDistributor(java.lang.String name,
                        int signalType)
                 throws SynthException
Use null sound for distributor that is not part of a circuit.

Throws:
SynthException - If signalType is invalid.

SynthDistributor

public SynthDistributor(SynthSound sound,
                        java.lang.String name)
                 throws SynthException
Use default signal type of Synth.SIGNAL_TYPE_FULL_RANGE

Throws:
SynthException - If sound is invalid.

SynthDistributor

public SynthDistributor(java.lang.String name)
                 throws SynthException
Use null sound, and default signal type of Synth.SIGNAL_TYPE_FULL_RANGE

Throws:
SynthException - Unlikely.
Method Detail

connect

public void connect(SynthInput inPort,
                    int inIndex)
             throws SynthException
Input port will be connected to any port that is driving this SynthDistributor. The SynthDistributor signal type will also be passed to the inPort. The current value will be set() if there is no driver.

Throws:
SynthException - If port name is not recognized, or index out of range.

connect

public void connect(int partNum,
                    SynthInput inPort,
                    int inIndex)
             throws SynthException
Description copied from class: SynthInput
This method is illegal for SynthInput but is legal for a subclass SynthDistributor. We need to define it so that we can make polymorphic ports. But defining this method here prevents me from catching input<->input connection errors.

Overrides:
connect in class SynthInput
Throws:
SynthException - If used to connect two SynthInputs, or if port is not invalid, or index out of range.

connect

public void connect(SynthOutput outPort,
                    int outIndex)
             throws SynthException
Connect output port of another instrument to this distributor. Output port will internally connect to all of the associated Input ports.

Throws:
SynthException - If port name is not recognized, or index out of range, or destPort already connected.

connect

public void connect(int inIndex,
                    SynthOutput outPort,
                    int outIndex)
             throws SynthException
Description copied from class: SynthInput
Connect output port of another instrument to this input port. Each port can have multiple indexed parts. A stereo sample reader would, for example, have an "Output" with two parts.

Overrides:
connect in class SynthInput
Throws:
SynthException - If port name is not recognized, or index out of range.

disconnect

public void disconnect()
                throws SynthException
Disconnects any SynthOutput connected to this distributor.

Overrides:
disconnect in class SynthInput
Throws:
SynthException

disconnect

public void disconnect(int index)
                throws SynthException
Description copied from class: SynthInput
Disconnects the connections made to this port. Only one connection can be made to an input port so a connection can be uniquely referenced by naming the input port. Output ports have infinite fan-out.

Overrides:
disconnect in class SynthInput
Throws:
SynthException - If port name is not recognized, or index out of range.

disconnect

public void disconnect(SynthInput inPort,
                       int inIndex)
                throws SynthException
Remove record for connection to this port from internal Vector.

Throws:
SynthException - If port is invalid, or index out of range.

disconnect

public void disconnect(SynthInput inPort)
                throws SynthException
Throws:
SynthException

set

public void set(int time,
                double value,
                int partIndex)
         throws SynthException
Set value of all connected SynthInputs at specified time.

Overrides:
set in class SynthVariable
Parameters:
time - Time in ticks for setting to occur.
value - Floating point value to set port. Must be in units that correspond to signal type of port.
partIndex - Index of part of multi-part port. Typically zero.
Throws:
SynthException - If port is invalid, or index out of range.

set

public void set(double value,
                int partIndex)
         throws SynthException
Set value of all connected SynthInputs.

Overrides:
set in class SynthVariable
Throws:
SynthException - If port is invalid, or index out of range.

setSignalType

public void setSignalType(int signalType,
                          int partIndex)
                   throws SynthException
Set signalType of all connected SynthInputs.

Overrides:
setSignalType in class SynthVariable
Parameters:
signalType - Selects signal type. Legal values are:
  • Synth.SIGNAL_TYPE_RAW_SIGNED = internal signal type that ranges from -1.0 to +1.0. This is used for Amplitude as an example.
  • Synth.SIGNAL_TYPE_RAW_UNSIGNED = internal signal type that ranges from 0.0 to +2.0. This is used for Amplitude as an example.
  • Synth.SIGNAL_TYPE_OSC_FREQ = oscillator frequency. Using this signal type allows you to call set with Frequency values in Hertz. (SIGNED)
  • Synth.SIGNAL_TYPE_SAMPLE_RATE = SynthSample reader sample rate. Using this signal type allows you to call set with SynthSample rate values in Hertz. The frequency that you actually hear will depend on the content of the sample. A bassoon sample played at 44100 Hz will sound lower than a picollo sample played at 44100 Hz. (UNSIGNED)
  • Synth.SIGNAL_TYPE_HALF_LIFE = half life of an exponential decay function. (UNSIGNED)
Throws:
SynthException - If port is invalid, or index out of range.

getSignalType

public int getSignalType(int partIndex)
                  throws SynthException
Overrides:
getSignalType in class SynthPort
Returns:
signalType of all connected SynthInputs.
Throws:
SynthException - If port is invalid, or index out of range.

get

public double get(int partIndex)
           throws SynthException
Overrides:
get in class SynthVariable
Returns:
current instantaneous value of port.
Throws:
SynthException - If port name is not recognized, or index out of range.

get

public double get()
           throws SynthException
Overrides:
get in class SynthScalarPort
Returns:
current instantaneous value of port.
Throws:
SynthException - If port name is not recognized, or index out of range.

getNumParts

public int getNumParts()
                throws SynthException
Get number of parts in a port. Always 1 for SynthDistributor

Overrides:
getNumParts in class SynthPort
Throws:
SynthException