Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const diffDegrees = (a, b) => Math.abs(getDegreeFromInterval(Distance.interval(a, b) + '') - degree);
/* const diffTones = (a, b) => Math.abs(Distance.interval(a, b) - semitones); */
return notes.map(note => {
let interval = Distance.interval(root, Note.pc(note));
return getStepFromInterval(interval, min);
});
}
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;
}, []);
}
export function semitoneDistance(noteA, noteB) {
return Interval.semitones(Distance.interval(noteA, noteB) + '');
}
/** Turns an interval into a degree */
return notes.reduce((intervals, note, index, notes) => {
if (index === 0) {
return [];
}
intervals.push(Distance.interval(notes[index - 1], note));
return intervals;
}, []);
}
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 + '')
});
});
}
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;
}, []);
}
export function getStepInChord(note, chord, min = false) {
return getStepFromInterval(
Distance.interval(
Chord.tokenize(Harmony.getTonalChord(chord))[0],
Note.pc(note)), min
);
}