Click here to Skip to main content
15,498,622 members
Articles / Programming Languages / C#
Posted 7 Jan 2007


149 bookmarked

Music Manager 1.1

Rate me:
Please Sign up or sign in to vote.
4.85/5 (36 votes)
15 Mar 2008CPOL6 min read
Music library, Probability based random play
Sample Image - Music_Manager_10.jpg


I use Creative Nano to listen to music. It's good to use. But I find that managing songs is a problem. It has a folder view where I can switch from one folder to other. But it displays all the folders containing MP3 songs in the same level. So, I had to create a folder based on the artist name. However, it becomes a problem to create the folders manually. So, I tried to use the software which can sync music with a removable drive. For that, I found Windows Media Player useful. But in case of my MP3 player, there is a big problem. Windows Media Player creates a folder name as [Artist Name]\[Album Name]\[File Name]. So, in my MP3 player, I can see only the album name which is most of the time incorrect. In fact I want to switch from one artist to another. So, I decided to make my own program which can sync according to my choice.

Then I found that it should have a play feature too. I don't want to use different applications for playing music while I'm copying music to my music player. So, I added the entire feature which helps me to listen to music from my MP3 player.

Then I designed a probability based random music playing algorithm which would monitor my choice and play music according to that. I found it's very useful to listen to music. I was using iTunes before I designed Music Manager. So, the look becomes similar to iTunes. I think this representation of music is better than that of Windows Media Player.


Manage Your Music Library

To import your existing music from your computer, you can browse the location of your music folder and then press the Load button. It will search for all the music recursively and add it to the library. It creates an MMHistory.mmh file for each folder you are interested in. It uses a relative location. So, if you copy this folder to some other location and browse the folder with Music Manager, then it will load the MMHistory.mmh file and play music.

To manage music, you can copy music from the Music Manager, paste to Music Manager and delete music from your music folder with Music Manager. You can also drag and drop music to Music Manager. It will copy according to the file name format you specified in the options.


File name formats are as follows:

  • {Album}\{Artist}\{FileName}
  • {Artist}\{Album}\{FileName}
  • {Artist}\{FileName}
  • {Album}\{FileName}
  • {FileName}
  • {Album}\{Artist}\{Title}
  • {Artist}\{Album}\{Title}
  • {Artist}\{Title}
  • {Album}\{Title}
  • {Title}
  • {Genre}\{Album}\{Artist}\{FileName}
  • {Genre}\{Artist}\{Album}\{FileName}
  • {Genre}\{Album}\{Artist}\{Title}
  • {Genre}\{Artist}\{Album}\{Title}

So, you can manage your music according to the information available in MP3 files.

You can also paste Windows Media Player play list (*.wpl) to Music Manager. Music Manager will copy all the music listed in the play list to the location you specified with your specified file name format.

You can also use add files, add folder from file menu to copy music to the specified location.

If you delete a file from the Music Manager library, then it will delete from the physical location too.

Volume Controller

In the controls menu, there is a Volume Controller menu. The user can control volume including bass and treble.

Volumn Controller

Probability Based Random Music Player

Now let's discuss the probability based random music player. When we play music, we follow some patterns. For example, if you selected a song with classical music then you might choose another song with classical music. Now in that classical music, there is a high probability that the next song is sung by the same artist or from the same album. So, we can conclude that selecting the next song depends on the previous song. Now let's discuss how I designed the random music player.

I used a simulation technique called Morkov Chain. Initially all the songs have the same priority. Let's say it's 1.
If there are n types of songs, then probability for each type is 1/n. When the user plays a song, Music Manager increases the priority for that music to one unit. So, after playing the first song, its priority becomes 2 and probability of that music becomes 2/(n+1) and probability of the other music is 1/(n+1). Simply put, the probability of a type of music is Priority/(Total Priority).

Now when user plays a music type, Music Manager increase priority to all the music belonging to the same genre. Music Manager adds the average priority of a genre to all the music belonging to that genre. So, priority gets increased for that genre. Then the next priority is the artist. So, all the music sang by the same artist gets increased by its average priority. Similarly, it adds the album priority. In this part, the user cannot control the priority. But the user can add additional priority specified in the option dialog. The user defined priority is added to every song according to the genre, artist and album.

The user might not expect the same music to play repetitively. So, the user can check the 'Do not repeat until all music is played' check box in the options. The user can define a priority to repeat the music too. In that case, a played song's priority is decreased with the factor defined by the user. If it is 20 (the maximum value), then Music Manager doesn't decrease the priority of a played song.

