[Verse-dev] Audio streaming and verse_callback_update()

Emil Brink emil at obsession.se
Thu Dec 1 20:30:37 CET 2005


Samuel Siltanen wrote:
> Hi,

Hi Samuel, sorry for not replying sooner. I'm not working full-time
in the Uni-Verse project at the moment. I  also guess I was hoping
for Eskil to pick this up, since it's a core protocol question and
he still is the one who knows those parts best. Also, I'm not working

> I am still working on audio streaming between Verse and PD. One of the 
> most difficult issues I have faced so far is choosing an appropriate 
> value as the blocking time of verse_callback_update(). Do you have good 
> suggestions how to come up with a nice value?

No, I can't say that I have. Eskil tends to favor very low values in
his applications, I've seen the values 30000, 3000 and 0 being used.

Personally I tend towards larger values, but I've not written anything
really performance-critical. 10000 is my default.

> Currently, the problem is that the receiver end falls behind. It does 
> not get as many audio stream blocks back from Verse as the sender has 
> already sent. I send two 44.1 kHz streams using the 32-bit floating 
> point format. Could it be a performance problem with Verse? Or a badly 
> chosen value (I have tested several) for verse_callback_update()?

It could certainly be a performance problem, although I don't have any
great knowledge about where the "performance limits" are in the network
code. I know Eskil has done lots of benchmarking and stuff, but I'm not
not ware of any exact results.

As I'm sure you're aware, streaming a 32-bit 44 kHz *mono* sound will
require (32 / 8) * 44100 = 4 * 44100 = 176400 bytes per second (the
same data rate as a standard CD's 2 * 16 bits).

A single Verse a_stream command will carry a maximum of 256 samples in
that format, i.e. 1024 bytes of sample data. Assuming each of these
commands gets its own Ethernet packet, we're looking at 2 * 176400 / 1024
or 344 packets per second. This is one packet every 2.9 ms in the
receiving end. I'm not sure if this means that your application needs
to pass a value smaller than this to verse_callback_update(). Eskil?

I'm sorry for just stating obvious maths, but it's all I can do at
the moment (plus, I wanted to force myself to think about it).

Also relevant is the buffering your OS kernel does on the socket, perhaps
the buffer size needs to be increased further. Verse does try to increase
the buffer size from the system default (to 1 MB, currently). You might
want to try hacking this, see v_network.c line 62 or so (buffer_size).

Are you running this inside a single machine, or do the data actually
have to traverse a network? Since you're seeing data loss, I wonder if
it's "just" Verse choking, or perhaps really data loss due to packets
being dropped somewhere en route.

Sorry for not having anything more concrete to offer you, I simply don't
have too much experience with streaming audio over Verse. You guys are
the first to try it for real, and pioneer it. Hopefully, we can get to
the bottom of this together.

Regards,

/Emil



More information about the Verse-dev mailing list