HydrogenAudio

Lossless Audio Compression => WavPack => Topic started by: Tatarimokke on 2006-06-29 16:25:40

Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-06-29 16:25:40
Hi, I try to setup a script to convert from ape to wavpack (high asymmetric, no tagging) with cue embedded. Someone suggest me this:

Quote
rem APE2WV
@echo off
set path=%PATH%;%~dp0
mac %1 - -d -|wavpack -mhx3 - "%~dpn1.wv"
echo.
PAUSE


However I obtain the wavpack but without the cue. Can someone help me? How can I do the same from flac and wavpack fast/normal?

Thanks a lot
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-06-29 19:31:59
As far as I understand you need an extra step: use Tag.exe with its --fromfile switch.

TAG.EXE --fromfile %1 "%~dpn1.wv"

... or:

FLAC --decode --stdout %1 | wavpack -mhx3 - "%~dpn1.wv"
TAG.EXE --fromfile %1 "%~dpn1.wv"
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-06-29 20:19:58
I need to convert an ape+cue separeted file in one wavpack with cue embedded file. I have try this:
Quote
rem APE2WV
@echo off
set path=%PATH%;%~dp0
mac %1 - -d -|wavpack -mhx3 - "%~dpn1.wv"
tag.exe --fromfile %1 "%~dpn1.wv"
echo.
PAUSE

But don't works. I obtain the wv but without cue.
Title: APE to WAVPACK with CUE embedded
Post by: Gow on 2006-06-29 20:47:54
Don't know if this helps or not. 

The Command Line Option for EAC when making a WavPack file with embedded cuesheet is:

Code: [Select]
-hlm -w "Cuesheet=@*.cue" -w "Album=%g" -w "Year=%y" -w "Genre=%m" %s


So, you might want to figure in an option that writes the cuesheet to the wavpack file...or maybe you did that already...not a coding genius here.

- Gow
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-06-29 22:29:45
I need to convert an ape+cue separeted file in one wavpack with cue embedded file.
As Gow says, you will need to use WavPack's -w "Cuesheet=@*.cue" switch to embed an external cuesheet, e.g.:

mac %1 - -d -|wavpack -mhx3 -w "Cuesheet=@*.cue" - "%~dpn1.wv"

If you use that format there can only be one cuesheet in the folder.  You may be able to specify the cuesheet name, e.g.:

mac %1 - -d -|wavpack -mhx3 -w "Cuesheet=@%~dpn1.wv.cue" - "%~dpn1.wv"

How did you get on with the embedded cuesheet files?
Title: APE to WAVPACK with CUE embedded
Post by: Gow on 2006-06-30 00:23:30
Playing around with foobar2000 9.2, I discovered you can make FLAC w/ embedded cuesheet and Monkey's Audio w/ embedded cuesheet.  Just an FYI.
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-06-30 07:39:07
Yes, as a manual process it is easy to embed a cuesheet using foobar.

However, I think it is difficult to convert files with embedded cuesheets, as foobar will split the file into tracks upon loading.  I think it's easier to stick to the command line for that (or perhaps dbPowerAmp, but I don't use it).
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-01 08:58:56
Thanks Synthetic Soul, Thanks Gow, now all wotks perfect. I use this:

mac %1 - -d -|wavpack -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1.wv"

I obtain cue embedded and metadata (title, artist, trak title). I'm not interested in metadata, but there is no problem. I can open the file in foobar, select all traks, properties, remove all metadata. Only another question, for flac file I can change with:

flac -d -c %1 - |wavpack -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1.wv"

And for recompress wavpack files from fast to high mode?
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-01 09:29:52
FLAC --decode --stdout %1 | WAVPACK -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1.wv"

WVUNPACK %1 - | WAVPACK -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"


If you wanted it to be a little more clever your batch file could possibly (I'm not sure the results you'd get when piping) check the return from WVUNPACK to ensure that it was successful, delete the source, and then rename the new file (REN "%~dpn1_h.wv" "%~n1.wv").

Edit: Corrected "n1.wv" to "%~n1.wv"
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-02 17:26:08
I have try to add your strig, but nothing appen. There is no problem, I can do some manual work. But if conversion ends successfully can I be sure that no errors occured? A last question, how can I check if burn process works good using MD5 hash?
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-02 19:27:24
I have try to add your strig, but nothing appen. There is no problem, I can do some manual work.
Without seeing all your code or knowing what you are doing I can't comment.