So, this random player plays according to the user's choice and the prediction that the user would like the next song from the same genre or from the same artist or album. So, it has become more interesting than any other random music player.

The priority of a song increases permanently in two cases:

  1. The user selects a song and plays it manually
  2. The user listens to the song completely

So, if the user does not like the randomly chosen song, then he can skip or play the next song and no priority is added to that song. If the user plays a song manually and listens to the complete song then the priority is increased by two units. Thus, it builds the probability database. The average priority of the genre, artist or album is not saved in the database. It is needed to affect the probability distribution based on the music played.

What's New in Music Manager 1.1?

WMA support to music manager - I thank Dave.Kelly for sending me the code to support WMA file.

To design this application, I used some code downloaded from The Code Project. I thank the authors of that code.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior) KAZ Software Limited
Bangladesh Bangladesh
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionMessage Closed Pin
19-Dec-21 18:16
Memberkillua boxer19-Dec-21 18:16 
Bugto play NEXT Pin
haltz14-May-13 10:58
Memberhaltz14-May-13 10:58 
Questionnice article ;) Pin
./tempatsampah15-Nov-12 0:41
Member./tempatsampah15-Nov-12 0:41 
GeneralMy vote of 5 Pin
descartes26-Mar-12 3:31
Memberdescartes26-Mar-12 3:31 
QuestionIs it possible to play multiple sounds at once? Pin
descartes26-Mar-12 3:28
Memberdescartes26-Mar-12 3:28 
GeneralMy vote of 5 Pin
Mardani Dani5-Jan-12 13:17
MemberMardani Dani5-Jan-12 13:17 
GeneralMy vote of 5 Pin
Mohammed Nazer18-Nov-10 19:10
MemberMohammed Nazer18-Nov-10 19:10 
GeneralAutoPLay... Pin
VisualLive26-Mar-09 21:53
MemberVisualLive26-Mar-09 21:53 
GeneralGreat Job !!! Pin
debanjan.routh7-Oct-08 23:06
Memberdebanjan.routh7-Oct-08 23:06 
Generalnice job!! Pin
Hari Om Prakash Sharma15-Mar-07 1:43
MemberHari Om Prakash Sharma15-Mar-07 1:43 
GeneralRe: nice job!! Pin
datacore17-Mar-08 5:00
Memberdatacore17-Mar-08 5:00 
AnswerRe: nice job!! Pin
H. S. Masud20-Mar-08 1:53
MemberH. S. Masud20-Mar-08 1:53 
Questionhow do i open the source code Pin
wolffighters5-Mar-07 13:09
Memberwolffighters5-Mar-07 13:09 
Questionhow does it work? Pin
Martin081524-Jan-07 1:44
professionalMartin081524-Jan-07 1:44 
AnswerRe: how does it work? Pin
Michael900022-Jul-07 0:18
MemberMichael900022-Jul-07 0:18 
GeneralRe: how does it work? Pin
pinelo4-Mar-08 18:27
Memberpinelo4-Mar-08 18:27 
GeneralRe: how does it work? Pin
Michael900010-Mar-08 1:25
MemberMichael900010-Mar-08 1:25 
GeneralRe: how does it work? Pin
H. S. Masud15-Mar-08 22:10
MemberH. S. Masud15-Mar-08 22:10 
QuestionSorted Listboxes? "Next" operation? Pin
akemper17-Jan-07 10:40
Memberakemper17-Jan-07 10:40 
AnswerRe: Sorted Listboxes? "Next" operation? Pin
H. S. Masud18-Jan-07 1:08
MemberH. S. Masud18-Jan-07 1:08 
Thanks for your comment. I sorted genre, artist and album. But I did that in a different way. Because I want the first item as All Gener or All Artist like that. So, I did not used the sort feature of the list box. I sort the data.
I solved the problem with the next button.


Hasan Shahriar Masud
Senior Software Engineer
Kaz Software limited
Dhaka, Bangladesh

AnswerQuick fix, but ... [modified] Pin
akemper18-Jan-07 10:35
Memberakemper18-Jan-07 10:35 
GeneralMaybe a silly suggestion Pin
XChronos17-Jan-07 6:21
MemberXChronos17-Jan-07 6:21 
GeneralRe: Maybe a silly suggestion Pin
Roland Li17-Jan-07 15:48
MemberRoland Li17-Jan-07 15:48 
GeneralExcellent Work Pin
XChronos17-Jan-07 6:09
MemberXChronos17-Jan-07 6:09 
GeneralRe: Excellent Work Pin
H. S. Masud18-Jan-07 1:05
MemberH. S. Masud18-Jan-07 1:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.