CMSC 246 Systems Programming
Fall 2019


Assignment #7: : Function pointers to Music
Due: November 10: 11:59 PM

In this assignment you will be working with an excerpt from the Million Song Dataset, a freely-available collection of audio features and metadata for a million contemporary popular music tracks. The file that you will be working with (/home/gtowell/Public246/a7/musicsampleCSV.csv) contains many records. (There is also a smaller file /home/gtowell/Public246/a7/musicsampleminiCSV.csv that might be easier to use during development.) Each record in musicsampleCSV.csv contains the following information for a recorded song, in comma-separated fields:

title: song title
artist name: name of artist 
duration: duration of the track in seconds
release: album name from which the track was taken
start_of_fade_out: start time of the fade out, in seconds, at the end of the song
tempo: tempo in BPM according to The Echo Nest
terms: terms describing the song genre according to The Echo Nest
year: year recorded
Example: Never Gonna Give You Up,Rick Astley,211.69587,Big Tunes - Back 2 The 80s,198.536,113.359,dance pop,1987

The data has been "cleaned" so that there are entries of the correct type for each field in each record. There are also no extra commas; the only commas are field separators. However, there may be incorrect data in some fields; sorry. Use appropriate data types for each field. Note that some of the name, artist, or release string values are very long so in your reader function, you will want something like:

	#define LONGLINE 4096
	FILE* f = ...
	char line[LONGLINE];
	while (fgets(line, LONGLINE, f)) 
	{ ... }

Requirements

  1. Everything that you store should be dynamically sized and allocated. It is OK -- even expected -- that you will re-use your ArrayList from the previous assignment. By everything I mean every char array in the program other that ones for reading from a file (as above) or directly related to user input should be no bigger than it needs to be. Your ArrayList can have some unused space; there should be no other wasted space in your data storage
  2. The program, on user selection, must be able to present the top N music items according the to the user selected sort order and user specified value of N
  3. The program must use qsort to sort and be able to sort on any data field
  4. The program must, on user selection, be able to search for a match to a search criteria. The match should be an exact match.
  5. The program must use a single binary search function for all searches.
  6. Binary search must do comparisons using a passed in comparison function (rather than a big switch statement).
  7. The comparison function used by binary search must be the same as the one used by qsort (for search / sort of the same field). You will almost certainly need one comparison function for every data field.
  8. The program must interact with the user in a style similar to the one shown below. The program need not exactly match (my approach could certainly be improved) but you must follow the spirit of the trace below
  9. When searching, you need only find one item -- assuming one item exists. There may be more than one item. You are only required to find one.
  10. When searching, for 3 points of extra credit, find all matches. You must still use binary search to find the first match
  11. The program must be split into multiple files. The split must make sense from an object-oriented viewpoint. That is imagine the program consists of a set of classes and a driver function. .c files implement classes. .h files are the public methods of the classes. Try to achieve standard OO goals; abstraction, encapsulations, modularity, etc. (Private data members are certainly unachievable, but other forms of encapsulation can be used.)
  12. You must include a makefile capable of building your program
  13. While finishing, the program must free up all dynamically allocated memory. (use valgrind)

Sample User Interaction

In the sample below, input from the user is indicated by lines starting with "****".
Sort by:  1: Title
       :  2: Artist
       :  3: Duration
       :  4: Album
       :  5: Fade Start
       :  6: Tempo
       :  7: Terms
       :  8: Year
         99 -- quit
****2
How many items should do you want to see?
         <0 show all:
        ==0 search for a particular record
****3
2007 ALB:Myth Takes                      ART:!!!                             LEN: 144.0
1995 ALB:The Man                         ART:"Clarence ""Gatemouth"" Brown"  LEN: 333.4
1976 ALB:Fill It! - I Love the Fifties   ART:"Dave ""Baby"" Cortez"          LEN: 125.6
Sort by:  1: Title
       :  2: Artist
       :  3: Duration
       :  4: Album
       :  5: Fade Start
       :  6: Tempo
       :  7: Terms
       :  8: Year
         99 -- quit
****4
How many items should do you want to see?
         <0 show all:
        ==0 search for a particular record
****3
1996 ALB:"Blues Singer 1929-1931 ""Booger Rooger Saturday Nite"  ART:Gene Autry                      LEN: 163.5
1967 ALB:"Trilha Sonora Do Filme ""Garota De Ipanema"  ART:Orquestra                       LEN:  87.6
1983 ALB:#8                              ART:J.J. Cale                       LEN: 160.6
Sort by:  1: Title
       :  2: Artist
       :  3: Duration
       :  4: Album
       :  5: Fade Start
       :  6: Tempo
       :  7: Terms
       :  8: Year
         99 -- quit
****2
How many items should do you want to see?
         <0 show all:
        ==0 search for a particular record
****0
Find A record what: 
****Devo
1993 ALB:Q: Are We Not Men?  A: We Are Devo / Devo Live  ART:Devo                            LEN: 175.3
Sort by:  1: Title
       :  2: Artist
       :  3: Duration
       :  4: Album
       :  5: Fade Start
       :  6: Tempo
       :  7: Terms
       :  8: Year
         99 -- quit
****99
	

What to submit:

How to submit

  1. Do not use the submit script
  2. Use tar to create an compressed archive of your submission. Name the tar file something clever like YOURLOGIN_qwe_7.tar.gz where "qwe" is a set of three "secret characters".
  3. Copy your tar file to /home/gtowell/submissions/fall2019/cs246/project7. Only I can get a directory listing of this directory so the three secret characters keeps other students from accidentally overwriting (before you get permission set as below), or reading, your work.
  4. Set permissions on your submission so that anyone can read but only you can write to the file. That way no one can accidentally overwrite your submission. If you do not allow anyone to read then I will not be able to read. This will result in a poor grade for the assignment (think zero).