Sound Destruction Problems

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
edward850
Posts: 5889
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Sound Destruction Problems

Post by edward850 »

That's strange. I made an acid test for sound and it said it was playing back 4095 channels fine. In-fact, the System->Init line looks like it's finding which is higher (snd_channels or MAX_CHANNELS) and using that, which is more strange, because I can make FMOD run of 1 channel. I didn't test music, though.

Edit: I think this is actually an FMOD-ism. setSoftwareChannels and maxchannels in init() are two different values.
Last edited by edward850 on Tue Jan 14, 2014 5:40 am, edited 2 times in total.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Sound Destruction Problems

Post by Gez »

Yeah, it's definitely a weird line. You'd expect it to be used with MIN() rather than MAX()... Or MAX_CHANNELS should be renamed MIN_CHANNELS, either way.

Anyway it's in sound/fmodsound.cpp of course. Lines 914, and 959. It's part of FMODSoundRenderer::Init().

Code: Select all

	for (;;)
	{
		result = Sys->init(MAX(*snd_channels, MAX_CHANNELS), initflags, 0);
		if (result == FMOD_ERR_OUTPUT_CREATEBUFFER)
		{ 
			// Possible causes of a buffer creation failure:
			// 1. The speaker mode selected isn't supported by this soundcard. Force it to stereo.
			// 2. The output format is unsupported. Force it to 16-bit PCM.
			// 3. ???
			result = Sys->getSpeakerMode(&speakermode);
			if (result == FMOD_OK &&
				speakermode != FMOD_SPEAKERMODE_STEREO &&
				FMOD_OK == Sys->setSpeakerMode(FMOD_SPEAKERMODE_STEREO))
			{
				Printf(TEXTCOLOR_RED"  Buffer creation failed. Retrying with stereo output.\n");
				continue;
			}
			result = Sys->getSoftwareFormat(&samplerate, &format, NULL, NULL, &resampler, NULL);
			if (result == FMOD_OK &&
				format != FMOD_SOUND_FORMAT_PCM16 &&
				FMOD_OK == Sys->setSoftwareFormat(samplerate, FMOD_SOUND_FORMAT_PCM16, 0, 0, resampler))
			{
				Printf(TEXTCOLOR_RED"  Buffer creation failed. Retrying with PCM-16 output.\n");
				continue;
			}
		}
		else if (result == FMOD_ERR_NET_SOCKET_ERROR && (initflags & FMOD_INIT_ENABLE_PROFILE))
		{
			Printf(TEXTCOLOR_RED"  Could not create socket. Retrying without profiling.\n");
			initflags &= ~FMOD_INIT_ENABLE_PROFILE;
			continue;
		}
#ifdef _WIN32
		else if (result == FMOD_ERR_OUTPUT_INIT)
		{
			FMOD_OUTPUTTYPE output;
			result = Sys->getOutput(&output);
			if (result == FMOD_OK && output != FMOD_OUTPUTTYPE_DSOUND)
			{
				Printf(TEXTCOLOR_BLUE"  Init failed for output type %s. Retrying with DirectSound.\n",
					Enum_NameForNum(OutputNames, output));
				if (FMOD_OK == Sys->setOutput(FMOD_OUTPUTTYPE_DSOUND))
				{
					continue;
				}
			}
		}
#endif
		break;
	}
	if (result != FMOD_OK)
	{ // Initializing FMOD failed. Cry cry.
		Printf(TEXTCOLOR_ORANGE"  System::init returned error code %d\n", result);
		return false;
	}
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Sound Destruction Problems

Post by randi »

Graf Zahl wrote:The 32 global channels limit is really antiquated
It sounds to me like they're describing the completely deliberate duplicate sound limiter. Changing the number of available sound channels isn't going to change a thing for them.
Gez wrote:You'd expect it to be used with MIN() rather than MAX().
It's the maximum value you can set snd_channels to without having to restart the sound system. The game always allocates at least MAX_CHANNELS channels. Snd_channels is the number of those that can be actively mixed into the final output at once. Any excess between and_channels and MAX_CHANNELS will be automatically switched to virtual channels using volume-based prioritization. Does that answer your confusion?
Locked

Return to “Editing (Archive)”