Help - Search - Members - Calendar
Full Version: Create single FLAC image from multiple FLAC files and cue sheet
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
gsa999
Hi
Is it possible to create a single Flac or a WAV image from multiple FLAC files and a cue sheet, without reripping the CD.
Thanks
Synthetic Soul
foobar's "Convert" > "Convert to Album Images with Cuesheet or Chapters" Converter option would be my choice. As you are outputting to FLAC it will embed the cuesheet in the file.

Edit:
QUOTE(gsa999 @ Jun 28 2007, 12:30) *
or a WAV image
If you convert to WAVE image foobar will create an accompanying external .cue file.
Fandango
No, as of version 0.9 foobar2000 does not work with non-compliant cue sheets (quote: "from multiple FLAC files and a cue sheet") anymore. It never officially supported them anyway.

Besides foobar2000 does not understand any other INDEX than 01. So pre-gaps may be lost when creating an Album Image from a multi-file+non-compliant rip if that worked. But I might be wrong and this limitation applies only to fb2k's ripper.

If you want a simple GUI solution then there's the CUETools:
http://www.hydrogenaudio.org/forums/index....showtopic=50113
It supports WAV, FLAC and WavPack. But it requires .NET2.
gsa999
Tried loading the cuesheet into Foobar as Synthetic Soul suggested, but get an error message. I can load the individual flac files and choose the option to convert all these to flac or wav image and cue sheet, but as Fandango indicates I think I am probably losing the gaps with this option (since foobar is not referring to the cue sheet at all) and therefore the image is not a true representation of the original CD.

Haven't tried cuetools yet, maybe that will work with the non compliant cue sheet.

Regards
Synthetic Soul
Yes, it will. Sorry, I didn't consider that you had a non-compliant cuesheet - even though that was the most likely option. blush.gif
collector
Once in a while, when I need an image from loose flac's, I convert them to a virtual CD and rip this at a 200x speed. The noncompliant cue sheet you can simply edit to an 'alt-O' one and even to an alt-S sheet, like in EAC. But maybe the well-advised Foobar can help.
greynol
I may have posted this somewhere else, but here's a batch file that I wrote that will make a compliant sheet from a noncompliant one:
CODE
@ECHO OFF

CD /D "%~dp1"

SET _outfile="%~dpn1 (compliant).cue"
SET _tempfile=%TEMP%\~cueconv.tmp
IF EXIST %_tempfile% DEL %_tempfile%
SET _out=%_tempfile%
SET _line=
SET _skip=
SET _track=0
GOTO start

:get_next_line
SET _prev_line=%_x%
SET /A _line+=1
SET _skip=skip=%_line%

:start
FOR /F "usebackq tokens=1,2* %_skip%" %%X IN (%1) DO (
SET _x=%%X
SET _y=%%Y
SET _z=%%Z
GOTO generate_cue
)
IF EXIST %_tempfile% (
TYPE %_tempfile%>>%_outfile%
DEL %_tempfile%
)
GOTO end

:generate_cue
IF %_x% == TRACK GOTO track
IF %_x% == FILE GOTO file
IF %_x% NEQ INDEX GOTO other
IF %_y% == 00 GOTO 00_index
:other
IF %_track% NEQ 0 (
IF %_x% NEQ FILE SET _x= %_x%
)
IF DEFINED _z (
ECHO %_x% %_y% %_z%>>%_out%
GOTO get_next_line
)
IF DEFINED _y (
ECHO %_x% %_y%>>%_out%
GOTO get_next_line
)
ECHO %_x%>>%_out%
GOTO get_next_line

:track
SET /A _track+=1
IF %_prev_line% == INDEX SET _out=%_tempfile%
ECHO TRACK %_y% AUDIO>>%_out%
GOTO get_next_line

:file
IF %_out% == %_outfile% GOTO other
TYPE %_tempfile%>>%_outfile%
DEL %_tempfile%
ECHO %_x% %_y% %_z%>>%_outfile%
SET _out=%_outfile%
GOTO get_next_line

:00_index
SET _00_index=%_x% %_y% %_z%
SET /A _line+=1
SET _skip=skip=%_line%
FOR /F "usebackq tokens=1* %_skip%" %%X IN (%1) DO (
SET _x=%%X
SET _y=%%Y
GOTO got_next_line
)
:got_next_line
IF %_x% == FILE (
ECHO %_x% %_y%>>%_outfile%
TYPE %_tempfile%>>%_outfile%
DEL %_tempfile%
SET _out=%_outfile%
GOTO get_next_line
)
ECHO %_00_index%>>%_out%
ECHO %_x% %_y%>>%_out%
GOTO get_next_line

