addon/utils/zeroify.js:1
utils
Method Summary
Public Methods | |
---|---|
public |
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 |
Formats a number and converts to string: 6 becomes '06' |
Private Methods | |
---|---|
private |
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 |
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] |
private |
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 |
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 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 |
max | Number |
|
The maximum allowed value of the |
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:
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:
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:
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. |
Return:
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 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:
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:
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.
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:
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 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 |
|
the output from extractOctaves. |
Return:
The mutated array.