OBS Audio Source plugin dev question...

mediawiz

New Member
I am developing an Audio Source plugin for OBS. I unfortunately can find very little documentation for doing this.

I think I'm pretty close to getting it working, but I am still trying to pin down what the values in the 'obs_source_audio' structure should be.

This is my current guess...

Code:
struct obs_source_audio   // from "obs.h" header file with my comments (guesses)
{
    const uint8_t *data[MAX_AV_PLANES];   

        // an array containing the pointers to 1 or more data blocks with audio data

            // My guess is that...

            //    - for "interleaved" PCM data, only the 1st pointer in the array should be used

            //    - for
    
    uint32_t frames;     // I am currently NOT SURE what this is supposed to contain???

    enum speaker_layout speakers;               

        // Number if input audio channels.   
        // Example:
        //    1 channel audio  = SPEAKERS_MONO,
        //    2 channel audio = SPEAKERS_STEREO,


    enum audio_format format;                       

        // Input audio format.   
        // Examples:
        //    Interleaved 16 bit audio = AUDIO_FORMAT_16BIT,
        //    Non-interleaved (planar) floating point audio  = AUDIO_FORMAT_FLOAT_PLANAR

    uint32_t samples_per_sec;                        // Number of audio samples to be played in 1 second

    uint64_t timestamp;                              //  I am not sure if this timestamp should start with zero, or with the current clock time???
                                                                        

};

I would be very grateful if someone could confirm correct values for these structure members.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
frames is number of audio frames, i.e. number of audio samples. so if you had an array of 5 floating point mono audio samples, there'd be 5 floats in data[0], and the frames member would be 5.

timestamp represents the time value of the segment of audio, in nanoseconds. you can start from 0 if you want, but it's good that it be relatively seamless relative to the last segment.
 
Top