📄 main_sound.m
字号:
function Main_Sound
% % Main_Sound: Main Program for the Impulsive Noise Meter and outputs a table of impulsive noise metrics
% %
% % Syntax:
% %
% % Main_Sound;
% %
% % ********************************************************************
% %
% % Description
% %
% % Main_Sound calculates metrics for impulsive noise.
% % Sound metrics include: peaks, Leq, LeqA, LeqC, kurtosis,
% % third octave band peaks and levels, and more.
% %
% % Main_Sound prompts the user for all of the inputs to the
% % Impulsive_Noise_Meter.m program and to the make_table_compare_systems.m
% %
% % Main_Sound has no Input or Output Variables.
% %
% % The user selects either matlab or wav files to analyze for sound.
% % There are a series of prompts for output filenames,
% % formating of output images of the figures, and the Name of the device
% % under test (Tool Name).
% %
% % The metrics calculated in this program are for time records of 1 second
% % or longer. Time records shorter than 1 second may not have accurate
% % results.
% %
% % The program is limited in its memory and capacity to process long
% % time records and calculate the metrics. In general, the program can
% % process files with a few million data points without crashing.
% %
% %
% % ********************************************************************
%
% Example='1';
%
% % One Example is shown for sound data.
% % The example illustrates the definitions of the time
% % increment variables which the user is prompted to select.
%
%
% % Step 1) Create a data file;
%
% % Set the sampling rate variables for sound and vibrations
% Fs_SP=50000;
%
% % Set the time increment variables for the sound data
% % t_SP, dt_SP are time increment variables for sound
%
% dt_SP=1/Fs_SP;
% t_SP=0:(1/Fs_SP):20;
%
% % SP is the sound pressure data
% % (3 channels for 20 seconds at 50 KHz sampling rate)
% SP=randn(3, length(t_SP));
%
% save('Example_data_file.mat', 'SP', 'Fs_SP','t_SP', 'dt_SP');
%
% % Step 2) Run the program;
%
% Main_Sound;
%
%
%
%
% Example='1';
%
% clear all;
% Fs_SP=50000; fc=1000; td=1; tau=0.01; delay=0.1; A1=8; A2=21;
% [SP1, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=1000; td=1; tau=0.1; delay=0.1; A1=2; A2=22;
% [SP2, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=1000; td=2; tau=0.4; delay=0.1; A1=2; A2=17;
% [SP3, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=2000; td=1; tau=0.1; delay=0.1; A1=8; A2=15;
% [SP4, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% SP=[[0.9*SP4 SP1 0.3*SP3 SP2 0.5*SP4 0.2*SP1 SP3 5*SP2];...
% [SP1 0.7*SP4 10*SP2 SP3 0.4*SP2 0.5*SP3 SP1 1*SP4];...
% [SP3 0.2*SP1 0.5*SP4 2*SP2 0.4*SP2 0.7*SP3 0.3*SP1 10*SP4];...
% [SP1 0.7*SP2 0.3*SP3 SP4 0.4*SP1 10*SP2 SP3 1*SP4]];
% [SP]=sub_mean2(SP, Fs_SP, 25);
% save('default_data_file.mat', 'SP', 'Fs_SP');
%
%
% Fs_SP=50000; fc=100; td=1; tau=0.1; delay=0.2; A1=4; A2=12;
% [SP1, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=500; td=1; tau=0.2; delay=0.15; A1=3; A2=12;
% [SP2, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=2500; td=2; tau=0.2; delay=0.05; A1=6; A2=9;
% [SP3, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=2000; td=1; tau=0.01; delay=0.12; A1=5; A2=11;
% [SP4, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% SP=[[0.9*SP4 SP1 0.3*SP3 SP2 0.5*SP4 0.2*SP1 SP3 5*SP2];...
% [SP1 0.7*SP4 10*SP2 SP3 0.4*SP2 0.5*SP3 SP1 1*SP4];...
% [SP3 0.2*SP1 0.5*SP4 2*SP2 0.4*SP2 0.7*SP3 0.3*SP1 10*SP4];...
% [SP1 0.7*SP2 0.3*SP3 SP4 0.4*SP1 10*SP2 SP3 1*SP4]];
% [SP]=sub_mean2(SP, Fs_SP, 25);
% save('default_data_file2.mat', 'SP', 'Fs_SP');
%
%
% Fs_SP=50000; fc=2000; td=1; tau=0.15; delay=0.2; A1=3; A2=135;
% [SP1, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=5000; td=1; tau=0.2; delay=0.15; A1=3; A2=12;
% [SP2, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=4000; td=2; tau=0.1; delay=0.05; A1=2; A2=34;
% [SP3, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=600; td=1; tau=0.01; delay=0.12; A1=5; A2=141;
% [SP4, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% SP=[[0.9*SP4 SP1 0.3*SP3 SP2 0.5*SP4 0.2*SP1 SP3 5*SP2];...
% [SP1 0.7*SP4 10*SP2 SP3 0.4*SP2 0.5*SP3 SP1 1*SP4];...
% [SP3 0.2*SP1 0.5*SP4 2*SP2 0.4*SP2 0.7*SP3 0.3*SP1 10*SP4];...
% [SP1 0.7*SP2 0.3*SP3 SP4 0.4*SP1 10*SP2 SP3 1*SP4]];
% [SP]=sub_mean2(SP, Fs_SP, 25);
% save('default_data_file3.mat', 'SP', 'Fs_SP');
%
%
% Fs_SP=50000; fc=3000; td=1; tau=0.23; delay=0.2; A1=33; A2=167;
% [SP1, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=2000; td=1; tau=0.23; delay=0.15; A1=34; A2=122;
% [SP2, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=400; td=2; tau=0.15; delay=0.05; A1=12; A2=134;
% [SP3, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% Fs_SP=50000; fc=1000; td=1; tau=0.13; delay=0.12; A1=52; A2=121;
% [SP4, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% SP=[[0.9*SP4 SP1 0.3*SP3 SP2 0.5*SP4 0.2*SP1 SP3 5*SP2];...
% [SP1 0.7*SP4 10*SP2 SP3 0.4*SP2 0.5*SP3 SP1 1*SP4];...
% [SP3 0.2*SP1 0.5*SP4 2*SP2 0.4*SP2 0.7*SP3 0.3*SP1 10*SP4];...
% [SP1 0.7*SP2 0.3*SP3 SP4 0.4*SP1 10*SP2 SP3 1*SP4]];
% [SP]=sub_mean2(SP, Fs_SP, 25);
% save('default_data_file4.mat', 'SP', 'Fs_SP');
%
% Main_Sound;
%
%
%
% % ********************************************************************
% %
% %
% % Subprograms
% %
% % This program requires the Matlab Signal Processing Toolbox
% % This program uses a recreation of oct3dsgn by Christophe Couvreur 69
% %
% %
% %
% %
% % List of Dependent Subprograms for
% % Main_Sound
% %
% %
% % Program Name Author FEX ID#
% % 1) A_duration
% % 2) abcd_durations
% % 3) ACdsgn
% % 4) ACweight_time_filter
% % 5) allstats Duane Hanselman NA
% % 6) analytic_impulse
% % 7) B_duration
% % 8) C_duration
% % 9) calc_diff_metrics
% % 10) calc_impuls_threshold_and_index
% % 11) choosebox Peter Wasmeier 4141
% % 12) convert_double
% % 13) D_duration
% % 14) data_loader2
% % 15) data_outliers3
% % 16) estimatenoise John D'Errico 16683
% % 17) file_extension
% % 18) filter_settling_data
% % 19) findextrema Schuberth Schuberth 3586
% % 20) fix_YTick
% % 21) func_threshold Jing Tian 10462
% % 22) genHyper Ben Barrowes 6218
% % 23) geomean2
% % 24) get_p_q
% % 25) hilbert2
% % 26) Impulsive_Noise_Meter
% % 27) kurtosis2
% % 28) Leq_all_calc
% % 29) LMS_trim
% % 30) LMSloc Alexandros Leontitsis 801
% % 31) LMTSregor
% % 32) localpeaks
% % 33) m_round
% % 34) make_summary_impls_stats_table
% % 35) moving Aslak Grinsted 8251
% % 36) nth_freq_band
% % 37) Nth_oct_time_filter2
% % 38) Nth_octdsgn
% % 39) num_impulsive_samples
% % 40) parseArgs Malcolm Wood 10670
% % 41) peak_index
% % 42) peak_threshhold_function
% % 43) percentiles
% % 44) plot_snd_vibs
% % 45) plotpeaks
% % 46) pow10_round
% % 47) print_channel_stats
% % 48) print_data_loader_configuration_table
% % 49) print_outliers_indices
% % 50) print_overall_stats
% % 51) psuedo_box
% % 52) rand_int
% % 53) resample_plot
% % 54) save_a_plot2_audiological
% % 55) sd_round
% % 56) snd_peak_metrics
% % 57) splat_cell
% % 58) sub_mean
% % 59) sub_mean2
% % 60) subaxis Aslak Grinsted 3696
% % 61) t_alpha
% % 62) t_confidence_interval
% % 63) t_icpbf
% % 64) tableGUI Joaquim Luis 10045
% % 65) threshold_bin_peaks
% % 66) wsmooth Damien Garcia NA
% %
% %
% % ********************************************************************
% %
% % References (standards and Journal Articles)
% %
% %
% % Guido F. Smoorenburg, "Damage Risk Criteria for Impulsive
% % Noise," New Perspectives on Noise Induced Hearing Loss,
% % Raven Press, New York, pages(471-490) 1982
% %
% %
% % References For Sound
% %
% % ANSI S1.4-1983 American National Standard
% % Specificaitons for Sound Level Meters
% %
% % ANSI S1.43-1997 American National Standard
% % Specificaitons for Integrating-Averaging Sound Level
% % Meters
% %
% % ANSI S1.11-1986 American National Standard
% % Specification for Octave-band and Fractional-Octave-
% % band Analog and Digital Filters
% %
% % ANSI S3.44-1986 American National Standard
% % Determination of Occupational Noise Exposure and
% % Estimation of Noise Induced Hearing Impairment
% %
% %
% % ********************************************************************
% %
% % Program Written by Edward L. Zechmann
% %
% % date 16 September 2008
% %
% % modified 17 September 2008 Updated Comments
% % Added the option to print a summary
% % statistics table
% %
% % modified 19 September 2008 Updated Comments
% %
% % modified 11 November 2008 Fixed a bug in the selection of
% % channels for calculating differences in
% % metrics between two channels.
% %
% % modified 10 December 2008 Upgraded the third octave band
% % filtering programs and the A and C-
% % weighting filter programs to include
% % filter settling and resampling.
% %
% % modified 11 December 2008 Upgraded the A and C-
% % weighting filter programs,
% % to include iterative filtering.
% % The filters are now very stable.
% %
% % Removed filter coefficients from input
% % and output;
% % Peaks pressures and Levels are output.
% %
% % modified 16 December 2008 Use convolution to make filter
% % coefficients (b and a) into
% % arrays from cell arrays.
% %
% % modified 5 January 2009 Added sub_mean to the Nth octave
% % band filters and A and C weighting
% % filters.
% %
% % modified 19 January 2009 Updated summary table to include
% % rounding.
% %
% %
% %
% % ********************************************************************
% %
% % Please feel free to modify this code.
% %
% % See Also: Impulsive_Noise_Meter, Continuous_Sound_and_Vibrations_Analysis
% %
% % ********************************************************************
%
% Get input parameters using various input boxes, menus, listboxes, etc...
%
% % ********************************************************************
%
% Get the filenames to process
%
[filenamesin, pathname, filterindex] = uigetfile( { '*.mat','*.wav'}, 'Select the files To Process', 'MultiSelect', 'on');
cd(pathname);
% expecting a cell array of strings
% if only one file is selected then it will be a character array or a
% single string
% convert into a cell array if necessary
if ischar(filenamesin) && isequal(exist(filenamesin), 2)
filenamesin={filenamesin};
end
if ~iscell(filenamesin) || isempty(filenamesin) || length(filenamesin) < 1
error('Must select at least 1 file to analyze');
end
% % ********************************************************************
%
% Get the filenames to save the text file and the matlab structures.
%
prompt= {['Enter the File Name for the Output Text file'], ['Enter the File Name for the Output Matlab Sructure Data file. .']};
defAns={'Impulse_snd', 'Impulse_snd'};
dlg_title='Enter File Names for Saving the Program Metrics and Descriptive Statistics';
num_lines=1;
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
file_name_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);
if isempty(file_name_cell)
fileout_txt='Impulse_text';
fileout_struct='Impulse_snd';
else
fileout_txt=file_name_cell{1};
fileout_struct=file_name_cell{2};
end
% % ********************************************************************
%
% Determine whether to save the Matlab structure or not
%
save_struct=menu('Save the Matlab Output Data Structure?', 'Yes', 'No', 'Default');
if isequal(save_struct, 2)
save_struct=0;
else
save_struct=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -