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

Sample at every tick #100

Merged
merged 4 commits into from
Jul 4, 2024
Merged

Sample at every tick #100

merged 4 commits into from
Jul 4, 2024

Conversation

leiradel
Copy link
Contributor

@leiradel leiradel commented Jul 4, 2024

The beeper misses some input values because the input state is only ever used when needed to produce an output sample. Sound quality suffers, I noticed it when comparing the Nonamed intro music with Fuse.

This PR takes every beeper tick into account, using the average when an output sample is required. Nonamed now sounds extremely similar to Fuse when configured to not use audio filters.

I've decreased the buffer because 512 made it sound a bit muffled. Both the sampling scheme and the buffer size were suggested by MartianGirl, who has all the merit.

I'm not sure if the change applies to systems other than the ZX Spectrum, I'm not familiar with them.

I'm also not sure if the comment below applies anymore, so I left it in the source code:

/* DC adjustment filter from StSound, this moves an "offcenter"
   signal back to the zero-line (e.g. the volume-level output
   from the chip simulation which is >0.0 gets converted to
   a +/- sample value)
*/

comparison.zip

@floooh
Copy link
Owner

floooh commented Jul 4, 2024

Hmm interesting, I need to try this fix in the other systems.

I know that the chips audio emulators generally suffer from frequency aliasing (except maybe the SID emulator), so I'll generally need to do more research into that area (also how other emulators solve those problems).

Do you know why Github thinks that your change has a merge collision? The beeper.h file in the chips repository had its last change 2 years ago 🤔

...it complains about this line, weird:
image

@leiradel
Copy link
Contributor Author

leiradel commented Jul 4, 2024

How odd, I can do another PR if you prefer.

@leiradel
Copy link
Contributor Author

leiradel commented Jul 4, 2024

I think I solved the "conflict".

@floooh
Copy link
Owner

floooh commented Jul 4, 2024

You're right, it does sound better. Mainly regular "beeps" like the error beep on the KC85, or the Popcorn bootup sound on the LC-80...

I'll merge and then also update the emulators webpage. Many thanks!

As I said, I'll also look into the aliasing problem (which at least the AY emulation still suffers from ... maybe it's actually a similar problem...).

@floooh floooh merged commit 3dee6d2 into floooh:master Jul 4, 2024
4 checks passed
@floooh
Copy link
Owner

floooh commented Jul 4, 2024

...and merged :)

@floooh
Copy link
Owner

floooh commented Jul 4, 2024

Ok, the webpage at https://floooh.github.io/tiny8bit/ will be updated when this CI pipeline finishes: https://github.com/floooh/chips-test/actions/runs/9796642006

@leiradel
Copy link
Contributor Author

leiradel commented Jul 4, 2024

You're right, it does sound better

Awesome! Again, credits go to MartianGirl, author of SpecIde.

@leiradel
Copy link
Contributor Author

leiradel commented Jul 4, 2024

Just to make it clear, I didn't look into her source code, which is GPL (though maybe it would be considered fair?), but she explained it to me and I changed beeper.h based on the explanation.

@floooh
Copy link
Owner

floooh commented Jul 4, 2024

Good point, but IMHO that should be totally fine.

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

Successfully merging this pull request may close these issues.

2 participants