getRecordNumDrivers value never change

Hello,

After some testing, I found out that the results of getRecordNumDrivers never changes.
For example if I run the code with two microphones plugged in, the value of numdrivers and numconnected will always be “2”, even if one is unplugged or if another microphone is added after initialization.

I also noticed that the value of the FMOD_DRIVER_STATE given by getRecordDriverInfo is “3”. This is weird as the documentation only gives two possible values (1 or 2): https://www.fmod.org/docs/content/generated/FMOD_DRIVER_STATE.html

Here is the code I use for testing in the Tick function of my actor.

void AMicrophoneManager::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );
	result = system->update();
	checkResult(result);


	result = system->getRecordNumDrivers(&numdrivers, &numconnected);
	checkResult(result);
	int count, speakermodechannels, systemrate;
	FMOD_SPEAKERMODE speakermode;
	FMOD_DRIVER_STATE state;

	for (count = 0; count < numdrivers; count++)
	{
		char name[256];
		FMOD_GUID guid;
		result = system->getRecordDriverInfo(count, name, 256, &guid, &systemrate, &speakermode, &speakermodechannels, &state);
		UE_LOG(LogTemp, Warning, TEXT("numdrivers : %d %d\n"), numdrivers, (unsigned int)state);
		checkResult(result);
	}
}

Is there something wrong with this code?

Edit: Using Fmod 1.08.04 and UE4.12 Preview 4 with simple usb microphones

EDIT Solution:

Mathew found out that the problem was due to a part of my code that was explicitly setting DSound. I removed it and it worked properly after this.

Can you link with the logging version of FMOD? You should see information in the TTY output whenever a microphone is added or removed.

It is expected that when calling System::getRecordNumDrivers the value of ‘numdrivers’ will only ever grow (disconnected microphones are still in the list). The other value ‘numconnected’ should be a real indication of the number of connected microphones.

FMOD_DRIVER_STATE can encompass multiple states at the same time, the defines are bitwise ORd together to give you the final number, i.e. 3 is the bitwise OR of CONNECTED and DEFAULT.

EDIT: For Windows, detection of microphone add/remove is currently only available with the WASAPI output mode (default on Windows Vista and up). DirectSound (default for Windows XP) does not have this feature.

I can log this as a request for improvement if you like?

1 Like

Thank you for the answer. The value of the state makes sense now.

In my tests, numconnected value never changes when a microphone is plugged in or out.

About the logs, I only have Warning log at the moment, for example:

LogFMOD:Warning: c:\jk\workspace\Build__1.8__UE4Libs_Win\lowlevel_api\src\fmod_file.cpp(537) - File offset: 0 + length: 64000 > actual file size 0, truncating length.

I’m looking at how to have more detailed logs.

Hello, can you help me solve a problem? After the initialization method, the getRecordNumDrivers method is called, returning numDrivers as 0.

Answered here: http://www.fmod.org/questions/question/android-the-getrecorddriverinfo-method-callback-is-0-android/

Hello,

I’m on Unity 2018.2.0f2 using the FMOD plugin 1.10.07 and running on Windows 10 with WASAPI and ‘getRecordNumDrivers’ values for ‘connected’ drivers does not change when I unplug my microphone.

Hi Chris,

Are you seeing the same issue when using the “record_enumeration” example in the lowlevel API examples?

I defined a callback to show the log in the ue4 Output Log window:

FMOD_RESULT fmodLogCallback(FMOD_DEBUG_FLAGS flags, const char *file, int line, const char *func, const char *message)
{
	UE_LOG(LogTemp, Warning, TEXT("%s : line %d | %s\n"), *(FString(ANSI_TO_TCHAR(file))), line, *(FString(ANSI_TO_TCHAR(message))));
	return FMOD_OK;
}


 .
 .
 .


result = FMOD::Debug_Initialize(FMOD_DEBUG_LEVEL_LOG, FMOD_DEBUG_MODE_CALLBACK, fmodLogCallback);

Here are the logs: http://pastebin.com/Kj7uFk4T

Nothing is printed when I add or remove a microphone. When I start the game, all the logs are printed up to

LogTemp:Warning: c:\jk\workspace\Build__1.8__UE4Libs_Win\lowlevel_api\src\fmod_systemi.cpp : line 4910 | Enumerating 2 record drivers
LogTemp:Warning: c:\jk\workspace\Build__1.8__UE4Libs_Win\lowlevel_api\src\fmod_systemi.cpp : line 4936 | 0. Found record driver: ‘Microphone (2- USB Microphone)’
LogTemp:Warning: c:\jk\workspace\Build__1.8__UE4Libs_Win\lowlevel_api\src\fmod_systemi.cpp : line 4936 | 1. Found record driver: ‘Microphone (USB Microphone)’

Then there is no more log until I stop the game.

EDIT: It seems to work properly on PS4. The number of recorded drivers follows the number of devices when I add or remove them. The problem remains on Windows.

It appears the link you’ve provided has expired, can you post to the Q&A or e-mail support@fmod.org?

I’ve sent an email to the support.

Thanks for the details, my guess is you are on XP? I’ve updated my above answer assuming this case.

I’m using Windows 10. Is there anything that could be wrong with WASAPI on a Windows install? Like missing dependencies or a service not running?

Actually looking at your sample code, you are explicitly setting DSound, you should remove this.

1 Like

That’s it. Removing the call to setOutput fixed the problem. Thank you Mathew!