Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
174 stars 17 forks source link

Descent MIDI notes don't release #223

Closed mmontag closed 4 years ago

mmontag commented 5 years ago

Hi, a little mystery here, wonder if you can help debug.

See this file: https://mmontag.github.io/chip-player-js/browse/Game%20MIDI/Descent%20(FM)?play=Game%20MIDI%2FDescent%20(FM)%2FGAME03%5Bint%5D.MID

Notice the synth bass loop that starts playing around 7.5 seconds. The notes are sustaining way too long, as compared to the sound in game: https://sectorgame.com/descentfiles/uploads/Music%20%26%20Sound%20Effects/Descent/Descent%20Midi%20Soundtrack%20%28OPL3%29/08%20%28Level%203%29%20Lunar%20Military%20Base.mp3

chip-player-js plays OPL3 through libADLMIDI realtime commands, and also loads the appropriate bank (HMI Descent: Int). My MIDI playback code is here.

I checked the MIDI file and the notes are not held like that. I can't figure out if the problem is in the bank file or somewhere in the MIDI file -> sequencing -> synthesis pipeline.

Wohlstand commented 5 years ago

I have checked that by myself, and it's not a defect of player, it's the instrument itself, and it's normal behavior:thinking: This bass has a big release time which makes it sound like it is held. I have made a quick demo of that: https://www.youtube.com/watch?v=8RUz-dLZcIg A bit later I'll give some random walkthrough video from the game itself where music is sounds...

Wohlstand commented 5 years ago

Or easier thing: try to choose absolutely any other bank even it will sound broken, but pay an attention on vibraphone (which a place of bass in that descent song), and you'll hear it's fine, not held :fox_face: :wink:

mmontag commented 5 years ago

Thanks! Can you open the “vibraphone” in a bank editor and see the envelope params of the instrument?

I am guessing it has a long release time. So then, why do the notes get cut off early within the game?

On Jun 10, 2019, at 3:45 AM, Vitaly Novichkov notifications@github.com wrote:

Or easier thing: try to choose absolutely any other bank even it will sound broken, but pay an attention on vibraphone (which a place of bass in that descent song), and you'll hear it's fine, not held 🦊 😉

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

mmontag commented 5 years ago

I just saw the demo video, is this your bank editor? looks awesome!

On Jun 10, 2019, at 3:45 AM, Vitaly Novichkov notifications@github.com wrote:

Or easier thing: try to choose absolutely any other bank even it will sound broken, but pay an attention on vibraphone (which a place of bass in that descent song), and you'll hear it's fine, not held 🦊 😉

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Wohlstand commented 5 years ago

You can open that in fm_banks/bnk_files/intmelo.bnk which is Descent::Int bank Снимок экрана от 2019-06-10 19-37-47

Yeah, everything I have showcased on the video with playback of the voice while I changing the instrument and the demo of playing the same song with a modified bank loaded as custom external WOPL bank file.

Wohlstand commented 5 years ago

P.S. @mmontag , I have checked out some MIDIs at your archive, and I see some interesting things! :fox_face: I have a huge collection of MIDI (~21k files) include those I made by myself, I would exchange with some things, and I have to add into this archive from my collection (for example, I did my own full rip of Corridor 7 songs from IMF to MIDI conversion which is more accurate and some other songs).

P.P.S. In your project you would also use my another libOPNMIDI synthesizer which is similar to libADLMIDI but does use of OPN2 chip from Sega Megadrive for synthesis.

mmontag commented 5 years ago

@Wohlstand are you suggesting that you can contribute some MIDI files? If so, that would be great :) You can email me directly, matt.montag / gmaiI.

Also yea, libOPNMIDI sounds cool...and definitely better than the 64 MB soundfonts that try to do the same thing.

Wohlstand commented 5 years ago

@mmontag , at morning I have sent you an email, feel free to read it! :fox_face: :wink:

mmontag commented 5 years ago

footnote: All of this (custom banks plus quirky MIDI playback behavior) makes Descent music a good candidate for doing VGM rips from DosBox.

jpcima commented 5 years ago

I dont think the source code of the Descent FM MIDI driver was released unfortunately, which would permit to reproduce these tracks exactly.

Apparently the PC sources support the GM tracks only. When we have implemented libADLMIDI support in dxx-rebirth we have also used the GM tracks. Since the Descent bank was arranged in different fashion than GM, I have just picked another from the set and used it as a default.

Note it can be bugs in original game engines also, which explain some differences of playback.

mmontag commented 5 years ago

Thanks for shedding some light on that @jpcima. I noticed some commented music stuff when browsing the Descent source, I guess it was a licensed product. dxx-rebirth is an awesome project!

Wohlstand commented 5 years ago

Okay, just now I have figured out for the sounding and I may guess two things I wanna check:

Wohlstand commented 4 years ago

Okay, I found the true reason for this difference:

bass-test-SoS.zip

Also, I had to include my experimental set.

