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

📄 impulsive_noise_meter.m

📁 我认为很不错的语音处理的matlab源代码
💻 M
📖 第 1 页 / 共 4 页
字号:
function [s, round_kind, round_digits]=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 )
% % Impulsive_Noise_Meter: Loads sound time records, finds Peaks, calculates impulsive sound metrics
% % 
% % Syntax;
% % 
% % [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 );
% % 
% % 
% % ********************************************************************
% % 
% % Description
% % 
% % The main program is Main_Sound which has dialog boxes for selecting 
% % filenames and other setting all of the paratmeters.  For convenience
% % the best way to use Impulsive_Noise_Meter program is to type
% % "Main_Sound" at the comand line.
% % 
% % The Impulsive_Noise_Meter program controls the data flow, and calls 
% % other programs to plot the time records, identify the peaks, computes
% % metrics for impulsive noise.  
% % 
% % Then the program finds the impulsive peaks and identifies each peak
% % with a circle in each plot and numbers the odd peaks.
% % 
% % Often several channels will be used to record the same impulsive noises
% % and it is useful to compare the same impulsive peaks. This program can
% % be set to select the corresponding peaks from all of the microphone
% % channels.
% % 
% % The figures are saved to a file.
% % 
% % The impulsive noise metrics are then calculated for each channel.
% % A statistical analysis is performed on the impulsive metrics and the
% % metrics and statistics are saved to a text file.
% % 
% % Once all of the files have been processed and saved a copy of all the
% % data is saved to a matlab structure.
% % 
% % ********************************************************************
% %  
% % Input Variables
% % 
% % filenamesin={'Impulse.mat'};    % cell array of filenames to process.  
% %                                 % default is uigetfile; a user windows
% %                                 % interface for slecting files.
% %
% % fileout_txt='test.txt';         % Filename to save data to a tab 
% %                                 % delimited text file.
% %
% % fileout_struct='Mertics.mat';
% %                             % File name for the output Matlab Data
% %                             % structures file.
% %                             %
% %                             % default is 'data1_struct';
% %
% %
% % same_ylim=1;                % 1 sets all of the limits of the y-axes 
% %                             % to the same values for each channel.
% %                             % The y-limits of the sound data is
% %                             % independent of the y-limits of the
% %                             % vibrations data.
% %                             %
% %                             % if same_ylim ~= 1 then the y-axis
% %                             % limits can be differenet values.
% %                             %
% %                             % default is same_ylim=1;
% % 
% % save_struct=1;              % Boolean controls whether to save all 
% %                             % data to a matlab structure.
% %                             % 
% %                             % default is save_struct=1;
% % 
% % 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)
% %                             %
% %                             % default is fig_format=1; pdf format
% % 
% % Tool_Name='Recip Saw';      % String which is the name of the tool
% %                             % or device under test.
% %                             % Typically should be 30 caracters or less.
% %                             %
% %                             % default is Tool_Name='';
% % 
% % 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 all requirements for 
% %                             % identifying peaks 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 0.25.
% % 
% % percent1=75;        % 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=1;    % 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;
% %
% % 
% % ********************************************************************
% % 
% % Output Variables
% %
% % s       % Is a cell array of structures.   
% %         % 
% %         % Each File and variable has its own cell and inside that cell
% %         % is s structure containing the metrics and
% %         % a description of the metrics data.  
% %         % 
% %         % The cells are arranged by [File_number Variable_Number]
% %         % So the structures are accessed by 
% %         %
% %         % s{file, var}.fieldname
% %         % 
% %         % The structure inside each cell contains the following fields
% %         % 
% %         % s{file, var}.filename is a char of the filename of the data 
% %         %            file which was processed.  
% %         % 
% %         % s{file, var}.variable is a char of the vriable name of the 
% %         %            variable within the filename of the data file 
% %         %            which was processed. 
% %         % 
% %         % s{file, var}.metrics is a cell array of numeric array of 
% %         %           metrics data for each identified impulsive peak 
% %         %           for each channel.  
% %         %
% %         %           size(s{1,1}.metrics)=[num_channels 1]
% %         %           size(s{1,1}.metrics{num_channel, 1})=[num_peaks, num_metrics]
% %         % 
% %         % s{file, var}.stats_of_metrics contains seven descriptive 
% %         %           statistical quantities for each metric and channel
% %         %           size(s{1,1}.stats_of_metrics)=[num_metrics num_channels num_stats]
% %         %
% %         %           The ststistical Quantities are
% %         %           Mean 
% %         %           Standard Deviation
% %         %           95 Confidence Interval 
% %         %           Median
% %         %           Index Median Value 
% %         %           Minimum 
% %         %           Maximum
% %         % 
% %         % s{file, var}.metrics_description isd a cell array of strings 
% %         %           which describe the metric and its units 
% %         %  
% %         %           s{1,1}.metrics_description{:, 1}  descriptive strings
% %         %           s{1,1}.metrics_description{:, 2}  units strings
% %         %  
% %         % s{file, var}.stats_description is a cell array containing the
% %         %           description for each of the descriptive statistical
% %         %           quntities which are
% %         %           Mean 
% %         %           Standard Deviation
% %         %           95 Confidence Interval 
% %         %           Median
% %         %           Index Median Value 
% %         %           Minimum 
% %         %           Maximum
% %         %           
% %         % s{file, var}.diff_chan is a row vector containing the channel
% %         %           numbers of the channels where the row vector is a 
% %         %           paired ordering of channel numbers.  
% %         %           Each pair contains a Primary channel and a Minus 
% %         %           channel.  
% %         %           
% %         %           The mean of the metrics of the Minus channel are
% %         %           subtracted from the mean of the metrics of Primary
% %         %           channel. 
% %         %           (For the peak values in (Pa) a ratio is computed.) 
% %         %           
% %         % s{file, var}.diff_metrics is a cell array containing numeric 
% %         %           arrays of the differences in the mean metrics.   
% %         %           size(s{1,1}.diff_metrics)=[num_peaks, num_metrics];
% %         %           
% %         %           The mean of the metrics of the Minus channel are
% %         %           subtracted from the mean of the metrics of Primary
% %         %           channel. 
% %         %           (For the peak values in (Pa) a ratio is computed.) 
% %         %           
% %         % s{file, var}.diff_stats_of_metrics is a numeric array of 
% %         %           descriptive statistics for the diff_metrics.  
% %         %           
% %         %           size(s{1,1}.diff_stats_of_metrics)=[num_metrics num_pairs_diff_chan num_stats];
% %         % 
% %         % s{file, var}.num_samples is a column vector of the number of 
% %         %            in each channel.  
% %         
% % 
% % round_kind=1;           % Array of values one element for the rta array
% %                         % and one element for each varargin array
% %                         % (see example)
% %                         % 1 round to specified number of significant
% %                         % digits
% %                         %
% %                         % 0 round to specified digits place
% %                         %
% %                         % default is round_kind=1;
% %
% % round_digits=3;         % Array of values one element for the rta array
% %                         % and one element for each varargin array
% %                         % (see example)% Type of rounding depends on round_kind
% %                         %
% %                         % if round_kind==1 number of significant digits
% %                         % if round_kind==0 specified digits place
% %                         %
% %                         % default is round_digits=3;
% % 
% %  
% % ********************************************************************
% 
% 
% 
% Example='1';
%
% % Create a data file;
% Fs_SP=100000; fc=1000; td=1; tau=0.01; delay=0.1; A1=2; A2=20;
% [SP, t]=analytic_impulse(Fs_SP, fc, td, tau, delay, A1, A2);
% save('default_data_file.mat', 'SP', 'Fs_SP');
%
% % Make appropriate settings for analyzing the default data file.
% 

⌨️ 快捷键说明

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