bjrnt
bjrnt

Reputation: 2822

What's the easiest way to produce an X Hz sound wave in Java?

It would also be great if it was fairly easy to export the wave so that it later can be drawn (visualized using for example Canvas).

To clarify: I want to be able to hear a X Hz wave, and preferably draw it.

Upvotes: 0

Views: 424

Answers (1)

duffymo
duffymo

Reputation: 308733

for (double t = 0.0; t < maxTime; t += dt)
{
  double value = amplitude*sin(2.0*Math.PI*frequency*t);
} 

Put the values out to the wave format or plotting program of your choice.

Upvotes: 1

Related Questions