32

I'm looking for the smallest type of audio file for some javascript to work smoother.

4
  • 2
    Size is hardly the only factor for smoothness. Jan 14, 2012 at 1:17
  • 1
    A 0-byte file is the smallest audio file you could possibly fine
    – Marc B
    Jan 14, 2012 at 1:34
  • @IgnacioVazquez-Abrams Can you expand on that? Audio size has been my suspicion and hypothesis for smooth javascript as of now.
    – Tony
    Jan 14, 2012 at 1:35
  • I am thinking you should also consider preloading your audio before running your script to improve performance. stackoverflow.com/questions/5313646/… Nov 2, 2012 at 15:27

5 Answers 5

30

Of those three, Ogg would usually be smaller than MP3. Both would be much smaller than the uncompressed WAV. Of course, there may be other factors that come into play for your site such as quality (not too much of a noticeable difference for most purposes) and browser support for each type.

The file size will only affect the time it takes to download the file to the user's machine. It won't necessarily determine Javascript execution speed. There may be other things in your code causing the performance drops (unless you've narrowed it down to the file size of the audio files).

1
  • That's my conclusion after comparing two files where one had a large audio file. Before removal of audio, javascript was executing extremely and caused my computer to overhead. After removal, javascript ran just perfectly without overheating my computer.
    – Tony
    Jan 14, 2012 at 1:38
12

2019: mp3 is your friend.

Type  | Compression  | Browser Support | Quality                | Size
---------------------------------------------------------------------------
MP3   | Compressed   | Great           | Depends on compression | Small
OGG   | Compressed   | Not so good     | Depends on compression | Smallest
WAV   | Uncompressed | Good            | Best                   | Large

mp3

ogg

wav

Browser support: mp3, ogg, wav

2
  • can any one give me smallest mp3 file? Apr 7, 2020 at 5:37
  • Apple and Microsoft don't want competition so of course they didn't support open source codecs and thus those browsers simply don't support the HTML5 audio and video elements.
    – John
    Aug 12, 2022 at 1:10
7

Wav files can be 16 bit,8 kHz (i.e 128 k bits per second) while mp3 could be compressed to 16 kbits per second. Typically wav is x10 larger than mpg. This is ratio is highly content specific. Wav is a raw format, while mp3 is a compressed format for audio. ogg is more of wrapper format. it can wrap Speex compressed audio, Speex (www speex org)is a very efficient compression technique based on CELP.

Tips – use audacity (audacity source forge net) to truncate and save the original with smallest size ( 8 kHz 16 bit formatting if possible) convert this output into mp3. Keeping audio in a common format (mp3/wav)is a good idea.

1
  • 1
    indeed, and Vorbis I is a forward-adaptive monolithic transform codec based on the modified discrete cosine transform (MDCT).[36] Vorbis uses the modified discrete cosine transform for converting sound data from the time domain to the frequency domain. The resulting frequency-domain data is broken into noise floor and residue components, and then quantized and entropy coded using a codebook-based vector quantization algorithm. Xiph.Org now considers Speex obsolete; its successor is the more modern Opus codec, which surpasses its performance in all areas. Opus data can be encapsulated in Ogg. Dec 13, 2014 at 4:11
4

WAV files are very large, and ogg is regrettably not supported universally, so MP3 is probably your best bet. if you want to make sure the file downloads as quickly as possible, you should take a look at the compression options you're using. If you don't have access to compression options, try downloading an audio editing program like Audacity. Open up the file and then re-export it as an MP3. Try saving the sound file with a relatively low bitrate (128k, 64k, or even less) and see if the playback quality is still acceptable.

2
0

IMHO - 48kb/s MP3

The best answer might be a balance between

  1. size of file ( kind on bandwidth to the user )

  2. how expensive it is to run ( better for lower powered machines )

  3. quality ( how it is perceived by the user )

I suspect in your case, because you are concerned about other code running, you want the format that uses up the least processing power.

The 2 variables at play here are bit rate and bit depth, however mp3 doesnt really take bit depth into account.

Here's what I understand to be true:

  1. The most widely used/known audio format is mp3
  2. Even though the possible audio spectrum is 20 - 20,000Hz, most people can't really hear above 13,000Hz
  3. Choosing a lower bit rate (playback) means the computer will not have to work as hard to playback (decode)

So my recommendation for general purpose sound would be to choose mp3 and a lower bit rate 48 kbs.

Not that it will make a lot of difference, most websites are accessed via phones that are mono anyway. Mono WAV files take up less space than stereo and lower bit depths take up less. Also Audacity is a software that can convert between audio types.

My professional view as a sound engineer is that mastering audio properly gives the best results, but that's another topic in another forum.

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