Community Q&A

Welcome to Audiokinetic’s community-driven Q&A forum. This is the place where Wwise and Strata users help each other out. For direct help from our team, please use the Support Tickets page. To report a bug, use the Bug Report option in the Audiokinetic Launcher. (Note that Bug Reports submitted to the Q&A forum will be rejected. Using our dedicated Bug Report system ensures your report is seen by the right people and has the best chance of being fixed.)

To get the best answers quickly, follow these tips when posting a question:

  • Be Specific: What are you trying to achieve, or what specific issue are you running into?
  • Include Key Details: Include details like your Wwise and game engine versions, operating system, etc.
  • Explain What You've Tried: Let others know what troubleshooting steps you've already taken.
  • Focus on the Facts: Describe the technical facts of your issue. Focusing on the problem helps others find a solution quickly.

0 votes

I've been trying for a while to try and have multiple listeners in a scene record the audio they pick up individually.

How I've been trying to do this is by making each listener output to a different audio device and record it.  I've been trying to use the AK::SoundEngine::AddOutput() func to do this, but every time I use it it says audio device share set doesn't exists, even if I send in what I think is the System audio device.  This is my first time using wwise so I could definitely be messing up something here.

I have a Audio Device called "System [System]", and a Audio Bus called "Master Audio Bus" (and a couple other ones, but I'm trying to make this work with the default first, unless I'm way-off with my approach)

Here is some code I've made so far, it's a modified version of the code from a blog about adding multiple audio devices: https://blog.audiokinetic.com/implementing-two-audio-devices-to-your-ue-game-using-wwise/

TTuple <AkUInt32, FString> AAudioManager::SearchAudioDeviceIdByName(FString deviceName)
{
    TTuple <AkUInt32, FString> result;
    AkUInt32 deviceId = AK_INVALID_DEVICE_ID;

    if (deviceName.Len() == 0) {
        // getting default device
        AK::GetWindowsDevice(-1, deviceId, NULL, AkDeviceState_Active);
        auto deviceNameWstr = AK::GetWindowsDeviceName(-1, deviceId, AkDeviceState_Active);
        result.Key = deviceId;
        result.Value = FString(deviceNameWstr);
    }
    else {
        AkUInt32 immDeviceCount = AK::GetWindowsDeviceCount(AkDeviceState_Active);
        for (AkUInt32 i = 0; i < immDeviceCount; ++i) {
            AK::GetWindowsDevice(i, deviceId, NULL, AkDeviceState_Active);
            auto deviceNameWstr = AK::GetWindowsDeviceName(i, deviceId, AkDeviceState_Active);
            if (FString(deviceNameWstr).Contains(deviceName)) {
                result.Key = deviceId;
                result.Value = FString(deviceNameWstr);
                break;
            }
        }
    }
    return result;
}

AkOutputDeviceID AAudioManager::AddCustomOutput(FString AudioDevice, FString WwiseDevice, AkGameObjectID in_pComponent)
{
    TTuple <AkUInt32, FString> Device;
    AkOutputDeviceID deviceId = AK_INVALID_DEVICE_ID;
    FString WwiseDeviceName = "System";
    AKRESULT res = AK_Fail;


    if (AudioDevice.Len() == 0 && WwiseDevice.Len() == 0) {
        return deviceId;
    }
    if (WwiseDevice.Len() > 0) {
        WwiseDeviceName = WwiseDevice;
    }

    Device = SearchAudioDeviceIdByName(*AudioDevice);

    if (Device.Key) 
    {
        AkOutputSettings outputSettings(*WwiseDeviceName, Device.Key);
        auto gameObjID = in_pComponent;
        res = AK::SoundEngine::AddOutput(outputSettings, &deviceId, &gameObjID, 1);
    }
    else
    {
        UE_LOG(LogAkAudio, Error, TEXT("Failed to find audio device %s"), *AudioDevice, *WwiseDeviceName, res);
    }

    FString componentName = FString("Listener");
    if (res != AK_Success) 
    {
        UE_LOG(LogAkAudio, Error, TEXT("Error attaching of AkComponent \"%s\" to \"%s\" <-> \"%s\". Error \"%d"), *componentName, *AudioDevice, *WwiseDeviceName, res);
    }
    else 
    {
        UE_LOG(LogAkAudio, Warning, TEXT("AkComponent \"%s\" attached to \"%s\" <-> \"%s\" "), *componentName, *Device.Value, *WwiseDeviceName);
    }
    return deviceId;
}

AKRESULT AAudioManager::RemoveCustomOutput(AkOutputDeviceID deviceId)
{
    return AK::SoundEngine::RemoveOutput(deviceId);
}

// Called when the game starts or when spawned
void AAudioManager::BeginPlay()
{
    Super::BeginPlay();
    
    //FAkAudioDevice* AudioDevice = FAkAudioDevice::Get()

    if (listeners.Num() <= 0)
    {
        UE_LOG(LogTemp, Error, TEXT("No Listeners Assigned to AudioManager!"));
        return;
    }

    TArray<AkGameObjectID> listenerIDs;

    for (int i = 0; i < listeners.Num(); i++)
    {
        listenerIDs.Add(listeners[i]);

        AkOutputDeviceID id = 0;

        //assign output for listener
        //AkOutputSettings outputSettings1("Mic", listenerIDs.Last() /*Player ID (first player)*/);
        //AK::SoundEngine::AddOutput(outputSettings1, NULL, &listenerIDs.Last(), 1);
        
        AddCustomOutput("System", "Master Audio Bus", listenerIDs.Last());

        AK::SoundEngine::RegisterGameObj(listeners[i], "My Default Listener");

        //AK::SoundEngine::Query::SetBusEffect()
    }
    AK::SoundEngine::SetDefaultListeners(&(listenerIDs[0]), listenerIDs.Num());
}

Thank you.

in General Discussion by Clara T. (100 points)

Please sign-in or register to answer this question.

...