diff --git a/Project/fractalNoteEcho.js b/Project/fractalNoteEcho.js index 5497cb2..996659e 100644 --- a/Project/fractalNoteEcho.js +++ b/Project/fractalNoteEcho.js @@ -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) diff --git a/src/fractalNoteEcho.ts b/src/fractalNoteEcho.ts index 25e3e80..bf47b75 100644 --- a/src/fractalNoteEcho.ts +++ b/src/fractalNoteEcho.ts @@ -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)