Class ClipPlayer

The ClipPlayer facilitates the playing of a clip.

The ClipPlayer should be added to a clock to receive regular updates. It should hold a reference to a metronome for beat timings. It should hold a reference to a MIDI Out for it to send MIDI data to. And it should hold a reference to a clip, which it will play.

Hierarchy

  • ClipPlayer

Implements

Constructors

  • Parameters

    • clip: Clip

      The clip to play.

    • metronome: IMetronome

      The metronome which the player uses for tracking passed beats.

    • midiOut: IMidiOut

      The IMidiOut which MIDI data generated from the clip gets sent to.

    Returns ClipPlayer

Accessors

  • get beatCount(): number
  • How many beats should have passed before the clip player stops. The default value is null, meaning the ClipPlayer never stops, and continually loops playback of the clip.

    Returns number

  • set beatCount(value: number): void
  • Parameters

    • value: number

    Returns void

  • get beatsPassed(): number
  • How many beats have passed since the clip player started.

    Returns number

  • get channel(): number
  • Which channel to play the clip on. Valid values range from 0 - 15.

    The default value is 0.

    Returns number

  • set channel(value: number): void
  • Parameters

    • value: number

    Returns void

  • get clip(): Clip
  • The clip to play.

    Returns Clip

  • set clip(value: Clip): void
  • Parameters

    Returns void

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

    Returns boolean

  • get metronome(): IMetronome
  • The metronome which the player uses for tracking passed beats.

    Returns IMetronome

  • set metronome(value: IMetronome): void
  • Parameters

    Returns void

  • get midiOut(): IMidiOut
  • The IMidiOut which MIDI data generated from the clip gets sent to.

    Returns IMidiOut

  • set midiOut(value: IMidiOut): void
  • Parameters

    Returns void

  • get muteAll(): boolean
  • If set to true, then no events of any kind will be dispatched by the player. All existing notes will be stopped

    Returns boolean

  • set muteAll(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get muteBends(): boolean
  • If set to true, then no new bend events will be dispatched by the player

    Returns boolean

  • set muteBends(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get muteCCs(): boolean
  • If set to true, then no control change events will be dispatched by the player

    Returns boolean

  • set muteCCs(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get muteNotes(): boolean
  • If set to true, then no new notes will be generated by the player, and all existing ones will be stopped

    Returns boolean

  • set muteNotes(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get noteModifier(): ((note: Note) => void)
  • Allows attaching custom logic to modify each note produced by the clip player. The provided function should accept a note as its only parameter. For example:

     clipPlayer.noteModifier = (note) => {
    note.pitch += 12;
    note.velocity = 40 + Math.floor(Math.random() * 40);
    };

    Returns ((note: Note) => void)

      • (note: Note): void
      • Parameters

        Returns void

  • set noteModifier(value: ((note: Note) => void)): void
  • Parameters

    • value: ((note: Note) => void)
        • (note: Note): void
        • Parameters

          Returns void

    Returns void

  • 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 running(): boolean
  • If not running, then the player won't do anything with each update cycle. This allows a way to temporarily pause playback of the clip, without having to remove it from the clock.

    By default this is set to true.

    Returns boolean

  • set running(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get speed(): number
  • How many beats in the clip to play for every beat that passes in actual time. For example: 1.5 means the clip is played 1.5 times faster than it would normally.

    Returns number

  • set speed(value: number): void
  • Parameters

    • value: number

    Returns void

  • get startBeat(): number
  • Which beat of the clip to start playing from. This allows for a clip player to begin playing a clip from half-way through for example.

    Returns number

  • set startBeat(value: number): void
  • Parameters

    • value: number

    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

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

    Returns void

  • Halt playback of the clip, with the playback position retained to allow for it to be resumed later.

    Returns void

  • Start the running of the clip player. This is not needed unless you've previously explicitly paused or stopped it.

    Returns void

  • Halt playback of the clip, discarding all information about how much of the clip has already been played.

    Returns void

  • This method is intended to be called by a clock to provide regular updates. It should not 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