Subscribe Subscribe via: (Email/RSS)

Song Capacity Calculator for MP3 Players

Filed under Podcasting

MP3 PlayerIf you’re considering buying an MP3 player, or are just wondering how much of your music collection will fit on to one, then this little utility could be just what you’re looking for.

The memory, or storage capacity, of an MP3 player is usually measured in GB (Giga Bytes), or MB (Mega Bytes) for the smaller/older players. However, the number of songs that your MP3 player can potentially store is not only determined by its memory capacity, but also by the bit rate of your MP3 tracks.

If you’re not sure of what a bit rate is, or what it has to do with things, then the previous article on What are bit rates? may help explain things for you.

If you’ve already got a collection of music in MP3 format (or one of the other popular music compression formats such as WMA or AAC), then your bit rates have already been set. However, when you’re converting your music from CD to MP3 (ripping as it’s called), you should be able to choose the bit rate most suitable to your requirements from within your chosen conversion software. 128 kbps is usually a good starting point as a compromise between sound quality and storage requirements.

MP3 Song Capacity Calculator

MP3 Song Capacity Calculator
45 mins/album
3:30 mins/song

Assumptions

The MP3 Song Capacity Calculator makes a few assumptions for its calculations. As such the quoted results are only approximations and may vary from actual results. The key assumptions are:

  • Average album length is 45 minutes
  • Average song length is 3 minutes 30 seconds
  • All MP3 track data is 100% audio
  • All of the MP3 player’s memory can be utilised

If you’d like to use this calculator on your own website, please feel free to do so. All I ask is that you put a link next to the calculator crediting me and linking back to this web page.

The JavaScript for this and the following storage capacity calculator is:

   1: // Define average album/song length and artwork size

   2: var SECONDS_PER_ALBUM    = 2700;  // in seconds = 45 mins

   3: var SECONDS_PER_SONG     = 210;   // in seconds = 3:30 mins

   4: var ALBUM_COVER_STORAGE  = 51200; // in bytes = 50kB in bytes

   5:

   6:

   7: // MP3 song space calculation

   8: function CalcSongs()

   9: {

  10:     // Get key variables from HTML form

  11:     intMemory  = document.getElementById("memory").value;

  12:     intBitrate = document.getElementById("bitrate").value;

  13:

  14:     // Calculate total time available in seconds for given memory and bitrate

  15:     intTotalTime = (intMemory * 8) / intBitrate;

  16:

  17:     // Convert total time in seconds to hours and minutes

  18:     intHours = Math.floor(intTotalTime / 3600);

  19:     intMins = Math.floor((intTotalTime - (intHours * 3600)) / 60);

  20:

  21:     // Estimate how many songs and albums can be stored

  22:     intAlbums = (intTotalTime / SECONDS_PER_ALBUM);

  23:     intSongs = Math.floor(intTotalTime / SECONDS_PER_SONG);

  24:

  25:     // Show results on web page in allocated fields

  26:     document.getElementById("hours").value  = intHours + ':' + intMins;

  27:     document.getElementById("albums").value = intAlbums.toFixed(1);

  28:     document.getElementById("songs").value  = intSongs;

  29: }

  30:

  31:

  32: // MP3 storage space calculation

  33: function CalcStorage()

  34: {

  35:     // Get key variables from HTML form

  36:     intAlbums  = document.getElementById("albums2").value;

  37:     intBitrate = document.getElementById("bitrate2").value;

  38:

  39:     // Calculate total time for all albums

  40:     intTotalTime = intAlbums * SECONDS_PER_ALBUM;

  41:

  42:     // Estimate how much storage is required for audio in M

  43:     intStorage = intTotalTime * (intBitrate / 8);

  44:

  45:     // Estimate how much storage is required for one artwork per album

  46:     intArtStorage = intAlbums * ALBUM_COVER_STORAGE;

  47:

  48:     // Estimate total storage

  49:     intStorage = intStorage + intArtStorage;

  50:

  51:     // Work out multplier: k, M, G

  52:     if (intStorage > 1073741823)

  53:         intStorage = Math.floor(intStorage / 1073741824) + 'G';

  54:     else if (intStorage > 1048575)

  55:         intStorage = Math.floor(intStorage / 1048576) + 'M';

  56:     else if (intStorage > 1023)

  57:         intStorage = Math.floor(intStorage / 1024) + 'k';

  58:

  59:     // Show results on web page in allocated fields

  60:     document.getElementById("storage").value  = intStorage + 'B';

  61: }

