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 playback is buggy (sounds bad and/or crashes mpv) #8724

Closed
dardoor opened this issue Apr 13, 2021 · 4 comments
Closed

midi playback is buggy (sounds bad and/or crashes mpv) #8724

dardoor opened this issue Apr 13, 2021 · 4 comments
Labels
down-upstream features and bugs that need to be implemented and fixed upstream os:win

Comments

@dardoor
Copy link

dardoor commented Apr 13, 2021

Important Information

Reproduction steps

  1. open mpv
  2. load a midi (.mid) file

Expected behavior

It plays properly.

Actual behavior

It either doesn't sound right or it crashes/exits mpv.

Log file (for the crash)

output.txt

Sample files

This .mid file makes mpv crash/exit: Simpsons.mid
Other .mid files just don't sound right, like toto-africa.mid

Both of these play fine elsewhere, for example in foobar2000 with foo_midi.

@dardoor dardoor added the os:win label Apr 13, 2021
@amariami
Copy link

Yep same on Linux mint Ulyssa. Midi is broken
rel_ulyssa_xfce.mpv.log

@sfan5
Copy link
Member

sfan5 commented Apr 16, 2021

Firstly, your log doesn't show mpv "crashing". It exits with an error message after unsuccessfully trying to read the file.

mpv does not implement MIDI support itself but lets ffmpeg handle it, ffmpeg supports either libopenmpt or libmodplug for decoding. If something is wrong with that it's not our bug.

This .mid file makes mpv crash/exit: Simpsons.mid

This file just happens to be smaller than 16k and you're using libmodplug so this will be a duplicate of #8466.

@sfan5 sfan5 closed this as completed Apr 16, 2021
@sfan5 sfan5 added the down-upstream features and bugs that need to be implemented and fixed upstream label Apr 16, 2021
@ghost
Copy link

ghost commented Apr 20, 2021

I'm just interested in this issue and not insisting on using mpv to play MIDI, but libmodplug seems to be the only choice because libopenmpt doesn't support MIDI (FAQ).

As you probably know and I apologize if you've done so already, you need to set up timidity.cfg and GUS patch files for libmodplug to play MIDI. By default, you need /usr/local/share/timidity/timidity.cfg and patch files in instruments subdirectory for Unix-like OS, C:\TIMIDITY\TIMIDITY.CFG and patch files in INSTRUMENTS subdirectory for Windows. (The location can be changed by setting environment variable MMPAT_PATH_TO_CFG.)

This is what I've managed to use FreePats General MIDI sound set.

  • Download "Old FreePats General MIDI sound set" from FreePats (or BitMidi author).
  • Extract downloaded file, name the top directory freepats.
  • Make instruments directory in freepats, move Drum_000 and Tone_000 into it.
  • Open freepats.cfg, edit as below, save as timidity.cfg.
    Move drumset 0 block (about 60 lines) to the bottom (under bank 0 block).
    Remove .pat from every lines.

The directory structure should look like this:

freepats/
├── instruments/
│   ├── Drum_000/
│   │   └──(patch files)
│   └── Tone_000/
│       └──(patch files)
└── timidity.cfg
  • Set MMPAT_PATH_TO_CFG to the path to freepats and run mpv (or ffplay).
    MMPAT_PATH_TO_CFG=/path-to/freepats mpv toto-africa.mid
    By setting --demuxer-lavf-probescore=20 (Some valid modplug files are not played #8474), Simpsons.mid can be played, too.
    MMPAT_PATH_TO_CFG=/path-to/freepats mpv --demuxer-lavf-probescore=20 Simpsons.mid

Sounds still may not be so good, though.

@ghost
Copy link

ghost commented Apr 21, 2021

I forgot to mention. While I was reading other issue reports, I noticed this commit 4f18e79 which enables fluidsynth support (but reverted soon afterwards 16b44d9).
If you have fluidsynth and soundfont installed, apply the changes, configure --enable-fluidsynth and build, mpv plays MIDI just fine. (Just run fluidsynth to play MIDI is easier, of course.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
down-upstream features and bugs that need to be implemented and fixed upstream os:win
Projects
None yet
Development

No branches or pull requests

3 participants