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

LSDJ wave channel PCM sample playback sounds bad #177

Closed
urbster1 opened this issue May 13, 2019 · 5 comments
Closed

LSDJ wave channel PCM sample playback sounds bad #177

urbster1 opened this issue May 13, 2019 · 5 comments

Comments

@urbster1
Copy link

Testing this ROM on hardware (also in BGB as well as Gambatte) produces the appropriate output, but Sameboy produces a weird distortion or filter on the output. I've used the lsdpack tool from the author of LSDJ to create a test ROM for playback and I've attached it to this issue.
lsdpack-sampletest.zip

@peterswimm
Copy link

To my ears it sounds like the hardware bug that is on the dmg -03 generation motherboards so maybe they are just modeling a hardware bug here?

@LIJI32
Copy link
Owner

LIJI32 commented May 23, 2019

I'd like to iterate something – generally speaking, DMG mainboards (DMG-CPU-02, 03 etc) don't have "bugs", but, if anything, different analog characteristics. DMG CPUs (misleadingly labeled similarly as DMG-CPU A, DMG-CPU B, etc) do have bugs, and probably even different analog characteristic. Other than the CPU, different Game Boys have different amp chips which can also effect audio. I highly doubt the mainboards have any direct effect other than their correlations with different CPU and amp chips, so while mainboard revision are mostly useless to me, actual chip revisions are far more informative when differences apply. (If you could tell which actual chips suffer from this problem, it would be nice as I could emulate both versions correctly depending on selected revision)

As for SameBoy's modeling – currently, the only supported DMG revision is DMG-B, but the analog characteristics of all models (DMG, SGB1/2, CGB, AGB) are currently all rough approximations, as I haven't measured those properly yet. (It's a bit tricky, considering I don't have proper equipment for good recordings) A better approximation might fix it.

In any case, I'll test this ROM against the latest master, which includes several APU improvements and compare the results to my Game Boys and see in what ways they differ.

@peterswimm
Copy link

Well the great majority of game boy units, up through the sp era play samples the same way. I think the “bad” sound we are talking about goes beyond analog flavor differences. This is a good thread that discusses the differences from musician perspectives: Anyways if they want to seriously consider it here is a good thread about it https://chipmusic.org/forums/topic/11881/dmg-cpu-versions-lsdj-revisited/

@LIJI32
Copy link
Owner

LIJI32 commented May 23, 2019

Yes, I'm well aware of this thread, but this doesn't change the fact that a specific mainboard revision has very little to no effect on the audio – it's the other components that affect it. Check gekkio's HW DB for example: https://gbhwdb.gekkio.fi/consoles/dmg/

Most DMG-CPU-06s come with DMG-CPU B (Affects digital behavior and some analog characteristics) and a type A3 power board (affects potential interference), but some come with DMG-CPU C, or type B or D power boards, so these comparisons shouldn't have been done with boards to begin with, but the actual components on them.

Specifically the bad sound in SameBoy running this ROM happens due to how LSDJ plays samples – by disabling and enabling channel 3, you also disable its DAC for a certain period of time. On an ideal DAC, disabling and enabling it would be instant, and it would cause a periodic spike when playing a sample, which translates into a constantly buzzing sound. You can actually hear the buzz on hardware, and it's more noticeable on less-carefully-written-ROMs such as Cannon Fodder. (Keep in mind BGB and Gambatte do not emulate any of these behaviors).

Thankfully, the DACs are not ideal, and take some time to discharge and charge again, mostly masking this buzz away. However, to emulate this properly, I need the proper lengths and shapes of the charge and discharge functions of the DACs (these are several of the so called analog characteristics), otherwise I might mask this effect too little (ending up with buzzing audio) or too much (ending up with the weird filter, as it is now). Finding those values by trial and error is tricky as well, because values that work well for one game might not work well for another, and so on.

Hopefully I can get proper oscilloscope-quality recordings and those should help properly solving this issue.

@urbster1
Copy link
Author

urbster1 commented May 24, 2019 via email

@LIJI32 LIJI32 closed this as completed in 85c43fa May 25, 2019
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

3 participants