tomwalters@0: % method of class @signal tomwalters@0: % savewave(sig,name[,ramp]) tomwalters@0: % INPUT VALUES: tomwalters@0: % name : name of the resulting sound file tomwalters@0: % ramp: if given, then the signal is ramped with a linear ramp with tomwalters@0: % that duration tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % bleeck@3: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: tomwalters@0: function savewave(sig,name,ramp) tomwalters@0: % does some things, to make a nice sound out of it tomwalters@0: tomwalters@0: if nargin < 3 tomwalters@0: ramp=0.0; % default ramp is off tomwalters@0: end tomwalters@0: if nargin < 2 tomwalters@0: name='just saved'; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: sig=rampamplitude(sig,ramp); tomwalters@0: sig=scaletomaxvalue(sig,0.999); tomwalters@0: if isempty(strfind(name,'.wav')) tomwalters@0: name=sprintf('%s.wav',name); tomwalters@0: end tomwalters@0: tomwalters@0: fid=fopen(name, 'w'); tomwalters@0: if fid==-1 tomwalters@0: disp(sprintf('can''t write file ''%s'', is file open in CoolEdit? If so please close!',name)); tomwalters@0: error('file open in CoolEdit... Cant write'); tomwalters@0: else tomwalters@0: % TCW AIM 2006 tomwalters@0: fclose(fid); % Otherwise MATLAB leaves the file open for writing for ever! tomwalters@0: tomwalters@0: writetowavefile(sig,name); tomwalters@0: end