A few notes based on my experiments the past couple of days.
First, when you manage to generate a sine wave, you’ll notice there’s a “clicking” sound at the end. Where does it come from and how to deal with it? I think it comes from having the volume suddenly drop to 0. So to make it go away, you gotta make the wave form fade away slowly and gradually.
The graph of e^(-2x)
looks like a good smooth path for that.
Second, you’ll notes that high frequencies sound way louder than low frequencies. To work around that, multiply the samples by 1/freq
(see: pink noise). This makes each tone sound the same loudness. (In reality you use a multiple of 1/freq
, for for instance, I used 100/freq
.
I realize this is way out of context and perhaps won’t make sense to most people. I’ll talk more about generating sound waves later. But I wanted to jot down these quick notes before I forget.