@@ -50,7 +50,6 @@ define(function (require) {
50
50
AudioVoice . call ( this ) ;
51
51
52
52
this . oscillator = new p5 . Oscillator ( ) ;
53
- // this.oscillator.disconnect();
54
53
55
54
this . env = new p5 . Envelope ( ) ;
56
55
this . env . setRange ( 1 , 0 ) ;
@@ -59,25 +58,19 @@ define(function (require) {
59
58
//set params
60
59
this . setADSR ( 0.02 , 0.25 , 0.05 , 0.35 ) ;
61
60
62
- // filter
63
- this . filter = new p5 . Filter ( 'highpass' ) ;
64
- this . filter . set ( 5 , 1 ) ;
65
-
66
- // oscillator --> env --> filter --> this.output (gain) --> p5.soundOut
61
+ // oscillator --> env --> this.output (gain) --> p5.soundOut
67
62
this . oscillator . disconnect ( ) ;
68
- this . oscillator . connect ( this . filter ) ;
63
+ this . oscillator . connect ( this . output ) ;
64
+
69
65
this . env . disconnect ( ) ;
70
- this . env . setInput ( this . oscillator ) ;
71
- // this.env.connect(this.filter);
72
- this . filter . connect ( this . output ) ;
66
+ this . env . setInput ( this . output . gain ) ;
67
+
68
+ // reset oscillator gain to 1.0
69
+ this . oscillator . output . gain . value = 1.0 ;
73
70
74
71
this . oscillator . start ( ) ;
75
72
this . connect ( ) ;
76
73
77
- //Audiovoices are connected to soundout by default
78
-
79
- this . _isOn = false ;
80
-
81
74
p5sound . soundArray . push ( this ) ;
82
75
} ;
83
76
@@ -162,9 +155,8 @@ define(function (require) {
162
155
var secondsFromNow = ~ ~ secondsFromNow ;
163
156
var freq = noteToFreq ( note ) ;
164
157
var vel = velocity || 0.1 ;
165
- this . _isOn = true ;
166
158
this . oscillator . freq ( freq , 0 , secondsFromNow ) ;
167
- this . env . ramp ( this . output , secondsFromNow , vel ) ;
159
+ this . env . ramp ( this . output . gain , secondsFromNow , vel ) ;
168
160
} ;
169
161
170
162
/**
@@ -189,8 +181,7 @@ define(function (require) {
189
181
*/
190
182
p5 . MonoSynth . prototype . triggerRelease = function ( secondsFromNow ) {
191
183
var secondsFromNow = secondsFromNow || 0 ;
192
- this . env . ramp ( this . output , secondsFromNow , 0 ) ;
193
- this . _isOn = false ;
184
+ this . env . ramp ( this . output . gain , secondsFromNow , 0 ) ;
194
185
} ;
195
186
196
187
/**
@@ -319,9 +310,6 @@ define(function (require) {
319
310
p5 . MonoSynth . prototype . dispose = function ( ) {
320
311
AudioVoice . prototype . dispose . apply ( this ) ;
321
312
322
- if ( this . filter ) {
323
- this . filter . dispose ( ) ;
324
- }
325
313
if ( this . env ) {
326
314
this . env . dispose ( ) ;
327
315
}
0 commit comments