fix: mondo setcps / setcpm
This commit is contained in:
parent
8833d623f7
commit
86248328cc
2 changed files with 16 additions and 3 deletions
|
|
@ -85,7 +85,17 @@ export function repl({
|
||||||
const start = () => scheduler.start();
|
const start = () => scheduler.start();
|
||||||
const pause = () => scheduler.pause();
|
const pause = () => scheduler.pause();
|
||||||
const toggle = () => scheduler.toggle();
|
const toggle = () => scheduler.toggle();
|
||||||
const setCps = (cps) => scheduler.setCps(cps);
|
const setCps = (cps) => {
|
||||||
|
scheduler.setCps(unpure(cps));
|
||||||
|
return silence;
|
||||||
|
};
|
||||||
|
|
||||||
|
function unpure(pat) {
|
||||||
|
if (pat._Pattern) {
|
||||||
|
return pat.__pure;
|
||||||
|
}
|
||||||
|
return pat;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the global tempo to the given cycles per minute
|
* Changes the global tempo to the given cycles per minute
|
||||||
|
|
@ -97,7 +107,10 @@ export function repl({
|
||||||
* setcpm(140/4) // =140 bpm in 4/4
|
* setcpm(140/4) // =140 bpm in 4/4
|
||||||
* $: s("bd*4,[- sd]*2").bank('tr707')
|
* $: s("bd*4,[- sd]*2").bank('tr707')
|
||||||
*/
|
*/
|
||||||
const setCpm = (cpm) => scheduler.setCps(cpm / 60);
|
const setCpm = (cpm) => {
|
||||||
|
scheduler.setCps(unpure(cpm) / 60);
|
||||||
|
return silence;
|
||||||
|
};
|
||||||
|
|
||||||
// TODO - not documented as jsdoc examples as the test framework doesn't simulate enough context for `each` and `all`..
|
// TODO - not documented as jsdoc examples as the test framework doesn't simulate enough context for `each` and `all`..
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ function evaluator(node, scope) {
|
||||||
let pat;
|
let pat;
|
||||||
if (type === 'plain' && typeof variable !== 'undefined') {
|
if (type === 'plain' && typeof variable !== 'undefined') {
|
||||||
// some function names are not patternable, so we skip reification here
|
// some function names are not patternable, so we skip reification here
|
||||||
if (['!', 'extend', '@', 'expand', 'square', 'angle', 'all'].includes(value)) {
|
if (['!', 'extend', '@', 'expand', 'square', 'angle', 'all', 'setcpm', 'setcps'].includes(value)) {
|
||||||
return variable;
|
return variable;
|
||||||
}
|
}
|
||||||
pat = reify(variable);
|
pat = reify(variable);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue