venta: (Default)
venta ([personal profile] venta) wrote2005-02-22 01:09 pm

Jazz police are looking through my folders

Right, let's see if anyone's daft enough to play this game :)

At work, I listen to music. I almost always listen to my own mp3s (in complete albums), with occasional diversification into various streaming audio sources (last.fm, Xfm, 6Music, launchcast, etc).

However, I reckon now's my chance to get down with the cool kids, and have a random play list. I could just bung Winamp on shuffle, but where's the fun in that ? You're invited to choose my tracks. But, obviously, you don't know what music I have to hand (about 20Gb of mp3s).

So, you are invited to choose a number, of the form x-y-z.

The x chooses the artist, and should be a number between 1 and 262 inclusive, where 1 is the alphabetically first artist in my collection.

The y chooses the album. So, in general, it should be quite a low number, as I often have only one or two albums per artist. Albums are numbered in ripping order. If you choose a number greater than the number of albums I have by the chosen artist, I'll just take that to be the highest numbered album I've got.

The z chooses the track. So, in general, it should be a number between 1 and about 12 or so. I do have albums with over 20 tracks, though. If you choose a number greater than the number of tracks on the chosen album, I'll just play the last track.

So, as an example, 262-1-10 would be Remember Me, which is the tenth track off the first Zutons' album (The Zutons are the alphabetically last artist I own).

I'll do it as a poll to make life easier, but feel free to comment your number instead. Or feel free to tell me to stop being so damn lazy and make my own playlist. If anyone's interested, I'll post the resulting playlist later this afternoon.

[Poll #442090]

[identity profile] onebyone.livejournal.com 2005-02-22 01:23 pm (UTC)(link)
If you choose a number greater than the number of albums I have by the chosen artist, I'll just take that to be the highest numbered album I've got.

Modulo arithmetic not good enough for ya?

[identity profile] venta.livejournal.com 2005-02-22 01:32 pm (UTC)(link)
I'm trying to be friendly to non-mathematicians :)
pm215: (Default)

[personal profile] pm215 2005-02-22 02:07 pm (UTC)(link)
Since telephone numbers seem too likely to overflow, my choice is my mother's Co-op share number (one of those odd nuggets of information that I don't suppose I'll ever forget).

I recommend the use of modular arithmetic when interpreting the number; otherwise you'll get a totally random track instead of one with deep cosmic significance and 1p dividend to the pound :-)

[identity profile] venta.livejournal.com 2005-02-22 02:13 pm (UTC)(link)
Yes, I'm rapidly reaching the conclusion that you and Onebyone are right about the modular arithmetic.

However, it's actually surprising how few cases it's making any difference - often it doesn't matter, because I only have one album to choose from, but quite often (for track numbers) it turns out that modular arithmetic and arbitrarily-choose-last provide the same answer :)

Think I'll go modular from now on, though.

[identity profile] broadmeadow.livejournal.com 2005-02-22 02:47 pm (UTC)(link)
In which case, to avoid any [mathematical] bias we should submit album and track numbers in a very large range. In the case of track numbers, for example, if I submit values in the range 1 to 20 and you modulo that value with the actual number of tracks, I will end up chosing lower numbered tracks more often than higher ones. But if I chose tracks in the range 1 to 1000000 that bias will almost completely disappear.

[identity profile] venta.livejournal.com 2005-02-22 02:56 pm (UTC)(link)
Yeah, I don't really like that approach, though. Which was another reason why I was trying to steer clear of modular stuff in the first place - I wanted to encourage people to aim for a "likely" track number. But that just meant that I was going to end up with more last tracks than I ought.

I haven't yet thought of a nice, elegant solution to this. Maybe I should hone my collection down to contain only CDs with, say, exactly twelve tracks.

[identity profile] wimble.livejournal.com 2005-02-22 03:03 pm (UTC)(link)
If they pick too large a number (either for the CD or for the track), you simply carry on counting into the next group?

Of course, in that case, you're effectively combining everything into a single list of several thousand tracks, and a single index number into that list would suffice.

[identity profile] venta.livejournal.com 2005-02-22 03:09 pm (UTC)(link)
Of course, in that case, you're effectively combining everything into a single list of several thousand tracks, and a single index number into that list would suffice.

Aaaargh!

<cower>

Look, my entire concept of the music I own is (primarily) artist-based, and secondarily album-based. I'm trying to break myself gently into this random playlist idea. Stop trying to scare me!

[identity profile] broadmeadow.livejournal.com 2005-02-22 03:23 pm (UTC)(link)
find . -name "*.mp3" | cat -n

will give you a nice numbered list of all your mp3 files. Then all we have to do is chose a number from that list.

[identity profile] venta.livejournal.com 2005-02-22 03:26 pm (UTC)(link)
I know. I use find as well :)

