How to use the tonal-pitches.chroma function in tonal-pitches

To help you get started, we’ve selected a few tonal-pitches 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 / tonal-intervals / dist / index.js View on Github external
function ic(ivl) {
  var s = typeof ivl === 'string' ? tonalPitches.chroma(ivl) : Math.round(ivl);
  return s !== null ? CLASSES[Math.abs(s) % 12] : null;
}
github tonaljs / tonal / packages / tonal-intervals / lib / index.js View on Github external
export const density = listFn((list) => {
  var a, b, i
  const notes = list.filter(isPitchNotIvl)
  const len = notes.length
  const result = [0, 0, 0, 0, 0, 0]
  for (a = 0; a < len; a++) {
    for (b = a; b < len; b++) {
      i = ic(chroma(notes[b]) - chroma(notes[a]))
      if (i === 6) result[5] = result[5] + 1
      else if (i > 0) result[5 - i] = result[5 - i] + 1
    }
  }
  return result
})
github tonaljs / tonal / packages / tonal-intervals / lib / index.js View on Github external
export function ic (ivl) {
  const s = typeof ivl === 'string' ? chroma(ivl) : Math.round(ivl)
  return s !== null ? CLASSES[Math.abs(s) % 12] : null
}
github tonaljs / tonal / packages / tonal-intervals / dist / index.js View on Github external
var density = tonalArrays.listFn(function (list) {
  var a, b, i;
  var notes = list.filter(tonalPitches.isPitchNotIvl);
  var len = notes.length;
  var result = [0, 0, 0, 0, 0, 0];
  for (a = 0; a < len; a++) {
    for (b = a; b < len; b++) {
      i = ic(tonalPitches.chroma(notes[b]) - tonalPitches.chroma(notes[a]));
      if (i === 6) result[5] = result[5] + 1;else if (i > 0) result[5 - i] = result[5 - i] + 1;
    }
  }
  return result;
});