Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilymilovidov committed Oct 7, 2023
1 parent 2f0798d commit b25b9d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 1 addition & 3 deletions packages/superdough/reverb.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ if (typeof AudioContext !== 'undefined') {

AudioContext.prototype.createReverb = function (duration, fade, lp, dim, ir) {
const convolver = this.createConvolver();
convolver.generate = (d, fade, lp, dim, buf) => {
convolver.generate = (d = 2, fade = 0.1, lp = 15000, dim = 1000, buf) => {
if (buf) {
convolver.buffer = this.adjustLength(d, buf);
return convolver;
} else {
this.generateReverb(
{
Expand All @@ -42,7 +41,6 @@ if (typeof AudioContext !== 'undefined') {
convolver.fade = fade;
convolver.lp = lp;
convolver.dim = dim;
return convolver;
}
};
convolver.setIR = (d, fade, lp, dim, buf) => {
Expand Down
26 changes: 16 additions & 10 deletions packages/superdough/superdough.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ function getDelay(orbit, delaytime, delayfeedback, t) {

let reverbs = {};

let hasChanged = (now, before) => now !== undefined && now !== before;

function getReverb(orbit, duration = 2, fade, lp, dim, ir) {
if (!reverbs[orbit]) {
const ac = getAudioContext();
Expand All @@ -123,13 +125,17 @@ function getReverb(orbit, duration = 2, fade, lp, dim, ir) {
}

if (
reverbs[orbit].duration !== duration ||
reverbs[orbit].fade !== fade ||
reverbs[orbit].ir !== lp ||
reverbs[orbit].dim !== dim ||
reverbs[orbit].ir !== ir
hasChanged(duration, reverbs[orbit].duration) ||
hasChanged(fade, reverbs[orbit].fade) ||
hasChanged(lp, reverbs[orbit].lp) ||
hasChanged(dim, reverbs[orbit].dim)
) {
reverbs[orbit].generate(duration, fade, lp, dim, ir);
// only regenerate when something has changed
// avoids endless regeneration on things like
// stack(s("a"), s("b").rsize(8)).room(.5)
// this only works when args may stay undefined until here
// setting default values breaks this
reverbs[orbit].generate(duration, fade, lp, dim);
}

if (reverbs[orbit].ir !== ir) {
Expand Down Expand Up @@ -235,10 +241,10 @@ export const superdough = async (value, deadline, hapDuration) => {
delaytime = 0.25,
orbit = 1,
room,
roomfade = 0.1,
roomlp = 15000,
roomdim = 1000,
roomsize = 2,
roomfade,
roomlp,
roomdim,
roomsize,
ir,
i = 0,
velocity = 1,
Expand Down

0 comments on commit b25b9d8

Please sign in to comment.