Home User Forums SongKong Music Tagger Jaikoz Music Tagger Albunack Music Service

Wednesday, 1 August 2012

Introducing functions in rename masks

An important aspect of tagging your songs is renaming your songs so that they match the metadata within the song. Although most music players depend only on the metadata within the song itself, we all have different preference of how to name our files and this helps us to keep them organized. Some applications require the filename to be in a particular format.

Jaikoz used to have quite a simple language for the rename mask that allowed most metadata to be used in the filename but only provided simple if statements. Then this was replaced with support for full Javascript syntax, this allows you to do pretty much anything but creating the correct mask could be long winded and error prone.

Consider this simple mask
 (album.length>0 ? album + '-':'') + (trackno.length>0 ? trackno + '-':'') 
 + (title.length>0 ? title:'')

Although its fairly clear what it is doing. its very fiddly and easy to make a mistake when editing. Unfortunately as a number of you have commented the Javascript is not as easy to understand as the old syntax, I traded this for the power the Javascript notation gives us.

However recently discovered there is nothing to stop you defining functions within your filename mask so the above can be replaced by

 function ifnotempty(value,sep){
     return value != undefined && value.length > 0 ? value + sep : '';
 }
 ifnotempty(album,'-')+ ifnotempty(trackno,'-') + ifnotempty(title,'') 

As you can now see the complexity is put into the function once, then the resultant mask can be much more concise.

In Jaikoz 3.6 we have made use of functions to provide better default masks. Of course if you are upgrading Jaikoz it will keep your existing mask so you will not see them so I have posted them below.

Folder Rename Mask

 function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }
 
 function ifnotempty2(value1,value2,sep){
     return value1.length > 0 ? value1 + sep :value2.length > 0 ? value2 + sep:'' ;
 }
 
 ifnotempty2(albumartist,artist,folderseparator) + ifnotempty(album,folderseparator)
 + (disctotal>1 ? discno  + folderseperator : '') 

Filename Rename Mask

function pad(number, length) {
      var str = '' + number; 
      while (str.length < length) {  
          str = '0' + str;
      }
      return str;
  }
 
 function ifnotempty(value,sep){
     return value.length > 0 ? value + sep : '';
 }
 
 function ifnotempty2(value1,value2,sep){
     return value1.length > 0 ? value1 + sep :value2.length > 0 ? value2 + sep:'' ;
 }
 
 ifnotempty2(albumartist,artist,' - ') + ifnotempty(album,' - ') + 
 ifnotempty(pad(trackno,2),' - ') + title

In future versions of Jaikoz I'm going to add the ability to create and store custom javascript functions with a name to make this even easier, but hopefully in the meantime the use of functions should make creating masks simpler.

Friday, 20 April 2012

Why you should consider the database your tag editor is using to fix your songs

When you use a tag editor that automatically fixes your metadata you should really have a think about where that data comes from.


Photo by Paul Downey

Openness

There are a number of databases containing music information but some of these such are closed, this means you cannot actually browse the data independently never mind correct errors in the database. Often applications that use these type of database keep the identity of their source database hidden.


Accuracy

Sometimes the data is not very accurate. this may be because a database is not being used at all instead the tagger may just trying to hack information from websites and other sources


Linking

An online database can be used to correct your song metadata but for you to take adavantage of a myriad of other interesting applications you need to store a unique id that accurately identifies your song so you dont have to fuzzy match it again.


Metadata and Acoustic Matching

Matching songs by metadata is good but matching by the actual audio can be even better, but you need both: matching by Acoustic Id might identify the correct song but if the song exists on multiple releases it cannot help select the correct release.


The Jaikoz Solution
Openness

The primary database used by Jaikoz is MusicBrainz, MusicBrainz is a completely open database run by the non profit Metabrainz Foundation that can be edited by anybody with a free account. Jaikoz also uses as secondary source Discogs another online database that allows the data to be browsed and edited and freely downloaded.


Accuracy

MusicBrainz has comprehensive guidelines on the editing process and voting system to ensure the quality of edits and to protect the database from poor edits. Discogs also has guidelines and only allows adding of releases that you own, both systems expect the editor to provide another source for their edits.

Linking

MusicBrainz provides unique identifiers for songs, releases and artists (plus some others) and these identifiers are increasing being used by other sites such as Last.fm and the BBC,in fact Musicbrainz Artist Ids are fast becoming an industry standard. Discogs does not have such a sophisticaed system but when a release is matched to Discogs we store the the Discogs Release Url in your songs metadata.

Metadata and Acoustic Matching

Jaikoz uses AcoustId in addition to metadata matching to ensure the best possible match. Acoustid is yet another open system that you can contribute songs to and you can also flag when an acoustic id seems to be assigned to an incorrect song.

Overall at Jthink we are committed to using the best sources available.
Jthink blog Jthink Facebook page google_plus Jthink YouTube channel Email Paul at Jthink Subscribe to Weekly Newsletter