Only detecting Stereo Devices

Hey,

I´ve got a 7.1 usb Sound Card for my Raspberry Pi 3 (Using FMOD5 Low Level API with C++).

$ amixer -c1 scontents

gives

Simple mixer control ‘Speaker’,0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right
Limits: Playback 0 - 197
Mono:
Front Left: Playback 197 [100%] [0.00dB] [on]
Front Right: Playback 197 [100%] [0.00dB] [on]
Rear Left: Playback 197 [100%] [0.00dB] [on]
Rear Right: Playback 197 [100%] [0.00dB] [on]
Front Center: Playback 197 [100%] [0.00dB] [on]
Woofer: Playback 197 [100%] [0.00dB] [on]
Side Left: Playback 197 [100%] [0.00dB] [on]
Side Right: Playback 197 [100%] [0.00dB] [on]
Simple mixer control ‘PCM’,0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 6928
Front Left: Capture 4096 [59%] [-0.01dB] [on]
Front Right: Capture 4096 [59%] [-0.01dB] [on]
Simple mixer control ‘PCM Capture Source’,0
Capabilities: enum
Items: ‘Mic’ ‘Line’ ‘IEC958 In’ ‘Mixer’
Item0: ‘Mic’
Simple mixer control ‘Line’,0
Capabilities: pvolume cvolume pswitch pswitch-joined cswitch cswitch-joined
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 8065 Capture 0 - 6928
Front Left: Playback 6144 [76%] [-0.01dB] [off] Capture 0 [0%] [-16.00dB] [off]
Front Right: Playback 6144 [76%] [-0.01dB] [off] Capture 0 [0%] [-16.00dB] [off]
Simple mixer control ‘Mic’,0
Capabilities: pvolume cvolume pswitch pswitch-joined cswitch cswitch-joined
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 8065 Capture 0 - 6928
Front Left: Playback 6144 [76%] [-0.01dB] [on] Capture 4096 [59%] [-0.01dB] [on]
Front Right: Playback 6144 [76%] [-0.01dB] [on] Capture 4096 [59%] [-0.01dB] [on]
Simple mixer control ‘IEC958 In’,0
Capabilities: cswitch cswitch-joined
Capture channels: Mono
Mono: Capture [on]

and

$ speaker-test -c 6 -D surround40 -t wav

works too.

But FMOD only detects stereo channels.

int num_drivers;
result = m_music_system->getNumDrivers(&num_drivers);
if (result != FMOD_OK)
{
	printf("FMOD ERROR\n");
	print_fmod_error(result);
	exit(-1);
}
for (int i = 0; i < num_drivers; i++) {
	char name[50];
	int name_len = 0;
	FMOD_GUID guid = FMOD_GUID();
	int system_rate = 0;
	FMOD_SPEAKERMODE speaker_mode = FMOD_SPEAKERMODE_DEFAULT;
	char* str_speaker_mode;
	int speaker_mode_channels = 0;
	result = m_music_system->getDriverInfo(i, name, name_len, &guid, &system_rate, &speaker_mode, &speaker_mode_channels);
	if (result != FMOD_OK)
	{
		printf("FMOD ERROR\n");
		print_fmod_error(result);
		exit(-1);
	}
	
	switch (speaker_mode) {
	case FMOD_SPEAKERMODE_DEFAULT:			str_speaker_mode = " Default speaker mode based on operating system/output mode.  Windows = control panel setting, Xbox = 5.1, PS3 = 7.1 etc. "; break;
	case FMOD_SPEAKERMODE_RAW:				str_speaker_mode = " There is no specific speakermode.  Sound channels are mapped in order of input to output.  Use System::setSoftwareFormat to specify speaker count. See remarks for more information. "; break;
	case FMOD_SPEAKERMODE_MONO:				str_speaker_mode = " The speakers are monaural. "; break;
	case FMOD_SPEAKERMODE_STEREO:			str_speaker_mode = " The speakers are stereo. "; break;
	case FMOD_SPEAKERMODE_QUAD:				str_speaker_mode = " 4 speaker setup.    This includes front left, front right, surround left, surround right.  "; break;
	case FMOD_SPEAKERMODE_SURROUND:			str_speaker_mode = " 5 speaker setup.    This includes front left, front right, center, surround left, surround right. "; break;
	case FMOD_SPEAKERMODE_5POINT1:			str_speaker_mode = " 5.1 speaker setup.  This includes front left, front right, center, surround left, surround right and an LFE speaker. "; break;
	case FMOD_SPEAKERMODE_7POINT1:			str_speaker_mode = " 7.1 speaker setup.  This includes front left, front right, center, surround left, surround right, back left, back right and an LFE speaker. "; break;
		
	case FMOD_SPEAKERMODE_MAX:				str_speaker_mode = " Maximum number of speaker modes supported. "; break;
	case FMOD_SPEAKERMODE_FORCEINT:			str_speaker_mode = " Makes sure this enum is signed 32bit. "; break;
	}
	
	char n_name[name_len];
	for (int j = 0; j < name_len; j++) {
		n_name[j] = name[j];
	}
	
	printf("%s-%s-%d\n", n_name, str_speaker_mode, speaker_mode_channels);
}

prints

�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports onl
y capture stream
�- The speakers are stereo. -2
ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports onl
y capture stream
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection
refused
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2
ALSA lib pcm_dsnoop.c:557:(snd_pcm_dsnoop_open) The dsnoop plugin supports onl
y capture stream
�- The speakers are stereo. -2
�- The speakers are stereo. -2
�- The speakers are stereo. -2

Any way to fix this? Any futher information I can provide?
Thanks for help :slight_smile:

This will be fixed for 1.08.08.

The speaker mode, channels and sample rate returned from System::getDriverInfo is more a guide on what the system is currently configured as, often a particular device will support values outside these defaults.

In the case of ALSA, the FMOD code will return stereo for all devices, but you are quite right that there are conventions in place for multichannel pseudo-devices, i.e. surround40.

I’ll log a task to put some string compare logic in our device enumeration code to perform the following mappings:

surround40 = FMOD_SPEAKERMODE_QUAD
surround50 = FMOD_SPEAKERMODE_SURROUND
surround51 = FMOD_SPEAKERMODE_5POINT1
surround71 = FMOD_SPEAKERMODE_7POINT1

Everything else will return stereo as it does currently.

Until this functionality is implemented, feel free to do the string compare in your code and apply the above mappings. If the pseudo-device supports the channel count it describes then it will work, no internal FMOD changes are necessary.