Skip to content

Commit

Permalink
Merge pull request tidalcycles#727 from tidalcycles/fix-n-scale
Browse files Browse the repository at this point in the history
consume n with scale
  • Loading branch information
felixroos authored Oct 7, 2023
2 parents e2569ed + 296cd83 commit daf965f
Show file tree
Hide file tree
Showing 3 changed files with 1,638 additions and 1,635 deletions.
3 changes: 3 additions & 0 deletions packages/tonal/tonal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ export const scale = register('scale', function (scale, pat) {
return pat.withHap((hap) => {
const isObject = typeof hap.value === 'object';
let note = isObject ? hap.value.n : hap.value;
if (isObject) {
delete hap.value.n; // remove n so it won't cause trouble
}
const asNumber = Number(note);
if (!isNaN(asNumber)) {
// TODO: worth keeping for supporting ':' in (non-mininotation) strings?
Expand Down
160 changes: 80 additions & 80 deletions test/__snapshots__/examples.test.mjs.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3942,96 +3942,96 @@ exports[`runs examples > example "saw" example index 1 1`] = `

exports[`runs examples > example "scale" example index 0 1`] = `
[
"[ 0/1 → 1/6 | n:0 note:C3 ]",
"[ 1/6 → 1/3 | n:2 note:E3 ]",
"[ 1/3 → 1/2 | n:4 note:G3 ]",
"[ 1/2 → 2/3 | n:6 note:B3 ]",
"[ 2/3 → 5/6 | n:4 note:G3 ]",
"[ 5/6 → 1/1 | n:2 note:E3 ]",
"[ 1/1 → 7/6 | n:0 note:C3 ]",
"[ 7/6 → 4/3 | n:2 note:E3 ]",
"[ 4/3 → 3/2 | n:4 note:G3 ]",
"[ 3/2 → 5/3 | n:6 note:B3 ]",
"[ 5/3 → 11/6 | n:4 note:G3 ]",
"[ 11/6 → 2/1 | n:2 note:E3 ]",
"[ 2/1 → 13/6 | n:0 note:C3 ]",
"[ 13/6 → 7/3 | n:2 note:E3 ]",
"[ 7/3 → 5/2 | n:4 note:G3 ]",
"[ 5/2 → 8/3 | n:6 note:B3 ]",
"[ 8/3 → 17/6 | n:4 note:G3 ]",
"[ 17/6 → 3/1 | n:2 note:E3 ]",
"[ 3/1 → 19/6 | n:0 note:C3 ]",
"[ 19/6 → 10/3 | n:2 note:E3 ]",
"[ 10/3 → 7/2 | n:4 note:G3 ]",
"[ 7/2 → 11/3 | n:6 note:B3 ]",
"[ 11/3 → 23/6 | n:4 note:G3 ]",
"[ 23/6 → 4/1 | n:2 note:E3 ]",
"[ 0/1 → 1/6 | note:C3 ]",
"[ 1/6 → 1/3 | note:E3 ]",
"[ 1/3 → 1/2 | note:G3 ]",
"[ 1/2 → 2/3 | note:B3 ]",
"[ 2/3 → 5/6 | note:G3 ]",
"[ 5/6 → 1/1 | note:E3 ]",
"[ 1/1 → 7/6 | note:C3 ]",
"[ 7/6 → 4/3 | note:E3 ]",
"[ 4/3 → 3/2 | note:G3 ]",
"[ 3/2 → 5/3 | note:B3 ]",
"[ 5/3 → 11/6 | note:G3 ]",
"[ 11/6 → 2/1 | note:E3 ]",
"[ 2/1 → 13/6 | note:C3 ]",
"[ 13/6 → 7/3 | note:E3 ]",
"[ 7/3 → 5/2 | note:G3 ]",
"[ 5/2 → 8/3 | note:B3 ]",
"[ 8/3 → 17/6 | note:G3 ]",
"[ 17/6 → 3/1 | note:E3 ]",
"[ 3/1 → 19/6 | note:C3 ]",
"[ 19/6 → 10/3 | note:E3 ]",
"[ 10/3 → 7/2 | note:G3 ]",
"[ 7/2 → 11/3 | note:B3 ]",
"[ 11/3 → 23/6 | note:G3 ]",
"[ 23/6 → 4/1 | note:E3 ]",
]
`;

exports[`runs examples > example "scale" example index 1 1`] = `
[
"[ 0/1 → 1/4 | n:0 note:C3 s:piano ]",
"[ 0/1 → 1/4 | n:7 note:C4 s:piano ]",
"[ 1/4 → 1/2 | n:4 note:G3 s:piano ]",
"[ 1/2 → 3/4 | n:2 note:E3 s:piano ]",
"[ 1/2 → 3/4 | n:7 note:C4 s:piano ]",
"[ 3/4 → 1/1 | n:4 note:G3 s:piano ]",
"[ 1/1 → 5/4 | n:0 note:C3 s:piano ]",
"[ 1/1 → 5/4 | n:7 note:C4 s:piano ]",
"[ 5/4 → 3/2 | n:4 note:G3 s:piano ]",
"[ 3/2 → 7/4 | n:2 note:E3 s:piano ]",
"[ 3/2 → 7/4 | n:7 note:C4 s:piano ]",
"[ 7/4 → 2/1 | n:4 note:G3 s:piano ]",
"[ 2/1 → 9/4 | n:0 note:C3 s:piano ]",
"[ 2/1 → 9/4 | n:7 note:C4 s:piano ]",
"[ 9/4 → 5/2 | n:4 note:G3 s:piano ]",
"[ 5/2 → 11/4 | n:2 note:Eb3 s:piano ]",
"[ 5/2 → 11/4 | n:7 note:C4 s:piano ]",
"[ 11/4 → 3/1 | n:4 note:G3 s:piano ]",
"[ 3/1 → 13/4 | n:0 note:C3 s:piano ]",
"[ 3/1 → 13/4 | n:7 note:C4 s:piano ]",
"[ 13/4 → 7/2 | n:4 note:G3 s:piano ]",
"[ 7/2 → 15/4 | n:2 note:Eb3 s:piano ]",
"[ 7/2 → 15/4 | n:7 note:C4 s:piano ]",
"[ 15/4 → 4/1 | n:4 note:G3 s:piano ]",
"[ 0/1 → 1/4 | note:C3 s:piano ]",
"[ 0/1 → 1/4 | note:C4 s:piano ]",
"[ 1/4 → 1/2 | note:G3 s:piano ]",
"[ 1/2 → 3/4 | note:E3 s:piano ]",
"[ 1/2 → 3/4 | note:C4 s:piano ]",
"[ 3/4 → 1/1 | note:G3 s:piano ]",
"[ 1/1 → 5/4 | note:C3 s:piano ]",
"[ 1/1 → 5/4 | note:C4 s:piano ]",
"[ 5/4 → 3/2 | note:G3 s:piano ]",
"[ 3/2 → 7/4 | note:E3 s:piano ]",
"[ 3/2 → 7/4 | note:C4 s:piano ]",
"[ 7/4 → 2/1 | note:G3 s:piano ]",
"[ 2/1 → 9/4 | note:C3 s:piano ]",
"[ 2/1 → 9/4 | note:C4 s:piano ]",
"[ 9/4 → 5/2 | note:G3 s:piano ]",
"[ 5/2 → 11/4 | note:Eb3 s:piano ]",
"[ 5/2 → 11/4 | note:C4 s:piano ]",
"[ 11/4 → 3/1 | note:G3 s:piano ]",
"[ 3/1 → 13/4 | note:C3 s:piano ]",
"[ 3/1 → 13/4 | note:C4 s:piano ]",
"[ 13/4 → 7/2 | note:G3 s:piano ]",
"[ 7/2 → 15/4 | note:Eb3 s:piano ]",
"[ 7/2 → 15/4 | note:C4 s:piano ]",
"[ 15/4 → 4/1 | note:G3 s:piano ]",
]
`;

exports[`runs examples > example "scale" example index 2 1`] = `
[
"[ 0/1 → 1/8 | n:10 note:C5 s:folkharp ]",
"[ 1/8 → 1/4 | n:2 note:F3 s:folkharp ]",
"[ 1/4 → 3/8 | n:7 note:F4 s:folkharp ]",
"[ 3/8 → 1/2 | n:4 note:A3 s:folkharp ]",
"[ 1/2 → 5/8 | n:2 note:F3 s:folkharp ]",
"[ 5/8 → 3/4 | n:5 note:C4 s:folkharp ]",
"[ 3/4 → 7/8 | n:9 note:A4 s:folkharp ]",
"[ 7/8 → 1/1 | n:8 note:G4 s:folkharp ]",
"[ 1/1 → 9/8 | n:7 note:F4 s:folkharp ]",
"[ 9/8 → 5/4 | n:1 note:D3 s:folkharp ]",
"[ 5/4 → 11/8 | n:1 note:D3 s:folkharp ]",
"[ 11/8 → 3/2 | n:6 note:D4 s:folkharp ]",
"[ 3/2 → 13/8 | n:2 note:F3 s:folkharp ]",
"[ 13/8 → 7/4 | n:4 note:A3 s:folkharp ]",
"[ 7/4 → 15/8 | n:6 note:D4 s:folkharp ]",
"[ 15/8 → 2/1 | n:10 note:C5 s:folkharp ]",
"[ 2/1 → 17/8 | n:4 note:A3 s:folkharp ]",
"[ 17/8 → 9/4 | n:0 note:C3 s:folkharp ]",
"[ 9/4 → 19/8 | n:8 note:G4 s:folkharp ]",
"[ 19/8 → 5/2 | n:2 note:F3 s:folkharp ]",
"[ 5/2 → 21/8 | n:7 note:F4 s:folkharp ]",
"[ 21/8 → 11/4 | n:6 note:D4 s:folkharp ]",
"[ 11/4 → 23/8 | n:11 note:D5 s:folkharp ]",
"[ 23/8 → 3/1 | n:3 note:G3 s:folkharp ]",
"[ 3/1 → 25/8 | n:0 note:C3 s:folkharp ]",
"[ 25/8 → 13/4 | n:11 note:D5 s:folkharp ]",
"[ 13/4 → 27/8 | n:4 note:A3 s:folkharp ]",
"[ 27/8 → 7/2 | n:9 note:A4 s:folkharp ]",
"[ 7/2 → 29/8 | n:10 note:C5 s:folkharp ]",
"[ 29/8 → 15/4 | n:12 note:F5 s:folkharp ]",
"[ 15/4 → 31/8 | n:1 note:D3 s:folkharp ]",
"[ 31/8 → 4/1 | n:4 note:A3 s:folkharp ]",
"[ 0/1 → 1/8 | note:C5 s:folkharp ]",
"[ 1/8 → 1/4 | note:F3 s:folkharp ]",
"[ 1/4 → 3/8 | note:F4 s:folkharp ]",
"[ 3/8 → 1/2 | note:A3 s:folkharp ]",
"[ 1/2 → 5/8 | note:F3 s:folkharp ]",
"[ 5/8 → 3/4 | note:C4 s:folkharp ]",
"[ 3/4 → 7/8 | note:A4 s:folkharp ]",
"[ 7/8 → 1/1 | note:G4 s:folkharp ]",
"[ 1/1 → 9/8 | note:F4 s:folkharp ]",
"[ 9/8 → 5/4 | note:D3 s:folkharp ]",
"[ 5/4 → 11/8 | note:D3 s:folkharp ]",
"[ 11/8 → 3/2 | note:D4 s:folkharp ]",
"[ 3/2 → 13/8 | note:F3 s:folkharp ]",
"[ 13/8 → 7/4 | note:A3 s:folkharp ]",
"[ 7/4 → 15/8 | note:D4 s:folkharp ]",
"[ 15/8 → 2/1 | note:C5 s:folkharp ]",
"[ 2/1 → 17/8 | note:A3 s:folkharp ]",
"[ 17/8 → 9/4 | note:C3 s:folkharp ]",
"[ 9/4 → 19/8 | note:G4 s:folkharp ]",
"[ 19/8 → 5/2 | note:F3 s:folkharp ]",
"[ 5/2 → 21/8 | note:F4 s:folkharp ]",
"[ 21/8 → 11/4 | note:D4 s:folkharp ]",
"[ 11/4 → 23/8 | note:D5 s:folkharp ]",
"[ 23/8 → 3/1 | note:G3 s:folkharp ]",
"[ 3/1 → 25/8 | note:C3 s:folkharp ]",
"[ 25/8 → 13/4 | note:D5 s:folkharp ]",
"[ 13/4 → 27/8 | note:A3 s:folkharp ]",
"[ 27/8 → 7/2 | note:A4 s:folkharp ]",
"[ 7/2 → 29/8 | note:C5 s:folkharp ]",
"[ 29/8 → 15/4 | note:F5 s:folkharp ]",
"[ 15/4 → 31/8 | note:D3 s:folkharp ]",
"[ 31/8 → 4/1 | note:A3 s:folkharp ]",
]
`;

Expand Down
Loading

0 comments on commit daf965f

Please sign in to comment.