Skip to content

Commit

Permalink
Merge pull request #1272 from tidalcycles/fix-sf2-timing
Browse files Browse the repository at this point in the history
Fix sf2 timing
  • Loading branch information
felixroos authored Feb 1, 2025
2 parents 3d37478 + 1bf7402 commit 0338c5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/soundfonts/sfumato.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { getAudioContext, registerSound } from '@strudel/webaudio';
import { loadSoundfont as _loadSoundfont, startPresetNote } from 'sfumato';

Pattern.prototype.soundfont = function (sf, n = 0) {
return this.onTrigger((t, h, ct) => {
return this.onTrigger((time_deprecate, h, ct, cps, targetTime) => {
const ctx = getAudioContext();
const note = getPlayableNoteValue(h);
const preset = sf.presets[n % sf.presets.length];
const deadline = ctx.currentTime + t - ct;
const deadline = targetTime;
const args = [ctx, preset, noteToMidi(note), deadline];
const stop = startPresetNote(...args);
stop(deadline + h.duration);
Expand Down
2 changes: 1 addition & 1 deletion packages/superdough/superdough.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,14 @@ export function resetGlobalEffects() {
}

export const superdough = async (value, t, hapDuration) => {
const ac = getAudioContext();
t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t;
let { stretch } = value;
if (stretch != null) {
//account for phase vocoder latency
const latency = 0.04;
t = t - latency;
}
const ac = getAudioContext();
if (typeof value !== 'object') {
throw new Error(
`expected hap.value to be an object, but got "${value}". Hint: append .note() or .s() to the end`,
Expand Down

0 comments on commit 0338c5b

Please sign in to comment.