mirror of
https://codeberg.org/uzu/strudel
synced 2026-09-05 06:57:35 -04:00
not quite..
This commit is contained in:
@@ -8,7 +8,7 @@ import { logger } from './logger.mjs';
|
||||
import { ClockCollator, cycleToSeconds } from './util.mjs';
|
||||
|
||||
export class NeoCyclist {
|
||||
constructor({ onTrigger, onToggle, getTime }) {
|
||||
constructor({ onTrigger, onToggle, getTime, latency = 0.1 }) {
|
||||
this.started = false;
|
||||
this.cps = 0.5;
|
||||
this.lastTick = 0; // absolute time when last tick (clock callback) happened
|
||||
@@ -20,7 +20,7 @@ export class NeoCyclist {
|
||||
// in order to schedule events consistently.
|
||||
this.collator = new ClockCollator({ getTargetClockTime: getTime });
|
||||
this.onToggle = onToggle;
|
||||
this.latency = 0.1; // fixed trigger time offset
|
||||
this.latency = latency; // fixed trigger time offset
|
||||
this.cycle = 0;
|
||||
this.id = Math.round(Date.now() * Math.random());
|
||||
this.worker = new SharedWorker(new URL('./clockworker.js', import.meta.url));
|
||||
|
||||
@@ -18,6 +18,7 @@ export function repl({
|
||||
editPattern,
|
||||
onUpdateState,
|
||||
sync = false,
|
||||
latency = 0.1,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
id,
|
||||
@@ -56,6 +57,7 @@ export function repl({
|
||||
setInterval,
|
||||
clearInterval,
|
||||
beforeStart,
|
||||
latency,
|
||||
};
|
||||
|
||||
// NeoCyclist uses a shared worker to communicate between instances, which is not supported on mobile chrome
|
||||
|
||||
@@ -108,6 +108,7 @@ export function SettingsTab({ started }) {
|
||||
audioEngineTarget,
|
||||
togglePanelTrigger,
|
||||
maxPolyphony,
|
||||
latency,
|
||||
multiChannelOrbits,
|
||||
isTabIndentationEnabled,
|
||||
isMultiCursorEnabled,
|
||||
@@ -165,6 +166,24 @@ export function SettingsTab({ started }) {
|
||||
value={maxPolyphony ?? ''}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="Latency">
|
||||
<Textbox
|
||||
min={0}
|
||||
max={Infinity}
|
||||
onBlur={(e) => {
|
||||
let v = parseFloat(e.target.value);
|
||||
v = isNaN(v) ? 0.1 : v;
|
||||
settingsMap.setKey('latency', v);
|
||||
}}
|
||||
onChange={(v) => {
|
||||
v = parseFloat(v);
|
||||
settingsMap.setKey('latency', isNaN(v) ? undefined : v);
|
||||
}}
|
||||
type="number"
|
||||
placeholder=""
|
||||
value={latency ?? 0.1}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Checkbox
|
||||
label="Multi Channel Orbits"
|
||||
|
||||
@@ -37,7 +37,7 @@ import './Repl.css';
|
||||
import { setInterval, clearInterval } from 'worker-timers';
|
||||
import { getMetadata } from '../metadata_parser';
|
||||
|
||||
const { latestCode, maxPolyphony, audioDeviceName, multiChannelOrbits } = settingsMap.get();
|
||||
const { latestCode, maxPolyphony, audioDeviceName, multiChannelOrbits, latency } = settingsMap.get();
|
||||
let modulesLoading, presets, drawContext, clearCanvas, audioReady;
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -73,6 +73,7 @@ export function useReplContext() {
|
||||
const drawContext = getDrawContext();
|
||||
const editor = new StrudelMirror({
|
||||
sync: isSyncEnabled,
|
||||
latency,
|
||||
defaultOutput,
|
||||
getTime,
|
||||
setInterval,
|
||||
|
||||
Reference in New Issue
Block a user