"Random" mp3 selector

  • Thread starter amp88
  • 17 comments
  • 1,124 views
3,746
I like to write fairly simple programs to do common tasks I perform on the PC. As I recently bought an mp3 player, I've written a small program to select a given number of mp3s or a given maximum volume of data from a reservoir of mp3s to be transferred to an mp3 player. As I only wrote it for myself, it doesn't have a GUI at the moment, but I'm interested to see if anyone else would find a tool like this handy. If you don't think this would be a handy tool, why not? Does anyone else use an existing program like this?

I'd appreciate some feedback...

@mods...I wasn't sure whether this should go in the Programming sub-forum or here...I only chose to stick it here because the Programming sub-forum seems to be a place to ask for help with problems.
 
Interesting...I wouldn't use it (too many crap mp3s) but with the proper feature set I'm sure many would.
 
skip0110
Interesting...I wouldn't use it (too many crap mp3s) but with the proper feature set I'm sure many would.
I wouldn't use it either, but like Skip said, if it had a nice little GUI and a few key options, I'm sure people would use it.

Good luck.
 
Ok, cool. Thanks for the replies...

Any ideas what kind of features you'd like (or you think other people would like)?

edit@ skip...at the moment I've got a sort-of blacklist of artist names...whatever you put on the list won't be selected by the program. If you stick Backstreet Boys on the blacklist you won't get any on your mp3 player :P

edit2: On my system (Athlon 2700+), it takes roughly 30-40ms to scan 3500mp3s with 10 artists names on the blacklist, so there isn't really a performance hit because of this. However, at the moment the blacklist only works if the artist name is at the start of the filename of the mp3.

For example...say you put "2pac" on the blacklist, the program wouldn't select a file named:

2pac - L'il Homies.mp3

...but it would select

03 - 2pac - L'il Homies.mp3

I'm considering modifying the program to search through the entire filename, but I'm wondering if this is worth the possible performance hit...I'll give it a look now.
 
To get a proper blacklist you'd have to read in mp3 tags and check the ARTIST tag against the blacklist. The current blacklist wouldn't work for me because I have my mp3s organised in this structure:

Artist\[Year] Album\0# - Title

With a little work (and if I had a DAP :P), I'd probably use it.
 
Ah, but not everyone uses mp3 tags and those who do don't always have them right. Anyway, I've just sorted it so that if the artist name appears anywhere in the filename it won't select them...problem is it now takes roughly ten times the amount of time to run... :(

So, Shannon, your mp3s don't contain the artist's name? I suppose I could check the full path of the file rather than just the filename...might balloon the run time again though
 
Not in the filename, no. In the filepath, yes. Here is one:

Alice In Chains\[1992] Dirt\01 - Them Bones.mp3

You could add an option to enable tag reading or not (and set it to disabled by default). Those who don't know what tags aren't likely to enable said option. And those same people are usually the ones with the screwed tags.

Although, if you added tag reading in you could also add a more sophisticated blacklist. eg: I could blacklist a certain album by a certain artist, or all Progressive Rock albums from the year 1972, etc.
 
Hmmm....getting a bit more complex than I'd intended ;)

I've never used mp3tags before (in programming anyway), so I'd have to look into that if I were to do it...

Cool suggestion though 👍
 
:odd: I'm not quite sure I understand what it is you're trying to do but it sounds like unless you have tags on it won't work. It won't work because I hate tags and only use filenames. The problem for me with that is I consume more than I can organize. :banghead: I rarely get commericalized crap so I wouldn't have a problem of blacklisting a group like backstreet boys. :lol:
 
VIPFREAK
:odd: I'm not quite sure I understand what it is you're trying to do but it sounds like unless you have tags on it won't work. It won't work because I hate tags and only use filenames. The problem for me with that is I consume more than I can organize. :banghead: I rarely get commericalized crap so I wouldn't have a problem of blacklisting a group like backstreet boys. :lol:
I blindfolded you and gave you a bunch of apples one after another, telling you to place all the red, juicy apples to your left and all the others to the right. Now, if I simply gave you the apple and said "Here's an apple", you wouldn't have any idea where to put the apple would you? Now, if I added some adjectives to that apple.

"Here's a big, red, round, juicy apple", you now immediately know to place that apple to your left. "Here's a green apple", and you'd place it your right.

