PhatHack

Phatbox / Keg software and support => Phatnoise Hardware Support => Topic started by: walkAbout on October 24, 2006, 11:37:04 am

Title: Convert cue-sheets to m3u playlists for phatbox
Post by: walkAbout on October 24, 2006, 11:37:04 am
Hi peeps,

I have lots of DJ-Sets consisting of a single file. For most I have a corresponding cue sheet, or if missing, I build one by myself while listening at home.
Now with the phatbox it's not a pleasure to listen to these sets. It is not possible to fast-forward in a track (at least, I didn't find out). Also for two hours sets it is uncomfortable to fast-forward.

I found the the following info here:
http://phatbox.sixpak.org/phatbox/unsupported.phtml

The .m3u files can now handle multiple tracks from one file. Just put a tab, start time (seconds), tab, end time (seconds) after the path to mark where it starts and ends in the file. -1 can be used to signify the end of the file. For non-audible files, the sections must be consecutive and run up to the end of the file. Here's an example:

  #First Track
  /dos/data/file.mp3      0      60
  #Second Track
  /dos/data/file.mp3      61      120
  #Third Track
  /dos/data/file.mp3      121      -1

That sounds really good. Now the only problem is to convert the cue sheet to such a m3u file. I searched through the net and found this question a couple times, but with now answer.

Has anyone here an idea how to easily convert my cue sheets? To this by hand each time is impossible.
I will do it manually for one set to check it out.

Many thanks in advance.
walkAbout
  
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: judb on October 24, 2006, 09:27:16 pm
I am not familiar with the internal format of a cue sheet.. so i cant say how easy it would be.. I don't know of a program that will do that for you off hand, sorry.
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on October 25, 2006, 02:13:02 pm
Hi,

that's the problem, I tried to find something already. I think for a programmer it will be very easy to do it, but I'm a technician, not a programmer.

The format is the following:

CUE:

PERFORMER "VA"
TITLE "Performer-Albumname"
FILE "sample.mp3" MP3  #Foldername is not included in filename#
  TRACK 01 AUDIO
    TITLE "Title 1"
    PERFORMER "Performer 1"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "Title 2"
    PERFORMER "Performer 2"
    INDEX 01 01:50:73
  TRACK 03 AUDIO
    TITLE "Title 3"
    PERFORMER "Performer 3"
    INDEX 01 07:40:03


And for the phatbox it should look like this:

#Performer 1 - Title 1
/dos/data/Music/Foldername/sample.mp3      0      110
#Performer 2 - Title 2
/dos/data/Music/Foldername/sample.mp3      110      460
#Performer 3 - Title 3
/dos/data/Music/Foldername/sample.mp3      460      -1


So you "only" have to get the Performer and Title information from the cue and then set the minutes to seconds and add the seconds from the cue.

Another thing is the foldername that is present in the m3u-file. Unfortunately it is not included in the cue sheet, as the cue has to be in the same folder like the sound file. So the program has to get the foldername where the soundfile is in and add it to this line:
/dos/data/Music/Foldername/sample.mp3

Hmm, it would be really handy for (not only) me, if someone could make a little program, that asks for the cue-sheet location and then has a button to save it as m3u with the right path/foldername in it.

Other question is, where to ask in the internet for programming, what language would you recommend (.NET, Perl....)

TIA
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: sbingner on October 25, 2006, 08:36:57 pm
You could try something like this (perl cue2m3u.pl file.cue file.m3u "/dos/data/DIRECTORY"):

Code: [Select]
#!perl -w
use strict;

my $cuefile = $ARGV[0] || die "No Cue file specified";
my $m3ufile = $ARGV[1] || die "No m3u specified";
my $path = $ARGV[2] || die "No path specified";

