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

DAC Volume Discrepancy w/ real Mega65 hardware #393

Closed
deathybrs opened this issue Dec 26, 2023 · 5 comments
Closed

DAC Volume Discrepancy w/ real Mega65 hardware #393

deathybrs opened this issue Dec 26, 2023 · 5 comments
Assignees

Comments

@deathybrs
Copy link

The values of CHnVOLUME ($d729, $d739, $d749 and $d459) do not have the same levels on xemu as they do on real hardware. On real hardware, it appears that $ff is +6dB, allowing the volume to be boosted above 100%. In contrast, on xemu, a value of $ff in these registers appears to be 0dB, which would be in line with what one would expect if you used a typical sound system like the one that is included in SDL.

It further appears that the scale of the registers on the real hardware is linear, when it should be log2, but I have not been able to confirm this with certainty yet... the relevance being that the behavior of these registers may need to change in the future.

I am using v20230703013254, with ROM 920384.

@lgblgblgb
Copy link
Owner

Hmm, I am far from being expert on this area but I guess I cannot make anything in "dB" I just can push digital samples to SDL. Also it must be taken account that audio samples generated for the SDL audio output is mixed together with SID and OPL3 output as a single stereo 16 bit audio stream. About the log/linear scale, I guess then the way would be to use a helper table to "scale" the meaning of the volume register values to "real" scaling (used for samples generated by the DMA-audio) before the final mixing stage, it can also include the effect being "louder", ie over 0dB or something. My main concern that though I can try to compare the listening experience with a real MEGA65, but I am very much "music / audio deaf" ie I never can say the difference too much, and I always have the feeling "well, it sounds similar, close enough" and cannot even distinguish the difference with different setting ie "which is the better" to be able to fine-tune the situation.

@lgblgblgb
Copy link
Owner

By the way, another key factor: Xemu misses the "audio mixer" part of MEGA65 still. Where logically the normalization of level-ratios of different sources should be done before submitting the sample values to SDL. And no, I don't want to use SDL_mix since it's another library, one of the key factors of Xemu I wanted to do: do not use anything other than the core SDL, otherwise another dll/dylib which complicates thing further, static linking otherwise can be a huge pain both because of possible license conflict and also how it should be done throughout different platforms Xemu should run on.

@lgblgblgb
Copy link
Owner

Well, so I guess this must be #272 where the various sources of audio should be mixed together with the right scaling factor also taking account the missing "MEGA65 mixer" settings. Currently Xemu internally uses 10 channels:

// 10 channels, consist of: 4 channel for audio DMA, 4 channel for SIDs (each SIDs are pre-mixed to one channel by sid.c), 2 OPL3 channel (OPL3 is pre-mixed into two channels in opl3.c)
#define MIXED_CHANNELS                  10

If you agree @deathybrs I would close this issue and move to #272 with extra observations and TODOs in this area.

By the way, I would say, even if I am "tone/volume deaf" I can still use an oscilloscope to measure the output levels and their relative standings with different volume/mixer settings and compare it to a real MEGA65's output.

@lgblgblgb lgblgblgb self-assigned this Dec 27, 2023
@deathybrs
Copy link
Author

Merging the tickets sounds fine to me. Yeah, I would recommend using tools to sort it out. If you are OK with waiting until the next batch ships, I can give you exact numbers by which it needs adjustment.

@lgblgblgb
Copy link
Owner

So my plan is (more or less ...):

Implement MEGA65 mixer emulation. Then, fine tune what certain "volume" and "level" settings mean for real. If not linear, with some help of a "mapping table" for example and such.

So I close this now, and moving to #272 , after all it's a really old issue, and should be targeted sooner than later for now ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants