Options
All
  • Public
  • Public/Protected
  • All
Menu

Melody representation as an array of integers: 0 for NO_EVENT (sustain), 1 for NOTE_OFF, and 2+ for note onsets at pitches between minPitch and maxPitch. Each position in the array corresponds to a fixed length of time. So, [2, 4, 6, 7, 9, 11, 13, 14, 0, 0, 0, 1] represents a major scale where the final note is held for 4 time steps then released.

param

An array of melody events.

param

The minimum pitch to represent.

param

The maximum pitch to represent.

Hierarchy

  • Melody

Index

Constructors

constructor

  • new Melody(events: ArrayLike<number>, minPitch: number, maxPitch: number): Melody

Properties

events

events: ArrayLike<number>

maxPitch

maxPitch: number

minPitch

minPitch: number

Methods

toNoteSequence

  • toNoteSequence(stepsPerQuarter?: number, qpm?: number): NoteSequence
  • Convert a melody to quantized NoteSequence.

    Parameters

    • Optional stepsPerQuarter: number

      Optional number of steps per quarter note.

    • Optional qpm: number

      Optional number of quarter notes per minute.

    Returns NoteSequence

    A quantized NoteSequence created from the Melody.

Static fromNoteSequence

  • fromNoteSequence(noteSequence: INoteSequence, minPitch: number, maxPitch: number, ignorePolyphony?: boolean, numSteps?: number): Melody
  • Extract a melody from a NoteSequence.

    Parameters

    • noteSequence: INoteSequence

      NoteSequence from which to extract a melody.

    • minPitch: number

      The minimum pitch to represent. Those above this value will cause an error to be thrown.

    • maxPitch: number

      The maximum pitch to represent. Those above this value will cause an error to be thrown.

    • Default value ignorePolyphony: boolean = true

      If false, an error will be raised when notes start at the same step. If true, the highest pitched note is used and others are ignored.

    • Optional numSteps: number

      The length of each sequence.

    Returns Melody

    A Melody created from the NoteSequence.

Generated using TypeDoc