com.softsynth.jmsl.jsyn
Class FreqSynthNoteInstrument

java.lang.Object
  extended by com.softsynth.jmsl.InstrumentAdapter
      extended by com.softsynth.jmsl.jsyn.FreqSynthNoteInstrument
All Implemented Interfaces:
Instrument, Namable, OutputProvider, Transposable
Direct Known Subclasses:
TunedSynthNoteInstrument

public class FreqSynthNoteInstrument
extends InstrumentAdapter

A JMSL Instrument that plays a JSyn SynthNote.
Optional constructor passes in a BussedVoiceAllocator to make this polyphonic.
double[] passed to play must contain duration, frequency , amplitude, hold
duration and hold (sustain) is in seconds. amplitude is 0..1 update() can be used to change the amplitude of a sustain synthnote. on() and off() are implemented here, giving the user a finer grain of control over the instrument

Author:
Nick Didkovsky, Nick.Didkovsky@mail.rockefeller.edu (C) 2000 Nick Didkovsky, all rights reserved.

Field Summary
static int insNum
           
 
Constructor Summary
FreqSynthNoteInstrument()
          Constructor sets MusicDevice to JSynMusicDevice
FreqSynthNoteInstrument(BussedVoiceAllocatorMultiOut allocator)
          polyphonic constructor
FreqSynthNoteInstrument(com.softsynth.jsyn.SynthNote synthNote)
          monophonic constructor
 
