Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/superdough/superdough.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This program is free software: you can redistribute it and/or modify it under th
import './feedbackdelay.mjs';
import './reverb.mjs';
import './vowel.mjs';
import { clamp, nanFallback, _mod } from './util.mjs';
import { clamp, nanFallback, _mod, cycleToSeconds } from './util.mjs';
import workletsUrl from './worklets.mjs?audioworklet';
import { createFilter, gainNode, getCompressor, getWorklet } from './helpers.mjs';
import { map } from 'nanostores';
Expand Down Expand Up @@ -132,7 +132,7 @@ const defaultDefaultValues = {
distortvol: 1,
delay: 0,
delayfeedback: 0.5,
delaytime: 0.25,
delaytime: 3 / 16,
orbit: 1,
i: 1,
velocity: 1,
Expand Down Expand Up @@ -429,7 +429,7 @@ export function resetGlobalEffects() {

let activeSoundSources = new Map();

export const superdough = async (value, t, hapDuration) => {
export const superdough = async (value, t, hapDuration, cps = 1) => {
const ac = getAudioContext();
t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t;
let { stretch } = value;
Expand Down Expand Up @@ -699,7 +699,7 @@ export const superdough = async (value, t, hapDuration) => {
// delay
let delaySend;
if (delay > 0 && delaytime > 0 && delayfeedback > 0) {
const delyNode = getDelay(orbit, delaytime, delayfeedback, t);
const delyNode = getDelay(orbit, cycleToSeconds(delaytime, cps), delayfeedback, t);
delaySend = effectSend(post, delyNode, delay);
audioNodes.push(delaySend);
}
Expand Down
4 changes: 4 additions & 0 deletions packages/superdough/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ export const _mod = (n, m) => ((n % m) + m) % m;
export const getSoundIndex = (n, numSounds) => {
return _mod(Math.round(nanFallback(n, 0)), numSounds);
};

export function cycleToSeconds(cycle, cps) {
return cycle / cps;
}
5 changes: 3 additions & 2 deletions packages/webaudio/webaudio.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ 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) =>
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) => {
return superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration, cps);
};

Pattern.prototype.webaudio = function () {
return this.onTrigger(webaudioOutputTrigger);
Expand Down