Author Topic: Convert cue-sheets to m3u playlists for phatbox  (Read 30141 times)

0 Members and 3 Guests are viewing this topic.

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Convert cue-sheets to m3u playlists for phatbox
« 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
  

Offline judb

  • Administrator
  • Veteran.
  • *****
  • Posts: 1329
  • ph4t l3wtz
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #1 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.

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #2 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

Offline sbingner

  • Administrator
  • Veteran.
  • *****
  • Posts: 1301
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #3 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
« Last Edit: October 25, 2006, 08:41:03 pm by sbingner »

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #4 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

Offline Terry_Kennedy

  • Moderator
  • Veteran.
  • *****
  • Posts: 253
  • There and back again
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #5 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.

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #6 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

Offline Terry_Kennedy

  • Moderator
  • Veteran.
  • *****
  • Posts: 253
  • There and back again
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #7 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.


Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #8 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

Offline AlanS

  • Newbie
  • Posts: 3
  • PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #9 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.

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #10 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

Offline AlanS

  • Newbie
  • Posts: 3
  • PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #11 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.

Offline walkAbout

  • A few posts under my belt.
  • *
  • Posts: 21
  • Techie and PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #12 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

Offline AlanS

  • Newbie
  • Posts: 3
  • PhatHacker
Re: Convert cue-sheets to m3u playlists for phatbo
« Reply #13 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.

Offline Anton

  • Needs to get outside.
  • ***
  • Posts: 116
  • I'll figure it out
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #14 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.

Offline VorTechS

  • Administrator
  • Veteran.
  • *****
  • Posts: 1678
  • PhatHack Media Manager & DMS Tools Wizard Author
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #15 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
Kenwood KDC-W7031 | Kenwood KHD-CX910 | 250GB DMS | PhatHack Media Manager v1.1.4 (Alpha) | VIOT

Catch me weekdays 8am-4pm GMT on IRC @ irc.freenode.net on channel #phathack (aka the chat link!!)

Offline Anton

  • Needs to get outside.
  • ***
  • Posts: 116
  • I'll figure it out
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #16 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.
« Last Edit: April 11, 2007, 01:17:02 pm by Anton »

Offline VorTechS

  • Administrator
  • Veteran.
  • *****
  • Posts: 1678
  • PhatHack Media Manager & DMS Tools Wizard Author
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #17 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
Kenwood KDC-W7031 | Kenwood KHD-CX910 | 250GB DMS | PhatHack Media Manager v1.1.4 (Alpha) | VIOT

Catch me weekdays 8am-4pm GMT on IRC @ irc.freenode.net on channel #phathack (aka the chat link!!)

Offline sbingner

  • Administrator
  • Veteran.
  • *****
  • Posts: 1301
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #18 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...

Offline Anton

  • Needs to get outside.
  • ***
  • Posts: 116
  • I'll figure it out
Re: Convert cue-sheets to m3u playlists for phatbox
« Reply #19 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.