Help on making MULTIRESOLUTION WAVELET ANALYSIS available ? - Page 2 - diyAudio
Go Back   Home > Forums > Design & Build > Software Tools

Software Tools SPICE, PCB CAD, speaker design and measurement software, calculators

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 28th March 2010, 09:47 PM   #11
Elias is offline Elias  Finland
diyAudio Member
 
Elias's Avatar
 
Join Date: May 2003
Location: Where you live
Hi,

I started a step-by-step thread on wavelets

WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?



- Elias
  Reply With Quote
Old 19th April 2010, 08:45 PM   #12
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
Hi folks

finally got around some starting point.


Special thanks to main contributors for the package I proudly present :

Elias
Jean Michel LeCleach
Jacques Lewalle


For now it features / is implemented :

- simple user menu
- file import of wav-file, ARTA-txt-file, plain-ascii-file (two and one column)
- display of first 100ms of unprocessed IR
- IR peak normalizing and display of IR peak in zoom
- Jean-Michel LeCleach wavelet analysis
- Jacques Lewalle wavelet analysis
- display of standard wavelet analysis
- display of normalized wavelet analysis

Hope you'll find it any useful so far


Michael
  Reply With Quote
Old 19th April 2010, 08:50 PM   #13
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
content of Diy_Audio_WTF package :
April 2010

start_wavelet, load_arta_txt_ir, load_ascii_ir, load_ascii1_ir, load_wav_ir, shape_ir, matrix_norm, wtf_mag_norm, wtf_lecleach, wtf_morlet_lewalle, lewa_fftfreq, lewa_mymorlet, content

% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle: Prof. Jacques Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  Reply With Quote
Old 19th April 2010, 08:51 PM   #14
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
%--------------------------------------------------------
% start_wavelet
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "start_wavelet" is a script to load impulse response files of various formats
% and to check valid import by simple impulse response and frequency response plot
%
% ir_time is the vector containing the time dat a of the IR file
% ir_amp is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii1_ir.m, fft_ir_raw, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle: Prof. Jacques Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------

%
%--------------------------------------------------------
% global declaration
%--------------------------------------------------------

global ir_file_name;

%--------------------------------------------------------
% introduction and prompt for debug option
%--------------------------------------------------------
disp("")
disp("")
disp("#######+++++++++++++++++++++++++++++++++++++ ++++##########")
disp("")
disp("")
disp("HELLO ! Wecome to DIY Audio Wavelet Analysis ! ")
disp("contributing authors : ")
disp("Michael Gerstgrasser ")
disp("Elias ")
disp("Jeaques Lewalle ")
disp("Jean-Michel Le Clea'ch")
disp("")
disp("You will be promted to pick your choices... ")
disp("")

k=0;
d_bug=1;
k=menu("Enter 1 for normal operation"," normal operation"," debug mode", "EXIT");

if k==1;
d_bug = 0;
endif;
if k==2;
d_bug=1;
disp("")
disp("DEBUG mode selected ! Additional progress information will be displayed")
endif;
if k==3;
disp("")
disp("DIY wavlet analysis will be terminated")
quit;
endif;


%--------------------------------------------------------
% prompt for file name
%--------------------------------------------------------

disp("")
disp("Make sure your impulse response file is located where it can be found by Octave")
disp("Make sure your impulse response file name avoids spaces and special characters")
disp("")
fflush (stdout);
ir_file_name=input("HELLO ! Please type in file name ( press ENTER for ir_file.wav )","s");

if isempty(ir_file_name);
ir_file_name="ir_file.wav"; % assign default
endif;

ir_file_name % display selected file name
disp("")
disp("")



%--------------------------------------------------------
% prompt for file type
%--------------------------------------------------------

k=0;


k=menu("HELLO ! Please select your impulse response file type","32 bit or 16 bit WAV file","ARTA txt file","two column TEXT file","one column TEXT file","EXIT");



