⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 impulsive_noise_meter.m

📁 我认为很不错的语音处理的matlab源代码
💻 M
📖 第 1 页 / 共 4 页
字号:
% filenamesin={'default_data_file.mat'};
%                               % cell array of strings of filenames to
%                               % process.  These files can be matlab files
%                               % or wave files
% 
% fileout_txt='fileout.txt';    % string filename to save data to a tab
%                               % delimited text file
% 
% fileout_struct='fileout.mat'; % string filename to save data to a
%                               % matlab structure file
% 
% save_struct=1;            % 1 save all data to a matlab structure
%                           % The structure contains all of the impulsive
%                           % noise data from each of the impulses in each
%                           % channel in each file.
%                           % 0 do not save data to a matlab
%                           % structure
% 
% peak_interval=1;          % 1 seconds.  Time interval of data to analyze
%                           % each peak.  Amount of data for calculating
%                           % metrics and Leqs.
% 
% make_plot=1;              % 1 to make plots for each channel analyzed.
%                           % otherwise will not make any plots
% 
% save_plot=1;              % 1 will save a plot.
%                           % otherwise will not not save plots
%                           % plots will not be saved if they are not made
%                           % the file name of hte plot is the
%                           % filename of the data file with the string
%                           % '_peaks' appended at the end.
%                           
% fig_format=[1,2,3,4,5,6]; % image format for saving the plot
%                           % 1 pdf    default is 1 suggested
%                           %          for simple documentation
%                           % 2 fig
%                           % 3 jpg  (200 dpi resolution)
%                           % 4 eps2
%                           % 5 tiff (200 dpi resolution)
%                           % 6 tiff (no compression) suggested for
%                           %         publications)
%                           
% Tool_Name='Hammer Drill'; % string input for the Name of the
%                           % test device.
% 
% same_ylim=1;              % 1 will set all of the ylimits of each of the
%                           % channels to the same value.
% 
% min_peak=30;              % is the peak value in Pa that is the minimum
%                           % for being consiedered a peak.
% 
% sar=1;                    % 1 suspend the requirements for being a peak
%                           % and force the program to find at least one
%                           % peak.  The program can crash if it does
%                           % not find a peak; however, this has rarely been a
%                           % problem.
%                           %
%                           % otherwise enforce all impulsive peak criteria
%                       
% plot_str={'Protected', 'Unprotected'};
%                           % Add a string to each subaxes indicating the
%                           % meaning of the data.  For hearing protector
%                           % research one microphone is under the
%                           % hearing protector so it is 'Protected'
%                           % and the other microphone is exposed so it is
%                           % 'Unprotected'.
%
% Align_peaks=1;            % Specifies which channel to align all of the 
%                           % peaks.  Can be empty then all peaks are 
%                           % found independently. 
% 
% portrait_landscape=1;     % 1 is for Potrait
%                           % Otherwise Landscape
% peak_alignment_tol=0.25; 
%                 % This input sets the fraction of the datapoints 
%                 % of num_pts_per_pk_intrl that a peak can be offset. 
%                 % When aligning peaks, the channels are 
%                 % synchronized, but temorally the peaks may be  
%                 % misaligned by a few milliseconds.  The 
%                 % alignment tolerance allows the program to find 
%                 % the maximum peak within the alignment 
%                 % tolerance. 
%                 % 
%                 % default is peak_alignment_tol=0.25; 
%                 % 
%                 % Further explanation of peak_alignment_tol
%                 % One-half of the datapoints of num_pts_per_pk_intrl are 
%                 % used for finding the index of the maximum sound 
%                 % pressure amplitude.    
%                 % 
%                 % The impulsive peak is found by selecting the highest 
%                 % sound pressure amplitude starting at the center of 
%                 % the bin and working toward the maximum radius which 
%                 % is one-half of teh data points for the impulse.  
%  
%  
% percent1=[];        % Is the percentage of the peak levels of the  
%                     % time record after signal processing to remove
%                     % continuous noise and sharpen the peak levels.
%                     % The default is percent1=[];    
%                     % 
%                     % If percent1 is empty, < 0, or > 100 then 
%                     % it is set to [] and not considered during
%                     % processing;   
%                     % 
%                     % percent1=75; is a typical value
% 
% exhaust_cycle=0;    % 1 use the threshold method approppriate for 
%                     % finding exhaust noise type impulses.   
%                     % 
%                     % Otherwise the method for impact type impulsive
%                     % noises is used.
%                     % 
%                     % The default value is exhaust_cycle=0;
% 
% sod=0;              % 1 surpress outlier detection
%                     % 0 find the outliers and remove them from the
%                     % statistical analysis
%                     % default is sod=1;
% 
% [s]=Impulsive_Noise_Meter(filenamesin, fileout_txt, fileout_struct, save_struct, peak_interval, make_plot, save_plot, fig_format, Tool_Name, same_ylim, min_peak, sar, plot_str, Align_peaks, portrait_landscape, peak_alignment_tol, percent1, exhaust_cycle, sod );
% 
% 
% % ********************************************************************
%
% 
% 
% Example='2';
% 
% % Simulate 8 impulses in 4 microphones with different time records
%
% Fs_SP=100000; 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=100000; 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=100000; 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=100000; 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]];
%
% % Subtract the running mean value
% [SP]=sub_mean2(SP, Fs_SP, 25);
%
% % save the SP data variable to a matfile data file
%
% save('default_data_file.mat', 'SP', 'Fs_SP');
%
% % save the data to a wav file
%
% cf=1/(10*max(max(max(abs(SP)))));
% [pp, buf, rdr]=sd_round(cf, 3);
% numstr=eval(['sprintf( ', ' ''%9.', num2str(rdr), 'f''', ', pp )']);
% fprintf(1, '%s\r', ['When Prompted use the calibration factor ', numstr]);
%
% wavwrite(cf*SP', Fs_SP, 16, 'default_data_file.wav');
%
% % Run the Main_Sound just respond to the prompts!
%
% Main_Sound;
%
%
%
% % ********************************************************************
%
%
% Example='3';
%
% Try to run the Impulsive_Noise_Meter from the Command Line 
% 
% Fs_SP=100000; 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=100000; 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=100000; 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=100000; 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]];
%
% simulate 8 impulses in 4 microphones with different time records
%
% 
% % save the SP data variable to a matfile data file
% 
% save('default_data_file.mat', 'SP', 'Fs_SP');
% 
% % save the data to a wav file
% 
% cf=1/(10*max(max(max(abs(SP)))));
% [pp, buf, rdr]=sd_round(cf, 3);
% numstr=eval(['sprintf( ', ' ''%9.', num2str(rdr), 'f''', ', pp )']);
% fprintf(1, '%s\r', ['When Prompted use the calibration factor ', numstr]);
% 
% wavwrite(cf*SP', Fs_SP, 16, 'default_data_file.wav');
% 
% filenamesin={'default_data_file.mat', 'default_data_file.wav'};
% fileout_txt='fileout.txt';
% fileout_struct='fileout.mat';
% save_struct=1;
% peak_interval=0.5;
% make_plot=1;
% save_plot=1;
% fig_format=[1];
% Tool_Name='Hammer';
% same_ylim=1;
% min_peak=30;
% sar=1;
% plot_str={'Protected', 'Unprotected'};
% Align_peaks=2;
% portrait_landscape=1;
% peak_alignment_tol=0.25;
% percent1=[];
% exhaust_cycle=[];
% sod=0;
%
%
% % [s]=Impulsive_Noise_Meter(filenamesin, fileout_txt, fileout_struct, save_struct, peak_interval, make_plot, save_plot, fig_format, Tool_Name, same_ylim, min_peak, sar, plot_str, Align_peaks, portrait_landscape, peak_alignment_tol, percent1, exhaust_cycle, sod );
% 
%
% % ********************************************************************
% 
% Example='4';
% 
% Try to analyze the Guns_example.wav using the command line with 
% the Impulsive_Noise_Meter
%
% When prompted use a calibration factor of 0.0001
%
% Note that mic 2 does not have adequate dynamic resolution
% 
% filenamesin={'Guns_example.wav'};
% fileout_txt='fileout.txt';
% fileout_struct='fileout.mat';
% save_struct=1;
% peak_interval=0.1;
% make_plot=1;
% save_plot=1;
% fig_format=[1];
% Tool_Name='Guns';
% same_ylim=1;
% min_peak=30;
% sar=1;
% plot_str={'Unprotected', 'Protected'};
% Align_peaks=1;
% portrait_landscape=1;
% peak_alignment_tol=0.25;
% percent1=[];
% exhaust_cycle=[];
% sod=0;
%
%
% % [s]=Impulsive_Noise_Meter(filenamesin, fileout_txt, fileout_struct, save_struct, peak_interval, make_plot, save_plot, fig_format, Tool_Name, same_ylim, min_peak, sar, plot_str, Align_peaks, portrait_landscape, peak_alignment_tol, percent1, exhaust_cycle, sod );
%
% % ********************************************************************
%
%
% Example='5';
%
% Run the Main_Sound and open the Guns_example.wav this time!
% 
%
% Main_Sound;
%
% 
% % ********************************************************************
% % 
% % Reference: Guido F. Smoorenburg, "Damage Risk Criteria for Impulsive
% %            Noise," New Perspectives on Noise Induced Hearing Loss, 
% %            Raven Press, New York, pages(471-490) 1982
% % 
% % ********************************************************************
% % 
% % 
% % 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 
% % Impulsive_Noise_Meter
% % 
% % 
% % Program Name   Author   FEX ID#
% %  1) A_duration		
% %  2) abcd_durations		
% %  3) ACdsgn		
% %  4) ACweight_time_filter		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -