-1

I just want to know if in Javascript we have a function similar to Matlab ("sound") to play a sound from an array? The input of the function will be a vector. Thanks for your help and time.

Mido
  • 1
  • 2
  • 1
    There's the HTML 5 ` – Max Sorin Mar 16 '16 at 13:33
  • does this help: http://stackoverflow.com/questions/18244692/how-to-play-base64-audio-data-on-firefox-with-using-html5 – Max Sorin Mar 16 '16 at 14:22
  • I need a function in javascript to convert the vector of signals to sound, similar to the "sound" function in Matlab. – Mido Mar 16 '16 at 14:43
  • 1
    Pretend, for a second, that not everyone here has Metlab experience, or wants to do research on how Metlab makes "sound" work to answer your question. Describe for these lazy people what it is you want your code to do. – Max Sorin Mar 16 '16 at 14:48
  • This is the result of google when you type `convert the vector of signals to sound` http://stackoverflow.com/questions/23244100/convert-wave-file-into-vectors-in-android – Max Sorin Mar 16 '16 at 14:51

1 Answers1

0

It's easy, just get your audio element and call the play() method:

This site uncovers some of the other cool things you can do such as load(), pause(), and a few other properties of the audio element.

<audio id="audiotag1" src="audio/flute_c_long_01.wav" preload="auto"></audio>
<a href="javascript:play_single_sound();">Play 5-sec sound on single channel</a>
<script type="text/javascript">
    function play_single_sound() {
        document.getElementById('audiotag1').play();
    }
</script>
Bishoy Bisahi
  • 377
  • 1
  • 11