Download this file: song-calc.js [2.4kB]

MP3 Storage Capacity Calculator

This simple little calculator estimates how much space will be required to store your CD collection on your computer’s hard disc or portable music player based on a given bit rate:

MP3 Storage Capacity Calculator
at 45 mins/album

Assumptions

The above MP3 Storage Capacity Calculator makes a few assumptions for its calculations. As such the results are only approximations. The key assumptions are:

  • Average album length is 45 minutes
  • A single piece of album artwork is added to each album at 50kB

The HTML code for the two calculators is:

   1: <script type="text/javascript" src="song-calc.js"></script>

   2:

   3: <form id="mp3calc" method="post">

   4:     <fieldset>

   5:         <legend>MP3 Song Capacity Calculator</legend>

   6:

   7:         <table border="0" summary="JavaScript MP3 Song Capacity Calculator">

   8:             <tbody>

   9:

  10:                 <tr>

  11:                     <td align="left"><label for="memory"><strong>Player Memory Capacity: </strong></label></td>

  12:

  13:                     <td align="left">

  14:                         <select id="memory" onchange="return CalcSongs();" name="memory">

  15:                             <option value="134217728">128 MB</option>

  16:                             <option value="268435456">256 MB</option>

  17:                             <option value="536870912">512 MB</option>

  18:                             <option value="1073741824">1 GB</option>

  19:                             <option value="2147483648">2 GB</option>

  20:                             <option value="4294967296">4 GB</option>

  21:                             <option value="8589934592">8 GB</option>

  22:                             <option value="17179869184">16 GB</option>

  23:                             <option value="21474836480">20 GB</option>

  24:                             <option value="32212254720">30 GB</option>

  25:                             <option value="34359738368">32 GB</option>

  26:                             <option value="42949672960">40 GB</option>

  27:                             <option value="64424509440">60 GB</option>

  28:                             <option value="85899345920">80 GB</option>

  29:                         </select>

  30:                     </td>

  31:                 </tr>

  32:

  33:                 <tr>

  34:                     <td align="left"><label for="bitrate"><strong>Bit Rate of Songs: </strong></label></td>

  35:                     <td align="left">

  36:                         <select id="bitrate" name="bitrate" onchange="return CalcSongs();">

  37:                             <option value="8000">8 kbps</option>

  38:                             <option value="16000">16 kbps</option>

  39:                             <option value="24000">24 kbps</option>

  40:                             <option value="32000">32 kbps</option>

  41:                             <option value="40000">40 kbps</option>

  42:                             <option value="48000">48 kbps</option>

  43:                             <option value="56000">56 kbps</option>

  44:                             <option value="64000">64 kbps</option>

  45:                             <option value="80000">80 kbps</option>

  46:                             <option value="96000">96 kbps</option>

  47:                             <option value="112000">112 kbps</option>

  48:                             <option selected="selected" value="128000">128 kbps</option>

  49:                             <option value="144000">144 kbps</option>

  50:                             <option value="160000">160 kbps</option>

  51:                             <option value="192000">192 kbps</option>

  52:                             <option value="224000">224 kbps</option>

  53:                             <option value="256000">256 kbps</option>

  54:                             <option value="320000">320 kbps</option>

  55:                         </select>

  56:                     </td>

  57:                 </tr>

  58:

  59:                 <tr>

  60:                     <td align="left"><label for="hours"><strong>Hours of Music: </strong></label></td>

  61:                     <td align="left"><input id="hours" disabled="disabled" name="hours" size="8" type="text" value="2:19" /></td>

  62:                 </tr>

  63:

  64:                 <tr>

  65:                   <td align="left"><label for="albums"><strong>Typical No. Albums: </strong></label></td>

  66:                     <td align="left"><input id="albums" disabled="disabled" name="albums" size="8" type="text" value="3.1" /> 45 mins/album</td>

  67:                 </tr>

  68:

  69:                 <tr>

  70:                     <td align="left"><label for="songs"><strong>Typical No. Songs: </strong></label></td>

  71:                     <td align="left"><input id="songs" disabled="disabled" name="songs" size="8" type="text" value="39" /> 3:30 mins/song</td>

  72:                 </tr>

  73:

  74:             </tbody>

  75:         </table>

  76:     </fieldset>

  77: </form>

  78:

  79: <form id="mp3calc2" method="post">

  80:     <fieldset>

  81:         <legend>MP3 Storage Capacity Calculator</legend>

  82:

  83:         <table border="0" summary="JavaScript MP3 Storage Capacity Calculator">

  84:             <tbody>

  85:

  86:                 <tr>

  87:                     <td align="left"><label for="albums2"><strong>No. Albums: </strong></label></td>

  88:                     <td align="left">

  89:                         <input id="albums2" name="albums2" size="8" type="text" value="100" onchange="return CalcStorage();" /> at 45 mins/album

  90:                     </td>

  91:                 </tr>

  92:

  93:                 <tr>

  94:                     <td align="left"><label for="bitrate2"><strong>Bit Rate of Songs: </strong></label></td>

  95:                     <td align="left">

  96:                         <select id="bitrate2" name="bitrate2" onchange="return CalcStorage();">

  97:                             <option value="8000">8 kbps</option>

  98:                             <option value="16000">16 kbps</option>

  99:                             <option value="24000">24 kbps</option>

 100:                             <option value="32000">32 kbps</option>

 101:                             <option value="40000">40 kbps</option>

 102:                             <option value="48000">48 kbps</option>

 103:                             <option value="56000">56 kbps</option>

 104:                             <option value="64000">64 kbps</option>

 105:                             <option value="80000">80 kbps</option>

 106:                             <option value="96000">96 kbps</option>

 107:                             <option value="112000">112 kbps</option>

 108:                             <option selected="selected" value="128000">128 kbps</option>

 109:                             <option value="144000">144 kbps</option>

 110:                             <option value="160000">160 kbps</option>

 111:                             <option value="192000">192 kbps</option>

 112:                             <option value="224000">224 kbps</option>

 113:                             <option value="256000">256 kbps</option>

 114:                             <option value="320000">320 kbps</option>

 115:                         </select>

 116:                     </td>

 117:                 </tr>

 118:

 119:                 <tr>

 120:                     <td align="left"><label for="storage"><strong>Storage Required: </strong></label></td>

 121:                     <td align="left"><input id="storage" disabled="disabled" name="storage" size="8" type="text" value="4GB" /></td>

 122:                 </tr>

 123:

 124:             </tbody>

 125:         </table>

 126:     </fieldset>

 127: </form>

