comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirenvelope/mirsave.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function mirsave(e,f)
2
3 ext = 0; % Specified new extension
4 if nargin == 1
5 f = '.envelope.mir';
6 elseif length(f)>3 && strcmpi(f(end-3:end),'.wav')
7 ext = '.wav';
8 if length(f)==4
9 f = '.mir';
10 end
11 elseif length(f)>2 && strcmpi(f(end-2:end),'.au')
12 ext = '.au';
13 if length(f)==3
14 f = '.mir';
15 end
16 end
17
18 d = get(e,'Data');
19 nf = length(d);
20 fs = get(e,'Sampling');
21 nm = get(e,'Name');
22 for i = 1:nf
23 di = d{i}{1};
24 fsi = fs{i};
25 nmi = nm{i};
26 di = resample(di,11025,round(fs{i}));
27 di = rand(size(di)).*di;
28 di = di/max(max(max(abs(di))))*.9999;
29 di = reshape(di,[],1);
30
31 %Let's remove the extension from the original files
32 if length(nmi)>3 && strcmpi(nmi(end-3:end),'.wav')
33 nmi(end-3:end) = [];
34 elseif length(nmi)>2 && strcmpi(nmi(end-2:end),'.au')
35 nmi(end-2:end) = [];
36 end
37
38 if nf>1 || strcmp(f(1),'.')
39 %Let's add the new suffix
40 n = [nmi f];
41 else
42 n = f;
43 end
44
45 if not(ischar(ext)) || strcmp(ext,'.wav')
46 if length(n)<4 || not(strcmpi(n(end-3:end),'.wav'))
47 n = [n '.wav'];
48 end
49 wavwrite(di,11025,32,n)
50 elseif strcmp(ext,'.au')
51 if length(n)<3 || not(strcmpi(n(end-2:end),'.au'))
52 n = [n '.au'];
53 end
54 auwrite(di,11025,32,'linear',n)
55 end
56 disp([n,' saved.']);
57 end