-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjp_makemono.m
36 lines (29 loc) · 879 Bytes
/
jp_makemono.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function jp_makemono(inputDirs);
% Make sure all .wav files are mono.
%
% If 2 (or more) channels, just use the first channel, and re-write.
%
% From https://github.com/jpeelle/jp_matlab
fprintf('\n');
if ischar(inputDirs)
inputDirs = {inputDirs};
end
for i=1:length(inputDirs)
d = dir(inputDirs{i});
for j = 1:length(d)
fileName = d(j).name;
if length(fileName)>4 && strcmpi(fileName(end-3:end),'.wav')
wavFile = fullfile(inputDirs{i},fileName);
try
[y,fs] = audioread(wavFile);
catch
error('Error reading %s.', wavFile);
end
if size(y,2) > 1
fprintf('Made %s mono.\n', wavFile);
audiowrite(wavFile, y(:,1), fs);
end
end
end
end % going through inputDirs to get files
fprintf('All done.\n\n');