Download this file: mp3.htm [6.6kB]

 

Posted on 19 April 2008

If you liked this post...

Why not subscribe via RSS or e-mail, it's FREE!

Please feel free to leave a comment.

Related Articles...

7 Responses to “Song Capacity Calculator for MP3 Players”

  1. James says:

    Dear Richard

    Handy page – or so I thought until I noticed the bug…
    Looks like for a given bitrate choice, the same values for Hours of Music: etc are calculated for both 4GB and 8GB capacity. Just a copy/paste typo I think:
    4 GB 8 GB
    in line 133 of your html source.
    The 16GB entry is OK – haven’t checked the rest!
    Nearly put me off the 8GB player I was looking at til I realised that the 16GB looked like 4 times the size!!!

    Cheers, James

  2. Richard says:

    James: Thanks for pointing out the school boy error. Hopefully I’ve fixed it now and it’s back to being a “handy page” again. If you’d like to try it again, let me know if you find any other deliberate mistakes. :-)

  3. Kylie says:

    Hi Richard,
    Great little item you have here, just wondering if i could get the code off you to place on my upcomming website. Happy to have links on it back to your blog =)

  4. hugo says:

    richard, exellent site, clear even to thickies like me, best wishes for a quick recovery
    hugo

  5. Oskar says:

    Great Article!

    If I could write like this I would be well chuffed ;-)

    The more I read articles of such quality as this (which is rare), the more I think there might be a future for the Web. Keep it up, as it were.

  6. Deni says:

    Is the 128 bit rate optimum for audiobooks? Our library system has a lot of MP3 CDs and I”m trying to get by on the less expensive Sansa Clip+.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>