|
-
Apr 3rd, 2008, 10:21 PM
#9
Re: Tutorial under construction
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:
Public Sub SoundStereoToMono16(InStereo() As Integer, OutLeftChannel() As Integer, OutRightChannel() As Integer)
Dim InPos As Long
Dim OutPos As Long
ReDim OutLeftChannel((UBound(InStereo) + 1) \ 2 - 1)
ReDim OutRightChannel(UBound(OutLeftChannel))
For InPos = 0 To UBound(InStereo) Step 2
OutLeftChannel(OutPos) = InStereo(InPos)
OutRightChannel(OutPos) = InStereo(InPos + 1)
OutPos = OutPos + 1
Next InPos
End Sub
Public Sub SoundStereoToMono8(InStereo() As Byte, OutLeftChannel() As Byte, OutRightChannel() As Byte)
Dim InPos As Long
Dim OutPos As Long
ReDim OutLeftChannel((UBound(InStereo) + 1) \ 2 - 1)
ReDim OutRightChannel(UBound(OutLeftChannel))
For InPos = 0 To UBound(InStereo) Step 2
OutLeftChannel(OutPos) = InStereo(InPos)
OutRightChannel(OutPos) = InStereo(InPos + 1)
OutPos = OutPos + 1
Next InPos
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|