Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BasePlayer

Abstract base class for a NoteSequence player based on Tone.js.

Hierarchy

Index

Constructors

constructor

  • BasePlayer constructor.

    @param playClick A boolean, determines whether the click will be played. @param callbackObject An optional BasePlayerCallback, specifies an object that contains run() and stop() methods to invode during playback.

    Parameters

    Returns BasePlayer

Properties

Protected callbackObject

callbackObject: BasePlayerCallback

Protected currentPart

currentPart: any

Protected desiredQPM

desiredQPM: number

Protected playClick

playClick: boolean

Protected scheduledStop

scheduledStop: number

Methods

getPlayState

  • getPlayState(): any
  • Returns the playback state of the player, either "started", "stopped", or "paused".

    Returns any

isPlaying

  • isPlaying(): boolean
  • Returns true iff the player is completely stopped. This will only be false after calling stop(), and will be true after calling start(), pause() or unpause().

    Returns boolean

pause

  • pause(): void
  • Pause playing the currently playing sequence right away. Call unpause() to resume.

    Returns void

Protected Abstract playNote

  • playNote(time: number, note: INote): void

resume

  • resume(): void
  • Pause playing the currently playing sequence right away. Call resume() to resume playing the sequence.

    Returns void

resumeContext

  • resumeContext(): void
  • Resumes the Audio context. Due to autoplay restrictions, you must call this function in a click handler (i.e. as a result of a user action) before you can start playing audio with a player. This is already done in start(), but you might have to call it yourself if you have any deferred/async calls.

    Returns void

setTempo

  • setTempo(qpm: number): void
  • Changes the tempo of the playback.

    Parameters

    • qpm: number

      The new qpm to use.

    Returns void

start

  • start(seq: INoteSequence, qpm?: number): Promise<void>
  • Starts playing a NoteSequence (either quantized or unquantized), and returns a Promise that resolves when it is done playing.

    Parameters

    • seq: INoteSequence

      The NoteSequence to play.

    • Optional qpm: number

      (Optional) If specified, will play back at this qpm. If not specified, will use either the qpm specified in the sequence or the default of 120. Only valid for quantized sequences.

    Returns Promise<void>

    a Promise that resolves when playback is complete.

stop

  • stop(): void
  • Stop playing the currently playing sequence right away.

    Returns void

Generated using TypeDoc