Class ToneJSMidiOut

The ToneJSMidiOut implements the IMidiOut, and provides an integration with the ToneJS javascript library. This allows for MIDI data coming from shimi to control sound generation in the browser by ToneJS.

Hierarchy

  • ToneJSMidiOut

Implements

Constructors

  • Requires that a reference to the toneJS library be passed in as a parameter, for example:

    import * as Tone from 'tone';
    new ToneJSMidiOut(Tone);

    Parameters

    • toneJS: any

    Returns ToneJSMidiOut

Accessors

  • get channels(): ToneJSMidiOutChannel[]
  • The collection of channels that MIDI data can be sent out to. Each channel that's being used should hold a reference to a ToneJS instrument object.

    Returns ToneJSMidiOutChannel[]

  • get isFinished(): boolean
  • Returns true if the clip player has finished playing its clip.

    Returns boolean

  • get notes(): Note[]
  • The notes collection consists of notes which have been started, but not ended yet.

    The ToneJSMidiOut will cycle through this collection on each update, checking to see if it needs to stop the playback of any notes.

    Returns Note[]

  • get ref(): string
  • Provides a way of identifying a clip player so that it can be easily retrieved later.

    Returns string

  • set ref(value: string): void
  • Parameters

    • value: string

    Returns void

  • get toneJS(): any
  • A reference to the ToneJS library.

    Returns any

  • get typeName(): string
  • Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.

    Returns string

Methods

  • Adds a new note to ToneJSMidiOut's collection, returning the note that was added.

    Note, if the ToneJSMidiOut has not set anything for the channel which the note is targetting, then no action will be performed.

    If note.on == true, then the ToneJS Instrument for the corresponding channel is immediately instructed to triggerAttack.

    Returns

    The note that was added

    Parameters

    • note: Note

      The note to add to the ToneJSMidiOut.

    Returns Note

  • Calling this tells the clip player to stop whatever it's doing and that it will no longer be used.

    Returns void

  • This method accepts an IMidiMessage object, which it converts to a MIDI byte array to send to the connected MIDI port.

    Returns

    Parameters

    • message: IMidiMessage

      The IMidiMessage object to be converted and sent out.

    Returns boolean

  • Sends a raw byte-array MIDI message

    Parameters

    • data: number[]

      An array of the data to be sent.

    Returns boolean

  • Sets up a target destination against a particular channel number, which MIDI messages with the corresponding number will be sent to.

    Example:

    const midiOut = new ToneJSMidiOut(Tone);
    midiOut.setChannel(0, new Tone.Synth().toDestination());

    Parameters

    • channel: number

      The channel number to be set up. Valid values range from 0 to 15.

    • target: any

      The ToneJS instrument object which will MIDI messages will ultimately end up affecting.

    Returns void

  • Calls the stop() method of all notes which have been added to the MidiOut that meet the passed in criteria.

    Parameters

    • Optional filter: ((note: Note) => boolean)

      The criteria for determining which notes need to be stopped. If no filter provided, then all notes are stopped.

        • (note: Note): boolean
        • Parameters

          Returns boolean

    Returns void

  • This method is intended to be called by a clock to provide regular updates. It should be called by consumers of the library.

    Returns

    Parameters

    • deltaMs: number

      How many milliseconds have passed since the last update cycle.

    Returns void

  • Provides a way for setting the ref through a chained function call. For example:

    clock.addChild(new ClipPlayer(clip, metronome, midiOut).withRef('player'));
    

    Returns

    The calling object.

    Parameters

    • ref: string

      The ref to set on the object.

    Returns IClockChild

Generated using TypeDoc