annotate aim-mat/tools/@signal/savewave.asv @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 74dedb26614d
children
rev   line source
tomwalters@0 1 % method of class @signal
tomwalters@0 2 % savewave(sig,name[,ramp])
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 % name : name of the resulting sound file
tomwalters@0 5 % ramp: if given, then the signal is ramped with a linear ramp with
tomwalters@0 6 % that duration
tomwalters@0 7 % RETURN VALUE:
tomwalters@0 8 %
tomwalters@0 9 %
tomwalters@0 10 % (c) 2003, University of Cambridge, Medical Research Council
tomwalters@0 11 % Stefan Bleeck (stefan@bleeck.de)
tomwalters@0 12 % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
tomwalters@0 13 % $Date: 2003/06/11 10:27:46 $
tomwalters@0 14 % $Revision: 1.6 $
tomwalters@0 15
tomwalters@0 16 function savewave(sig,name,ramp)
tomwalters@0 17 % does some things, to make a nice sound out of it
tomwalters@0 18
tomwalters@0 19 if nargin < 3
tomwalters@0 20 ramp=0.0; % default ramp is off
tomwalters@0 21 end
tomwalters@0 22 if nargin < 2
tomwalters@0 23 name='just saved';
tomwalters@0 24 end
tomwalters@0 25
tomwalters@0 26
tomwalters@0 27
tomwalters@0 28 sig=rampamplitude(sig,ramp);
tomwalters@0 29 sig=scaletomaxvalue(sig,0.999);
tomwalters@0 30 if isempty(strfind(name,'.wav'))
tomwalters@0 31 name=sprintf('%s.wav',name);
tomwalters@0 32 end
tomwalters@0 33
tomwalters@0 34 fid=fopen(name,'w');
tomwalters@0 35 if fid==-1
tomwalters@0 36 disp(sprintf('can''t write file ''%s'', is file open in CoolEdit? If so please close!',name));
tomwalters@0 37 error('file open in CoolEdit... Cant write');
tomwalters@0 38 else
tomwalters@0 39 writetowavefile(sig,name);
tomwalters@0 40
tomwalters@0 41 end