I just don't want to think of my mp3s as a big floppity linear list. Their album structure is important, dammit :)

[identity profile] broadmeadow.livejournal.com 2005-02-22 03:29 pm (UTC)(link)
<splutter> but surely not if we're putting together a playlist of random tracks from random albums?!

[identity profile] wimble.livejournal.com 2005-02-22 03:38 pm (UTC)(link)
I think what she's doing is the same thing my Dension does for generating random play lists: at each point in the directory structure, pick a random entry. If it's a file, play it. If it's a directory, repeat the random selection. After each play, start again at the top of the structure.

Of course, this produces effect unfairly biasing towards directories which are under-represented.

(Consider two directories. There's an even choice between them. But one contains only one track, and the other contains 10 tracks. So 50% of the choices will turn out to be that first track, and the other ten only get an expectation of 5%)

[identity profile] broadmeadow.livejournal.com 2005-02-22 03:41 pm (UTC)(link)
find . -type t, unlike dir /s only generates a list of files. So using this method will produce no bias.

[identity profile] wimble.livejournal.com 2005-02-22 03:57 pm (UTC)(link)
no bias

Yes, where the original selection method does include bias: each of [livejournal.com profile] venta's artists only have 1 chance in 262 of being selected to supply a track, even if one of those artists has produced half of her actual mp3 collection.

[identity profile] venta.livejournal.com 2005-02-22 04:02 pm (UTC)(link)
the original selection method does include bias

It was meant to. I have, for example, five directories of New Model Army mp3s, and only one directory of Baader Meinhof.

This does not mean I want Baader Meinhof to appear in the playlist only one fifth as often as NMA does.

[identity profile] broadmeadow.livejournal.com 2005-02-22 04:07 pm (UTC)(link)
Ah yes, good point.

Which _may_ have been a desirable attribute of her original method, of course. Venta may wish to have her "random" playlist contain an even mix of artists and not be biased towards an artist she has a lot of. Although usually the most represented "artist" in a collection is "VARIOUS ARTISTS" (ie compilations) and so this probably isn't the case.

Which, er, I think leads me to conclude that the big floppity list is well suited to producing this random selection.

I wonder if Venta ever wonders why she bothers starting these threads. ;-)

[identity profile] wimble.livejournal.com 2005-02-22 04:10 pm (UTC)(link)
I think I know why she starts them.
I wonder whether she ever wonders how to stop them. :)

[identity profile] venta.livejournal.com 2005-02-22 04:16 pm (UTC)(link)
I wonder if Venta ever wonders why she bothers starting these threads. ;-)

Hey, I only start them, you don't think I read them, do you ?

[identity profile] wimble.livejournal.com 2005-02-22 04:56 pm (UTC)(link)
Would "No" be the right answer?

[identity profile] wimble.livejournal.com 2005-02-22 03:34 pm (UTC)(link)
It had occured to me that you probably didn't want to flatten the list, and this might be classed as an unfortunate side effect to a "reasonable" workaround.

The find is, in fact, even worse, as it doesn't traverse the file structure in alphabetical order, but in inode order(*). So traverses each directory in approximately chronological order(*). And therefore even more floppity than you'd expect.

(*) I think.

[identity profile] broadmeadow.livejournal.com 2005-02-22 03:45 pm (UTC)(link)
Well, it would only be a list produced for the purpose of randomly selecting tracks. The directory structure itself would be untouched. With the list Venta could then simply ask "pick a number between 1 and n", and go an look up the track that the chosen number represented.

[identity profile] wimble.livejournal.com 2005-02-22 03:56 pm (UTC)(link)
I know, but you'd kind of expect there to be some logical connection between track N and track N+1. Which there would be, as long as they're within the same directory (due to find being depth first). But you'd get great discontinuities as you crossed directory boundaries: my machine starts with U2, and then jumps to ABC (thus disproving my chronological theory, anyway).

On the other hand, given that it's the musical style that's important, the jump from "Peter Skellern" to "Suede" and then to "Percy Sledge", whilst being gradual in a lexicographical sense (note, I store them surname first!) is somewhat more disturbing when you actually listen to them.

Which proves that my point is still bobbins :)

[identity profile] broadmeadow.livejournal.com 2005-02-22 04:10 pm (UTC)(link)
> you'd kind of expect there to be some logical connection between track N and track N+1

For the purpose of making a random selection from the collection, I don't think you would. You would not be listening to the tracks in the order in the list, rather in the order of randomly-selected entries from that list.

[identity profile] ringbark.livejournal.com 2005-02-22 05:28 pm (UTC)(link)
You're not the only one. My mum's was 46758. NW46758 if you were travelling.

