Options
All
  • Public
  • Public/Protected
  • All
Menu

A note consist of a semitone and an octave.

example
import { Note } from "musictheoryjs";
import { NoteInitializer } from "musictheoryjs"; // typescript only if needed

Hierarchy

  • Note

Implements

  • Entity

Index

Constructors

constructor

  • example
    import { Note } from "musictheoryjs";

    // creates a new note with default values semitone 0(C) and octave 4
    const note = new Note();

    // creates a new note using an initializer object
    const note = new Note({semitone: 4, octave: 5});

    // String parsing should follow the format: note-name[modifier][octave]
    // creates a new note using a string
    const note = new Note("C5");

    Parameters

    Returns Note

Properties

id

id: string = ...

unique id for this note(auto generated)

example
const note = new Note();
console.log(note.id); // s2898snloj

Accessors

octave

  • get octave(): number
  • set octave(octave: number): void
  • example
    const note = new Note();
    console.log(note.octave); // 4

    Returns number

  • The octave is clamped to the range [0, 9].

    example
    const note = new Note();
    note.octave = 10;
    console.log(note.octave); // 9(because of clamping)

    Parameters

    • octave: number

    Returns void

semitone

  • example
    const note = new Note();
    console.log(note.semitone); // 0

    Returns Semitone

  • setting the semitone with a number outside the range of 0-11 will wrap the value around and change the octave accordingly

    example
    const note = new Note();
    note.semitone = 4;// E
    console.log(note.semitone); // 4(E)

    Parameters

    Returns void

Methods

copy

  • example
    const note = new Note(); // default semitone is 0(C)
    const note2 = note.copy();
    console.log(note.equals(note2)); // true

    Returns Note

    a copy of this note

equals

  • equals(note: Note): boolean
  • example
    const note = new Note();
    const note2 = new Note();
    console.log(note.equals(note2)); // true

    Parameters

    Returns boolean

    true if this note is equal to the given note

flat

  • Returns a new note that is a flattened version of this note.

    chainable
    example
    const note = new Note(); // default semitone is 0(C)
    const note2 = note.flat();
    console.log(note2.semitone); // 3(Eb)

    Returns Note

    a new note that is a flattened version of this note.

flatten

  • Flattens the note in place.

    chainable
    example
    const note = new Note({semitone: 4}); //  semitone is 4(E)
    note.flatten();
    console.log(note.semitone); // 3(Eb)

    Returns Note

isFlat

  • isFlat(): boolean
  • attempts to determine if the note is flat

    example
    const note = new Note(); // default semitone is 0(C)
    console.log(note.isFlat()); // false
    note.flatten();
    console.log(note.isFlat()); // true

    Returns boolean

    true if the note is flat

isSharp

  • isSharp(): boolean
  • attempts to determine if the note is sharp

    example
    const note = new Note(); // default semitone is 0(C)
    console.log(note.isSharp()); // false
    note.sharpen();
    console.log(note.isSharp()); // true

    Returns boolean

    true if the note is sharp

sharp

  • chainable
    example
    const note = new Note(); // default semitone is 0(C)
    const note2 = note.sharp();
    console.log(note2.semitone); // 1(C#)

    Returns Note

    a new note that is a sharpened version of this note.

sharpen

  • Sharpens the note in place.

    chainable
    example
    const note = new Note(); // default semitone is 0(C)
    note.sharpen();
    console.log(note.semitone); // 1(C#)

    Returns Note

toString

  • toString(): string
  • Returns a string version of this note

    example
    const note = new Note(); // default semitone is 0(C)
    console.log(note.toString()); // C4

    Returns string

Static A

  • A(octave?: number): Note
  • static
    example
    const note = Note.A();
    console.log(note.toString()); // A4

    Parameters

    • octave: number = 4

    Returns Note

    note set to A[octave]

Static B

  • B(octave?: number): Note
  • static
    example
    const note = Note.B();
    console.log(note.toString()); // B4

    Parameters

    • octave: number = 4

    Returns Note

    note set to B[octave]

Static C

  • C(octave?: number): Note
  • static
    example
    const note = Note.C();
    console.log(note.toString()); // C4

    Parameters

    • octave: number = 4

    Returns Note

    note set to C[octave]

Static D

  • D(octave?: number): Note
  • static
    example
    const note = Note.D();
    console.log(note.toString()); // D4

    Parameters

    • octave: number = 4

    Returns Note

    note set to D[octave]

Static E

  • E(octave?: number): Note
  • static
    example
    const note = Note.E();
    console.log(note.toString()); // E4

    Parameters

    • octave: number = 4

    Returns Note

    note set to E[octave]

Static F

  • F(octave?: number): Note
  • static
    example
    const note = Note.F();
    console.log(note.toString()); // F4

    Parameters

    • octave: number = 4

    Returns Note

    note set to F[octave]

Static G

  • G(octave?: number): Note
  • static
    example
    const note = Note.G();
    console.log(note.toString()); // G4

    Parameters

    • octave: number = 4

    Returns Note

    note set to G[octave]

Generated using TypeDoc