How to use the music-gamut.transform 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-harmonizer / index.js View on Github external
function harmonize (source, tonic) {
  if (arguments.length === 1) return function (t) { return harmonize(source, t) }
  return gamut.transform(function (g) {
    if (tonic === null) return g
    var base = g[0]
    var intervals = g.map(distanceTo(base))
    if (tonic === false) return intervals
    tonic = parse(tonic)
    return intervals.map(transpose(tonic))
  }, source)
}
github tonaljs / tonal / packages / chord-progression / index.js View on Github external
module.exports = function (tonic, progression) {
  return gamut.transform(false, progression)
    .map(function (e) { return roman.exec(e) })
    .map(function (roman) {
      if (!roman) return null
      var intervl = parse(roman[2])
      return transpose(tonic, intervl) + roman[3]
    })
}
github tonaljs / tonal / packages / pitch-sort / index.js View on Github external
function sort (comp, source) {
  if (arguments.length > 1) return sort(comp)(source)
  if (comp === null || comp === true) comp = asc
  else if (comp === false) comp = desc
  return transform(function (g) { return g.sort(comp) })
}