Program / Task Name:

   MP3 Organizer

Level:

 

 Novice / Advanced

Point Value:

 

 8

 

Task Description

You've decided to join the digital music revolution, and convert all of your CD's to digital media.  You want your music to sound its best by using a high-bitrate MP3 format.   Since you want to take your digital music with you everywhere, you decide to write a program to tell you how many MP3CD's (a 650MB CD-ROM full of MP3 song files) it will take to hold the collection once it has been converted.

Using a list of CD's and MP3's, calculate the number of MP3CD's required to hold your entire collection, using a given target bitrate.  Your supported bitrates (used as keywords in the input file) are:

            MP3-128           =  128 kilobit/second MP3
            MP3-160           =  160 kilobit/second MP3
            MP3-192           =  192 kilobit/second MP3
            MP3-256           =  256 kilobit/second MP3
            MP3-320           =  320 kilobit/second MP3
            FLAC    =  700 kilobit/second Lossless (assumes a 2:1 compression from CD Audio)
            CD       = 1411 kilobit/second CD Audio (WAV file)

For example, a 10 second CD Audio clip (WAV) uses 1.764MB of disk space (note that for our purposes, 1MB = 1000 kilobytes).

Program Input

The first line of the input file (prob08.in) contains the target bitrate (format) for encoding.  Each line that follows will contain four fields about each CD or MP3 album in your collection, in the following format:

            <artist name>, <album name>, <album length in minutes:seconds>, <format>

Sample Input file:

TARGET_BITRATE=MP3-256
Duran Duran, Rio, 45:44, CD
Flock of Seagulls, One Hit Wonder, 39:10, CD
Orbital, Orbital 2, 54:33, MP3-192
Beethoven, 9th Symphony, 73:52, CD
Britney Spears, Blah Blah Blah, 33:33, 128
Metallica, Please Give Us Money, 46:58, MP3-256
The Barking Dogs, A Barking Dog Christmas, 68:04, CD

Note that if a particular album is already encoded at a lower bitrate than the target bitrate, you will just store the album as is, because converting it to a higher-rate format would be a waste of disk space.  For example, Britney Spears' "Blah Blah Blah" is shown as being in the MP3-128 format, and the target bitrate is MP3-256, so that album would just be stored as an MP3-128.  But the Matrix Reloaded Soundtrack is in the CD format, and therefore would be encoded in the MP3-256 format.

Program Output

Your output must be written to a file (prob08.out) and contain an album listing for each MP3CD, with a header that includes the CD number (start at #1) separating each MP3CD.  The album listing must show the artist, album name, time, and file size in megabytes (in whole MB, round up).  And finally, the total amount of space used on the MP3CD must be shown (in whole MB, round up).

To calculate the number of MP3 CD's correctly, fill each MP3CD in the order the albums are shown in the input file.  If there isn't enough space left to hold the next album, start on the next CD.

Sample output file:

MP3 CD #1
-------------------
Duran Duran, Rio, 45:44, 88MB
Flock of Seagulls, One Hit Wonder, 39:10, 76MB
Orbital, Orbital 2, 54:33, 79MB
Beethoven, 9th Symphony, 73:52, 142MB
Britney Spears, Blah Blah Blah, 33:33, 33MB
Metallica, Please Give Us Money, 46:58, 91MB
The Barking Dogs, A Barking Dog Christmas, 68:04, 131MB

Total: 637MB

 

 

   
  (c) 2004 Hewlett-Packard Company