Mercurial > hg > ape
view aux/stereo2mono.m @ 8:2afd6ff39f08
prepare2listen fixes
author | Brecht De Man <b.deman@qmul.ac.uk> |
---|---|
date | Fri, 28 Nov 2014 00:52:12 +0000 |
parents | 4fd284285159 |
children | 0014c50188da |
line wrap: on
line source
function [] = stereo2mono(foldername) % STEREO2MONO Turns all stereo WAV files in a specified folder into two % mono WAV files, named origfilename_L.wav and origfilename_R.wav % % written by Brecht De Man at C4DM,QMUL on 26 April 2013 currentfolder = pwd; cd(foldername); % go to specified folder % go over all wav files in this folder files = dir('*.wav'); % remove hidden files % see http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/258220 for k = length(files):-1:1 fname = files(k).name; if fname(1) == '.' files(k) = [ ]; end end for k=1:length(files) disp(['Reading' files(k).name '...']); % TODO: check stereo without reading file [audio,fs] = audioread(files(k).name); % read audio % check if stereo; if so, get channels and save as separate wavfile if size(audio,2)==2 audiowrite([files(k).name(1:end-4) '_L.wav'],audio(:,1),fs, 'BitsPerSample', 24); audiowrite([files(k).name(1:end-4) '_R.wav'],audio(:,2),fs, 'BitsPerSample', 24); end end cd(currentfolder); % go back to original folder end