This version includes a new AudioStreamer type. Note that this is a beta version (for this type only).
The purpose of AudioStreamer is to make it simple to stream audio from the microphone and to the speakers. Internally it is based on AudioTrack and MediaRecorder.
Next week I plan to create an example of streaming audio between two devices (walkie-talkie app).
Recording is done by calling StartRecording. The RecordBuffer event will be raised multiple times during the recording:
Sub streamer_RecordBuffer (Buffer() As Byte)
'collect the recording data
buffers.Add(Buffer)
End Sub
You can write this data to a file or as done in this example, collect the buffers in a list. Later we will use this list to play the recording:
Sub btnPlay_Click
btnStartRecording.Enabled = False
streamer.StartPlaying
For Each b() As Byte In buffers
streamer.Write(b)
Next
streamer.Write(Null) 'when this "message" will be processed, the player will stop.
End Sub
Note that the player has an internal queue. The write method will not block the main thread. The data is just added to the queue. It is processed by another thread.
As this is a beta version, it will be great if you can run the small example and test it on your device...
An example of saving the recording to a wave file is available in post #10.
Walkie-Talkie example is available here.
Installation instructions:
This library should be copied to the internal libraries folder.
Unzip the attached file and copy both files to (default):
C:\Program Files (x86)\Anywhere Software\Basic4android\Libraries