Global

Methods

addOctaveToNoteName(noteName, octave) → {string}

Parameters:
Name Type Description
noteName string Note name
octave number
Source:
Returns:
noteName - Note name
Type
string
Example
addOctaveToNoteName('A', 3) // returns 'A3'

getInterval(noteNameOne, noteNameTwo) → {string}

Parameters:
Name Type Description
noteNameOne string Without octave
noteNameTwo string Without octave
Source:
Returns:
noteName - Note name
Type
string
Example
getInterval('A', 'B') // returns 1

getIntervalPermutationsFromNoteNames(noteNames) → {array}

Get all possible interval permutations between these notes. Helpful to be able to guess scale
Parameters:
Name Type Description
noteNames array Without octave
Source:
Returns:
intervalPermutations - [{firstNoteName: string, intervals: number, guessedScales: array}]
Type
array
Example
getIntervalPermutationsFromNoteNames(['A', 'B', 'C'])

//  Returns { firstNoteName: 'A', intervals: [0, 9, 10], guessedScales: [] },
//  { firstNoteName: 'B', intervals: [0, 2, 11], guessedScales: [] },
//  { firstNoteName: 'C', intervals: [0, 1, 3], guessedScales: [] },

getJSONFromMidiURL(url) → {Promise.<object>}

Download midi from url and parse it into JSON {meta, musicTracks}. Wrapper around MidiIO.parseMidi(url)
Parameters:
Name Type Description
url string URL to a midi file.
Source:
Returns:
Type
Promise.<object>
Example
getJSONFromMidiURL('https://s3-eu-west-1.amazonaws.com/ut-music-player/assets/midis/beet1track-medium-fast.mid')
.then((metaAndMusicTracks) => {
  const {meta, musicTracks} = metaAndMusicTracks;
})

getNoteNamesFromChordName(firstNoteNameWithOctave, chordName) → {array}

Get unique note names from array of note objects or note names
Parameters:
Name Type Description
firstNoteNameWithOctave string note name with octave e.g. 'A3'
chordName string Chord name full list of supported chords in src/constants/CHORDS.js
Source:
Returns:
notenames
Type
array
Example
getNoteNamesFromChordName('A3', 'min') // returns ['A3', 'C3', 'E3']
getNoteNamesFromChordName('C3', 'maj') // returns ['C3', 'E3', 'G3']
// Full list of supported chords in src/constants/CHORDS.js

getNoteNamesFromIntervals(noteNameWithOctave) → {array}

Get unique note names from array of note objects or note names
Parameters:
Name Type Description
noteNameWithOctave string note name with octave e.g. 'A3'
Source:
Returns:
notenames
Type
array
Example
getNoteNamesFromChordName('A3', [0, 2, 3]) // returns ['A3', 'B3', 'C3']
// Full list of supported chords in src/constants/CHORDS.js

getScaleNotes(note, scale, startOctave, count) → {array}

getScaleNotes - Get notes for a given scale for _count_ octaves at _startOctave_
Parameters:
Name Type Description
note string noteName without octave
scale string scaleName must be one defined in constants/SCALES
startOctave number starting octave
count number Number of octaves
Source:
Returns:
Array of note names with octave
Type
array

getScalesFromNoteNames(noteNames) → {array}

getScalesFromNoteNames - Get all scales matched with the given notes
Parameters:
Name Type Description
noteNames array noteNames with octave
Source:
Returns:
Array of note names with octave [{firstNoteName: string, intervals: number, guessedScales: array}]
Type
array
Example
getScalesFromNoteNames(['A3', 'B3', 'C3']);
// [
//   {
//     firstNoteName: 'A',
//     intervals: [0, 9, 10],
//     guessedScales: ['dorian', 'mixolydian', 'acoustic', 'algerian', 'majorBlues']
//   },
//  {
//     firstNoteName: 'B',
//     intervals: [0, 2, 11],
//     guessedScales: ['ionian', 'lydian', 'harmonicMinor', 'melodicMinorAsc']
//   },
//  {
//    firstNoteName: 'C',
//    intervals: [0, 1, 3],
//    guessedScales: ['phrygian', 'locrian', 'altered']
//  },
// ]

getTracksAndMetaFromParsedMidi(noteNames) → {object}

