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

📄 main_sound.m

📁 我认为很不错的语音处理的matlab源代码
💻 M
📖 第 1 页 / 共 3 页
字号:
end


% % ********************************************************************
%
% Get the Peak Time interval
%
prompt= {['Enter the Peak Interval (seconds)']};
defAns={'1.0',};
dlg_title='Enter the time interval for each peak default is 1.0 seconds';
num_lines=1;

options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';

peak_interval_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

if isempty(peak_interval_cell)
    peak_interval=1;
else
    peak_interval=str2double(peak_interval_cell{1});
end



% % ********************************************************************
%
% Determine whether to make a plot of impulsive noise time records
% including all identified impulsive peaks.
%
make_plot=menu('Make a plot of the impulsive noise time records?', 'Yes', 'No', 'Default');

if isequal(make_plot, 2)
    make_plot=0;
else
    make_plot=1;
end




% % ********************************************************************
%
% Determine whether to make a plot of impulsive noise time records
% including all identified impulsive peaks.
%

if isequal(make_plot, 1)
    save_plot=menu('Save a plot of the impulsive noise time records?', 'Yes', 'No', 'Default');

    if isequal(save_plot, 2)
        save_plot=0;
    else
        save_plot=1;
    end

else
    save_plot=0;
end



% % ********************************************************************
%
% Get the Tool Name
%
prompt= {['Enter the Tool Name or Description']};
defAns={'Circular Saw 6000'};
dlg_title='Device Under Test Name, Tool Name, or Description';
num_lines=1;

options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';

Tool_Name_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

if isempty(Tool_Name_cell)
    Tool_Name='';
else
    Tool_Name=Tool_Name_cell{1};
end



% % ********************************************************************
%
% Prompt the user to declare which File Formats to save the Figures as
% Images
%
str{1}='1 .pdf   Portable Document Format Default';
str{2}='2 .fig    Matlab Figure Format';
str{3}='3 .jpg   (200 dpi resolution)';
str{4}='4 .eps  Encapsulated Post Script';
str{5}='5 .tiff   Tagged Image File Format (200 dpi resolution)';
str{6}='6 .tiff   (no compression) suggested for publications)';

prompt={'Which formats should the Files be saved in?', 'Select Desired Formats',' For Saving Figure Images'};
[fig_format,ok] = listdlg('Name', 'figure Formats', 'PromptString', prompt,'SelectionMode','multiple','ListString',str, 'InitialValue', [1], 'ListSize', [500, 500]);

if (isempty(fig_format) || any(logical(fig_format < 1))) || (any(logical(fig_format > 6)) || any(~isequal(ok, 1)))
    fig_format=1;
end



% % ********************************************************************
%
%  Get whether the y-axes should have the same limits
%
same_ylim = menu('Should the y-axes have the same limits For each channel?', 'Yes', 'No', 'Default');

if isequal(same_ylim, 2)
    same_ylim=0;
else
    same_ylim=1;
end



% % ********************************************************************
%
%  Get whether to suppress the minimum peak limit requirement
%
sar = menu('Suppress the minimum peak limit requirement?', 'Yes', 'No', 'Default');

if isequal(sar, 2)
    sar=0;
else
    sar=1;
end



% % ********************************************************************
%
%  Get the requried minimum peak amplitude (Pa) converted from (dB)
%
if isequal(sar, 0)

    prompt= {'Enter the Minimum Peak Level (dB)'};
    defAns={'120'};
    dlg_title='Each peak must be greater than the minimum peak level.';
    num_lines=1;

    options.Resize='on';
    options.WindowStyle='normal';
    options.Interpreter='tex';

    min_peak_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

    if isempty(min_peak_cell)
        min_peak=30;
    else
        min_peak=0.00002*10^(str2double(min_peak_cell{1})/20);
    end

else
    sar=1;
    min_peak=30;
end



% % ********************************************************************
%
% Enter the maximum number of channels to be analyzed in a single file
%
prompt= {'Enter the Maximum number of channels of sound data to be analyzed in a single file and variable.'};
defAns={'2'};
dlg_title='Enter the maximum number of channels of sound data to analyze.';
num_lines=1;

options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';

