Last active
January 5, 2016 12:32
-
-
Save yogiblue/4f011ea67200f07b221f to your computer and use it in GitHub Desktop.
Split a directory of two channel wav recordings into separate mono flac files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ ] = SplitAudioChannels( ) | |
%SPLITAUDIOCHANNELS Split a 2 channel wav file into two flac files | |
% Reads a directory of wav files containing 2 channels of audio | |
% Reads in the wav file, stores the left hand recording | |
% Repeats the process for the right hand recording | |
% All audio files start with the name 2014/2015 | |
AllFiles = dir('201*.wav'); | |
% Computes the number of files in the current directory | |
NumFiles = length(AllFiles); | |
display('Splitting audio channels'); | |
display('Making left and right directories '); | |
mkdir('left'); | |
mkdir('right'); | |
display('Processing ... '); | |
display(num2str(NumFiles)); | |
for i = 1:NumFiles | |
display(AllFiles(i).name) | |
C = strsplit(AllFiles(i).name, '.'); | |
[y2,Fs2]=audioread(AllFiles(i).name); | |
y2(:,2)=[]; | |
outfile = strcat('left\',C(1),'_l.flac'); | |
audiowrite(outfile{1}, y2, Fs2) | |
clear y2; | |
[y2,Fs2]=audioread(AllFiles(i).name); | |
y2(:,1)=[]; | |
outfile = strcat('right\',C(1),'_r.flac'); | |
audiowrite(outfile{1}, y2, Fs2) | |
clear y2; | |
end | |
display('Finished'); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment