├── #README.md#
├── ICA.m
├── README.md
├── a43.wav
├── allpass.m
├── audioeffector43.fig
├── audioeffector43.m
├── b43.wav
├── c43.wav
├── compensated_grandpiano.wav
├── compensated_hc.wav
├── compensating.m
├── d43.wav
├── denoising_hc.wav
├── denosing.m
├── e43.wav
├── equalized_grandpiano.wav
├── equalizer.m
├── grandpiano.wav
├── grd.bmp
├── mnpresponse.bmp
├── separate.m
└── testICA.m
/#README.md#:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello everyone.
4 | audioeffector43.project is a course project
5 | of digital signal processing(short by DSP).
6 | Our team decided to creat a audio effector
7 | which is able to do something about noise
8 | reduction, speech-speech/speech-music
9 | separation and music equalizer.
10 | ----------
11 | Environment
12 | Archlinux/Matlab/Octave(for test)
13 |
14 |
Oct 19.
15 |
Done:
16 |
denoising (a43.wav)
17 |
separating (b32.wav c32.wav)(using Fast ICA)
18 |
19 |
--------------------------------------------------------------------------------
/ICA.m:
--------------------------------------------------------------------------------
1 | function [W,S] = ICA(X,C)
2 | %----------centering
3 | [N,M] = size(X); %to get the number of rows(signals) and columns(samples) of X
4 | average= mean(X')'; %to get the average value of each rows(X has been transposed)
5 | for i=1:N
6 | X(i,:)=X(i,:)-average(i)*ones(1,M);
7 | end
8 | %---------whitening
9 | Cx = cov(X',1); %to calculate the cov of X
10 | [eigvector,eigvalue] = eig(Cx); %to get the eigenvector and eigenvalue of Cx
11 | Whit = eigvector*eigvalue^(-1/2)*eigvector';
12 | X = Whit*X; %orthogonal matrix
13 | %----------components extraction
14 | syms u;
15 | Maxcount=1e4;
16 | Critical=1e-4.*ones(N,1); %the value of convergement
17 | W = rand(N,C); %initialize the un-mixing mitrix
18 | ONE = ones(M,1);
19 | f(u) = -exp(-u^2/2); %general purposes nonquadratic nonlinearity
20 | g(u) = u*exp(-u^2/2);
21 | h(u) = (1-u^2)*exp(-u^2/2);
22 | for p = 1:C
23 | Prev = W(:,p)+1;
24 | count = 0;
25 | while abs(W(:,p)-Prev) > Critical
26 | count = count+1;
27 | Prev = W(:,p);
28 | W(:,p) = (1/M).*(X*g(W(:,p)'*X)')-(1/M).*(h(W(:,p)'*X))*ONE*W(:,p);
29 | Wj = zeros(N,1);
30 | for j = 1:p-1
31 | Wj = Wj+W(:,p)'*W(:,j)*W(:,j);
32 | end
33 | W(:,p) = W(:,p)-Wj;
34 | W(:,p) = W(:,p)/norm(W(:,p));
35 | if count >= Maxcount
36 | fprintf('No useful components was found.');
37 | return;
38 | end
39 | end
40 | end
41 | S = W'*X;
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello everyone.
4 | audioeffector43.project is a course project
5 | of digital signal processing(short by DSP).
6 | Our team decided to creat an audio effector
7 | which is able to do something about noise
8 | reduction, speech-speech/speech-music
9 | separation and music equalizer.
10 | ----------
11 | Environment
12 | Archlinux/Matlab/Octave(for test)
13 |
14 |
Oct 19.
15 |
Done:
16 |
denoising (a43.wav)
17 |
separating (b43.wav c43.wav)(using Fast ICA)
18 |
19 |
--------------------------------------------------------------------------------
/a43.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/a43.wav
--------------------------------------------------------------------------------
/allpass.m:
--------------------------------------------------------------------------------
1 | %% april 17, 2017. shanghai university. mattma9209@gmail.com
2 | function [sigout,objout] = allpass(sigin,objin)
3 | [wav,fs] = audioread(sigin);
4 | g = grpdelay(objin,'whole');
5 | g1 = max(g) - g;
6 | Spec = fdesign.arbgrpdelay('N,B,F,Gd',8,objin.NumEQBands,wncomp,g1);
7 | objout = design(Spec,'iirlpnorm','SystemObject', ...
8 | true);
9 | sigmid = objin(sigin);
10 | sigout = objout(sigmid);
11 | audiowrite(['compensated_',sigin],sigout,fs);
12 | denoisingfilename = ['denoising_',in];
13 |
--------------------------------------------------------------------------------
/audioeffector43.fig:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/audioeffector43.fig
--------------------------------------------------------------------------------
/audioeffector43.m:
--------------------------------------------------------------------------------
1 | function varargout = audioeffector43(varargin)
2 | % AUDIOEFFECTOR43 MATLAB code for audioeffector43.fig
3 | % AUDIOEFFECTOR43, by itself, creates a new AUDIOEFFECTOR43 or raises the existing
4 | % singleton*.
5 | %
6 | % H = AUDIOEFFECTOR43 returns the handle to a new AUDIOEFFECTOR43 or the handle to
7 | % the existing singleton*.
8 | %
9 | % AUDIOEFFECTOR43('CALLBACK',hObject,eventData,handles,...) calls the local
10 | % function named CALLBACK in AUDIOEFFECTOR43.M with the given input arguments.
11 | %
12 | % AUDIOEFFECTOR43('Property','Value',...) creates a new AUDIOEFFECTOR43 or raises the
13 | % existing singleton*. Starting from the left, property value pairs are
14 | % applied to the GUI before audioeffector43_OpeningFcn gets called. An
15 | % unrecognized property name or invalid value makes property application
16 | % stop. All inputs are passed to audioeffector43_OpeningFcn via varargin.
17 | %
18 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
19 | % instance to run (singleton)".
20 | %
21 | % See also: GUIDE, GUIDATA, GUIHANDLES
22 |
23 | % Edit the above text to modify the response to help audioeffector43
24 |
25 | % Last Modified by GUIDE v2.5 18-Apr-2017 19:31:57
26 |
27 | % Begin initialization code - DO NOT EDIT
28 | gui_Singleton = 1;
29 | gui_State = struct('gui_Name', mfilename, ...
30 | 'gui_Singleton', gui_Singleton, ...
31 | 'gui_OpeningFcn', @audioeffector43_OpeningFcn, ...
32 | 'gui_OutputFcn', @audioeffector43_OutputFcn, ...
33 | 'gui_LayoutFcn', [] , ...
34 | 'gui_Callback', []);
35 | if nargin && ischar(varargin{1})
36 | gui_State.gui_Callback = str2func(varargin{1});
37 | end
38 |
39 | if nargout
40 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
41 | else
42 | gui_mainfcn(gui_State, varargin{:});
43 | end
44 | % End initialization code - DO NOT EDIT
45 |
46 | % --- Executes just before audioeffector43 is made visible.
47 | function audioeffector43_OpeningFcn(hObject, eventdata, handles, varargin)
48 | % This function has no output args, see OutputFcn.
49 | % hObject handle to figure
50 | % eventdata reserved - to be defined in a future version of MATLAB
51 | % handles structure with handles and user data (see GUIDATA)
52 | % varargin command line arguments to audioeffector43 (see VARARGIN)
53 | % $$$ handles.mPEQ = multibandParametricEQ(...
54 | % $$$ 'NumEQBands',10,...
55 | % $$$ 'Frequencies', [31,63,127,255,511,1023,2047,4095,8191,16383],...
56 | % $$$ 'QualityFactors',[1,1,1,1,1,1,1,1,1,1],...
57 | % $$$ 'PeakGains',[0,0,0,0,0,0,0,0,0,0],...
58 | % $$$ 'HasHighShelfFilter',true,...
59 | % $$$ 'HighShelfCutoff',14000,...
60 | % $$$ 'HighShelfSlope',0.3,...
61 | % $$$ 'HighShelfGain',-5,...
62 | % $$$ 'SampleRate',44100);
63 | % $$$
64 | handles.fs = 44100;
65 | handles.order = 8;
66 | handles.orders = 2*ones(1,10);
67 | handles.frequencies = [31,63,127,255,511,1023,2047,4095,8191, ...
68 | 16383];
69 | handles.qualityfactors = 1.5*ones(1,10);
70 | handles.gains = zeros(1,10); % by default
71 | handles.bandwidth = handles.frequencies ./ handles.qualityfactors;
72 | handles.mPEQ = dsp.BiquadFilter(...
73 | 'SOSMatrixSource','Input port',...
74 | 'ScaleValuesInputPort',false);
75 | [handles.b,handles.a] = designParamEQ(handles.orders, ...
76 | handles.gains,handles.frequencies,handles.bandwidth);
77 | handles.orisos = [handles.b',[ones(sum(handles.orders)/2,1),handles.a']];
78 | guidata(hObject, handles);
79 | % there has a problem about fit the 'visualize' to a plot in gui.
80 | %
81 | % Choose default command line output for audioeffector43
82 | handles.output = hObject;
83 |
84 | % Update handles structure
85 | guidata(hObject, handles);
86 |
87 | % UIWAIT makes audioeffector43 wait for user response (see UIRESUME)
88 | % uiwait(handles.figure1);
89 |
90 | % --- Outputs from this function are returned to the command line.
91 | function varargout = audioeffector43_OutputFcn(hObject, eventdata, handles)
92 | % varargout cell array for returning output args (see VARARGOUT);
93 | % hObject handle to figure
94 | % eventdata reserved - to be defined in a future version of MATLAB
95 | % handles structure with handles and user data (see GUIDATA)
96 |
97 | % Get default command line output from handles structure
98 | varargout{1} = handles.output;
99 |
100 | % --- Executes on slider movement.
101 | function s31_Callback(hObject, eventdata, handles)
102 | % hObject handle to s31 (see GCBO)
103 | % eventdata reserved - to be defined in a future version of MATLAB
104 | % handles structure with handles and user data (see GUIDATA)
105 | handles.gains(1) = get(hObject,'Value');
106 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
107 | guidata(hObject,handles);
108 | % Hints: get(hObject,'Value') returns position of slider
109 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
110 |
111 | % --- Executes during object creation, after setting all properties.
112 | function s31_CreateFcn(hObject, eventdata, handles)
113 | % hObject handle to s31 (see GCBO)
114 | % eventdata reserved - to be defined in a future version of MATLAB
115 | % handles empty - handles not created until after all CreateFcns called
116 |
117 | % Hint: slider controls usually have a light gray background.
118 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
119 | set(hObject,'BackgroundColor',[.9 .9 .9]);
120 | end
121 |
122 | % --- Executes on slider movement.
123 | function s63_Callback(hObject, eventdata, handles)
124 | % hObject handle to s63 (see GCBO)
125 | % eventdata reserved - to be defined in a future version of MATLAB
126 | % handles structure with handles and user data (see GUIDATA)
127 | handles.gains(2) = get(hObject,'Value');
128 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
129 | guidata(hObject,handles);
130 | % Hints: get(hObject,'Value') returns position of slider
131 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
132 |
133 | % --- Executes during object creation, after setting all properties.
134 | function s63_CreateFcn(hObject, eventdata, handles)
135 | % hObject handle to s63 (see GCBO)
136 | % eventdata reserved - to be defined in a future version of MATLAB
137 | % handles empty - handles not created until after all CreateFcns called
138 |
139 | % Hint: slider controls usually have a light gray background.
140 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
141 | set(hObject,'BackgroundColor',[.9 .9 .9]);
142 | end
143 |
144 | % --- Executes on slider movement.
145 | function s127_Callback(hObject, eventdata, handles)
146 | % hObject handle to s127 (see GCBO)
147 | % eventdata reserved - to be defined in a future version of MATLAB
148 | % handles structure with handles and user data (see GUIDATA)
149 | handles.gains(3) = get(hObject,'Value');
150 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
151 | guidata(hObject,handles);
152 | % Hints: get(hObject,'Value') returns position of slider
153 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
154 |
155 | % --- Executes during object creation, after setting all properties.
156 | function s127_CreateFcn(hObject, eventdata, handles)
157 | % hObject handle to s127 (see GCBO)
158 | % eventdata reserved - to be defined in a future version of MATLAB
159 | % handles empty - handles not created until after all CreateFcns called
160 |
161 | % Hint: slider controls usually have a light gray background.
162 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
163 | set(hObject,'BackgroundColor',[.9 .9 .9]);
164 | end
165 |
166 | % --- Executes on slider movement.
167 | function s255_Callback(hObject, eventdata, handles)
168 | % hObject handle to s255 (see GCBO)
169 | % eventdata reserved - to be defined in a future version of MATLAB
170 | % handles structure with handles and user data (see GUIDATA)
171 | handles.gains(4) = get(hObject,'Value');
172 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
173 | guidata(hObject,handles);
174 | % Hints: get(hObject,'Value') returns position of slider
175 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
176 |
177 | % --- Executes during object creation, after setting all properties.
178 | function s255_CreateFcn(hObject, eventdata, handles)
179 | % hObject handle to s255 (see GCBO)
180 | % eventdata reserved - to be defined in a future version of MATLAB
181 | % handles empty - handles not created until after all CreateFcns called
182 |
183 | % Hint: slider controls usually have a light gray background.
184 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
185 | set(hObject,'BackgroundColor',[.9 .9 .9]);
186 | end
187 |
188 | % --- Executes on slider movement.
189 | function s511_Callback(hObject, eventdata, handles)
190 | % hObject handle to s511 (see GCBO)
191 | % eventdata reserved - to be defined in a future version of MATLAB
192 | % handles structure with handles and user data (see GUIDATA)
193 | handles.gains(5) = get(hObject,'Value');
194 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
195 | guidata(hObject,handles);
196 | % Hints: get(hObject,'Value') returns position of slider
197 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
198 |
199 | % --- Executes during object creation, after setting all properties.
200 | function s511_CreateFcn(hObject, eventdata, handles)
201 | % hObject handle to s511 (see GCBO)
202 | % eventdata reserved - to be defined in a future version of MATLAB
203 | % handles empty - handles not created until after all CreateFcns called
204 |
205 | % Hint: slider controls usually have a light gray background.
206 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
207 | set(hObject,'BackgroundColor',[.9 .9 .9]);
208 | end
209 |
210 | % --- Executes on slider movement.
211 | function s1k_Callback(hObject, eventdata, handles)
212 | % hObject handle to s1k (see GCBO)
213 | % eventdata reserved - to be defined in a future version of MATLAB
214 | % handles structure with handles and user data (see GUIDATA)
215 | handles.gains(6) = get(hObject,'Value');
216 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
217 | guidata(hObject,handles);
218 | % Hints: get(hObject,'Value') returns position of slider
219 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
220 |
221 | % --- Executes during object creation, after setting all properties.
222 | function s1k_CreateFcn(hObject, eventdata, handles)
223 | % hObject handle to s1k (see GCBO)
224 | % eventdata reserved - to be defined in a future version of MATLAB
225 | % handles empty - handles not created until after all CreateFcns called
226 |
227 | % Hint: slider controls usually have a light gray background.
228 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
229 | set(hObject,'BackgroundColor',[.9 .9 .9]);
230 | end
231 |
232 | % --- Executes on slider movement.
233 | function s2k_Callback(hObject, eventdata, handles)
234 | % hObject handle to s2k (see GCBO)
235 | % eventdata reserved - to be defined in a future version of MATLAB
236 | % handles structure with handles and user data (see GUIDATA)
237 | handles.gains(7) = get(hObject,'Value');
238 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
239 | guidata(hObject,handles);
240 | % Hints: get(hObject,'Value') returns position of slider
241 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
242 |
243 | % --- Executes during object creation, after setting all properties.
244 | function s2k_CreateFcn(hObject, eventdata, handles)
245 | % hObject handle to s2k (see GCBO)
246 | % eventdata reserved - to be defined in a future version of MATLAB
247 | % handles empty - handles not created until after all CreateFcns called
248 |
249 | % Hint: slider controls usually have a light gray background.
250 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
251 | set(hObject,'BackgroundColor',[.9 .9 .9]);
252 | end
253 |
254 | % --- Executes on slider movement.
255 | function s4k_Callback(hObject, eventdata, handles)
256 | % hObject handle to s4k (see GCBO)
257 | % eventdata reserved - to be defined in a future version of MATLAB
258 | % handles structure with handles and user data (see GUIDATA)
259 | handles.gains(8) = get(hObject,'Value');
260 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
261 | guidata(hObject,handles);
262 | % Hints: get(hObject,'Value') returns position of slider
263 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
264 |
265 | % --- Executes during object creation, after setting all properties.
266 | function s4k_CreateFcn(hObject, eventdata, handles)
267 | % hObject handle to s4k (see GCBO)
268 | % eventdata reserved - to be defined in a future version of MATLAB
269 | % handles empty - handles not created until after all CreateFcns called
270 |
271 | % Hint: slider controls usually have a light gray background.
272 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
273 | set(hObject,'BackgroundColor',[.9 .9 .9]);
274 | end
275 |
276 | % --- Executes on slider movement.
277 | function s8k_Callback(hObject, eventdata, handles)
278 | % hObject handle to s8k (see GCBO)
279 | % eventdata reserved - to be defined in a future version of MATLAB
280 | % handles structure with handles and user data (see GUIDATA)
281 | handles.gains(9) = get(hObject,'Value');
282 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
283 | guidata(hObject,handles);
284 | % Hints: get(hObject,'Value') returns position of slider
285 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
286 |
287 | % --- Executes during object creation, after setting all properties.
288 | function s8k_CreateFcn(hObject, eventdata, handles)
289 | % hObject handle to s8k (see GCBO)
290 | % eventdata reserved - to be defined in a future version of MATLAB
291 | % handles empty - handles not created until after all CreateFcns called
292 |
293 | % Hint: slider controls usually have a light gray background.
294 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
295 | set(hObject,'BackgroundColor',[.9 .9 .9]);
296 | end
297 |
298 | % --- Executes on slider movement.
299 | function s16k_Callback(hObject, eventdata, handles)
300 | % hObject handle to s16k (see GCBO)
301 | % eventdata reserved - to be defined in a future version of MATLAB
302 | % handles structure with handles and user data (see GUIDATA)
303 | handles.gains(10) = get(hObject,'Value');
304 | [handles.b,handles.a] = designParamEQ(handles.orders,handles.gains,handles.frequencies,handles.bandwidth);
305 | guidata(hObject,handles);
306 | % Hints: get(hObject,'Value') returns position of slider
307 | % get(hObject,'Min') and get(hObject,'Max') to determine range of slider
308 |
309 | % --- Executes during object creation, after setting all properties.
310 | function s16k_CreateFcn(hObject, eventdata, handles)
311 | % hObject handle to s16k (see GCBO)
312 | % eventdata reserved - to be defined in a future version of MATLAB
313 | % handles empty - handles not created until after all CreateFcns called
314 |
315 | % Hint: slider controls usually have a light gray background.
316 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
317 | set(hObject,'BackgroundColor',[.9 .9 .9]);
318 | end
319 |
320 | % --- Executes on button press in openbutton.
321 | function openbutton_Callback(hObject, eventdata, handles)
322 | % hObject handle to openbutton (see GCBO)
323 | % eventdata reserved - to be defined in a future version of MATLAB
324 | % handles structure with handles and user data (see GUIDATA)
325 | % MATT the ifs below are judging the members in handles struct,
326 | % MATT if them exist, then release for opening a new file.
327 | % if isfield(handles,'fileReader')
328 | % release(handles.fileReader)
329 | % end
330 | % if isfield(handles,'mPEQ')
331 | % release(handles.mPEQ)
332 | % end
333 | % if isfield(handles,'deviceWriter')
334 | % release(handles.deviceWriter)
335 | % end
336 | [filename,pathname]=uigetfile(...
337 | {'*.wav','WAV Files(*.wav)';...
338 | '*.*','All Files(*.*)'}, ...
339 | 'Select a *.wav file');
340 | if isequal(filename,0)||isequal(pathname,0)
341 | return;
342 | else
343 | set(handles.nowplay,'String',filename);
344 | end
345 | [wave,fs] = audioread(filename);
346 | handles.frequencies = handles.frequencies * (2*pi/fs);
347 | handles.bandwidth = handles.bandwidth * (2*pi/fs);
348 | plot(handles.axes2,wave,'k');
349 | set(handles.axes2,'YLim',[-1.0 1.0]);
350 | set(handles.axes2,'XLim',[0.0 length(wave)]);
351 | handles.filename = filename;
352 | handles.fs = fs;
353 | guidata(hObject, handles);
354 |
355 | % --- Executes on button press in generatebutton.
356 | function generatebutton_Callback(hObject, eventdata, handles)
357 | % hObject handle to generatebutton (see GCBO)
358 | % eventdata reserved - to be defined in a future version of MATLAB
359 | % handles structure with handles and user data (see GUIDATA)
360 | val = get(handles.popupmenu1,'Value');
361 | switch val
362 | case 1
363 | return;
364 | case 2
365 | ori = audioread(handles.filename);
366 | equ = dsp.BiquadFilter('SOSMatrix',handles.orisos);
367 | sig = equ(ori,handles.b,handles.a);
368 | audiowrite(['equalized_',handles.filename],sig,handles.fs);
369 | genefilename = ['equalized_',handles.filename];
370 | guidata(hObject,handles);
371 | case 3
372 | handles.orisos = [handles.b',[ones(sum(handles.orders)/2,1),handles.a']];
373 | [genefilename,allpass] = compensating(handles.filename, ...
374 | handles.orisos, ...
375 | handles.order, ...
376 | handles.frequencies);
377 | handles.allpass = allpass;
378 | guidata(hObject,handles);
379 | end
380 |
381 | frameLength = 512;
382 | handles.fileReader = dsp.AudioFileReader(...
383 | 'Filename',genefilename,...
384 | 'SamplesPerFrame',frameLength);
385 | handles.deviceWriter = audioDeviceWriter(...
386 | 'SampleRate',handles.fileReader.SampleRate);
387 | setup(handles.deviceWriter,ones(frameLength,2));
388 | [wave] = audioread(genefilename);
389 | plot(handles.axes3,wave,'k');
390 | set(handles.axes3,'YLim',[-1,1]);
391 | set(handles.axes3,'XLim',[0,length(wave)]);
392 | handles.genefilename = genefilename;
393 | guidata(hObject, handles);
394 |
395 | % --- Executes during object creation, after setting all properties.
396 | function popupmenu1_CreateFcn(hObject, eventdata, handles)
397 | % hObject handle to popupmenu1 (see GCBO)
398 | % eventdata reserved - to be defined in a future version of MATLAB
399 | % handles empty - handles not created until after all CreateFcns called
400 |
401 | % Hint: popupmenu1 controls usually have a white background on Windows.
402 | % See ISPC and COMPUTER.
403 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
404 | set(hObject,'BackgroundColor','white');
405 | end
406 |
407 | % --- Executes on button press in playbutton1.
408 | function playbutton1_Callback(hObject, eventdata, handles)
409 | % hObject handle to playbutton1 (see GCBO)
410 | % eventdata reserved - to be defined in a future version of MATLAB
411 | % handles structure with handles and user data (see GUIDATA)
412 | global flag;
413 | if ~isfield(handles,'filename')
414 | errordlg('Please select an audio file.','Error');
415 | return;
416 | end
417 | nowstate = get(handles.pausebutton1,'String');
418 | if strcmp(nowstate,'Continue')
419 | set(handles.pausebutton1,'String','Pause');
420 | end
421 | if isfield(handles,'fileReader')
422 | release(handles.fileReader)
423 | end
424 | if isfield(handles,'mPEQ')
425 | release(handles.mPEQ)
426 | end
427 | if isfield(handles,'deviceWriter')
428 | release(handles.deviceWriter)
429 | end
430 |
431 | frameLength = 1024;
432 | handles.fileReader = dsp.AudioFileReader(...
433 | 'Filename',handles.filename,...
434 | 'SamplesPerFrame',frameLength);
435 | handles.deviceWriter = audioDeviceWriter(...
436 | 'SampleRate',handles.fileReader.SampleRate);
437 | setup(handles.deviceWriter,ones(frameLength,2));
438 | guidata(hObject, handles);
439 | while ~isDone(handles.fileReader)&&~flag
440 | handles.originalSignal = handles.fileReader();
441 | switch get(handles.eqenable,'Value')
442 | case 1
443 | handles.equalizedSignal = handles.mPEQ(handles.originalSignal,handles.b,handles.a);
444 | handles.deviceWriter(handles.equalizedSignal);
445 | case 0
446 | handles.deviceWriter(handles.originalSignal);
447 | end
448 | pause(2e-2);
449 | end
450 | flag = 0;
451 | % releasing
452 | if isfield(handles,'fileReader')&&isDone(handles.fileReader)
453 | release(handles.fileReader)
454 | end
455 | if isfield(handles,'deviceWriter')&&isDone(handles.fileReader)
456 | release(handles.deviceWriter)
457 | end
458 |
459 | % --- Executes on button press in pausebutton1.
460 | function pausebutton1_Callback(hObject, eventdata, handles)
461 | % hObject handle to pausebutton1 (see GCBO)
462 | % eventdata reserved - to be defined in a future version of MATLAB
463 | % handles structure with handles and user data (see GUIDATA)
464 | nowstate = get(hObject,'String');
465 | if strcmp(nowstate,'Continue')
466 | set(hObject,'String','Pause');
467 | uiresume;
468 | elseif strcmp(nowstate,'Pause')
469 | set(hObject,'String','Continue');
470 | uiwait;
471 | end
472 |
473 | % --- Executes on button press in stopbutton1.
474 | function stopbutton1_Callback(hObject, eventdata, handles)
475 | % hObject handle to stopbutton1 (see GCBO)
476 | % eventdata reserved - to be defined in a future version of MATLAB
477 | % handles structure with handles and user data (see GUIDATA)
478 | % delete(handles.fileReader);
479 | global flag;
480 | flag = 1;
481 | nowstate = get(handles.pausebutton1,'String');
482 | if strcmp(nowstate,'Continue')
483 | set(handles.pausebutton1,'String','Pause');
484 | flag = 0;
485 | end
486 | guidata(hObject, handles);
487 |
488 | % --- Executes on button press in exitbutton.
489 | function exitbutton_Callback(hObject, eventdata, handles)
490 | % hObject handle to exitbutton (see GCBO)
491 | % eventdata reserved - to be defined in a future version of MATLAB
492 | % handles structure with handles and user data (see GUIDATA)
493 | global flag;
494 | flag = 1;
495 | close();
496 |
497 | % --- Executes on button press in playbutton2.
498 | function playbutton2_Callback(hObject, eventdata, handles)
499 | % hObject handle to playbutton2 (see GCBO)
500 | % eventdata reserved - to be defined in a future version of MATLAB
501 | % handles structure with handles and user data (see GUIDATA)
502 | global flag;
503 | nowstate = get(handles.pausebutton2,'String');
504 | if strcmp(nowstate,'Continue')
505 | set(handles.pausebutton2,'String','Pause');
506 | end
507 | if isfield(handles,'fileReader')
508 | release(handles.fileReader)
509 | end
510 | if isfield(handles,'mPEQ')
511 | release(handles.mPEQ)
512 | end
513 | if isfield(handles,'deviceWriter')
514 | release(handles.deviceWriter)
515 | end
516 |
517 | frameLength = 512;
518 | handles.fileReader = dsp.AudioFileReader(...
519 | 'Filename',handles.genefilename,...
520 | 'SamplesPerFrame',frameLength);
521 | handles.deviceWriter = audioDeviceWriter(...
522 | 'SampleRate',handles.fileReader.SampleRate);
523 | setup(handles.deviceWriter,ones(frameLength,2));
524 | guidata(hObject, handles);
525 | while ~isDone(handles.fileReader)&&~flag
526 | handles.originalSignal = handles.fileReader();
527 | handles.deviceWriter(handles.originalSignal);
528 | pause(1e-2);
529 | end
530 | flag = 0;
531 | % releasing
532 | if isfield(handles,'fileReader')&&isDone(handles.fileReader)
533 | release(handles.fileReader)
534 | end
535 | if isfield(handles,'deviceWriter')&&isDone(handles.fileReader)
536 | release(handles.deviceWriter)
537 | end
538 |
539 | % --- Executes on button press in pausebutton2.
540 | function pausebutton2_Callback(hObject, eventdata, handles)
541 | % hObject handle to pausebutton2 (see GCBO)
542 | % eventdata reserved - to be defined in a future version of MATLAB
543 | % handles structure with handles and user data (see GUIDATA)
544 | nowstate = get(hObject,'String');
545 | if strcmp(nowstate,'Continue')
546 | set(hObject,'String','Pause');
547 | uiresume;
548 | elseif strcmp(nowstate,'Pause')
549 | set(hObject,'String','Continue');
550 | uiwait;
551 | end
552 |
553 | % --- Executes on button press in stopbutton2.
554 | function stopbutton2_Callback(hObject, eventdata, handles)
555 | % hObject handle to stopbutton2 (see GCBO)
556 | % eventdata reserved - to be defined in a future version of MATLAB
557 | % handles structure with handles and user data (see GUIDATA)
558 | global flag;
559 | flag = 1;
560 | nowstate = get(handles.pausebutton2,'String');
561 | if strcmp(nowstate,'Continue')
562 | set(handles.pausebutton2,'String','Pause');
563 | flag = 0;
564 | end
565 | guidata(hObject, handles);
566 |
567 | % --- Executes on button press in infobutton.
568 | function infobutton_Callback(hObject, eventdata, handles)
569 | % hObject handle to infobutton (see GCBO)
570 | % eventdata reserved - to be defined in a future version of MATLAB
571 | % handles structure with handles and user data (see GUIDATA)
572 |
573 | % --- Executes during object creation, after setting all properties.
574 | function slideruseless_CreateFcn(hObject, eventdata, handles)
575 | % hObject handle to slideruseless (see GCBO)
576 | % eventdata reserved - to be defined in a future version of MATLAB
577 | % handles empty - handles not created until after all CreateFcns called
578 |
579 | % Hint: slider controls usually have a light gray background.
580 | if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
581 | set(hObject,'BackgroundColor',[.9 .9 .9]);
582 | end
583 |
584 | % --- Executes on button press in eqenable.
585 | function eqenable_Callback(hObject, eventdata, handles)
586 | % hObject handle to eqenable (see GCBO)
587 | % eventdata reserved - to be defined in a future version of MATLAB
588 | % handles structure with handles and user data (see GUIDATA)
589 | eqval = get(hObject,'Value');
590 | switch eqval
591 | case 1
592 | set(hObject,'String','EQ ON');
593 | case 0
594 | set(hObject,'String','EQ OFF');
595 | end
596 | % Hint: get(hObject,'Value') returns toggle state of eqenable
597 |
598 | % --- Executes during object creation, after setting all properties.
599 | function stopbutton1_CreateFcn(hObject, eventdata, handles)
600 | % hObject handle to stopbutton1 (see GCBO)
601 | % eventdata reserved - to be defined in a future version of MATLAB
602 | % handles empty - handles not created until after all CreateFcns called
603 | global flag;
604 | flag = 0;
605 |
606 |
607 |
608 | function orderedit_Callback(hObject, eventdata, handles)
609 | % hObject handle to orderedit (see GCBO)
610 | % eventdata reserved - to be defined in a future version of MATLAB
611 | % handles structure with handles and user data (see GUIDATA)
612 |
613 | % Hints: get(hObject,'String') returns contents of orderedit as text
614 | % str2double(get(hObject,'String')) returns contents of orderedit as a double
615 | order = str2num(get(hObject,'String'));
616 | handles.order = order;
617 | guidata(hObject, handles);
618 |
619 | % --- Executes during object creation, after setting all properties.
620 | function orderedit_CreateFcn(hObject, eventdata, handles)
621 | % hObject handle to orderedit (see GCBO)
622 | % eventdata reserved - to be defined in a future version of MATLAB
623 | % handles empty - handles not created until after all CreateFcns called
624 |
625 | % Hint: edit controls usually have a white background on Windows.
626 | % See ISPC and COMPUTER.
627 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
628 | set(hObject,'BackgroundColor','white');
629 | end
630 |
631 |
632 | % --- Executes on button press in fvtoolbutton.
633 | function fvtoolbutton_Callback(hObject, eventdata, handles)
634 | % hObject handle to fvtoolbutton (see GCBO)
635 | % eventdata reserved - to be defined in a future version of MATLAB
636 | % handles structure with handles and user data (see GUIDATA)
637 |
638 | if ~isfield(handles,'allpass')
639 | errordlg('Please generate it first.','Error');
640 | return;
641 | else
642 | fvtool(handles.allpass,...
643 | 'Fs',handles.fs,...
644 | 'FrequencyScale','Log');
645 | guidata(hObject,handles);
646 | end
647 |
648 | % --- Executes on button press in fvtool2button.
649 | function fvtool2button_Callback(hObject, eventdata, handles)
650 | % hObject handle to fvtool2button (see GCBO)
651 | % eventdata reserved - to be defined in a future version of MATLAB
652 | % handles structure with handles and user data (see GUIDATA)
653 | SOS = [handles.b',[ones(sum(handles.orders)/2,1),handles.a']];
654 | fvtool(SOS,...
655 | 'Fs',handles.fs,...
656 | 'FrequencyScale','Log');
657 | handles.orisos = SOS;
658 | guidata(hObject,handles);
659 |
660 |
661 | % --- Executes on button press in save1button.
662 | function save1button_Callback(hObject, eventdata, handles)
663 | % hObject handle to save1button (see GCBO)
664 | % eventdata reserved - to be defined in a future version of MATLAB
665 | % handles structure with handles and user data (see GUIDATA)
666 |
667 |
668 | % --- Executes on button press in save2button.
669 | function save2button_Callback(hObject, eventdata, handles)
670 | % hObject handle to save2button (see GCBO)
671 | % eventdata reserved - to be defined in a future version of MATLAB
672 | % handles structure with handles and user data (see GUIDATA)
673 | B = handles.b;
674 | A = handles.a;
675 | f = handles.frequencies;
676 | g = handles.gains;
677 | b = handles.bandwidth;
678 | uisave({'B','A','f','g','b'},'equalizer');
679 |
680 | % --- Executes during object creation, after setting all properties.
681 | function figure1_CreateFcn(hObject, eventdata, handles)
682 | % hObject handle to figure1 (see GCBO)
683 | % eventdata reserved - to be defined in a future version of MATLAB
684 | % handles empty - handles not created until after all CreateFcns czalled
685 |
686 |
687 | % --- Executes on button press in sumbutton.
688 | function sumbutton_Callback(hObject, eventdata, handles)
689 | % hObject handle to sumbutton (see GCBO)
690 | % eventdata reserved - to be defined in a future version of MATLAB
691 | % handles structure with handles and user data (see GUIDATA)
692 | if ~isfield(handles,'allpass')
693 | errordlg('Please generate a allpass filter first.','Error');
694 | return;
695 | else
696 | p = 0:0.001:1;
697 | [g1,f] = grpdelay(handles.allpass,p,handles.fs);
698 | [g2,f] = grpdelay(handles.orisos,p,handles.fs);
699 | figure(1);
700 | plot(f,g1+g2,'b',f,g1,'k',f,g2,'r');
701 | grid on;
702 | axis([0 1 0 max(cell2mat({g1+g2,g1,g2}))+2]);
703 | end
704 |
--------------------------------------------------------------------------------
/b43.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/b43.wav
--------------------------------------------------------------------------------
/c43.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/c43.wav
--------------------------------------------------------------------------------
/compensated_grandpiano.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/compensated_grandpiano.wav
--------------------------------------------------------------------------------
/compensated_hc.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/compensated_hc.wav
--------------------------------------------------------------------------------
/compensating.m:
--------------------------------------------------------------------------------
1 | %% april 17, 2017. shanghai university. mattma9209@gmail.com
2 | function [filename,sosout] = compensating(filein,sosin,order,freq)
3 |
4 | [sigin,fs] = audioread(filein);
5 |
6 | g = grpdelay(sosin,10001);
7 | g1 = max(g) - g;
8 | f = 0:0.0001:1;
9 | R = 0.99;
10 |
11 | h = fdesign.arbgrpdelay('N,F,Gd',order,f,g1);
12 | comp = design(h,'MaxPoleRadius',R,'SystemObject',true);
13 | sosout = comp;
14 | % $$$ [b,a] = iirgrpdelay(order,f,[0 1],g1');
15 | % $$$ sosout = tf2sos(b,a);
16 | ori = dsp.BiquadFilter('SOSMatrix',sosin);
17 | % $$$ comp = dsp.BiquadFilter('SOSMatrix',sosout);
18 |
19 | sigmid = ori(sigin);
20 | sigout = comp(sigmid);
21 | filename = ['compensated_',filein];
22 | audiowrite(filename,sigout,fs);
23 |
--------------------------------------------------------------------------------
/d43.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/d43.wav
--------------------------------------------------------------------------------
/denoising_hc.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/denoising_hc.wav
--------------------------------------------------------------------------------
/denosing.m:
--------------------------------------------------------------------------------
1 | function denoisingfilename = denosing(in)
2 | [wav,fs] = audioread(in);
3 | wavL = wav(1:length(wav));
4 | wavR = wav(length(wav)+1:2*length(wav));
5 | out = wavL-wavR;
6 | audiowrite(['denoising_',in],out,fs);
7 | denoisingfilename = ['denoising_',in];
8 |
--------------------------------------------------------------------------------
/e43.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/e43.wav
--------------------------------------------------------------------------------
/equalized_grandpiano.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/equalized_grandpiano.wav
--------------------------------------------------------------------------------
/equalizer.m:
--------------------------------------------------------------------------------
1 | a = dsp.AudioFileReader('e43.wav');
2 | mPEQ = multibandParametricEQ(...
3 | 'NumEQBands',10,...
4 | 'Frequencies',[31,63,127,255,511,1000,2000,4000,8000,16000],...
5 | 'QualityFactors',[1,1,1,1,1,1,1,1,1,1],...
6 | 'PeakGains',[0,0,0,0,0,0,0,0,0,0],...
7 | 'HasHighShelfFilter',true,...
8 | 'HighShelfCutoff',14000,...
9 | 'HighShelfSlope',0.3,...
10 | 'HighShelfGain',-5,...
11 | 'SampleRate',44100);
12 | % visualize(mPEQ)
13 | N = getNumOutputs(a);
--------------------------------------------------------------------------------
/grandpiano.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/grandpiano.wav
--------------------------------------------------------------------------------
/grd.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/grd.bmp
--------------------------------------------------------------------------------
/mnpresponse.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/km4sh/audioeffector43/39f2f81c02ca17f610c3c25277e60355798f63b2/mnpresponse.bmp
--------------------------------------------------------------------------------
/separate.m:
--------------------------------------------------------------------------------
1 | [y,Fs] = audioread('e43.wav');
2 | [W,S] = ICA(y',2);
3 | y1 = audioplayer(S(1,:),Fs);
4 | y2 = audioplayer(S(2,:),Fs);
5 | play(y2)
6 | % yL = y(1:length(y));
7 | % yR = y(length(y)+1:2*length(y));
8 | % yd = yL+yR;
9 | % fftyd = fft(yd);
10 | % fftyd2 = abs(fftyd/length(y));
11 | % fftyd1 = fftyd2(1:length(y)/2+1);
12 | % fftyd1(2:end-1) = 2*fftyd1(2:end-1);
13 | % f = Fs*(0:(length(y)/2))/length(y);
14 | % plot(f,fftyd1);
15 |
--------------------------------------------------------------------------------
/testICA.m:
--------------------------------------------------------------------------------
1 |
2 | %以下为主程序,主要为原始信号的产生,观察信号和解混信号的作图
3 | clear all;clc;
4 | N=200;n=1:N; %N为采样点数
5 | s1=2*sin(0.02*pi*n); %正弦信号
6 | t=1:N;s2=2*square(100*t,50); %方波信号
7 | a=linspace(1,-1,25);s3=2*[a,a,a,a,a,a,a,a];%锯齿信号
8 | s4=rand(1,N);%随机噪声
9 | S=[s1;s2;s3;s4];%信号组成4*N
10 | A=rand(4,4);
11 | X=A*S;%观察信号
12 |
13 | %源信号波形图
14 | figure(1);subplot(4,1,1);plot(s1);axis([0 N -5,5]);title('源信号');
15 | subplot(4,1,2);plot(s2);axis([0 N -5,5]);
16 | subplot(4,1,3);plot(s3);axis([0 N -5,5]);
17 | subplot(4,1,4);plot(s4);xlabel('Time/ms');
18 | %观察信号(混合信号)波形图
19 | figure(2);subplot(4,1,1);plot(X(1,:));title('观察信号(混合信号)');
20 | subplot(4,1,2);plot(X(2,:));
21 | subplot(4,1,3);plot(X(3,:));subplot(4,1,4);plot(X(4,:));
22 |
23 | [W,Z]=ICA(X,3);
24 |
25 | figure(3);subplot(4,1,1);plot(Z(1,:));title('解混后的信号');
26 | subplot(4,1,2);plot(Z(2,:));
27 | subplot(4,1,3);plot(Z(3,:));
28 | subplot(4,1,4);plot(Z(4,:));xlabel('Time/ms');
--------------------------------------------------------------------------------