Question about obs_source_audio data

buscher

New Member
Hi,
I was playing around with the obs-studio code, trying to build another audio plugin, but I am stuck at obs_source_audio.data.

>>>>>>>>>>>>>
/**
* Source audio output structure. Used with obs_source_output_audio to output
* source audio. Audio is automatically resampled and remixed as necessary.
*/
struct obs_source_audio {
const uint8_t *data[MAX_AV_PLANES];
uint32_t frames;

enum speaker_layout speakers;
enum audio_format format;
uint32_t samples_per_sec;

uint64_t timestamp;
};
<<<<<<<<<<<<

so... I am passing data.
I was assuming *data[] is a "data-array" for each channel, like

data[0] = leftChannel; //512 float size data
data[1] = rightChannel; //512 float size data
speakers = SPEAKERS_STEREO;
frames = 512;
format = AUDIO_FORMAT_FLOAT;
samples_per_sec = 48000;
timestamp = ...

but that does not seem to be the case, I happen to pass only "0" to data[0] and "noise" to data[1]
and obs-studio did not recognize the input, like it got nothing.

so I am kinda stuck, is data[x] not the channel number? Or should "frames" be the number of uint8_t frames? Or is it frames*channels? Or does the timestamp somehow need to change in multichannel case?
btw, if I change it to mono everything works fine, but just mono.

data[0] = leftChannel; //512 float size data
speakers = SPEAKERS_MONO;
frames = 512;
format = AUDIO_FORMAT_FLOAT;
samples_per_sec = 48000;
timestamp = ...

if anyone could solve my confusion... it would be great, thanks in advance :)
(using todays git master obs-studio under linux)
 

buscher

New Member
After playing around a bit more...

obs-studio is happy if I set the data[0] as a mix of right&left channel

//pseudo code
data[0] = leftChannel[0], rightChannel[0], leftChannel[1], rightChannel[1], leftChannel[2], rightChannel[2]...

but this really correct? what is the data array for?
 

buscher

New Member
ok, ok, seems like I get it,

I have planar audio,
data[0] = leftChannel; //512 float size data
data[1] = rightChannel; //512 float size data
format = AUDIO_FORMAT_FLOAT_PLANAR;

and now it works :)
 

dodgepong

Administrator
Community Helper
Glad you were able to figure it out. Feel free to stop by #obs-dev on Quakenet for dev chat if you have more questions (sometimes it's quiet, so just ask your question and stick around).
 
Top