c@0: function [y,fs,bits] = wavread(filename,arg) c@0: %WAVREAD Read an audio file c@0: % c@0: % WAVREAD is a wrapper function for audioread, using the same function c@0: % name and input arguments as the deprecated MATLAB WAVREAD function. It c@0: % is provided in order to improve the compatibility of legacy code. c@0: % c@0: % Y = WAVREAD(FILENAME) loads an audio file specified by the string c@0: % FILENAME, returning the sampled data in Y. Audio channels are returned c@0: % in the columns of Y. c@0: % c@0: % [Y,FS,BITS] = WAVREAD(FILENAME) returns the sample rate (FF) in Hertz c@0: % and the number of bits per sample (BITS) used to encode the data in the c@0: % file. c@0: % c@0: % ... = WAVREAD(FILENAME,N) returns only the first N samples from each c@0: % channel in the file. c@0: % c@0: % ... = WAVREAD(FILENAME,[N1 N2]) returns only samples N1 through N2 from c@0: % each channel in the file. c@0: % c@0: % SIZ = WAVREAD(FILENAME,'SIZE') returns the size of the audio data c@0: % contained in the file in place of the actual audio data, returning the c@0: % vector SIZ = [NumSamples NumChannels]. c@0: % c@0: % See also AUDIOREAD. c@0: c@0: % Copyright 2016 University of Surrey. c@0: c@0: % basic info c@0: info = audioinfo(filename); c@0: bits = info.BitsPerSample; c@0: c@0: if nargin>1 c@0: if ischar(arg) c@0: % return size c@0: if strcmpi(arg,'size') c@0: y = [info.TotalSamples info.NumChannels]; c@0: else c@0: error('Unknown argument ''%s'' specified',arg) c@0: end c@0: else c@0: % return some samples c@0: assert(isnumeric(arg) && numel(arg)<=2,'The second argument must be a one- or two-element numeric array.') c@0: [y,fs] = audioread(filename,arg); c@0: end c@0: else c@0: % return all samples c@0: [y,fs] = audioread(filename); c@0: end c@0: c@0: end