if k==1,
disp("")
disp("please wait... ")
disp(ir_file_name) % display selected file name
disp("16 bit or 32 bit WAV file will be imported")
disp("")
disp("Make sure to use a 16 bit or 32 bit WAV impulse respones file")
[ir_time ir_amp] = load_wav_ir(d_bug); % load wav32 impulse response file and assign to variables ir_time, ir_amp
endif
if k==2,
disp("")
disp("please wait... ")
disp(ir_file_name)
disp("ARTA text file will be imported")
disp("")
disp("Make sure to use a TEXT impulse respones file exported from ARTA")
[ir_time ir_amp] = load_arta_txt_ir(d_bug); % load ARTA txt impulse response file and assign to variables ir_time, ir_amp
endif
if k==3,
disp("")
disp("please wait... ")
disp(ir_file_name) % display selected file name
disp("Two column TEXT file will be imported")
disp("")
disp("Make sure to use a plain TEXT, headerless, two column impulse response file")
disp("Make sure first column in your impulse response file contains time")
disp("Make sure second column in your impulse response file contains amplitude")
[ir_time ir_amp] = load_ascii_ir(d_bug); % load ascii impulse response file and assign to variables ir_time, ir_amp
endif
if k==4,
disp("")
disp("please wait... ")
disp(ir_file_name) % display selected file name
disp("One column TEXT file will be imported")
disp("")
disp("Make sure to use a plain TEXT, headerless, one column impulse response file")
disp("Make sure first column in your impulse response file contains amplitude")
disp("Check the following plot for correct impulse response file import")
[ir_time ir_amp] = load_ascii1_ir(d_bug); % load ascii impulse response file and assign to variables ir_time, ir_amp
endif
if k==5,
disp("")
disp("DIY wavlet analysis will be terminated")
quit;
endif;
%--------------------------------------------------------
% restore and display : samplerate , sample count , total time
%--------------------------------------------------------

disp("")
disp("")
disp("HELLO ! Properties of imported file :")
disp("")
sample_rate = 10/(ir_time(110)-ir_time(100)) % reconstruckt sample rate
samples = length(ir_amp) % sample count
total_time = samples / sample_rate % calculate total time of measurement


%--------------------------------------------------------
%--------------------------------------------------------


%--------------------------------------------------------
% plot impulse response to check correct import
%--------------------------------------------------------
clf;
disp("")
disp("")
disp("HELLO ! Please check the following plot for correct impulse respones file import")


figure(1)
plot (ir_time,ir_amp,"-;Impulse Response;")
set (gca (), "xlim", [0 0.1]);
title(["HELLO ! Please check plot below for correct impulse response import (first 100ms) ! "," Imported file: ",(ir_file_name)])

xlabel ("Time");
ylabel ("Amplitude");


disp("marker")
samples_trim = 1024;
ir_time_trim=ir_time;
ir_amp_trim=ir_amp;
[ir_time_trim, ir_amp_trim] = shape_ir (ir_time, ir_amp, samples_trim, d_bug);


%--------------------------------------------------------
% select wavelet analysis
%--------------------------------------------------------



k=0;
k=menu("HELLO ! please select wavlet analysis"," Jean-Michael LeCleach Wavelet Analysis"," Jeaques Lewalle Morlet Wavelet Analysis", " EXIT");

if k==1;
disp("")
disp("HELLO ! Wavelet analysis in progress - this may take a few minutes")
disp("------------ normalised impulse response will be displayed ------------ ")
disp("------------ wavelet plot will be displayed ------------ ")
disp("------------ normalised wavelet plot will be displayed ------------ ")
[wtf_t, wtf_f, wtf_mag] = wtf_lecleach (ir_time_trim, ir_amp_trim, d_bug) ;
endif;
if k==2;
disp("")
disp("HELLO ! Wavelet analysis in process - this may take a few minutes")
disp("------------ normalised impulse response plot will be displayed ------------ ")
disp("------------ wavelet plot will be displayed ------------ ")
disp("------------ normalised wavelet plot will be displayed ------------ ")
[wtf_t, wtf_f, wtf_mag] = wtf_morlet_lewalle (ir_time_trim, ir_amp_trim, d_bug);
endif;
if k==3;
disp("")
disp("DIY wavelet analysis will be terminated")
quit;
endif;


%--------------------------------------------------------
% plot normalised impulse response
%--------------------------------------------------------




figure(2)
clf(2);
plot (ir_time_trim,ir_amp_trim,"-;Impulse Response;")
set (gca (), "xlim", [0 0.1]);
title(["HELLO ! Please check plot below for correct impulse response import (first 100ms) ! "," Imported file: ",(ir_file_name)])
set (gca (), "xlim", [0 0.013]);
xlabel ("Time");
ylabel ("Amplitude");


%--------------------------------------------------------
% plot wavlet analysis
%--------------------------------------------------------

fmin = 1000; % or check for min freqeuncy to plot min(wtf_f);
fmax = max (wtf_f); % check for max freqeuncy to plot
mag_low_limit=-40; % set minimum magnitude


max_wtf_mag = max(max(wtf_mag)); % set peak magnitude to 0 dB
wtf_mag_norm = wtf_mag - max_wtf_mag;
wtf_mag_norm = max(mag_low_limit,wtf_mag_norm); % set minimum magnitude to mag_low_limit


figure (3);
clf(3);
pcolor (wtf_t, wtf_f, wtf_mag_norm);
shading ("interp");
colorbar (); % optional : colorbar ();
xlabel ("Time [ms]");
ylabel ("Freq [Hz]");
set (gca (), "yscale", "log");
set (gca (), "xlim", [-3 10]);
set (gca (), "ylim", [fmin fmax]);
title(["WTF spectrogram ",(ir_file_name)])
grid("on");



%--------------------------------------------------------
% plot normalised wavlet analysis
%--------------------------------------------------------


matrixx_norm = matrix_norm(wtf_mag, d_bug); % normalization feature


max_wtf_mag = max(max(matrixx_norm)); % set peak magnitude to 0 dB
matrixx_norm = matrixx_norm - max_wtf_mag;
matrixx_norm = max(mag_low_limit,matrixx_norm); % set minimum magnitude to mag_low_limit


figure (4);
clf(4);
pcolor (wtf_t, wtf_f, matrixx_norm);
shading ("interp");
colorbar (); % optional : colorbar ();
xlabel ("Time [ms]");
ylabel ("Freq [Hz]");
set (gca (), "yscale", "log");
set (gca (), "xlim", [-3 10]);
set (gca (), "ylim", [fmin fmax]);
title(["WTF spectrogram normalized ",(ir_file_name)])
grid("on");
  Reply With Quote
Old 19th April 2010, 08:52 PM   #15
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [ir_time, ir_amp] = load_arta_txt_ir (d_bug);

%--------------------------------------------------------
% load_arta_txt_ir
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software

% Copyright (C) 2010 Elias Pekonen % Contact information: user 'Elias' at www.diyaudio.com
% rewritten by Michael Gerstgrasser % Contact information: user 'mige0' at www.diyaudio.com
%
% " load_arta_txt_ir" is a functon to load impulse response files of ARTA txt export format
%
% inpt variables:
% d_bug is for providing additional information in case of debug mode
%
% output variables:
% "ir_time" is the vector containing the time data of the IR file
% "ir_amp" is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------
%

if d_bug == 1;
disp ("DEBUG REPORT: processing function : load_arta_txt_ir , please WAIT !" )
endif
%--------------------------------------------------------
% global declaration
%--------------------------------------------------------

global ir_file_name;

%--------------------------------------------------------


ir_file_name
disp("")

point_pos=rindex (ir_file_name, "."); % string extension detect
ir_local=ir_file_name(1oint_pos-1); % string extension delete


