Wohlstand / libOPNMIDI

A Software MIDI Synthesizer library with OPN2 (YM2612) emulator
GNU Lesser General Public License v3.0
91 stars 7 forks source link

Occassional messy playback (bug?) #45

Closed freq-mod closed 6 years ago

freq-mod commented 6 years ago

High time I reported this issue. There are few midis which break OPNMIDI. During playback, weird noises (sound like junk FM data?) can be heard in the background. Sometimes these are very loud and long and I can't really tell what is the real cause. At this point I can't tell it's emulation issue or broken GS support. It affects both mine and your xg bank (although they are not as noticeable as in case of mine). What's really weird though it's that these noises happen at different time positions between VLC and command- line MIDI player ( I even suspect PGE MUSplay would give different result, one month ago it was the case). It's almost random.

bug.zip - here are recordings, two MIDs which exhibit that bug ,newest revision of my bank and a version of it with every instrument and drum muted so have this crap isolated on MIDI2.MID

P.S. It's somewhat better after sysex calls were implemented, so it could have something to do with NRPNs. But then again, they're ignored at this point :suspect:

Wohlstand commented 6 years ago

PGE MusPlay here is still use old version (until I'll push the updates into AudioCodecs repository and will poke SDL Mixer X and PGE-Project pull the fresh deps)

Wohlstand commented 6 years ago

About of the bug, I guess, it's arpeggio have applied to... percussion instruments! Damn!

Wohlstand commented 6 years ago

But seems some another glitch, it's not an arpeggio, however, I'll check out the thing...

Wohlstand commented 6 years ago

The junk noise happens on MAME and Nuked OPN2, but never happen on GENS. It's possible some glitch of real chip that may happen on some condition I need to find... EDIT: Okay, it happen on GENS too...

freq-mod commented 6 years ago

Yeah, it's not arpeggio, since libADLMIDI sounds rather fine. Maybe YM2612 commands are called incorrectly, like in case of OPL3's drum mode...

Wohlstand commented 6 years ago

Okay, I found reason why this happens: when all channels are busy, and when some of them (with note that begins playing now) are immediately overriding them (too short distance between first noteOn and second that overrides first)

Wohlstand commented 6 years ago

Okay, after some tweaking: this will happen when one instrument will be missing! I know how to resolve this - drop the note if no instrument on it

Wohlstand commented 6 years ago

opn2-singlechip-noise-on-missing-notes.mid.zip Just now I made the unit-test MIDI file that reproduces this crap, but, you need to turn the single-chip for this.

Wohlstand commented 6 years ago

Lowest note here plays empty instrument entry. default

Wohlstand commented 6 years ago

So, the fix is - complete avoiding blank notes be even played. This will also resolve trouble of channels overflow that caused by those damned blank notes (are playing missing instrument).

Wohlstand commented 6 years ago

Just now I have posted an update, please try it out! I'll apply same to libADLMIDI as this will give more effective channels usage as blank notes will don't busy chip channels.

Wohlstand commented 6 years ago

@papiezak , Try to test the stuff again

freq-mod commented 6 years ago

Sounds good so far. Please apply it to vlc plugin as well

Wohlstand commented 6 years ago

VLC plugin is only a wrapper over the library which is an actual backend, so, the fix will affect everything that uses libADLMIDI, include VLC plugin :wink:

freq-mod commented 6 years ago

that's strange, at first I compiled vlc plugin, gave a listen to one of mids I sent and heard crap note I will try once again...

Wohlstand commented 6 years ago

I think, you need to do full rebuild (make clean and then make -j 4 again). Some CMake assemblies are may not re-link updated library to "up-to-date" plugin.

freq-mod commented 6 years ago

Yes, it's OK now.

Wohlstand commented 6 years ago

Closing as fixed and tested! :fox_face: :+1: