mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-22 21:23:21 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a481a86c3b |
@@ -8,7 +8,7 @@ import { logger } from './logger.mjs';
|
|||||||
import { ClockCollator, cycleToSeconds } from './util.mjs';
|
import { ClockCollator, cycleToSeconds } from './util.mjs';
|
||||||
|
|
||||||
export class NeoCyclist {
|
export class NeoCyclist {
|
||||||
constructor({ onTrigger, onToggle, getTime }) {
|
constructor({ onTrigger, onToggle, getTime, latency = 0.1 }) {
|
||||||
this.started = false;
|
this.started = false;
|
||||||
this.cps = 0.5;
|
this.cps = 0.5;
|
||||||
this.lastTick = 0; // absolute time when last tick (clock callback) happened
|
this.lastTick = 0; // absolute time when last tick (clock callback) happened
|
||||||
@@ -20,7 +20,7 @@ export class NeoCyclist {
|
|||||||
// in order to schedule events consistently.
|
// in order to schedule events consistently.
|
||||||
this.collator = new ClockCollator({ getTargetClockTime: getTime });
|
this.collator = new ClockCollator({ getTargetClockTime: getTime });
|
||||||
this.onToggle = onToggle;
|
this.onToggle = onToggle;
|
||||||
this.latency = 0.1; // fixed trigger time offset
|
this.latency = latency; // fixed trigger time offset
|
||||||
this.cycle = 0;
|
this.cycle = 0;
|
||||||
this.id = Math.round(Date.now() * Math.random());
|
this.id = Math.round(Date.now() * Math.random());
|
||||||
this.worker = new SharedWorker(new URL('./clockworker.js', import.meta.url));
|
this.worker = new SharedWorker(new URL('./clockworker.js', import.meta.url));
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export function repl({
|
|||||||
editPattern,
|
editPattern,
|
||||||
onUpdateState,
|
onUpdateState,
|
||||||
sync = false,
|
sync = false,
|
||||||
|
latency = 0.1,
|
||||||
setInterval,
|
setInterval,
|
||||||
clearInterval,
|
clearInterval,
|
||||||
id,
|
id,
|
||||||
@@ -56,6 +57,7 @@ export function repl({
|
|||||||
setInterval,
|
setInterval,
|
||||||
clearInterval,
|
clearInterval,
|
||||||
beforeStart,
|
beforeStart,
|
||||||
|
latency,
|
||||||
};
|
};
|
||||||
|
|
||||||
// NeoCyclist uses a shared worker to communicate between instances, which is not supported on mobile chrome
|
// 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,
|
audioEngineTarget,
|
||||||
togglePanelTrigger,
|
togglePanelTrigger,
|
||||||
maxPolyphony,
|
maxPolyphony,
|
||||||
|
latency,
|
||||||
multiChannelOrbits,
|
multiChannelOrbits,
|
||||||
isTabIndentationEnabled,
|
isTabIndentationEnabled,
|
||||||
isMultiCursorEnabled,
|
isMultiCursorEnabled,
|
||||||
@@ -165,6 +166,24 @@ export function SettingsTab({ started }) {
|
|||||||
value={maxPolyphony ?? ''}
|
value={maxPolyphony ?? ''}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</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>
|
<FormItem>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
label="Multi Channel Orbits"
|
label="Multi Channel Orbits"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import './Repl.css';
|
|||||||
import { setInterval, clearInterval } from 'worker-timers';
|
import { setInterval, clearInterval } from 'worker-timers';
|
||||||
import { getMetadata } from '../metadata_parser';
|
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;
|
let modulesLoading, presets, drawContext, clearCanvas, audioReady;
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
@@ -73,6 +73,7 @@ export function useReplContext() {
|
|||||||
const drawContext = getDrawContext();
|
const drawContext = getDrawContext();
|
||||||
const editor = new StrudelMirror({
|
const editor = new StrudelMirror({
|
||||||
sync: isSyncEnabled,
|
sync: isSyncEnabled,
|
||||||
|
latency,
|
||||||
defaultOutput,
|
defaultOutput,
|
||||||
getTime,
|
getTime,
|
||||||
setInterval,
|
setInterval,
|
||||||
|
|||||||
Reference in New Issue
Block a user