@tspro/web-music-score
    Preparing search index...

    Interface Instrument

    Instrument interface.

    To create your own instrument just create a class that implement this simple interface.

      import * as Audio from "@tspro/web-music-score/audio";

    class MyCoolInstrument implements Audio.Instrument {
    constructor() { }
    getName() { return "My Cool Instrument"; }
    playNote(note: string, duration: number, linearVolume: number) { }
    stop() { }
    }

    // Add and use my cool instrument.
    Audio.addInstrument(new MyCoolInstrument());
    interface Instrument {
        getName(): string;
        playNote(note: string, duration: number, linearVolume: number): void;
        stop(): void;
    }
    Index

    Methods

    • Get instrument name.

      Returns string

      • Instrument name.
    • Play a note.

      Parameters

      • note: string

        Note to play (e.g. "C4").

      • duration: number

        Play duration in seconds.

      • linearVolume: number

        Linear volume in range [0, 1].

      Returns void

    • Stop playback.

      Returns void