Skip to content

Commit

Permalink
gswaNoise: random offset
Browse files Browse the repository at this point in the history
  • Loading branch information
mr21 committed Nov 6, 2023
1 parent 451d9b4 commit 080e51c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gswaNoise/gswaNoise.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

class gswaNoise {
static #buffer = null;
static #duration = 1;

// .........................................................................
static $initBuffer( ctx ) {
const srate = ctx.sampleRate;
const bufSize = 1 * srate;
const buf = ctx.createBuffer( 2, bufSize, srate );
const bufSize = gswaNoise.#duration * ctx.sampleRate;
const buf = ctx.createBuffer( 2, bufSize, ctx.sampleRate );
const chan0 = buf.getChannelData( 0 );
const chan1 = buf.getChannelData( 1 );

Expand All @@ -24,7 +24,7 @@ class gswaNoise {

absn.buffer = gswaNoise.#buffer;
absn.loop = true;
absn.start( when );
absn.start( when, Math.random() * gswaNoise.#duration );
if ( Number.isFinite( dur ) ) {
absn.stop( when + dur );
}
Expand Down

0 comments on commit 080e51c

Please sign in to comment.