Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I would like to generate a single continuous tone (eg. a sine wave) from a web page with the ability to interactively control the following:

  • start/stop sound
  • change pitch
  • change volume

I'm after a solution that is reasonably likely to work on a wide variety of hardware, browsers and connections; something as simple and low-bandwidth as possible.

The only method that seems to work reliably across the hardware I have access to is Flash, but I'd really like to avoid a proprietary solution and create something with open-source software that conforms to open standards.

Is this possible?

If so, how?

share|improve this question
add comment

2 Answers 2

You could try using the <audio> tag and loop it using the onendedattribute. I'm not sure about the cross-platform compatibility of this solution, but it has to be better than Flash, which won't work on the iPad, iPhone or many other mobile devices.

Then you just need a server-side script to generate small audio clips of a particular frequency. I.e. you'd point the src of the audio tag to:

/generate_tone?freq={the frequency you want}
share|improve this answer
add comment

Java is an alternative. There's a development environment called Processing that was created to abstract Java and make it easier for artists and regular folks to program graphics and multimedia.

You can output programs as applets (or cross platform applications).

If having an applet on your website is ok, then this is a good way to go.

Here's their example of generating a sine wave tone using an audio library.

share|improve this answer
    
Do mobile browsers support Java applets? –  Lèse majesté Oct 22 '10 at 4:04
1  
@Lèse - we've been investigating browser-based java applets on mobile devices lately and the general answer is a resounding no - not even Android supports them. –  Mark Henderson Oct 22 '10 at 4:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.