To calculate probability user has to select the starting music which represents user's current mode of listening music. Let's call it as Initialized Music. Smart Music DJ calculates probability based on this music.

The Initialized Music has an influence on the probability distribution of the candidate music. So, we can call it as an Influencing Music.

The algorithm is very simple. If any candidate music has the same artist/album/composer/genre as the influencing music then I used a influencing factor to increase the probability of the candidate music. Let's discuss it with a code snippet

protected override void CalculateProbability(Music playingMusic)
{
    var grandTotal = 0d;
    foreach (var music in NextMusics)
    {
        music.TotalScore = DataSource.GetScore(music);
        if (IsInfluencedGenre(music.Genre, playingMusic) || IsInfluencedGenre(music.Genre, InitializedMusic))
        {
            music.TotalScore += RegistryHelper.GenrePreference * GetAverageGenreScore(music.Genre);
        }
        if (IsInfluencedAlbum(music.Album, playingMusic) || IsInfluencedAlbum(music.Album, InitializedMusic))
        {
            music.TotalScore += RegistryHelper.AlbumPreference * GetAverageAlbumScore(music.Album);
        }
        if (IsInfluencedArtist(music.Artist, playingMusic) || IsInfluencedArtist(music.Artist, InitializedMusic))
        {
            music.TotalScore += RegistryHelper.ArtistPreference * GetAverageArtistScore(music.Artist);
        }
        if (IsInfluencedComposer(music.Composer, playingMusic) || IsInfluencedComposer(music.Composer, InitializedMusic))
        {
            music.TotalScore += RegistryHelper.ComposerPreference * GetAverageComposerScore(music.Composer);
        }
        grandTotal += music.TotalScore;
    }
    foreach (var music in NextMusics)
    {
        music.Probability = music.TotalScore / grandTotal;
    }
}

In the code snippet playingMusic is the music currently playing. It could be user's Initialized Music. So, there are two influencing music used in the algorithm. The Initialized Music has influence for the entire cycle of automatic playing music. But the currently playing music has also an influence on the next music. so, this influence changes as soon as the next music is played. The Genre Preference, Album Preference, Artist Preference and Composer Preference are fixed multiplier which user can configure using the preference dialog.

Music's initial Total Score is calculated from the database. It's the addition of the music's score and the profile score for that music. Music's score is based on the number of people likes the music and profile score is based on the preference assigned in the current profile.

After initializing the score from the database I added to influence score if the music has an influence from the currently playing music or Initialized Music.

See Also : How preference is recorded?

Last edited May 21, 2011 at 4:32 PM by hsmasud, version 2

Comments

No comments yet.