How to use the music-gamut.operation 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 / music-scale / lib / select.js View on Github external
module.exports = function select (pttn, notes) {
  if (arguments.length === 2) return select(pttn)(notes)

  return G.operation(function (g) {
    var nums = G.split(pttn).map(function (n) { return +n - 1 })
    var index = []
    build(g, false).forEach(function (item) {
      var fifths = (item[0] + 1) % 7
      index[STEPS[fifths]] = item
    })
    var selected = nums.map(function (n) {
      var i = index[n % 7]
      // up an octave if number > 7
      if (i && n > 6) {
        i = i.slice()
        i[1] = i[1] + Math.floor(n / 7)
      }
      return i
    })
    return selected.map(transpose(g[0]))