Method Summary
 double close(double time)
          close your instrument, this stub does nothing and returns time
 BussedVoiceAllocatorMultiOut getAllocator()
           
 int getMaxVoices()
           
 java.lang.String getName()
           
 int getNumOutputs()
           
 java.lang.Object getOutput()
          get this output (SynthOutput in the case of a JSyn Instrument, for example
 java.lang.Object getOutput(int partNum)
           
 boolean getPolyphonic()
           
 int getUpdateDimension()
          Get the dimension to match against when update() is called.
static void main(java.lang.String[] args)
          Create a polyphonic, stereo instrument, and play a MusicShape with it.
 java.lang.Object off(double playTime, double timeStretch, double[] dar)
          Calls SynthNoteOff with the most recent SynthNote which was used to turn on the data in the array
 void off(double playTime, com.softsynth.jsyn.SynthNote sn)
          turn off a SynthNote at playTime and call allocator,free() This SynthNote should have been returned from on()
 java.lang.Object on(double playTime, double timeStretch, double[] dar)
          Allocate a SynthNote and call SynthNote.noteOn()
 double open(double time)
          open your instrument, this stub does nothing and returns time
 double play(double playTime, double timeStretch, double[] dar)
          Override on() and off() methods for Instrument class to provide custom interpretation of double[].
 void setAllocator(BussedVoiceAllocatorMultiOut allocator)
          Sets allocator and set polyphonic = true
 void setMaxVoices(int n)
           
 void setName(java.lang.String n)
           
 void setSynthNote(com.softsynth.jsyn.SynthNote sn)
           
 void setUpdateDimension(int dim)
          Set the dimension to match against when update() is called.
 double update(double playTime, double timeStretch, double[] dar)
          Update amplitude and frequency using (by default) dimension 1 as lookup to retrieve allocated synthnote.
 
Methods inherited from class com.softsynth.jmsl.InstrumentAdapter
getDimensionNameSpace, getInterpreter, getMixerClassName, getMusicDevice, getTransposition, noteOff, noteOn, noteOnFor, setDimensionNameSpace, setInterpreter, setMixerClassName, setMusicDevice, setTransposition, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

insNum

public static int insNum
Constructor Detail

FreqSynthNoteInstrument

public FreqSynthNoteInstrument()
Constructor sets MusicDevice to JSynMusicDevice


FreqSynthNoteInstrument

public FreqSynthNoteInstrument(com.softsynth.jsyn.SynthNote synthNote)
                        throws com.softsynth.jsyn.SynthException
monophonic constructor

Throws:
com.softsynth.jsyn.SynthException

FreqSynthNoteInstrument

public FreqSynthNoteInstrument(BussedVoiceAllocatorMultiOut allocator)
                        throws com.softsynth.jsyn.SynthException
polyphonic constructor

Throws:
com.softsynth.jsyn.SynthException
Method Detail

setAllocator

public void setAllocator(BussedVoiceAllocatorMultiOut allocator)
Sets allocator and set polyphonic = true


getAllocator

public BussedVoiceAllocatorMultiOut getAllocator()

setUpdateDimension

public void setUpdateDimension(int dim)
Set the dimension to match against when update() is called. This is used to retrieve the SynthNote which was play()'ed and is currently sounding, and which wants to be updated . Defaults to 1, which is the "pitch" dimension

Parameters:
dim -

getUpdateDimension

public int getUpdateDimension()
Get the dimension to match against when update() is called. This is used to retrieve the SynthNote which was play()'ed and is currently sounding, and which wants to be updated . Defaults to 1, which is the "pitch" dimension


getPolyphonic

public boolean getPolyphonic()

setMaxVoices

public void setMaxVoices(int n)

getMaxVoices

public int getMaxVoices()

setSynthNote

public void setSynthNote(com.softsynth.jsyn.SynthNote sn)

setName

public void setName(java.lang.String n)
Specified by:
setName in interface Namable
Overrides:
setName in class InstrumentAdapter

getName

public java.lang.String getName()
Specified by:
getName in interface Namable
Overrides:
getName in class InstrumentAdapter

open

public double open(double time)
            throws java.lang.InterruptedException
open your instrument, this stub does nothing and returns time

Specified by:
open in interface Instrument
Overrides:
open in class InstrumentAdapter
Throws:
java.lang.InterruptedException

close

public double close(double time)
             throws java.lang.InterruptedException
close your instrument, this stub does nothing and returns time

Specified by:
close in interface Instrument
Overrides:
close in class InstrumentAdapter
Throws:
java.lang.InterruptedException

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

on

public java.lang.Object on(double playTime,
                           double timeStretch,
                           double[] dar)
Allocate a SynthNote and call SynthNote.noteOn()
 double frequency = dar[1];double amp = dar[2];  //  0..1
      
     
    
   
  
 

Specified by:
on in interface Instrument
Overrides:
on in class InstrumentAdapter
Returns:
allocated Synthnote. play() refers to this returned object directly and calls synthNoteOff()
See Also:
Instrument.on(double, double, double[])

off

public java.lang.Object off(double playTime,
                            double timeStretch,
                            double[] dar)
Calls SynthNoteOff with the most recent SynthNote which was used to turn on the data in the array

Specified by:
off in interface Instrument
Overrides:
off in class InstrumentAdapter
Returns:
null
See Also:
com.softsynth.jmsl.Instrument#off(double, Object)

off

public void off(double playTime,
                com.softsynth.jsyn.SynthNote sn)
turn off a SynthNote at playTime and call allocator,free() This SynthNote should have been returned from on()


play

public double play(double playTime,
                   double timeStretch,
                   double[] dar)
Override on() and off() methods for Instrument class to provide custom interpretation of double[]. play() calls
 double duration = dar[0];
 double hold = dar[3];
 double offtime = playTime + hold * timeStretch;
 Object allocatedSynthNote = on(playTime, timeStretch, dar);
 synthNoteOff(offtime, (SynthNote) allocatedSynthNote);
 return playTime + duration * timeStretch;
 
Interpretation of data:
 double dur = dar[0];double frequency = dar[1];
          double amp = dar[2];  //  0..1
          double hold = dar[3];
          
     
    
   
  
 

Specified by:
play in interface Instrument
Overrides:
play in class InstrumentAdapter

update

public double update(double playTime,
                     double timeStretch,
                     double[] dar)
Update amplitude and frequency using (by default) dimension 1 as lookup to retrieve allocated synthnote. You may change this with setUpdateDimension()

Specified by:
update in interface Instrument
Overrides:
update in class InstrumentAdapter

main

public static void main(java.lang.String[] args)
Create a polyphonic, stereo instrument, and play a MusicShape with it. Specify frequencies