I wish for 1 additional read-only property:
1) RecordBufferSize As Int
This should contain the buffer size that AudioStreamer uses to conduct the recordings.
I wish for two additional methods for AudioStreamer:
1) StartRecording2(Size As Int)
Where Size is the amount of bytes AudioStreamer should read when using AudioRecord's read method. If Size is < 1 or > RecordBufferSize, then either throw/return an error or just use RecordBufferSize. Why is this needed? In VOIP applications, the time it takes to record a voice sample, transfer it across the network and play it on the other end should be less than 150ms (see https://www.voip-info.org/qos/). It looks like AudioRecord's read method is blocking (see https://stackoverflow.com/questions...n-it-ever-read-more-data-than-has-been-record and https://stackoverflow.com/questions/4569421/problem-of-read-method-in-audiorecord-class). For most phones that may not be an issue. For example, if a phone has a minimum recording buffer requirement of 640 bytes, and the recording audio settings are 8000 Hertz, 16 bit PCM, Mono, the recording will block for up to 40ms to retrieve the necessary data. That would leave 110ms to pack up the data, sent it across the network and play it on the other end. It looks like some phones may have larger buffers, with one case being 2024 bytes. That would take roughly 126ms to read, leaving only 24ms left to for sending and playback. By allowing one to tell AudioStreamer how much to read from the initially set recording buffer, one would gain better control/more consistent control over the delays that may occur in VOIP on various phones with their various buffer sizes.
2) Write2(Data() as Byte, Offset as Int, Length as Int)
When using UDP, this method would keep me from using ByteConverter to write the incoming UDP's backet into another Byte array before playing it. In other words, instead of code like this:
I could just write
without needing to allocate an intermediate buffer.
1) RecordBufferSize As Int
This should contain the buffer size that AudioStreamer uses to conduct the recordings.
I wish for two additional methods for AudioStreamer:
1) StartRecording2(Size As Int)
Where Size is the amount of bytes AudioStreamer should read when using AudioRecord's read method. If Size is < 1 or > RecordBufferSize, then either throw/return an error or just use RecordBufferSize. Why is this needed? In VOIP applications, the time it takes to record a voice sample, transfer it across the network and play it on the other end should be less than 150ms (see https://www.voip-info.org/qos/). It looks like AudioRecord's read method is blocking (see https://stackoverflow.com/questions...n-it-ever-read-more-data-than-has-been-record and https://stackoverflow.com/questions/4569421/problem-of-read-method-in-audiorecord-class). For most phones that may not be an issue. For example, if a phone has a minimum recording buffer requirement of 640 bytes, and the recording audio settings are 8000 Hertz, 16 bit PCM, Mono, the recording will block for up to 40ms to retrieve the necessary data. That would leave 110ms to pack up the data, sent it across the network and play it on the other end. It looks like some phones may have larger buffers, with one case being 2024 bytes. That would take roughly 126ms to read, leaving only 24ms left to for sending and playback. By allowing one to tell AudioStreamer how much to read from the initially set recording buffer, one would gain better control/more consistent control over the delays that may occur in VOIP on various phones with their various buffer sizes.
2) Write2(Data() as Byte, Offset as Int, Length as Int)
When using UDP, this method would keep me from using ByteConverter to write the incoming UDP's backet into another Byte array before playing it. In other words, instead of code like this:
B4X:
Sub UDP_PacketArrived (Packet As UDPPacket)
Dim buffer(Packet.Length) As Byte
bc.ArrayCopy(Packet.Data,Packet.Offset,buffer,0,Packet.Length)
audioStream.Write(buffer)
End Sub
B4X:
Sub UDP_PacketArrived (Packet As UDPPacket)
audioStream.Write2(Packet.Data,Packet.Offset,Packet.Length)
End Sub