From: yomguy Date: Tue, 13 Nov 2007 01:18:34 +0000 (+0000) Subject: New import X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b689b432ee22c1bfdb1deb5491010915c95d253a;p=cnaq.git New import git-svn-id: http://svn.parisson.org/svn/CNAQ/trunk@97 5fc3e0e6-29bc-4d03-b52b-c088cb822bde --- diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 0000000..dc54388 Binary files /dev/null and b/AUTHORS.txt differ diff --git a/CNACQ.fig b/CNACQ.fig new file mode 100644 index 0000000..19e8aac Binary files /dev/null and b/CNACQ.fig differ diff --git a/CNACQ.m b/CNACQ.m new file mode 100644 index 0000000..734ea59 --- /dev/null +++ b/CNACQ.m @@ -0,0 +1,702 @@ +function varargout = CNACQ(varargin) +% CNACQ M-file for CNACQ.fig +% CNACQ, by itself, creates a new CNACQ or raises the existing +% singleton*. +% +% H = CNACQ returns the handle to a new CNACQ or the handle to +% the existing singleton*. +% +% CNACQ('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in CNACQ.M with the given input arguments. +% +% CNACQ('Property','Value',...) creates a new CNACQ or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before CNACQ_OpeningFunction gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to CNACQ_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Copyright (c) 2007 Guillaume Pellerin +% All rights reserved. + +% This software is governed by the CeCILL license under French law and +% abiding by the rules of distribution of free software. You can use, +% modify and/ or redistribute the software under the terms of the CeCILL +% license as circulated by CEA, CNRS and INRIA at the following URL +% "http://www.cecill.info". +% +% As a counterpart to the access to the source code and rights to copy, +% modify and redistribute granted by the license, users are provided only +% with a limited warranty and the software's author, the holder of the +% economic rights, and the successive licensors have only limited +% liability. +% +% In this respect, the user's attention is drawn to the risks associated +% with loading, using, modifying and/or developing or reproducing the +% software by the user in light of its specific status of free software, +% that may mean that it is complicated to manipulate, and that also +% therefore means that it is reserved for developers and experienced +% professionals having in-depth computer knowledge. Users are therefore +% encouraged to load and test the software's suitability as regards their +% requirements in conditions enabling the security of their systems and/or +% data to be ensured and, more generally, to use and operate it in the +% same conditions as regards security. +% +% The fact that you are presently reading this means that you have had +% knowledge of the CeCILL license given in the file COPYING and +% that you accept its terms. The terms are also available at +% http://svn.parisson.org/cnacq/wiki/CnacqLicense. + +% Author: Guillaume Pellerin + +% Last Modified by GUIDE v2.5 07-Nov-2007 18:26:57 + +% Global variables + +% ============================================================== +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @CNACQ_OpeningFcn, ... + 'gui_OutputFcn', @CNACQ_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +%global out_button_value in_button_value gen_button_value mes_button_value f_s n_bits; + +% --- Executes just before CNACQ is made visible. +function CNACQ_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to CNACQ (see VARARGIN) + +% Choose default command line output for CNACQ +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% --- Outputs from this function are returned to the command line. +function varargout = CNACQ_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% UIWAIT makes CNACQ wait for user response (see UIRESUME) +% uiwait(handles.figure1); +% ============================================================== + + +% ============================================================== +% INIT +% ============================================================== + +cnacq_version = '0.1'; + +% Get/Set home_dir & paths +root_dir = 'E:\CNACQ'; +home_dir = uigetdir(root_dir, 'Choisissez votre dossier de travail'); +set(handles.home_dir_box,'String',home_dir); + +% Get tools +%cnacq_path = pwd; +cnacq_path = root_dir; +manu_path = [cnacq_path '\Manulab\']; +tools_path = [cnacq_path '\tools\']; +path(path, cnacq_path); +path(path, manu_path); +path(path, tools_path); + +% Get/Set ID +id = get_id(handles); +set(handles.ID,'String',id); + +set(handles.info1_text,'String',['CNACQ v' cnacq_version ' - Copyright (C) 2007']); +set(handles.info2_text,'String','Guillaume Pellerin, Manuel Melon (CNAM Paris) http://svn.parisson.org/cnacq/'); + +%set(handles.home_dir_box,'C:\CNACQ\'); + +set(handles.f_gen_min,'String','20'); +set(handles.f_gen_max,'String','20000'); +set(handles.f_gen,'Value',1000); +set(handles.f_gen,'Min',20); +set(handles.f_gen,'Max',20000); +set(handles.freq_value,'String','1000') + +set(handles.gain_in,'Value',-6.0); +set(handles.gain_in_value,'String','-6.0'); +set(handles.gain_out,'Value',-6.0); +set(handles.gain_out_value,'String','-6.0'); + +set(handles.time_gen_min,'String','1'); +set(handles.time_gen_max,'String','20'); +set(handles.time_gen,'Value',5); +set(handles.time_gen,'Min',1); +set(handles.time_gen,'Max',20); +set(handles.time_value,'String','5') + +set(handles.nbits,'String','16|24'); +set(handles.f_s,'String','44100|48000|96000'); + +%set(handles.out_on_off,'Value',0); +set(handles.in_on_off,'Value',0); +set(handles.gen_on_off,'Value',0); +set(handles.sig_type,'String','Sinus|Chirp'); +set(handles.voices_in,'String','1|1 2|1 2 3|1 2 3 4'); +set(handles.voices_out,'String','1|1 2|1 2 3|1 2 3 4'); + +buffer = 2048; +os_sep = '\'; + +% ============================================================== +% TOOLS +% ============================================================== + +function id = get_id(handles) + home_dir = get(handles.home_dir_box,'String'); + id_file = [home_dir '\ID.m']; + if exist(id_file) == 0 + id = '1'; + elseif exist(id_file) == 2 + fid = fopen(id_file, 'r'); + id = fgetl(fid); + fclose(fid); + end + +function increment_id(handles) + home_dir = get(handles.home_dir_box,'String'); + id_file = [home_dir '\ID.m']; + id = get_id(handles); + id = num2str(str2double(id) + 1); + fid = fopen(id_file, 'w+'); + fprintf(fid, id); + fclose(fid); + set(handles.ID,'String',id); + +function f_s = get_fs(handles) + fs_ind = get(handles.f_s,'Value'); + if fs_ind == 1 + f_s = 44100; + elseif fs_ind == 2 + f_s = 48000; + elseif fs_ind == 3 + f_s = 96000; + end + +function voices_out = get_voices_out(handles) + vo_ind = get(handles.voices_out,'Value'); + if vo_ind == 1 + voices_out = [1]; + elseif vo_ind == 2 + voices_out = [1,2]; + elseif vo_ind == 3 + voices_out = [1,2,3]; + elseif vo_ind == 4 + voices_out = [1,2,3,4]; + end + +function voices_in = get_voices_in(handles) + vi_ind = get(handles.voices_in,'Value'); + if vi_ind == 1 + voices_in = [1]; + elseif vi_ind == 2 + voices_in = [1 2]; + elseif vi_ind == 3 + voices_in = [1 2 3]; + elseif vi_ind == 4 + voices_in = [1 2 3 4]; + end + +function nbits = get_nbits(handles) + nb_ind = get(handles.nbits,'Value'); + if nb_ind == 1 + nbits = 16; + elseif nb_ind == 2 + nbits = 24; + end + + +%============================================ +% DONNEES +%============================================ + +function username_Callback(hObject, eventdata, handles) +% hObject handle to username (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of username as text +% str2double(get(hObject,'String')) returns contents of username as a double + +% --- Executes during object creation, after setting all properties. +function username_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function comment_Callback(hObject, eventdata, handles) + +function comment_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function f_s_Callback(hObject, eventdata, handles) + +function f_s_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function nbits_Callback(hObject, eventdata, handles) + +function nbits_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function get_home_dir_Callback(hObject, eventdata, handles) + home_dir = uigetdir; + set(handles.home_dir_box,'String',home_dir); + id = get_id(handles); + set(handles.ID,'String',id); + + +%============================================ +% MONITOR +%============================================ + +function in_on_off_Callback(hObject, eventdata, handles) + device = 0; + buffer = 4096; + window = hanning(buffer); + f_s = get_fs(handles); + time = buffer/f_s; + t = [0:1/f_s:time-1/f_s]; + + f_min = str2double(get(handles.f_gen_min,'String')); + f_max = str2double(get(handles.f_gen_max,'String')); + freq = 2*(f_max-f_min)/buffer; + f = [f_min:freq:f_max-freq]; + voices_in = get_voices_in(handles); + voice_first = voices_in(1); + voice_last = voices_in(length(voices_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 = sig_in(:,1); + axes(handles.plot_in_temp); + cla; + %sig = sin(2*pi*10*t); + plot(t,sig_in); + grid on; + + % FREQ + axes(handles.plot_in_freq); + cla; + fft_in = fft(sig_in.*window,buffer); + log_abs_fft_in = 20*log10(2*abs(fft_in(1:round(buffer/2)))/buffer); + semilogx(f,log_abs_fft_in); + %axis([f_min f_max min(log_abs_fft_in) max(log_abs_fft_in)]); + axis([f_min f_max -120 0]); + grid on; + drawnow; + pause(0.01); + end + + +%============================================ +% VOIES +%============================================ + +function gain_in_Callback(hObject, eventdata, handles) + set(handles.gain_in_value,'String',num2str(get(handles.gain_in,'Value'))); + +function gain_in_CreateFcn(hObject, eventdata, handles) + if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); + end + +function gain_out_Callback(hObject, eventdata, handles) + set(handles.gain_out_value,'String',num2str(get(handles.gain_out,'Value'))) + +function gain_out_CreateFcn(hObject, eventdata, handles) + if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); + end + +function voices_in_Callback(hObject, eventdata, handles) + +function voices_in_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function voices_out_Callback(hObject, eventdata, handles) + +function voices_out_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +%============================================ +% GENERATEUR +%============================================ + +function sig_type_Callback(hObject, eventdata, handles) + +function sig_type_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +% TIME + +function time_gen_min_Callback(hObject, eventdata, handles) + tg_min = str2double(get(handles.time_gen_min,'String')); + tg_value = get(handles.time_gen,'Value'); + if tg_min > tg_value + set(handles.time_gen,'String',num2str(tg_min)); + end + set(handles.time_gen,'Min',tg_min); + +function time_gen_min_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function time_gen_max_Callback(hObject, eventdata, handles) + tg_max = str2double(get(handles.time_gen_max,'String')); + tg_value = get(handles.time_gen,'Value'); + if tg_max < tg_value + set(handles.time_gen,'String',num2str(tg_max)); + end + set(handles.time_gen,'Max',tg_max); + +function time_gen_max_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function time_gen_Callback(hObject, eventdata, handles) + set(handles.time_value,'String',num2str(get(handles.time_gen,'Value'))) + +function time_gen_CreateFcn(hObject, eventdata, handles) + if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); + end + + +% FREQ + +function f_gen_max_Callback(hObject, eventdata, handles) + fg_max = str2double(get(handles.f_gen_max,'String')); + fg_value = get(handles.f_gen,'Value'); + if fg_max < fg_value + set(handles.f_gen,'String',num2str(fg_max)); + end + set(handles.f_gen,'Max',fg_max); + +function f_gen_max_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function f_gen_min_Callback(hObject, eventdata, handles) + fg_min = str2double(get(handles.f_gen_min,'String')); + fg_value = get(handles.f_gen,'Value'); + if fg_min > fg_value + set(handles.f_gen,'String',num2str(fg_min)); + end + set(handles.f_gen,'Min',fg_min); + +function f_gen_min_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + + +function f_gen_Callback(hObject, eventdata, handles) + set(handles.freq_value,'String',num2str(get(handles.f_gen,'Value'))); + + +function f_gen_CreateFcn(hObject, eventdata, handles) + if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor',[.9 .9 .9]); + end + + + +function gen_on_off_Callback(hObject, eventdata, handles) +% Hint: get(hObject,'Value') returns toggle state of gen_on_off + + f_min = str2double(get(handles.f_gen_min,'String')); + f_max = str2double(get(handles.f_gen_max,'String')); + sig_type = get(handles.sig_type,'Value'); + sin_freq = get(handles.f_gen,'Value'); + f_s = get_fs(handles); + time = get(handles.time_gen,'Value'); + voices_out = get_voices_out(handles); + %voice_first = voices_out(1); + %voice_last = voices_out(length(voices_out)); + gain_out = get(handles.gain_out,'Value'); + gain_out = 10^(gain_out/20); + t = [0:1/f_s:time]; + + if sig_type == 1 + % SINUS + sig = gain_out*sin(2*pi*sin_freq*t); + elseif sig_type == 2 + % CHIRP + sig = gain_out*chirp(t,f_min,time,f_max,'logarithmic'); + end + + sig_out = []; + for i=1:length(voices_out) + sig_out(:,i) = sig'; + end + + % Matlab way... + ao = analogoutput('winsound', 0); + addchannel(ao, voices_out); + set(ao, 'StandardSampleRates', 'Off'); + set(ao, 'SampleRate', f_s); + + if get(handles.gen_on_off,'Value') == 1 + putdata(ao, sig_out); + start(ao); + set(handles.gen_on_off,'Value',0); + end + + %delete(ao); + + % PA way but can't work with monitor !... + % pa_wavplay(sig_out',f_s,0,'asio'); + + +%============================================ +% MESURE +%============================================ + +function mes_type_Callback(hObject, eventdata, handles) + +function mes_type_CreateFcn(hObject, eventdata, handles) + if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); + end + +function mes_on_Callback(hObject, eventdata, handles) + device = 0; + nfft = 16384; + f_min = str2double(get(handles.f_gen_min,'String')); + f_max = str2double(get(handles.f_gen_max,'String')); + f_s = get_fs(handles); + time = get(handles.time_gen,'Value'); + voices_in = get_voices_in(handles); + voice_first = voices_in(1); + voice_last = voices_in(length(voices_in)); + gain_out = get(handles.gain_out,'Value'); + gain_out = 10^(gain_out/20); + + % Avoid Gibbs like phenomenon + f0 = 0.1; + f1 = f_min; + f2 = f_max; + f3 = f_s/2; + fade_in_time = time/((log(f2/f0)/log(f1/f0))-1); + fade_out_time = time*((log(f3/f1)/log(f2/f1))-1); + total_time = fade_in_time + time + fade_out_time; + t = [0:1/f_s:total_time]; + + % Remove clicks durring emission and oscillations in the spectral response + len_win_in = fade_in_time * f_s; + window = blackman(len_win_in); + len_win_in = round(len_win_in/2); + window_in = window(1:len_win_in); + + len_win_out = fade_out_time * f_s; + window = blackman (len_win_out); + len_win_out = round(len_win_out/2); + window_out = flipud(window(1:len_win_out)); + + sig_exc = gain_out*chirp_farina(t,total_time,f0,f3); + l_t = length(t); + one(1:l_t-len_win_in-len_win_out) = 1; + mask = [window_in' one window_out']; + sig_exc = sig_exc.*mask; + + % Synchronizing + %The number of samples in the buffer (latency of the sound card in + %samples. See tests/testacqui2.m) + delay = 588; + zero = zeros(1,delay); + % Zeros are added before and removed after + sig_exc_z = [sig_exc zero]; + len_sig_exc = length(sig_exc); + + % Make all voices + sig_out = []; + for i=1:length(voices_in) + sig_out(:,i) = sig_exc_z'; + end + + % Measure + sig_mes = pa_wavplayrecord(sig_out, device, f_s, 0, voice_first, voice_last, device, 'asio'); + % Usage: + % inputbuffer = pa_wavplayrecord(playbuffer,[playdevice],[samplerate], + % [recnsamples], [recfirstchannel], [reclastchannel], + % [recdevice], [devicetype]) + + % Resynchro + len_sig_mes = length(sig_mes); + size_sig_mes = size(sig_mes); + n_col_sig_mes = size_sig_mes(2); + sig_mes = sig_mes(delay+1:len_sig_mes,:); + len_sig_mes = length(sig_mes); + sig_exc = sig_exc'; + f = logspace(log10(f0), log10(f3), len_sig_mes)'; + + % Save data + set(handles.ID,'UserData',sig_mes); + set(handles.id_title,'UserData',sig_exc); + set(handles.mes_on,'UserData',f); + + % Get infos + username = get(handles.username,'String'); + comment = get(handles.comment,'String'); + id = get(handles.ID,'String'); + + % Compute excitation spectrum + [rep_imp_exc, spec_exc] = fonc_trans(f, sig_exc, sig_exc); + 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] = fonc_trans(f, sig_exc, sig_mes(:,i)); + 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); + end + + set(handles.close_button,'UserData',f_lin'); + set(handles.plot,'UserData',t); + + +% Close all figures +% --- Executes on button press in close_button. +function close_button_Callback(hObject, eventdata, handles) +% hObject handle to close_button (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + close all; + + +% --- Executes on button press in plot. +function plot_Callback(hObject, eventdata, handles) +% hObject handle to plot (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + % Get data + sig_mes = get(handles.ID,'UserData'); + sig_exc = get(handles.id_title,'UserData'); + f = get(handles.mes_on,'UserData'); + t = get(handles.plot,'UserData'); + f_min = str2double(get(handles.f_gen_min,'String')); + f_max = str2double(get(handles.f_gen_max,'String')); + f_s = get_fs(handles); + + % Get infos + username = get(handles.username,'String'); + comment = get(handles.comment,'String'); + id = get(handles.ID,'String'); + + % Compute excitation spectrum + [rep_imp_exc, spec_exc] = fonc_trans(f, sig_exc, sig_exc); + len_spec_exc = length(spec_exc); + spec_exc = spec_exc(1:len_spec_exc/2); + + size_sig_mes = size(sig_mes); + n_col_sig_mes = size_sig_mes(2); + + % Compute all Ris and specs + for i=1:n_col_sig_mes + voice = num2str(i); + [rep_imp_mes, spec_mes] = fonc_trans(f, sig_exc, sig_mes(:,i)); + 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); + end + + +% SAVE all data in a mat file +function save_button_Callback(hObject, eventdata, handles) + % Get data + id = get(handles.ID,'String'); + username = get(handles.username,'String'); + home_dir = get(handles.home_dir_box,'String'); + comment = get(handles.comment,'String'); + sig_exc = get(handles.id_title,'UserData'); + sig_mes = get(handles.ID,'UserData'); + f_log = get(handles.mes_on,'UserData'); + f_lin = get(handles.close_button,'UserData'); + f_s = get_fs(handles); + nbits = get_nbits(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); + gain_in = get(handles.gain_in,'Value'); + voices_out = get_voices_out(handles); + gain_out = get(handles.gain_out,'Value'); + + % Save it + file = [home_dir '\' username '_' id '.mat']; + save(file); + + % Clear big data + set(handles.ID,'UserData',[]); + set(handles.id_title,'UserData',[]); + set(handles.mes_on,'UserData',[]); + + % Increment ID + increment_id(handles); + + + + + + diff --git a/COPIE.txt b/COPIE.txt new file mode 100644 index 0000000..d679121 --- /dev/null +++ b/COPIE.txt @@ -0,0 +1,512 @@ + +CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL + + + Avertissement + +Ce contrat est une licence de logiciel libre issue d'une concertation +entre ses auteurs afin que le respect de deux grands principes préside à +sa rédaction: + + * d'une part, le respect des principes de diffusion des logiciels + libres: accès au code source, droits étendus conférés aux + utilisateurs, + * d'autre part, la désignation d'un droit applicable, le droit + français, auquel elle est conforme, tant au regard du droit de la + responsabilité civile que du droit de la propriété intellectuelle + et de la protection qu'il offre aux auteurs et titulaires des + droits patrimoniaux sur un logiciel. + +Les auteurs de la licence CeCILL (pour Ce[a] C[nrs] I[nria] L[ogiciel] +L[ibre]) sont: + +Commissariat à l'Energie Atomique - CEA, établissement public de +recherche à caractère scientifique, technique et industriel, dont le +siège est situé 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris. + +Centre National de la Recherche Scientifique - CNRS, établissement +public à caractère scientifique et technologique, dont le siège est +situé 3 rue Michel-Ange, 75794 Paris cedex 16. + +Institut National de Recherche en Informatique et en Automatique - +INRIA, établissement public à caractère scientifique et technologique, +dont le siège est situé Domaine de Voluceau, Rocquencourt, BP 105, 78153 +Le Chesnay cedex. + + + Préambule + +Ce contrat est une licence de logiciel libre dont l'objectif est de +conférer aux utilisateurs la liberté de modification et de +redistribution du logiciel régi par cette licence dans le cadre d'un +modèle de diffusion en logiciel libre. + +L'exercice de ces libertés est assorti de certains devoirs à la charge +des utilisateurs afin de préserver ce statut au cours des +redistributions ultérieures. + +L'accessibilité au code source et les droits de copie, de modification +et de redistribution qui en découlent ont pour contrepartie de n'offrir +aux utilisateurs qu'une garantie limitée et de ne faire peser sur +l'auteur du logiciel, le titulaire des droits patrimoniaux et les +concédants successifs qu'une responsabilité restreinte. + +A cet égard l'attention de l'utilisateur est attirée sur les risques +associés au chargement, à l'utilisation, à la modification et/ou au +développement et à la reproduction du logiciel par l'utilisateur étant +donné sa spécificité de logiciel libre, qui peut le rendre complexe à +manipuler et qui le réserve donc à des développeurs ou des +professionnels avertis possédant des connaissances informatiques +approfondies. Les utilisateurs sont donc invités à charger et tester +l'adéquation du logiciel à leurs besoins dans des conditions permettant +d'assurer la sécurité de leurs systèmes et/ou de leurs données et, plus +généralement, à l'utiliser et l'exploiter dans les mêmes conditions de +sécurité. Ce contrat peut être reproduit et diffusé librement, sous +réserve de le conserver en l'état, sans ajout ni suppression de clauses. + +Ce contrat est susceptible de s'appliquer à tout logiciel dont le +titulaire des droits patrimoniaux décide de soumettre l'exploitation aux +dispositions qu'il contient. + + + Article 1 - DEFINITIONS + +Dans ce contrat, les termes suivants, lorsqu'ils seront écrits avec une +lettre capitale, auront la signification suivante: + +Contrat: désigne le présent contrat de licence, ses éventuelles versions +postérieures et annexes. + +Logiciel: désigne le logiciel sous sa forme de Code Objet et/ou de Code +Source et le cas échéant sa documentation, dans leur état au moment de +l'acceptation du Contrat par le Licencié. + +Logiciel Initial: désigne le Logiciel sous sa forme de Code Source et +éventuellement de Code Objet et le cas échéant sa documentation, dans +leur état au moment de leur première diffusion sous les termes du Contrat. + +Logiciel Modifié: désigne le Logiciel modifié par au moins une +Contribution. + +Code Source: désigne l'ensemble des instructions et des lignes de +programme du Logiciel et auquel l'accès est nécessaire en vue de +modifier le Logiciel. + +Code Objet: désigne les fichiers binaires issus de la compilation du +Code Source. + +Titulaire: désigne le ou les détenteurs des droits patrimoniaux d'auteur +sur le Logiciel Initial. + +Licencié: désigne le ou les utilisateurs du Logiciel ayant accepté le +Contrat. + +Contributeur: désigne le Licencié auteur d'au moins une Contribution. + +Concédant: désigne le Titulaire ou toute personne physique ou morale +distribuant le Logiciel sous le Contrat. + +Contribution: désigne l'ensemble des modifications, corrections, +traductions, adaptations et/ou nouvelles fonctionnalités intégrées dans +le Logiciel par tout Contributeur, ainsi que tout Module Interne. + +Module: désigne un ensemble de fichiers sources y compris leur +documentation qui permet de réaliser des fonctionnalités ou services +supplémentaires à ceux fournis par le Logiciel. + +Module Externe: désigne tout Module, non dérivé du Logiciel, tel que ce +Module et le Logiciel s'exécutent dans des espaces d'adressage +différents, l'un appelant l'autre au moment de leur exécution. + +Module Interne: désigne tout Module lié au Logiciel de telle sorte +qu'ils s'exécutent dans le même espace d'adressage. + +GNU GPL: désigne la GNU General Public License dans sa version 2 ou +toute version ultérieure, telle que publiée par Free Software Foundation +Inc. + +Parties: désigne collectivement le Licencié et le Concédant. + +Ces termes s'entendent au singulier comme au pluriel. + + + Article 2 - OBJET + +Le Contrat a pour objet la concession par le Concédant au Licencié d'une +licence non exclusive, cessible et mondiale du Logiciel telle que +définie ci-après à l'article 5 pour toute la durée de protection des droits +portant sur ce Logiciel. + + + Article 3 - ACCEPTATION + +3.1 L'acceptation par le Licencié des termes du Contrat est réputée +acquise du fait du premier des faits suivants: + + * (i) le chargement du Logiciel par tout moyen notamment par + téléchargement à partir d'un serveur distant ou par chargement à + partir d'un support physique; + * (ii) le premier exercice par le Licencié de l'un quelconque des + droits concédés par le Contrat. + +3.2 Un exemplaire du Contrat, contenant notamment un avertissement +relatif aux spécificités du Logiciel, à la restriction de garantie et à +la limitation à un usage par des utilisateurs expérimentés a été mis à +disposition du Licencié préalablement à son acceptation telle que +définie à l'article 3.1 ci dessus et le Licencié reconnaît en avoir pris +connaissance. + + + Article 4 - ENTREE EN VIGUEUR ET DUREE + + + 4.1 ENTREE EN VIGUEUR + +Le Contrat entre en vigueur à la date de son acceptation par le Licencié +telle que définie en 3.1. + + + 4.2 DUREE + +Le Contrat produira ses effets pendant toute la durée légale de +protection des droits patrimoniaux portant sur le Logiciel. + + + Article 5 - ETENDUE DES DROITS CONCEDES + +Le Concédant concède au Licencié, qui accepte, les droits suivants sur +le Logiciel pour toutes destinations et pour la durée du Contrat dans +les conditions ci-après détaillées. + +Par ailleurs, si le Concédant détient ou venait à détenir un ou +plusieurs brevets d'invention protégeant tout ou partie des +fonctionnalités du Logiciel ou de ses composants, il s'engage à ne pas +opposer les éventuels droits conférés par ces brevets aux Licenciés +successifs qui utiliseraient, exploiteraient ou modifieraient le +Logiciel. En cas de cession de ces brevets, le Concédant s'engage à +faire reprendre les obligations du présent alinéa aux cessionnaires. + + + 5.1 DROIT D'UTILISATION + +Le Licencié est autorisé à utiliser le Logiciel, sans restriction quant +aux domaines d'application, étant ci-après précisé que cela comporte: + + 1. la reproduction permanente ou provisoire du Logiciel en tout ou + partie par tout moyen et sous toute forme. + + 2. le chargement, l'affichage, l'exécution, ou le stockage du + Logiciel sur tout support. + + 3. la possibilité d'en observer, d'en étudier, ou d'en tester le + fonctionnement afin de déterminer les idées et principes qui sont + à la base de n'importe quel élément de ce Logiciel; et ceci, + lorsque le Licencié effectue toute opération de chargement, + d'affichage, d'exécution, de transmission ou de stockage du + Logiciel qu'il est en droit d'effectuer en vertu du Contrat. + + + 5.2 DROIT D'APPORTER DES CONTRIBUTIONS + +Le droit d'apporter des Contributions comporte le droit de traduire, +d'adapter, d'arranger ou d'apporter toute autre modification au Logiciel +et le droit de reproduire le logiciel en résultant. + +Le Licencié est autorisé à apporter toute Contribution au Logiciel sous +réserve de mentionner, de façon explicite, son nom en tant qu'auteur de +cette Contribution et la date de création de celle-ci. + + + 5.3 DROIT DE DISTRIBUTION + +Le droit de distribution comporte notamment le droit de diffuser, de +transmettre et de communiquer le Logiciel au public sur tout support et +par tout moyen ainsi que le droit de mettre sur le marché à titre +onéreux ou gratuit, un ou des exemplaires du Logiciel par tout procédé. + +Le Licencié est autorisé à distribuer des copies du Logiciel, modifié ou +non, à des tiers dans les conditions ci-après détaillées. + + + 5.3.1 DISTRIBUTION DU LOGICIEL SANS MODIFICATION + +Le Licencié est autorisé à distribuer des copies conformes du Logiciel, +sous forme de Code Source ou de Code Objet, à condition que cette +distribution respecte les dispositions du Contrat dans leur totalité et +soit accompagnée: + + 1. d'un exemplaire du Contrat, + + 2. d'un avertissement relatif à la restriction de garantie et de + responsabilité du Concédant telle que prévue aux articles 8 + et 9, + +et que, dans le cas où seul le Code Objet du Logiciel est redistribué, +le Licencié permette aux futurs Licenciés d'accéder facilement au Code +Source complet du Logiciel en indiquant les modalités d'accès, étant +entendu que le coût additionnel d'acquisition du Code Source ne devra +pas excéder le simple coût de transfert des données. + + + 5.3.2 DISTRIBUTION DU LOGICIEL MODIFIE + +Lorsque le Licencié apporte une Contribution au Logiciel, les conditions +de distribution du Logiciel Modifié en résultant sont alors soumises à +l'intégralité des dispositions du Contrat. + +Le Licencié est autorisé à distribuer le Logiciel Modifié, sous forme de +code source ou de code objet, à condition que cette distribution +respecte les dispositions du Contrat dans leur totalité et soit +accompagnée: + + 1. d'un exemplaire du Contrat, + + 2. d'un avertissement relatif à la restriction de garantie et de + responsabilité du Concédant telle que prévue aux articles 8 + et 9, + +et que, dans le cas où seul le code objet du Logiciel Modifié est +redistribué, le Licencié permette aux futurs Licenciés d'accéder +facilement au code source complet du Logiciel Modifié en indiquant les +modalités d'accès, étant entendu que le coût additionnel d'acquisition +du code source ne devra pas excéder le simple coût de transfert des données. + + + 5.3.3 DISTRIBUTION DES MODULES EXTERNES + +Lorsque le Licencié a développé un Module Externe les conditions du +Contrat ne s'appliquent pas à ce Module Externe, qui peut être distribué +sous un contrat de licence différent. + + + 5.3.4 COMPATIBILITE AVEC LA LICENCE GNU GPL + +Le Licencié peut inclure un code soumis aux dispositions d'une des +versions de la licence GNU GPL dans le Logiciel modifié ou non et +distribuer l'ensemble sous les conditions de la même version de la +licence GNU GPL. + +Le Licencié peut inclure le Logiciel modifié ou non dans un code soumis +aux dispositions d'une des versions de la licence GNU GPL et distribuer +l'ensemble sous les conditions de la même version de la licence GNU GPL. + + + Article 6 - PROPRIETE INTELLECTUELLE + + + 6.1 SUR LE LOGICIEL INITIAL + +Le Titulaire est détenteur des droits patrimoniaux sur le Logiciel +Initial. Toute utilisation du Logiciel Initial est soumise au respect +des conditions dans lesquelles le Titulaire a choisi de diffuser son +oeuvre et nul autre n'a la faculté de modifier les conditions de +diffusion de ce Logiciel Initial. + +Le Titulaire s'engage à ce que le Logiciel Initial reste au moins régi +par le Contrat et ce, pour la durée visée à l'article 4.2. + + + 6.2 SUR LES CONTRIBUTIONS + +Le Licencié qui a développé une Contribution est titulaire sur celle-ci +des droits de propriété intellectuelle dans les conditions définies par +la législation applicable. + + + 6.3 SUR LES MODULES EXTERNES + +Le Licencié qui a développé un Module Externe est titulaire sur celui-ci +des droits de propriété intellectuelle dans les conditions définies par +la législation applicable et reste libre du choix du contrat régissant +sa diffusion. + + + 6.4 DISPOSITIONS COMMUNES + +Le Licencié s'engage expressément: + + 1. à ne pas supprimer ou modifier de quelque manière que ce soit les + mentions de propriété intellectuelle apposées sur le Logiciel; + + 2. à reproduire à l'identique lesdites mentions de propriété + intellectuelle sur les copies du Logiciel modifié ou non. + +Le Licencié s'engage à ne pas porter atteinte, directement ou +indirectement, aux droits de propriété intellectuelle du Titulaire et/ou +des Contributeurs sur le Logiciel et à prendre, le cas échéant, à +l'égard de son personnel toutes les mesures nécessaires pour assurer le +respect des dits droits de propriété intellectuelle du Titulaire et/ou +des Contributeurs. + + + Article 7 - SERVICES ASSOCIES + +7.1 Le Contrat n'oblige en aucun cas le Concédant à la réalisation de +prestations d'assistance technique ou de maintenance du Logiciel. + +Cependant le Concédant reste libre de proposer ce type de services. Les +termes et conditions d'une telle assistance technique et/ou d'une telle +maintenance seront alors déterminés dans un acte séparé. Ces actes de +maintenance et/ou assistance technique n'engageront que la seule +responsabilité du Concédant qui les propose. + +7.2 De même, tout Concédant est libre de proposer, sous sa seule +responsabilité, à ses licenciés une garantie, qui n'engagera que lui, +lors de la redistribution du Logiciel et/ou du Logiciel Modifié et ce, +dans les conditions qu'il souhaite. Cette garantie et les modalités +financières de son application feront l'objet d'un acte séparé entre le +Concédant et le Licencié. + + + Article 8 - RESPONSABILITE + +8.1 Sous réserve des dispositions de l'article 8.2, le Licencié a la +faculté, sous réserve de prouver la faute du Concédant concerné, de +solliciter la réparation du préjudice direct qu'il subirait du fait du +Logiciel et dont il apportera la preuve. + +8.2 La responsabilité du Concédant est limitée aux engagements pris en +application du Contrat et ne saurait être engagée en raison notamment: +(i) des dommages dus à l'inexécution, totale ou partielle, de ses +obligations par le Licencié, (ii) des dommages directs ou indirects +découlant de l'utilisation ou des performances du Logiciel subis par le +Licencié et (iii) plus généralement d'un quelconque dommage indirect. En +particulier, les Parties conviennent expressément que tout préjudice +financier ou commercial (par exemple perte de données, perte de +bénéfices, perte d'exploitation, perte de clientèle ou de commandes, +manque à gagner, trouble commercial quelconque) ou toute action dirigée +contre le Licencié par un tiers, constitue un dommage indirect et +n'ouvre pas droit à réparation par le Concédant. + + + Article 9 - GARANTIE + +9.1 Le Licencié reconnaît que l'état actuel des connaissances +scientifiques et techniques au moment de la mise en circulation du +Logiciel ne permet pas d'en tester et d'en vérifier toutes les +utilisations ni de détecter l'existence d'éventuels défauts. L'attention +du Licencié a été attirée sur ce point sur les risques associés au +chargement, à l'utilisation, la modification et/ou au développement et à +la reproduction du Logiciel qui sont réservés à des utilisateurs avertis. + +Il relève de la responsabilité du Licencié de contrôler, par tous +moyens, l'adéquation du produit à ses besoins, son bon fonctionnement et +de s'assurer qu'il ne causera pas de dommages aux personnes et aux biens. + +9.2 Le Concédant déclare de bonne foi être en droit de concéder +l'ensemble des droits attachés au Logiciel (comprenant notamment les +droits visés à l'article 5). + +9.3 Le Licencié reconnaît que le Logiciel est fourni "en l'état" par le +Concédant sans autre garantie, expresse ou tacite, que celle prévue à +l'article 9.2 et notamment sans aucune garantie sur sa valeur commerciale, +son caractère sécurisé, innovant ou pertinent. + +En particulier, le Concédant ne garantit pas que le Logiciel est exempt +d'erreur, qu'il fonctionnera sans interruption, qu'il sera compatible +avec l'équipement du Licencié et sa configuration logicielle ni qu'il +remplira les besoins du Licencié. + +9.4 Le Concédant ne garantit pas, de manière expresse ou tacite, que le +Logiciel ne porte pas atteinte à un quelconque droit de propriété +intellectuelle d'un tiers portant sur un brevet, un logiciel ou sur tout +autre droit de propriété. Ainsi, le Concédant exclut toute garantie au +profit du Licencié contre les actions en contrefaçon qui pourraient être +diligentées au titre de l'utilisation, de la modification, et de la +redistribution du Logiciel. Néanmoins, si de telles actions sont +exercées contre le Licencié, le Concédant lui apportera son aide +technique et juridique pour sa défense. Cette aide technique et +juridique est déterminée au cas par cas entre le Concédant concerné et +le Licencié dans le cadre d'un protocole d'accord. Le Concédant dégage +toute responsabilité quant à l'utilisation de la dénomination du +Logiciel par le Licencié. Aucune garantie n'est apportée quant à +l'existence de droits antérieurs sur le nom du Logiciel et sur +l'existence d'une marque. + + + Article 10 - RESILIATION + +10.1 En cas de manquement par le Licencié aux obligations mises à sa +charge par le Contrat, le Concédant pourra résilier de plein droit le +Contrat trente (30) jours après notification adressée au Licencié et +restée sans effet. + +10.2 Le Licencié dont le Contrat est résilié n'est plus autorisé à +utiliser, modifier ou distribuer le Logiciel. Cependant, toutes les +licences qu'il aura concédées antérieurement à la résiliation du Contrat +resteront valides sous réserve qu'elles aient été effectuées en +conformité avec le Contrat. + + + Article 11 - DISPOSITIONS DIVERSES + + + 11.1 CAUSE EXTERIEURE + +Aucune des Parties ne sera responsable d'un retard ou d'une défaillance +d'exécution du Contrat qui serait dû à un cas de force majeure, un cas +fortuit ou une cause extérieure, telle que, notamment, le mauvais +fonctionnement ou les interruptions du réseau électrique ou de +télécommunication, la paralysie du réseau liée à une attaque +informatique, l'intervention des autorités gouvernementales, les +catastrophes naturelles, les dégâts des eaux, les tremblements de terre, +le feu, les explosions, les grèves et les conflits sociaux, l'état de +guerre... + +11.2 Le fait, par l'une ou l'autre des Parties, d'omettre en une ou +plusieurs occasions de se prévaloir d'une ou plusieurs dispositions du +Contrat, ne pourra en aucun cas impliquer renonciation par la Partie +intéressée à s'en prévaloir ultérieurement. + +11.3 Le Contrat annule et remplace toute convention antérieure, écrite +ou orale, entre les Parties sur le même objet et constitue l'accord +entier entre les Parties sur cet objet. Aucune addition ou modification +aux termes du Contrat n'aura d'effet à l'égard des Parties à moins +d'être faite par écrit et signée par leurs représentants dûment habilités. + +11.4 Dans l'hypothèse où une ou plusieurs des dispositions du Contrat +s'avèrerait contraire à une loi ou à un texte applicable, existants ou +futurs, cette loi ou ce texte prévaudrait, et les Parties feraient les +amendements nécessaires pour se conformer à cette loi ou à ce texte. +Toutes les autres dispositions resteront en vigueur. De même, la +nullité, pour quelque raison que ce soit, d'une des dispositions du +Contrat ne saurait entraîner la nullité de l'ensemble du Contrat. + + + 11.5 LANGUE + +Le Contrat est rédigé en langue française et en langue anglaise, ces +deux versions faisant également foi. + + + Article 12 - NOUVELLES VERSIONS DU CONTRAT + +12.1 Toute personne est autorisée à copier et distribuer des copies de +ce Contrat. + +12.2 Afin d'en préserver la cohérence, le texte du Contrat est protégé +et ne peut être modifié que par les auteurs de la licence, lesquels se +réservent le droit de publier périodiquement des mises à jour ou de +nouvelles versions du Contrat, qui posséderont chacune un numéro +distinct. Ces versions ultérieures seront susceptibles de prendre en +compte de nouvelles problématiques rencontrées par les logiciels libres. + +12.3 Tout Logiciel diffusé sous une version donnée du Contrat ne pourra +faire l'objet d'une diffusion ultérieure que sous la même version du +Contrat ou une version postérieure, sous réserve des dispositions de +l'article 5.3.4. + + + Article 13 - LOI APPLICABLE ET COMPETENCE TERRITORIALE + +13.1 Le Contrat est régi par la loi française. Les Parties conviennent +de tenter de régler à l'amiable les différends ou litiges qui +viendraient à se produire par suite ou à l'occasion du Contrat. + +13.2 A défaut d'accord amiable dans un délai de deux (2) mois à compter +de leur survenance et sauf situation relevant d'une procédure d'urgence, +les différends ou litiges seront portés par la Partie la plus diligente +devant les Tribunaux compétents de Paris. + + +Version 2.0 du 2006-09-05. diff --git a/COPYING.txt b/COPYING.txt new file mode 100644 index 0000000..4d89ece --- /dev/null +++ b/COPYING.txt @@ -0,0 +1,506 @@ + +CeCILL FREE SOFTWARE LICENSE AGREEMENT + + + Notice + +This Agreement is a Free Software license agreement that is the result +of discussions between its authors in order to ensure compliance with +the two main principles guiding its drafting: + + * firstly, compliance with the principles governing the distribution + of Free Software: access to source code, broad rights granted to + users, + * secondly, the election of a governing law, French law, with which + it is conformant, both as regards the law of torts and + intellectual property law, and the protection that it offers to + both authors and holders of the economic rights over software. + +The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) +license are: + +Commissariat à l'Energie Atomique - CEA, a public scientific, technical +and industrial research establishment, having its principal place of +business at 25 rue Leblanc, immeuble Le Ponant D, 75015 Paris, France. + +Centre National de la Recherche Scientifique - CNRS, a public scientific +and technological establishment, having its principal place of business +at 3 rue Michel-Ange, 75794 Paris cedex 16, France. + +Institut National de Recherche en Informatique et en Automatique - +INRIA, a public scientific and technological establishment, having its +principal place of business at Domaine de Voluceau, Rocquencourt, BP +105, 78153 Le Chesnay cedex, France. + + + Preamble + +The purpose of this Free Software license agreement is to grant users +the right to modify and redistribute the software governed by this +license within the framework of an open source distribution model. + +The exercising of these rights is conditional upon certain obligations +for users so as to preserve this status for all subsequent redistributions. + +In consideration of access to the source code and the rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors only have limited liability. + +In this respect, the risks associated with loading, using, modifying +and/or developing or reproducing the software by the user are brought to +the user's attention, given its Free Software status, which may make it +complicated to use, with the result that its use is reserved for +developers and experienced professionals having in-depth computer +knowledge. Users are therefore encouraged to load and test the +suitability of the software as regards their requirements in conditions +enabling the security of their systems and/or data to be ensured and, +more generally, to use and operate it in the same conditions of +security. This Agreement may be freely reproduced and published, +provided it is not altered, and that no provisions are either added or +removed herefrom. + +This Agreement may apply to any or all software for which the holder of +the economic rights decides to submit the use thereof to its provisions. + + + Article 1 - DEFINITIONS + +For the purpose of this Agreement, when the following expressions +commence with a capital letter, they shall have the following meaning: + +Agreement: means this license agreement, and its possible subsequent +versions and annexes. + +Software: means the software in its Object Code and/or Source Code form +and, where applicable, its documentation, "as is" when the Licensee +accepts the Agreement. + +Initial Software: means the Software in its Source Code and possibly its +Object Code form and, where applicable, its documentation, "as is" when +it is first distributed under the terms and conditions of the Agreement. + +Modified Software: means the Software modified by at least one +Contribution. + +Source Code: means all the Software's instructions and program lines to +which access is required so as to modify the Software. + +Object Code: means the binary files originating from the compilation of +the Source Code. + +Holder: means the holder(s) of the economic rights over the Initial +Software. + +Licensee: means the Software user(s) having accepted the Agreement. + +Contributor: means a Licensee having made at least one Contribution. + +Licensor: means the Holder, or any other individual or legal entity, who +distributes the Software under the Agreement. + +Contribution: means any or all modifications, corrections, translations, +adaptations and/or new functions integrated into the Software by any or +all Contributors, as well as any or all Internal Modules. + +Module: means a set of sources files including their documentation that +enables supplementary functions or services in addition to those offered +by the Software. + +External Module: means any or all Modules, not derived from the +Software, so that this Module and the Software run in separate address +spaces, with one calling the other when they are run. + +Internal Module: means any or all Module, connected to the Software so +that they both execute in the same address space. + +GNU GPL: means the GNU General Public License version 2 or any +subsequent version, as published by the Free Software Foundation Inc. + +Parties: mean both the Licensee and the Licensor. + +These expressions may be used both in singular and plural form. + + + Article 2 - PURPOSE + +The purpose of the Agreement is the grant by the Licensor to the +Licensee of a non-exclusive, transferable and worldwide license for the +Software as set forth in Article 5 hereinafter for the whole term of the +protection granted by the rights over said Software. + + + Article 3 - ACCEPTANCE + +3.1 The Licensee shall be deemed as having accepted the terms and +conditions of this Agreement upon the occurrence of the first of the +following events: + + * (i) loading the Software by any or all means, notably, by + downloading from a remote server, or by loading from a physical + medium; + * (ii) the first time the Licensee exercises any of the rights + granted hereunder. + +3.2 One copy of the Agreement, containing a notice relating to the +characteristics of the Software, to the limited warranty, and to the +fact that its use is restricted to experienced users has been provided +to the Licensee prior to its acceptance as set forth in Article 3.1 +hereinabove, and the Licensee hereby acknowledges that it has read and +understood it. + + + Article 4 - EFFECTIVE DATE AND TERM + + + 4.1 EFFECTIVE DATE + +The Agreement shall become effective on the date when it is accepted by +the Licensee as set forth in Article 3.1. + + + 4.2 TERM + +The Agreement shall remain in force for the entire legal term of +protection of the economic rights over the Software. + + + Article 5 - SCOPE OF RIGHTS GRANTED + +The Licensor hereby grants to the Licensee, who accepts, the following +rights over the Software for any or all use, and for the term of the +Agreement, on the basis of the terms and conditions set forth hereinafter. + +Besides, if the Licensor owns or comes to own one or more patents +protecting all or part of the functions of the Software or of its +components, the Licensor undertakes not to enforce the rights granted by +these patents against successive Licensees using, exploiting or +modifying the Software. If these patents are transferred, the Licensor +undertakes to have the transferees subscribe to the obligations set +forth in this paragraph. + + + 5.1 RIGHT OF USE + +The Licensee is authorized to use the Software, without any limitation +as to its fields of application, with it being hereinafter specified +that this comprises: + + 1. permanent or temporary reproduction of all or part of the Software + by any or all means and in any or all form. + + 2. loading, displaying, running, or storing the Software on any or + all medium. + + 3. entitlement to observe, study or test its operation so as to + determine the ideas and principles behind any or all constituent + elements of said Software. This shall apply when the Licensee + carries out any or all loading, displaying, running, transmission + or storage operation as regards the Software, that it is entitled + to carry out hereunder. + + + 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS + +The right to make Contributions includes the right to translate, adapt, +arrange, or make any or all modifications to the Software, and the right +to reproduce the resulting software. + +The Licensee is authorized to make any or all Contributions to the +Software provided that it includes an explicit notice that it is the +author of said Contribution and indicates the date of the creation thereof. + + + 5.3 RIGHT OF DISTRIBUTION + +In particular, the right of distribution includes the right to publish, +transmit and communicate the Software to the general public on any or +all medium, and by any or all means, and the right to market, either in +consideration of a fee, or free of charge, one or more copies of the +Software by any means. + +The Licensee is further authorized to distribute copies of the modified +or unmodified Software to third parties according to the terms and +conditions set forth hereinafter. + + + 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION + +The Licensee is authorized to distribute true copies of the Software in +Source Code or Object Code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's + warranty and liability as set forth in Articles 8 and 9, + +and that, in the event that only the Object Code of the Software is +redistributed, the Licensee allows future Licensees unhindered access to +the full Source Code of the Software by indicating how to access it, it +being understood that the additional cost of acquiring the Source Code +shall not exceed the cost of transferring the data. + + + 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE + +When the Licensee makes a Contribution to the Software, the terms and +conditions for the distribution of the resulting Modified Software +become subject to all the provisions of this Agreement. + +The Licensee is authorized to distribute the Modified Software, in +source code or object code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's + warranty and liability as set forth in Articles 8 and 9, + +and that, in the event that only the object code of the Modified +Software is redistributed, the Licensee allows future Licensees +unhindered access to the full source code of the Modified Software by +indicating how to access it, it being understood that the additional +cost of acquiring the source code shall not exceed the cost of +transferring the data. + + + 5.3.3 DISTRIBUTION OF EXTERNAL MODULES + +When the Licensee has developed an External Module, the terms and +conditions of this Agreement do not apply to said External Module, that +may be distributed under a separate license agreement. + + + 5.3.4 COMPATIBILITY WITH THE GNU GPL + +The Licensee can include a code that is subject to the provisions of one +of the versions of the GNU GPL in the Modified or unmodified Software, +and distribute that entire code under the terms of the same version of +the GNU GPL. + +The Licensee can include the Modified or unmodified Software in a code +that is subject to the provisions of one of the versions of the GNU GPL, +and distribute that entire code under the terms of the same version of +the GNU GPL. + + + Article 6 - INTELLECTUAL PROPERTY + + + 6.1 OVER THE INITIAL SOFTWARE + +The Holder owns the economic rights over the Initial Software. Any or +all use of the Initial Software is subject to compliance with the terms +and conditions under which the Holder has elected to distribute its work +and no one shall be entitled to modify the terms and conditions for the +distribution of said Initial Software. + +The Holder undertakes that the Initial Software will remain ruled at +least by this Agreement, for the duration set forth in Article 4.2. + + + 6.2 OVER THE CONTRIBUTIONS + +The Licensee who develops a Contribution is the owner of the +intellectual property rights over this Contribution as defined by +applicable law. + + + 6.3 OVER THE EXTERNAL MODULES + +The Licensee who develops an External Module is the owner of the +intellectual property rights over this External Module as defined by +applicable law and is free to choose the type of agreement that shall +govern its distribution. + + + 6.4 JOINT PROVISIONS + +The Licensee expressly undertakes: + + 1. not to remove, or modify, in any manner, the intellectual property + notices attached to the Software; + + 2. to reproduce said notices, in an identical manner, in the copies + of the Software modified or not. + +The Licensee undertakes not to directly or indirectly infringe the +intellectual property rights of the Holder and/or Contributors on the +Software and to take, where applicable, vis-à-vis its staff, any and all +measures required to ensure respect of said intellectual property rights +of the Holder and/or Contributors. + + + Article 7 - RELATED SERVICES + +7.1 Under no circumstances shall the Agreement oblige the Licensor to +provide technical assistance or maintenance services for the Software. + +However, the Licensor is entitled to offer this type of services. The +terms and conditions of such technical assistance, and/or such +maintenance, shall be set forth in a separate instrument. Only the +Licensor offering said maintenance and/or technical assistance services +shall incur liability therefor. + +7.2 Similarly, any Licensor is entitled to offer to its licensees, under +its sole responsibility, a warranty, that shall only be binding upon +itself, for the redistribution of the Software and/or the Modified +Software, under terms and conditions that it is free to decide. Said +warranty, and the financial terms and conditions of its application, +shall be subject of a separate instrument executed between the Licensor +and the Licensee. + + + Article 8 - LIABILITY + +8.1 Subject to the provisions of Article 8.2, the Licensee shall be +entitled to claim compensation for any direct loss it may have suffered +from the Software as a result of a fault on the part of the relevant +Licensor, subject to providing evidence thereof. + +8.2 The Licensor's liability is limited to the commitments made under +this Agreement and shall not be incurred as a result of in particular: +(i) loss due the Licensee's total or partial failure to fulfill its +obligations, (ii) direct or consequential loss that is suffered by the +Licensee due to the use or performance of the Software, and (iii) more +generally, any consequential loss. In particular the Parties expressly +agree that any or all pecuniary or business loss (i.e. loss of data, +loss of profits, operating loss, loss of customers or orders, +opportunity cost, any disturbance to business activities) or any or all +legal proceedings instituted against the Licensee by a third party, +shall constitute consequential loss and shall not provide entitlement to +any or all compensation from the Licensor. + + + Article 9 - WARRANTY + +9.1 The Licensee acknowledges that the scientific and technical +state-of-the-art when the Software was distributed did not enable all +possible uses to be tested and verified, nor for the presence of +possible defects to be detected. In this respect, the Licensee's +attention has been drawn to the risks associated with loading, using, +modifying and/or developing and reproducing the Software which are +reserved for experienced users. + +The Licensee shall be responsible for verifying, by any or all means, +the suitability of the product for its requirements, its good working +order, and for ensuring that it shall not cause damage to either persons +or properties. + +9.2 The Licensor hereby represents, in good faith, that it is entitled +to grant all the rights over the Software (including in particular the +rights set forth in Article 5). + +9.3 The Licensee acknowledges that the Software is supplied "as is" by +the Licensor without any other express or tacit warranty, other than +that provided for in Article 9.2 and, in particular, without any warranty +as to its commercial value, its secured, safe, innovative or relevant +nature. + +Specifically, the Licensor does not warrant that the Software is free +from any error, that it will operate without interruption, that it will +be compatible with the Licensee's own equipment and software +configuration, nor that it will meet the Licensee's requirements. + +9.4 The Licensor does not either expressly or tacitly warrant that the +Software does not infringe any third party intellectual property right +relating to a patent, software or any other property right. Therefore, +the Licensor disclaims any and all liability towards the Licensee +arising out of any or all proceedings for infringement that may be +instituted in respect of the use, modification and redistribution of the +Software. Nevertheless, should such proceedings be instituted against +the Licensee, the Licensor shall provide it with technical and legal +assistance for its defense. Such technical and legal assistance shall be +decided on a case-by-case basis between the relevant Licensor and the +Licensee pursuant to a memorandum of understanding. The Licensor +disclaims any and all liability as regards the Licensee's use of the +name of the Software. No warranty is given as regards the existence of +prior rights over the name of the Software or as regards the existence +of a trademark. + + + Article 10 - TERMINATION + +10.1 In the event of a breach by the Licensee of its obligations +hereunder, the Licensor may automatically terminate this Agreement +thirty (30) days after notice has been sent to the Licensee and has +remained ineffective. + +10.2 A Licensee whose Agreement is terminated shall no longer be +authorized to use, modify or distribute the Software. However, any +licenses that it may have granted prior to termination of the Agreement +shall remain valid subject to their having been granted in compliance +with the terms and conditions hereof. + + + Article 11 - MISCELLANEOUS + + + 11.1 EXCUSABLE EVENTS + +Neither Party shall be liable for any or all delay, or failure to +perform the Agreement, that may be attributable to an event of force +majeure, an act of God or an outside cause, such as defective +functioning or interruptions of the electricity or telecommunications +networks, network paralysis following a virus attack, intervention by +government authorities, natural disasters, water damage, earthquakes, +fire, explosions, strikes and labor unrest, war, etc. + +11.2 Any failure by either Party, on one or more occasions, to invoke +one or more of the provisions hereof, shall under no circumstances be +interpreted as being a waiver by the interested Party of its right to +invoke said provision(s) subsequently. + +11.3 The Agreement cancels and replaces any or all previous agreements, +whether written or oral, between the Parties and having the same +purpose, and constitutes the entirety of the agreement between said +Parties concerning said purpose. No supplement or modification to the +terms and conditions hereof shall be effective as between the Parties +unless it is made in writing and signed by their duly authorized +representatives. + +11.4 In the event that one or more of the provisions hereof were to +conflict with a current or future applicable act or legislative text, +said act or legislative text shall prevail, and the Parties shall make +the necessary amendments so as to comply with said act or legislative +text. All other provisions shall remain effective. Similarly, invalidity +of a provision of the Agreement, for any reason whatsoever, shall not +cause the Agreement as a whole to be invalid. + + + 11.5 LANGUAGE + +The Agreement is drafted in both French and English and both versions +are deemed authentic. + + + Article 12 - NEW VERSIONS OF THE AGREEMENT + +12.1 Any person is authorized to duplicate and distribute copies of this +Agreement. + +12.2 So as to ensure coherence, the wording of this Agreement is +protected and may only be modified by the authors of the License, who +reserve the right to periodically publish updates or new versions of the +Agreement, each with a separate number. These subsequent versions may +address new issues encountered by Free Software. + +12.3 Any Software distributed under a given version of the Agreement may +only be subsequently distributed under the same version of the Agreement +or a subsequent version, subject to the provisions of Article 5.3.4. + + + Article 13 - GOVERNING LAW AND JURISDICTION + +13.1 The Agreement is governed by French law. The Parties agree to +endeavor to seek an amicable solution to any disagreements or disputes +that may arise during the performance of the Agreement. + +13.2 Failing an amicable solution within two (2) months as from their +occurrence, and unless emergency proceedings are necessary, the +disagreements or disputes shall be referred to the Paris Courts having +jurisdiction, by the more diligent Party. + + +Version 2.0 dated 2006-09-05. diff --git a/Manulab/Lissage_Spl.m b/Manulab/Lissage_Spl.m new file mode 100644 index 0000000..26a6446 --- /dev/null +++ b/Manulab/Lissage_Spl.m @@ -0,0 +1,22 @@ +function [Out_Freq,Out_dB] = Lissage_Spl (In_Freq ,In_dB) +load Parametres_Affichages +load Parametres_Mesures +Nb_dB = Para_Affi.RF.Nb_dB; +Nb_dB_Affiche = 48; +dbmin = -500; +% Diminution du nbs de point avant le lissage pour eviter +rapport = round(Nb_dB_Affiche*10/Para_Affi.RF.Nb_dB); +liste_f_log = freqoctav(Para_Affi.RF.Fmin*0.3,Para_Mesu.Fs/1.5,Nb_dB_Affiche*10); +liste_db_log = interp1 (In_Freq ,In_dB, liste_f_log,'cubic',dbmin); + +db_log_smooth = smooth(liste_db_log,rapport); + +db_ok2 = db_log_smooth(2 : length(db_log_smooth)-1); %elim ination du 1° et dermier point +f_ok2 = liste_f_log (2 : length(liste_f_log)-1); + +Out_Freq = freqoctav(Para_Mesu.Fmin,Para_Mesu.Fmax,Nb_dB_Affiche); + +Out_dB = interp1(f_ok2,db_ok2,Out_Freq,'cubic',dbmin); + +function [valf]=freqoctav(fmin,fmax,db) +syms nx; nf=floor(log(fmax/fmin)*db/log(2))+2; for i = 1:nf; valf(i) = fmin*2^((i-1)/db); end diff --git a/Manulab/cmsmmshp.m b/Manulab/cmsmmshp.m new file mode 100644 index 0000000..9241f56 --- /dev/null +++ b/Manulab/cmsmmshp.m @@ -0,0 +1,33 @@ +%Fréquences de résonance issues de la mesure +frhp=20; % fréquence de résonance du Hp seul +frb=35; % fréquence de résonance du Hp sur caisson clos +frhpm=14; % fréquence de résonance du Hp + masse ajoutée +frbm=23.12; %fréquence de résonance du Hp sur caisson clos + masse ajoutée + +%Pulsations correspondantes +omrhp=2*pi*frhp; +omrb=2*pi*frb; +omrhpm=2*pi*frhpm; +omrbm=2*pi*frbm; + +%Données Physiques +sd=352e-4; %Surface de la membrane m2 +V=0.037%(0.395-0.06)^3-0.001; % Volume du caisson clos m3 +Ma=0.181 %masse ajoutée kg + +kb=1.4*1.0135e5/V*sd^2; %Raideur du caison clos N/m + +disp('Détermination HP seul et caisson clos') +Cms1=1/kb*(omrb^2/omrhp^2-1) +%mms1=1/omr^2/Cms +Mms1=1/omrb^2*(1/Cms1+kb) +% frth=1/2/pi/sqrt(0.1353*0.52e-3) +% frm=1/2/pi/sqrt(Cms*mms1) + +disp ('Détermination HP seul et HP + masse') +Mms2=Ma/(omrhp^2/omrhpm^2-1) +Cms2=1/(Mms2+Ma)/omrhpm^2 + +disp('Détermination HP + masse et Hp clos') +Mms3=(kb+Ma*omrhpm^2)/(omrb^2-omrhpm^2) +Cms3=1/(Mms3+Ma)/omrhpm^2 \ No newline at end of file diff --git a/Manulab/fonc_trans_recup.m b/Manulab/fonc_trans_recup.m new file mode 100644 index 0000000..0d4c1e0 --- /dev/null +++ b/Manulab/fonc_trans_recup.m @@ -0,0 +1,23 @@ +function [RI,spec] = fonctrans_recup(filename); +%calcul d'une fonction de tranfert mesurée par l'interface CNACQ +%Sorties : fonction de transfert et réponse impulsionnelle +load (filename); + +% soustraction de la composante continue +DC=mean(sig_mes,1); +sig_mes=sig_mes-DC; +S=size(sig_mes); +NT=S(1); +Freq =logspace(log10(f_min), log10(f_max), NT)'; +excinv=sig_exc(NT:-1:1).*f_min./Freq; +[RI,spec] = fconv(sig_mes,excinv); +plot(sig_mes,'k'); +hold on +plot(sig_exc,'r') +angleexc=unwrap(angle(fft(sig_exc))); +anglemes=unwrap(angle(fft(sig_mes))); +ang=anglemes-angleexc + 2*pi; +figure +plot(ang) + + diff --git a/Manulab/gene_chirp.m b/Manulab/gene_chirp.m new file mode 100644 index 0000000..06001c4 --- /dev/null +++ b/Manulab/gene_chirp.m @@ -0,0 +1,66 @@ +function gene_chirp + +load Parametres_Mesures + +Size = 2^Para_Mesu.Prec ; +Para_Mesu.Tps = (Size/Para_Mesu.Fs) % Tps de Mesure +Time = [0:Size-1]./Para_Mesu.Fs ; % Decalage de la Data.Fmini +Freq = logspace(log10(Para_Mesu.Fmin), log10(Para_Mesu.Fmax), Size) ; +w1 = 2*pi*Para_Mesu.Fmin; +w2 = 2*pi*Para_Mesu.Fmax; +Stimulus = .9 *sin((w1*Para_Mesu.Tps)/log(w2/w1) * (exp(Time'/Para_Mesu.Tps*log(w2/w1))-1)) ; +L = floor(Size/100)*2 ; +Window = flattop(L) ; +Calc_Theo.Stimulus = [Window(1:L/2); ones(Size-L,1); Window(L/2+1:L)].*Stimulus; +Calc_Theo.St_inv = Stimulus([Size:-1:1]) .* (Para_Mesu.Fmin./Freq') ; +Calc_Theo.Freq = Freq'; +wavwrite(Calc_Theo.Stimulus,Para_Mesu.Fs ,16,'chirplog') +% Application du niveau de Mesure +% Calc_Theo.Stimulus = Calc_Theo.Stimulus * 10^(Para_Mesu.Nive/20) ; + +% Calcul de la reponse Impulse Theorique +% Calc_Theo.Parfait.IR = fconv(Calc_Theo.Stimulus, Calc_Theo.St_inv) ; + +% Calcul de la FFT +% Calc_Theo.Parfait.FFT = 20*log10(abs(fft(Calc_Theo.Parfait.IR))) ; + +% Calcul de l'échelle des fréquences +% Calc_Theo.Parfait.Fr = Para_Mesu.Fs/(length(Calc_Theo.Parfait.FFT)) ; +% Calc_Theo.Parfait.Freq = 0:Calc_Theo.Parfait.Fr:Para_Mesu.Fs-Calc_Theo.Parfait.Fr ; + +% Calcul de courbe de reponse avec Fenetrage Tempo +% [Val,Num_Max_Par] = max(abs(Calc_Theo.Parfait.IR)) ; +% Nombres_Ech = round(Para_Mesu.Tps_Fen/1000*Para_Mesu.Fs) ; +% Ech_Min_Par = round(Num_Max_Par-Nombres_Ech) ; +% Ech_Max_Par = round(Ech_Min_Par+2*Para_Mesu.Tps_Fen/1000*Para_Mesu.Fs) ; +% IR_Par_Fen = Calc_Theo.Parfait.IR(Ech_Min_Par:Ech_Max_Par) ; +% Calc_Theo.Parfait.FFT_Fen = 20*log10(abs(fft(IR_Par_Fen))) ; + +% Calcul de l'échelle des fréquences +% Calc_Theo.Parfait.Fr_Fen = Para_Mesu.Fs/(length(Calc_Theo.Parfait.FFT_Fen)) ; +% Calc_Theo.Parfait.Freq_Fen = 0:Calc_Theo.Parfait.Fr_Fen:Para_Mesu.Fs-Calc_Theo.Parfait.Fr_Fen ; + +% Fenetrage tempo des THD +% IR = Calc_Theo.Parfait.IR; +% Decal = round((length(IR)/(2^15*2)*(32610-29865))/1.3);% 30% de marge +% [a,Num_Max] = max(abs(IR)); +% Fen = blackman(Decal*2); Demi_Fen = Fen(1:Decal)'; Num_Debut = Num_Max-Decal; +% Debut = zeros(1,Num_Debut); Nbs_Ones = length(IR)-length(Debut)-length(Demi_Fen); Fin = ones(1,Nbs_Ones); +% Fenetre = [Debut Demi_Fen Fin]'; +% IR_Sans_THD = Fenetre.*IR; +% Calc_Theo.Parfait.IR_Sans_THD = IR_Sans_THD; + +% Calcul de la FFT +% Calc_Theo.Parfait.FFT_Sans_THD = 20*log10(abs(fft(Calc_Theo.Parfait.IR_Sans_THD))) ; + + +save Calculs_Theoriques Calc_Theo + + + + +function [window] = flattop(N) +a1 = -1.93; a2 = 1.29; a3 = -0.388; a4 = 0.028; temp = [1:N]'/N; window = 1 + a1*cos(2*pi*temp) + a2*cos(4*pi*temp) + a3*cos(6*pi*temp) + a4*cos(8*pi*temp); window = window/max(window); + +function [New_sign, Fs] = fconv(Old_sign, Cvfilter, Fs) +X = fft([Old_sign; zeros(length(Cvfilter)-1, 1)]); Y = fft([Cvfilter; zeros(length(Old_sign)-1, 1)]); New_sign = real(ifft(X.*Y)); diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..048ba60 --- /dev/null +++ b/README.txt @@ -0,0 +1,57 @@ +# README +# ====== + +CNACQ : a Matlab acquisition tool for ASIO + + +# 1. Introduction +# =============== + +CNACQ est un programme de génération, d'émission et d'acquisition de signaux +écrit pour Matlab. Il utilise les cartes son intégrant le protocole ASIO pour +déterminer les fonctions de transfert des systèmes électro-dynamiques. + +Fonctionnalités principales : + +- Générateur de signal (sinus, schip) +- Moniteur temps-réel +- Mesure de fonctions de transfert + + +# 2. Installation +# =============== + +see INSTALL + + +# 3. License +# =============== + +This software is licensed as described in the file COPYING, which +you should have received as part of this distribution. The terms +are also available at http://svn.parisson.org/cnacq/CnacqLicense + + +# 4. Usage +# ========= + +Just open CNACQ.m in Matlab and run it... + + +# 5. Author +# ========= + +Guillaume Pellerin + + +# 6. Aknowledgements +# ================== + +Manuel Melon, Andrew Gadenko, + + +# 7. Contact / Infos +# ================== + +see http://svn.parisson.org/cnacq/ for more details + diff --git a/doc/latex/Manuel_CNACQ.pdf b/doc/latex/Manuel_CNACQ.pdf new file mode 100644 index 0000000..df8e01a Binary files /dev/null and b/doc/latex/Manuel_CNACQ.pdf differ diff --git a/doc/latex/Manuel_CNACQ.tex b/doc/latex/Manuel_CNACQ.tex new file mode 100644 index 0000000..fc66192 --- /dev/null +++ b/doc/latex/Manuel_CNACQ.tex @@ -0,0 +1,229 @@ +\documentclass[pdftex,11pt,a4paper,twoside]{article} + +\usepackage{article_profile} +%\graphicspath{{/figures}} + +%================================================================== +% Page de garde +%================================================================== + +\title{\begin{flushright} + \rule{17cm}{1mm}\\ + \vspace{8mm} + \huge{\bf{Manuel du logiciel CNACQ}}\\ + \vspace{4mm} + \rule{17cm}{1mm}\\ + \large{\today\\} + \large{Version 0.1}\\ + \vspace{3cm} + \end{flushright} + \begin{figure}[h] + \centering + \includegraphics[width=12cm]{img/cnacq-01} + \end{figure} + \vspace{3cm} +} + +\author{\textbf{Guillaume Pellerin$^1$}\\ + \vspace{0.5cm} + \small{ + $^1$ Laboratoire d'Acoustique, Conservatoire National des Arts et Métiers\\ + 5 rue du Vert Bois 75003 Paris, France\\ <\href{mailto:guillaume.pellerin@cnam.fr}{guillaume.pellerin@cnam.fr}>\\ + \vspace{0.5cm} + }} + + + +\begin{document} + +\maketitle + +\newpage +\tableofcontents + +\begin{figure}[b] + \includegraphics[width=4cm]{img/logo_cnam.png} + \large{Copyright (C) 2007 Guillaume Pellerin} +\end{figure} + + +%\setcounter{page}{3} + +\cleardoublepage +\setlength{\parindent}{5mm} +\renewcommand{\labelitemi}{$\bullet$} + +\section{Introduction} + +CNACQ est un logiciel dédié à la mesure de fonctions de transfert des systèmes électriques ou électrodynamiques. Ecrit en langage Matlab, il permet d'utiliser une carte d'acquisition audio compatible avec la norme ASIO pour générer un signal de type sinus glissant (<< sweep >> ou << chirp >> en anglais), de quantifier la réponse temporelle du système puis d'en déterminer sa réponse fréquentielle. + +La structure d'analyse de CNACQ utilise la méthode d'Angelo Farina \cite{farina} qui, appliquée dans le domaine numérique, permet d'obtenir des réponses avec un grand nombre d'échantillons, même à très basse fréquence, tout en suivant les harmoniques créés au cours du glissement en fréquence. Le calcul est en effet basé sur un produit de convolution dont la transformée de Fourier comporte le même nombre de points que le nombre d'échantillons dans le signal mesuré. Outre le fait que cette technique offre une souplesse d'utilisation supplémentaire par rapport aux autres méthodes, MLS par exemple, elle fournit des résolutions fréquentielles très grandes, notamment aux basses fréquences. Elle rend également très aisée et rapide la déduction des taux de distortions du système mesuré \cite{muller}. + +Le logiciel CNACQ offre ainsi une interface interactive pour mesurer et calculer les fonctions de transfert directement dans Matlab. Il s'inspire pour certaines idées du logiciel libre QLoud \cite{qloud} fonctionnant sur système GNU/Linux. + + +\section{Licence} + +Ce logiciel libre CNACQ est régi par la licence CeCILL soumise au droit français et +respectant les principes de diffusion des logiciels libres. Vous pouvez +utiliser, modifier et/ou redistribuer ce programme sous les conditions +de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA +sur le site \url{http://www.cecill.info}. + +En contrepartie de l'accessibilité au code source et des droits de copie, +de modification et de redistribution accordés par cette licence, il n'est +offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, +seule une responsabilité restreinte pèse sur l'auteur du programme, le +titulaire des droits patrimoniaux et les concédants successifs. + +A cet égard l'attention de l'utilisateur est attirée sur les risques +associés au chargement, à l'utilisation, à la modification et/ou au +développement et à la reproduction du logiciel par l'utilisateur étant +donné sa spécificité de logiciel libre, qui peut le rendre complexe à +manipuler et qui le réserve donc à des développeurs et des professionnels +avertis possédant des connaissances informatiques approfondies. Les +utilisateurs sont donc invités à charger et tester l'adéquation du +logiciel à leurs besoins dans des conditions permettant d'assurer la +sécurité de leurs systèmes et ou de leurs données et, plus généralement, +à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. + +Le fait que vous puissiez accéder à cet en-tête signifie que vous avez +pris connaissance de la licence CeCILL, et que vous en avez accepté les +termes. + + +\section{Téléchargement} + +CNACQ est librement téléchargeable à l'adresse suivante : \url{http://svn.parisson.org/cnacq/} où il est conseillé de choisir la dernière version. + +Pour obtenir la version de développement, il est nécessaire d'utiliser le logiciel Subversion\footnote{\url{http://subversion.tigris.org/}} et d'utiliser la commande : +\begin{verbatim} + svn co https://svn.parisson.org/svn/CNACQ/trunk CNACQ +\end{verbatim} + + +\section{Dépendances} + +\begin{itemize} +\item Microsoft Windows\circledR~~(>= 2000). +\item MATLAB\circledR~~(>= 6.0). +\item Une carte audio compatible ASIO et ses pilotes ASIO installés.\\ +\end{itemize} + +CNACQ utilise deux principes pour converser avec la carte d'acquisition. D'une part, les fonctions d'émission du générateur propres à Matlab sur la base du driver \textit{Winsound} permettent d'utiliser le monitoring graphique en parallèle de l'émission. D'autre part, les librairies \textit{pa-wavplay} \cite{pawavplay} utilisant la norme ASIO facilitent le calcul des fonctions de transfert grâce à une taille de tampon mémoire mieux gérée. + + +\section{Lancement}\label{lancement} + +%Dans cette documentation, nous considérerons que le dossier décompressé de l'application se trouve à l'addresse \texttt{C:\CNACQ}. Si l'application a été décompréssée dans un autre dossier, modifier les exemples suivants en conséquence. + +\begin{enumerate} + \item Démarrer Matlab. + \item Exécuter le fichier CNACQ.m depuis le dossier décompressé de l'application CNACQ, par exemple \verb|C:\CNACQ|. Avant de démarrer, l'application demande de fournir un dossier de travail. Ce dossier peut être vide mais doit exister (le créer dans l'explorateur si nécessaire avec un nom explicite) : il intégrera l'ensemble des fichiers sauvegardés pendant les mesures. Une fenêtre semblable à la figure \ref{cnacq_default} doit alors s'afficher. + + \begin{figure}[htbp] + \centering + \includegraphics[width=12cm]{img/cnacq_02} + \caption{Fenêtre de démarrage par défaut du logiciel CNACQ.} + \label{cnacq_default} + \end{figure} + + \item Remplir les champs << Nom d'utilisateur >> et << Commentaires >>. + \item Démarrer le vu-mètre stereo : \verb|C:\CNACQ\vu-meters\meterV.exe|. +\end{enumerate} + + +\section{Détails de l'interface} + +L'interface graphique de CNACQ comporte 6 blocs principaux dont voici les descriptions : + +\begin{description} + \item[Données :] les données générales de la prochaine mesure : le nom de groupe (à remplir), les commentaires (optionnels), le dossier de travail à choisir (bouton \textbf{Browse}), la fréquence d'échantillonnage \textbf{$F_s$} en Hz et le nombre de bits \textbf{Nbits} de la quantification.\\ + + \item[Infos :] les informations de copyright et de version de l'application utilisée.\\ + + \item[Moniteur :] les fenêtres d'affichage en temps réel des signaux entrant par la voie n°1. Au démarrage, l'affichage est désactivé. La première fenêtre est la forme d'onde temporelle du signal par blocs de 1 s et la deuxième le module de la transformée de Fourier de chaque bloc numérisé. Cette fonction est démarrée en appuyant sur le bouton \textbf{ON/OFF} et stoppée de la même manière.\\ + \textbf{Remarque :} les fonctions d'affichage de Matlab imposent une priorité maximale de l'affichage de CNACQ lorsque le moniteur est enclenché. Pour pouvoir intervenir sur d'autres fenêtres dans l'environnement Windows, il est donc nécessaire de \textbf{stopper le moniteur}.\\ + + \item[Voies :] les voies entrantes et sortantes utilisées de la carte d'acquisition et leurs gains associées dans l'intervalle $[0;1]$.\\ + + \item[Générateur : ] les fonctions permettant de générer un signal et de le jouer à travers les voies choisies.\\ + Si le type de signal est un \textbf{sinus}, sa fréquence est déterminé par la valeur du curseur \textbf{Fréquence} et sa durée par la valeur du curseur \textbf{Durée}. Les bornes de chaque curseur sont déterminées par les valeurs indiquées dans les champs latéraux.\\ + Si le type de signal est un \textbf{chirp}, un sinus à fréquence glissante logarithmique est généré. Ses bornes sont celles du curseur de fréquence.\\ + L'émission du signal déterminé est effectuée en cliquant sur le bouton \textbf{TRIG}. Noter qu'il est possible d'émettre un signal tout en visualisant la réponse du système étudié sur le moniteur.\\ + + \item[Mesure :] les fonctions de mesure de fonctions de transfert selon la méthode de Farina.\\ + Les valeurs des bornes fréquentielles pour la génération du chirp ainsi que sa durée sont issues de celles du bloc Générateur.\\ + Le bouton \textbf{TRIG} lance la mesure et affiche les résultats temporels (réponse temporelle et réponse impulsionnelle) et fréquentiels (module et phase) dans de nouvelles fenêtres pour chaque voie.\\ + Le bouton \textbf{Sauver} sauvegarde l'ensemble des paramètres de la fenêtre, le signal émis ainsi que tous les signaux temporels mesurés dans un fichier de type MAT dans le dossier de travail. Le nom de ce fichier comporte le nom du groupe et l'\textbf{ID} de la mesure. Cette valeur s'incrémente automatiquement après chaque sauvegarde. +\end{description} + + +\section{Première mesure} + +Voici une chronologie des étapes à suivre pour la mesure d'une fonction de transfert, après avoir effectué celles du paragraphe \ref{lancement}. + +\begin{enumerate} + \item Choisir la fréquence d'échantillonnage et le nombre de bits de quantification. + \item Choisir les voies d'entrée et de sortie ainsi que les gains associés\footnote{Pour une émission, seul le gain de sortie est influant.}. On ne doit JAMAIS dépasser 0 dB en entrée. Le vu-mètre externe permet de le contrôler. + \item Régler les paramètres du générateur qui détermineront ceux de la mesure (intervalles, durée, etc...). + \item Régler les appareils intermédiaires (amplis, filtres) en utilisant le générateur et le moniteur. Ne pas dépasser 0 dB au vu-mètre. + \item Effectuer la mesure à l'aide du bouton \textbf{TRIG} du bloc Mesure. + \item Sauvegarder éventuellement la mesure en cliquant sur le bouton \textbf{Sauver}. +\end{enumerate} + + +\section{Dépouillement} + +\subsection{Récupérer une mesure}\label{depouillement_1} +Outre les résultats bruts affichés après chaque mesure, il est possible d'analyser plus profondément les résultats grâce au langage Matlab. Il suffit de rappeler le fichier sauvegardé de type MAT depuis le dossier de travail à l'aide de la fonction \textbf{load}. Par exemple, si le fichier se nomme \verb|Durand_89.mat| et se trouve dans le dossier \verb|D:\Durand|, exécuter : + +\begin{verbatim} +load(D:\Durand\Durand_89.mat) +\end{verbatim} + +Toutes les variables ainsi que les signaux temporels mesurés sont alors disponibles en mémoire pour être traîtés (voir la fenêtre \textbf{Workspace}). Voici une liste non-exhaustive des paramètres et des signaux récupérés : + +\begin{description} + \item[\texttt{comment} :] le commentaire textuel associé à la mesure. + \item[\texttt{f\_lin} :] le vecteur fréquentiel utilisé pour le tracé des fonctions de transfert. + \item[\texttt{f\_log} :] le vecteur fréquentiel utilisé pour la définition du sinus glissant logarithmique. + \item[\texttt{f\_max} :] la fréquence maximale mesurée. + \item[\texttt{f\_min} :] la fréquence minimale mesurée. + \item[\texttt{f\_s} :] la fréquence d'échantillonnage. + \item[\texttt{file} :] l'adresse du fichier de mesure sauvegardé dans le système de fichier. + \item[\texttt{gain\_in} :] la valeur du gain d'entrée en dB au cours de la mesure. + \item[\texttt{gain\_out} :] la valeur du gain de sortie en dB au cours de la mesure. + \item[\texttt{groupe} :] le nom du groupe de travail. + \item[\texttt{home\_dir} :] le dossier de travail. + \item[\texttt{id} :] le numéro d'identification de la mesure sauvegardée. + \item[\texttt{nbits} :] le nombre de bits de quantification. + \item[\texttt{sig\_exc} :] le tableau des valeurs du signal d'excitation (mono-colonne). + \item[\texttt{sig\_mes} :] le tableau des valeurs des signaux mesurés (éventuellement multi-colonne). + \item[\texttt{time} :] la durée de la mesure en secondes. + \item[\texttt{voices\_in} :] les numéros des voies d'entrée de la carte d'acquisition choisies pour la mesure. + \item[\texttt{voices\_out} :] les numéros des voies de sortie de la carte d'acquisition choisies pour la mesure. + \end{description} + +\subsection{Aide}\label{depouillement_2} +Deux commandes fondamentales permettent de trouver/retrouver une commande Matlab : +\begin{itemize} + \item \textbf{lookfor} : pour chercher un commande a l'aide d'un mot clé. Par exemple : + \begin{verbatim} + lookfor plot + \end{verbatim} + \item \textbf{help} : pour afficher l'aide textuelle d'une commande connnue. Par exemple : + \begin{verbatim} + help plot + \end{verbatim} +\end{itemize} + +\subsection{Octave} +Lorsqu'aucune licence Matlab n'est disponible (chez soi par exemple), il est possible d'utiliser le logiciel libre et gratuit \textbf{Octave} \cite{octave} pour l'analyse des mesures. Ce logiciel, bien que moins complet que Matlab, dispose des mêmes fonctions principales que lui et surtout du même langage ! On peut donc - après avoir téléchargé, installé et démarré Octave - récupérer les mesures muni du fichier de sauvegarde .mat et exécuter directement les commandes vues aux paragraphes \ref{depouillement_1} et \ref{depouillement_2}. + +\newpage +\bibliographystyle{apalike} +\nocite{*} +\bibliography{biblio_cnacq} + +\end{document} \ No newline at end of file diff --git a/doc/latex/article_profile.sty b/doc/latex/article_profile.sty new file mode 100644 index 0000000..b0791bf --- /dev/null +++ b/doc/latex/article_profile.sty @@ -0,0 +1,321 @@ +\usepackage[pdftex]{graphicx} + +%\usepackage{graphicx} +%\usepackage{mltex} + +\usepackage[body={17cm, 25cm}]{geometry} +%,left=2cm,right=2cm + % Geometry package for easy page margin + % setup +%\usepackage{epsfig} +%\usepackage{rotating} % Sideways of figures & tables +%\usepackage[sectionbib]{natbib} % Cross-reference package (Natural BiB) +%\usepackage{chapterbib} % Put References at the end of each chapter + % Do not put 'sectionbib' option here. + % Sectionbib option in 'natbib' will do. +\usepackage{fancyhdr} % Fancy Header and Footer +%\usepackage{setspace} % Line spacing +%\doublespacing +%\usepackage{txfonts} % Public Times New Roman text & math font +\usepackage{newcent} +\usepackage[latin1]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{epstopdf} +\usepackage[usenames,dvipsnames]{color} +\usepackage[tight,centerlast,sc,small]{subfigure} +\usepackage{latexsym} +\usepackage{amsthm} +\usepackage{makeidx,xspace} +\usepackage{newlfont} +\usepackage{amssymb} +\usepackage{amsfonts} +\usepackage[centertags]{amsmath} +% \usepackage{apalike} +\usepackage{multicol} +\usepackage{setspace} +\usepackage{lgrind} +\usepackage[francais]{babel} + +\usepackage{url} +\urlstyle{small} +%\selectlanguage{french} + + %%% Fancy Header %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % Fancy Header Style Options +\pagestyle{fancy} % Sets fancy header and footer +\fancyfoot{} % Delete current footer settings +\renewcommand{\sectionmark}[1]{ % Lower Case Chapter marker style +\markboth{\thesection.\ #1}{}} % +\renewcommand{\subsectionmark}[1]{ % Lower case Section marker style +\markright{\thesubsection.\ #1}} % +\fancyhead[LE,RO]{\bfseries\thepage} % Page number (boldface) in left on even + % pages and right on odd pages +\fancyhead[RE]{\footnotesize{\bfseries\leftmark}} % Chapter in the right on even pages +\fancyhead[LO]{\footnotesize{\bfseries\rightmark}} % Section in the left on odd pages +\renewcommand{\headrulewidth}{0.3pt} % Width of head rule + +% pb odd/even pages with twosides +\setlength{\oddsidemargin}{0cm} +\setlength{\evensidemargin}{\paperwidth} +\addtolength{\evensidemargin}{-\textwidth} +\addtolength{\evensidemargin}{-2.0in} +\addtolength{\evensidemargin}{-\oddsidemargin} + +% Another issue that will arise when using double-sided pages is that'll you'll +% likely want all chapters to start on a right-hand (odd) page; however, the +% previous chapter may occasionally end on an odd page, meaning that the next +% free page is even. Thus, I added the lines +% to have real blank page +% +% \makeatletter +% \def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else% +% \hbox{}% +% \thispagestyle{empty} +% \newpage% +% \if@twocolumn\hbox{}\newpage\fi\fi\fi} +% \makeatother + +% \usepackage[pdftex]{color} + +% PDF Link colors +\definecolor{refcolor}{rgb}{0,0,0.4} % Color for the reference links +\definecolor{anchorcolor}{rgb}{0,0,0} % Color for anchor text +\definecolor{citecolor}{rgb}{0,0,0.4} % Color for bibligraphical citations +\definecolor{urlcolor}{rgb}{0,0,0.4} % Color for linked URLs +\definecolor{filecolor}{rgb}{0.75,0,0} % Color for URLs which open local files +\definecolor{menucolor}{rgb}{0.75,0,0} % Color for Acrobat menu items +\definecolor{pagecolor}{rgb}{0.75,0,0} % Color for links to other pages + +\usepackage[bookmarksopen,bookmarksnumbered,colorlinks,hyperindex,pagebackref,breaklinks, +pdftitle={Modal analysis applied to modelling of loudspeaker systems}, +pdfauthor={Guillaume Pellerin}, +pdfsubject={Article draft for the JAES}, +pdfkeywords={acoustics, modal analysis, vented box, directivity}, +hyperfigures=true, % provide links to figures +hyperindex=true, % provide links from index to pages (broken?) +pagebackref=true, % provide links to pages where bib is cited from +backref=page, % provide links to sec where bib is cited from +colorlinks=true, %*** +linkcolor=refcolor, % +anchorcolor=anchorcolor, % +citecolor=citecolor, % Colors are defined above; +filecolor=filecolor, % change them there +menucolor=menucolor, % +pagecolor=pagecolor, % +urlcolor=urlcolor, %*** +bookmarksopen=true, % whether to open bookmarks window on open +pdfpagemode=UseOutlines, % show the bookmarks in outline form +pdfstartview=FitBH, % default window sizing +pdfview=FitBH]{hyperref} % default view after clicking a link + +%\usepackage[bookmarksopen,bookmarksnumbered,colorlinks,hyperindex,pagebackref,breaklinks]{hyperref} +%\usepackage[bookmarksopen,colorlinks,pagebackref,linktocpage]{hyperref} +%\usepackage[monochrome]{color} +%\definecolor{links}{rgb}{0.9,0.0104,0.7716} % BlueViolet +%\def\LinkColor{links} +%\definecolor{anchors}{rgb}{0.5812,0.0665,0.0659} % IndianRed +%\def\AnchorColor{anchors} + +\usepackage{amsmath} + +%\usepackage{xthesis} %DAL Thesis Style +%\usepackage{xtocinc} %Include Table of Contents as the first entry in TOC +% Faculty of Grad Studies insists on this!? +%\usepackage[active]{srcltx} %SRC Specials for DVI search + +\newcommand\address[1]{} +\newcommand\netaddress[1]{} +%\usepackage{shortvrb} +%\MakeShortVerb{\|} +\newcommand{\file}[1]{\texttt{#1}} +\newcommand{\Lopt}[1]{\textsf{#1}} +\newcommand{\babel}{\textsf{babel}} +\makeatletter +\DeclareGraphicsExtensions{.pdf,.jpg,.png,.tif,.tiff,.JPG} + +%Titre +\renewcommand{\maketitle}{ + \begin{titlepage} + \vspace{5cm} + \textsf{\@title} + \centering + \large{\@author} + \rule{17cm}{0.5mm}\\ + \small{Version électronique type PDF avec hypertexte :}\\ + \footnotesize{\url{http://svn.parisson.org/cnacq/browser/trunk/doc/latex/Manuel_CNACQ.pdf?format=raw}} + \end{titlepage} +} + + + + +%\newif\ifpdf +%\ifx\pdfoutput\undefined +%\pdffalse % we are not running PDFLaTeX +%\else +%\pdfoutput=1 % we are running PDFLaTeX +%\pdftrue \fi +% +%\ifpdf + +%\else +%\usepackage{graphicx} +%\fi + +%================================================================== +% GRAPHICS +%\graphicspath{} +%\setcounter{section}{0} +\setcounter{secnumdepth}{5} +\setcounter{tocdepth}{5} +\setcounter{totalnumber}{4} +%\renewcommand{\floatpagefraction}{0.9} +\renewcommand{\textfraction}{0.1} +\setlength{\abovecaptionskip}{0.2cm} +\setlength{\belowcaptionskip}{0.2cm} +% Different font in captions +\newcommand{\captionfonts}{\small\it} + +\makeatletter % Allow the use of @ in command names +\long\def\@makecaption#1#2{% + \vskip\abovecaptionskip + \sbox\@tempboxa{{\captionfonts #1: #2}}% + \ifdim \wd\@tempboxa >\hsize + {\captionfonts #1: #2\par} + \else + \hbox to\hsize{\hfil\box\@tempboxa\hfil}% + \fi + \vskip\belowcaptionskip} +\makeatother % Cancel the effect of \makeatletter + + +% compress the PDF as much as possible +%\pdfcompresslevel=9 + +%Raccourcis============================================= +\newcommand{\cad}{c'est-à-dire } +\newcommand{\hp}{haut-parleur } +\newcommand{\hps}{haut-parleurs } +\newcommand{\edyn}{électrodynamique } + +\newcommand{\hpf}{haut-parleur} +\newcommand{\hpsf}{haut-parleurs} +\newcommand{\edynf}{électrodynamique} +\renewcommand{\labelitemi}{$\blacktriangleright$} +\renewcommand{\labelitemii}{$\bullet$} + +%MATHS=============================================================== +\newcommand{\A}{{\cal A}} +\newcommand{\h}{{\cal H}} +\newcommand{\s}{{\cal S}} +\newcommand{\W}{{\cal W}} +\newcommand{\BH}{\mathbf B(\cal H)} +\newcommand{\KH}{\cal K(\cal H)} +\newcommand{\Real}{\mathbb R} +\newcommand{\Complex}{\mathbb C} +\newcommand{\Field}{\mathbb F} +\newcommand{\RPlus}{[0,\infty)} +\newcommand{\norm}[1]{\left\Vert#1\right\Vert} +\newcommand{\essnorm}[1]{\norm{#1}_{\text{\rm\normalshape ess}}} +\newcommand{\abs}[1]{\left\vert#1\right\vert} +\newcommand{\set}[1]{\left\{#1\right\}} +\newcommand{\seq}[1]{\left<#1\right>} +\newcommand{\eps}{\varepsilon} +\newcommand{\To}{\longrightarrow} +\newcommand{\RE}{\operatorname{Re}} +\newcommand{\IM}{\operatorname{Im}} +\newcommand{\Poly}{{\cal{P}}(E)} +\newcommand{\EssD}{{\cal{D}}} +\newcommand{\Df}[2]{\frac{\partial #1}{\partial #2}} +\newcommand{\df}{\partial} + +\newcommand{\boxeqn}[1]{% + \[\fbox{% + \addtolength{\textwidth}{-2\fboxsep}% + \addtolength{\textwidth}{-2\fboxrule}% + \begin{minipage}{\textwidth}% + #1% + \end{minipage}% + }\]% + } + +%THEOREMS============================================================== +\newtheorem{theorem}{Theorem} +\newtheorem{corollary}[theorem]{Corollary} +\newtheorem{definition}{Definition} +\theoremstyle{plain} +\newtheorem{thm}{Theorem}[section] +\newtheorem{cor}[thm]{Corollary} +\newtheorem{lem}[thm]{Lemma} +\newtheorem{prop}[thm]{Proposition} +\theoremstyle{definition} +\newtheorem{defn}{Definition}[section] +\theoremstyle{remark} +\newtheorem{rem}{Remark}[section] +\numberwithin{equation}{section} +\renewcommand{\theequation}{\thesection.\arabic{equation}} + +%================================================================== +% spécification de la mise en page +%================================================================== +% Préambule perso simulant le style road sans avoir besoin +% du fichier road.sty : de ce fait les .tex sont standards. +%================================================================== +% +% Gestion entête/pied de page +% +%\newcommand{\footrulewidth}{0.4pt} % footline visible +\setlength{\headheight}{30pt} % more space for the head +%% +%\lhead{\scriptsize \sc \rightmark} +%\chead{} +%\rhead{{\sc Cours ENSTA MF307}} +%\lfoot{Initiation à la simulation numérique en mécanique des fluides} +%\cfoot{} +%\rfoot{\thepage} +% +% Mise en page spéciale type road.sty +% +%\mathindent=2cm % eqn at 2cm from the left margin +%\parskip 1.4ex plus 0.3ex minus 0.2ex % extra space will precede each paragraph +%\setlength{\parindent}{7mm} % no indentation for paragraph +%\tabcolsep 0.4em % space between two col +%\fboxsep2mm % ibid for box +%\renewcommand{\arraystretch}{1.15} % more space in tables +%\arrayrulewidth0.1pt % more space in thin lines +%\doublerulesep=0pt % no space between double lines +%\hfuzz=1pt % less errors for horizontal box +%\vfuzz=1pt % ibid for vertical box +%\sloppy % less errors for hyphenation +%% +%================================================= Fin entête +% +%\def\tens#1{\overline{\overline{#1}}} % tenseur in eqn-environment + +%\usepackage[french]{babel} +%\selectlanguage{french} + + +% Modif appel de citations biblio : on tolere la cesure +% """"""""""""""""""""""""""""""""""""""""""""""""""""" +\makeatletter + +\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi + \let\@citea\@empty + \@cite{\@for\@citeb:=#2\do + {\@citea\def\@citea{,\penalty\@m\ }% + \def\@tempa##1##2\@nil{\edef\@citeb{\if##1\space##2\else##1##2\fi}}% + \expandafter\@tempa\@citeb\@nil + \@ifundefined{b@\@citeb}{{\reset@font\bf ?}\@warning + {Citation `\@citeb' on page \thepage \space undefined}}% +% \hbox{\csname b@\@citeb\endcsname}}}{#1}} + {\csname b@\@citeb\endcsname}}}{#1}} +\makeatother +% """"""""""""""""""""""""""""""""""""""""""""""""""""" + +% NOTATIONS +%\def\listofnotations{\input bonus/notations.tex} +%\def\addnotation #1 #2{$#1$ \> #2\\} + +%\def\newnot#1{\label{#1}} + diff --git a/doc/latex/biblio_cnacq.bib b/doc/latex/biblio_cnacq.bib new file mode 100644 index 0000000..cac0971 --- /dev/null +++ b/doc/latex/biblio_cnacq.bib @@ -0,0 +1,45 @@ + +@InProceedings{farina, + author = {A. Farina}, + title = {Simultaneous Measurement of Impulse Response and Distortion with a Swept-Sine Technique}, + organization = {Presenté à la $108^e$ Convention de l'Audio Engineering Society, Paris, France}, + year = {2000}, + month = {february}, + note = {preprint 5093}, + } + +@ARTICLE{muller, + AUTHOR = {S. Müller and P. Massarani}, + TITLE = {Transfert-Function Measurement with Sweeps}, + YEAR = {2001}, + JOURNAL = {J. Audio Eng. Soc.}, + volume = {49}, + pages = {443-471}, + month = {June}, +} + +@Manual{qloud, +title = {QLoud}, +author = {A. Gaydenko}, +address = {\url{http://gaydenko.com/qloud/}}, +note = {Logiciel}, +year = {2007} +} + +@Manual{pawavplay, +title = {pa-wavplay}, +author = {M. Frear}, +address = {\url{http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4017}}, +note = {Librairies ASIO}, +year = {2003} +} + +@Manual{octave, +title = {Octave}, +author = {J. W. Eaton and Contributors}, +address = {\url{http://www.gnu.org/software/octave/octave.html}}, +note = {Logiciel}, +year = {1998-2007} +} + + diff --git a/doc/latex/img/cnacq_01.png b/doc/latex/img/cnacq_01.png new file mode 100644 index 0000000..4f70a9d Binary files /dev/null and b/doc/latex/img/cnacq_01.png differ diff --git a/doc/latex/img/cnacq_02.png b/doc/latex/img/cnacq_02.png new file mode 100644 index 0000000..7328e70 Binary files /dev/null and b/doc/latex/img/cnacq_02.png differ diff --git a/pa_wavplay/pa_wavplay usage instructions.txt b/pa_wavplay/pa_wavplay usage instructions.txt new file mode 100644 index 0000000..8f3b630 --- /dev/null +++ b/pa_wavplay/pa_wavplay usage instructions.txt @@ -0,0 +1,11 @@ + +To play audio: +pa_wavplay(buffer, [samplerate], [deviceid], [devicetype]); + +To record audio: +inputbuffer = pa_wavrecord(channels, nsamples, [samplerate], [deviceid], [devicetype]); + +To play and record audio simultaneously: +inputbuffer = pa_wavplayrecord(playbuffer,[playdevice],[samplerate], [recnsamples], [recchannels], [recdevice],[devicetype]) + +see help for each of these commands for much more information. \ No newline at end of file diff --git a/pa_wavplay/pa_wavplay.m b/pa_wavplay/pa_wavplay.m new file mode 100644 index 0000000..9bcb4c9 --- /dev/null +++ b/pa_wavplay/pa_wavplay.m @@ -0,0 +1,97 @@ +function pa_wavplay(varargin) +% pa_wavplay: playback a matrix to multichannel sound hardware +% +% Usage: pa_wavplay([devicetype]) +% pa_wavplay(buffer, [samplerate], [deviceid], [devicetype]) +% +% pa_wavplay is a tool for playing multi-channel audio through your ASIO +% device. Arguments in [] are optional +% +% pa_wavplay([devicetype]) will list all your audio devices for that +% device type then exit. +% +% - buffer is the matrix to play +% - samplerate is the sampling frequency. Default: 44100 +% - deviceid is the device id to use for output. Default: 0 +% - devicetype determines which sound driver to use +% 'win' Windows Multimedia Device +% 'dx' DirectX DirectSound driver +% 'asio' ASIO Driver (default) +% +% For stereo playback, buffer should be an N-by-2 matrix. The number of +% audio channels supported is hardware dependent. +% +% samplerate should be a valid integer sample rate, eg. 22050 44100 etc. +% +% As of pa_wavplay 0.2, buffer should be either of type double or +% single. pa_wavplay uses 32-bit floats (single) internally. +% +% SEE ALSO: pa_wavrecord, pa_wavplayrecord + +% check right num of args +error(nargchk(0,4,nargin)); + +% defaults +device_opt = 1; +device = 0; +fs = 44100; + +% no args, print devices for asio +if (nargin==0) + pawavplaya; + return; +end + +% if devtype specified +if ischar(varargin{end}), + s=varargin{end}; + varargin(end)=[]; + + device_opt = strmatch(s,{'asio','win', 'dx'}); + if isempty(device_opt), + error(['Unrecognized DEVICETYPE: ' s]); + end + + if (nargin==1) + if device_opt==1, % asio + pawavplaya; + end + if device_opt==2, % win + pawavplayw; + end + if device_opt==3, % dx + pawavplayx; + end + return; + end +end + +% data buffer +y = varargin{1}; + +% sample rate +if length(varargin)>=2, + fs=varargin{2}; +end + +% device id +if length(varargin) >= 3, + if (~(ischar(varargin{3}))) + device = varargin{3}; + end +end + +if device_opt==1, % asio + %fprintf('Using ASIO driver\n'); + pawavplaya(y, device, fs, 0, 0, 0, -1); + +elseif device_opt==2, % win + fprintf('Using WMME driver\n'); + pawavplayw(y, device, fs, 0, 0, 0, -1); + +elseif device_opt==3, % dx + fprintf('Using DirectX driver\n'); + pawavplayx(y, device, fs, 0, 0, 0, -1); +end + +% [EOF] pa_wavplay.m \ No newline at end of file diff --git a/pa_wavplay/pa_wavplayrecord.m b/pa_wavplay/pa_wavplayrecord.m new file mode 100644 index 0000000..cfb1e11 --- /dev/null +++ b/pa_wavplay/pa_wavplayrecord.m @@ -0,0 +1,116 @@ +function y = pa_wavplayrecord(varargin) +% pa_wavplayrecord: simultaneous playback & record of multichannel sound +% +% Usage: +% inputbuffer = pa_wavplayrecord(playbuffer,[playdevice],[samplerate], +% [recnsamples], [recfirstchannel], [reclastchannel], +% [recdevice], [devicetype]) +% +% pa_wavplayrecord is a tool for playing and recording multi-channel +% audio through your ASIO device. Arguments in [] are optional +% +% pa_wavplayrecord([devicetype]) will list all your audio devices for +% that device type then exit. +% +% - playbuffer the matrix to play +% - playdevice the device to play it on. Default: 0 +% - samplerate the sampling frequency. Default: 44100 +% - recnsamples the number of samples to record. Default: 0 +% if 0 then we'll record for the duration of playbuffer +% - recfirstchannel the first channel to record from Default: 1 +% - reclastchannel the last channel to record from Default: 1 +% - recdevice the device to record from. Default: 0 +% - devicetype determines which sound driver to use +% 'win' Windows Multimedia Device +% 'dx' DirectX DirectSound driver +% 'asio' ASIO Driver (default) +% +% See the help for pa_wavplay for a list of some of these arguments, +% and the formatting of them. +% +% SEE ALSO: pa_wavrecord, pa_wavplayrecord + +% check right num of args +error(nargchk(1,8,nargin)); + +% defaults +device_opt = 1; +playdevice = 0; +fs = 44100; +recnsamples = 0; +recfirstchannel = 1; +reclastchannel = 1; +recdevice = 0; + +% if devtype specified +if ischar(varargin{end}), + s=varargin{end}; + varargin(end)=[]; + + device_opt = strmatch(s,{'asio','win', 'dx'}); + if isempty(device_opt), + error(['Unrecognized DEVICETYPE: ' s]); + end + + if (nargin==1) + if device_opt==1, % asio + pawavplaya; + end + if device_opt==2, % win + pawavplayw; + end + if device_opt==3, % dx + pawavplayx; + end + return; + end +end + +% data buffer +playbuffer = varargin{1}; + +% play device +if length(varargin)>=2, + playdevice=varargin{2}; +end + +% sample rate +if length(varargin)>=3, + fs=varargin{3}; +end + +% recnsamples +if length(varargin)>=4, + recnsamples=varargin{4}; +end + +% recfirstchannel +if length(varargin)>=5, + recfirstchannel=varargin{5}; +end + +% reclastchannel +if length(varargin)>=6, + reclastchannel=varargin{6}; +end + +% recdevice +if length(varargin)>=7, + recdevice=varargin{7}; +end + +if device_opt==1, % asio + %fprintf('Using ASIO driver\n'); + y = pawavplaya(playbuffer, playdevice, fs, recfirstchannel, reclastchannel, recnsamples, recdevice); +elseif device_opt==2, % win + fprintf('Using WMME driver\n'); + y = pawavplayw(playbuffer, playdevice, fs, recfirstchannel, reclastchannel, recnsamples, recdevice); +elseif device_opt==3, % dx + fprintf('Using DirectX driver\n'); + y = pawavplayx(playbuffer, playdevice, fs, recfirstchannel, reclastchannel, recnsamples, recdevice); +end + +%fprintf('Converting result to doubles\n'); +y = double(y); + +% [EOF] pa_wavplayrecord.m \ No newline at end of file diff --git a/pa_wavplay/pa_wavrecord.m b/pa_wavplay/pa_wavrecord.m new file mode 100644 index 0000000..3d1dcb1 --- /dev/null +++ b/pa_wavplay/pa_wavrecord.m @@ -0,0 +1,113 @@ +function y = pa_wavrecord(varargin) +% pa_wavrecord: record from multichannel sound hardware +% +% Usage: pa_wavrecord([devicetype]) +% inputbuffer = pa_wavrecord(firstchannel, lastchannel, nsamples, [samplerate], +% [deviceid], [devicetype]) +% +% pa_wavrecord is a tool for recording multi-channel audio through your +% ASIO device. Arguments in [] are optional +% +% - firstchannel the first input channel to record from +% - lastchannel the last input channel to record from +% - nsamples the number of samples to record from each channel +% - samplerate the sampling frequency. Default: 44100 +% - deviceid the device id to use for INPUT. Default: 0 +% - informat the desired data type of inputbuffer. Valid types +% and the number of bits per sample are as follows: +% - devicetype determines which sound driver to use +% 'win' Windows Multimedia Device +% 'dx' DirectX DirectSound driver +% 'asio' ASIO Driver (default) +% - inputbuffer is a variable that will hold the recorded audio, +% running along rows, with a seperate column for +% each channel +% +% SEE ALSO: pa_wavplay, pa_wavplayrecord + +% check right num of args +error(nargchk(0,6,nargin)); + +% defaults +device_opt = 1; +device = 0; +fs = 44100; +%in_opt = 2; + +% no args, print devices for asio +if (nargin==0) + pawavplaya; + return; +end + +% if devtype specified +if ischar(varargin{end}) + s=varargin{end}; + varargin(end)=[]; + + device_opt = strmatch(s,{'asio','win', 'dx'}); + if isempty(device_opt), + error(['Unrecognized DEVICETYPE: ' s]); + end + + if (nargin==1) + if device_opt==1, % asio + pawavplaya; + end + if device_opt==2, % win + pawavplayw; + end + if device_opt==3, % dx + pawavplayx; + end + return; + end +end + +%{ +% if informat specified +if ischar(varargin{end}) + s=varargin{end}; + varargin(end)=[]; + + in_opt = strmatch(s,{'int16','double'}); + if isempty(in_opt), + error(['Unrecognized informat: ' s]); + end +end +%} + +% channels +firstchannel = varargin{1}; +lastchannel = varargin{2}; + +% samples +nsamples = varargin{3}; + +% sample rate +if length(varargin)>=4, + fs=varargin{4}; +end + +% device id +if length(varargin) >= 5, + device = varargin{5}; +end + +if device_opt==1, % asio + %fprintf('Using ASIO driver\n'); + y = pawavplaya(0, -1, fs, firstchannel, lastchannel, nsamples, device); + +elseif device_opt==2, % win + fprintf('Using WMME driver\n'); + y = pawavplayw(0, -1, fs, firstchannel, lastchannel, nsamples, device); + +elseif device_opt==3, % dx + fprintf('Using DirectX driver\n'); + y = pawavplayx(0, -1, fs, firstchannel, lastchannel, nsamples, device); +end + +%fprintf('Converting result to doubles\n'); +y = double(y); + +% [EOF] pa_wavrecord.m \ No newline at end of file diff --git a/pa_wavplay/pawavplaya.dll b/pa_wavplay/pawavplaya.dll new file mode 100644 index 0000000..dfbb755 Binary files /dev/null and b/pa_wavplay/pawavplaya.dll differ diff --git a/pa_wavplay/pawavplayw.dll b/pa_wavplay/pawavplayw.dll new file mode 100644 index 0000000..bb9d2bd Binary files /dev/null and b/pa_wavplay/pawavplayw.dll differ diff --git a/pa_wavplay/pawavplayx.dll b/pa_wavplay/pawavplayx.dll new file mode 100644 index 0000000..6714be5 Binary files /dev/null and b/pa_wavplay/pawavplayx.dll differ diff --git a/tests/record.m b/tests/record.m new file mode 100644 index 0000000..20eb49c --- /dev/null +++ b/tests/record.m @@ -0,0 +1,432 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% File: record.m % +% Author: Jesse Hansen (12-1-01) % +% Email: hansenj@ele.uri.edu % +% Web: www.ele.uri.edu/~hansenj/ % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Type "record" in the matlab command window to +% run the program. Note: I believe you need the +% signal processing toolbox for the program to +% successfully execute. + +% Last updated on 9-21-02 + +function record(op) + +global H_RECORD F_RECORD AXIS_RECORD ai data z_data R_fs R_samp_len + +global ZOOM_HISTORY + +if nargin == 0 % if no input argument, draw the GUI + op = 0; +end + +%spec = 'wideband'; +spec = 'narrowband'; +wideband_time = 4e-3; +narrowband_time = 25e-3; +%window_width = 200; % window width for FFT +%step_size = 100; % window movement +fft_pts = 2048; % # of points in the FFT + +switch op + +case 0 % Draw figure + + clear global data % erase any previously recorded data + + width = 950; + height = 700; + + F_RECORD = figure('Position',[25 50 width height],... + 'NumberTitle','off',... + 'Color',[.8 .8 .8],... + 'Name','Record'); + + H_RECORD(1) = uicontrol('Style','pushbutton',... % record button + 'Units','normalized',... + 'Position',[190/width (height-75)/height 80/width 30/height],... + 'ForegroundColor',[1 0 0],... + 'FontWeight','bold',... + 'String','Play',... + 'String','Record',... + 'Visible','on',... + 'CallBack','record(1)'); + + H_RECORD(2) = uicontrol('Style','text',... + 'Units','normalized', ... + 'Position',[190/width (height-45)/height 80/width 20/height],... + 'BackgroundColor',[.8 .8 .8],... + 'String',' '); + + H_RECORD(3) = uicontrol('Style','pushbutton',... % play button + 'Units','normalized', ... + 'Position',[300/width (height-75)/height 80/width 30/height],... + 'ForegroundColor',[.2 .4 .2],... + 'FontWeight','bold',... + 'String','Play',... + 'Enable','off',... + 'CallBack','record(2)'); + + H_RECORD(4) = uicontrol('Style','Slider',... % user selects time length + 'Units','normalized', ... + 'Position',[60/width (height-70)/height 100/width 20/height],... + 'Min',1,'Max',6,'Value',2,... + 'SliderStep',[1/5-0.000001 1/5],... + 'Callback','record(3)'); + + H_RECORD(5) = uicontrol('Style','text',... % diplays time length + 'Units','normalized', ... + 'Position',[50/width (height-45)/height 120/width 20/height],... + 'BackgroundColor',[.8 .8 .8],... + 'String','Length - 2 sec'); + + H_RECORD(6) = uicontrol('Style','pushbutton',... % Zoom in on data + 'Units','normalized', ... + 'Position',[(width-240)/width (height-72.5)/height 75/width 25/height],... + 'ForegroundColor',[.2 .4 .2],... + 'FontWeight','bold',... + 'String','Zoom In',... + 'Enable','off',... + 'CallBack','record(4)'); + + H_RECORD(7) = uicontrol('Style','pushbutton',... % Zoom out + 'Units','normalized', ... + 'Position',[(width-135)/width (height-72.5)/height 75/width 25/height],... + 'ForegroundColor',[.2 .4 .2],... + 'FontWeight','bold',... + 'String','Zoom Out',... + 'Enable','off',... + 'CallBack','record(5)'); + + H_RECORD(8) = uicontrol('Style','pushbutton',... % Load data from wav file + 'Units','normalized', ... + 'Position',[(width-395)/width (height-72.5)/height 75/width 25/height],... + 'ForegroundColor',[.2 .4 .2],... + 'FontWeight','bold',... + 'String','Load',... + 'Enable','on',... + 'CallBack','record(6)'); + + H_RECORD(9) = uicontrol('Style','pushbutton',... % Save data to wav file + 'Units','normalized', ... + 'Position',[(width-500)/width (height-72.5)/height 75/width 25/height],... + 'ForegroundColor',[.2 .4 .2],... + 'FontWeight','bold',... + 'String','Save',... + 'Enable','off',... + 'CallBack','record(7)'); + + +case 1 % record button + + % Set sampling and length info + %R_fs = 11025; + R_fs = 16000; + R_samp_len = get(H_RECORD(4),'Value'); + + % get handles for sound input and output + ai = init_sound(R_fs,R_samp_len); + R_fs = get(ai, 'SampleRate'); % in case actual rate doesn't match desired + + % gets an array named data from the microphone + nogo=0; + + while not (nogo) + set(H_RECORD(1),'String','Recording'); + set(H_RECORD(2),'String','Speak now...'); + start(ai); + try + data = getdata(ai); + nogo=1; + catch + disp('10 seconds elapsed... try again!'); + stop(ai); + end + end + delete(ai); + set(H_RECORD(1),'String','Record'); + set(H_RECORD(2),'String',' '); + + % Make "Play", "Zoom In/Out", and "Save" buttons available + set(H_RECORD(3),'enable','on'); + set(H_RECORD(6),'enable','on'); + set(H_RECORD(7),'enable','on'); + set(H_RECORD(9),'enable','on'); + + % normalize sound data to 99% of max + data = 0.99*data/max(abs(data)); + z_data = data; + % displays the time graph of the voice signal + AXIS_RECORD(1) = timedata(F_RECORD,data,R_fs,0.06,0.50,0.88,0.30); + xlims = get(AXIS_RECORD(1),'XLim'); + ylims = get(AXIS_RECORD(1),'YLim'); + ZOOM_HISTORY = []; + ZOOM_HISTORY = push(ZOOM_HISTORY,[xlims ylims]); + + % Sampling rate dependent window width + if strcmp(spec,'narrowband') + window_width = round(R_fs*narrowband_time); + step_size = round(window_width/8); + elseif strcmp(spec,'wideband') + window_width = round(R_fs*wideband_time); + step_size = round(window_width/2); + end + + % calculates the spectrum of the voice signal + X = specgram(data,fft_pts,1,hamming(window_width),window_width-step_size); + X = abs(X); + % displays the spectrum of the voice signal + AXIS_RECORD(2) = spectdata(F_RECORD,X,R_fs,step_size,window_width,0.06,0.11,0.88,0.30); + axis([xlims get(gca,'YLim')]) + +case 2 % Play recording + + % sends an array named z_data to the speakers/headphones + if length(z_data) ~= 0 + sound(z_data,R_fs) + end + +case 3 % Display time length text + + % Allow the user to set the time length of sample + num = get(H_RECORD(4),'Value'); + set(H_RECORD(5),'String',['Length - ' num2str(num) ' sec']); + +case 4 + + % Zoom in on the data + + axes(AXIS_RECORD(1)) + + % Allow the user to draw a rectangle on the area + % they would like to zoom in on + RECT = getrect; + + xmin = RECT(1); + xmax = RECT(1) + RECT(3); + ymin = RECT(2); + ymax = RECT(2) + RECT(4); + + % Set maximum zoom limits to the data edges + xaxis_limits = get(AXIS_RECORD(1),'XLim'); + yaxis_limits = get(AXIS_RECORD(1),'YLim'); + + if xmin < xaxis_limits(1) + xmin = xaxis_limits(1); + end + + if xmax > xaxis_limits(2) + xmax = xaxis_limits(2); + end + + if ymin < yaxis_limits(1) + ymin = yaxis_limits(1); + end + + if ymax > yaxis_limits(2) + ymax = yaxis_limits(2); + end + + % if the choosen zoom range is acceptable... + if ~((ymin > ymax) | (xmin > xmax)) + + % zoom in on the time data + axis([xmin xmax ymin ymax]); + % define the last limits + last_axis_limits = [xaxis_limits yaxis_limits]; + ZOOM_HISTORY = push(ZOOM_HISTORY,last_axis_limits); + + % zoom in on the frequency data by adjusting the xaxis + % limits to be the same as those of the time data + axes(AXIS_RECORD(2)) + yaxis_limits = get(AXIS_RECORD(2),'YLim'); + axis([xmin xmax yaxis_limits(1) yaxis_limits(2)]); + + % define the zoomed in data (for playback purposes) + imin = round(xmin*R_fs)+1; + imax = round(xmax*R_fs)+1; + z_data = data(imin:imax); + + end + +case 5 + + zoom_level = length(ZOOM_HISTORY); + + if zoom_level > 1 + [ZOOM_HISTORY,axis_limits] = pop(ZOOM_HISTORY); + else + axis_limits = ZOOM_HISTORY{1}; + end + + % zoom out to the full time data + axes(AXIS_RECORD(1)) + axis(axis_limits); + + % zoom out to the full frequency data + axes(AXIS_RECORD(2)) + ymin = 0; + ymax = R_fs/2000; + axis([axis_limits(1:2) ymin ymax]); + + % define the zoomed in data (for playback purposes) + imin = round(axis_limits(1)*R_fs)+1; + imax = round(axis_limits(2)*R_fs)+1; + z_data = data(imin:imax); + %z_data = data; + +case 6 % Load button + + [filename, pathname] = uigetfile('*.wav','Select Data File'); + + if filename ~= 0 + + cd(pathname); + + % Get data and sampling rate + [data,R_fs] = wavread([pathname filename]); + if min(size(data))>1 + error('Can''t load stereo data') + end + % Make "Play", "Zoom In/Out", and "Save" buttons available + set(H_RECORD(3),'enable','on'); + set(H_RECORD(6),'enable','on'); + set(H_RECORD(7),'enable','on'); + set(H_RECORD(9),'enable','on'); + + z_data = data; + % displays the time graph of the voice signal + AXIS_RECORD(1) = timedata(F_RECORD,data,R_fs,0.06,0.50,0.88,0.30); + xlims = get(AXIS_RECORD(1),'XLim'); + ylims = get(AXIS_RECORD(1),'YLim'); + ZOOM_HISTORY = []; + ZOOM_HISTORY = push(ZOOM_HISTORY,[xlims ylims]); + + % Sampling rate dependent window width + if strcmp(spec,'narrowband') + window_width = round(R_fs*narrowband_time); + step_size = round(window_width/8); + elseif strcmp(spec,'wideband') + window_width = round(R_fs*wideband_time); + step_size = round(window_width/2); + end + + % calculates the spectrum of the voice signal + X = specgram(data,fft_pts,1,hamming(window_width),window_width-step_size); + X = abs(X); + % displays the spectrum of the voice signal + AXIS_RECORD(2) = spectdata(F_RECORD,X,R_fs,step_size,window_width,0.06,0.11,0.88,0.30); + axis([xlims get(gca,'YLim')]) + + end + +case 7 % Save waveform + + [filename, pathname] = uiputfile('*.wav', 'Save Data to Wave File'); + if filename ~= 0 + wavwrite(z_data,R_fs,[pathname filename]) + end + +end + + + +%--------------------------------------------------------------- +% SUBFUNCTION +function H = timedata(Fig,x,fs,left,bottom,width,height) +% This function plots time data at location specified by user +% Left, bottom, width, height are relative locations less than 1 + +figure(Fig); + +samp_len = length(x)/fs; +delta_t = 1/fs; +t = 0:delta_t:(samp_len-delta_t); + +% display the signal +H = subplot('position',[left bottom width height]); +plot(t,x), xlabel('Time [sec]'), ylabel('Amplitude') +axis([0 t(length(x)-1) -1 1 ]); + + +%--------------------------------------------------------------- +% SUBFUNCTION +function H = spectdata(Fig,x,fs,step,ww,left,bottom,width,height) +% This function plots spectral data at location specified by user +% Left, bottom, width, height are relative locations less than 1 + +figure(Fig); + +% frequency axis vector +y_len = size(x,1); % num of rows +f = [0:y_len-1]*fs/y_len/2; +f = f/1000; % kHz scale + +% time axis vector +x_len = size(x,2); % num of columns +%t = [0.5:1:x_len+0.5]*step/fs; +%t = [(ww-1)/2-0.5:step:step*x_len+(ww-1)/2-1.5]/fs; +t = [(ww-1)/2:step:(x_len-1)*step+(ww-1)/2]/fs; + +% display the signal +H = subplot('position',[left bottom width height]); +log_data = -log10(x+0.0001); +imagesc(t,f,log_data), xlabel('Time [sec]'), ylabel('Frequency [kHz]') +set(gca,'YDir','normal') + + +%--------------------------------------------------------------- +% SUBFUNCTION +function ai = init_sound(fs,samp_len) +% Function 'init_sound' initializes microphone input for voice +% 'fs' is the sampling rate, 'samp_len' is the time to record +% in seconds. + +v = ver; +name = {v.Name}; +ind = find(strcmp(name,'MATLAB')); +if isempty(ind) + ind = find(strcmp(name,'MATLAB Toolbox')); +end + +v_num = str2num(v(ind).Version); + +ai = analoginput('winsound'); +addchannel(ai, 1); +if (v_num == 6.1) | (v_num == 6.5) + set(ai, 'StandardSampleRates', 'Off'); +end +set(ai, 'SampleRate', fs); +actual_fs = get(ai, 'SampleRate'); +set(ai, 'TriggerType', 'software'); +set(ai, 'TriggerRepeat', 0); +set(ai, 'TriggerCondition', 'Rising'); +set(ai, 'TriggerConditionValue', 0.01); +set(ai, 'TriggerChannel', ai.Channel(1)); +set(ai, 'TriggerDelay', -0.1); +set(ai, 'TriggerDelayUnits', 'seconds'); +set(ai, 'SamplesPerTrigger', actual_fs*samp_len+1); +set(ai, 'TimeOut', 10); + + +%--------------------------------------------------------------- +% SUBFUNCTION +function s = push(s,new_item) +% Function 'push' adds 'new_item' to stack 's' +if ~isempty(s) + height = length(s); + s{height+1} = new_item; +else + s{1} = new_item; +end + +%--------------------------------------------------------------- +% SUBFUNCTION +function [s,x] = pop(s) +% Function 'pop' removes item from top of stack 's' +height = length(s); +x = s{height}; +s = s(1:height-1); + diff --git a/tests/specplot.m b/tests/specplot.m new file mode 100644 index 0000000..c0f35e1 --- /dev/null +++ b/tests/specplot.m @@ -0,0 +1,60 @@ +function specplot(ficpath,fic,sens,var) +% plots the spectrogram of a signal +% distributed as a part of fazplot + +% PARAMETERS +% ficpath: the path folder of the wav file +% fic: the wav file +% sens: la sensibilté du préampli micro (V/Pa) +% var: nom de la variable + +[y,fs,nbits,opts] = wavread([ficpath fic]); +sens +y=y./sens; +ly=length(y); +nfft=16384; +fe=44100; +f=[0:nfft/2]*fe/nfft; +t=[0:ly-1]/fe; +nwin=nfft; +wind=hanning(nwin); + +% ajout des zeros +p=round(log(ly)/log(2)); +epsil=(2^p-ly); +ynew=[y' zeros(1,epsil)]'; + +% Calcul des spectres +fy=pwelch(ynew,wind,0,nfft,fe); +fya=unwrap(angle(fft(ynew,nfft))); +aspect=20*log10(abs(fy(1:(nfft/2+1))).^0.5./2e-5); +fya=fya(1:(nfft/2+1)); +maxaspect=max(aspect); +maxy=max(max(y),abs(min(y))); + +% plots +figure(); +plot(t,y,'k'); +axis([0 max(t) -(maxy*1.1) (maxy*1.1)]); +xlabel('Temps (s)'); +ylabel('Amplitude (Pa)'); +title(['Signal temporel : ' fic ' - paramètre : ' var]); +grid on; + +figure(); +semilogx(f,aspect,'k'); +axis([10 max(f) 0 (maxaspect+10)]); +xlabel('Fréquence (Hz)'); +ylabel('Lp (dB SPL)'); +title(['Module de la réponse fréquentielle, signal : ' fic ' - paramètre : ' var]); +grid on; + +figure(); +semilogx(f,fya,'k'); +axis([10 max(f) min(fya) max(fya)]); +grid on; +xlabel('Fréquence (Hz)'); +ylabel('Phase (rad)'); +title(['Phase de la réponse fréquentielle, signal : ' fic ' - paramètre : ' var]); + +end \ No newline at end of file diff --git a/tests/testacqui.m b/tests/testacqui.m new file mode 100644 index 0000000..d954e68 --- /dev/null +++ b/tests/testacqui.m @@ -0,0 +1,20 @@ +lt=2; %s +f_min=20; +f_max=20000; +n=50; + +t=0:1/44100:lt; +sig=chirp(t,20,lt,20000,'logarithmic'); +%sig2=wavread('excitation'); + +for i = 1:n + i + pause(0.1) + inputbuffer = pa_wavplayrecord(sig',1,[44100],0,[1],[1],[1],['asio']); + Co=crosscorr(sig',inputbuffer',length(inputbuffer)-1); + [Y(i),I(i)] = max(Co); + I(i) +end + +plot(I); +axis([1 n (max(I)+2) (min(I)-2)]); diff --git a/tests/testacqui2.m b/tests/testacqui2.m new file mode 100644 index 0000000..d644011 --- /dev/null +++ b/tests/testacqui2.m @@ -0,0 +1,24 @@ +lt=5; %s +f_min=20; +f_max=20000; +n=50; + +t=0:1/44100:lt; +sig=0.9*chirp(t,20,lt,20000,'logarithmic'); +len_sig = length(sig); +% sig=wavread('excitation'); + +for i = 1:n + i + pause(0.1) + inputbuffer = pa_wavplayrecord(sig',0,[44100],0,[1],[1],0,['asio']); + Co=crosscorr(sig',inputbuffer',length(inputbuffer)-1); + [Y(i),I(i)] = max(Co); + I(i)-len_sig +end + +plot(I); +axis([1 n (min(I)+2) (max(I)-2)]); +figure() +plot(Y); +axis([1 n min(Y) max(Y)]); diff --git a/tests/testplay.m b/tests/testplay.m new file mode 100644 index 0000000..1a4ae01 --- /dev/null +++ b/tests/testplay.m @@ -0,0 +1,16 @@ +l_buffer = 2048; +f_e = 44100; +lt=5; %s +f_min=20; +f_max=20000; +n=50; + +t=0:1/44100:lt; +sig=chirp(t,20,lt,20000,'logarithmic'); +% sig=wavread('excitation'); + +for i = 1:n + i + pause(0.1) + pa_wavplay(sig', f_e, 1, 'win') +end \ No newline at end of file diff --git a/tests/testrec.m b/tests/testrec.m new file mode 100644 index 0000000..188ad3d --- /dev/null +++ b/tests/testrec.m @@ -0,0 +1,20 @@ +l_buffer = 2048; +f_e = 44100; +lt=5; %s +f_min=20; +f_max=20000; +n=50; + +t=0:1/44100:lt; +%sig=chirp(t,20,lt,20000,'logarithmic'); +%pa_wavplay(sig', f_e, 1, 'asio') + +for i=1:30 + tic + buffer = pa_wavrecord(1, 1, l_buffer, 44100, 'asio'); + %oscmx(3,y); + plot(buffer); + axis([1 l_buffer -1 1]); + drawnow + toc +end \ No newline at end of file diff --git a/tools/chirp_farina.m b/tools/chirp_farina.m new file mode 100644 index 0000000..6fb88a1 --- /dev/null +++ b/tools/chirp_farina.m @@ -0,0 +1,3 @@ +function s = chirp_farina(t, t1, f0, f1) + s = sin(2*pi*(f0*t1)/log(f1/f0) * (exp(t'/t1*log(f1/f0))-1))'; + \ No newline at end of file diff --git a/tools/fonc_trans.m b/tools/fonc_trans.m new file mode 100644 index 0000000..5553bd7 --- /dev/null +++ b/tools/fonc_trans.m @@ -0,0 +1,27 @@ +function [ri,ft]=fonc_trans(f, sig_exc, sig_mes); +%calcul d'une fonction de tranfert mesurée par l'interface CNACQ +%Sorties : fonction de transfert et réponse impulsionnelle + +% soustraction de la composante continue +DC = mean(sig_mes,1); +sig_mes = sig_mes - DC; +len_f = length(f); +f0 = f(1); +f1 = f(length(f)); + +% Methode du produit +%sig_exc_inv = sig_exc(len_f:-1:1)'.*f0./f'; +%X = fft([sig_mes; zeros(length(sig_exc_inv)-1, 1)]); +%Y = fft([sig_exc_inv; zeros(length(sig_mes)-1, 1)]); +%spec=X.*Y; +%rep_imp = ifft(spec); + +% Methode du quotient +%sig_exc = sig_exc(len_f:-1:1)'.*f0./f'; +X = fft(sig_exc); +Y = fft(sig_mes); +ft = Y./X; +ri = ifft(ft); + +% Methode par déconvolution +%[ft, r] = deconv(sig_mes, sig_exc); diff --git a/tools/plot_impedance.m b/tools/plot_impedance.m new file mode 100644 index 0000000..48a9bd7 --- /dev/null +++ b/tools/plot_impedance.m @@ -0,0 +1,63 @@ +% Loudspeaker impedance post-processing from a 2 voice acquisition from CNACQ +% Copyright (C) Guillaume Pellerin + +function plot_impedance(fic_resitance, fic_hp, R_c, option) + +% fic_resistance : the (CNACQ) MAT file containing the transfert function of the +% resistance +% fic_hp = the (CNACQ) MAT file containing the the transfert function of the +% loudspeaker +% R_c = the value of the resistance (Ohm) +% option : 'lin' or 'log' to plot the frequency with a linear or +% logarithmic scale respectively + +load(fic_resitance); +I_r = sig_mes(:,1)/R_c; + +load(fic_hp); +U_hp = sig_mes(:,1); + +%i = sig_mes(:,1); +%u = sig_mes(:,2); +li = length(I_r); +fi = fft(I_r); +fu = fft(U_hp); +fz = fu./fi; +f = [0:f_s/li:f_s]; +f = f(1:li); + +% get limit freq +f_max_list = find(f > f_max); +f_max_ind = f_max_list(1); +f_min_list = find(f < f_min); +f_min_ind = f_min_list(length(f_min_list)); + +figure +subplot(2,1,1); +data = smooth(abs(fz),20); +if option == 'lin' + plot(f,data) +elseif option == 'log' + semilogx(f,data) +end +axis([f_min f_max 0 max(data(f_min_ind:f_max_ind))]) +xlabel('Fréquence (Hz)'); +ylabel('Amplitude (Ohm)'); +title(['Module de l impedance']); +grid on + +subplot(2,1,2); +data = smooth(unwrap(angle(fz)),20); +if option == 'lin' + plot(f,data) +elseif option == 'log' + semilogx(f,data) +end +axis([f_min f_max min(data(f_min_ind:f_max_ind)) max(data(f_min_ind:f_max_ind))]); +xlabel('Fréquence (Hz)'); +ylabel('Amplitude (Rad)'); +title(['Phase de l impedance']); +grid on + + + diff --git a/tools/plot_mes.m b/tools/plot_mes.m new file mode 100644 index 0000000..bd1d2f0 --- /dev/null +++ b/tools/plot_mes.m @@ -0,0 +1,59 @@ +function plot_mes(t, f, f_s, f_min, f_max, sig_exc, sig_mes, rep_imp_mes, spec_mes, spec_exc, id, voice, group, comment, i); + +len_spec_mes = length(spec_mes); +%spec = spec(1:len_spec); + +% Time +figure; +subplot(2,1,1); +plot(t, sig_mes); +%semilogx(t, sig_mes); +axis([0 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]); +%axis([1 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]); +xlabel('Temps (s)'); +ylabel('Amplitude'); +title(['Signal temporel mesuré (groupe: ' group ', id: ' id ', voie : ' voice ')']); +grid on; + +subplot(2,1,2); +rep_imp_mes = real(rep_imp_mes); +len_ri = length(rep_imp_mes); +t_ri = [-len_ri/(2*f_s):1/f_s:len_ri/(2*f_s)]; +t_ri = t_ri(2:length(t_ri)); +plot(t_ri, rep_imp_mes); +%semilogx(t, sig_mes); +axis([t_ri(1) t_ri(len_ri) min(rep_imp_mes)-0.01 max(rep_imp_mes)+0.01]); +%axis([1 t(length(t)) min(sig_mes)-0.01 max(sig_mes)+0.01]); +xlabel('Temps (s)'); +ylabel('Amplitude'); +title(['Réponse impulsionnelle mesurée (groupe: ' group ', id: ' id ', voie : ' voice ')']); +grid on; + + +% Freq +f_max_list = find(f > f_max); +f_max_ind = f_max_list(1); +f_min_list = find(f < f_min); +f_min_ind = f_min_list(length(f_min_list)); + +figure; +subplot(2,1,1); +spec_mes_log = 10*log10(abs(spec_mes)); +semilogx(f, smooth(spec_mes_log,7)); +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]); +xlabel('Fréquence (Hz)'); +ylabel('Amplitude (dB)'); +title(['Module de la fonction de transfert (groupe: ' group ', id: ' id ', voie : ' voice ')']); +grid on; + +subplot(2,1,2); +angle_exc = angle(spec_exc); +angle_mes = angle(spec_mes); +ang = unwrap(angle_mes - angle_exc) + 2*pi; +semilogx(f, smooth(ang,7)); +axis([f_min f_max min(ang(f_min_ind:f_max_ind)) max(ang(f_min_ind:f_max_ind))]); +grid on; +xlabel('Fréquence (Hz)'); +ylabel('Phase (rad)'); +title(['Phase de la fonction de transfert (groupe: ' group ', id: ' id ', voie : ' voice ')']); + diff --git a/vu-meters/meterH.exe b/vu-meters/meterH.exe new file mode 100644 index 0000000..51594d9 Binary files /dev/null and b/vu-meters/meterH.exe differ diff --git a/vu-meters/meterV.exe b/vu-meters/meterV.exe new file mode 100644 index 0000000..063eaa7 Binary files /dev/null and b/vu-meters/meterV.exe differ