Skip to content

Commit

Permalink
FIXES: note2pc TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
bwagner committed Jul 14, 2023
1 parent a3fdfbb commit 4298e58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/tonal/test/tonleiter.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,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);
Expand Down
2 changes: 1 addition & 1 deletion packages/tonal/tonleiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 4298e58

Please sign in to comment.