Allegro Audio Buffers Format


I'm currently trying to get fluidsynth to work with allegro streams. The function fluidsynth provides for filling the stream buffer (fluid_synth_write_float) has the following arguments:

int len Count of audio frames to synthesize

void *lout Array of floats to store left channel of audio
int loff Offset index in 'lout' for first sample
int lincr Increment between samples stored to 'lout'

void* rout Array of floats to store right channel of audio
int roff Offset index in 'rout' for first sample
int rincr Increment between samples stored to 'rout'

TL;DR: It needs two buffers, but even with ALLEGRO_CHANNEL_CONF_2 I only get one, so my question is, has this one buffer supplied by al_get_audio_stream_fragment got twice the size of a one-channel "mono" buffer and I just got to store the data of the two buffers into this one (alternately or one after the other?) or does it work completely different.

Thanks in advance!


The left and right channels are interleaved. I imagine doing something like: lout=buffer, loff=0, lincr=sizeof(float) * 2, rout=buffer, roff=sizeof(float), rincr=sizeof(float) 2 should work. I.e. you pass the same buffer, but set the offsets and increments appropriately. Make sure you use a floating point format as well.


The arguments are in "frames" (I think) as fluidsynth calls it and didn't need to be multiplied with sizeof(float), but besides that you were absolutely right, thank you very much!

(So if anyone has the same problem as me: lout=buffer, loff=0, lincr=2, rout=buffer, roff=1, lincr=2)

Thread #617087. Printed from