JohnEarnest / Octo

A Chip8 IDE
MIT License
664 stars 53 forks source link

Low-pass filtering / audio output super-sampling / anti-aliasing #142

Closed Kouzeru closed 2 years ago

Kouzeru commented 3 years ago

It's an attempt to remove dread aliasing by implementing some sort of low-pass filtering...

I... don't know if this should be applied (since it may overcomplicate the code a bit), but the results are significant.

Without low-pass filtering: https://johnearnest.github.io/Octo/index.html?key=DJRtrTsh With low-pass filtering: https://kouzeru.github.io/Octo/index.html?key=DJRtrTsh

The implementation of it is two-poles lowpass filtering, which is easy ones to achieve.


And by the way, regarding the audio editor interface, honestly, I still need these buffer blending features, and also the alterable pulse-width (cut-offs).

JohnEarnest commented 3 years ago

Hmm. I'll need some time to think about it and study the technique.

Adding a configurable pulse-width to the revised audio editor wouldn't be too hard- I can play with that. I wasn't under the impression anyone actually used the buffer-blending stuff! Maybe there's a clearer/easier to use design that could reintroduce the functionality you use.

Kouzeru commented 3 years ago

Alrighty. I'm putting some of oscilloscope view here demonstrating the both filter and nonfiltered output from the program:

No filter:

https://user-images.githubusercontent.com/46141631/133367307-87fecb5b-e1a9-4276-a5c2-7998d2530044.mp4

With two-order low-pass filtering:

https://user-images.githubusercontent.com/46141631/133367282-978c9c36-983e-4e38-81cb-39ea23572288.mp4


I'm actually seeing lot of potentials from the buffer-blending stuff though, there I could generate various amount of buffers with these bitwise operations. And the oscillator generator is also important having the amount of pulse-cycles other than power of 2. With the blending, I could also create some pulse-interleaving stuff with some AND and OR there, to pack multiple melodies into a single audio-buffer creating pseudo chords. [e.g. combining 2:1 to create octave; 3:2 for perfect-fifth; 4:3 for fourth; 5:4 for third; etc]

and maybe my point here is to keep the blending feature while revising the audio editor, and it's 8 years its been there; removing them would make me feel like, ashamed anyhow, here's how im using it:

https://user-images.githubusercontent.com/46141631/133437760-929e4a59-87fe-4e03-abaf-92306beee3f2.mp4

Kouzeru commented 3 years ago

My last changes here is making the lowpass almost unnoticable, preserving the lovely treble while eliminating the aliasing. I did brute force to get the best results of the given parameters of the lowpass algorithm that being used with analizations, while considering the performance, for the balance.

Theres the comparisons of the both again, which is with and without some anti-aliasing stuff.

Kouzeru commented 3 years ago

I'm considering there's something I want to add into the current audio editor interface, such as piano keys that allows the users to play the pattern by simply clicking the piano keys, and which is gives pitch value of the key being played.

There's also few of corrections of the audio blending and the tone generator to maximize its intuitiveness.

That'd be another PR...