Debian Codegraph @

src/Examples/CsoundQt/Miscellaneous/Noise_Reduction.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 ;-+rtaudio=jack -idac -odac -+jack_client=Csound
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 48000
8 ksmps = 128
9 nchnls = 1
10 0dbfs = 1
11
12 turnon 1
13 fsig2 pvsinit 1024, 256, 1024, 0
14
15 instr 1
16 klearning init 0
17 ifftsize = 1024
18 ioverlap = 256
19 iwinsize = 1024
20 iwintype = 0
21
22 kratio invalue "ratio"
23 kgain invalue "gain"
24 klearn invalue "learn"
25 kbypass invalue "bypass"
26
27 ain inch 1
28
29 if kbypass == 1 then
30 aout = ain
31 else
32 fsig pvsanal ain, ifftsize, ioverlap, iwinsize, iwintype
33 ffilt pvstencil fsig, kratio, kgain, 1
34 aout pvsynth ffilt
35 endif
36
37 out aout
38
39 if klearn == 1 then
40 krms rms ain
41 if krms > 0.00000001 then
42 klearning = klearning + 1
43 kflag pvsftw fsig, 2
44 vaddv 1, 2, 1024
45 endif
46 elseif klearning > 0 then
47 vmult 1, 1/klearning, 1024
48 klearning = 0
49 endif
50
51 outvalue "learning", (klearning == 0 ? 0:1)
52 endin
53
54 instr 2 ;clear mask table
55 gin ftgen 1, 0, 1024, 2, 0
56 turnoff
57 endin
58
59 instr 3 ;mask white noise
60 gin ftgen 1, 0, 1024, -7, 0.006, 1024, 0.006
61 turnoff
62 endin
63
64 </CsInstruments>
65 <CsScore>
66 f 1 0 1024 -7 0.006 1024 0.006
67 f 2 0 1024 2 0 ;temp amp table
68 f 0 3600
69 </CsScore>
70 </CsoundSynthesizer>
71 <bsbPanel>
72 <label>Widgets</label>
73 <objectName/>
74 <x>454</x>
75 <y>149</y>
76 <width>352</width>
77 <height>267</height>
78 <visible>true</visible>
79 <uuid/>
80 <bgcolor mode="background">
81 <r>170</r>
82 <g>170</g>
83 <b>127</b>
84 </bgcolor>
85 <bsbObject version="2" type="BSBVSlider">
86 <objectName>ratio</objectName>
87 <x>5</x>
88 <y>5</y>
89 <width>20</width>
90 <height>200</height>
91 <uuid>{a4c39f46-4d94-4530-af01-0bb3554759ca}</uuid>
92 <visible>true</visible>
93 <midichan>0</midichan>
94 <midicc>-3</midicc>
95 <minimum>0.00000000</minimum>
96 <maximum>1.00000000</maximum>
97 <value>0.00000000</value>
98 <mode>lin</mode>
99 <mouseControl act="jump">continuous</mouseControl>
100 <resolution>-1.00000000</resolution>
101 <randomizable group="0">false</randomizable>
102 </bsbObject>
103 <bsbObject version="2" type="BSBVSlider">
104 <objectName>gain</objectName>
105 <x>45</x>
106 <y>5</y>
107 <width>20</width>
108 <height>200</height>
109 <uuid>{7144b550-cd89-4a26-850d-eabccac898f7}</uuid>
110 <visible>true</visible>
111 <midichan>0</midichan>
112 <midicc>-3</midicc>
113 <minimum>0.00000000</minimum>
114 <maximum>0.10000000</maximum>
115 <value>0.10000000</value>
116 <mode>lin</mode>
117 <mouseControl act="jump">continuous</mouseControl>
118 <resolution>-1.00000000</resolution>
119 <randomizable group="0">false</randomizable>
120 </bsbObject>
121 <bsbObject version="2" type="BSBLabel">
122 <objectName/>
123 <x>1</x>
124 <y>200</y>
125 <width>34</width>
126 <height>23</height>
127 <uuid>{aa008cf6-defc-48c0-b4d7-48d301fa8852}</uuid>
128 <visible>true</visible>
129 <midichan>0</midichan>
130 <midicc>-3</midicc>
131 <label>ratio</label>
132 <alignment>left</alignment>
133 <font>DejaVu Sans</font>
134 <fontsize>10</fontsize>
135 <precision>3</precision>
136 <color>
137 <r>0</r>
138 <g>0</g>
139 <b>0</b>
140 </color>
141 <bgcolor mode="nobackground">
142 <r>255</r>
143 <g>255</g>
144 <b>255</b>
145 </bgcolor>
146 <bordermode>noborder</bordermode>
147 <borderradius>1</borderradius>
148 <borderwidth>1</borderwidth>
149 </bsbObject>
150 <bsbObject version="2" type="BSBLabel">
151 <objectName/>
152 <x>38</x>
153 <y>200</y>
154 <width>39</width>
155 <height>24</height>
156 <uuid>{8a12090d-fad7-476d-8051-e46377cd9e65}</uuid>
157 <visible>true</visible>
158 <midichan>0</midichan>
159 <midicc>-3</midicc>
160 <label>Gain</label>
161 <alignment>left</alignment>
162 <font>DejaVu Sans</font>
163 <fontsize>10</fontsize>
164 <precision>3</precision>
165 <color>
166 <r>0</r>
167 <g>0</g>
168 <b>0</b>
169 </color>
170 <bgcolor mode="nobackground">
171 <r>255</r>
172 <g>255</g>
173 <b>255</b>
174 </bgcolor>
175 <bordermode>noborder</bordermode>
176 <borderradius>1</borderradius>
177 <borderwidth>1</borderwidth>
178 </bsbObject>
179 <bsbObject version="2" type="BSBCheckBox">
180 <objectName>learn</objectName>
181 <x>75</x>
182 <y>180</y>
183 <width>30</width>
184 <height>30</height>
185 <uuid>{1dad9308-a031-4e4e-b182-315c289338f3}</uuid>
186 <visible>true</visible>
187 <midichan>0</midichan>
188 <midicc>-3</midicc>
189 <selected>false</selected>
190 <label/>
191 <pressedValue>1</pressedValue>
192 <randomizable group="0">false</randomizable>
193 </bsbObject>
194 <bsbObject version="2" type="BSBLabel">
195 <objectName/>
196 <x>90</x>
197 <y>183</y>
198 <width>60</width>
199 <height>25</height>
200 <uuid>{d6b0e393-3d46-477f-b320-a353c5984eb0}</uuid>
201 <visible>true</visible>
202 <midichan>0</midichan>
203 <midicc>-3</midicc>
204 <label>Learn</label>
205 <alignment>left</alignment>
206 <font>DejaVu Sans</font>
207 <fontsize>10</fontsize>
208 <precision>3</precision>
209 <color>
210 <r>147</r>
211 <g>52</g>
212 <b>14</b>
213 </color>
214 <bgcolor mode="nobackground">
215 <r>255</r>
216 <g>255</g>
217 <b>255</b>
218 </bgcolor>
219 <bordermode>noborder</bordermode>
220 <borderradius>1</borderradius>
221 <borderwidth>1</borderwidth>
222 </bsbObject>
223 <bsbObject version="2" type="BSBButton">
224 <objectName>button1</objectName>
225 <x>75</x>
226 <y>158</y>
227 <width>100</width>
228 <height>25</height>
229 <uuid>{6adaeefc-4f17-486a-9bff-61607dbf5ea8}</uuid>
230 <visible>true</visible>
231 <midichan>0</midichan>
232 <midicc>-3</midicc>
233 <type>event</type>
234 <pressedValue>1.00000000</pressedValue>
235 <stringvalue/>
236 <text>Clear mask</text>
237 <image>/</image>
238 <eventLine>i2 0 1</eventLine>
239 <latch>false</latch>
240 <latched>false</latched>
241 </bsbObject>
242 <bsbObject version="2" type="BSBCheckBox">
243 <objectName/>
244 <x>75</x>
245 <y>130</y>
246 <width>30</width>
247 <height>30</height>
248 <uuid>{ef9646a0-ea0e-4bda-a05d-4d8c5748f646}</uuid>
249 <visible>true</visible>
250 <midichan>0</midichan>
251 <midicc>-3</midicc>
252 <selected>false</selected>
253 <label/>
254 <pressedValue>1</pressedValue>
255 <randomizable group="0">false</randomizable>
256 </bsbObject>
257 <bsbObject version="2" type="BSBLabel">
258 <objectName/>
259 <x>90</x>
260 <y>135</y>
261 <width>80</width>
262 <height>25</height>
263 <uuid>{b87655c4-4638-45ba-9b03-453c1448e630}</uuid>
264 <visible>true</visible>
265 <midichan>0</midichan>
266 <midicc>-3</midicc>
267 <label>Bypass</label>
268 <alignment>left</alignment>
269 <font>DejaVu Sans</font>
270 <fontsize>10</fontsize>
271 <precision>3</precision>
272 <color>
273 <r>0</r>
274 <g>0</g>
275 <b>0</b>
276 </color>
277 <bgcolor mode="nobackground">
278 <r>255</r>
279 <g>255</g>
280 <b>255</b>
281 </bgcolor>
282 <bordermode>noborder</bordermode>
283 <borderradius>1</borderradius>
284 <borderwidth>1</borderwidth>
285 </bsbObject>
286 <bsbObject version="2" type="BSBLabel">
287 <objectName/>
288 <x>75</x>
289 <y>5</y>
290 <width>160</width>
291 <height>125</height>
292 <uuid>{e5158635-d1f0-4070-b7bd-e8f413701a70}</uuid>
293 <visible>true</visible>
294 <midichan>0</midichan>
295 <midicc>-3</midicc>
296 <label>This noise reduction unit can sample a noise print and then remove it through spectral masking. First clear the mask then activate the learn while the noise is playing. Deactivate the learn button and the noise will be removed.</label>
297 <alignment>left</alignment>
298 <font>Helvetica</font>
299 <fontsize>10</fontsize>
300 <precision>3</precision>
301 <color>
302 <r>127</r>
303 <g>112</g>
304 <b>94</b>
305 </color>
306 <bgcolor mode="background">
307 <r>194</r>
308 <g>194</g>
309 <b>194</b>
310 </bgcolor>
311 <bordermode>border</bordermode>
312 <borderradius>4</borderradius>
313 <borderwidth>1</borderwidth>
314 </bsbObject>
315 <bsbObject version="2" type="BSBCheckBox">
316 <objectName>learning</objectName>
317 <x>236</x>
318 <y>191</y>
319 <width>30</width>
320 <height>30</height>
321 <uuid>{2d1b5c28-1a8c-447a-8d3b-a8ab34394597}</uuid>
322 <visible>true</visible>
323 <midichan>0</midichan>
324 <midicc>-3</midicc>
325 <selected>false</selected>
326 <label/>
327 <pressedValue>1</pressedValue>
328 <randomizable group="0">false</randomizable>
329 </bsbObject>
330 <bsbObject version="2" type="BSBButton">
331 <objectName>white</objectName>
332 <x>190</x>
333 <y>158</y>
334 <width>132</width>
335 <height>25</height>
336 <uuid>{b5c9f013-75ca-4caa-8b31-c7fbb0bb01b9}</uuid>
337 <visible>true</visible>
338 <midichan>0</midichan>
339 <midicc>-3</midicc>
340 <type>event</type>
341 <pressedValue>1.00000000</pressedValue>
342 <stringvalue/>
343 <text>Mask white noise</text>
344 <image>/</image>
345 <eventLine>i3 0 1</eventLine>
346 <latch>false</latch>
347 <latched>false</latched>
348 </bsbObject>
349 </bsbPanel>
350 <bsbPresets>
351 </bsbPresets>
352 <MacOptions>
353 Version: 3
354 Render: Real
355 Ask: Yes
356 Functions: ioObject
357 Listing: Window
358 WindowBounds: 454 149 352 267
359 CurrentView: io
360 IOViewEdit: On
361 Options: -b128 -A -s -m167 -R
362 </MacOptions>
363 <MacGUI>
364 ioView background {43690, 43690, 32639}
365 ioSlider {5, 5} {20, 200} 0.000000 1.000000 0.000000 ratio
366 ioSlider {45, 5} {20, 200} 0.000000 0.100000 0.100000 gain
367 ioText {1, 200} {34, 23} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {0, 0, 0} {65280, 65280, 65280} nobackground noborder ratio
368 ioText {38, 200} {33, 25} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {0, 0, 0} {65280, 65280, 65280} nobackground noborder Gain
369 ioCheckbox {75, 180} {30, 30} off learn
370 ioText {90, 183} {60, 25} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {37632, 13312, 3584} {65280, 65280, 65280} nobackground noborder Learn
371 ioButton {75, 158} {100, 25} event 1.000000 "button1" "Clear mask" "/" i2 0 1
372 ioCheckbox {75, 130} {30, 30} off
373 ioText {90, 135} {80, 25} label 0.000000 0.00100 "" left "DejaVu Sans" 10 {0, 0, 0} {65280, 65280, 65280} nobackground noborder Bypass
374 ioText {75, 5} {160, 125} label 0.000000 0.00100 "" left "Helvetica" 10 {32512, 28672, 24064} {49664, 49664, 49664} nobackground noborder This noise reduction unit can sample a noise print and then remove it through spectral masking. First clear the mask then activate the learn while the noise is playing. Deactivate the learn button and the noise will be removed.
375 ioCheckbox {236, 191} {30, 30} off learning
376 ioButton {190, 158} {132, 25} event 1.000000 "white" "Mask white noise" "/" i3 0 1
377 </MacGUI>