Homework 3, My Playlist
Short Description:
Write a program which will allow a user to manipulate a modified .mu3 formatted
playlist.
This assignment is worth 100 points.
Goals
When you finish this homework, you should:
- Declare and manipulate C++ structures.
- Dynamically allocate and deallocate arrays in C++
Formal Description
Write a program which will assist a user in managing a playlist.
A Playlist is used by music a player (such as xmms) to allow the user to customize which songs will be played, as well as the order in which these songs
will be played. For this program we will work with a modified version of the
.m3u playlist format.
The playlist begins with the directive #EXTM3U. In our modified format, this line will also contain the number of tracks in the file.
Each track in the file is formatted as follows:
- #EXTINF: a marker for the beginning of a track.
- a colon
- The time, in seconds, for the track
- a comma
- The title of the track.
- A new line character
- The path to the track.
- A new line character.
My music management software (mediamonkey) names files in the following format
- Artist Name
- A space, dash, space ( - )
- Track Name.
Furthermore, files are saved in a directory structure with the following format:
- Music
- a slash (/)
- Artist Name
- a slash (/)
- Album Name
- a slash (/)
- File Name
Combining these two bits of information, we can extract, from a playlist generated on my system the following information:
- Artist
- Album Name
- Song Title
- Song Length
- Path to song file
- Filename of song file
Here is an example playlist
Your program should be interactive and allow the user to perform the following
actions to manipulate a playlist in the format described above.
- l filename load a playlist from a file. If a playlist is already in memory it should be destroyed and the memory deallocated.
- w filename write the current playlist to the specified file. If no playlist is in memory no action should be taken.
- p print the current playlist.
- 1 sort the current playlist by title.
- 2 sort the current playlist by artist.
- 3 sort the current playlist by time.
- r randomize the current playlist.
- s songname artistname search for a track title. Print all information about the track if it is found, otherwise print Track not found!.
- d songname artistname delete this track from the list. This should deallocate the current array after copying all tracks (except the deleted track) to a new array.
- a add a track. Query the user for information about the track to be added. This should copy all tracks to a new array and add the new track at the end.
- x delete the current playlist.
- t find the total time for the current playlist.
- q exit the program.
Discussion
I would begin by doing an bottom up design. I would write a set of routines to
read, write, display, compare, and perform other options on a track.
You may NOT write three different sort routines. Modify the sort routine so that it uses different comparisons depending on an input flag.
Use plenty of space in your output. Make sure you tell the user what you are doing at every step.
To randomize an array:
for(i=0; i < arraySize; i ++) {
k = rand() % arraySize;
swap(array, i, k);
}
Required Files
Source code, Makefile, and ReadMe files required to build the project.
Submission
This program in due October 20 at class time. Email a tar file containing
all required files to dbennett@edinboro.edu by that time.