Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: cuesplit.exe Alpha (Read 37745 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

cuesplit.exe Alpha

CUESPLIT
========
Neil Popham <neilpopham@bigfoot.com>, 2005

Version 0.1, 2005-03-24

CUESPLIT is a tool for converting WAVE image files into individual track files.

CUESPLIT will use an accompanying cuesheet to split a WAVE file into its component parts.  It will also run a specified command line on those track files, allowing the user to use foobar-style tags as placeholders for meta data taken from the cuesheet.

Current working syntax is:

CUESPLIT.EXE [--p] -c <path to cuesheet> -f <path to file> -r <command to run>

--p : prepend track one's pregap to track one's track file
-c : the path to the cuesheet
-f : the path to the WAVE file
-r : the command line to run on each track file

EXAMPLE USAGE
=============

CUESPLIT.EXE -c "C:\DOS\Alan Parsons\CDImage.cue" -f "C:\DOS\Alan Parsons\CDImage.wav" -r "C:\DOS\LAME.EXE" -V5 --ta "%artist%" --tt "%title%" --tn "%tracknumber%" --tl "%album%" --tc "%comment%" --tg "%genre%" %s "C:\DOS\@artist@\@album@\@tracknumber@ - @title@.mp3"

--

The above is taken from this text file.

This is something I've been thinking about for a while, so I thought I'd have a play. The intention is to incorporate it into my EAC > APE batch scripts, so I can archive to image format (APE) and transcode to MP3 all in one go. I.e.:

EAC > WAVE image
WAVE image > CUESPLIT > Track WAVEs > Track MP3s
WAVE image > MAC > APE image
etc.

I thought I'd post it now, at alpha stage (Please read the to-do!), just to see if anyone was interested.

Take a look at the application, but more importantly take a look at the text file - which explains the current logic, and what's on my to-do.

I'm quite pleased about the way CUESPLIT goes about things (notably the foobar tags, REM parsing, and the bit-accurate splitting) - but the main thing that bugs me about it is the fact that I've had to write it in VB6, so you get windows opening for each encoder call.  You can obviously still run it from the CMD prompt though (it's just that it will open a second shell to run LAME, etc.).

I had considered contacting Tangerine and seeing whether he would be interested in writing CUESPLIT by adapting his WAVSPLIT application.  I would like to see a proper command line version of this application... Perhaps my logic and someone else's Delphi/C/C++ skills is the answer...

All feedback welcome.
I'm on a horse.


cuesplit.exe Alpha

Reply #2
Quote
Hi Synthetic Soul,

Wow! I wrote a very similar command-line program before, but nobody on HA showed interests   . See:
http://www.hydrogenaudio.org/forums/index....showtopic=23488
Due to my web space, now it's available only at: http://nyaochi.sakura.ne.jp/xoops/modules/...php?cid=1&lid=2

It seems that people prefer foobar2000 to do this job. I should have written an English manual.

Now you tell me! 

I am familiar with your LAME patch - I've used it before, but there's no 3.96.1 version.  I see from your other post why, and can't say I blame you.  Even if there was I'd want a 3.97 version soon...

I see from the accompanying BAT files that ACDIR does support tags also. I really could do with an English explanation of the syntax though. 

Is the source available?  It would be interesting to see it after writing CUESPLIT.

Edit: Maybe if you give me the source I could write the readme for you, if you would rather not bother.  I should be able to deduce the syntax from the source... I think...

Quote
I should have written an English manual.

You see, I have decent documentation - it's just the application that's crap.
I'm on a horse.

cuesplit.exe Alpha

Reply #3
NB:  I was, and am still, aware that there are other WAVE splitting tools (including shntools and wavsplit) already in existance - but my requirement was for the flexible tagging that CUESPLIT, and it appears ACDIR, provides.

Another aspect of CUESPLIT - the INI file - may also be relevant here, as the intention is to allow users to encode to multiple encoders with one call (one excuse for writing to a file and not piping).
I'm on a horse.

cuesplit.exe Alpha

Reply #4
Thank you very much for the reply and understanding of the current situation.

Quote
I am familiar with your LAME patch - I've used it before, but there's no 3.96.1 version.  I see from your other post why, and can't say I blame you.  Even if there was I'd want a 3.97 version soon...

I ceased the patch because the situation around gapless MP3 playback has been changed a lot and we don't have to stick with it. Instead, I created a more generalized tool, ACDIR, because I wanted vorbis files as well after I owned iriver H120.

Quote
Is the source available?  It would be interesting to see it after writing CUESPLIT.
Edit: Maybe if you give me the source I could write the readme for you, if you would rather not bother.  I should be able to deduce the syntax from the source... I think...

I will release it under GPL shortly (after writing the build instruction). And it would be very helpful if you could write the English manual. I don't have spare time lately because I've just moved in UK from Japan. 

Quote
You see, I have decent documentation - it's just the application that's crap.


cuesplit.exe Alpha

Reply #5
Quote
Quote
Is the source available?  It would be interesting to see it after writing CUESPLIT.
Edit: Maybe if you give me the source I could write the readme for you, if you would rather not bother.  I should be able to deduce the syntax from the source... I think...
I will release it under GPL shortly (after writing the build instruction). And it would be very helpful if you could write the English manual. I don't have spare time lately because I've just moved in UK from Japan.

Please feel free to either email me at the address above, or PM me.

Welcome to the UK.  You will see from my profile that I live in Exeter, in Devon.

Quote
Quote
You see, I have decent documentation - it's just the application that's crap.

Well, I think I can explain exactly want I want the application to do, and what it currently does do, quite well.  However, I am not happy about the VB6 implementation at all.
I'm on a horse.

cuesplit.exe Alpha

Reply #6
1. I have compiled the following from ACDIR's command line help (which I only just discovered).  This may be useful to others.

Code: [Select]
Audio CD Image Reader (ACDIR) 0.5 alpha  Copyright © 2003-2005 by Nyaochi

Audio CD Image Reader (ACDIR) is a tool for audio images with cuesheets.


USAGE:

ACDIR [options] command [command-arguments] [options] targets

EXAMPLE:

ACDIR.EXE --output %t.wav --extract CDImage.cue


OPTIONS:

--help or -h      Show usage information

--output name      Substitute 'name' for the output file variable (%o)

--extra-opt opt    Substitute 'opt' for the extra option variable (%x)

--track range      Specify track range to be processed

--targets file    Specify targets by an external file list

--overwrite        Force to overwrite existing output files


COMMANDS:

--exec      Execute expression for each track in cuesheets
            USAGE:  ACDIR [options] --exec expression cuesheet1 [cuesheet2 ...]

--pipe      Execute expression for each track with stdin redirection
            USAGE:  ACDIR [options] --pipe expression cuesheet1 [cuesheet2 ...]

--echo      Evaluate and show the expression (test only, no execution)
            USAGE:  ACDIR [options] --echo expression cuesheet1 [cuesheet2 ...]

--extract    Extract tracks to specified output files (use --output option)
            USAGE: CDIR [options] --extract cuesheet1 [cuesheet2 ...]

--find      Find cuesheets recursively in a directory that match the specified pattern
            USAGE:  ACDIR [options] --find directory pattern


VARIABLES:

Format:

{%|$}[#]<variable-name>

A variable begins with either '%' or '$' (for batch file use)

An optional character '#' quotes the value with '"'

Available variables are:

%f    Filename of the audio image (e.g. CDImage.wav)
%p    Path to the cuesheet file
%d    Path to the cuesheet file with substitution of '_' for '\'
%o    Output filename (evaluation result of --output argument)
%x    Extra options (specified in --extra-opt argument)
%t    Title of the track (e.g. White Album)
%T    Title of the CD image (e.g. Back in the U.S.S.R.)
%a    Performer of the track (e.g. The Beatles)
%A    Performer of the CD image (e.g. The Beatles)
%n    Track number (e.g. 01)
%N    Number of tracks in the CD image (e.g. 17)
%q    Double-quotation character, '"'
%s    Start time of the track (INDEX 01)
%S    Start time of the track (INDEX 00 if any, otherwise INDEX 01)
%e    End time of the track (INDEX 01)
%E    End time of the track (INDEX 00 if any, otherwise INDEX 01)


COMMAND LINE HELP:

--help or -h        Show usage information
--help-options      Show a list of options
--help-variables    List available variables with description
--help-commands    Show a list of commands

-h followed by a command name for command-specific help
2. @nyaochi : Is there any way you can provide an additional variable switch to turn the variable into a valid file or folder name?

E.g.:

ACDIR.EXE --output "%n - %~t.wav" --extract CDImage.cue

The tilde would instruct ACDIR to remove illegal characters from the track title.

I've only just begun to test, but I've already fallen foul of an illegal character, which caused ACDIR to fail on that track.

3. My WAVE files match those created by Foobar and WavSplit byte for byte.  There is a discrepancy in the RIFF header between CUESPLIT's and ACDIR's (byte #4 - ACDIR's value is 4 bytes less).  I assume libsndfile deals with this?  I have checked the header spec and I'm pretty sure mine is accurate.  Anyone know whether this inaccuracy in the chunk size (bytes 4-7) means diddly? "This is the size of the                                entire file in bytes minus 8 bytes for the two fields not included in this count:                          ChunkID and ChunkSize."
I'm on a horse.

cuesplit.exe Alpha

Reply #7
Quote
2. @nyaochi : Is there any way you can provide an additional variable switch to turn the variable into a valid file or folder name?

E.g.:

ACDIR.EXE --output "%n - %~t.wav" --extract CDImage.cue

The tilde would instruct ACDIR to remove illegal characters from the track title.

I've only just begun to test, but I've already fallen foul of an illegal character, which caused ACDIR to fail on that track.

You mean removing characters such as :\?*<> which are not acceptable for a filename. Would it be fine just removing them?

I never thought about that because I don't use %t for naming files.

Quote
3. My WAVE files match those created by Foobar and WavSplit byte for byte.  There is a discrepancy in the RIFF header between CUESPLIT's and ACDIR's (byte #4 - ACDIR's value is 4 bytes less).  I assume libsndfile deals with this?  I have checked the header spec and I'm pretty sure mine is accurate.  Anyone know whether this inaccuracy in the chunk size (bytes 4-7) means diddly? "This is the size of the                                entire file in bytes minus 8 bytes for the two fields not included in this count:                          ChunkID and ChunkSize."
[a href="index.php?act=findpost&pid=285243"][{POST_SNAPBACK}][/a]

I confirmed this was a bug.  I don't use libsndfile for writing WAVE to an output stream. I miscalculated the value. Thank you for reporting this.

I'll update the binary shortly.

cuesplit.exe Alpha

Reply #8
Quote
You mean removing characters such as :\?*<> which are not acceptable for a filename. Would it be fine just removing them?

I never thought about that because I don't use %t for naming files.

Removing them would be fine.  I was planning to add a switch to CUESPLIT that would let the user supply a string of characters that were replacement characters. I.e.:  the characters that need replacing are \/:*?"<>|, so if the user would submit their replacement characters in the same order.  CUESPLIT currently replaces them all with a space.

Quote
I confirmed this was a bug.  I don't use libsndfile for writing WAVE to an output stream. I miscalculated the value. Thank you for reporting this.

I'll update the binary shortly.

Cool.  Glad to be of help.

I'm really looking forward to working with ACDIR.
I'm on a horse.

cuesplit.exe Alpha

Reply #9
I released ACDIR 0.6 alpha.
http://nyaochi.sakura.ne.jp/xoops/modules/...php?cid=1&lid=2

@Synthetic Soul,
I decided to add a routine to legitimate the value of variable %o instead of your suggestion. I created a new undocumented option "--legitimate-output" which is activated by default. Then you don't have to change your variable template at all. If you specify "--legitimate-output=no" in ACDIR command-line, the value of %o variable won't be changed/converted.

cuesplit.exe Alpha

Reply #10
Woah.  Fast work!

Thanks for the mentions.

I look forward to testing...
I'm on a horse.

cuesplit.exe Alpha

Reply #11
Ah, just spotted a problem.

Because you are removing all the invalid filename characters across the board you can no longer create directories.  The following will no longer work as required:

ACDIR.EXE --output "%A\%T\%n - %t.wav" --extract CDImage.cue

I get:

Extracting track 1 to Kings Of Leon Aha Shake Heartbreak 01 - Slow Night, So Long.wav
Extracting track 2 to Kings Of Leon Aha Shake Heartbreak 02 - King Of The Rodeo.wav
... etc.

However, you can't just allow "\", as if one is found in a tag it will cause problems.

I think you may have to apply to replace one tag at a time...
I'm on a horse.

cuesplit.exe Alpha

Reply #12
Quote
Ah, just spotted a problem.

Because you are removing all the invalid filename characters across the board you can no longer create directories.  The following will no longer work as required:

ACDIR.EXE --output "%A\%T\%n - %t.wav" --extract CDImage.cue

I get:

Extracting track 1 to Kings Of Leon Aha Shake Heartbreak 01 - Slow Night, So Long.wav
Extracting track 2 to Kings Of Leon Aha Shake Heartbreak 02 - King Of The Rodeo.wav
... etc.

However, you can't just allow "\", as if one is found in a tag it will cause problems.

I think you may have to apply to replace one tag at a time...
[a href="index.php?act=findpost&pid=285277"][{POST_SNAPBACK}][/a]

I should have known this. I will re-update it.


cuesplit.exe Alpha

Reply #14
That works well.

Thank you very much.
I'm on a horse.

cuesplit.exe Alpha

Reply #15
Great work, Synthetic Soul. I must have missed this post. I'm using Flacattack as a basis to write a new program that will allow all types of encoders. It will be similar to M.A.R.E.O. but will allow you to encode to any assortment of image files and individual files. I am currently using a call to wavsplit, but cuesplit looks like it may be more robust.

As part of the program, I need to convert an image file cuesheet to an individual file cuesheet. Do you know of any program that already does this or could this be a feature of cuesplit? Do you have the source of cuesplit available? Thanks.

cuesplit.exe Alpha

Reply #16
Another brilliant way to cut would be to use DPSGuru's BeSplit!
It is able to cut/split: WAV/AC3/AAC/MPA/MP3/MP2/MP1/PCM/DTS/DTS-WAV
It also fixes corrupt streams, removes WAV headers etc.

As for the command line you may use the web to create one out of a list of track times, be it from
  • freedb.org,
  • a Winamp generated playlist
  • or a CUE file
and it will generate the command line for Besplit.

Website: http://www.delta-hf.co.uk/freedbesplit/

Or just generate one yourself.
Or use the CUE-File cutter GUI (although its in italian  )
BeSplit's a GEM!

cuesplit.exe Alpha

Reply #17
Quote
I'm using Flacattack as a basis to write a new program that will allow all types of encoders. It will be similar to M.A.R.E.O. but will allow you to encode to any assortment of image files and individual files.

This new application sounds great.  It's something I would have liked to attempt, but just do not have the time.  It seems there is a definite call for an easy to use app that will allow you to write to multiple image formats and multiple track formats in the same run.  Good luck.

Quote
I am currently using a call to wavsplit, but cuesplit looks like it may be more robust.

I used a few references to help me build CueSplit - one of which was Tangerine's WavSplit source code.  I don't know if CueSplit is any more robust than WavSplit. As I noted earlier in the thread: I am pleased that the WAVE files produced appear 100% accurate (I believe WavSplit's are also, I haven't tested as thoroughly).  However, I think the main thing CueSplit has going for it over any other is the comprehensive meta data parsing.  I was quite pleased with that.

CueSplit (or more accurately VB6) really falls down over the command line I'm afraid.  If you call it from a normal command line it will begin CueSplit, but then continue without waiting.  I'm sure there is some way you can wait for CueSplit to complete, but I don't know.  Basically, I'm pleased with the concept of CueSplit - but the VB6 implementation really lets it down in my opinion.  I have considered moving to a .NET console app for both CueSplit and CueMake.

I'm personally very keen for ACDIR to progress and become my application of choice. It's a "proper" command line application, and I know nyaochi is planning to build in support for FLAC and maybe WavPack, as well as the existing WAVE and APE support.  It supports piping which CueSplit currently doesn't.

Quote
As part of the program, I need to convert an image file cuesheet to an individual file cuesheet. Do you know of any program that already does this or could this be a feature of cuesplit? Do you have the source of cuesplit available? Thanks.

I don't know of a program that does that (apart from perhaps foo_cue_ex in previous versions), however it would be very, very easy to do.  I had considered making it part of my other recent little app, CueMake.  I mean, all you have to do is create a track entry for each track with a FILE command and INDEX 01 00:00:00.

When I wrote CueSplit I was wondering whether I could adapt WavSplit, or ask Tangerine to do it - then I decided "Hey, it may be fun to do it myself".  Similarly, with CueMake I wanted to use Foobar to create the image file and the accompanying cuesheet.  I then thought I could make the cuesheet myself, using what I'd learnt from CueSplit - then I thought "If I'm iterating through the WAVE files to build the cuesheet I may as well glue them together at the same time".

What am I on about?  I think you should write your own WAVE parser.  I couldn't believe how easy it was once I'd got to grips with a few things.  All the info you need is in the WAVE header.  Once you know your way around the header (there's only 13 parts, a few of which are of no real use) you can do anything you'll need.  I've had very little experience working with binary files previously, and I managed it.  The real breakthrough was creating the UDT (user-defined type) "WaveHeader" (see source) - which then let me access the header with complete ease.  WavSplit uses byte positions to access parts of the header, which makes things look very difficult.

If you write your own you'd have a lot more flexibility.

If you don't want to write your own I'd think about ACDIR.  I'm yet to have a proper look at tas' BeSplit - but it doesn't look like it has direct cuesheet support.  ACDIR could be very good.

The source of CueSplit can be found here.  I have also uploaded the source of CueMake.  I am by no means now an expert in WAVE file parsing now, but if I can be of any help I'd be very pleased to be of service.
I'm on a horse.

cuesplit.exe Alpha

Reply #18
Quote
As part of the program, I need to convert an image file cuesheet to an individual file cuesheet. Do you know of any program that already does this or could this be a feature of cuesplit? Do you have the source of cuesplit available? Thanks.
[{POST_SNAPBACK}][/a]

I'm not sure if I'll get what you mean, but [a href="http://www.burrrn.net/]Burrrn's[/url] CUEditor has an option "Split Into Tracks - Create a separate .cue file for each track".
"ONLY THOSE WHO ATTEMPT THE IMPOSSIBLE WILL ACHIEVE THE ABSURD"
        - Oceania Association of Autonomous Astronauts

cuesplit.exe Alpha

Reply #19
Quote
Quote
As part of the program, I need to convert an image file cuesheet to an individual file cuesheet. Do you know of any program that already does this or could this be a feature of cuesplit? Do you have the source of cuesplit available? Thanks.
[{POST_SNAPBACK}][/a]

I'm not sure if I'll get what you mean, but [a href="http://www.burrrn.net/]Burrrn's[/url] CUEditor has an option "Split Into Tracks - Create a separate .cue file for each track".
[a href="index.php?act=findpost&pid=288209"][{POST_SNAPBACK}][/a]


No, I meant take a cuesheet that is meant for an image file and convert it to the EAC Non-compliant format.

>>Synthetic Soul. Thanks for all that. I had started a few weeks ago to create my own converter, but thought I might see what was already available. Do you have any good references about WAV headers? I'll probably just do a Google search and I'm sure I'll find something. I'll also have a look at your source. This doesn't sound like it will be too difficult to do though as you have desribed it (writing a WAV parser).

cuesplit.exe Alpha

Reply #20
Quote
I had started a few weeks ago to create my own converter, but thought I might see what was already available. Do you have any good references about WAV headers? I'll probably just do a Google search and I'm sure I'll find something. I'll also have a look at your source. This doesn't sound like it will be too difficult to do though as you have desribed it (writing a WAV parser).

I used:
http://www.ringthis.com/dev/wave_format.htm
http://ccrma.stanford.edu/courses/422/projects/WaveFormat/

I know there's something to be said for not reinventing the wheel, but I think your app will be a lot more flexible if you create your own, as you can make decisions knowing the users exact requirements (like whether to pipe or create temporary WAVE files).

Since posting I have actually had a little play in VB.NET.  I've got a class, "WaveFile", from which you can load and (soon) save WAVE data.  The idea will be that you create your WaveFile object, load a WAVE file into it, and then manipulate it as you see fit.

It is my wish to expand this into a set of classes to manipualte WAVE and CUE files - with the intention of converting CueSplit and CueMake into a .NET console app.  However, unfortunately I have a severe lack of free time at the moment.

If I end up with anything that I think will be of use I'll pass it on (I assume you are writing this new app in C#).
I'm on a horse.

cuesplit.exe Alpha

Reply #21
Thanks for the links. It is true that it might be better to have the option of piping instead of creating temp waves. I hadn't thought of that. This would most likely only be true if the user were only encoding to one set of individual files (only choosing one encoder instead of multiple). It is good to have options though.

I'd be very interested to see a set of classes that deal with wave files and cue sheets. That would make it very easy to deal with them. Good luck with VB.NET. C# has not been too bad. I'm no expert by any means but I've been able to do most things I wanted.

This new app is written in C#. Right now I've got it working fairly well. It relies on one (maybe 2, another for general settings) ini files for encoder settings, supports replaygain (for formats that allow it). Right now I'm working on the cuesheet conversion aspects. The program requires that the user create a image file with a cuesheet. When the user chooses to encode to individual files for some format, the original cuesheet no longer works, so I want to update the cuesheet to match the new set of files. This includes index00 and index01 values. I wrote the code last night to find these new values after looking at an explanation that Tangerine had given about WavSplit. However, I read one of your posts about CueMake and the problem you encountered when dealing with waves that aren't standard (you can't just use the 2352 constant, which is what I'm doing). I'll have to look at your code to see how you worked around that.

Good luck with CueMake and finding time to work on it.

cuesplit.exe Alpha

Reply #22
Quote
I read one of your posts about CueMake and the problem you encountered when dealing with waves that aren't standard (you can't just use the 2352 constant, which is what I'm doing). I'll have to look at your code to see how you worked around that.

The answer was staring me in the face with the WAVE header (it's all there somewhere).

Bytes 28-31 provide the bytes per second (Int32 value).  I stopped converting to frames, etc. and simply used Bytes / BytesPerSecond to find the number of seconds.  Simple!

I didn't use it to start as I hadn't bothered looking at any other parts of the header than I needed, which was only the FileSize (4-7) and DataSize (40-43) I think.

It was this page that first got me using the header info to calculate the number of samples, and to use that with the SampleRate (24-27).  Finally another glance at the header info lead me to BytesPerSecond - a quite obvious friend. 

You'll see this in CueMake's modMain:

Code: [Select]
Trace "  Samples: " & lngTotalBytes / (objHeader.Channels * (objHeader.BitsPerSample / 8))
Trace "  Seconds (old): " & (lngTotalBytes / (objHeader.Channels * (objHeader.BitsPerSample / 8))) / objHeader.SampleRate
Trace "  Seconds (cur): " & lngTotalBytes / objHeader.BytesPerSecond

Of course, you should only be dealing with 2 channel 44.1kHz 16 bit WAVE files - having been ripped from CD - but it is nice to know that the code you write can cope with other formats also, for use elsewhere.
I'm on a horse.


cuesplit.exe Alpha

Reply #24
Quote
CUESPLIT
========
Neil Popham <neilpopham@bigfoot.com>, 2005

Version 0.1, 2005-03-24

CUESPLIT is a tool for converting WAVE image files into individual track files.
All feedback welcome.
[a href="index.php?act=findpost&pid=285187"][{POST_SNAPBACK}][/a]


Hi. Thanks for this nice tool. It seems to me the kind of tool I was searching for.

Question: How do you handle pauses. Will they be added to the last track, the current track, or will they be removed?