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

[VGMplay] Weird playback issue with a CPS-2 title #6824

Open
Epictyphlosion opened this issue Jun 13, 2020 · 17 comments
Open

[VGMplay] Weird playback issue with a CPS-2 title #6824

Epictyphlosion opened this issue Jun 13, 2020 · 17 comments
Assignees

Comments

@Epictyphlosion
Copy link

Not sure if anyone has reported this before or not, but when playing back some music from 1944: The Loop Master, they end up sounding very off. I did get an error saying that it had detected a bad rip, but the music plays just fine when running the game itself.

For example, when playing the third song (Deep Blue), the guitar randomly stops playing in-between each beat, as well as the drums a little. Same thing happens when trying to play the opening music. Funnily enough, the instrument cutting out in that one is also the guitar. I'd assume every song has the same or similar issue when playing them back, but I haven't had time to test them all.

Still, there may have been some incorrect settings that I missed, or I didn't have something in order... or it could be that I really do have a bad rip after all.

@MooglyGuy
Copy link
Contributor

If you hit F11 to show the current frame rate, does it show that you're running at 100% of full speed, or some value less than that? What you describe seems similar to how the audio of an emulated machine sounds if the system isn't running at full speed.

@Tafoid
Copy link
Contributor

Tafoid commented Jun 13, 2020

AFAIK most (all?) of the QSound related rips were hand crafted and some data may not be present/stripped from the data, only covering known registers back before actual emulation of QSound, not using HLE. Outside of that, the QSound emulation is activated for vgmplay and requires a decently beefy CPU to keep in the 100% speed during playback and I agree with @MooglyGuy that it sounds like your CPU may not be up to snuff. With my i5 4570 (3.2ghz) I don't get 100% without some frameskip (using AUTO seems to get there eventually).

@Epictyphlosion
Copy link
Author

Epictyphlosion commented Jun 13, 2020

The computer I'm running this on has an i7-9750H (2.6Ghz base, 4.5Ghz turbo), should be more than enough as far as I'm aware. The framerate shows 100% for a majority of the time, but for some reason it randomly dips down to ~90%, then up to around ~105%, and then back to 100% again, which must be causing some desyncing.

Though task manager showed that the CPU wasn't even at 25% utilization when music was being played, so I wouldn't blame it just yet. I didn't blow a thousand dollars on a gaming laptop for nothing, lol.

@Epictyphlosion
Copy link
Author

Annotation 2020-06-13 162243
Here's a screenshot of the CPU usage. Red line indicates when VGMplay was started.

@Caedhros
Copy link

If you switch to a per cpu core usage display instead of overall, that is likely maxing out 1 core and that's what is causing the problem.

@angelosa
Copy link
Member

I'm been aware that several CPS1/2 VGM dumps don't play correctly with our LLE, Slam Masters 008 Moscow and Cadillacs & Dinosaurs 015 boss 2 comes into mind (which also reports bad rip detected, correcting qsound clock in terminal)
Given the context once I start overhauling the DB I'm gonna mark these as bad_dump .

@Epictyphlosion
Copy link
Author

Annotation 2020-06-14 182842
Good thinking, @Caedhros. Turns out it wasn't utilizing all the cores, and the second one was getting maxed out for some reason. Might be causing a bottleneck.

Sounds good, @angelosa.

@superctr
Copy link
Contributor

I'm not sure if this has been fixed at this point, but I recall that the vgmplay driver doesn't honor the required wait time between writes to the QSound chip. Since VGM files can't detect how long the chip will be busy after each write, it is expected that if the chip requires a wait between writes, the player should buffer those if needed.

@superctr
Copy link
Contributor

superctr commented Jul 15, 2020

Also, since I just remembered. There's a hack that needs to be added to properly play back some old VGMs since the old vgm_cmp optimization tool removed too many register writes. This affects both the new HLE and the LLE. See here.

