Hi ,
I'm just starting to work with audiostreamer so will have a few silly questions while I get going.
I ran the AudioStreamerTutorial, that works fine. For my application all I want to do is analyse the MIC audio for a clap sound to trigger an event, I don't want to record. So I modified the streamer_RecordBuffer event as follows, but it's not working (expectedly). I know there are many errors in approach, any pinted to what I'm doing wrong will be much appreciated.
When running this, the program never leaves the " For Each b As Byte In Buffer" loop, thats problem number one.
I changed "For Each b() As Byte In Buffer" to "For Each b As.." as it wouldn't compile with the (), so that's probably why but I am not sure how I can looop through Buffer in the manner I wish if this doesn't work.
Also, do I need to concact each two subsequent bytes together to form a 16 bit value?
Thanks.
I'm just starting to work with audiostreamer so will have a few silly questions while I get going.
I ran the AudioStreamerTutorial, that works fine. For my application all I want to do is analyse the MIC audio for a clap sound to trigger an event, I don't want to record. So I modified the streamer_RecordBuffer event as follows, but it's not working (expectedly). I know there are many errors in approach, any pinted to what I'm doing wrong will be much appreciated.
B4X:
Sub streamer_RecordBuffer (Buffer() As Byte)
'lets check the buffer for average and peak volumes
AvgVol = 0
PeakVol = 0
NumSamps = 0
For Each b As Byte In Buffer
AvgVol = AvgVol + Abs(b)
NumSamps = NumSamps + 1
If Abs(b) > PeakVol Then
PeakVol = Abs(b)
End If
Next
AvgVol = AvgVol/NumSamps
'collect the recording data
'buffers.Add(Buffer) - I don't want to record the audio so commented this out
End Sub
When running this, the program never leaves the " For Each b As Byte In Buffer" loop, thats problem number one.
I changed "For Each b() As Byte In Buffer" to "For Each b As.." as it wouldn't compile with the (), so that's probably why but I am not sure how I can looop through Buffer in the manner I wish if this doesn't work.
Also, do I need to concact each two subsequent bytes together to form a 16 bit value?
Thanks.