Class MidiOut

The MidiOut class is an implementation of IMidiOut, which takes MIDI messages and sends them on to a connected MIDI port.

Hierarchy

  • MidiOut

Implements

Constructors

  • Parameters

    • port: any

      The MIDI Out port which data gets sent to, see MidiAccess class.

    Returns MidiOut

Properties

port: any

The MIDI Out port which data gets sent to, see MidiAccess class.

suppressPortValidationErrors: boolean = false

Whenever the MidiOut attempts to send MIDI data, it does some validation that there is a MIDI port actually connected. If not then it throws an error.

Setting this property to true means that the MidiOut bypasses throwing that error. This can be useful when the MidiOut may regularly be switching outputs that it sends data to, and that it may be valid for it to not be connected to a port at times.

Accessors

  • get isFinished(): boolean
  • Returns true if the MidiOut has been instructed to stop everything by the finish() method.

    Returns boolean

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

    The MidiOut will cycle through this collection on each update, checking to see if it needs to send out Note Off messages for any, or update note pressure.

    Returns Note[]

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

    Returns string

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

    • value: string

    Returns void

  • 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 the MidiOut's collection, returning the note that was added.

    If note.on == true, then the the MidiOut immediately sends a Note On message to the connected port.

    Returns

    Parameters

    • note: Note

      The note to add to the MidiOut.

    Returns Note

  • Calling this tells the MidiOut 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 to the connected MIDI port.

    Parameters

    • data: number[]

      An array of the data to be sent.

    Returns boolean

  • 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 MidiOut(port).withRef('output'));
    

    Returns

    The calling object.

    Parameters

    • ref: string

      The ref to set on the object.

    Returns IClockChild

Generated using TypeDoc