Android Question AudioStreamer & Short?

Midimaster

Member
Licensed User
I'm experimenting with AUDIO on Android, but I'm new with B4A. I fould a Recording and Playback example from Erel, which uses the AudioStreamer. It works perfect, but I have a question.

The AudioStreamer is initalized with 16bit-Resolution...
B4X:
streamer.Initialize("streamer", 44100, True, 16, streamer.VOLUME_MUSIC)
...
Sub streamer_RecordBuffer (Buffer() As Byte)
    'collect the recording data
    buffers.Add(Buffer)
End Sub
...but it looks like the Event function will return BYTEs instead of SHORTs.

This is not important as long as you only send the byte untouched to the next stream, but....

If I want to manipulate the audio datas I have to know which byte is the low and which is the high. For manipulation I would need SIGNED SHORTs values from -32767 to+32767.

Does anybody have experiences with this? Where can I find more informations?

Thanks
 

Midimaster

Member
Licensed User
Thank you. This clarifies everything. First low byte followed by high byte.

Last question: Is the AudioStreamer a ANDROID function or made by B4X-Team? Is the sourece code avaiable?
 

Midimaster

Member
Licensed User
additional newbie question:
Erel gave me that code snipplet above, but inside there is a line i do not understand:
B4X:
Sub Process_Globals
   Private streamer As AudioStreamer
End Sub

Sub Service_Create
   streamer.Initialize("streamer", 8000, True, 16, streamer.VOLUME_MUSIC)
   streamer.StartPlaying
End Sub
....
What is this "Service_Create"? And what do I need to prepare? Is it a library? Is there a tutorial about "Service" ?
 

JordiCP

Well-Known Member
Licensed User
Service_Create is one of the Android service's lifecycle events, that will be automatically called when the service is first created (or has been killed).
This service can be manually started from an activity or another service, or automatically launched upon some event: for instance, Starter service is automatically invoqed when the App starts.

Worth getting familiar with Android lifecycle, processes and events :): https://www.b4x.com/android/forum/threads/android-process-and-activities-life-cycle.6487/
 

Midimaster

Member
Licensed User
Thank you. I understand. Now I moved the code from the MAIN-Editor-window to a new Service-window called STARTER and it works now . Everything is very new for me, but it is amazing.
 
Top