]> git.parisson.com Git - cnaq.git/commitdiff
* Global voice -> channel
authoryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Tue, 8 Apr 2008 16:19:40 +0000 (16:19 +0000)
committeryomguy <yomguy@5fc3e0e6-29bc-4d03-b52b-c088cb822bde>
Tue, 8 Apr 2008 16:19:40 +0000 (16:19 +0000)
* Add analysis spec : type, method, domain

git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@178 5fc3e0e6-29bc-4d03-b52b-c088cb822bde

CNAQ.fig
CNAQ.m
tools/generator.m
tools/get_fs.m
tools/get_nbits.m
tools/get_ri_spec.m
tools/monitor.m
tools/plot_main.m
tools/plot_mes.m
tools/save_mes.m

index d4f963f0bec572c7cd3714afea84a0d6cfc1baa2..45880fbb02095d2cdc400e96f1a47c221c239c73 100644 (file)
Binary files a/CNAQ.fig and b/CNAQ.fig differ
diff --git a/CNAQ.m b/CNAQ.m
index d52b03b704e3978794f79b51dadd1c74c9a791d7..9e30e4159dc20c796873cb148d2bde463d0f86f8 100644 (file)
--- a/CNAQ.m
+++ b/CNAQ.m
@@ -34,7 +34,7 @@ function varargout = CNAQ(varargin)
 \r
 %  Author: Guillaume Pellerin <guillaume.pellerin@cnam.fr>\r
 \r
-% Last Modified by GUIDE v2.5 08-Apr-2008 16:23:22
+% Last Modified by GUIDE v2.5 08-Apr-2008 18:19:43
 \r
 %      CNAQ, by itself, creates a new CNAQ or raises the existing\r
 %      singleton*.\r
@@ -169,7 +169,9 @@ set(handles.sig_type,'String','Sinus|Chirp|White noise|Pink noise');
 set(handles.channels_in,'String','1|1 2|1 2 3|1 2 3 4|1 2 3 4 5 6 7 8');\r
 set(handles.channels_out,'String','1|1 2|1 2 3|1 2 3 4|1 2 3 4 5 6 7 8');\r
 \r
-set(handles.mes_type,'String','Transfert function|Impulse response');\r
+set(handles.analysis_type,'String','Default');\r
+set(handles.analysis_method,'String','Transfert function|Deconvolution');\r
+set(handles.analysis_domain,'String','Frequency|Time');\r
 set(handles.in_on_off,'UserData',device);\r
 set(handles.save_button,'UserData',latency);\r
 \r
@@ -357,9 +359,9 @@ function gen_on_off_Callback(hObject, eventdata, handles)
 % MEASUREMENT\r
 %============================================\r
 \r
-function mes_type_Callback(hObject, eventdata, handles)\r
+function analysis_method_Callback(hObject, eventdata, handles)\r
 \r
-function mes_type_CreateFcn(hObject, eventdata, handles)\r
+function analysis_method_CreateFcn(hObject, eventdata, handles)\r
     if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))\r
         set(hObject,'BackgroundColor','white');\r
     end\r
@@ -421,3 +423,51 @@ function load_Callback(hObject, eventdata, handless)
 %      set(handles.time_value,'String',num2str(time));\r
 \r
 \r
