Class MidiBus

The MidiBus is a combination of both MidiIn & MidiOut. It gets data passed to it through the methods & properties that it implements from the IMidiOut interface, and in turn, distributes that data through the events that it implements from the IMidiIn interface.

The typical use cases of this are when you want some common actions to be applied to MIDI data being generated from a number of different places within your shimi application. For example, you might have a number of different processes generating a number of different instrument parts, and want to make sure that simple pitch correction is applied to all parts.

Rather than modify the logic of each separate process, you could instead have each process connect to a common MidiBus, then connect that MidiBus up to a MidiOut, and just insert pitch correction logic in that connection from MidiBus to MidiOut.

Hierarchy

  • MidiBus

Implements

Constructors

Accessors

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

    Returns boolean

  • get noteOff(): MidiInEvent<NoteOffMessage>
  • The noteOff property can be subscribed to, to receive all Note Off messages that pass through the MidiBus object.

    Returns MidiInEvent<NoteOffMessage>

  • get noteOn(): MidiInEvent<NoteOnMessage>
  • The noteOn property can be subscribed to, to receive all Note On messages that pass through the MidiBus object.

    Returns MidiInEvent<NoteOnMessage>

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

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

    Returns Note[]

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

    Returns string

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

    • value: string

    Returns void

  • get start(): MidiInEvent<StartMessage>
  • The start property can be subscribed to, to receive all Start messages that pass through the MidiIn object.

    Returns MidiInEvent<StartMessage>

  • get stop(): MidiInEvent<StopMessage>
  • The stop property can be subscribed to, to receive all Stop messages that pass through the MidiIn object.

    Returns MidiInEvent<StopMessage>

  • get tick(): MidiInEvent<TickMessage>
  • The tick property can be subscribed to, to receive all timing clock messages that pass through the MidiBus object.

    Returns MidiInEvent<TickMessage>

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

    Returns string

Methods

  • The addNote method adds a new note to begin being sent by the MIDI out.

    Parameters

    Returns Note

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

    Returns void

  • The receiveData method allows for raw MIDI message data to be passed in, which will then be analysed, and trigger an event for whichever MIDI event type it corresponds to.

    Parameters

    Returns void

  • Sends data from the passed in MIDI message to the connected MIDI port

    Parameters

    Returns void

  • Sends a custom MIDI message to the connected MIDI port

    Parameters

    • data: number[]

      An array of the data to be sent

    Returns void

  • The stopNotes method allows for stopping any number of notes currently being sent by the MIDI out.

    Parameters

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

      The filter parameter is a function that runs against each note on the MIDI out. Notes for which the function returns true are 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

    Returns void

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

    clock.addChild(new MidiBus().withRef('bus'));
    

    Returns

    The calling object.

    Parameters

    • ref: string

      The ref to set on the object.

    Returns IClockChild

Generated using TypeDoc