[identity profile] antoniosteve.livejournal.com 2005-02-22 02:16 pm (UTC)(link)
142-1-7

[identity profile] wimble.livejournal.com 2005-02-22 02:16 pm (UTC)(link)
Right, let's see if anyone's daft enough to play this game :)

What, round here? Nah, nobody daft 'round here...

[identity profile] broadmeadow.livejournal.com 2005-02-22 02:38 pm (UTC)(link)
So, it's daft you want.

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>

#define MAX_ARTIST 262
#define MAX_ALBUM 5
#define MAX_TRACK 20

int
main (int argc, char **argv)
{
    struct timeval tv;
    gettimeofday (&tv, NULL);
    srandom ((unsigned int) tv.tv_usec);
    printf ("%d-", random() % MAX_ARTIST + 1);
    printf ("%d-", random() % MAX_ALBUM + 1);
    printf ("%d\n", random() % MAX_TRACK + 1);
}


I got 20-3-5. YMMV.

[identity profile] wimble.livejournal.com 2005-02-22 02:42 pm (UTC)(link)
That's a bit wordy, innit? See the Poll Answers for a perl one liner ;-)

[identity profile] broadmeadow.livejournal.com 2005-02-22 03:07 pm (UTC)(link)
Wait 'till you see it in COBOL.

IDENTIFICATION DIVISION.
PROGRAM-ID. LIZ-PLAYLIST.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
66  MAX-ARTIST VALUE 262.
66  MAX-ALBUM VALUE 5.
66  MAX-TRACK VALUE 20.
01  ARTIST  PIC 999.
01  ALBUM   PIC 9.
01  TRACK   PIC 9.
PROCEDURE DIVISION.
       COMPUTE ARTIST = 1 + MAX-ARTIST * FUNCTION RANDOM.
       COMPUTE ALBUM = 1 + MAX-ALBUM * FUNCTION RANDOM.
       COMPUTE TRACK = 1 + MAX-TRACK * FUNCTION RANDOM.

       DISPLAY ARTIST "-" ALBUM "-" TRACK.
       STOP RUN.


[My COBOL's rusty, so that's probably not quite right. And you can do it in one line using MF COBOL.]

[identity profile] wimble.livejournal.com 2005-02-22 03:20 pm (UTC)(link)
I'll write it in SQL, if you're not careful!

[identity profile] phlebas.livejournal.com 2005-02-22 04:24 pm (UTC)(link)
Bah, beaten to it!

COBOL

[identity profile] ringbark.livejournal.com 2005-02-22 05:26 pm (UTC)(link)
Real cobblers don't use COMPUTE. It makes it too close to a useful language.

Re: COBOL

[identity profile] broadmeadow.livejournal.com 2005-02-23 12:17 pm (UTC)(link)
I think there would be problems with the intrinsic functions if you used combinations of MULTIPLY and ADD instead. phlebas will be able to confirm, I am sure.

Name that language in one line!

[identity profile] compilerbitch.livejournal.com 2005-02-22 04:02 pm (UTC)(link)
Here's another one liner for you...

{Random[Integer,{1,262}],Random[Integer,{1,5}],Random[Integer,{1,20}]}

I get {45, 2, 6}.

The question for the fellow geeks is: what language is this?

Re: Name that language in one line!

[identity profile] phlebas.livejournal.com 2005-02-22 04:28 pm (UTC)(link)
Python?

Re: Name that language in one line!

[identity profile] phlebas.livejournal.com 2005-02-22 04:29 pm (UTC)(link)
Ahh. Mathematica?

Re: Name that language in one line!

[identity profile] compilerbitch.livejournal.com 2005-02-22 05:13 pm (UTC)(link)
Yep!

Re: Name that language in one line!

[identity profile] compilerbitch.livejournal.com 2005-02-22 04:35 pm (UTC)(link)
Good guess, but no.
ext_54529: (Default)

Re: Name that language in one line!

[identity profile] shrydar.livejournal.com 2005-02-22 06:45 pm (UTC)(link)
Nah, this is python:

from random import *; '-'.join(['%d'%(randint(1,x)) for x in [262,5,20]])

I fear I am too late to contribute 252-1-19
ext_550458: (Handel)

[identity profile] strange-complex.livejournal.com 2005-02-22 03:07 pm (UTC)(link)
Are you going to post to say what tracks all the codes translated as in the end? I'm curious to know what I've made you listen to!

[identity profile] venta.livejournal.com 2005-02-22 03:09 pm (UTC)(link)
Aye, I will do in a little while. Poll-votes[*] have slowed down a lot now, so I reckon most people have had their say.

[*] Or pole-vaults.

[identity profile] wimble.livejournal.com 2005-02-22 04:09 pm (UTC)(link)
And your Very Specific Opinion too!