open(CUE, "$cuefile");
open(M3U, ">$m3ufile");
my %cueentry;
my @cueentries;
my $lastnum;
my $curnum = '00';
while (my $line = <CUE>) {
  $line =~ s/\r?\n$//;
  if ($line =~ /^PERFORMER\s"([^"]+)"/) {
    if (defined $cueentry{$curnum}{offset}) {
      foreach my $num (@cueentries) {
        if ($num eq $cueentries[$#cueentries]) {
          printf M3U ("#%s - %s\r\n%s/%s\t%d\t%d\r\n", $cueentry{$num}{performer}, $cueentry{$num}{track}, $path, $cueentry{filename}, $cueentry{$num}{offset}, -1);
        } else {
          printf M3U ("#%s - %s\r\n%s/%s\t%d\t%d\r\n", $cueentry{$num}{performer}, $cueentry{$num}{track}, $path, $cueentry{filename}, $cueentry{$num}{offset}, $cueentry{$num}{endoffset});
        }
      }
    }
    %cueentry = @cueentries = ();
    $cueentry{performer} = $1;
  } elsif ($line =~ /^\s+PERFORMER\s"([^"]+)"/) {
    $cueentry{$curnum}{performer} = $1;
  } elsif ($line =~ /^TITLE\s"([^"]+)"/) {
    $cueentry{album} = $1;
  } elsif ($line =~ /^\s+TRACK (\d+) AUDIO/) {
    push @cueentries, $1;
    $curnum = $1;
  } elsif ($line =~ /^\s+TITLE\s"([^"]+)"/) {
    $cueentry{$curnum}{track} = $1;
  } elsif ($line =~ /^\s+INDEX\s\d+\s(\d+):(\d+):(\d+)/) {
    if ($#cueentries) {
      $cueentry{$cueentries[$#cueentries-1]}{endoffset} = $1 * 60 + $2;
    }
    $cueentry{$curnum}{offset} = $1 * 60 + $2;
  } elsif ($line =~ /^FILE\s"([^"]+)"/) {
    $cueentry{filename} = $1;
  }
}
close(CUE);
if (defined $cueentry{$curnum}{offset}) {
  foreach my $num (@cueentries) {
    if ($num eq $cueentries[$#cueentries]) {
      printf M3U ("#%s - %s\r\n%s/%s\t%d\t%d\r\n", $cueentry{$num}{performer}, $cueentry{$num}{track}, $path, $cueentry{filename}, $cueentry{$num}{offset}, -1);
    } else {
      printf M3U ("#%s - %s\r\n%s/%s\t%d\t%d\r\n", $cueentry{$num}{performer}, $cueentry{$num}{track}, $path, $cueentry{filename}, $cueentry{$num}{offset}, $cueentry{$num}{endoffset});
    }
  }
}
close(M3U);

PS. I posted a copy to http://downloads.phathack.com/sbingner/cue2m3u.pl -- it'll show up on the hour or so
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on October 26, 2006, 02:56:03 pm
Hi sbingner,

many thanks for your script, I really appreciate it. Just downloaded ActivePerl and tried it. Works like a charm.
Unfortunately I cannot try it right now, cause I'm in Munich at the fair Systems. But your script does exactly what I did by hand yesterday. Great.

Now lets see if it works, cause I/we did not set the extra second between the tracks, like it is stated in my initial post. As it is a DJ-Set, I don't want to have space between the tracks. I will check it at the weekend, if it works like this, but I guess yes.

Again, many thanks for coding so quick.
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: Terry_Kennedy on October 27, 2006, 06:11:20 pm
Quote
Now lets see if it works, cause I/we did not set the extra second between the tracks, like it is stated in my initial post. As it is a DJ-Set, I don't want to have space between the tracks. I will check it at the weekend, if it works like this, but I guess yes.

I'm doing something similar for my music collection. Note that you must use a constant bitrate for your MP3, or the PhatBox "track skip" within the MP3 will get very confused.
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on October 30, 2006, 12:28:05 pm
Quote
I'm doing something similar for my music collection. Note that you must use a constant bitrate for your MP3, or the PhatBox "track skip" within the MP3 will get very confused.

Hi,

thanks for mention. That's probably the reason why it didn't work on my side. I just wanted to contact the author of the unsupported features, but I will now first check, if my trial set has a constant bitrate.

Here the phatbox behaves like before. If I want to go to the next track it goes to the next set in the folder.

I hope it has to do with the variable bitrate.

CU
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: Terry_Kennedy on October 31, 2006, 06:24:56 am
Quote
thanks for mention. That's probably the reason why it didn't work on my side. I just wanted to contact the author of the unsupported features, but I will now first check, if my trial set has a constant bitrate.

Here the phatbox behaves like before. If I want to go to the next track it goes to the next set in the folder.

I hope it has to do with the variable bitrate.

Nope, you've got some other issue (more below). Using VBR just means that track skip will land at random places within the .mp3 file, instead of at song boundaries.

Regarding your skipping to the next album, rather than to the next track in your .mp3 file, are you creating the P*.pbx files as well as the .m3u files? You need to create both of them (this isn't documented on the "unsupported hacks" page). Here's a sample .m3u and .pbx file:

#warehouse 5am
/dos/data/music/A Positive Life_Synaesthetic.mp3        0       573
#bathdub
/dos/data/music/A Positive Life_Synaesthetic.mp3        574     1258
#the calling
/dos/data/music/A Positive Life_Synaesthetic.mp3        1259    1565
#pleidean communication
/dos/data/music/A Positive Life_Synaesthetic.mp3        1566    2001
#lighten up!
/dos/data/music/A Positive Life_Synaesthetic.mp3        2002    2397
#spacehopper
/dos/data/music/A Positive Life_Synaesthetic.mp3        2398    3015
#hypnosystem
/dos/data/music/A Positive Life_Synaesthetic.mp3        3016    3680
#aquasonic
/dos/data/music/A Positive Life_Synaesthetic.mp3        3681    4181

[Disc]
playlist_type=default
playlist_title=A Positive Life - Synaesthetic
dynamic_disc=0
num_tracks=8
mag_random=1
force_random=0
image_filename=

Once you've created these files and copied them onto your DMS, you need to do a "save and eject" in PMM to build the index files.

Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on October 31, 2006, 12:28:16 pm
Thanks again...

it is working on my side now. I converted the set from VBR to CBR.
The process for replacing the m3u file is not really clear for me. I ejected the DMS, connected it again, but stopped the PhatnoiseAgent and replaced the m3u file. When starting the PMM then, it recognizes the single songs and after an other ejecting it also updates the pbx file with right number of tracks. So this seems to do the trick. But I think it is easier, to do it like you.
But for newly copied "albums" the m3u will be created when ejecting the DMS. So I have to eject one time anyway.
I will play around a bit...

I have another problem since it worked yesterday, it doesn't speak the current album etc. for me. It only says "The current album is:" then nothing (back to music) Lets see, I use Phatvoice parallel.

CU
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: AlanS on December 13, 2006, 10:14:49 pm
Are there any further developments on this topic as this feature is of great interest to me.
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on December 15, 2006, 11:13:49 pm
Quote
Are there any further developments on this topic as this feature is of great interest to me.

Hi,

I'm really satisfied with the script provided here. It does everything for me. What further things you will need? Let me know, probably I want it too.

CU
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: AlanS on December 19, 2006, 12:45:55 am
Yes there is no doubt that the script works perfectly. One has to be so careful when writing the directory path for the perl command in dos. Any error and PMM won't recognise the tracks but shows them with a red line through them. This invariably means your directory path was wrong when you typed the perl command.

Once I have run the script, I open up the P*.cue file in notepad to check it for detail. Then I replace the file in the PHTDTA\Profiles\Default directory using Windows Explorer. I then do a Save and Eject of the DMS in PMM. I then reinsert the DMS, run PMM again and check that the tracks can be seen. I dont touch the P*.pbx file as PMM sorts this out for you if you follow my procedure.

So I guess I'm happy because it can be done, but it is a pain in the ass way of sorting out. I'm considering upgrading my DMS sooner than later now as I don't want to have to mess about reloading all these P*.cue files.

Oh yes, don't forget that Playlist 8 displayed in PMM will have a P*.m3u file P7.m3u not 8 because the playlist files start at Zero not One, if you follow.
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: walkAbout on December 21, 2006, 12:29:07 pm
Hi,

I simply do a copy/paste from the source path for the directory and for the cue as well. So I don't have to be careful. Give it a try. No more typing or mistyping, you will like it.

A GUI would also be fine, with a browse button to select the mp3 and cue file and then press something like "create m3u". But I cannot do it by myself, so I'm fine with this solution.

CU
walkAbout
Title: Re: Convert cue-sheets to m3u playlists for phatbo
Post by: AlanS on December 21, 2006, 03:35:46 pm
Copy and Paste, now why didn't I think of that doh! I'll try it.

Yes, a proper interface would be a dream, do you know anyone on here that could try, after all in this day and age of free mixes with supplied cue sheets, you would think everyone would be after a solution.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on April 11, 2007, 05:31:19 am
I can't get this to work for me.  I posted another thread about it before I found this.

After replacing the m3u file, Music Manage hangs at 99% initializing DMS 'reading playlists...'

Is everyone else using Media Manager.  I thought that wasn't an option with a hack DMS.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: VorTechS on April 11, 2007, 08:25:58 am
Not seen this topic before - and being a DJ myself, it's of mega interest to me as I want to start putting my own mixes on the DMS.

I've added this to my list of feature requests for PhatHack Media Manager.

:D
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on April 11, 2007, 01:14:56 pm
cool Vortech,
That is what I was thinking.  Even if one didn't have a Cue sheet.  Maybe during playback there is a button that adds a bookmark (timestamp) to the file, and splits into multiple tracks.

although I haven't tried PhathackMM yet, I plan to soon.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: VorTechS on April 11, 2007, 02:03:32 pm
Quote
That is what I was thinking.  Even if one didn't have a Cue sheet.  Maybe during playback there is a button that adds a bookmark (timestamp) to the file, and splits into multiple tracks.

I've been looking into wave form generation as a side thing, un-related to PhatHack Media Manager, as I often want to take samples from tracks on my DMS to use as ringtones for my mobile [cell] phone.

The plan would be to have a simple wave form 'editor' to allow you to add the relevant bookmarks [with playback options] and either generate a cue-sheet that will work with the DMS - or split the file according to the bookmarks. [Trans-coding is already in place for PhatHack Media Manager, and I can easily modify for track / bookmark offsetting].

This is another one of those things that I haven't seriously thought about yet though in terms of PhatHack Media Manager - and I'll leave it until we are actually manipulating the DMS correctly before I make a start on it with any gusto.

Quote
although I haven't tried PhathackMM yet, I plan to soon.

It'd be nice to have some more people joining the testing - for what there is to test.  I am generally using it on a day-to-day basis to playback from the DMS cartridge, and for loading up my MP3 player.  Hopefully soon we'll get to the point where we can really trash, er I mean, manipulate the DMS! :D
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: sbingner on April 13, 2007, 12:05:26 pm
I never actually USED this -- I only wrote it, so I can't tell you what versions of PMM it works with...  perhaps one of the others who have used it can fill you in...
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on April 14, 2007, 01:39:10 pm
It's not the perl script that I'm having a problem with.  I wasn't using it, as I don't have a cue sheet.

I'm having trouble just editing the m3u file, and getting it to play in the box.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: judb on April 14, 2007, 03:51:45 pm
how are you editing the file?  after you edit it what do you do?
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on April 15, 2007, 08:14:55 pm
I've tried this two different ways.
1. in P MusicManager, I copy the track to a playlist several times.  so there are say 5 tracks of the same song in one playlist.  then I save/eject the DMS, reinsert, and open the m3u file in the PHTDTA with notepad.  Now the playlist already has the 5 tracks, so I insert the timestamp after each filename per the instructions. (tab...)  Save the changes to the file, and do another Save/eject.
2. I just open the m3u file in notepad, make it look like I want it to, save the changes, and do a Save/Eject.

I'm going to try this with my Original DMS in Media Manager tonight to see if I get better results...

since the hack DMS won't work with Media manager.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: sbingner on April 15, 2007, 11:04:28 pm
You would need to NOT have media manager open when you edit it, if you hit save/eject it'll overwrite all your changes
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on April 16, 2007, 01:57:41 am
could I edit the phatcart backup, and then just restore a backup of the playlists?
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: sbingner on April 16, 2007, 03:01:37 am
Unless I'm missing something -- you would just need to create these m3u files manually, when PMM is closed... then you ought to be OK opening/closing PMM... again, I'm just going off what I know of how PMM works... if somebody who actually does this feels like chiming in it would be more authoritative ;)

Sam
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Anton on October 26, 2007, 08:01:59 pm
Still having some trouble here...
to be more specific, the playlist that I'm editing only has one track.  It is an Audiobook (non-audible), several hours long.  So I want to put in breaks so it is easier to skip forward and back in the file.

I've got the M3u file edited as I want, and I edit the pbx file to reflect the # of tracks.  the good news is PMM does not overwrite these files, however, it doesn't recognize multiple tracks.

I think my problem is with the m3u file.  PMM 2.3 will allow me to add multiples of the same track to a specific playlist.  PMM 3.92  will only let me add a specific track to a playlist just once.  Example, the original file:
#Kurlansky, Mark - Cod
/dos/data/eBook backup/Cod_A_Biography.wma


And if I add the same track three times to a playlist in PMM 2.3
#Kurlansky, Mark - Cod
/dos/data/eBook backup/Cod_A_Biography.wma
#Kurlansky, Mark - Cod
/dos/data/eBook backup/Cod_A_Biography.wma
#Kurlansky, Mark - Cod
/dos/data/eBook backup/Cod_A_Biography.wma


After editing: (and the .pbx file was changed to reflect 3 tracks.)
#Kurlansky, Mark - Cod1
/dos/data/eBook backup/Cod_A_Biography.wma     0       690
#Kurlansky, Mark - Cod2
/dos/data/eBook backup/Cod_A_Biography.wma     691    1594 
#Kurlansky, Mark - Cod3
/dos/data/eBook backup/Cod_A_Biography.wma     1595   -1


I numbered the track names, because I figured they couldn't be the same name.  Problem is this doesn't work.  tracks two and three don't play in PMM 2.3, they skip, and then stop.  would it be any different in the box?  Track one plays all the way through...

anyone reccomend a good WMA file splitter?  I figure I could just do it that way, and then have multiple files and add them to the playlist seperately.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: sbingner on October 26, 2007, 09:04:42 pm
Are you trying to play it from PMM, or from the PhatBox?

I wouldn't be surprised if this doesn't work in PMM at all
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: Terry_Kennedy on October 27, 2007, 03:03:46 am
Are you trying to play it from PMM, or from the PhatBox?

I wouldn't be surprised if this doesn't work in PMM at all

Right - this is only supported on the PhatBox.
Title: Re: Convert cue-sheets to m3u playlists for phatbox
Post by: VorTechS on October 27, 2007, 07:46:51 am
Just as a side note, I'd appreciate a copy of the files you are editing so I can build a CUE splitting function into PhatHack Media Manager... :)