Options
All
  • Public
  • Public/Protected
  • All
Menu

Sampled instrument. Must be initialized and samples must be pre-loaded using the loadSamples method before any notes can be played.

Hierarchy

  • Instrument

Index

Constructors

constructor

Properties

durationSeconds

durationSeconds: number

maxPitch

maxPitch: number

minPitch

minPitch: number

name

name: string

percussive

percussive: boolean

releaseSeconds

releaseSeconds: number

Optional velocities

velocities: number[]

Methods

initialize

  • initialize(): Promise<void>
  • Loads instrument configuration from an instrument.json file in the base URL directory. Does not load any of the samples.

    Returns Promise<void>

loadSamples

  • loadSamples(samples: SampleInfo[]): Promise<void>
  • Load samples necessary to play a set of pitch/velocity pairs. This must be called before any notes can be played.

    Parameters

    • samples: SampleInfo[]

      Array of pitch/velocity pairs.

    Returns Promise<void>

playNote

  • playNote(pitch: number, velocity: number, startTime: number, duration: number, output: any): void
  • Play a note using one of the samples.

    Parameters

    • pitch: number

      Pitch of the note.

    • velocity: number

      Velocity of the note.

    • startTime: number

      Time at which to start playing the note.

    • duration: number

      Length of the note in seconds.

    • output: any

      Output AudioNode.

    Returns void

Generated using TypeDoc