mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
Merge pull request #650 from bwagner/tonleiter
FIXES: TODO in rotateChroma
This commit is contained in:
commit
584d469a73
@ -61,8 +61,7 @@ describe('tonleiter', () => {
|
||||
});
|
||||
test('rotateChroma', () => {
|
||||
expect(rotateChroma(0, 1)).toBe(1);
|
||||
expect(rotateChroma(0, -1)).toBe(-1); // this is wrong...
|
||||
//expect(rotateChroma(0, -1)).toBe(11); // <-- TODO
|
||||
expect(rotateChroma(0, -1)).toBe(11);
|
||||
expect(rotateChroma(11, 1)).toBe(0);
|
||||
expect(rotateChroma(11, 13)).toBe(0);
|
||||
});
|
||||
@ -81,9 +80,9 @@ describe('tonleiter', () => {
|
||||
});
|
||||
test('note2pc', () => {
|
||||
expect(note2pc('C5')).toBe('C');
|
||||
// expect(note2pc('C52')).toBe('C'); // <- 2 digits fail
|
||||
expect(note2pc('C52')).toBe('C');
|
||||
expect(note2pc('Bb3')).toBe('Bb');
|
||||
//expect(note2pc('F')).toBe('F'); // <- fails
|
||||
expect(note2pc('F')).toBe('F');
|
||||
});
|
||||
test('note2oct', () => {
|
||||
expect(note2oct('C5')).toBe(5);
|
||||
|
||||
@ -13,7 +13,7 @@ export const pc2chroma = (pc) => {
|
||||
return pcs.indexOf(letter.toLowerCase()) + rest.reduce((sum, sign) => sum + accs[sign], 0);
|
||||
};
|
||||
|
||||
export const rotateChroma = (chroma, steps) => (chroma + steps) % 12;
|
||||
export const rotateChroma = (chroma, steps) => (chroma + (steps % 12) + 12) % 12;
|
||||
|
||||
export const chroma2pc = (chroma, sharp = false) => {
|
||||
return (sharp ? sharps : flats)[chroma];
|
||||
@ -27,7 +27,7 @@ export function tokenizeChord(chord) {
|
||||
}
|
||||
return match.slice(1);
|
||||
}
|
||||
export const note2pc = (note) => note.slice(0, -1);
|
||||
export const note2pc = (note) => note.match(/^[A-G][#b]?/i)[0];
|
||||
export const note2oct = (note) => Number(note.slice(-1));
|
||||
|
||||
export const note2chroma = (note) => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Vitest Snapshot v1
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`renders tunes > tune: amensister 1`] = `
|
||||
[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user