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

📄 f_getsound.asv

📁 DSP程序 Matlab是一套用于科学工程计算的可视化高性能语言与软件环境。它集数值分析、矩阵运算、信号处理和图形显示于一体
💻 ASV
字号:
function [x,cancel] = f_getsound (x,duration,fs,xstr);

%F_GETSOUND: Record sound from PC microphone
%
% Usage: [x,cancel] = f_getsound (x,duration,fs);
%
% Inputs: 
%         x        = an array of length n containing original samples
%         duration = length of recording in seconds (0 to 10)
%         fs       = sampling frequency in Hz (default 8000)
%         xstr     = optional name containing string specifying name to use
%
% Outputs: 
%          x      = an array of length N = floor(duration*fs) containing
%                   microphone samples
%          cancel = true if cancel button is clicked
%
% Notes: This function requires a Windows PC.
%
%  See also: SOUNDSC

% Initialize

channels = 1;
dtype = 'double';
seconds = f_clip (duration,0,10);
if nargin < 3
    fs = 8000;            % 8000, 11025, 22050, 44100
end
if nargin < 4
    xstr 

% Record the sound

cancel = 0;
N = floor(seconds*fs);
xstr = inputname(1);
caption = sprintf ('Click Start to begin recording %.1f seconds of microphone data in %s.',...
                    seconds,xstr);
choice = questdlg (caption,'Recorded Input','Start','Cancel','Start');
if strcmp(choice,'Start')
    x = wavrecord (N,fs,channels,dtype);
else
    cancel = 1;
end

 

⌨️ 快捷键说明

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