I've got an array of objects of this signature:
Note {
_payload: [Object],
blockText: 'ti',
measure: [Measure],
entries: [Array],
start: 500,
voiceId: undefined,
octaveModifier: 0,
previousNote: [Note],
firstNoteOfPreviousBlock: [Chord],
isTied: undefined,
currentSubgroup: undefined,
userInput: 'do refala misoti fa',
crescendoIndex: undefined,
chord: [Chord],
_duration: 250
}
There are getter functions baked into the API which allow me to access specific object properties, such as:
block.elapsedTime (which is the 'time' value), and ${note.alpha}${note.octave}, which is the ('note' value).
Ultimately, I am trying to iterate through the list of objects so that I can return objects with time and note values in this format:
[
{time: 0, note: 'C4', velocity: 0.7 },
{time: 250, note: 'D4', velocity: 0.7}
{time: 250, note: 'F4', velocity: 0.7}
{time: 250, note: 'A4', velocity: 0.7}
{time: 500, note: 'E4', velocity: 0.7}
{time: 500, note: 'G4', velocity: 0.7}
{time: 500, note: 'B4', velocity: 0.7}
{time: 750, note: 'F4', velocity: 0.7}
]
I've tried to use map in this vein:
block.entries.map(note => [block.elapsedTime, `${note.alpha}${note.octave}`])
but this returns arrays instead of objects.
Many thanks, Nakul
velocitya constant value (0.7)? Will you getnote.alphafrompreviousNote' field? How is the structure ofblock` object? Is it like{block : elapsedTime, note:{alpha:1,octave:1}?block.elapsedTimevalue, why are they different in the output? There is noalphaandoctaveproperties innotenoteclass extendsblockclass, then note object will haveelapsedTimeproperty. so the returned object can be{time: note.elapsedTime, note: '${}${}'}