You can try to tweak this to compare things. Edit "setup.ini" to change names of test MIDI file and bank names, then run "setup.exe" and "midi test" to test the playback. Note that this thing won't play "hmp" files: hmi only.

Wohlstand commented 4 years ago

Okay, just now I finished some work to:

One note: while playing Descent songs, please enable the panning stereo mode (which is off by default). HMI does simulation of panned stereo by using of two channels in parallel.

Wohlstand commented 4 years ago

@mmontag, please apply the latest master state of libADLMIDI to you and verify, how Descent songs will be played on your end.

mmontag commented 4 years ago

@Wohlstand I'll try this out and let you know.

mmontag commented 4 years ago

@Wohlstand hm; I'm sad to say the track sounds the same as it did before, with the HMI (Descent:: Int) bank. I've merged in the latest libADLMIDI master branch all the way up to commit 5703f4b (Sun Sep 6). Maybe something else I can try...? BTW I believe I've already enabled the panning mode:

  g_adlSynth = adl_init(sampleRate);
  adl_setSoftPanEnabled(g_adlSynth, 1);
  adl_setNumChips(g_adlSynth, 4);
Wohlstand commented 4 years ago

You need to rebuild your local adldata with latest tool. If you did a set of WOPL files, please edit them with latest OPL3-BE and set them the HMI volume model. A quick fix: set volume model by libADLMIDI's API.

Wohlstand commented 4 years ago

The feature works if volume model is HMI. When other volume models used, then Descent songs will sound same as in past.

Wohlstand commented 4 years ago

Also: if you have the master copy, set volume model to AUTO, then HMI volume model should work for all banks of HMI type.

mmontag commented 4 years ago

Ok, I've added the AUTO volume model switch. It still sounds different from the MP3 I linked in the first post. I'm using adldata.cpp that is tracked in the repository - that should be up to date, right?

It's deployed live now, in case you want to hear for yourself: https://mmontag.github.io/chip-player-js/browse/Game%20MIDI/Descent%20(FM)?play=Game%20MIDI%2FDescent%20(FM)%2FGAME03%5Bint%5D.MID (note the list of OPL3 Banks is updated. You have to choose HMI (Descent:: Int) yourself)

Wohlstand commented 4 years ago

that should be up to date, right?

That fine. Re-generation is needed if you plan to pass your own set of banks.

It still sounds different from the MP3 I linked in the first post.

The reason is that SOS is mote aggressive on channel allocation. Also, because SOS does the use of full panned stereo by itself, it limits 9 channels only. If you will remove all tracks but bass, it will sound the same in both SOS and libADLMIDI. I found a copy of SOS libs at Corridor 8 package, and I built a simple player with OpenWatcom to try various experiments. At least, other songs sounding correct without making a mess of releasing notes.

EDIT: If you are interested for some local tests, I made this archive: sosplay-descent.zip run each bat file inside DosBox to play each song.

Wohlstand commented 4 years ago

SOS - HMI Sound Operating System, a sound library used by Descent game.

mmontag commented 4 years ago

So this relies on a quirk of the sound engine... maybe this should in theory be addressed in the MIDI conversion process, when extracting MIDI from Descent. It sounds very difficult to fix unless you have a dedicated HMI SOS emulation mode in libADLMIDI engine...

Wohlstand commented 4 years ago

I crafted another demo:

Wohlstand commented 4 years ago

@mmontag , just now I made a small tweak, and seems, HMI behavior is now more accurate :fox_face:

Wohlstand commented 4 years ago

P.S. Please pull the top master, I did one minor mistake that breaks all other models, I fixed that.

Wohlstand commented 4 years ago

A quick demo: adl[L]-vs-sos[R].ogg.zip libADLMIDI at left, SOSPLAY at right. Both ran in DosBox to make a fair comparison.

mmontag commented 4 years ago

Yes, it sounds great now! I am getting the same result as your example audio. Very impressive :) I hope your effort yields more accurate playback in other music as well.

Wohlstand commented 4 years ago

I hope your effort yields more accurate playback in other music as well.

Working hard on this :) Also, my recent works I did to make accurate sounding of AIL and DMX banks: I had to replicate bugs of DMX with AM voices, and make the sounding of volume model same as in Doom games, and AIL volume model was been tuned. I had to inspect ASM source of AIL2, released by Miles in 2000. HMI is hardest thing because I had to dig for tools the universe and hack by disassemblers :zany_face: . Also, I had to replicate the bug of AM voices for Apogee Sound System model, especially this makes accurate sounding of FM music of Blood game.

Wohlstand commented 4 years ago

I guess, the task is solved, I'll close it! :fox_face:

Wohlstand commented 4 years ago

Thank you @mmontag for verifying and confirming the work! :)

Wohlstand commented 4 years ago

btw, one bug I will need to fix #233, otherwise, Doom's bank makes some odd noise while playing some songs...

EDIT: Fixed