Hi all,
I'm making an app that will amongst other things allow the user to record a sound then play it back immediately.
Using Erel's example I have added a panel so that when you press the panel it starts recording and then when you release it, it plays back the sound.
This works fine on my tablet (Jellybean) with almost no delay but on my phone (gingerbread) it works fine most of the time but then there will be a delay of a few seconds before it plays back.
When I say 'almost no delay' there is still a delay... any way to make it snappier?
Also on my gingerbread phone it'll suddenly get noisy clicks in the audio so is there any way to re-initialise the sound hardware?
I include Erels project with the extra panel and you can download the apk directly to your device here:
Audiostreamer.apk
Also I find on my devices that I will often get a click or pop at the beginning and end of the recording so this altered routine:
Butchers the buffers list to remove the first and last byte arrays which seems to clear up the noisy clicks.
Also for processing or examining the data before playing it back this altered routine:
breaks out each byte array from the list before sending it to the streamer.write method.
I'm making an app that will amongst other things allow the user to record a sound then play it back immediately.
Using Erel's example I have added a panel so that when you press the panel it starts recording and then when you release it, it plays back the sound.
This works fine on my tablet (Jellybean) with almost no delay but on my phone (gingerbread) it works fine most of the time but then there will be a delay of a few seconds before it plays back.
When I say 'almost no delay' there is still a delay... any way to make it snappier?
Also on my gingerbread phone it'll suddenly get noisy clicks in the audio so is there any way to re-initialise the sound hardware?
I include Erels project with the extra panel and you can download the apk directly to your device here:
Audiostreamer.apk
Also I find on my devices that I will often get a click or pop at the beginning and end of the recording so this altered routine:
B4X:
Sub btnStopRecording_Click
Try
streamer.StopRecording
Catch
Log(LastException.Message)
End Try
timer1.Enabled = False
btnPlay.Enabled = True
Label1.Text = ""
Log(buffers.Size)
buffers.RemoveAt(buffers.Size -1)
buffers.RemoveAt(1)
Log(buffers.Size)
End Sub
Butchers the buffers list to remove the first and last byte arrays which seems to clear up the noisy clicks.
Also for processing or examining the data before playing it back this altered routine:
B4X:
Sub btnPlay_Click
btnStartRecording.Enabled = False
streamer.StartPlaying
'For Each b() As Byte In buffers
For i = 0 To buffers.Size - 1
Dim b2() As Byte = buffers.Get(i)
'Log("b2.Length = " & b2.Length)
streamer.Write(b2)
Next
streamer.Write(Null) 'when this "message" will be processed, the player will stop.
End Sub