Skip to content

Fix crackling in audio #282

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

Open
torch2424 opened this issue Apr 24, 2019 · 2 comments
Open

Fix crackling in audio #282

torch2424 opened this issue Apr 24, 2019 · 2 comments
Assignees
Labels
bug Something isn't working Core/Wasm Issues concerning the core library of Wasmboy Lib / JS Issues concerning the JS API of WasmBoy

Comments

@torch2424
Copy link
Owner

Quite a strange thing I noticed. It's kind of hard to notice, but I got the music ear so it bugs me haha!

Anyways, seems like there is some popping/crackling on the square waves.

So usually cracking happens from drops in the signal, thus, incorrect PCM samples. But I did the following screenshot last night:

Screen Shot 2019-04-23 at 1 54 48 AM

So I know it's not the square wave, but you would hear it. And what I am trying to show is that there is no crazy spikes, and it's just binary (high / low) values. Thus crackling doesn't make sense.

One theory is I need to smooth the wave, and not instantly drop for the square waves and things. Which when I made a Jsfiddle (and accidentally closed the tab and lost it), the built in oscillator does a very slight diagnonal from high/low.

But a PR linked below, I simply changed the sample rate to match Elmboy, and things still crackled, but slightly less pronounced. So I may either be going crazy, or possibly it is an issue with an uneven sample rate vs. how often we produce samples.

@torch2424 torch2424 added bug Something isn't working Core/Wasm Issues concerning the core library of Wasmboy Lib / JS Issues concerning the JS API of WasmBoy labels Apr 24, 2019
@torch2424 torch2424 self-assigned this Apr 24, 2019
@torch2424
Copy link
Owner Author

torch2424 commented Feb 4, 2020

So this mostly bugs me, as I want to sample using the audio recorder for music I want to make 😂

Did some more random late night research. Audacity has a nice sample data export, which just exports the levels of each PCM Sample like:

0.00000
0.00000
0.00000
0.10077
0.10077
0.10077
0.10077

Doing a quick scan, there is not a single sample for a square wave that is not either 0 0r 0.10777. Thus the wave is correct. but let's write a node script that will go and make sure everything length is the same. E.g something like:

0: 27 in a row
0.10077: 27 in a row
0: 27 in a row
0.10077: 27 in a row

Because I bet if the sample lenghts aren't the exact same. Maybe that causes the crackling? 🤔 Which would kind of make sense, since as we stated before, the sample rate seems to affect this...

@torch2424
Copy link
Owner Author

Maybe it's because we need a gain node? https://7tonshark.com/2018-09-16-web-audio-part-1/#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Core/Wasm Issues concerning the core library of Wasmboy Lib / JS Issues concerning the JS API of WasmBoy
Projects
None yet
Development

No branches or pull requests

1 participant