If we simply searched the filename for "2pac", we're not to know it's actually by 2pac. It could be The Westside Gangstaz - An Ode To 2pac, but the program would still blacklist it. However, if we checked the ARTIST tag and it said "2pac", it's definately a 2pac song and thus blacklisted. The filename is the apple and the tags are its adjectives describing it.

Tags are very handy, you just can't be bothered using them.
 
Well... ok I see your point but at the same time if were talking personal collections ( excluding genere like Electronica :ill: ) I don't let mine get to the point where I don't know what is what. I know it enough I can generally find it without anyproblems. I guess it sounds good for others that have that problem though.

Tags arn't handy when they are inaccurate... but yeah... I know, they are from sources we can't talk about here. :dopey: but it's where you get the "good" stuff.
 
amp88
Ah, but not everyone uses mp3 tags and those who do don't always have them right. Anyway, I've just sorted it so that if the artist name appears anywhere in the filename it won't select them...problem is it now takes roughly ten times the amount of time to run... :(
When you consider that moving the mp3s is the real limiting factor, a 10x performance hit is acceptable...

Maybe you should release the .exe, we can all try it and give suggestions ;) :D
 
Cool explanation Shannon :)

The only reason I originally wrote the program was because I was faced with a bit of a dilemma after buying my mp3 player. With 1 gig of sd memory available, you can get about 220 tracks on (depending on bitrate and length (though I did convert all of the files in my file reservoir down to 128kbps to save space (and I'm not really going to notice the difference on cheap headphones when I'm listening to mp3s on the train))), and the cheap mp3 player only reads the first 200 tracks on the card. So, having many more than 200 mp3s I wanted on the card, I initially just chose a few albums I wanted on and was reasonably happy with that. Then, after listening to every album a few times I wanted some more selection...so rather than hand-picking tracks, I wrote the small program to "randomly" select up to 200 tracks (or up to 1 gig of data) and stick them on the mp3 player.

I was just wondering if other people were in the same situation and whether or not they might benefit from having a simple, automated solution.
 
skip0110
When you consider that moving the mp3s is the real limiting factor, a 10x performance hit is acceptable...

Maybe you should release the .exe, we can all try it and give suggestions ;) :D

Yep, that's true, but I know when I show it to the guys at uni I'll probably get stick for inefficient coding...

I'm writing it in Java (that's what they teach us at uni and I haven't really got the free time to learn C++ properly, though I have done a small amount of C), and at the moment it's really just hard-coded stuff (paths, memory, file limit, blacklist etc)...

After I finish the recursive file search and clean things up a bit I'll stick it up
 
amp88
Cool explanation Shannon :)

The only reason I originally wrote the program was because I was faced with a bit of a dilemma after buying my mp3 player. With 1 gig of sd memory available, you can get about 220 tracks on (depending on bitrate and length (though I did convert all of the files in my file reservoir down to 128kbps to save space (and I'm not really going to notice the difference on cheap headphones when I'm listening to mp3s on the train))), and the cheap mp3 player only reads the first 200 tracks on the card. So, having many more than 200 mp3s I wanted on the card, I initially just chose a few albums I wanted on and was reasonably happy with that. Then, after listening to every album a few times I wanted some more selection...so rather than hand-picking tracks, I wrote the small program to "randomly" select up to 200 tracks (or up to 1 gig of data) and stick them on the mp3 player.

I was just wondering if other people were in the same situation and whether or not they might benefit from having a simple, automated solution.

At least for me... I can't say that would work. I guess I'm too picky. :guilty: I rather hand pick all my songs even if it means going though my collection manually. :scared:
 
Ok, just finished the recursive file search and cleaned up the source (a bit)...

Feedback/comments on source welcome (don't be too harsh though ;) )
 

Attachments

  • PathRecFileSelector.txt
    8 KB · Views: 17
I see 2 performace improvements:

Wrap your FileInputStream and and FileOutputStream in a BufferedInputStream and a BufferedOutputStream. These will lower the number of disk I/O requests, and speed it up a bit. Just remeber to flush them when you are done!

Also, string searching can be done much more effectively than what you do (to find artist names) using the so called Knuth-Morris-Pratt algorithm. You don't need to know how this works (read: I don't feel like explaining ;)) but use the String.indexOf(...) method. If it returns -1, the string was not found.

HTH.

P.S. You do a great job commenting your code. I typically am much more lax, and your code was really easy to read.
 
Will do, thanks 👍

edit: wow, the indexOf method is amazing...

Takes my mess of many lines and replaces it with 1...

Thanks again
 
Back