getTracksAndMetaFromParsedMidi - Convert a json midi file parsed with MidiIO into clean meta and tracks object
Parameters:
Name Type Description
noteNames array noteNames with octave
Source:
Returns:
Array of note names with octave [{firstNoteName: string, intervals: number, guessedScales: array}]
Type
object
Example
const parsedMidi = await getJSONFromMidiURL(url);
getTracksAndMetaFromParsedMidi(parsedMidi);
// Returns
//   {
//     meta: object,
//     tracks: array,
//   }

getTracksAndMetaFromUrl(url) → {object}

get all tracks and meta information from a midi url hosted online
Parameters:
Name Type Description
url string url of midi file that needs to be converted
Source:
Returns:
{tracks: [], meta: {}}
Type
object
Example
getTracksAndMetaFromUrl('https://s3-eu-west-1.amazonaws.com/ut-music-player/assets/midis/beet1track-medium-fast.mid') // returns {tracks: [], meta: {}}

getUniqueNoteNames(notes) → {array}

Get unique note names from array of note objects or note names
Parameters:
Name Type Description
notes array Can contain note objects with payload property or strings of note names
Source:
Returns:
notenames
Type
array
Example
getUniqueNoteNames(['A3', 'B3', 'A3']) // returns ['A3', 'B3']
getUniqueNoteNames(['A', 'B', 'A']) // returns ['A', 'B']
const noteOne = new Note({name: 'A3'});
const noteTwo = new Note({name: 'B3'});
const noteThree = new Note({name: 'A3'});
getUniqueNoteNames([noteOne, noteTwo, noteThree]) // returns ['A3', 'B3']

getUniqueNoteNamesNoOctave(notes) → {array}

Get unique note names from array of note objects or note names and remove octave from it
Parameters:
Name Type Description
notes array Can contain note objects with payload property or strings of note names
Source:
Returns:
notenames
Type
array
Example
getUniqueNoteNamesNoOctave(['A3', 'B3', 'A3']) // returns ['A', 'B']
getUniqueNoteNamesNoOctave(['A', 'B', 'A']) // returns ['A', 'B']
const noteOne = new Note({name: 'A3'});
const noteTwo = new Note({name: 'B3'});
const noteThree = new Note({name: 'A3'});
getUniqueNoteNamesNoOctave([noteOne, noteTwo, noteThree]) // returns ['A', 'B']

isInHigherOctave(noteOneNoOctave, noteTwoNoOctave) → {boolean}

Checks if interval between noteTwo and noteOne is negative or positive to know when to change octave
Parameters:
Name Type Description
noteOneNoOctave string
noteTwoNoOctave string
Source:
Returns:
isInHigherOctave
Type
boolean
Example
isInHigherOctave('A', 'B') // returns false
isInHigherOctave('B', 'A') // returns true

removeOctaveFromNoteName(noteName) → {string}

Parameters:
Name Type Description
noteName string Note name
Source:
Returns:
noteName - Note name
Type
string
Example
removeOctaveFromNoteName('A3') // returns 'A'

reOrderNotes(firstNote, notes) → {boolean}

reorder a set of notes such that it starts with the firstNote
Parameters:
Name Type Description
firstNote string
notes array
Source:
Returns:
isInHigherOctave
Type
boolean
Example
reOrderNotes('A' , ['C', 'B', 'A']) // returns ['A', 'B', 'C']
reOrderNotes('B') // returns ['B', 'C', 'D', 'E', 'F', 'G', 'A']

updateTempo(tracksAndMeta, notes) → {object}

reorder a set of notes such that it starts with the firstNote
Parameters:
Name Type Description
tracksAndMeta object from getTracksAndMetaFromParsedMidi getTracksAndMetaFromUrl
notes array
Source:
Returns:
tracksAndMeta
Type
object
Example
const newBPM = 60;
const trackIndex = 1;
const tracksAndMeta = await getTracksAndMetaFromUrl(url);
const updatedTracksAndMeta = updateTempo(tracksAndMeta, newBPM, trackIndex);
updateTempo('A' , ['C', 'B', 'A']); // returns ['A', 'B', 'C']
reOrderNotes('B'); // returns ['B', 'C', 'D', 'E', 'F', 'G', 'A']