:end

To use it, I just drag and drop a cue sheet onto the batch file. It should work via command line also.

In order to copy the code, pretend like you're going to reply to this post first and then copy what's in the reply; otherwise, critical formatting information will be lost.
gsa999
QUOTE(greynol @ Jun 30 2007, 02:54) *

I may have posted this somewhere else, but here's a batch file that I wrote that will make a compliant sheet from a noncompliant one:

Thanks, this seems to work - thanks greynol.
I can now load the cuesheet into foobar and convert to a single flac or wav image, although I am still not convinced that I have the gaps restored. I only seem to have an Index 01 line in the resulting cue sheet, whereas I thought I was expecting to see and Index 00 and an Index 01 line.

Regards
greynol
You cannot have a compliant cue sheets with gaps appended to the previous track. In order to make them compliant the 00 indices must be discarded.

If you want to make a single file image cue sheet from one for separate files, I have batch for this also. wink.gif

For Monkey's Audio files, it requires the program, shntool. For flac files, it requires metaflac.

CODE
@ECHO OFF

CD /D "%~dp1"

SET _outfile="%~dpn1 (single wav).cue"

IF EXIST %_outfile% (
ECHO "%~n1 (single wav).cue"
ECHO already exists!
ECHO.
ECHO Press any key to end . . .
PAUSE>nul
GOTO end
)

SET _line=
SET _skip=
SET _track=0
SET _total_frames=0
SET _correct_cue=
SET _tempfile=%TEMP%\~imgcue.tmp

GOTO start

:get_next_line
SET /A _line+=1
SET _skip=skip=%_line%

:start
FOR /F "usebackq tokens=1,2* %_skip%" %%X IN (%1) DO (
SET _x=%%X
SET _y=%%Y
SET _z=%%Z
GOTO generate_cue
)
GOTO end

:generate_cue
IF "%_x%" == "FILE" (
CALL :file "%~dp1%_y:~1% %_z:~0,-5%
GOTO check_for_error
)
IF "%_x%" == "PREGAP" (
IF %_track% GTR 1 (
IF "%_correct_cue%" NEQ "c" (
GOTO leftout_gaps
) ELSE (
GOTO lg_index
)
)
)
IF "%_x%" NEQ "INDEX" GOTO other
IF "%_z%" == "00:00:00" (
GOTO start_index
) ELSE (
GOTO non_start_index
)
:other
IF %_track% NEQ 0 (
IF "%_x%" == "TRACK" (
SET _x= TRACK
) ELSE (
SET _x= %_x%
)
)
IF DEFINED _z (
ECHO %_x% %_y% %_z%>>%_outfile%
GOTO get_next_line
)
IF DEFINED _y (
ECHO %_x% %_y%>>%_outfile%
GOTO get_next_line
)
ECHO %_x%>>%_outfile%
GOTO get_next_line


:start_index
IF "%_y%" == "01" GOTO new_start_index
IF "%_correct_cue%" == "" GOTO corrected_gaps
IF /I "%_correct_cue%" == "p" GOTO get_next_line

:new_start_index
CALL :format_index %_prev_ftotal%
ECHO INDEX %_y% %mm%:%ss%:%ff%>>%_outfile%
GOTO get_next_line


:non_start_index
IF "%_y%" == "01" (
IF /I "%_correct_cue%" == "p" (
CALL :new_00_index %_z%
GOTO new_start_index
)
)
CALL :extract_index %_z%
SET /A _iframes=_prev_ftotal + mm*4500+ss*75+ff - _pregap
CALL :format_index %_iframes%
ECHO INDEX %_y% %mm%:%ss%:%ff%>>%_outfile%
GOTO get_next_line


:new_00_index
CALL :extract_index %1
SET /A _pregap=mm*4500+ss*75+ff
IF %_track% == 1 GOTO pregap
SET /A _iframes=_prev_ftotal - _pregap
CALL :format_index %_iframes%
ECHO INDEX 00 %mm%:%ss%:%ff%>>%_outfile%
GOTO :eof

:pregap
ECHO PREGAP %1>>%_outfile%
GOTO :eof


:file
IF EXIST "%~n1.wav" (
CALL :wav "%~n1.wav"
GOTO :eof
) ELSE (
IF EXIST "%~n1.flac" (
GOTO flac
) ELSE (
IF EXIST "%~n1.ape" (
GOTO ape
) ELSE (
ECHO "%~n1"
ECHO does not exist as .wav, .flac, or .ape!
SET _error=2
GOTO :eof
)
)
)

