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InC,OAHI,EAAG,GAAI,EAAM,KAAK,GACb,EAAG,QAAQ,IAAK,EAAM,KAAK,QAAQ,IACnC,EAAG,QAAQ,KAAK,EAAM,KAAK,QAAQ,IACrC,CACT,GAAG,GACL,GAPO,CAOJ,EACL,EA2BA,OAAO,QAAU","file":"/npm/note-filter@0.1.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/note-filter@0.1.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict'\n\nvar gamut = require('music-gamut')\nvar parse = require('music-notation/note/parse')\nvar note = require('midi-note')\n// descending dimished second\nfunction prevEnh (n) { return [n[0] + 12, n[1] - 7, n[2]] }\n// ascending dimished second\nfunction nextEnh (n) { return [n[0] - 12, n[1] + 7, n[2]] }\n\n/**\n * Filter notes using a function or a collection of notes\n *\n * This function is currified and can be partially applied.\n *\n * @function filter\n * @param {Function|String|Array} filter - the function to filter notes or the\n * collection of notes allowed. The collection of notes can be pitch classes or\n * individual notes. The function will receive one parameter with a note in\n * [array notation]() and must return true or false\n * @param {Array} notes - the notes to be filtered\n * @return {Array} the filtered notes\n *\n * @example\n * var filter = require('note-filter')\n * // filter by pitch class\n * filter('C', 'c3 c#2 c2 c4 cb2') // => ['C3', 'C2', 'C4'])\n * // filter by note\n * filter('c3', 'c1 c2 c3 c4 c5 c6') // => ['C3']\n * // filter by collection\n * filter('C E G3', 'c2 db2 c3 eb2 gb2 g3 ab g4') // => [ 'C2', 'C3', 'G3' ])\n *\n * @example\n * // partially applied\n * var cMajorFilter = filter('C D E F G A B')\n * cMajorFilter('c3') // => 'C3'\n * cMajorFilter('c#3') // => null\n */\nfunction filter (fn, notes) {\n  if (arguments.length > 1) return filter(fn)(notes)\n  fn = filterFn(fn)\n  return gamut.operation(function (g) {\n    return g.filter(fn)\n  })\n}\n\n/**\n * Filter midi notes using a filter function or a note list\n *\n * The difference from normal filter is that it check note enhramonics (see example)\n *\n * @name filter.midi\n * @function\n * @memberof filter\n * @param {Function|Array|String} filter - the filter function or the collection\n * of valid notes\n * @param {Integer|Array|String} midi - the midi notes\n *\n * @example\n * var filter = require('note-filter')\n * filter.midi('C D F', '60 61 62 63 64 65 66 67 69') // => ['C4', 'D4', 'F4']\n * // enhramonics\n * filter.midi('C D E#', '60 61 62 63 64 65 66 67 69') // => ['C4', 'D4', 'E#4']\n */\nfilter.midi = function (fn, midi) {\n  if (arguments.length === 1) return function (m) { return filter.midi(fn, m) }\n  fn = filterFn(fn)\n  var midiNotes = gamut.split(midi).map(note)\n  return gamut.operation(function (notes) {\n    return notes.reduce(function (notes, n) {\n      if (fn(n)) notes.push(n)\n      else if (fn(prevEnh(n))) notes.push(prevEnh(n))\n      else if (fn(nextEnh(n))) notes.push(nextEnh(n))\n      return notes\n    }, [])\n  })(midiNotes)\n}\n\nfunction filterFn (fn) {\n  switch (typeof fn) {\n    case 'function': return fn\n    case 'string': return notesFilter(fn)\n    default: throw Error('Not valid filter')\n  }\n}\n\n// create a function that filter the given note\nfunction noteFilter (n) {\n  return n.length === 1 ? function (o) { return n[0] === o[0] }\n  : function (o) { return n[0] === o[0] && n[1] === o[1] }\n}\n\nfunction notesFilter (notes) {\n  var fns = gamut.split(notes).map(parse).map(noteFilter)\n  var len = fns.length\n  return function (note) {\n    for (var i = 0; i < len; i++) {\n      if (fns[i](note)) return true\n    }\n    return false\n  }\n}\n\nmodule.exports = filter\n"]}