wolffd@0: function mirsave(e,f) wolffd@0: wolffd@0: ext = 0; % Specified new extension wolffd@0: if nargin == 1 wolffd@0: f = '.envelope.mir'; wolffd@0: elseif length(f)>3 && strcmpi(f(end-3:end),'.wav') wolffd@0: ext = '.wav'; wolffd@0: if length(f)==4 wolffd@0: f = '.mir'; wolffd@0: end wolffd@0: elseif length(f)>2 && strcmpi(f(end-2:end),'.au') wolffd@0: ext = '.au'; wolffd@0: if length(f)==3 wolffd@0: f = '.mir'; wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: d = get(e,'Data'); wolffd@0: nf = length(d); wolffd@0: fs = get(e,'Sampling'); wolffd@0: nm = get(e,'Name'); wolffd@0: for i = 1:nf wolffd@0: di = d{i}{1}; wolffd@0: fsi = fs{i}; wolffd@0: nmi = nm{i}; wolffd@0: di = resample(di,11025,round(fs{i})); wolffd@0: di = rand(size(di)).*di; wolffd@0: di = di/max(max(max(abs(di))))*.9999; wolffd@0: di = reshape(di,[],1); wolffd@0: wolffd@0: %Let's remove the extension from the original files wolffd@0: if length(nmi)>3 && strcmpi(nmi(end-3:end),'.wav') wolffd@0: nmi(end-3:end) = []; wolffd@0: elseif length(nmi)>2 && strcmpi(nmi(end-2:end),'.au') wolffd@0: nmi(end-2:end) = []; wolffd@0: end wolffd@0: wolffd@0: if nf>1 || strcmp(f(1),'.') wolffd@0: %Let's add the new suffix wolffd@0: n = [nmi f]; wolffd@0: else wolffd@0: n = f; wolffd@0: end wolffd@0: wolffd@0: if not(ischar(ext)) || strcmp(ext,'.wav') wolffd@0: if length(n)<4 || not(strcmpi(n(end-3:end),'.wav')) wolffd@0: n = [n '.wav']; wolffd@0: end wolffd@0: wavwrite(di,11025,32,n) wolffd@0: elseif strcmp(ext,'.au') wolffd@0: if length(n)<3 || not(strcmpi(n(end-2:end),'.au')) wolffd@0: n = [n '.au']; wolffd@0: end wolffd@0: auwrite(di,11025,32,'linear',n) wolffd@0: end wolffd@0: disp([n,' saved.']); wolffd@0: end