mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
adjust latency
This commit is contained in:
parent
0f24e97855
commit
0a6373f64c
@ -34,7 +34,6 @@ function safeEval(str, options = {}) {
|
||||
str = `(async ()=>${str})()`;
|
||||
}
|
||||
const body = `"use strict";return (${str})`;
|
||||
console.log(body);
|
||||
return Function(body)();
|
||||
}
|
||||
|
||||
@ -49,6 +48,5 @@ export const evaluate = async (code, transpiler) => {
|
||||
// if no transpiler is given, we expect a single instruction (!wrapExpression)
|
||||
const options = { wrapExpression: !!transpiler };
|
||||
let evaluated = await safeEval(code, options);
|
||||
console.log(evaluated);
|
||||
return { mode: 'javascript', pattern: evaluated, meta };
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ Pattern.prototype.midi = function (output) {
|
||||
return this.onTrigger((time_deprecate, hap, currentTime, cps, targetTime) => {
|
||||
let { note, nrpnn, nrpv, ccn, ccv, velocity = 0.9, gain = 1 } = hap.value;
|
||||
//magic number to get audio engine to line up, can probably be calculated somehow
|
||||
const latency = 0.03;
|
||||
const latency = 0.034;
|
||||
const offset = (targetTime - currentTime + latency) * 1000;
|
||||
velocity = Math.floor(gain * velocity * 100);
|
||||
const duration = Math.floor((hap.duration.valueOf() / cps) * 1000 - 10);
|
||||
|
||||
@ -120,7 +120,7 @@ Pattern.prototype.midi = function (output) {
|
||||
const device = getDevice(output, WebMidi.outputs);
|
||||
hap.ensureObjectValue();
|
||||
//magic number to get audio engine to line up, can probably be calculated somehow
|
||||
const latency = 0.03;
|
||||
const latency = 0.034;
|
||||
// passing a string with a +num into the webmidi api adds an offset to the current time https://webmidijs.org/api/classes/Output
|
||||
const timeOffsetString = `+${(targetTime - currentTime + latency) * 1000}`;
|
||||
|
||||
|
||||
@ -17,9 +17,8 @@ const hap2value = (hap) => {
|
||||
|
||||
export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(hap), t - ct, hap.duration / cps, cps);
|
||||
// uses more precise, absolute t if available, see https://github.com/tidalcycles/strudel/pull/1004
|
||||
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) => {
|
||||
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) =>
|
||||
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
|
||||
};
|
||||
|
||||
Pattern.prototype.webaudio = function () {
|
||||
return this.onTrigger(webaudioOutputTrigger);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user