annotate Utilities/wavwrite.m @ 38:c7d11a428a0d
tip master
Merge branch 'develop'
* develop:
Updated copyright year.
author |
Christopher Hummersone <c.hummersone@surrey.ac.uk> |
date |
Tue, 16 May 2017 12:15:34 +0100 |
parents |
e34a535b9af0 |
children |
|
rev |
line source |
c@0
|
1 function wavwrite(y,varargin)
|
c@0
|
2 %WAVWRITE Write an audio file
|
c@0
|
3 %
|
c@0
|
4 % WAVWRITE is a wrapper function for audiowrite, using the same function
|
c@0
|
5 % name and input arguments as the deprecated MATLAB WAVWRITE function. It
|
c@0
|
6 % is provided in order to improve the compatibility of legacy code.
|
c@0
|
7 %
|
c@0
|
8 % WAVWRITE(Y,FILENAME) writes an audio file specified by the string
|
c@0
|
9 % FILENAME. The audio data in Y should be arranged with one channel per
|
c@0
|
10 % column. The data are assumed to be sampled at 8000 Hz and 16 bits per
|
c@0
|
11 % sample.
|
c@0
|
12 %
|
c@0
|
13 % WAVWRITE(Y,FS,FILENAME) specifies the sample rate FS, in Hertz, of the
|
c@0
|
14 % data.
|
c@0
|
15 %
|
c@0
|
16 % WAVWRITE(Y,FS,N,FILENAME) forces an N-bit file format to be written,
|
c@0
|
17 % where N <= 32.
|
c@0
|
18 %
|
c@0
|
19 % See also AUDIOWRITE.
|
c@0
|
20
|
c@0
|
21 % Copyright 2016 University of Surrey.
|
c@0
|
22
|
c@0
|
23 % defaults
|
c@0
|
24 fs = 8000;
|
c@0
|
25 N = 16;
|
c@0
|
26
|
c@0
|
27 % determine arguments
|
c@0
|
28 switch nargin
|
c@0
|
29 case 1
|
c@0
|
30 error('Not enough input arguments')
|
c@0
|
31 case 2
|
c@0
|
32 filename = varargin{1};
|
c@0
|
33 case 3
|
c@0
|
34 fs = varargin{1};
|
c@0
|
35 filename = varargin{2};
|
c@0
|
36 case 4
|
c@0
|
37 fs = varargin{1};
|
c@0
|
38 N = varargin{2};
|
c@0
|
39 filename = varargin{3};
|
c@0
|
40 otherwise
|
c@0
|
41 error('Too many input arguments')
|
c@0
|
42 end
|
c@0
|
43
|
c@0
|
44 % write audio file
|
c@0
|
45 audiowrite(filename,y,fs,'BitsPerSample',N);
|
c@0
|
46
|
c@0
|
47 end
|