Click here to Skip to main content
15,867,308 members
Articles / Programming Languages / C#
Article

Music Manager 1.1

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

Introduction

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.

Description

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.

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.

License

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 17:16
killua boxer19-Dec-21 17:16 
Bugto play NEXT Pin
haltz14-May-13 9:58
haltz14-May-13 9:58 
Questionnice article ;) Pin
./tempatsampah14-Nov-12 23:41
./tempatsampah14-Nov-12 23:41 
GeneralMy vote of 5 Pin
descartes26-Mar-12 2:31
descartes26-Mar-12 2:31 
QuestionIs it possible to play multiple sounds at once? Pin
descartes26-Mar-12 2:28
descartes26-Mar-12 2:28 
GeneralMy vote of 5 Pin
Mardani Dani5-Jan-12 12:17
Mardani Dani5-Jan-12 12:17 
GeneralMy vote of 5 Pin
Mohammed Nazer18-Nov-10 18:10
Mohammed Nazer18-Nov-10 18:10 
GeneralAutoPLay... Pin
VisualLive26-Mar-09 20:53
VisualLive26-Mar-09 20:53 
GeneralGreat Job !!! Pin
debanjan.routh7-Oct-08 22:06
debanjan.routh7-Oct-08 22:06 
Generalnice job!! Pin
Hari Om Prakash Sharma15-Mar-07 0:43
Hari Om Prakash Sharma15-Mar-07 0:43 
GeneralRe: nice job!! Pin
datacore17-Mar-08 4:00
datacore17-Mar-08 4:00 
AnswerRe: nice job!! Pin
H. S. Masud20-Mar-08 0:53
H. S. Masud20-Mar-08 0:53 
Questionhow do i open the source code Pin
wolffighters5-Mar-07 12:09
wolffighters5-Mar-07 12:09 
Questionhow does it work? Pin
Martin081524-Jan-07 0:44
professionalMartin081524-Jan-07 0:44 
AnswerRe: how does it work? Pin
Michael900021-Jul-07 23:18
Michael900021-Jul-07 23:18 
GeneralRe: how does it work? Pin
pinelo4-Mar-08 17:27
pinelo4-Mar-08 17:27 
GeneralRe: how does it work? Pin
Michael900010-Mar-08 0:25
Michael900010-Mar-08 0:25 
GeneralRe: how does it work? Pin
H. S. Masud15-Mar-08 21:10
H. S. Masud15-Mar-08 21:10 
QuestionSorted Listboxes? "Next" operation? Pin
akemper17-Jan-07 9:40
akemper17-Jan-07 9:40 
The file lists are perfectly sorted. The sort order changes ascending <-> descending on mouse clicks on the column header. But the Genre/Artist/Album lists lack sorting. I've set the "sorted" property of these lists to "true". That fixed it right away.

I couldn't get the "next" operation working. How do I persuade Music Manager to play the next title in the list of files? Using "next" in the "tool" menu, the current title is restarted.

This is certainly my first piece of Software from Bangladesh.
I take it as a text-book example to learn how to craft a C# application.

Thanks a lot!

Axel Kemper
AnswerRe: Sorted Listboxes? "Next" operation? Pin
H. S. Masud18-Jan-07 0:08
H. S. Masud18-Jan-07 0:08 
AnswerQuick fix, but ... [modified] Pin
akemper18-Jan-07 9:35
akemper18-Jan-07 9:35 
GeneralMaybe a silly suggestion Pin
XChronos17-Jan-07 5:21
XChronos17-Jan-07 5:21 
GeneralRe: Maybe a silly suggestion Pin
Roland Li17-Jan-07 14:48
Roland Li17-Jan-07 14:48 
GeneralExcellent Work Pin
XChronos17-Jan-07 5:09
XChronos17-Jan-07 5:09 
GeneralRe: Excellent Work Pin
H. S. Masud18-Jan-07 0:05
H. S. Masud18-Jan-07 0: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.