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

How to determine the speaker configuration/number of channels at runtime?

0 votes
Hi,

I'd like to find out the number of speakers/channels configured at runtime for Wwise (Windows in this case). Is there a simple way to do so? Ideally it would be something we could query periodically and update in case the output device changes in Windows.

Thank you,

Brent
asked May 3, 2017 in General Discussion by Brent S. (140 points)

1 Answer

0 votes
We are using Unreal (older integration) so I'll post my answer here if someone else needs it.

I added a call to register the bus volume callback for the master audio bus in the initialization routine.

    if (AK_Success != AK::SoundEngine::RegisterBusVolumeCallback(MASTER_AUDIO_BUS, AkMasterBusSpeakerVolumeMatrixCallback))
    {
        UE_LOG(LogInit, Warning, TEXT("Could not register the master bus volume callback."));
    }
 

Then had the callback set the rtpc based on the number of channels, removing the low frequency effects channel in the count if found.    

 

static const AkUniqueID MASTER_AUDIO_BUS = 3803692087U;
void FAkAudioDevice::AkMasterBusSpeakerVolumeMatrixCallback(AkSpeakerVolumeMatrixCallbackInfo *in_pCallbackInfo)
{
    static unsigned long LastNumChannels = 0xffffffff;

    if (in_pCallbackInfo
        && (in_pCallbackInfo->outputConfig.uNumChannels != LastNumChannels))
    {
        auto AudioDevice = FAkAudioDevice::Get();
        if (!AudioDevice)
        {
            return;
        }

        LastNumChannels = in_pCallbackInfo->outputConfig.uNumChannels;

        const FString& ChannelRtpc = GetDefault<UAkSettings>()->SpeakerChannelRtpcName;
        if (ChannelRtpc.Len())
        {
            // remove the .1 low frequency effects channel from the reported channel count
            const bool HasLFE = in_pCallbackInfo->outputConfig.HasLFE();
            const unsigned long ReportedChannels = LastNumChannels - (HasLFE ? 1 : 0);

            UE_LOG(LogAkAudio, Display, TEXT("Number of audio channels found: %d%s"), ReportedChannels, (HasLFE ? TEXT(".1") : TEXT("")));

            AudioDevice->SetRTPCValue(*ChannelRtpc, ReportedChannels);
        }
    }
}
answered May 15, 2017 by Brent S. (140 points)
This no longer works in 2017.1.3.6377
...