mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-15 23:58:33 +00:00
add preliminary getFrequency
This commit is contained in:
parent
803b50535f
commit
1b35dd0c55
@ -40,6 +40,23 @@ export const getPlayableNoteValue = (event) => {
|
||||
return note;
|
||||
};
|
||||
|
||||
// TODO: make this compatible with midi numbers object values
|
||||
export const getFrequency = (event) => {
|
||||
let { value, context } = event;
|
||||
// if value is number => interpret as midi number as long as its not marked as frequency
|
||||
if (typeof value === 'object' && value.freq) {
|
||||
return value.freq;
|
||||
}
|
||||
/* if (typeof value === 'number' && context.type !== 'frequency') {
|
||||
value = fromMidi(event.value);
|
||||
} else */ if (typeof value === 'string' && isNote(value)) {
|
||||
value = fromMidi(toMidi(event.value));
|
||||
} else if (typeof value !== 'number') {
|
||||
throw new Error('not a note or frequency:' + value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
// rotate array by n steps (to the left)
|
||||
export const rotate = (arr, n) => arr.slice(n).concat(arr.slice(0, n));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user