Falcosoft / vstdriver

A Windows user-mode software MIDI synthesizer driver which is capable of using any 32 or 64 bit VST2 Instrument
https://falcosoft.hu/softwares.html#vst_driver
GNU Lesser General Public License v2.1
44 stars 0 forks source link

Audio corruption when switching playback between MIDI files #5

Closed RebelliousX closed 5 months ago

RebelliousX commented 5 months ago

I tried v2.30, 2.40 and 2.5.0. All of them have the same issue. I tried this with Winamp and MPC-HC, so it is not a specific audio player issue.

I am using S-YXG50 VSTi plugin. CoolSoft MidiMapper v2.1.2.0

Issue: From the archive, try to play DemonStar 03.MID or Metal Gear Solid - Discovery.mid and while the music still playing try to play Shell Shock by Sam Sketty.mid. All is well and be fine at this point, now while Shell Shock still playing, try to play any of the first two tracks. The instruments / channels are corrupted. And the only way to fix this is by exiting the player (winamp or mpc-hc) and open the midi file again.

I am not sure if this can be fixed, to be honest, I always had this issue, even before I started using VSTMidiDrv, it happened too when I was using VSTHost too. But the corruption only starts happening when I play Shell Shock by Sam Sketty.mid. MIDI Files.zip

Falcosoft commented 5 months ago

Hi, The solution is rather easy: You have to set an XG (or GS/GM) reset type instead of All Notes/CC (you can change the reset type from the tray menu of the driver): image

This works in MPC-HC since it re-opens the port after each track that triggers the driver to send the reset SysEx itself. (WMP and VanBasco work the same way.)

In case of Winamp you can also use the player's built-in Midi reset settings: image

FSMP works a similar way. It has its own reset type setting: image

The point is you should always use a Midi player that can send (or at least can trigger) a Midi SysEx reset after playing back a track. Or you can also send a reset from the driver's tray menu manually (in case the player can do neither). So restarting the player is never necessary.

RebelliousX commented 5 months ago

Thanks for your reply and amazing work 👍

It worked for few times when I tried switching tracks using Winamp and after that the same behavior is back. I changed it from Winamp midi plugin as the screenshot you provided and chose XG (Yamaha). Also I did select XG from the driver's tray menu, exited Winamp and tried for few times, issue is still there.

If I choose the reset option from Winamp to XG and the driver's systray to XG, I get worse behavior that will last even if I exit Winamp and open it again. So I decided to leave it to None for Winamp and set it to XG for the driver's tray menu. But I still see corruption or reset did not work correctly when switching between tracks while a track is still playing. I did exit Winamp when I made any changes to make sure settings were applied if that helps.

Edit: what I also found, if the track is playing incorrectly still, I have to try to play it again and again few times until it plays fine. Now Shell Shock plays fine almost every time (since it uses XG), but any other track that doesn't use XG like GM might have corruption. I noticed now I have random corruption with DemonStar and MGS - Discovery tracks. Again, if I play the same tracks few times it starts to play correctly. It is annoying and inconvenient, but it works.

I haven't tried to play older games like Duke3D Nuke'em to see if corruption will happen during music playback (it has great soundtracks for XG like the legendary Grab Bag theme), but if it happens there that would be horrible.

Also, somehow Winamp midi plugin still crashes for me if I try to open it after playing any track, the next time I try to open Winamp without playing anything, the Nullsoft Midi Player plugin opens fine. I thought that was fixed?

Falcosoft commented 5 months ago

Hi, Unfortunately I cannot confirm/reproduce the problems you experienced. For me it works perfectly. test video: https://youtu.be/2hFwFk1AKEc

Are you still experiencing the same problem with MPC-HC also? If not (the problem is Winamp specific) then try to use latest Winamp: https://download.winamp.com/winamp/winamp_latest_full.exe Also try to select the VST Midi driver port A/B directly in Nullsoft's Midi plugin as Midiout device to rule out that the problem is with Midi mapper.

In case of Winamp plugin freezes you can also try to untick the "Keep Host open even if ports are closed" option in advanced settings of the config dialog: image

PS:

I haven't tried to play older games like Duke3D Nuke'em to see if corruption will happen during music playback (it has great soundtracks for XG like the legendary Grab Bag theme), but if it happens there that would be horrible.

