Notice: Undefined index: action in /home2/armanpow/ on line 2
Javascript Sound - Programming Codex

Javascript Sound

  • I use the ‘audio’ tag if it has a ‘play’ function defined otherwise I use a ‘bgsound’ tag which works for old versions of Internet Explorer. With the second method you can only play one sound at a time. There are great plans for sound with Javascript but they don’t work in all browsers.
  • I store how long each sound takes within my program, but these details take up a lot of space.
  • Playing sounds can slow down your browser: for example, my animation using Javascript pauses a little.
  • Stopping a sound by setting the ‘src’ attribute to an empty string sounds abrupt It does not sound like someone interrupting.
  • I use the free ‘SoX’ (Sound eXchange) program. If you build it yourself you can convert sounds to ‘MP3’ format with the ‘LAME’ (LAME Ain’t an MP3 Encoder) and ‘MAD’ (MPEG audio decoder library) libraries. I needed the Ogg Vorbis libraries too. I use the ‘soxi’ program that comes with SoX to find out how long a sound takes. I use the Linux ‘paste’ and ‘cut’ tools a lot when working with big lists of ‘sox’ or ‘soxi’ commands.
  • I used the ‘pitch’ effect in ‘SoX’ to get a female voice and the ‘echo’ effect to sound like being in hall. But these effects can reduce the clarity of the voice.
  • I should have used the ‘normalise’ function of my sound editor. This scales up the sound until the loudest part is the maximum. But this won’t work if there are a few large peaks of sound.
  • Recording sounds can take a long time. I can record about 50 phrases per hour. I have over 10,000 sound files. The files need a lot of space: about 250 megabytes.
  • I find it best to record whole phrases rather playing individual words which does not sound natural. But I sometimes have many different variations of a sentence so I split the sentence into a few
    parts and it sounds fine.
  • I had a problem with the different emphasis when saying ’22?’ rather than ’22’.
  • It is best to speak loudly and have your microphone some distance away from you. I speak quietly so hold the microphone by my chin. I get distortion if the microphone is too close to my mouth.
  • I sometimes get rid of distortion by just cutting out the peaks of sound with my sound editor. I sometimes use the editor to reduce the silence between words.
  • My sound files are named after the phrase they contain so I shorten long names by taking the first letter of the words at the end.
  • I put my sound files in directories named after the first letter of the phrase. A better way might be to calculate a hash value from the letters in each phrase as I have lots of phrases that start with the same word like ‘because’.
  • To reduce the size, I have separate archives of ‘MP3’ files for the Internet Explorer and Safari browsers and ‘Ogg’ files for Firefox, Opera and Chrome. MP3 and Ogg files are compressed already.
  • Only a few people download the sounds for my program. The files are large. Experts say people do not like sound on web pages.
  • I forgot to plan for a sore throat, neighbours drilling and aircraft noise!

Source by Bert Beckwith

Leave a Reply

Your email address will not be published.