Sub streamer_RecordBuffer (Buffer() As Byte)
Dim j As Int
j = Buffer.Length / 2
Dim s As Byte
Dim t As Byte
Dim intbuffer(384) As Int
For i = 0 To j - 1
s = Bit.AND (Buffer( 2 * i ), 255)
t = Bit.AND ( Buffer( 2 * i + 1), 255)
'intbuffer(i) = ( s + Bit.ShiftLeft(t, 8) + Bit.AND(t,128) * -512 )
intbuffer(i) = ( s + Bit.ShiftLeft(t, 8) + Bit.AND(t,255) )
Next 'that lot was just to convert the bytes to Int audio samples
buffers.Add(intbuffer)
End Sub
No, it isn´t! With your code you put an array of int as ONE object in the list
Yo; if you want to use this buffer later you need to get the first object of this list to get the array back.
asuming that buffers is of Type LIST:
i would write it like this
B4X:
Sub streamer_RecordBuffer (Buffer() As Byte)
Dim j As Int
j = Buffer.Length / 2
Dim s As Byte
Dim t As Byte
'Dim intbuffer(384) As Int
For i = 0 To j - 1
s = Bit.AND (Buffer( 2 * i ), 255)
t = Bit.AND ( Buffer( 2 * i + 1), 255)
Dim intbuf As Int ' Declare a new Variable of type INT
'intbuffer(i) = ( s + Bit.ShiftLeft(t, 8) + Bit.AND(t,128) * -512 )
intbuf = ( s + Bit.ShiftLeft(t, 8) + Bit.AND(t,255) )
buffers.Add(intbuf) ' Add the int into the list
Next 'that lot was just to convert the bytes to Int audio samples
' You now can use buffers in your foreach-loop
End Sub