fid = fopen (ir_file_name);
fgetl (fid)
fgetl (fid)
fgetl (fid)
fgetl (fid)
data = zeros (2^18, 2);
i = 1;
while (! feof (fid) )
data (i++, = str2num (fgetl (fid));
endwhile
fclose (fid);

data = data(1 : i - 1, ;

% figure (1)
% plot (data(:, 1), data(:, 2));


ir_time = data(:, 1);
ir_amp = data(:, 2);


if d_bug == 1;
disp ("DEBUG REPORT: function : load_arta_txt_ir processed successfully" )
endif

endfunction
  Reply With Quote
Old 19th April 2010, 08:52 PM   #16
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [ir_time, ir_amp] = load_ascii1_ir(d_bug);

%--------------------------------------------------------
% load_ascii1_ir
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "load_ascii1_ir" is a functon to load impulse response files of ARTA txt export format
%
%
% inpt variables:
% d_bug is for providing additional information in case of debug mode
%
% output variables:
% "ir_time" is the vector containing the time data of the IR file
% "ir_amp" is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------

if d_bug == 1;
disp ("DEBUG REPORT: processing function : load_ascii1_ir , please WAIT !" )
endif

global ir_file_name;
point_pos=rindex (ir_file_name, "."); % string extension detect
ir_local=ir_file_name(1oint_pos-1); % string extension delete
load ("-ascii", (ir_file_name));
ir=eval(ir_local); % save file content into varaible ir
ir_amp=ir;

%--------------------------------------------------------
% prompt for sampling rate
%--------------------------------------------------------

disp("")
fflush (stdout);
sampling_freq =input("type in sample rate [Hz], or press enter for 44100 Hz");

if isempty(sampling_freq);
sampling_freq =44100; % assign default
endif;

%--------------------------------------------------------

sampling_freq % display sampling frequency

time_incr=1/sampling_freq; % calculate sample time interval
samples=length(ir_amp);
last_sample=samples*time_incr-time_incr; % calculate sampling time
ir_time=(0:time_incr:last_sample); % calculate ir_time vector

%--------------------------------------------------------

if d_bug == 1;
disp ("DEBUG REPORT: function : load_ascii1_ir processed successfully" )
endif

endfunction
  Reply With Quote
Old 19th April 2010, 08:53 PM   #17
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [ir_time, ir_amp] = load_ascii_ir (d_bug) ;

%--------------------------------------------------------
% load_ascii_ir
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "load_ascii_ir" is a functon to load impulse response files of ARTA txt export format
%
% inpt variables:
% d_bug is for providing additional information in case of debug mode
%
% output variables:
% "ir_time" is the vector containing the time data of the IR file
% "ir_amp" is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------
%

if d_bug == 1;
disp ("DEBUG REPORT: processing function : load_ascii_ir , please WAIT !" )
endif
%--------------------------------------------------------
% global declaration
%--------------------------------------------------------

global ir_file_name;

%--------------------------------------------------------

point_pos=rindex (ir_file_name, "."); % string extension detect
ir_local=ir_file_name(1oint_pos-1); % string extension delete
load ("-ascii", (ir_file_name));
ir=eval(ir_local); % save file content into varaible ir

ir_time=ir(:,1);
ir_amp=ir(:,2);

if d_bug == 1;
disp ("DEBUG REPORT: function : load_ascii_ir processed successfully" )
endif

endfunction
  Reply With Quote
Old 19th April 2010, 08:54 PM   #18
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [ir_time, ir_amp] = load_wav_ir (d_bug);

%--------------------------------------------------------
% load_wav_ir
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "load_wav_ir" is a functon to load impulse response files of ARTA txt export format
%
% inpt variables:
% d_bug is for providing additional information in case of debug mode
%
% output variables:
% "ir_time" is the vector containing the time data of the IR file
% "ir_amp" is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------

if d_bug == 1;
disp ("DEBUG report: processing function : load_wav_ir , please WAIT !" )
endif
%--------------------------------------------------------
% global declaration
%--------------------------------------------------------

global ir_file_name;

%--------------------------------------------------------


point_pos=rindex (ir_file_name, "."); % string extension detect
ir_local=ir_file_name(1oint_pos-1); % string extension delete
[ir_amp,sampling_freq,Nbits]=wavread(ir_file_name);
sampling_freq % display sampling frequency
Bit=Nbits;
Bit % display resolution

time_incr=1/sampling_freq; % calculate sample time interval
samples=length(ir_amp);

last_sample=samples*time_incr-time_incr; % calculate sampling time
ir_time=(0:time_incr:last_sample); % calculate ir_time vector

if d_bug == 1;
disp ("DEBUG report: function : load_wav_ir processed successfully" )
endif

endfunction
  Reply With Quote
Old 19th April 2010, 08:55 PM   #19
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [ir_time_trim, ir_amp_trim] = shape_ir (ir_time, ir_amp, samples_trim, d_bug);

%--------------------------------------------------------
% shape_ir
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "shape_ir" is a functon to shape teh response files for further processing.
% set IR peak to positive
% set IR peak to 3ms
% normalise IR peak to 1
% set IR length to samples_trim variabel
%
%
% output variables:
% "ir_time_shaped" is the vector containing the time data of the IR file
% "ir_amp_shaped" is the vector containing the amplitude of the IR file
%
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------

if d_bug == 1;
disp ("DEBUG report: processing function : load_wav_ir , please WAIT !" )
endif

ir_time_trim = ir_time;
ir_amp_trim = ir_amp;

%----------- set IR peak to positive --------------------------

amp_max = max (ir_amp_trim);
amp_min = min (ir_amp_trim);

if abs(amp_min) >= abs(amp_max) % ceck if impulse is positive
ir_amp_trim = ir_amp_trim .* -1; % in case not : invert IR
endif



%----------- set peak to 3 ms --------------------------

samples = length (ir_time); % total number of samples
time_incr = (ir_time(110)-ir_time(100)) / 10; % check out time interval between samples
s_r_rec = 1 / time_incr; % reconstruckt sample rate
samples_3ms = fix(0.003 / time_incr); % sample count for 3ms


[max_amp, max_amp_pos] = max (ir_amp_trim);
max_amp_pos;
sample_diff = max_amp_pos - samples_3ms;

if sample_diff > 0
ir_amp_trim = ir_amp_trim(abs(sample_diff):end);
ir_time_trim = ir_time_trim(abs(sample_diff):end);
endif



%----------- set samples to "samples_trim" --------------------------

amp_length=length(ir_amp_trim);

if amp_length >= samples_trim % for sample numbers > samples_trim : truncate
ir_amp_trim = ir_amp_trim (1 : samples_trim);
endif

amp_length=length(ir_amp_trim);

if amp_length < samples_trim % for sample numbers < samples_trim : add samples
ir_amp_trim(amp_length:samples_trim) = [0];
endif

end_time = (samples_trim -1) * time_incr;
ir_time_trim =[0 : time_incr : end_time]; % restore correct frequency vecror



%----------- set IR peak to 1 --------------------------

ir_amp_f = 1 / max_amp;
ir_amp_trim = ir_amp_trim * ir_amp_f;



%-------------------------------------

disp("")
disp ("HELLO ! Samples got trimmed to : ")
samples_trim

if d_bug == 1;
disp ("DEBUG report: function : load_wav_ir processed successfully" )
endif

endfunction
  Reply With Quote
Old 19th April 2010, 08:56 PM   #20
mige0 is offline mige0  Austria
diyAudio Member
 
mige0's Avatar
 
Join Date: Jan 2005
Location: Austria, at a beautiful place right in the heart of the Alps.
function [matrixx_norm] = matrix_norm( matrixx, d_bug);

%--------------------------------------------------------
% function matrix_norm
%--------------------------------------------------------
% This file is part of Diy_Audio_WTF package, intended to get started on Audio Wavelet Transformation
% on free Octave software
% Copyright (C) 2010 Michael Gerstgrasser
%
% "matrix_norm" is a function to normalize a time frequency matrix and ploting
%
%
% matrixx is the input matix that has to be normalized
% matrixx_norm is the output matrix for any further processing
%
% see also load_wav_ir.m, load_ascii_ir.m, load_ascii_ir.m, load_ascii1_ir.m, load_arta_txt_ir, start_wavelet, waveletdemo.m

% Contributing authors to the Diy_Audio_WTF package in order of code publishing date:
%
% Michael Gerstgrasser - Contact information: user 'mige0' at www.diyaudio.com
% Elias Pekonen - Contact information: user 'Elias' at www.diyaudio.com
% J. Lewalle
%
% check out on www.diyaudio.com :
% "Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?"
% Help on making MULTIRESOLUTION WAVELET ANALYSIS available ?
% "WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?"
% WTF!? Wavelet TransForm for audio measurements - What-is? and How-to?
% "Horn Honk $$ WANTED $$"
% Horn Honk $$ WANTED $$
%
% Diy_Audio_WTF (Wavelet Audio Analysis) is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2, or (at your option) any
% later version.
%
% Diy_Audio_WTF is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with Diy_WAA; see the file COPYING. If not, write to the Free
% Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
%--------------------------------------------------------

if d_bug == 1;
disp ("DEBUG report: processing function : function matrix_norm , please WAIT !" )
endif


%------------------------ normalize matix ----------------------------------


max_max = max (max (matrixx)); % max-value in matrix

x_y_size = size(matrixx); % check for row and column lengrh of matrix
time_length = x_y_size(2); % check for x lengrh of matrix
ampl_length = x_y_size(1); % check for y lengrh of matrix

i = ampl_length;
while i > 0
max_max = max (max (matrixx)); % max-value in matrix
amp_max = max(matrixx(i, ); % max-value of each colum (y)
norm_f = amp_max - max_max; % if matrix-z-value is scaled linear, use: norm_f = amp_max / max_max;

matrixx_norm(i, = [matrixx(i, .- norm_f]; % normalize matrix by each row to max_max value - if matrix-z-value is scaled linear, use : matrixx_norm(i, = [matrixx(i, ./ norm_f];
i = i-1;
endwhile



if d_bug == 1;
disp ("DEBUG report: matrix_norm processed successfully " )
endif

endfunction
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is pole analysis ? percy Solid State 22 12th March 2006 02:03 PM
Midrange Analysis mbutzkies Multi-Way 4 25th May 2005 01:51 PM
noise analysis tenderland Tubes / Valves 5 29th March 2005 11:22 PM
FFT Analysis RobPhill33 Everything Else 22 19th March 2003 07:01 PM


New To Site? Need Help?

All times are GMT. The time now is 05:42 PM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2