:flac
metaflac --show-total-samples "%~n1.flac">%_tempfile%
FOR /F "usebackq" %%A IN (%_tempfile%) DO (
SET length=%%A
GOTO got_metaflac_data
)
:got_metaflac_data
SET /A _boundry=length%%588
IF %_boundry% GTR 0 (
ECHO The time for
ECHO "%~n1"
ECHO cannot be accurately calculated.
ECHO.
ECHO The file may not end on a frame boundry.
SET _error=3
GOTO :eof
)
SET /A _current_track_frames=length/588
GOTO calculate

:ape
shntool len "%~n1.ape">%_tempfile%
FOR /F "usebackq tokens=1,3 skip=1" %%A IN (%_tempfile%) DO (
SET length=%%A
SET cdr=%%B
GOTO got_shntool_data
)
:got_shntool_data
IF %cdr:~0,2% NEQ -- (
ECHO The time for
ECHO "%~n1"
ECHO cannot be accurately calculated.
ECHO.
ECHO The file may not end on a frame boundry.
SET _error=3
GOTO :eof
)
SET mm=%length:~0,-6%
IF %length:~-5,1% == 0 (
SET ss=%length:~-4,1%
) ELSE (
SET ss=%length:~-5,2%
)
IF %length:~-2,1% == 0 (
SET ff=%length:~-1%
) ELSE (
SET ff=%length:~-2%
)
SET /A _current_track_frames=mm*4500+ss*75+ff
GOTO calculate

:wav
SET /A _boundry=(%~z1 - 44)%%2352
IF %_boundry% GTR 0 (
ECHO The time for
ECHO "%~n1"
ECHO cannot be accurately calculated.
ECHO.
ECHO The file may not end on a frame boundry.
SET _error=3
GOTO :eof
)
SET /A _current_track_frames=(%~z1 - 44)/2352

:calculate
SET _prev_ftotal=%_total_frames%
SET /A _total_frames+=_current_track_frames
SET /A _track+=1
SET _pregap=
IF %_track% GTR 1 GOTO :eof
ECHO FILE "Range.wav" WAVE>>%_outfile%
GOTO :eof

:check_for_error
IF "%_error%" NEQ "" GOTO error
GOTO get_next_line


:extract_index
SET _z=%1
IF %_z:~0,1% == 0 (
SET mm=%_z:~1,1%
) ELSE (
SET mm=%_z:~0,2%
)
IF %_z:~3,1% == 0 (
SET ss=%_z:~4,1%
) ELSE (
SET ss=%_z:~3,2%
)
IF %_z:~6,1% == 0 (
SET ff=%_z:~7,1%
) ELSE (
SET ff=%_z:~6,2%
)
GOTO :eof

:format_index
SET /A mm=%1/4500
SET /A ss=%1%%4500/75
SET /A ff=%1%%4500%%75
IF %mm% LSS 10 (SET mm=0%mm%)
IF %ss% LSS 10 (SET ss=0%ss%)
IF %ff% LSS 10 (SET ff=0%ff%)
GOTO :eof


:corrected_gaps
ECHO The source CUE sheet was likely created using
ECHO the Multiple WAV Files With Corrected Gaps option.
ECHO.
ECHO Enter "P" to continue assuming the corresponding files were created
ECHO with the Append Gaps To (P)revious Track (default) option selected,
ECHO.
ECHO enter "N" to continue assuming the corresponding files were created
ECHO with the Append Gaps To (N)ext Track option selected, or
ECHO.
SET /P _correct_cue=press ^<Enter^> to exit:
IF /I "%_correct_cue%" == "p" GOTO get_next_line
IF /I "%_correct_cue%" == "n" GOTO new_start_index
GOTO del_outfile


:leftout_gaps
ECHO The source CUE sheet was likely created using
ECHO the Multiple WAV Files With Leftout Gaps option.
ECHO.
ECHO Enter "c" to continue assuming the corresponding files were created
ECHO with the Append Gaps To Previous Track (default) option selected or
SET /P _correct_cue=press ^<Enter^> to exit:
IF /I "%_correct_cue%" NEQ "c" GOTO del_outfile

:lg_index
CALL :new_00_index %_y%
SET _pregap=
GOTO get_next_line


:error
ECHO.
ECHO Press any key to end . . .
PAUSE>nul

:del_outfile
DEL %_outfile%

:end
DEL %_tempfile%

This is probably what you wanted in the first place?


PS: cuesheets were not intended to be used as playlists. If you want to append separate tracks using foobar2000, load them manually or with a playlist file (m3u, pls, or whatever format it likes).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.