Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Music shuffling

by YuckFoo (Abbot)
on Jul 08, 2008 at 17:20 UTC ( #696267=note: print w/replies, xml ) Need Help??

in reply to Music shuffling

Now, how you gonna make sure that NIN isn't followed by Elton John.

That could cause a brain hemorrhage!

Replies are listed 'Best First'.
Re^2: Music shuffling
by Hue-Bond (Priest) on Jul 09, 2008 at 07:18 UTC

    The simplest solution I found to the OP issue was to divide the track list in two halves, then play each one of them alternately:

    ## pseudocode my @list = shuffle get_tracks; my @list1 = @list[0..@list/2-1]; my @list2 = @list[@list/2..$#list]; while (1) { play @list1; play @list2; shuffle @list1; shuffle @list2; }

    Regarding this:

    Now, how you gonna make sure that NIN isn't followed by Elton John.

    I have thought about a database with style tags and a mechanism for specifying which styles are allowable after a given song:

    ## pseudocode my @style_levels = ( [ qw/noise/ ], [ qw/metal heavy/ ], [ qw/pop rock/ ], [ qw/chill_out classical/ ], ); sub get_next_song { my $cur_song = shift; my $cur_style = get_style_from_db $cur_song; ## now we have 'pop' +, 'classical'... my $index = get_index $cur_style; ## walk @style_level +s and return the index where 'pop' or 'classical' has been found my $next_index = $index + (-1,0,1)[rand 3]; ## randomly go to ne +xt, current or previous style level (TODO: bounds checking) my $next_style = ${ $style_levels[$next_index] }[ rand @{$style_le +vels[$next_index]} ]; ## choose a style of this level return get_song { style => $next_style }; ## pick some song of + this style }

    David Serrano

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://696267]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-12-03 19:08 GMT
Find Nodes?
    Voting Booth?

    No recent polls found