Method Summary

Public Methods
public
sortNotes(notes): Array

Sorts an array of Notes so that they are in the same order that they would appear on a piano.

public
withinRange(value, min, max)

Ensures that a number is not less than or greater than a given min and max.

public
zeroify(input): String

Formats a number and converts to string: 6 becomes '06'

Private Methods
private
arraySwap(arr, index): Array

Given an array and an index, splits the array at index and pushes the first chunk to the end of the second chunk.

private
base64ToUint8(base64String): Uint8Array

Converts a base64 string into a Uint8Array of "binary" data.

private

Accepts an array of two arrays, [0] being an array of Note objects, [1] being all the available octaves. Returns a single array made up of arrays of Note objects, organized by octave. Each inner array represents all of the notes in an octave.

private

Accepts an array of Note objects and passes back an array like this: [original array, array of each octave in the orginal array]

private
flatten(arr): Array

Flattens an array of arrays into a shallow array.

private
mungeSoundFont(soundfont): Object

Strips extraneous stuff from a soundfont and splits the soundfont into a JSON object. Keys are note names and values are base64 encoded strings.

private
noteSort(a, b): Number

Acts as a comparator function for the Array.prototype.sort method. Sorts two Note instances alphabetically, flats before naturals.

private
octaveShift(octaves): Array

Takes an array of arrays of notes, determines the last note of the first array, then splits the rest of the arrays in the array at the last note of the first array, and moves the beginning of the array to the end so that each array starts at the next note after the last note of the first array, instead of at "A" (alphabetically).

private
octaveSort(octaves): Array

Maps through an array of arrays and sorts each array with "noteSort"

private
stripDuplicateOctaves([notes, octaves]): Array

Accepts an array of two arrays and returns the same array, but with array at index [1] uniq'd and sorted alphabetically.

Public Methods

addon/utils/note-methods.js:13

public sortNotes(notes): Array

Sorts an array of Notes so that they are in the same order that they would appear on a piano.

Parameters:

Name Type Attribute Description
notes Array

An array of notes that should be musically-sorted.

Return:

Array

Array of musically-sorted notes.

addon/utils/within-range.js:6

public withinRange(value, min, max)

Ensures that a number is not less than or greater than a given min and max.

Parameters:

Name Type Attribute Description
value Number

The value that should be checked/returned if within given range.

min Number

The minimum allowed value of the value param. If value is less than this value, this value will be returned instead.

max Number

The maximum allowed value of the value param. If value is greater than this value, this value will be returned instead.

addon/utils/zeroify.js:6

public zeroify(input): String

Formats a number and converts to string: 6 becomes '06'

Parameters:

Name Type Attribute Description
input Number

A number that should be formatted

Return:

String

The number formatted and converted to string

Private Methods

addon/utils/array-methods.js:12

private arraySwap(arr, index): Array

Given an array and an index, splits the array at index and pushes the first chunk to the end of the second chunk.

Parameters:

Name Type Attribute Description
arr Array

An array to split, shift and rejoin.

index Number

The index where the split should occur.

Return:

Array

The swapped/shifted array.

addon/utils/decode-base64.js:6

private base64ToUint8(base64String): Uint8Array

Converts a base64 string into a Uint8Array of "binary" data.

Parameters:

Name Type Attribute Description
base64String String

The base64 string that you'd like to be converted.

Return:

Uint8Array

A Uint8Array of converted "binary" audio data.

addon/utils/note-methods.js:128

private createOctavesWithNotes(data): Ember.MutableArray

Accepts an array of two arrays, [0] being an array of Note objects, [1] being all the available octaves. Returns a single array made up of arrays of Note objects, organized by octave. Each inner array represents all of the notes in an octave.

Parameters:

Name Type Attribute Description
data Array

The output of stripDuplicateOctaves.

addon/utils/note-methods.js:97

private extractOctaves(notes): Array

Accepts an array of Note objects and passes back an array like this: [original array, array of each octave in the orginal array]

Parameters:

Name Type Attribute Description
notes Array

array of note objects.

Return:

Array

array containing two inner arrays, [0] is the untouched input array, [1] is an array of all the octaves in the original array.

addon/utils/array-methods.js:28

private flatten(arr): Array

Flattens an array of arrays into a shallow array.

Parameters:

Name Type Attribute Description
arr ArrayOfArrays

An array to flatten.

Return:

Array

The flattened array.

addon/utils/decode-base64.js:38

private mungeSoundFont(soundfont): Object

Strips extraneous stuff from a soundfont and splits the soundfont into a JSON object. Keys are note names and values are base64 encoded strings.

Parameters:

Name Type Attribute Description
soundfont String

A soundfont as a long base64 string

Return:

Object

A JSON representation of all the notes in the font

addon/utils/note-methods.js:145

private noteSort(a, b): Number

Acts as a comparator function for the Array.prototype.sort method. Sorts two Note instances alphabetically, flats before naturals.

Parameters:

Name Type Attribute Description
a Note

The first Note instance to compare.

b Note

The second Note instance to compare.

Return:

Number

-1 or 1, depending on whether the current Note instance should be sorted left, or right.

addon/utils/note-methods.js:45

private octaveShift(octaves): Array

Takes an array of arrays of notes, determines the last note of the first array, then splits the rest of the arrays in the array at the last note of the first array, and moves the beginning of the array to the end so that each array starts at the next note after the last note of the first array, instead of at "A" (alphabetically).

Parameters:

Name Type Attribute Description
octaves Array

An array of octaves, each octave is an array of Notes.

Return:

Array

Input array after having been shifted.

Example:

This is hard to explain. Here's an example.
(Simplified, as the real notes are objects)

Example input: [['A0', 'B0'], ['A1', 'B1', 'C1', 'D1']]
Example output: [['A0', 'B0'], ['C1', 'D1', 'A1', 'B1']]
addon/utils/note-methods.js:82

private octaveSort(octaves): Array

Maps through an array of arrays and sorts each array with "noteSort"

Parameters:

Name Type Attribute Description
octaves Array

array of arrays to be sorted

Return:

Array

array of sorted arrays

addon/utils/note-methods.js:113

private stripDuplicateOctaves([notes, octaves]): Array

Accepts an array of two arrays and returns the same array, but with array at index [1] uniq'd and sorted alphabetically.

Parameters:

Name Type Attribute Description
notes, octaves Array
  • optional

the output from extractOctaves.

Return:

Array

The mutated array.