How to use the music-gamut.reduce function in music-gamut

To help you get started, we’ve selected a few music-gamut examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tonaljs / tonal / packages / note-filter / index.js View on Github external
filter.midi = function (fn, midi) {
  if (arguments.length === 1) return function (m) { return filter.midi(fn, m) }
  fn = filterFn(fn)
  var midiNotes = gamut.split(midi).map(note)
  return gamut.reduce(function (notes, n) {
    if (fn(n)) notes.push(n)
    else if (fn(prevEnh(n))) notes.push(prevEnh(n))
    else if (fn(nextEnh(n))) notes.push(nextEnh(n))
    return notes
  }, [], midiNotes)
}