This is false information. Duke Nukem 3D does not contain even a single XG (Yamaha) track. All the tracks were composed on Sound Canvas devices from Roland. Some of the Midi files are GS (Roland) specific but most of them only use standard GM features (but they use a specific file format called EMIDI although it is not relevant in this context).

RebelliousX commented 5 months ago

Hello, thanks you again.

Here is a video showing the issue, sorry for the bad sound quality, it was clearer while recording though. https://youtu.be/PMUiASKQaYc

I still have same issue with MPC-HC too.

As for Winamp, I am using latest v5.9. I noticed the Nullsoft Midi Player plugin is newer than the screenshot you provided (v3.2) while mine is v3.57 ! Unchecking that option in vst midi driver configuration didn't help.

This is false information. Duke Nukem 3D does not contain even a single XG (Yamaha) track. All the tracks were composed on Sound Canvas devices from Roland. Some of the Midi files are GS (Roland) specific but most of them only use standard GM features (but they use a specific file format called EMIDI although it is not relevant in this context).

True, I know that. But XG soundcards still played the music differently than any others. I remember back in the 90s, I had Yamaha DS-XG card which had fantastic music playback for Duke Nuke'em 3D and when I tried the game on my friend's computer who had Adlib sound card (that didn't have yamaha chip IIRC) I wanted to puke because of its low quality.

It did sound similar but much better and crispier (for the lack of better term) than this video, in this video sound feels muffled compared to old Yamaha DS-XG card: https://youtu.be/YKsyPvTIBHM?si=e0Z2KXX-qz6u8lNg&t=408 or this https://www.youtube.com/watch?v=LqCFl-D1jAc

Anyways, sorry if I wasted your time, if you feel this is not a real issue, please feel free to close this. 👍

Falcosoft commented 5 months ago

As for Winamp, I am using latest v5.9

As you can see at the beginning of my test video it was done also with latest version and the plugin version was 3.57. Only the screenshot was done with an earlier version (but it worked also without problems for me).

True, I know that. But XG soundcards still played the music differently than any others

Of course, but this still does not mean that the soundtracks are for XG :) . Contrary Shell Shock by Sam Sketty.mid is really meant to be played on XG synths (it contain XG specific SysEx messages that are understood only by XG synths).

when I tried the game on my friend's computer who had Adlib sound card (that didn't have yamaha chip IIRC) I wanted to puke because of its low quality.

Adlib means FM synthesis so you should not comapre it to sample based ones (like Yamaha XG or Roland GS). But back to the point, you can try some more options to find out what can be the issue:

  1. You can change in Winamp's Midi plugin the 'Playback Method': image

  2. You can try to use ASIO2WASAPI plugin instead of Waveout: image

  3. You can try my Midi player (FSMP): https://falcosoft.hu/softwares.html#midiplayer

RebelliousX commented 5 months ago

Thank you for your suggestions. What fixed it for me was your second suggestion. I reinstalled with private ASIO drivers option enabled (I am not sure it has any effects since I don't have ASIO4ALL installed?).

Screenshot 2024-06-09 024222

But with Exclusive mode, I get slight audio noise when a track starts, like in Demon Star 03.mid.. Choosing Shared fixes that. And the dialog determines that 22ms was the closest buffer. I did not notice any delays with Shared option unlike Exclusive mode.

Should I increase the buffer or leave it at that number? What are the drawbacks if I increase the buffer in Shared mode?

I know when it was Exclusive, I noticed a delay until the buffer is created, for example 256ms will add a quarter of a second after initial playback. Shared doesn't have that.

So with this and choosing to Send XG Reset from systray area fixed the problem for me.

Again, I want to thank you for your amazing work. I really appreciate it 👍

Falcosoft commented 5 months ago

Hi, WASAPI Exclusive mode uses double buffereing so the latency is actually doubled compared to what is set in the dialog. But in exclusive mode much lower buffer sizes can be set (i.e. even 3 ms). Actually exclusive mode is only recommended when you want to achieve a really low latency (3 -10 ms buffer size). Otherwise it has only drawbacks like only one app can use the audio device (as the name suggests exclusively). In shared mode no double buffering is used so the set buffer size in the dialog is closer to the real latency. If the minimum is working for you that's great. 30 ms buffer size can give a little more headroom so if low latency is not a requirement for you then you can try it.

RebelliousX commented 5 months ago

Thanks a lot for the explanation, I appreciate it 😊