Merge pull request #40 from tidalcycles/compose

Compose
This commit is contained in:
Felix Roos 2022-04-11 22:39:43 +02:00 committed by GitHub
commit cf7b2b2acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 4516 additions and 2963 deletions

1974
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,12 +6,11 @@
"packages": {
"": {
"name": "@strudel.cycles/core",
"version": "0.0.1",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
"fraction.js": "^4.2.0"
},
"devDependencies": {
"mocha": "^9.2.2"
@ -733,15 +732,6 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
@ -1485,11 +1475,6 @@
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true
},
"ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA=="
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",

View file

@ -26,8 +26,7 @@
"homepage": "https://strudel.tidalcycles.org",
"dependencies": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
"fraction.js": "^4.2.0"
},
"devDependencies": {
"mocha": "^9.2.2"

View file

@ -1,6 +1,5 @@
import Fraction from './fraction.mjs';
import { compose } from 'ramda'; // will remove this as soon as compose is implemented here
import { isNote, toMidi } from './util.mjs';
import { isNote, toMidi, compose } from './util.mjs';
// Removes 'None' values from given list
const removeUndefineds = (xs) => xs.filter((x) => x != undefined);

View file

@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { isNote, tokenizeNote, toMidi, mod } from '../util.mjs';
import { isNote, tokenizeNote, toMidi, mod, compose } from '../util.mjs';
describe('isNote', () => {
it('should recognize notes without accidentals', () => {
@ -83,3 +83,16 @@ describe('mod', () => {
assert.equal(mod(-3, 2), 1);
});
});
describe('compose', () => {
const add1 = (a) => a + 1;
it('should compose', () => {
assert.equal(compose(add1, add1)(0), 2);
assert.equal(compose(add1)(0), 1);
});
const addS = (s) => (a) => a + s;
it('should compose left to right', () => {
assert.equal(compose(addS('a'), addS('b'))(''), 'ab');
assert.equal(compose(addS('a'), addS('b'))('x'), 'xab');
});
});

View file

@ -42,3 +42,14 @@ export const getPlayableNoteValue = (event) => {
// rotate array by n steps (to the left)
export const rotate = (arr, n) => arr.slice(n).concat(arr.slice(0, n));
export const pipe = (...funcs) => {
return funcs.reduce(
(f, g) =>
(...args) =>
f(g(...args)),
(x) => x,
);
};
export const compose = (...funcs) => pipe(...funcs.reverse());

View file

@ -1,4 +1,4 @@
import { curry } from 'ramda';
import { curry } from './strudel.mjs';
function unionWithObj(a, b, func) {
const common = Object.keys(a).filter((k) => Object.keys(b).includes(k));

View file

@ -6,7 +6,7 @@
"packages": {
"": {
"name": "@strudel.cycles/eval",
"version": "0.0.1",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"estraverse": "^5.3.0",

View file

@ -6,7 +6,7 @@
"packages": {
"": {
"name": "@strudel.cycles/midi",
"version": "0.0.1",
"version": "0.0.4",
"license": "GPL-3.0-or-later",
"dependencies": {
"tone": "^14.7.77",

View file

@ -6,10 +6,9 @@
"packages": {
"": {
"name": "@strudel.cycles/tonal",
"version": "0.0.1",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"dependencies": {
"@strudel.cycles/core": "^0.0.1",
"@tonaljs/tonal": "^4.6.5",
"webmidi": "^3.0.15"
}
@ -390,16 +389,6 @@
"rollup": "^1.20.0||^2.0.0"
}
},
"node_modules/@strudel.cycles/core": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@strudel.cycles/core/-/core-0.0.1.tgz",
"integrity": "sha512-s+swPALAfq0GbCNNii+u7Crpm0GIC6b8pYF5c20xh0wjOazX61YgIckYRue/4c6x8S4HRHR88CilB0CEo9rCZQ==",
"dependencies": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
}
},
"node_modules/@tonaljs/abc-notation": {
"version": "4.6.5",
"resolved": "https://registry.npmjs.org/@tonaljs/abc-notation/-/abc-notation-4.6.5.tgz",
@ -688,11 +677,6 @@
"node": ">=8"
}
},
"node_modules/bjork": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/bjork/-/bjork-0.0.1.tgz",
"integrity": "sha1-br1a3pkWSwvgMIeI1kaRQ9XJrZw="
},
"node_modules/bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -969,18 +953,6 @@
"node": ">= 0.10"
}
},
"node_modules/fraction.js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
"integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==",
"engines": {
"node": "*"
},
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/infusion"
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -1370,15 +1342,6 @@
"node": ">=0.10.0"
}
},
"node_modules/ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/ramda"
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",
@ -1829,16 +1792,6 @@
"picomatch": "^2.2.2"
}
},
"@strudel.cycles/core": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@strudel.cycles/core/-/core-0.0.1.tgz",
"integrity": "sha512-s+swPALAfq0GbCNNii+u7Crpm0GIC6b8pYF5c20xh0wjOazX61YgIckYRue/4c6x8S4HRHR88CilB0CEo9rCZQ==",
"requires": {
"bjork": "^0.0.1",
"fraction.js": "^4.2.0",
"ramda": "^0.28.0"
}
},
"@tonaljs/abc-notation": {
"version": "4.6.5",
"resolved": "https://registry.npmjs.org/@tonaljs/abc-notation/-/abc-notation-4.6.5.tgz",
@ -2112,11 +2065,6 @@
"yoctodelay": "^1.1.0"
}
},
"bjork": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/bjork/-/bjork-0.0.1.tgz",
"integrity": "sha1-br1a3pkWSwvgMIeI1kaRQ9XJrZw="
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
@ -2312,11 +2260,6 @@
"time-stamp": "^1.0.0"
}
},
"fraction.js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
"integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA=="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -2615,11 +2558,6 @@
}
}
},
"ramda": {
"version": "0.28.0",
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.28.0.tgz",
"integrity": "sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA=="
},
"regenerator-runtime": {
"version": "0.13.9",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz",

View file

@ -6,7 +6,7 @@
"packages": {
"": {
"name": "@strudel.cycles/tone",
"version": "0.0.1",
"version": "0.0.4",
"license": "GPL-3.0-or-later",
"dependencies": {
"@tonejs/piano": "^0.2.1",