num_chan_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

if isempty(num_chan_cell)
    num_chan=2;
else
    num_chan=str2double(num_chan_cell{1});
end

num_chan=round(num_chan);

if num_chan  < 1
    num_chan=1;
end



% % ********************************************************************
%
% Enter the names of the channels such as {'Unprotected', 'Protected'}
%
% These labels will appear on the time record plots in the bottom right
% corner for each channel
%
switch num_chan
    case 1
        plot_str={'Channel 1'};
    case 2
        plot_str={'Unprotected', 'Protected'};
    otherwise

        plot_str={'Unprotected', 'Protected'};
        for e1=1:(num_chan-2);
            plot_str{e1+2}=num2str(e1+2);
        end
end

% initialize the default answers for the  channel labels (plot_str)
prompt=cell(num_chan,1);
defAns=cell(num_chan,1);

for e1=1:num_chan;

    prompt{e1}= ['Enter label for Channel ', num2str(e1), '.'];

    if isempty(plot_str{e1})
        defAns{e1}=['Channel ', num2str(e1)];
    else
        defAns{e1}=plot_str{e1};
    end

end

dlg_title='Enter the maximum number of channels of sound data to analyze.';
num_lines=1;

options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';

plot_str_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

if isempty(plot_str_cell)
    plot_str=defAns;
else
    plot_str=plot_str_cell;
end



% % ********************************************************************
%
%  Get the channel number to align the impulsive peaks
%
Align_peaks = menu('Align peaks to the peaks of a channel?', 'Yes', 'No', 'Default');

if isequal(Align_peaks, 2)
    Align_peaks=0;
else
    Align_peaks=1;
end


if isequal(Align_peaks, 0)
    Align_peaks=[];
else

    prompt= {'Enter the channel number to align all of the impulsive peaks to.'};
    defAns={'1'};
    dlg_title='Enter the number of the channel to align the peaks.';
    num_lines=1;

    options.Resize='on';
    options.WindowStyle='normal';
    options.Interpreter='tex';

    Align_peaks_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

    if isempty(num_chan_cell)
        Align_peaks=1;
    else

        Align_peaks=ceil(str2double(num_chan_cell{1}));
        if Align_peaks > num_chan
            Align_peaks=num_chan;
        end

        if Align_peaks < 1
            Align_peaks=1;
        end

    end

end



% % ********************************************************************
%
% Get whether the figures should be saved in portrait or landscape
%
portrait_landscape = menu('Choose Orientation of the Figures? Portrait is better for more than 4 channels of data.', 'Portrait', 'Landscape', 'Default');

if isequal(portrait_landscape, 2)
    portrait_landscape=2;
else
    portrait_landscape=1;
end



% % ********************************************************************
%
% Get the peak alignment tolerance fraction
%
if ~isempty(Align_peaks)
    prompt= {'Enter the peak alignment tolerance fraction.'};
    defAns={'0.25'};
    dlg_title='Enter the fraction of the impulsive peak interval for aligning the impulses.';
    num_lines=1;

    options.Resize='on';
    options.WindowStyle='normal';
    options.Interpreter='tex';

    peak_alignment_tol_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

    if isempty(peak_alignment_tol_cell)
        peak_alignment_tol=0.25;
    else

        peak_alignment_tol=str2double(peak_alignment_tol_cell{1});
        if peak_alignment_tol > 1
            peak_alignment_tol=0.9;
        end

        if peak_alignment_tol < 0
            peak_alignment_tol=0.01;
        end

    end
else
    peak_alignment_tol=0.25;
end



% % ********************************************************************
%
% Get the percent of the highest peak level
% to set the threshold for identifying an impulsive peak.
%
percent1 = menu('Use percentage of the highest peak as a threshold to identify peaks?', 'Yes', 'No', 'Default');
if isequal(percent1, 1)

    prompt= {'Enter the percentage of the highset peak to threshold peak identification.'};
    defAns={'75'};
    dlg_title='Enter the percentage of the highset peak to threshold peak identification.';
    num_lines=1;

    options.Resize='on';
    options.WindowStyle='normal';
    options.Interpreter='tex';

    percent1_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);

⌨️ 快捷键说明

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