mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 11:38:37 +00:00
fixed prettier
This commit is contained in:
parent
c2be2ed76a
commit
3cd31e4841
@ -364,17 +364,16 @@ export function objectMap(obj, fn) {
|
|||||||
return Object.fromEntries(Object.entries(obj).map(([k, v], i) => [k, fn(v, k, i)]));
|
return Object.fromEntries(Object.entries(obj).map(([k, v], i) => [k, fn(v, k, i)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// utility for averaging two clocks together to account for drift
|
// utility for averaging two clocks together to account for drift
|
||||||
export class ClockCollator {
|
export class ClockCollator {
|
||||||
constructor({getTargetClockTime = () => Date.now() / 1000, weight = 16, offsetDelta = .005, checkAfterTime = 2}) {
|
constructor({ getTargetClockTime = () => Date.now() / 1000, weight = 16, offsetDelta = 0.005, checkAfterTime = 2 }) {
|
||||||
this.offsetTime;
|
this.offsetTime;
|
||||||
this.timeAtPrevOffsetSample;
|
this.timeAtPrevOffsetSample;
|
||||||
this.prevOffsetTimes = [];
|
this.prevOffsetTimes = [];
|
||||||
this.getTargetClockTime = getTargetClockTime
|
this.getTargetClockTime = getTargetClockTime;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.offsetDelta = offsetDelta
|
this.offsetDelta = offsetDelta;
|
||||||
this.checkAfterTime = checkAfterTime
|
this.checkAfterTime = checkAfterTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateTimestamp(currentTime, targetTime) {
|
calculateTimestamp(currentTime, targetTime) {
|
||||||
@ -398,7 +397,7 @@ export class ClockCollator {
|
|||||||
this.offsetTime = rollingOffsetTime;
|
this.offsetTime = rollingOffsetTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = this.offsetTime + targetTime;
|
const timestamp = this.offsetTime + targetTime;
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { parseNumeral, Pattern, ClockCollator } from '@strudel/core';
|
|||||||
|
|
||||||
import { Invoke } from './utils.mjs';
|
import { Invoke } from './utils.mjs';
|
||||||
|
|
||||||
const collator = new ClockCollator({})
|
const collator = new ClockCollator({});
|
||||||
|
|
||||||
export async function oscTriggerTauri(t_deprecate, hap, currentTime, cps = 1, targetTime) {
|
export async function oscTriggerTauri(t_deprecate, hap, currentTime, cps = 1, targetTime) {
|
||||||
hap.ensureObjectValue();
|
hap.ensureObjectValue();
|
||||||
@ -15,7 +15,7 @@ export async function oscTriggerTauri(t_deprecate, hap, currentTime, cps = 1, ta
|
|||||||
|
|
||||||
const params = [];
|
const params = [];
|
||||||
|
|
||||||
const timestamp = collator.calculateTimestamp(currentTime, targetTime)
|
const timestamp = collator.calculateTimestamp(currentTime, targetTime);
|
||||||
|
|
||||||
Object.keys(controls).forEach((key) => {
|
Object.keys(controls).forEach((key) => {
|
||||||
const val = controls[key];
|
const val = controls[key];
|
||||||
|
|||||||
@ -6,7 +6,7 @@ This program is free software: you can redistribute it and/or modify it under th
|
|||||||
|
|
||||||
import OSC from 'osc-js';
|
import OSC from 'osc-js';
|
||||||
|
|
||||||
import { logger, parseNumeral, Pattern, getEventOffsetMs, isNote, noteToMidi, ClockCollator } from '@strudel/core';
|
import { logger, parseNumeral, Pattern, isNote, noteToMidi, ClockCollator } from '@strudel/core';
|
||||||
|
|
||||||
let connection; // Promise<OSC>
|
let connection; // Promise<OSC>
|
||||||
function connect() {
|
function connect() {
|
||||||
@ -34,9 +34,9 @@ function connect() {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
const collator = new ClockCollator({})
|
const collator = new ClockCollator({});
|
||||||
|
|
||||||
export async function oscTrigger(t_deprecate, hap, currentTime, cps = 1, targetTime) {
|
export async function oscTrigger(t_deprecate, hap, currentTime, cps = 1, targetTime) {
|
||||||
hap.ensureObjectValue();
|
hap.ensureObjectValue();
|
||||||
const osc = await connect();
|
const osc = await connect();
|
||||||
const cycle = hap.wholeOrPart().begin.valueOf();
|
const cycle = hap.wholeOrPart().begin.valueOf();
|
||||||
@ -54,7 +54,7 @@ export async function oscTrigger(t_deprecate, hap, currentTime, cps = 1, targetT
|
|||||||
controls.bank && (controls.s = controls.bank + controls.s);
|
controls.bank && (controls.s = controls.bank + controls.s);
|
||||||
controls.roomsize && (controls.size = parseNumeral(controls.roomsize));
|
controls.roomsize && (controls.size = parseNumeral(controls.roomsize));
|
||||||
const keyvals = Object.entries(controls).flat();
|
const keyvals = Object.entries(controls).flat();
|
||||||
const ts = Math.round(collator.calculateTimestamp(currentTime, targetTime) * 1000)
|
const ts = Math.round(collator.calculateTimestamp(currentTime, targetTime) * 1000);
|
||||||
|
|
||||||
const message = new OSC.Message('/dirt/play', ...keyvals);
|
const message = new OSC.Message('/dirt/play', ...keyvals);
|
||||||
const bundle = new OSC.Bundle([message], ts);
|
const bundle = new OSC.Bundle([message], ts);
|
||||||
|
|||||||
@ -8,5 +8,5 @@ const trigger = isTauri() ? oscTriggerTauri : oscTrigger;
|
|||||||
export const superdirtOutput = (hap, deadline, hapDuration, cps, targetTime) => {
|
export const superdirtOutput = (hap, deadline, hapDuration, cps, targetTime) => {
|
||||||
const ctx = getAudioContext();
|
const ctx = getAudioContext();
|
||||||
const currentTime = ctx.currentTime;
|
const currentTime = ctx.currentTime;
|
||||||
return trigger(null, hap, currentTime, cps, targetTime)
|
return trigger(null, hap, currentTime, cps, targetTime);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,8 +20,6 @@ export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(h
|
|||||||
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) =>
|
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) =>
|
||||||
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
|
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Pattern.prototype.webaudio = function () {
|
Pattern.prototype.webaudio = function () {
|
||||||
return this.onTrigger(webaudioOutputTrigger);
|
return this.onTrigger(webaudioOutputTrigger);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export function AudioEngineTargetSelector({ target, onChange, isDisabled }) {
|
|||||||
onChange(target);
|
onChange(target);
|
||||||
};
|
};
|
||||||
const options = new Map([
|
const options = new Map([
|
||||||
[audioEngineTargets.webaudio, audioEngineTargets.webaudio ],
|
[audioEngineTargets.webaudio, audioEngineTargets.webaudio],
|
||||||
[audioEngineTargets.superdirt, 'superdirt (osc)'],
|
[audioEngineTargets.superdirt, 'superdirt (osc)'],
|
||||||
]);
|
]);
|
||||||
return <SelectInput isDisabled={isDisabled} options={options} value={target} onChange={onTargetChange} />;
|
return <SelectInput isDisabled={isDisabled} options={options} value={target} onChange={onTargetChange} />;
|
||||||
|
|||||||
@ -122,7 +122,7 @@ export function SettingsTab({ started }) {
|
|||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
{(
|
{
|
||||||
<FormItem label="Audio Engine Target">
|
<FormItem label="Audio Engine Target">
|
||||||
<AudioEngineTargetSelector
|
<AudioEngineTargetSelector
|
||||||
target={audioEngineTarget}
|
target={audioEngineTarget}
|
||||||
@ -136,7 +136,7 @@ export function SettingsTab({ started }) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
}
|
||||||
<FormItem label="Theme">
|
<FormItem label="Theme">
|
||||||
<SelectInput options={themeOptions} value={theme} onChange={(theme) => settingsMap.setKey('theme', theme)} />
|
<SelectInput options={themeOptions} value={theme} onChange={(theme) => settingsMap.setKey('theme', theme)} />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@ -242,7 +242,7 @@ export function SettingsTab({ started }) {
|
|||||||
if (r) {
|
if (r) {
|
||||||
settingsMap.set(defaultSettings);
|
settingsMap.set(defaultSettings);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
restore default settings
|
restore default settings
|
||||||
|
|||||||
@ -102,10 +102,10 @@ export function confirmDialog(msg) {
|
|||||||
const confirmed = confirm(msg);
|
const confirmed = confirm(msg);
|
||||||
if (confirmed instanceof Promise) {
|
if (confirmed instanceof Promise) {
|
||||||
return confirmed;
|
return confirmed;
|
||||||
}
|
}
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolve(confirmed)
|
resolve(confirmed);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastShared;
|
let lastShared;
|
||||||
@ -116,7 +116,9 @@ export async function shareCode(codeToShare) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmDialog('Do you want your pattern to be public? If no, press cancel and you will get just a private link.').then(async (isPublic) => {
|
confirmDialog(
|
||||||
|
'Do you want your pattern to be public? If no, press cancel and you will get just a private link.',
|
||||||
|
).then(async (isPublic) => {
|
||||||
const hash = nanoid(12);
|
const hash = nanoid(12);
|
||||||
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
|
const shareUrl = window.location.origin + window.location.pathname + '?' + hash;
|
||||||
const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
|
const { error } = await supabase.from('code_v1').insert([{ code: codeToShare, hash, ['public']: isPublic }]);
|
||||||
@ -138,9 +140,7 @@ export async function shareCode(codeToShare) {
|
|||||||
// alert(message);
|
// alert(message);
|
||||||
logger(message);
|
logger(message);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ReplContext = createContext(null);
|
export const ReplContext = createContext(null);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export const defaultSettings = {
|
|||||||
panelPosition: 'right',
|
panelPosition: 'right',
|
||||||
userPatterns: '{}',
|
userPatterns: '{}',
|
||||||
audioDeviceName: defaultAudioDeviceName,
|
audioDeviceName: defaultAudioDeviceName,
|
||||||
audioEngineTarget: audioEngineTargets.webaudio //webaudio | superdirt
|
audioEngineTarget: audioEngineTargets.webaudio, //webaudio | superdirt
|
||||||
};
|
};
|
||||||
|
|
||||||
let search = null;
|
let search = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user