+
+
+% --- Executes on selection change in analysis_type.
+function analysis_type_Callback(hObject, eventdata, handles)
+% hObject    handle to analysis_type (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: contents = get(hObject,'String') returns analysis_type contents as cell array
+%        contents{get(hObject,'Value')} returns selected item from analysis_type
+
+
+% --- Executes during object creation, after setting all properties.
+function analysis_type_CreateFcn(hObject, eventdata, handles)
+% hObject    handle to analysis_type (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    empty - handles not created until after all CreateFcns called
+
+% Hint: popupmenu controls usually have a white background on Windows.
+%       See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+    set(hObject,'BackgroundColor','white');
+end
+
+
+% --- Executes on selection change in analysis_domain.
+function analysis_domain_Callback(hObject, eventdata, handles)
+% hObject    handle to analysis_domain (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    structure with handles and user data (see GUIDATA)
+
+% Hints: contents = get(hObject,'String') returns analysis_domain contents as cell array
+%        contents{get(hObject,'Value')} returns selected item from analysis_domain
+
+
+% --- Executes during object creation, after setting all properties.
+function analysis_domain_CreateFcn(hObject, eventdata, handles)
+% hObject    handle to analysis_domain (see GCBO)
+% eventdata  reserved - to be defined in a future version of MATLAB
+% handles    empty - handles not created until after all CreateFcns called
+
+% Hint: popupmenu controls usually have a white background on Windows.
+%       See ISPC and COMPUTER.
+if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
+    set(hObject,'BackgroundColor','white');
+end
+
+
index f2165a3294dece81e82fd2876b4acbef511c942e..af3801b9d79b531d08c09e79dcaa129518b80890 100644 (file)
@@ -9,9 +9,8 @@ function generator(handles)
     f_s = get_fs(fs_id);
     nbits = get_nbits(nb_id);
     time = get(handles.time_gen,'Value');
-    voices_out = get_voices_out(handles);
-    %voice_first = voices_out(1);
-    %voice_last = voices_out(length(voices_out));
+    ch_out_id = get(handles.channels_out,'Value');
+    channels_out = get_channels_in(ch_out_id);
     gain_out = get(handles.gain_out,'Value');
     gain_out = 10^(gain_out/20);
     t = [0:1/f_s:time];
@@ -32,13 +31,13 @@ function generator(handles)
     end
   
     sig_out = [];
-    for i=1:length(voices_out)
+    for i=1:length(channels_out)
         sig_out(:,i) = sig';
     end
 
     % Matlab way (needs Data Acquisition Toolbox)
 %      ao = analogoutput('winsound', 0);
-%      addchannel(ao, voices_out);
+%      addchannel(ao, channels_out);
 %      set(ao, 'StandardSampleRates', 'Off');
 %      set(ao, 'SampleRate', f_s);
 %      
index 41815d4a117ccf71681e8b249c0d38f0cf22a316..e8be091a3fa184dba3f0c518de2327111ec4ad2c 100644 (file)
@@ -1,14 +1,14 @@
-function f_s = get_fs(fs_ind)
+function f_s = get_fs(fs_id)
 
-    if fs_ind == 1
+    if fs_id == 1
         f_s = 44100;
-    elseif fs_ind == 2
+    elseif fs_id == 2
         f_s = 48000;
-    elseif fs_ind == 3
+    elseif fs_id == 3
         f_s = 88200;
-    elseif fs_ind == 4
+    elseif fs_id == 4
         f_s = 96000;
-    elseif fs_ind == 5
+    elseif fs_id == 5
         f_s = 192000;
     end
 
index 8fae0f80710dc0170a5eca0bf3284b78a6b7b25c..2b839432b4acfcbf84a18dbd79d07e944e8dd88e 100644 (file)
@@ -1,8 +1,8 @@
-function nbits = get_nbits(nb_ind)
+function nbits = get_nbits(nb_id)
 
-    if nb_ind == 1
+    if nb_id == 1
         nbits = 16;
-    elseif nb_ind == 2
+    elseif nb_id == 2
         nbits = 24;
     end
 
index 21efd8ac8953dee0faa4293bd2aae502331cabb3..eff6c738d6ceb6f4a2ed8f9d5543dc1b34a94705 100644 (file)
@@ -1,10 +1,10 @@
-function [ri, spec] = get_spec_ri(f, sig_exc, sig_mes, f_s, mes_type)
+function [ri, spec] = get_spec_ri(f, sig_exc, sig_mes, f_s, method)
 % Return the impulse response and the spectrum compute with the given method
     
-    if mes_type == 1
+    if method == 1
         % Frequency method
         [ri, spec] = fonc_trans(f, sig_exc, sig_mes, f_s);
-    elseif mes_type == 2
+    elseif method == 2
         % Temporal method
         [ri, spec] = RI_FT(f, sig_exc, sig_mes, f_s);
     end
index 0160c59d9be0c27176de26a286f5ed1a103ef838..e19cee691ee63cd06506a0935e8d9ed803ac01fc 100644 (file)
@@ -13,14 +13,15 @@ function monitor(handles)
     freq = 2*(f_max-f_min)/buffer;
     f = [0:f_s/buffer:f_s/2];
     f = f(1:length(f)-1);
-    voices_in = get_voices_in(handles);
-    voice_first = voices_in(1);
-    voice_last =  voices_in(length(voices_in));
+    ch_in_id = get(handles.channels_in,'Value');
+    channels_in = get_channels_in(ch_in_id);
+    channel_first = channels_in(1);
+    channel_last =  channels_in(length(channels_in));
         
     while get(handles.in_on_off,'Value') == 1
         % TIME_GEN
         %sig_in = wavrecord(buffer,f_s,2);
-        sig_in = pa_wavrecord(voice_first, voice_last, buffer, f_s, device, 'asio');
+        sig_in = pa_wavrecord(channel_first, channel_last, buffer, f_s, device, 'asio');
         sig_in = sig_in(:,1);
         axes(handles.plot_in_temp);
         cla;
index 38b3d4342e03490e2ce60cbe0cfc050790a557ab..5350094e8d0068ce85313c3006e155773b8a33cb 100644 (file)
@@ -18,23 +18,25 @@ function plot_main(handles)
     username = get(handles.username,'String');
     comment = get(handles.comment,'String');
     id = get(handles.ID,'String');
-    mes_type = get(handles.mes_type,'Value');
-            
+    type = get(handles.analysis_type,'Value');
+    method = get(handles.analysis_method,'Value');
+    domain = get(handles.analysis_domain,'Value');
+         
     % Compute excitation spectrum    
-    [rep_imp_exc, spec_exc] = get_ri_spec(f, sig_exc, sig_exc, f_s, mes_type);
+    [rep_imp_exc, spec_exc] = get_ri_spec(f, sig_exc, sig_exc, f_s, method);
     len_spec_exc = length(spec_exc);
     spec_exc = spec_exc(1:len_spec_exc/2);
     
     % Compute all Ris and specs
     for i=1:n_col_sig_mes
-        voice = num2str(i);
-        [rep_imp_mes, spec_mes] = get_ri_spec(f, sig_exc, sig_mes(:,i), f_s, mes_type);
+        channel = num2str(i);
+        [rep_imp_mes, spec_mes] = get_ri_spec(f, sig_exc, sig_mes(:,i), f_s, method);
         len_spec_mes = length(spec_mes);    
         spec_mes = spec_mes(1:len_spec_mes/2);
         % Plot results
         f_lin = [0:f_s/len_spec_mes:f_s/2];
         f_lin = f_lin(1:length(f_lin)-1);
-        plot_mes(t, f_lin, f_s, f_min, f_max, sig_exc, sig_mes(:,i), rep_imp_mes, spec_mes, spec_exc, id, voice, username, comment, i);
+        plot_mes(t, f_lin, f_s, f_min, f_max, sig_exc, sig_mes(:,i), rep_imp_mes, spec_mes, spec_exc, id, channel, username, comment, i, domain);
     end
 
     set(handles.close_button,'UserData',f_lin');
index 06d3ce2cc1c2aa627a528335ec0ff73ce6bd41f7..77e2e7a34f5c94c7485365181d9d709fbb0c5d33 100644 (file)
@@ -1,57 +1,62 @@
-function plot_mes(t, f, f_s, f_min, f_max, sig_exc, sig_mes, rep_imp_mes, spec_mes, spec_exc, id, channel, group, comment, i);\r
+function plot_mes(t, f, f_s, f_min, f_max, sig_exc, sig_mes, rep_imp_mes, spec_mes, spec_exc, id, channel, group, comment, i, domain);\r
 \r
 len_spec_mes = length(spec_mes);\r
 %spec = spec(1:len_spec);\r
 \r
-% Time\r
-figure;\r
-subplot(2,1,1);\r
-plot(t, sig_mes);\r
-%semilogx(t, sig_mes);\r
-axis([0 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]);\r
-%axis([1 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]);\r
-xlabel('Time (s)');\r
-ylabel('Amplitude');\r
-title(['Measured temporal signal (group: ' group ', id: ' id ', channel : ' channel ')']);\r
-grid on;\r
-\r
-subplot(2,1,2);\r
-len_ri = length(rep_imp_mes);\r
-t_ri = [(-len_ri)/(2*f_s):1/f_s:(len_ri)/(2*f_s)];\r
-%t_ri = [0:1/f_s:len_ri/f_s];\r
-t_ri = t_ri(1:length(t_ri)-1);\r
-plot(t_ri,rep_imp_mes);\r
-axis([-t_ri(len_ri) t_ri(len_ri) min(rep_imp_mes)-0.01 max(rep_imp_mes)+0.01]);\r
-xlabel('Time (s)');\r
-ylabel('Amplitude');\r
-title(['Measured impulse response (group: ' group ', id: ' id ', channel : ' channel ')']);\r
-grid on;\r
-\r
-\r
-% Freq\r
-f_max_list = find(f > f_max);\r
-f_max_ind = f_max_list(1);\r
-f_min_list = find(f < f_min);\r
-f_min_ind = f_min_list(length(f_min_list));\r
-\r
-figure;\r
-subplot(2,1,1);\r
-spec_mes_log = 10*log10(abs(spec_mes));\r
-semilogx(f, spec_mes_log);\r
-axis([f_min f_max min(spec_mes_log(f_min_ind:f_max_ind-1000))-6 max(spec_mes_log(f_min_ind:f_max_ind))+6]);\r
-xlabel('Frequency (Hz)');\r
-ylabel('Amplitude (dB)');\r
-title(['Modulus of the transfert function (group: ' group ', id: ' id ', channel : ' channel ')']);\r
-grid on;\r
-\r
-subplot(2,1,2);\r
-angle_exc = angle(spec_exc);\r
-angle_mes = angle(spec_mes);\r
-ang = unwrap(angle_mes - angle_exc) + 2*pi;\r
-semilogx(f, ang);\r
-axis([f_min f_max min(ang(f_min_ind:f_max_ind)) max(ang(f_min_ind:f_max_ind))]);\r
-grid on;\r
-xlabel('Fréquence (Hz)');\r
-ylabel('Phase (rad)');\r
-title(['Phasis of the transfert function (group: ' group ', id: ' id ', channel : ' channel ')']);\r
+if domain == 1\r
+    % Freq\r
+    f_max_list = find(f > f_max);\r
+    f_max_ind = f_max_list(1);\r
+    f_min_list = find(f < f_min);\r
+    f_min_ind = f_min_list(length(f_min_list));\r
+\r
+    figure;\r
+    subplot(2,1,1);\r
+    spec_mes_log = 10*log10(abs(spec_mes));\r
+    semilogx(f, spec_mes_log);\r
+    axis([f_min f_max min(spec_mes_log(f_min_ind:f_max_ind-1000))-6 max(spec_mes_log(f_min_ind:f_max_ind))+6]);\r
+    xlabel('Frequency (Hz)');\r
+    ylabel('Amplitude (dB)');\r
+    title(['Modulus of the transfert function (group: ' group ', id: ' id ', channel : ' channel ')']);\r
+    grid on;\r
+\r
+    subplot(2,1,2);\r
+    angle_exc = angle(spec_exc);\r
+    angle_mes = angle(spec_mes);\r
+    ang = unwrap(angle_mes - angle_exc) + 2*pi;\r
+    semilogx(f, ang);\r
+    axis([f_min f_max min(ang(f_min_ind:f_max_ind)) max(ang(f_min_ind:f_max_ind))]);\r
+    grid on;\r
+    xlabel('Fréquence (Hz)');\r
+    ylabel('Phase (rad)');\r
+    title(['Phasis of the transfert function (group: ' group ', id: ' id ', channel : ' channel ')']);\r
+\r
+elseif domain == 2\r
+    % Time\r
+    figure;\r
+    subplot(2,1,1);\r
+    plot(t, sig_mes);\r
+    %semilogx(t, sig_mes);\r
+    axis([0 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]);\r
+    %axis([1 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]);\r
+    xlabel('Time (s)');\r
+    ylabel('Amplitude');\r
+    title(['Measured temporal signal (group: ' group ', id: ' id ', channel : ' channel ')']);\r
+    grid on;\r
+\r
+    subplot(2,1,2);\r
+    len_ri = length(rep_imp_mes);\r
+    t_ri = [(-len_ri)/(2*f_s):1/f_s:(len_ri)/(2*f_s)];\r
+    %t_ri = [0:1/f_s:len_ri/f_s];\r
+    t_ri = t_ri(1:length(t_ri)-1);\r
+    plot(t_ri,rep_imp_mes);\r
+    axis([-t_ri(len_ri) t_ri(len_ri) min(rep_imp_mes)-0.01 max(rep_imp_mes)+0.01]);\r
+    xlabel('Time (s)');\r
+    ylabel('Amplitude');\r
+    title(['Measured impulse response (group: ' group ', id: ' id ', channel : ' channel ')']);\r
+    grid on;\r
+\r
+end\r
+\r
+\r
 \r
index 2df08d53c7a57e4ee7751e67b8b20170525cf82b..8ea5952fb9c4c5342bddb68e1dce84782e571417 100644 (file)
@@ -18,9 +18,9 @@ function save_mes(handles)
     f_min = str2double(get(handles.f_gen_min,'String'));
     f_max = str2double(get(handles.f_gen_max,'String'));
     time = get(handles.time_gen,'Value');
-    voices_in = get_voices_in(handles);
+    channels_in = get_channels_in(handles);
     gain_in = get(handles.gain_in,'Value');
-    voices_out = get_voices_out(handles);
+    channels_out = get_channels_out(handles);
     gain_out = get(handles.gain_out,'Value');
     
     % Save it