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

Improve looping for older midi hardware devices #2180

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

ceski-1
Copy link
Collaborator

@ceski-1 ceski-1 commented Feb 4, 2025

This was reported on the speedrunner Discord. Apparently there's stuttering with vanilla songs (E2M1) when using Nuked SC-55 (I couldn't reproduce it). However, I verified there was stuttering with a real SC-55. Test wad: shortloop.zip

When a midi song finishes playing, the DMX system in vanilla Doom sends "reset controllers" and "default volume" events, but just for the channels that are used by the current song. Then it loops from the beginning. Woof and DSDA-Doom (and maybe others) send the same events but to every channel. It seems these extra events are enough to overload older midi hardware. It's more noticeable with songs that place too many events together at the very start of a song (E2M1). The fix is to just mimic what vanilla Doom does.

When the song loops, only reset the used channels.
Copy link
Owner

@fabiangreffrath fabiangreffrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Glad to see you back.

@rfomin
Copy link
Collaborator

rfomin commented Feb 4, 2025

Looks good, thank you!

I can't replicate it on the Nuked SC-55 either. Maybe it depends on the emulated model?

@Kappa971
Copy link

Kappa971 commented Feb 4, 2025

Looks good, thank you!

I can't replicate it on the Nuked SC-55 either. Maybe it depends on the emulated model?

kraflab/dsda-doom#600 (comment)

I recorded audio from Nuked SC55 (mk2) with the test wad. You can easily hear that in DSDA-Doom the music loop is not played correctly... every time the track starts again, the initial notes are played too fast.

@ceski-1 ceski-1 merged commit 09d1399 into fabiangreffrath:master Feb 4, 2025
8 checks passed
@ceski-1 ceski-1 deleted the midiloop branch February 4, 2025 21:03
@d-bind
Copy link

d-bind commented Feb 5, 2025

Regarding it stuttering or not in Nuked vs real hardware.
A while ago I found that with a hardware device it actually depends on the interface.

When connected via USB or serial port, the overload sound like a stutter (the first note arrives late and runs into the next one).
However, when connected via soundcard's MIDI interface (e.g. gameport on the old soundblasters or the rare direct connection in newer cards), the same overload instead sounds like a slightly drawn out note (the first note arrives immediately, and it's the second note that is late).
So the way Nuked behaves could also vary depending on some other factors. For me the hiccup in Nuked sounds closer to how a serial-connected physical device sounds.

With vanilla Doom tracks, besides E2M1 there's also D_INTRO that overloads the device right away.
But this is more audible in complex custom tracks, such as this one.

My understanding is that even without GS Reset, just the program and control changes for 16 tracks are more than enough to overload it. A possible, more robust way of ensuring seamless playback would be getting all events before the first Note On, and playing them in advance and staggered if possible - after the channel's last Note Off but before the track actually loops.
When I first discovered the issue I was hoping that there would be some kind of system-wide MIDI buffering software, but now I'm not really sure this is even possible.

@ceski-1
Copy link
Collaborator Author

ceski-1 commented Feb 5, 2025

A possible, more robust way of ensuring seamless playback would be getting all events before the first Note On, and playing them in advance and staggered if possible - after the channel's last Note Off but before the track actually loops.

It's the composer's responsibility to space out midi events appropriately (a lot of older midis do this) and to test their midis with their target midi devices. Woof's responsibility is to just play the events as written.

Creating workarounds for older hardware eventually introduces other issues. There are wads that have midis with hundreds of events bunched together at the immediate start. Spacing these out as a fix would create a noticeable delay. That's just one example.

Using retro midi hardware or accurate emulators (Nuked SC-55) will always have compromises. Enjoy them with the selection of (older) wads that work okay, otherwise understand that most midis are only tested with software now, usually the default Windows synth or a soundfont player.

@Kappa971
Copy link

Kappa971 commented Feb 7, 2025

Apparently modern Doom midis are composed with the Windows midi synthesizer or this soundfont: https://musical-artifacts.com/artifacts/724 (including tracks from the new Legacy of the Rust expansion). Both have the Roland Sound Canvas sound.

Another solution is to find a copy of Edirol Virtual Sound Canvas and use the VSTi plugin with Falcosoft Midi Player (same sound as the Windows synthesizer but with working reverb and chorus, and 128 voice polyphony instead of 32).

The above solutions however don't have a high quality sound.
To have the best possible quality while maintaining the Sound Canvas sound, you can run two instances of Nuked SC-55 (mk2) through Falcosoft Midi Player, to have a polyphony of 56 voices.

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

Successfully merging this pull request may close these issues.

5 participants