@smf-
Copy link
Member

smf- commented Jul 19, 2020 via email

@superctr
Copy link
Contributor

I think we're hoping that the files get re-ripped, so they don't have have too much removed and also with correct write timing.

I'm afraid that won't happen, as the correct write timing is not possible for the reasons I just mentioned.

Also some of the people who made the CPS2 packs on vgmrips.net have simply left or don't have the original files, so it's not possible to re-optimize.

@angelosa
Copy link
Member

angelosa commented Jul 19, 2020

For all purposes and intents the CPS2 (actually QSound) current dumps are considered bad_dumps. Just the same as any other romset that internally sports bitrot or whatever really.

@smf-
Copy link
Member

smf- commented Jul 19, 2020 via email

@superctr
Copy link
Contributor

Ok, sorry for this wall of text. If anything is unclear, just let me know.

There are a few legacy reasons to why the busy wait needs to be done inside the player:

  1. The busy wait intervals were not considered when the VGM file format was created. One of the reasons why the format was created in order to replay music on real hardware. Originally, only 8-bit Sega consoles were supported. The CPU couldn't support such fine intervals, so the timings would be quantized in the player. Since the sound chips (especially Yamaha FM chips) still required a minimum wait interval, this wait would be ensured by the player, since any fine timing intervals would have been stripped. You'll also see that many VGM files hosted by smspower.org have all waits shorter than 1/60 seconds stripped, for those reasons. Newer hardware can supporter finer timing intervals, however they will still buffer writes in order to not overload the sound chip.

  2. The minimal delay in a VGM file is 1/44100 second (22 microseconds). This isn't precise enough for the actual busy wait required by many sound chips. Especially Yamaha chips will actually usually become ready much faster than the busy flag tells you. For example, the YM2612 may actually require between 47 and 83 cycles after a write. Considering a Mega Drive's clock speed, this corresponds to 5-10 microseconds. This means that a logged VGM from an accurate emulator could have 2 YM2612 writes in the same 44100 Hz "sample". Obviously the chip will drop one of the writes if you do them at the exact same time, so you will need to buffer the writes.

  3. VGMs generated by trackers and tools or converters other than emulators often don't take into account the busy time at all, and will put all writes for a frame in the same VGM sample. Although this shouldn't apply to Project2612 and vgmrips packs, this does apply to the SMSPower packs, as I have mentioned.

And finally, one thing to mention.

Currently QSound is the only chip supported by the MAME vgm player that actually cares about the wait interval between writes, but most Yamaha FM chips (and possibly other chips) will also have a similar wait interval, even if this behavior currently isn't emulated in MAME.

As the emulation of those chips improve, more and more VGM files will become broken, and at some point you would question why the VGM files play back correctly in any other player, and even on real hardware, but not in MAME. You could argue that the VGM logs are bad, but in that case they will simply stay broken forever as no one will have the incentive to re-log a VGM that works fine on every other player, including real hardware.

I suggest reserving the "bad dump" keyword for VGM files that actually are unplayable on real hardware, disregarding the timing issue. The QSound packs that used the old optimization tool would be an example for that, even if they could be fixed using a hack. Another example is the Project2612 Rocket Knight Adventures pack, since it does a lot of nasty stuff, including garbage writes to the test register.

@smf-
Copy link
Member

smf- commented Jul 29, 2020 via email

@MooglyGuy
Copy link
Contributor

Due to the Covid situation, I'm stuck using my work PC at home, and as beastly as it is, it can't cope with the LLE core either. I understand the desire to prevent code rot by having the LLE core present and accounted for in builds, but it might be better to make the HLE/LLE switch a runtime flag (similar to -drc/-nodrc) and have vgmplay default to HLE.

@smf-
Copy link
Member

smf- commented Jul 30, 2020 via email

@aaronsgiles aaronsgiles self-assigned this Jun 22, 2021
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

No branches or pull requests

8 participants