Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

Crackling sound with just a few synths #904

Closed lancejpollard closed 3 years ago

lancejpollard commented 3 years ago

Hi there,

I have put together a quick set of rhythms here. The code is basically this.

Why is each attackAndRelease for the 3 synths not producing the same exact sound every time? Also, why is it crackling? How do I get it to sound nice?

Thanks! Lance

tambien commented 3 years ago

To my ears it sounds like clipping distortion. I would recommend adjusting the volume of your synths to avoid clipping, maybe dropping them all -6db. The synths default to unity gain so playing multiple at once without first lowering the gain will probably cause clipping.

I also noticed you use a bass note of D1, which is roughly 36 hertz. Many speakers (especially small computer speakers) aren't going to be able to produce a 36hz sine tone and will probably distort in that range. I might try adding a hipass to the output or choosing a higher octave.

Here's a simple example of 3 similar synths running dropping the gain -6db: https://codesandbox.io/s/quiet-snowflake-7yxyp?file=/src/index.ts

It still distorts a little on my headphones, but if i change D1 to D2, i get much less distortion.