title: Taking the left and right channels of two wav files and joining them into one separate stereo file
body: <p>I have two stereo wav files that I would like to take the left channel of the first audio file and take the right channel of the second audio file and join them into one new wave file.</p>
  
  <p>Here's an image of what I'm trying to do.</p>
  
  <p><img src="https://i.stack.imgur.com/CWr5X.png" alt="http://i.imgur.com/Rwe5jWHl.jpg"></p>
  
  <p>I know I can read files into matlab / octave and get the separate left right channels with the code below:</p>
  
  <pre><code>[imported_sig_1, fs_rate, nbitsraw] = wavread(strcat('/tmp/01a.wav'));
  imported_sig_L=imported_sig_1(:,1)';
  
  [imported_sig_2, fs_rate, nbitsraw] = wavread(strcat('/tmp/02a.wav'));
  imported_sig_R=imported_sig_2(:,2)';
  </code></pre>
  
  <p>I can then write the new channels that I want out using the code</p>
  
  <pre><code>wavwrite([(imported_sig_L)' (imported_sig_R)'] ,fs_rate,16,'newfile.wav'); %
  </code></pre>
  
  <p>The problem I'm running into is the time it takes to import the file and size of the array the wave files take up.  The files I'm importing are about 1-4 hours long and it takes a while to import and it takes a lot of memory in the array is there away around importing the full file and then exporting them?  </p>
  
  <p>I'm using octave 3.8.1 on Ubuntu 14.04 which is like matlab but I also have access to sox</p>