How to use the tonal.Distance.interval function in tonal

To help you get started, we’ve selected a few tonal 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 felixroos / harmonical / src / util_old.ts View on Github external
  const diffDegrees = (a, b) => Math.abs(getDegreeFromInterval(Distance.interval(a, b) + '') - degree);
  /* const diffTones = (a, b) => Math.abs(Distance.interval(a, b) - semitones); */
github felixroos / harmonical / src / util_old.ts View on Github external
return notes.map(note => {
    let interval = Distance.interval(root, Note.pc(note));
    return getStepFromInterval(interval, min);
  });
}
github felixroos / harmonical / src / util.ts View on Github external
return notes.reduce((absolute, current, index, notes) => {
    if (index === 0) {
      return [current + octave];
    }
    let interval = Distance.interval(notes[index - 1], current);
    interval = Harmony.minInterval(interval, direction);
    if (interval === '1P') {
      interval = direction === 'down' ? '-8P' : '8P';
    }
    absolute.push(Distance.transpose(absolute[index - 1], interval + ''));
    return absolute;
  }, []);
}
github felixroos / harmonical / src / util.ts View on Github external
export function semitoneDistance(noteA, noteB) {
  return Interval.semitones(Distance.interval(noteA, noteB) + '');
}
/** Turns an interval into a degree */
github felixroos / harmonical / src / util_old.ts View on Github external
return notes.reduce((intervals, note, index, notes) => {
    if (index === 0) {
      return [];
    }
    intervals.push(Distance.interval(notes[index - 1], note));
    return intervals;
  }, []);
}
github felixroos / harmonical / src / util_old.ts View on Github external
return notes.filter(note => {
    const interval = Distance.interval(tokens[0], note);
    return !validate || validate(note, {
      root: tokens[0],
      symbol: tokens[1],
      interval,
      step: getStepFromInterval(interval),
      degree: getDegreeFromInterval(interval + '')
    });
  });
}
github felixroos / harmonical / src / util_old.ts View on Github external
return notes.reduce((absolute, current, index, notes) => {
    if (index === 0) {
      return [current + octave];
    }
    let interval = Distance.interval(notes[index - 1], current);
    interval = Harmony.minInterval(interval, direction);
    if (interval === '1P') {
      interval = direction === 'down' ? '-8P' : '8P';
    }
    absolute.push(Distance.transpose(absolute[index - 1], interval + ''));
    return absolute;
  }, []);
}
github felixroos / harmonical / src / util_old.ts View on Github external
export function getStepInChord(note, chord, min = false) {
  return getStepFromInterval(
    Distance.interval(
      Chord.tokenize(Harmony.getTonalChord(chord))[0],
      Note.pc(note)), min
  );
}