Splitting a Stereo buffer to 2 Mono buffers

In a Stereo buffer, the left channel is stored first, then the right channel.
So, at position 1, you will find the sample of the left channel, position 2 is right channel, position 3 is left channel again, and so on.

Here is code to split Stereo buffer to 2 Mono buffers, for 8 and 16 Bit:
vb Code:
  1. Public Sub SoundStereoToMono16(InStereo() As Integer, OutLeftChannel() As Integer, OutRightChannel() As Integer)
  2.     Dim InPos As Long
  3.     Dim OutPos As Long
  4.    
  5.     ReDim OutLeftChannel((UBound(InStereo) + 1) \ 2 - 1)
  6.     ReDim OutRightChannel(UBound(OutLeftChannel))
  7.    
  8.     For InPos = 0 To UBound(InStereo) Step 2
  9.         OutLeftChannel(OutPos) = InStereo(InPos)
  10.         OutRightChannel(OutPos) = InStereo(InPos + 1)
  11.        
  12.         OutPos = OutPos + 1
  13.     Next InPos
  14. End Sub
  15.  
  16. Public Sub SoundStereoToMono8(InStereo() As Byte, OutLeftChannel() As Byte, OutRightChannel() As Byte)
  17.     Dim InPos As Long
  18.     Dim OutPos As Long
  19.    
  20.     ReDim OutLeftChannel((UBound(InStereo) + 1) \ 2 - 1)
  21.     ReDim OutRightChannel(UBound(OutLeftChannel))
  22.    
  23.     For InPos = 0 To UBound(InStereo) Step 2
  24.         OutLeftChannel(OutPos) = InStereo(InPos)
  25.         OutRightChannel(OutPos) = InStereo(InPos + 1)
  26.        
  27.         OutPos = OutPos + 1
  28.     Next InPos
  29. End Sub