74
74
var writeCount = 0 ;
75
75
76
76
var signal = new Float32Array ( 2048 ) ;
77
- var response = [ 0 ] ;
77
+ var freqz = [ 0 ] ;
78
78
79
79
var grapheq ;
80
80
112
112
113
113
var changeBandGain = function ( event , ui ) {
114
114
grapheq . setBandGain ( ui . handle . parentNode . id . split ( "_" ) [ 1 ] , ui . value ) ;
115
+ plotCoeffs ( ) ;
115
116
}
116
117
117
- function getMethods ( obj , short ) {
118
- var result = [ ] ;
119
- for ( var id in obj ) {
120
- try {
121
- if ( short ) {
122
- result . push ( id + ": " + typeof ( obj [ id ] ) ) ;
123
- } else {
124
- result . push ( id + ": " + obj [ id ] . toString ( ) ) ;
125
- }
126
- } catch ( err ) {
127
- result . push ( id + ": inaccessible" ) ;
128
- }
129
- }
130
- return result ;
131
- }
132
-
133
-
134
118
var plotCoeffs = function ( ) {
135
119
freqz = new Float32Array ( grapheq . freqzs [ 0 ] . length ) ;
136
120
155
139
156
140
< script type ="application/processing " target ="#signal ">
157
141
// Draw axes
158
- float yMin = - 12 ;
159
- float yMax = 3 ;
142
+ float yMin = - 60 ;
143
+ float yMax = 12 ;
160
144
float yCenter = 0 ;
161
145
162
146
float xMin = 0 ;
163
147
float xMax = PI ;
164
148
float xCenter = 0 ;
165
149
166
150
void setup ( ) {
167
- size ( 300 , 200 ) ;
151
+ size ( 700 , 200 ) ;
168
152
grapheq = new GraphicalEq ( sampleRate ) ;
169
153
grapheq . recalculateFilters ( ) ;
170
154
plotCoeffs ( ) ;
177
161
178
162
void draw ( ) {
179
163
background ( 255 ) ;
180
-
164
+
165
+ noFill ( ) ;
166
+ stroke ( 127 ) ;
167
+ rect ( 0 , 0 , width , height ) ;
168
+
181
169
stroke ( 0 ) ;
182
170
line ( map ( xCenter , xMin , xMax , 0 , width ) , map ( yMin , yMin , yMax , height , 0 ) , map ( xCenter , xMin , xMax , 0 , width ) , map ( yMax , yMin , yMax , height , 0 ) ) ;
183
171
line ( map ( xMin , xMin , xMax , 0 , width ) , map ( yCenter , yMin , yMax , height , 0 ) , map ( xMax , xMin , xMax , 0 , width ) , map ( yCenter , yMin , yMax , height , 0 ) ) ;
186
174
noFill ( ) ;
187
175
stroke ( 10 , 40 , 200 ) ;
188
176
beginShape ( ) ;
189
- for ( int i = 0 ; i < response . length ; i ++ ) {
190
- vertex ( map ( i , 0 , response . length , 0 , width ) , map ( response [ i ] , yMin , yMax , height , 0 ) ) ;
177
+ for ( int i = 0 ; i < freqz . length ; i ++ ) {
178
+ vertex ( map ( i , 0 , freqz . length , 0 , width ) , map ( freqz [ i ] , yMin , yMax , height , 0 ) ) ;
191
179
}
192
180
endShape ( ) ;
193
181
}
194
182
195
- void mousePressed ( ) {
196
- int ind = ( int ) map ( mouseX , 0 , width , 0 , grapheq . filters . length - 1 ) ;
197
- float gain = map ( mouseY , 0 , height , yMax , yMin ) ;
198
- grapheq . setBandGain ( ind , gain ) ;
199
- plotCoeffs ( ) ;
200
- }
201
183
</ script >
202
184
203
185
< h1 > Graphical Equalizer</ h1 >
204
186
< h3 > by < a href ="http://www.ricardmarxer.com/blog "> Ricard Marxer</ a > </ h3 >
205
- < p > Applies a Graphical Equalizer filter to an audio stream. Remember to < b > Mute</ b > the audio to hear the pure filtered sound.</ p >
206
- < p > The filter implementation will become part of the < a href ="https://wiki.mozilla.org/Audio_Data_API_JS_Library "> dsp.js</ a > library.</ p >
207
187
< p > You will need a recent build of Mozilla Firefox with the Audio API to hear the filtered version.</ p >
208
-
209
- < audio id ='input ' tabindex ="0 " src ="audio/corban-peddle.ogg " controls ="true " onaudiowritten ="audioWritten(event); " style ="width: 100%; "> </ audio > < br >
210
-
188
+ < audio id ='input ' style ="float: left; height:70px; width: 100% " tabindex ="0 " src ="audio/corban-peddle.ogg " controls ="true " onaudiowritten ="audioWritten(event); "> </ audio > </ br >
189
+ < p > </ br > </ br > </ p >
211
190
< div style ="width: 100%; ">
212
191
< div > < canvas id ="signal " width ="50% " height ="200px " style ="float: left; "> </ canvas > </ div >
213
192
214
- < div class ="control " style ="float: right; height: 188px ">
193
+ < div class ="control " style ="float: right; height: 200px ">
215
194
< h3 > Graphical Equalizer</ h3 >
216
195
< table >
217
196
< tr >
@@ -223,7 +202,9 @@ <h3>Graphical Equalizer</h3>
223
202
</ div >
224
203
</ div >
225
204
226
- < div class ="control " style ="width: 100%; float: left; ">
205
+ < p > </ br > </ br > </ br > </ p >
206
+
207
+ < div class ="control " style ="width: 100%; float: left; ">
227
208
< table >
228
209
< tr id ="bandSliders ">
229
210
</ tr >
0 commit comments