How to split a sound file (mp3/wav/ogg/flac) accordingly to a CUE sheet? And viceversa?

Asked by Uqbar

I'd like to be able to split sound files into chunks accordingly to a CUE sheet file or, viceversa, create a single sound file and a CUE sheet file from a number of sound files.
Thanks for the hints.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
David Friedman
Solved:
Last query:
Last reply:
Revision history for this message
Uqbar (uqbar) said :
#1

OK. I learned that the first question is trivial as far as I convert the sound file to WAV. I can use bchunk.
But I still don't know how to do it the other way around.

Revision history for this message
David Friedman (david-kit-friedman) said :
#2

I don't think it is at all difficult to concatenate a bunch of sound files together. You could probably use something like audacity for this purpose:

http://sourceforge.net/projects/audacity/

Do you have a lot of files that you need to concatenate and make CUE sheets from? I don't know if there exists a script or program that would automate the process for you.

However, if you don't have too many I might just concatenate the files together using Audacity, and then write the CUE file using a text editor (e.g. notepad).

Maybe audacity might have some feature that automates this process.

Links:

http://mediacoder.sourceforge.net/wiki/index.php/Cue_sheet

Revision history for this message
Uqbar (uqbar) said :
#3

Well, I do need an automated way to do it.
Audacity is a GUI that needs human intervention.
A CLI based solution would be better.
Any hint?

Revision history for this message
David Friedman (david-kit-friedman) said :
#4

Uqbar,

Is it that you have a particular fixed data set and are just looking for a method to process it? Or are you looking for an application that you could use for now and also in the future?

I might be able to write a script or program that could concatenate the audio files and generate the CUE file. I could distribute this to the community so that other people could use it as well.

For example, handling WAV files might not be that difficult. The other file types I think would need libraries to do the concatenation (and for MP3 there is also royalty/intellectual property issues as well)

David

Revision history for this message
David Friedman (david-kit-friedman) said :
#5

Apparently, there already exists some software that can concatenate WAV files together.

http://sourceforge.net/projects/waveproject/

This isn't too difficult since I think it is mostly just a matter of stripping the headers, combining the bytes, and then recreating the header.

So a simple workflow would be to convert the files to WAV, concatenate them, and then convert the combined file back to OGG/Flac etc.

This could take some time depending on the size of the files, and also the WAV files will be large, but they can be deleted afterwards. There may also be some distortion etc. introduced in the process of encoding/decoding.

So maybe I could start by writing a script that would just handle WAV files, and generate the CUE file.
(waveproject doesn't handle this).

David

Revision history for this message
David Friedman (david-kit-friedman) said :
#6

Another thing to look into would be an audacity plugin for this purpose. I'm looking now at:

http://audacityteam.org/wiki/index.php?title=Creating_your_own_Plug-in

Revision history for this message
David Friedman (david-kit-friedman) said :
#7

After researching this a little more, I think the question is why would a user want to go in the other direction. For what reason would you want to concatenate all the files together?

I can see why you might want to split them. You might want to take the songs that you like, or organize the songs in some way.

Some reasons why you might end up with a large file with a CUE sheet is:

1) The CD was burned from a live recording
2) The burner software was designed to create one large file with a CUE sheet (Medieval software lists as few that did this:

"Usually these couple of files are generated by programs like EAC (Exact Audio Copy), CDRWin, BPM Studio, GoldWave or similar."

http://www.medieval.it/content/view/28/70/

)

In this case you can use bchunk or mp3splt to get individual files.

There is a command line interface audio program that can concatenate sound files together it is called sox:

http://sox.sourceforge.net/

David

Revision history for this message
Uqbar (uqbar) said :
#8

I have a CD whose tracks needs to be played with the correct inter-track timing.
Some of them need no pause in between, some other do.
So I have a CUE file (I can generate one by myself) and the splitted sound files.
Simply concatenating them won't work!

Revision history for this message
David Friedman (david-kit-friedman) said :
#9

Uqbar,

I looked into this, and I'd like to help you if possible.

First let me make sure that I understand the problem.

Let's say we have four files:

Kentucky Days 3:24 3:24
Lazy Bill 2:21 5:45
Little by Little and Bit by Bit 2:59 8:44
Keep in the Middle of the Road 2:25 11:09

(these don't necessarily represent my musical taste :-) )

http://launchpadtest.webs.com/kentucky_days.ogg
http://launchpadtest.webs.com/lazy_bill.ogg
http://launchpadtest.webs.com/little_by_little.ogg
http://launchpadtest.webs.com/middle_of_the_road.ogg

We have a CUE sheet which specifies a PREGAP of 5 seconds before the 2nd track, 8 seconds before the 3rd track, and 10 seconds before the 4th track.

http://launchpadtest.webs.com/test.cue

From the other files we generate master.wav which will be used by the CD burning program wodim.

David

Revision history for this message
Best David Friedman (david-kit-friedman) said :
#10

Uqbar,

I can just post the rest of what I did. Also, if you'd prefer the files I used are also on:

http://www.archive.org/details/BillyMurray_part3

I renamed them and also clipped off some of the end of "Little by Little and Bit by Bit" because there was a lot of silence at the end of the file, so with the unmodified files the procedure would be the same, but of course the numbers will be different.

===========

The next step is to create master.wav:

The pre-compiled sox package downloaded using synaptic does not
include support for ogg files, so you need to download sox from the
sox website and compile it from source. Make sure that you have the
libraries needed for processing ogg files.

At least two of these are:

libogg-dev
libvorbis-dev

and there may be others.

When you run the sox configure script just make sure that it indicates
support for ogg files.

After sox is compiled you can run it from the src directory to
concatenate all the ogg files together:

sox kentucky_days.ogg lazy_bill.ogg little_by_little.ogg middle_of_the_road.ogg master.wav

The number of samples in master.wav needs to be a multiple of
588.

The number of samples that I got when I concatenated them was: 29923388.

The total number of samples can be found using:

sox master.wav output.wav stat
rm output.wav

Although this took a long time on my machine when processing one of
the ogg tracks (it computes a lot of other stuff), so I just used audacity.

The number of samples needs to be trimmed so that it is a multiple of 588.

One way to trim it is to use audacity. However, you can also use sox.

sox master.wav master_new.wav trim 0 29923320s
rm master.wav
mv master_new.wav master.wav

The next step is to use wodim to burn the CD using the CUE sheet.

wodim -dao cuefile=test.cue

The documentation says that the cuefile option requires -dao (session
at once mode) and that the session at once mode option requires MMC
drives that support this mode. My CD-ROM is pretty old, (about seven
or eight years maybe), but it still has this support and it burned the
CD alright from the CUE sheet.

It seems to me that most people probably would be alright just using brasero or k3b but that the CUE sheet can give a finer level of control over how exactly the tracks are laid out.

David

Revision history for this message
Uqbar (uqbar) said :
#11

Thanks David Friedman, that solved my question.