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

Midi notes are never released and sustained forever #7637

Closed
mercuriete opened this issue Jul 3, 2019 · 7 comments
Closed

Midi notes are never released and sustained forever #7637

mercuriete opened this issue Jul 3, 2019 · 7 comments

Comments

@mercuriete
Copy link

mercuriete commented Jul 3, 2019

Version of OpenTTD

openttd-1.9.1

Expected result

When I switch between songs I expect to not hear any notes from the previous song.
But they are sustained forever.

Actual result

Notes are sustained forever even when you exit the game.

Steps to reproduce

Using Gentoo Linux

  1. Compile Openttd with ALSA midi using USE=aplaymidi emerge openttd
  2. Install original .gm files on ~/.openttd/gm from Openttd deluxe
  3. Configure game to use original_windows songs and exit.
  4. Open qsynth as synthesizer (Use fluid-soundfont)
  5. Open Openttd with this command: ALSA_OUTPUT_PORTS=128:0 openttd
  6. Go to New Game
  7. Go to Music
  8. Change between songs OR press stop button.
  9. You will hear sustained notes from previous songs making the game unplayable.

Proposed fix

You can send Midi off notes to ALSA like CC 123 or something like that and release the sustain pedal as well between songs and before exit the game.

By the way, thanks for your awesome work 👍

@nielsmh
Copy link
Contributor

nielsmh commented Jul 3, 2019

Which music driver does this actually compile the game with? There is no "aplaymidi" driver in the official version, and if this uses the extmidi driver to call an external program, then the playback issues are not in OpenTTD code.

@mercuriete
Copy link
Author

If you read the gentoo package itself they do this:

+	else
+		myopts+=(
+			$(usex aplaymidi '--with-midi=/usr/bin/aplaymidi' '')

https://gitweb.gentoo.org/repo/gentoo.git/tree/games-simulation/openttd/openttd-1.9.1.ebuild

@nielsmh
Copy link
Contributor

nielsmh commented Jul 3, 2019

Okay that implies it builds with the extmidi driver, and extmidi simply calls an external program to do all the playback. Have you tried running aplaymidi from the commandline to play the MIDI files? It will probably fail in the same way.

@mercuriete
Copy link
Author

Yes,
When doing something like:
aplaymidi --port 128:0 gm_tt00.gm

and then do control+c to kill the command...

The sounds fails in the similar way.
and I have to press the panic button in Qsynth

So not sure to where belongs this issue.

Thanks anyways

@nielsmh
Copy link
Contributor

nielsmh commented Jul 3, 2019

I'm closing this as the issue is not in OpenTTD code.

@nielsmh nielsmh closed this as completed Jul 3, 2019
@nielsmh
Copy link
Contributor

nielsmh commented Jul 3, 2019

A possible workaround for the missing note-offs on skip track could be if aplaymidi can be instructed to send various reset messages on startup (ideally a GM init message F0 7E 7F 09 01 F7) which would only leave the issue of hanging notes on exit. That could be worked around by starting OpenTTD via a shell script that performs a similar synth reset after OpenTTD exits.

@nielsmh
Copy link
Contributor

nielsmh commented Jul 3, 2019

The extmidi driver in OpenTTD is designed for softsynths that naturally end all sound and implicitly reset on exit/startup, not piping to external synths/hardware synths, it would require a major reworking of it to make that work. That effort would probably be better to put into writing a dedicated ALSA-MIDI driver for OpenTTD to natively output to a hardware port.

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

2 participants