mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 11:38:37 +00:00
Merge pull request #135 from tidalcycles/trigger-simplification
remove cycle + delta from onTrigger
This commit is contained in:
commit
0ce70f4d0d
@ -22,13 +22,15 @@ let startedAt = -1;
|
|||||||
*/
|
*/
|
||||||
Pattern.prototype.osc = function () {
|
Pattern.prototype.osc = function () {
|
||||||
return this._withHap((hap) => {
|
return this._withHap((hap) => {
|
||||||
const onTrigger = (time, hap, currentTime, cps, cycle, delta) => {
|
const onTrigger = (time, hap, currentTime, cps) => {
|
||||||
|
const cycle = hap.wholeOrPart().begin.valueOf();
|
||||||
|
const delta = hap.duration.valueOf();
|
||||||
// time should be audio time of onset
|
// time should be audio time of onset
|
||||||
// currentTime should be current time of audio context (slightly before time)
|
// currentTime should be current time of audio context (slightly before time)
|
||||||
if (startedAt < 0) {
|
if (startedAt < 0) {
|
||||||
startedAt = Date.now() - currentTime * 1000;
|
startedAt = Date.now() - currentTime * 1000;
|
||||||
}
|
}
|
||||||
const controls = Object.assign({}, { cps: cps, cycle: cycle, delta: delta }, hap.value);
|
const controls = Object.assign({}, { cps, cycle, delta }, hap.value);
|
||||||
const keyvals = Object.entries(controls).flat();
|
const keyvals = Object.entries(controls).flat();
|
||||||
const ts = Math.floor(startedAt + (time + latency) * 1000);
|
const ts = Math.floor(startedAt + (time + latency) * 1000);
|
||||||
const message = new OSC.Message('/dirt/play', ...keyvals);
|
const message = new OSC.Message('/dirt/play', ...keyvals);
|
||||||
|
|||||||
@ -57,14 +57,7 @@ function useRepl({ tune, defaultSynth, autolink = true, onEvent, onDraw: onDrawP
|
|||||||
/* console.warn('no instrument chosen', event);
|
/* console.warn('no instrument chosen', event);
|
||||||
throw new Error(`no instrument chosen for ${JSON.stringify(event)}`); */
|
throw new Error(`no instrument chosen for ${JSON.stringify(event)}`); */
|
||||||
} else {
|
} else {
|
||||||
onTrigger(
|
onTrigger(time, event, currentTime, 1 /* cps */);
|
||||||
time,
|
|
||||||
event,
|
|
||||||
currentTime,
|
|
||||||
1 /* cps */,
|
|
||||||
event.wholeOrPart().begin.valueOf(),
|
|
||||||
event.duration.valueOf(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user