📄 playback.m
字号:
function playback(nn,type,vv)
% PLAYBACK .... Playback sound files of different quantization levels.
%
% PLAYBACK(N,TYPE) plays back the speech sound file which has
% been quantized by an N-bit and TYPE quantizer.
% Valid TYPE options are: 'uniform' and 'mu_law'.
%
% PLAYBACK( N, TYPE, K) is the same but sets the output volume to
% K where K is a positive integer between 0 and 100.
% The default value used by PLAYBACK(X,TYPE) is 80.
% AUTHORS : M. Zeytinoglu & N. W. Ma
% Department of Electrical & Computer Engineering
% Ryerson Polytechnic University
% Toronto, Ontario, CANADA
%
% DATE : January 1992.
% VERSION : 1.0
%===========================================================================
% Modifications history:
% ----------------------
% o Added "checking" 11.30.1992 MZ
% o Tested (and modified) under MATLAB 4.0/4.1 08.16.1993 MZ
%===========================================================================
global START_OK;
global BELL;
global WARNING;
check;
%--------------------------------------------------------------------------
% Default values
%--------------------------------------------------------------------------
DEFAULT_VOLUME = 80;
NOPT = nan;
%--------------------------------------------------------------------------
% Input parameter control
%--------------------------------------------------------------------------
if ((nargin ~= 1) & (nargin ~= 2) & (nargin ~= 3))
error(eval('eval(BELL),eval(WARNING),help playback'));
return;
end
%---------------------------------------------------------------------------
% Check validity of options
%---------------------------------------------------------------------------
if strcmp(type, 'uniform')
NOPT = 0;
elseif strcmp(type, 'mu_law')
NOPT = 1;
end
if isnan(NOPT), error('Unknown quantize TYPE'), end
if ( (nn > 8) | (nn < 1) )
error('Only N-bit quantized sound files with 1 <= N <= 8 are available');
end
%--------------------------------------------------------------------------
% Set parameters
%--------------------------------------------------------------------------
if( nargin == 2)
volume = DEFAULT_VOLUME;
else
if( (vv > 100) | (vv < 0) )
error('Volume level must be between 0 and 100');
return;
end
volume = vv;
end
if (NOPT == 0) % uniform
com = sprintf( ...
'!play -v%3.0f /usr/local/matlab/toolbox/etc/sounds/speech_q%1.0f.au', ...
volume, nn);
elseif (NOPT == 1) % mu-law
com = sprintf( ...
'!play -v%3.0f /usr/local/matlab/toolbox/etc/sounds/speech_mq%1.0f.au', ...
volume, nn);
end
%--------------------------------------------------------------------------
% Play bck the sound file
%--------------------------------------------------------------------------
eval( com );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -