- Online Community Forums » Programming Questions » Allegro Audio Buffers Format

Credits go to SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
Allegro Audio Buffers Format
Member #16,751
October 2017


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!

Member #7,827
October 2006

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.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Member #16,751
October 2017

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)

Go to: