DEV Community

loading...
Cover image for Playing with a sine wave

Playing with a sine wave

mellen profile image Matt Ellen ・1 min read

I was inspired to make a this toy project by a question on Stack Overflow asking about generating sine waves.

You can adjust the frequency, amplitude and phase of the wave. The chart spans two seconds. Frequency can be set between 1 and 100Hz, mostly because anything above 100hz becomes indistinguishable at this resolution. Amplitude can be set between 0 and 1. Phase can be set between 0 and 2π (well kinda, javascript maths being what it is).

There is a validation error that pops up on the phase slider, due to ieee floating point rounding and me wanting the slider to move in steps of π/100. I'm not sure the best way to get rid of that.

Discussion (0)

pic
Editor guide