PDA

View Full Version : Convert WAV to WMA VB/C*/C++ Example



Maarten
07-25-2008, 03:11 AM
Hi,

I just bought the dbpoweramp reference. Until now we use windows scripting host to convert from wav to wma but your application offers better control.

I'm able to convert from wav > mp3 or wma > mp3 without any problems.

When I try to convert from wav > wma I get various errors (based whether I type in : 'Windows Media Audio 9.1' or 'Windows Media Audio 9'

Error Creating WMA Profile. [clEncoder::BeginConversion]
Error: Unable to load encoder 'Windows Media Audio 9.1'. [dBCoreConverter::dBCoreConverter]

Does someone have a working code sample? (can be VB/C++/C*)

I've been playing a bit with your components, but without luck.

CREATE(DMConverter);
CREATE(DMWMASettings);


//DMWMASettings.SetWMA('Windows Media Audio 9.1', 'VBR Quality 98, 44kHz, stereo VBR', 1);
DMConverter.Convert(
'c:\temp\org.wav',
'c:\temp\converted.wma',
'Windows Media Audio 9.1',
'VBR Quality 98, 44kHz, stereo VBR',
'c:\temp\log.txt'
);

Spoon
07-25-2008, 04:00 AM
Try:

"Windows Media Audio 9.2 Lossless"

"VBR Quality 100, 44 kHz, 2 channel 16 bit VBR"

Maarten
07-25-2008, 05:06 AM
Hi, Thanks for your answer.

Error: Unable to load encoder 'Windows Media Audio 9.2 Lossless'. [dBCoreConverter::dBCoreConverter]

In configuration I switched to detailed error logging.
C:\Program Files\dBpoweramp\encoder\Windows Media Audio 9.2 Lossless.dll
is not found

C:\Program Files\dBpoweramp\encoder\Windows Media Audio 9.dll
is there.

Now when I set back the option back to 'Windows Media Audio 9'
Error Creating WMA Profile. [clEncoder::BeginConversion]

I tried to play with the options:

'VBR Quality 25, 44kHz, stereo VBR'
'' (EMPTY)
'1' --> to try for an option
'VBR Quality 100, 44 kHz, 2 channel 16 bit VBR'

But no luck either.

Can I call some code to verify available profiles to the application?
Or is this info available in some registry key?

Maarten
07-25-2008, 07:08 AM
Dear,

Through comment line I get the same error

Will look on google as well

"c:\program files\dbpoweramp\coreconverter.exe" -infile="c:\temp\org.wav" -outfile="c:\temp\converted.wma" -convert_to="Windows Media Audio 9" -codec="Windows Media Audio 9" -settings="VBR Quality 98, 44 kHz, stereo VBR" -vbr

LtData
07-25-2008, 08:18 AM
I managed to get this command-line working:

"E:\program files\dbpoweramp\coreconverter.exe" -infile="E:\test.m4a" -outfile="E:\test.wma" -convert_to="Windows Media Audio 10" -codec="Windows Media Audio 9.2" -settings="VBR Quality 98, 44 kHz, stereo VBR" -vbr
Note I'm using WMA 10, not WMA 9.

However, I'm having trouble with the scripting equivalent also. Trying this, which would seem to be what I want:
Call dMC.Convert("E:\test.m4a", "E:\test.wma", "Windows Media Audio 10", -codec="Windows Media Audio 9.2" -settings="VBR Quality 98, 44 kHz, stereo VBR", "E:\error.txt") gives a Windows Scripting Host error:
Type mismatch: '[string: "Windows Media Audio "]'.

Other various permutations end up giving me the error in my error log: "Error Creating WMA Profile. [clEncoder::BeginConversion]"
The line that gave me that error is:
Call dMC.Convert("E:\test.m4a", "E:\test.wma", "Windows Media Audio 10", "VBR Quality 98, 44 kHz, stereo VBR", "E:\error.txt")

More ideas, anyone?

Maarten
07-25-2008, 08:47 AM
Hi,

Thanks for all your comments!

I've command line working as well.

I noticed some other topic on the form where someone replaced the

"VBR Quality 98, 44 kHz, stereo VBR" -vbr
{qt}VBR Quality 98, 44 kHz, stereo VBR{qt} -vbr

What we could check is:

1. command line works; so profiles are valid
2. what does the dmConverterreceive?

- does my application send correct ascii code to the converter --> the reason why we put in xml '&amp' instead of '&'????

- is there a way (debugging option) to see what is actually received by the external dBpoweramp application?

- I noticed: ' -vbr' <-- a space!! could this be the problem????


*************
Splitting Command Line:Done
->-> [dBCoreConverter::ReaddBCommandFile]
<-<- [dBCoreConverter::ReaddBCommandFile]
->-> [cldBCodecHandler::FindDecoder]
Checking Decoder 'C:\Program Files\dBpoweramp\decoder\Wave.dll' for extension '.wav'
Decodes [clDecoder::Get]
<<< Match, using decoder
Using Registry Cached Decoder: C:\Program Files\dBpoweramp\decoder\Wave.dll
<-<- [cldBCodecHandler::FindDecoder]
->-> [cldBCodecHandler::LoadEncoder]
Loading Encoder 'C:\Program Files\dBpoweramp\encoder\Windows Media Audio 10.DLL'
<-<- [cldBCodecHandler::LoadEncoder]
->-> [dBCoreConverter::StripCoreConverterCmds]
<-<- [dBCoreConverter::StripCoreConverterCmds]
SendRawUnCompressed [clEncoder::Get]
Communicate [clDecoder::Get]
Communicate [clEncoder::Get]
NeedHQAudio [clEncoder::Get]
->-> [clDecoder::Open]
Opening file 'c:\temp\org.wav' for read access: Opened
Reading Audio Information
->-> [clWaveDecoder::Initialize]
<-<- [clWaveDecoder::Initialize]
->-> [clRIFFHandler::Initialize]
clRIFFHandler::CalcAllChunks: Ok
<-<- [clRIFFHandler::Initialize]
->-> [clRIFFHandler::ScanFile]
clRIFFHandler::CalcAllChunks: Ok
RIFF Header 'RIFF' Length: 40902692 FormType 'WAVE'
Got Chunk 'fmt ' Length: 16 RiffSizeLeft: 40902680 ChunkPosition: 12
Got Chunk 'data' Length: 40902656 RiffSizeLeft: 40902656 ChunkPosition: 36
clRIFFHandler::CalcAllChunks: Ok
<-<- [clRIFFHandler::ScanFile]
Read Audio Information
->-> [clWaveDecoder::ReadIDTags]
->-> [clWaveDecoder::PullOutFMTnDATA]
Finding 'fmt ' chunk.
Finding 'data' chunk.
Assigning 'fmt ' chunk to WFX
<-<- [clWaveDecoder::PullOutFMTnDATA]
2 ID Tags:
_riff_1: DATA Length: 4 fmt
_riff_2: DATA Length: 4 data
<-<- [clWaveDecoder::ReadIDTags]
->-> [clWaveDecoder::FillAudioProps]
Audio Quality: CD (Lossless)
Encoder Settings: PCM
Wave Header: Wave Format PCM
Channel Mapping: Left, Right
Sample Count: 10,225.664
Riff Chunks: 'fmt ' 16 bytes, 'data' 39,01 MB
Gapless: Yes
<-<- [clWaveDecoder::FillAudioProps]
Writing Audio Information
->-> [clWaveDecoder::FillAudioInfo]
Audio Length: 231874 mili-seconds 40902656 bytes 1411 kbps
<-<- [clWaveDecoder::FillAudioInfo]
Written Audio Information
Preparing to Decode
->-> [clWaveDecoder::PrepareToDecodeAudio]
Calling ACMDecoder.CreateNewConverter
Compressed WFX (on file): Format Tag: 1 Channels: 2 Bits per Sample: 16 Samples Per Second: 44100 Bytes Per Second: 176400 Block Align: 4 CB Size: 0
Uncompressed WFX (sent to db): Format Tag: 1 Channels: 2 Bits per Sample: 16 Samples Per Second: 44100 Bytes Per Second: 176400 Block Align: 4 CB Size: 0
Setting Position in File
<-<- [clWaveDecoder::PrepareToDecodeAudio]
Prepared Decoding
<-<- [clDecoder::Open]
SendRawUnCompressed [clEncoder::Get]
->-> [clEncoder::BeginConversion]
Converting to 'c:\temp\converted.wma' encoder settings ' -vbr'
Creating WMA Writer
Creating WMA Profile Manager
Creating Empty WMA Profile
Adding Audio Stream
*** Error: Error Creating WMA Profile. [clEncoder::BeginConversion]
***********************

Maarten
07-25-2008, 08:59 AM
:-) getting closer:

