Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PlayerWithClick

A NoteSequence player based on Tone.js that includes a click track and a callback object to be called while playing notes.

Hierarchy

Index

Constructors

constructor

Properties

Protected callbackObject

callbackObject: BasePlayerCallback

Protected currentPart

currentPart: any

Protected desiredQPM

desiredQPM: number

Protected playClick

playClick: boolean

Protected scheduledStop

scheduledStop: number

Static tone

tone: any = Tone

The Tone module being used.

Methods

getPlayState

  • getPlayState(): any

isPlaying

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

    Returns boolean

pause

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

    throws

    {Error} If the player is stopped.

    Returns void

Protected playNote

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

resume

  • resume(): 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

seekTo

  • seekTo(seconds: number): void
  • Seek to a number of seconds in the NoteSequence.

    throws

    {Error} If the player is stopped.

    Parameters

    • seconds: number

    Returns void

setTempo

  • setTempo(qpm: number): void

start

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

    throws

    {Error} If this or a different player is currently 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.

    • Default value offset: number = 0

      (Optional) The time to start playing from.

    Returns Promise<void>

    a Promise that resolves when playback is complete.

stop

  • stop(): void

Generated using TypeDoc