# FMOD sounds not playing through Rift

**URL:** <https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388>\
**Category:** Unreal Engine\
**Created:** [March 17, 2016, 8:24pm UTC](https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388 "2016-03-17T20:24:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyc](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@eyc](https://qa.fmod.com/u/eyc)\
**Post date:** [March 17, 2016, 8:24pm UTC](https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388/1 "2016-03-17T20:24:25Z")

</div>

We migrated over a UE4 4.9 project to UE4 4.10 and tested it on the Rift, music plays though the Rift, but all FMOD sounds play though the default audio device which is usually the user’s headphones, computer speakers, etc. Has anyone else seen this problem? I’ve tried upgrading to the latest version of FMOD, but that’s just seems to break FMOD entirely. And I’m not entirely sure it’s necessary to upgrade FMOD.  
Does anyone else have problems re-routing audio to the Rift?

Thanks,  
-Stanley

---

<div class="post-metadata">

**Author:** ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://qa.fmod.com/u/geoff)\
**Post date:** [March 18, 2016, 5:28am UTC](https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388/2 "2016-03-18T05:28:08Z")

</div>

From what you’ve said, there may be multiple audio outputs on the one computer. By default FMOD should choose the system default output device. If that is a headphones, computer speakers, etc, then it explains why you see FMOD sound going to there instead of to the Rift.

FMOD initialization has functions for querying all outputs and then selecting a specific one, but we haven’t hooked that up to our UE4 integration.

When you say the music plays fine, are you playing that via FMOD or the inbuilt audio? Did you change any settings in UE4 to make it play sound via the Rift as opposed to the normal output device?

---

<div class="post-metadata">

**Author:** ![eyc](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@eyc](https://qa.fmod.com/u/eyc)\
**Post date:** [March 18, 2016, 5:43am UTC](https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388/3 "2016-03-18T05:43:24Z")

</div>

We’ve wrapped some low level FMOD API calls, like getNumDrivers, getDriverInfo, and setDriver and exposes them in Blueprints. But getDriverInfo is crashing the UE4 editor. Here’s some of our code: #include “FMODStudioPrivatePCH.h”

```
#include "FMODStudioModule.h"
#include "FMODManager.h"

bool UFMODManagerLibrary::setAudioOutput(FString targetName)
{
	FMOD::Studio::System* System = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
	FMOD::System* lowLevelSystem = nullptr;
	if (System->getLowLevelSystem(&lowLevelSystem) != FMOD_OK)
		return false;

	int numDrivers;
	if (lowLevelSystem->getNumDrivers(&numDrivers) != FMOD_OK)
		return false;
	FMOD_GUID *tmpGuid = 0;
	int *tmpSystemrate = 0;
	FMOD_SPEAKERMODE *tmpSpeakermode = 0;
	int *tmpSpeakermodechannels = 0;
	
	for (int i = 0; i < numDrivers; ++i) {		
		
		char *name = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
		int namelen = sizeof(name);

		UE_LOG(LogTemp, Display, TEXT("numdrivers %d\n"), numDrivers);
		UE_LOG(LogTemp, Display, TEXT("i %d\n"), i);
		UE_LOG(LogTemp, Display, TEXT("namelen %d\n"), namelen);
		
		if (lowLevelSystem->getDriverInfo(i, name, namelen, tmpGuid, tmpSystemrate, tmpSpeakermode, tmpSpeakermodechannels) != FMOD_OK)
			return false;
	
		FString currDriverName(name);
		UE_LOG(LogTemp, Display, TEXT("Driver name %s\n"), *currDriverName);
		
		currDriverName.TrimToNullTerminator();

		if (targetName.Equals(currDriverName)) {
			if (lowLevelSystem->FMOD::System::setDriver(i) != FMOD_OK)
				return false;
			else
				return true;
		}
	}
	
	return false;
}

```

Any idea why getDriverInfo is crashing the UE4 editor?

Thanks,  
-Stanley

---

<div class="post-metadata">

**Author:** ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://qa.fmod.com/u/geoff)\
**Post date:** [March 18, 2016, 5:54am UTC](https://qa.fmod.com/t/fmod-sounds-not-playing-through-rift/12388/4 "2016-03-18T05:54:38Z")

</div>

> [@](#):
>
> We’ve wrapped some low level FMOD API calls, like getNumDrivers, getDriverInfo, and setDriver and exposes them in Blueprints. But getDriverInfo is crashing the UE4 editor. Here’s some of our code: #include “FMODStudioPrivatePCH.h”
> 
> ```
> #include "FMODStudioModule.h"
> #include "FMODManager.h"
> 
> bool UFMODManagerLibrary::setAudioOutput(FString targetName)
> {
> FMOD::Studio::System* System = IFMODStudioModule::Get().GetStudioSystem(EFMODSystemContext::Runtime);
> FMOD::System* lowLevelSystem = nullptr;
> if (System->getLowLevelSystem(&lowLevelSystem) != FMOD_OK)
> return false;
> 
> int numDrivers;
> if (lowLevelSystem->getNumDrivers(&numDrivers) != FMOD_OK)
> return false;
> FMOD_GUID *tmpGuid = 0;
> int *tmpSystemrate = 0;
> FMOD_SPEAKERMODE *tmpSpeakermode = 0;
> int *tmpSpeakermodechannels = 0;
> 	
> for (int i = 0; i < numDrivers; ++i) {		
> 		
> char *name = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
> int namelen = sizeof(name);
> 
> UE_LOG(LogTemp, Display, TEXT("numdrivers %d\n"), numDrivers);
> UE_LOG(LogTemp, Display, TEXT("i %d\n"), i);
> UE_LOG(LogTemp, Display, TEXT("namelen %d\n"), namelen);
> 		
> if (lowLevelSystem->getDriverInfo(i, name, namelen, tmpGuid, tmpSystemrate, tmpSpeakermode, tmpSpeakermodechannels) != FMOD_OK)
> return false;
> 	
> FString currDriverName(name);
> UE_LOG(LogTemp, Display, TEXT("Driver name %s\n"), *currDriverName);
> 		
> currDriverName.TrimToNullTerminator();
> 
> if (targetName.Equals(currDriverName)) {
> if (lowLevelSystem->FMOD::System::setDriver(i) != FMOD_OK)
> return false;
> else
> return true;
> }
> }
> 	
> return false;
> }
> 
> ```
> 
> Any idea why getDriverInfo is crashing the UE4 editor?
> 
> Thanks,  
> -Stanley

Declare the name buffer like this instead:

```
char name[128];

```