But if conversion ends successfully can I be sure that no errors occured?
I don't believe that you can; you need to check the exit code is 0 to be sure, I think.  I may well be wrong.

A last question, how can I check if burn process works good using MD5 hash?
Create an MD5 file of all the files you are about to burn (burn it to the disc as well), and then check the files against the MD5 file after burning?  I tend to use QuickSFV (http://www.quicksfv.org/) a lot of the time for creating and checking MD5 digests.
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-02 20:23:18
I haven't reread it thoroughly, but I just dug up one of my previous posts (http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=36099&view=findpost&p=330401) that may help you some more.
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-03 10:38:18
I have used this code:
Quote
rem APE2WV
@echo off
set path=%PATH%;%~dp0
mac %1 - -d -|wavpack -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1.wv"
REN "%~dpn1_h.wv" "n1.wv"
echo.
PAUSE

I obtain:

original md5 signature: xxxxxx
created cdimage.wv in xxx secs
succsess
impossible find specified file
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-03 11:07:35
Ah, that's because you are not creating "<name>_h.wv" with that script.

I suggested the REN statement to go along with the WavPack to WavPack conversion:

WVUNPACK %1 - | WAVPACK -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"

As you are converting from one WV file to another you need to amend the destination filename (otherwise you are trying to overwrite the source while you are reading it).  In the code above I append "_h" to the destination's filename.

Therefore:

REN "%~dpn1_h.wv" "%~n1.wv"

... renames "<name>_h.wv" to "<name>.wv".


My idea was that you would check that the operation worked successfully, delete the source, and then rename the destination, e.g.:

WVUNPACK %1 - | WAVPACK -mhx3 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"
IF %ERRORLEVEL% EQU 0 (
DEL %1
REN "%~dpn1_h.wv" "%~n1.wv"
)


... or something like that...

Edit: Corrected "n1.wv" to "%~n1.wv"
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-03 12:42:28
So I must create the wv file from ape or flac. Then recompress to check it! I have try this two script:
Quote
rem APE2WV
@echo off
set path=%PATH%;%~dp0
WVUNPACK %1 - | WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"
IF %ERRORLEVEL% EQU 0 (DEL %1 REN "%~dpn1_h.wv" "n1.wv")
echo.
PAUSE

rem APE2WV
@echo off
set path=%PATH%;%~dp0
WVUNPACK %1 - | WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"
IF %ERRORLEVEL% EQU 0
DEL %1
REN "%~dpn1_h.wv" "n1.wv"
echo.
PAUSE


But nothing (thanks for patience  )
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-03 13:14:14
The first one will fail as you have two commands on one line ((DEL %1 REN "%~dpn1_h.wv" "n1.wv")).

The second fails as you have no brackets to denote a group of commands.

Also, I wrongly used "n1.wv", when I meant "%~n1.wv".

Try:

rem WV2WV
@echo off
set path=%PATH%;%~dp0
WVUNPACK %1 - | WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"
IF %ERRORLEVEL% EQU 0 (
DEL %1
REN "%~dpn1_h.wv" "%~n1.wv"
)
echo.
PAUSE
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-03 15:19:33
Now works great!!! I have created this batch:
Quote
rem APE2WV
@echo off
set path=%PATH%;%~dp0
mac %1 - -d -| WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1_h.wv"
IF %ERRORLEVEL% EQU 0 (
DEL %1
REN "%~dpn1_h.wv" "%~n1.wv"
)
echo.
PAUSE

So now I can convert my files in one step and I can be sure that the new file is no corrupted. Thanks so much Synthetic Soul, you are a genius!!!
Do you know if there is a similar way to check mp3 obtained from these lossless files?

(Sorry for the OT)
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-03 15:31:02
You still don't seem to get the requirement for the DEL and REN statements.

If you are converting from APE to WV they are unrequired.  It is only if you are converting from WV to WV that you need to worry about renaming, deleting and renaming again.

In the example quoted you could just use:

rem APE2WV
@echo off
set path=%PATH%;%~dp0
mac %1 - -d | WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" - "%~dpn1.wv"
echo.
PAUSE


RE: MP3s, most command line applications will return 0 if successful, and a non-zero value if unsuccessful, so you can generally use %ERRORLEVEL% to check whether the application has exited sucessfully.
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-03 15:44:52
In effect the dos window don't say nothing more, but I have find the ape deleted and the CDimage.wv file, so I have thinked that the script was ok.
Sorry but my english is really poor, I can use the cheking function only from wv to wv conversion? For ape and flac I don't need them or I need to convert from ape to wv to wv (for cheking)?
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-03 16:08:31
Yes, that is true: if you want to always delete the source then checking the error level and using the DEL statement would be required.

I'm not actually convinced what return code you are getting when piping; is it the return code of the application decoding, or encoding?

The safest way may be to decode to WAV, check the error code of the decoding app, and then only encode if it is 0, e.g.:

Code: [Select]
REM Decode to WAVE
WVUNPACK %1 "%~dpn1.wav"

REM If the return code is 0 encode, otherwise report the error
IF %ERRORLEVEL% EQU 0 (
  WAVPACK -mfx5 -w "Cuesheet=@%~dpn1.cue" "%~dpn1.wav" "%~dpn1.wv"
  IF %ERRORLEVEL% EQU 0 (
    REM Delete source and temporary WAVE
    DEL %1
    DEL "%~dpn1.wav"
    ECHO Successful conversion
  ) ELSE (
    ECHO Problem encoding
  )
) ELSE (
  ECHO Problem decoding
)


I don't know, I think I'm just confusing the issue now.

NB: With the code above you would just edit line 2 to decode from another format.
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-03 16:50:25
The idea is great, but when I try to drag a wv file a dos window open and immediatly close
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-03 17:23:42
It worked fine for me,  if I removed the cuesheet switch (as I don't have a cuesheet to test with).

However, I realised that WavPack will be trying to overwrite the source file, so here's an update:

Code: [Select]
@ECHO OFF

REM Decode to WAVE
WVUNPACK %1 "%~dpn1.wav"

REM If the return code is 0 encode, otherwise report the error
IF %ERRORLEVEL% EQU 0 (
  WAVPACK -dymfx5  -w "Cuesheet=@%~dpn1.cue" "%~dpn1.wav" "%~dpn1.wv"
  IF %ERRORLEVEL% EQU 0 (
    ECHO Successful conversion
  ) ELSE (
    ECHO Problem encoding
  )
) ELSE (
  ECHO Problem decoding
)

PAUSE


With the above code WavPack will delete the source WAV (-d switch) and overwrite the source WV (-y switch).
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-04 11:24:01
I have created a shortcut to the batch and works perfectly!  First decompress to wav, then recompress to wavpack and finally delete the wav file. Only a question: for decode from ape and flac I must edit "WVUNPACK %1" with "mac %1 - -d" and "flac -d -c %1"?
Title: APE to WAVPACK with CUE embedded
Post by: Synthetic Soul on 2006-07-04 12:52:18
Only a question: for decode from ape and flac I must edit "WVUNPACK %1" with "mac %1 - -d" and "flac -d -c %1"?
Remember, you are decompressing to WAVE now.

MAC %1 "%~dpn1.wav" -d

FLAC -d %1

... should do it.
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-04 15:24:10
OK Synthetic Soul, now works good! Thanks a lot  This script is very useful to convert quick and safetly my music collection for archive them.
Title: APE to WAVPACK with CUE embedded
Post by: Tatarimokke on 2006-07-14 20:42:15
When I try to convert flac with this catch:
Quote
@ECHO OFF

REM FLAC2WV
FLAC -d %1 "%~dpn1.wav"

REM If the return code is 0 encode, otherwise report the error
IF %ERRORLEVEL% EQU 0 (
  WAVPACK -mhx3  -w "Cuesheet=@%~dpn1.cue" "%~dpn1.wav" "%~dpn1.wv"
  IF %ERRORLEVEL% EQU 0 (
    ECHO Successful conversion
  ) ELSE (
    ECHO Problem encoding
  )
) ELSE (
  ECHO Problem decoding
)

PAUSE

I receive this error (decoding to wav:
Quote
0:FKAC_STREAM_DECODER_ERROR_STATUS_LOST_SYNC

Can somebody help me?