Please be advised that the Audiokinetic offices will close at 3:00 p.m. EST on December 23rd, 2019 for the holiday period, and will reopen on January 3rd, 2020 at 9:00 a.m. EST. Learn more.

Community Q&A

Where Wwise users help each other out!

Audiokinetic's Community Q&A is the forum where Wwise users ask and answer questions within the Wwise community. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

[C++] Setting 32 bit float values directly into the audio buffer.

+1 vote

Hello all.

I'm trying to understand the kind of data that can be passed into a audio buffer channel.

According to https://www.audiokinetic.com/library/2015.1_5418/?source=SDK&id=soundengine__plugins.html#fx_audiobuffer_struct

    Audio buffers’ channels are not interleaved, and all samples are normalized 32-bit floating point in the (-1.f,1.f) range running at a 48 kHz sampling rate.

So, as an example, is it possible to simply read a RAW file, Mono track, 48 kHz, little endian 32 bit float data straight from disk and feed into into a channel, like so ? 

// Note: length of file and eventual starvation is not my concern for the moment.

AKRESULT CAkFXSrcRawFile::Init(    
    AK::IAkPluginMemAlloc *            /*in_pAllocator*/,     /// Memory allocator interface.
    AK::IAkSourcePluginContext *in_pSourceFXContext,/// Sound engine plug-in execution context.
    AK::IAkPluginParam *in_pParams,            /// Associated effect parameters node.
    AkAudioFormat &    io_rFormat            /// Output audio format.
)
{
    io_rFormat.SetAll(48000, AK_SPEAKER_SETUP_MONO, 32, 1, AK_FLOAT, AK_NONINTERLEAVED);

        m_pFile = fopen("mysound.raw", "rb")
}

    void CAkFXSrcRawFile::Execute(AkAudioBuffer* io_pBufferOut)
    {
     if (io_pBufferOut->NumChannels())
    {
        AkSampleType* ch0Buffer = io_pBufferOut->GetChannel(0);

        io_pBufferOut->uValidFrames = fread(ch0Buffer, sizeof(AkSampleType), io_pBufferOut->MaxFrames(), m_pFile);
    
        if (!feof(m_pFile) && io_pBufferOut->uValidFrames > 0)
        {
            io_pBufferOut->eState = AK_DataReady;
            return;
        }
    }
    
    io_pBufferOut->eState = AK_NoDataReady;
   }

 

 

asked Jan 25, 2016 in General Discussion by Marc S. (120 points)

Please sign-in or register to answer this question.

...