EXAMPLE
DMConverter.Convert(
'c:\temp\org.wav',
'c:\temp\converted.wma',
Compression,
' ' + '-vbr does' + 'text' + 'come' + 'here',
'c:\temp\log.txt'
);

RESULTS IN ERROR

->-> [clEncoder::BeginConversion]
Converting to 'c:\temp\converted.wma' encoder settings ' -vbr="doestextcomehere"'
Creating WMA Writer
Creating WMA Profile Manager
Creating Empty WMA Profile
Adding Audio Stream
*** Error: Error Creating WMA Profile. [clEncoder::BeginConversion]

Maarten
07-25-2008, 09:13 AM
'xxx' + '-vbr' + 'VBR Quality 98, 44 kHz, stereo VBR',

OR

'xxx -vbr' + 'VBR Quality 98, 44 kHz, stereo VBR',

RESULTS IN DEBUGGER
Converting to 'c:\temp\converted.wma' encoder settings ' -vbrVBR="Quality"'
Converting to 'c:\temp\converted.wma' encoder settings ' -vbrVBR="Quality"'

somehow it completely misses all information which is send.

:-( let's try to add it to some other line of code...

Maarten
07-25-2008, 09:23 AM
SOLVED :D

DMConverter.Convert(
'c:\temp\org.wav',
'c:\temp\converted.wma',
Compression,
'-codec="Windows Media Audio 9.1" -settings="VBR Quality 98, 44 kHz, stereo VBR" -vbr',
'c:\temp\log.txt'
);

When you put all information about the profile in one big string.. then it's working..

;) please can someone add this to the standard help page (rewrite to vb./c*/c++ if he likes)

would save a lot of time since there is no simple example on * > wma conversion.

Maarten Luijt
Astralmusic.com

LtData
07-25-2008, 07:06 PM
For vbs scripting, since single-quotes are comment marks, you have to use chr(34) to make double-quotes appear in the string. So my example looks like:
Call dMC.Convert("E:\test.m4a",
"E:\test.wma",
"Windows Media Audio 10",
"-codec="+chr(34)+"Windows Media Audio 9.2"+chr(34)+" -settings="+chr(34)+"VBR Quality 98, 44 kHz, stereo VBR"+chr(34)+" -vbr",
"E:\error.txt")