DEV Community

Cover image for Playing with a sine wave
Matt Ellen-Tsivintzeli
Matt Ellen-Tsivintzeli

Posted on

4 2

Playing with a sine wave

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.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs