DiscID search with libmusicbrainz5

Hello Everyone.
Now let us see how to search the MusicBrainz Database using DiscID. “discid” is one of the non-core entities in MusicBrainz but still it is very important. DiscID for any Compact Disc is generated with the help of libdiscid. This discid will be searched using libmusicbrainz5 to get the metadata associated with the discid. Here’s the code for this tutorial.

Using libdiscid is simple. Here’s the API Reference of libdiscid.

Functions which are of prime importance here are
1.  DiscId* discid_new();
This function creates a new object of DiscId.
2.  char * discid_get_default_device (void)
This function returns the default device to be used by libdiscid.
3.  int discid_read(DiscId* d,const char* device)
This function reads the disc inserted into the device. If device is NULL, then default device is used. It returns true (value greater than 0)  if successful or false(0) if not.
4.  char * discid_get_id (DiscId *d)
This function returns the discid of the disc referred by d.
The above functions are used as in the code to determine the discid and use it to search.
You should pass, “discid” and discid in mb5_query_query() function as shown in the code.
Everything else is same. Try on your own 🙂


2 thoughts on “DiscID search with libmusicbrainz5

  1. Nice tutorial.

    You should probably use “discid_free(disc);” somewhere in your example.

    I find it a bit weird that dropbox is used to host these code snippets. I’d recommend gist or even a github repository for your examples.

  2. Oh!! Yes yes, I forgot that thanks for pointing the mistake.
    I will host a github repository for the examples. That I will do shortly.
    Thanks for your valuable comments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s