Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Instrument

Instrument are used to encapsulate the tuning and retrieving of midi keys and frequencies for notes

example
import { Instrument } from "musictheoryjs";

Hierarchy

  • Instrument

Implements

  • Entity

Index

Constructors

constructor

Properties

id

id: string = ...
returns

a unique id for this instance

example
const instrument = new Instrument();
instrument.id; // returns a unique id

tuning

tuning: Tuning

Methods

copy

  • chainable
    example
    const instrument = new Instrument();
    const copy = instrument.copy();
    console.log(instrument.equals(copy)); // true

    Returns Instrument

    a copy of this instance

equals

  • example
    const instrument = new Instrument();
    const copy = instrument.copy();
    console.log(instrument.equals(copy)); // true

    Parameters

    Returns boolean

    true if the other object is equal to this one

getFrequency

  • getFrequency(note: Note): number
  • example
    const instrument = new Instrument();
    instrument.getFrequency(new Note("C4")); // returns 261.6255653005986

    Parameters

    Returns number

    the frequency of the given note

getMidiKey

  • getMidiKey(note: Note): number
  • example
    const instrument = new Instrument();
    instrument.getMidiKey(new Note("C4")); // returns 60

    Parameters

    Returns number

    the midi key of the given note

toString

  • toString(): string
  • example
    const instrument = new Instrument();
    console.log(instrument.toString()); // returns "Instrument Tuning(440)"

    Returns string

    the tuning as a string

Generated using TypeDoc