jm.music.rt

## Class RTLine

- java.lang.Object
- - jm.music.rt.RTLine

- All Implemented Interfaces:
    AudioChainListener
  Direct Known Subclasses:
    AudioRTLine, RTPhrase

      public abstract class RTLine
      extends java.lang.Object
      implements AudioChainListener

  This class frovides a framework for real time audio playback. It renders a Part using the provided instrument(s). If there are more than one instrument it is assumed they are simply multiple instances of the one instrument. These are used to play notes that overlap in the score or as a result of effects such as delays or reverb. There is an assumption that all instruments have the same sample rate number of channels.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `clear` if clear is true the threads wait call will be skipped
    `protected Instrument[]` | `inst` The instrument associated with this real time line

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RTLine(Instrument[] inst)` The RTLine constructor is primarily responsible for initialising its associated instrument and the instruments audio chain.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `controlChange(float[] buffer, int returned, boolean finished)` controlChange is called by RTLine's instrument everytime it completes filling its current buffer.
    `void` | `externalAction(java.lang.Object obj, int actionNumber)` External action is called by RTMixer whenever an external event is sent to trigger a real time audio event.
    `int` | `getChannels()` Return the current number of channels, based on the channels of the instruments.
    `Instrument[]` | `getInstrument()` Returns the instrument associated with this RTLine
    `abstract Note` | `getNextNote()` Override this method to set the next method to be called.
    `int` | `getNumLines()` Return the number of lines (note polyphony for this RTLine
    `int` | `getSampleRate()` Return the current samplerate, based on the sample rate of the instruments.
    `void` | `instNote(Instrument inst, long samplesProcessed)` This method is called from Instrument and in return calls that instrument's renderNote method.
    `void` | `pause()`
    `void` | `setBufferSize(int buf)` Specify the buffer size for each instrument.
    `void` | `setTempo(double tempo)` sets the tempo of this RTLine
    `void` | `start(RTMixer rta)` start this RTLine's instrument call for the setting of the first note
    `void` | `stop()`
    `void` | `unPause()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### inst

          protected Instrument[] inst

      The instrument associated with this real time line

    - #### clear

          protected boolean clear

      if clear is true the threads wait call will be skipped

  - ### Constructor Detail

    - #### RTLine

          public RTLine(Instrument[] inst)

      The RTLine constructor is primarily responsible for initialising its associated instrument and the instruments audio chain.

  - ### Method Detail

    - #### getInstrument

          public Instrument[] getInstrument()

      Returns the instrument associated with this RTLine
      Returns:
        Instrument the instrument associated with this RTLine

    - #### getNumLines

          public int getNumLines()

      Return the number of lines (note polyphony for this RTLine

    - #### setTempo

          public void setTempo(double tempo)

      sets the tempo of this RTLine

    - #### setBufferSize

          public void setBufferSize(int buf)

      Specify the buffer size for each instrument. Called by RTMixer.

    - #### getSampleRate

          public int getSampleRate()

      Return the current samplerate, based on the sample rate of the instruments. All instrument sample rates in real time audio must be the same.

    - #### getChannels

          public int getChannels()

      Return the current number of channels, based on the channels of the instruments. All instruments in real time audio must have the same number of channels.

    - #### externalAction

          public void externalAction(java.lang.Object obj,
                            int actionNumber)

      External action is called by RTMixer whenever an external event is sent to trigger a real time audio event. The event will commonly be triggered by a GUI widget such as a button or slider.
      Parameters:
        `obj` - and undetermined Object which will need to be cast locally to whatever type is expected.
        `actionNumber` - is an serial index value for the source of the event.

    - #### controlChange

          public void controlChange(float[] buffer,
                           int returned,
                           boolean finished)

      controlChange is called by RTLine's instrument everytime it completes filling its current buffer. The regularity at which controlChange is called is what determines the control rate. The control rate is used therefore to set the buffer sizes of the instrument sample buffers.
      Specified by:
        `controlChange` in interface `AudioChainListener`
      Parameters:
        `buffer` - a buffer of samples passed from an instrument
        `returned` - the number of samples in the buffer
        `finished` - this boolean indicates whether the instrument has finished processing its current note.

    - #### instNote

          public void instNote(Instrument inst,
                      long samplesProcessed)

      This method is called from Instrument and in return calls that instrument's renderNote method. When this method returns, the instruments iterateChain method is called and the note is processed. This method is responsible for either fetching a "playable" note from the getNextNote() method or else for inserting a rest of an appropriate amount of time.

    - #### start

          public void start(RTMixer rta)

      start this RTLine's instrument call for the setting of the first note

    - #### pause

          public void pause()

    - #### unPause

          public void unPause()

    - #### stop

          public void stop()

    - #### getNextNote

          public abstract Note getNextNote()

      Override this method to set the next method to be called.