tags:

views:

79

answers:

4

I would like to add an unusual feature to a website that would allow the user to play a sound...a single sampled note. When the user moves a slider control the sound would go up or down in tone (seamlessly). So, as the user slides the button to the right the sound would rise in pitch, when moved to the left it would go down in pitch (from soprano to bass). Does anyone know how this could be achieved? What sort of sound file would you use and how would you get it to play continuously (when a button was pressed) and change pitch (when the slider was moved)? This isnt really language specific - it could be php or flex. Thanks in advance. Simon...

=============================================== Further information

It appears that the best solution might involve something like C or C# or C++. Unfortunately, I have very little experience of these languages. Would anyone be able to tell me whether it is possible to achieve this in C? Thanks.

A: 

You will need a client-side plugin to make this work in a browser, Silverlight, Flex, or Flash will most likely be your best/only option.

On a website, with limited access to hardware, what you want to do will be hard, if not impossible. Your best bet is to have many audio files (for each note/pitch you want) and have the slide control play a different file.

You may want to use a queue and an array of different audio files.

If the next item from the queue is different than the first, play it, if the queue is empty, keep playing the last file. Then in the "slider" event you'll queue the next file.

If you were running a native application, you would have more control over the sound hardware, and could likely create this effect without having an mp3 for each note/pitch you want to play.

Nate Bross
Thanks for the ideas...I am not absolutely wedded to the idea of any particular technical solution.Could you tell me what you mean by "native application". I dont think that the idea of having a separate sound for each note would work (since the sound needs to glide through the pitches), and so if there is a solution in a different language then that would be great.Thanks again,Simon...
swiltshire
When I said a native application, I meant an exe file that the user would run locally. C++, C#, Java, etc, something with direct access to the Windows API and the hardware.
Nate Bross
A: 

Hi,

To achieve what you want you need specific audio manipulation tools, that most web-apps do not have access to. I suggest you take a look at Flex and Alchemy. Alchemy allows you to call c or c++ which can allow you to use different c filters for transforming the sound.

I know it is not impossible... just not so easy to do :) Good luck.


Adrian

Adrian Pirvulescu
+2  A: 

There are these guys "Sonoflash" who are doing very interesting things with generated audio in pure ActionScript3 - in other words, no external sound file necessary.

Here's a link to an interview that Adobe Platform Evangelist Ryan Stewart did with them. I suspect that you'll be able to get what you need using this AS3 library.

http://blog.digitalbackcountry.com/2009/09/sonoflash-easily-add-sound-to-your-flash-apps/

Myk
+1 This is very close to what I was thinking you could do with a native application, I didn't realize that its now currently possible with Flash10.
Nate Bross
A: 

There is definately not a PHP solution, other than echoing HTML to call the client-side routine.

Sure you could use Flash, or Flex.. but have you tried JavaScript mouse events?

for example:

<img src="buttonImageFilename"
onMouseDown="handlePress();return true;" 
onMouseUp="handleRelease();return true;" 
onMouseOut="handleRelease();return true;" 
onClick="return false;"
>

Honestly, it bugs me whenever Flash gets thrown around as first solution since an environment object wrapper is normally needed to render it. (have you seen the issues with Flash10 and CPU hogging??)

Many times for simple things JavaScript works just fine.

Talvi Watia
In regards to the C#/C++ requirements - what exactly does this have to do with working on a webpage? Are you trying to build a widget on a webpage or a stand-alone application? Many languages emulate the C syntax, but specifically C is used for applications normally, not webpages.
Talvi Watia