Skip to content

Matlab implementation of Shazam-linke hashing algorithm and db search.

Notifications You must be signed in to change notification settings

LNSD/ShazamMatlab

Repository files navigation

ShazamMatlab

Matlab implementation of music hashing and track db matching algorithm. Requires a recent Matlab version to run, due the use of Matlab's audioread() function. I used Matlab's 2013a version to write down the program.

Project structure

  • Target folder: Place here the tracklist that will form the tracks DB.

    • hashes.mat: Matlab file that stores the DB. Is generated by Matlab after executing add_tracks() function.
  • Query folder: Place here the track snippets. Then use match_query() function to find them in the DB. Requires a previously created DB.

  • add_tracks.m: The add_tracks() function generates and stores the database from a tracklist stored in a folder.

  • create_database.m: This file contains the create_database() function. This function, if doesn't exists, creates the hashes database file. If it exists, loads the variables to the Matlab environment.

  • find_landmarks.m: Contains the find_landmarks() function. Extracts all the landmarks from a track.

  • landmark2hash.m: The landmark2hash() function converts the landmark info into a 20 bits code.

  • record_hashes.m: Contains the record_hashes() function. It stores the hash in a map container. With the hash as key, the TrackID and hash time as values.

  • match_query.m: This function is called to find if a track fragment matches with a track stored in the database previously created with add_tracks() function.

  • get_hash_hits.m: get_hash_hits() function, is called by match_query(), and returns to this function all the matches for a hash calculated from a recording fragment.

  • show_landmarks.m: This function was added for debugging purpose. It draws the spectrogram of a signal and all its landmarks, as can be seen in the following screenshot:

Running procedure

Create tracks hashes database

  1. Add your list of audio files that will form your track's database to Target folder.
  2. Run add_tracks() function: >> add_tracks('Target'). This will create your own hashes.mat file inside Target.

Track fragment matching

  1. Add yout audio snippets to Query folder. I recomend, but it is not mandatory.
  2. Run match_query() function: >> match_query('Query/audio_fragment.mp3', 'Target/hashes.mat') where the first function's argument is the path to our audio fragment and the second argument is the DB file created before.

About

Matlab implementation of Shazam-linke hashing algorithm and db search.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published