This repository was archived by the owner on Jun 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,51 @@ export class Dust {
108108 update = ( density ) => ( Math . random ( ) < density * ISR ? Math . random ( ) : 0 ) ;
109109}
110110
111+ export class WhiteNoise {
112+ update ( ) {
113+ return Math . random ( ) * 2 - 1 ;
114+ }
115+ }
116+
117+ export class BrownNoise {
118+ constructor ( ) {
119+ this . out = 0 ;
120+ }
121+ update ( ) {
122+ let white = Math . random ( ) * 2 - 1 ;
123+ this . out = ( this . out + 0.02 * white ) / 1.02 ;
124+ return this . out ;
125+ }
126+ }
127+
128+ export class PinkNoise {
129+ constructor ( ) {
130+ this . b0 = 0 ;
131+ this . b1 = 0 ;
132+ this . b2 = 0 ;
133+ this . b3 = 0 ;
134+ this . b4 = 0 ;
135+ this . b5 = 0 ;
136+ this . b6 = 0 ;
137+ }
138+
139+ update ( ) {
140+ const white = Math . random ( ) * 2 - 1 ;
141+
142+ this . b0 = 0.99886 * this . b0 + white * 0.0555179 ;
143+ this . b1 = 0.99332 * this . b1 + white * 0.0750759 ;
144+ this . b2 = 0.969 * this . b2 + white * 0.153852 ;
145+ this . b3 = 0.8665 * this . b3 + white * 0.3104856 ;
146+ this . b4 = 0.55 * this . b4 + white * 0.5329522 ;
147+ this . b5 = - 0.7616 * this . b5 - white * 0.016898 ;
148+
149+ const pink = this . b0 + this . b1 + this . b2 + this . b3 + this . b4 + this . b5 + this . b6 + white * 0.5362 ;
150+ this . b6 = white * 0.115926 ;
151+
152+ return pink * 0.11 ;
153+ }
154+ }
155+
111156export class Impulse {
112157 phase = 1 ;
113158 update ( freq ) {
@@ -369,7 +414,11 @@ let oscillators = {
369414 pulse : PulseOsc ,
370415 pulze : PulzeOsc ,
371416 dust : Dust ,
417+ crackle : Dust ,
372418 impulse : Impulse ,
419+ white : WhiteNoise ,
420+ brown : BrownNoise ,
421+ pink : PinkNoise ,
373422} ;
374423
375424const defaultDefaultValues = {
You can’t perform that action at this time.
0 commit comments