Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fluidsynth driver plays music too loudly #7189

Closed
nikolas opened this issue Feb 7, 2019 · 4 comments
Closed

fluidsynth driver plays music too loudly #7189

nikolas opened this issue Feb 7, 2019 · 4 comments

Comments

@nikolas
Copy link
Member

nikolas commented Feb 7, 2019

Version of OpenTTD

git master: bfdad9a

libfluidsynth 1.1.11 on Debian buster/testing.

Expected result

I expect the volume of songs played when compiled with fluidsynth to match that of when OpenTTD defaults to the external MIDI player (timidity).

Actual result

When a new game is started, the song is played at a much louder volume. But the intro song seems to play at normal volume, so the difference is kind of jarring.

Steps to reproduce

  • Compile OpenTTD with libfluidsynth dev headers installed.
  • Open program and start a new game.

Using fluidsynth and timidity standalone utilities, these two commands both play the song at the correct volume. This track in particular is noticeably louder when played in game with fluidsynth, and causes some buzzing in my speakers.

timidity ~/.openttd/content_download/baseset/openmsx-0.3.1/5432gone_redfarn.mid
fluidsynth -a alsa /usr/share/sounds/sf2/FluidR3_GM.sf2 ~/.openttd/content_download/baseset/openmsx-0.3.1/5432gone_redfarn.mid
@nielsmh
Copy link
Contributor

nielsmh commented Feb 8, 2019

What music volume setting inside OTTD?

@nikolas
Copy link
Member Author

nikolas commented Feb 9, 2019

This is noticeable when the volume setting is set at max, which I think is the default:

2019-02-08-190138_1280x800_scrot

Looking at the code here:

void MusicDriver_FluidSynth::SetVolume(byte vol)
{
	/* Allowed range of synth.gain is 0.0 to 10.0 */
	if (fluid_settings_setnum(_midi.settings, "synth.gain", 1.0 * vol / 128.0) != 1) {
		DEBUG(driver, 0, "Could not set volume");
	}
}

I think the issue is that this volume setter sets the gain between 0 and 1.0, and 1.0 is too loud (the default is 0.2: http://www.fluidsynth.org/api-1.x/).

I get better behavior when ranging the gain between something like 0 and 0.3, but then the intro music is way too quiet. I'm still learning the code here which is why I haven't made a PR for this.

nikolas added a commit to nikolas/OpenTTD that referenced this issue Feb 9, 2019
@michicc
Copy link
Member

michicc commented Feb 19, 2019

Any updates on this, @nikolas ?

nikolas added a commit to nikolas/OpenTTD that referenced this issue Feb 19, 2019
nikolas added a commit to nikolas/OpenTTD that referenced this issue Feb 19, 2019
@nikolas
Copy link
Member Author

nikolas commented Feb 19, 2019

It looks like tttheme2.mid is just a quieter song, so fluidsynth is playing it correctly with gain set to 0.2. This can be confirmed by using fluidsynth in standalone mode:

fluidsynth -a alsa /usr/share/sounds/sf2/FluidR3_GM.sf2 ~/.openttd/content_download/baseset/openmsx-0.3.1/tttheme2.mid

I've opened #7253 to resolve this issue.

nikolas added a commit to nikolas/OpenTTD that referenced this issue Feb 19, 2019
nielsmh pushed a commit to nielsmh/OpenTTD that referenced this issue Mar 11, 2019
douiwby pushed a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants