File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,20 @@ import Effect from "./Effect"
44
55export default class Reverb extends Effect {
66
7- constructor ( length = 1 ) {
7+ constructor ( length = 1 , buffer = null ) {
88 super ( ) ;
99
10+ this . length = length ;
11+
12+
13+ //TODO: Should there be a buffer getter?
1014 this . reverbNode = Sound . context . createConvolver ( ) ;
11- this . reverbNode . buffer = this . generateReverbSignal ( length ) ;
15+ if ( ! buffer ) {
16+ this . _buffer = this . generateReverbSignal ( this . length ) ;
17+ } else {
18+ this . reverbNode . buffer = this . _buffer = buffer ;
19+ }
20+
1221
1322 this . effectBus . connect ( this . reverbNode ) ;
1423 this . reverbNode . connect ( this . wetGainNode ) ;
@@ -24,9 +33,12 @@ export default class Reverb extends Effect {
2433 bufferData [ i ] = ( Math . random ( ) * 2 - 1 ) * Math . pow ( ( 1 - ( i / bufferData . length ) ) , 3 ) ;
2534 }
2635
27- this . buffer = buffer ;
2836 return buffer ;
2937
3038 }
3139
40+ clone ( ) {
41+ return new Reverb ( this . length , this . _buffer ) ;
42+ }
43+
3244}
You can’t perform that action at this time.
0 commit comments