Skip to content

Commit

Permalink
fix bug when out-of-scale notes were received
Browse files Browse the repository at this point in the history
  • Loading branch information
zsteinkamp committed Dec 22, 2024
1 parent 52f3f4a commit 0800070
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Project/fractalNoteEcho.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ function makeTask(r, n, v) {
if (options[INLET_SCALE_AWARE]) {
// get base note, look up
var baseIdx = scaleMeta.notes.indexOf(n);
while (baseIdx < 0 && n > 0) {
n -= 1;
baseIdx = scaleMeta.notes.indexOf(n);
}
if (baseIdx < 0) {
// invalid something or another
return;
}
var newIdx = baseIdx + r.note_incr;
n = scaleMeta.notes[newIdx];
//log('NOTE: ' + n + ' base:' + baseIdx + ' new:' + newIdx)
Expand Down
10 changes: 9 additions & 1 deletion src/fractalNoteEcho.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,15 @@ function makeTask(r: NoteMeta, n: number, v: number) {
return function () {
if (options[INLET_SCALE_AWARE]) {
// get base note, look up
const baseIdx = scaleMeta.notes.indexOf(n)
let baseIdx = scaleMeta.notes.indexOf(n)
while (baseIdx < 0 && n > 0) {
n -= 1
baseIdx = scaleMeta.notes.indexOf(n)
}
if (baseIdx < 0) {
// invalid something or another
return
}
const newIdx = baseIdx + r.note_incr
n = scaleMeta.notes[newIdx]
//log('NOTE: ' + n + ' base:' + baseIdx + ' new:' + newIdx)
Expand Down

0 comments on commit 0800070

Please sign in to comment.