Log in

View Full Version : Convert aac to wav to ??? to ac3


Pages : [1] 2 3

Paulcat
9th February 2005, 19:58
I have a matroska file with 5.1 aac audio. I would like to end up with 5.1 ac3 audio.

I can use faad2 to extract the audio into a wav file, and it gives me the option to go to stereo or not.

If NOT, I get a big wav file. So how do I convert this wav file to 6 mono waves to dump into soft encode to get my 5.1 ac3?

Kurtnoise
9th February 2005, 20:06
with BeSweet....and accessory BeLight. :p You can choose the "16 bits (six) mono waves" option in WAV tab.

Sakuya
22nd February 2005, 01:31
Can I please have more information on how to do this? From what I understand, Paulcat wants to convert AAC 5.1 to AC3 5.1?

Well I have the same problem. I have HE-AAC 5.1 and I want it in AC3 5.1 so that it'll go nicely onto a DVD-R. But my authoring programs don't support AAC. How can I go about doing this?

KpeX
22nd February 2005, 05:00
Please read the AAC and AC3 sections of the FAQ, and use the search. You'll need to decode the AAC and then encode to AC3. There are numerous tools for both tasks.

Sakuya
22nd February 2005, 05:09
I used faad2 to decode the AAC to a 6ch WAV. Then I used BeSplit command line to split that WAV into 6 mono WAVs using this:

besplit -core( -input multichannel.wav -prefix mono -demux -type wav )

I have Soft Encode. How do I know what order it is in? In Soft Encode, I opened all the WAVs in order, as raw data. There's an option menu after that for each WAV so I chose: 1 channel (since they're in mono individually) and then 44100Hz (source samp. rate)
I set the order as the WAV channel order which is I believe: L,R,C,LFE,SL,SR. I noticed that there's a clip sound at the very beginning when I play it in Soft Encode. But I don't get that clip when I play it in Winamp.

Edit:
My problem lies in the video portion and is making it all go out of sync. Should I start a new thread or stay here? :(

violao
23rd February 2005, 12:17
Originally posted by Sakuya
... and then 44100Hz (source samp. rate)
If you want to create DVD you need to resample your audio to 48000.

Sakuya
23rd February 2005, 19:59
I've already gotten the audio out of the way. I inputted that AC3 into BeSweet and changed the sampling rate (preserving 5.1). Does BeSweet mess up the channel order? I'm not sure. I can't check yet because my DVD project is out of sync.

My problem lies in the MKV>AVI video but since this is in the Audio forum, I'm not sure if I should post here or start a new thread.

Sakuya
24th February 2005, 07:00
One question on AAC. How does HE-AAC 5.1 lose quality when transcoded from AC3 5.1? Does the volume get distorted? I tested my AC3 and it all sounds pretty good. I don't think I even need the increase LFE. So what did the AAC FAQ mean by "quality"?

Paulcat
24th February 2005, 14:00
I know this answer is available somewhere else but, since it follows this thread...

Starting with the multichannel wav files, if it is in two parts, how can I merge the two BEFORE processing?

Paulcat
25th February 2005, 01:30
Originally posted by Sakuya
I used faad2 to decode the AAC to a 6ch WAV. Then I used BeSplit command line to split that WAV into 6 mono WAVs using this:

besplit -core( -input multichannel.wav -prefix mono -demux -type wav )

I have Soft Encode. How do I know what order it is in? In Soft Encode, I opened all the WAVs in order, as raw data. There's an option menu after that for each WAV so I chose: 1 channel (since they're in mono individually) and then 44100Hz (source samp. rate)
I set the order as the WAV channel order which is I believe: L,R,C,LFE,SL,SR. I noticed that there's a clip sound at the very beginning when I play it in Soft Encode. But I don't get that clip when I play it in Winamp.

I did the same. According to the note that pops up in faad2, the channel order is "reset to" C,L,R,SL,SR,LFE. In reality, the order remains as you stated (L,R,C,LFE,SL,SR). When entering the waves into soft encode, it expects them in the order L,C,R,SL,SR,LFE so you have to make sure the correct wav goes to the matching channel.

Soft encode will also let you output to 48000Hz so you can skip your last step.

Sakuya
25th February 2005, 04:05
So what you're saying is that BeSplit outputs the mono WAVs in this order (L,R,C,LFE,SL,SR) but Soft Encode needs each WAV to go in this order (L,C,R,SL,SR,LFE).

I find in Soft Encode that you can change the speaker settings of each WAV by clicking one of the other speakers. Can I do that or must I need to open them all in the default order (L,C,R,SL,SR,LFE)?

Also, I opened each mono WAV as raw data as 44100Hz. It has the option of opening them as 48000Hz but I'm not sure if that's right. Where is the option of saving it as 48000Hz AC3?

tebasuna51
25th February 2005, 04:56
@Sakuya
Sorry for my bad english. I hope you understand me.

About Faad:
- This program can make a wav file greater than 4 GB if the aac input is greater than 135 m. (44 Kh) or 124 m. (48 Kh). Now there are an overflow in two header's fields (4 bytes).

- Make a header WAVE_FORMAT_EXTENSIBLE with AudioFormat 0xFFFE ?, this must be changed to AudioFormat PCM 0x0001

- For this many soft (BeSweet, Soft Encode, Goldwave, ...) can't read the wav. Only BeSplit can demux this wav in 6 wav mono almost correct.

- It pops up in a note: the channel order is C,L,R,SL,SR,LFE (like aacenc/aacenc32). In reality, the order is (like faac default) : FL,FR,C,LFE,SL,SR. Soft Encode and ac3enc need: FL,C,FR,SL,SR,LFE, so you must realign. (OK Paulcat)

You can modify the Audioformat with Winhex by hand or with a script like this:

winhex AudioFor.whs

Where AudioFor.whs is:

Open "G:\FaadWav6.wav" in-place (your path and name)
Goto 0x14 (Offset of Audiformat)
Write 0x0100 (PCM, lower byte first)
Save
Exit

If your wav is < 4 GB you can now open this wav with Softencode and realign the channels or you can demux to 6 mono wav with:
BeSweet -core( -input g:\6faad_PCM.wav -output g:\ -6ch )
This make corrects g:\FL.wav, FR.wav, ...

But if your wav is > 4 GB you must use BeSplit
BeSplit -core( -input g:\6faad_PCM.wav -prefix g:\c -type wav -demux )

Now there are another problem. BeSplit has a bug (reported for me to DSPguru) in the header of the mono wavs, the field BlockAlign is fixed to 6 but it must be 2 (mono 16 bits)
You can modify the BlockAlign with Winhex by hand or with a script like this:

winhex BlockAli.whs

Where BlockAli.whs is:

Open "G:\c01.wav" in-place (your path and name)
Goto 0x20 (Offset of BlockAlign)
Write 0x0200 (lower byte first)
Save
Close
Open "G:\c02.wav" in-place (repeat for the 6 channels)
...
Save
Exit

Now, only for clarity, rename g:\c01.wav FL.wav, etc (FR,C,LFE,SL,SR) and open with Soft Encode without RAW mode and without inicial click (the bad header).

Sakuya
25th February 2005, 05:12
I got WinHex (trial) and I created a script exactly like this:

Open "D:\file.wav" in-place (your path and name)
Goto 0x14 (Offset of Audiformat)
Write 0x0100 (PCM, lower byte first)
Save
Exit
Do I need to change anything? Do I need to remove all the text in ()? Also, when I tried to execute it, it said the trial version can only execute the sample scripts. Only the professional version can execute your own scripts. What should I do now?

As for using BeSplit to separate the 6ch WAV, can I use this:


besplit -core( -input multichannel.wav -prefix mono -demux -type wav )

I used that before and it works fine. How come your code is different?
And, when and how do I change the sampling rate to 48000Hz? I used Soft Encode but it doesn't change the rate. I've checked the AC3, it is still 44100. :(

Paulcat
25th February 2005, 13:50
Sakuya:

Your method works fine. You can ignore the channel order that pops up in faad2 if you are using besplit after: the actual channel order after making your six mono wav files is L (Wav1),R (Wav2),C (Wav3),LFE (Wav4),SL (Wav5),SR (Wav6).

When you open wavs one at a time in soft encode, it will place them in the order L,C,R,SL,SR,LFE, SO TO MAKE THINGS EASIER load them in the order Wav1, Wav3, Wav2, Wav5, Wav6, Wav4 and then soft encode will have received them in the order it was expecting.

Also, if the original wav was 44100Hz, when importing the wavs into soft encode, select 44100Hz in the option box. Under ENCODE OPTIONS in the menu, you can change this to 48000Hz for AC3 creation.

If you import the wavs in a DIFFERENT order, you can re-order them by clicking on the little square that represents the channel to the left of the wav. REMEMBER to check the (right arrow) option for each wav (a drop down box will show channel 0, channel 1 with tick marks beside each) and make sure both left channels have a tick beside channel 0 only, both right channels have a tick beside channel 1 only, and the centre and lfe channels have both ticks. This is important!

Paul

I also noticed that playing the mono wav files individually in media player classic causes them to play really fast (like Alvin the chipmunk) and a partial ac3 that I made did the same. Is this normal? They play correctly when played in soft encode. Help!

Sakuya, the "-demux" option from besplit should be before the "-type" option I think...

Paulcat
25th February 2005, 14:01
Originally posted by tebasuna51
Now there are another problem. BeSplit has a bug (reported for me to DSPguru) in the header of the mono wavs, the field BlockAlign is fixed to 6 but it must be 2 (mono 16 bits)

You can modify the BlockAlign with Winhex by hand
How do you do it by hand? And if you modify 0x20 is that the 20th byte or 32nd byte ($20 HEX)? And all this will do is eliminate the chirp at the start of playback?

tebasuna51
25th February 2005, 18:09
@Sakuya
Sorry, of course without the comments in (). With the Trial version of WinHex you can make the changes by hand:

Go to Options -> Edit Mode -> In-place Mode (In the default mode it make a long backup of the file)
Open the wav6. Go to offset 0x14 (0x = hexadecimal). If there are 01 the file is ok, but if there are FE you must change to 01.
In offset 0x15 the value FF must be corrected to 00. Then save the file. Now Soft Encode open the wav like PCM, not RAW.

For the field BlockAlign in the 6 mono wav you must open the 6 mono01.wav ... mono06.wav, and go to offset 0x20 (0x = hexadecimal) and change the value 06 to 02.
I tried BeSplit v0.82 (last oficial version), v0.9b6 and v0.9b7 (last betas I know) and always with the same result.
When I open a mono wav_PCM with BlockAlign 6 in Soft Encode the sound is distorted and 3 times short (6/2).

At last, I change the sampling rate to 48000 Hz with Goldwave (Cool Edit, ...) but is shareware. I read about a free program R8Brain 1.6 (http://www.voxengo.com/downloads/#r8brain) but I don't tested yet.

@Paulcat
I tried with Soft Encode open 44100 Hz wav, and set in Encode Options 48000 Hz and the result is more acute than the original.

0x20 is hexadecimal = 32 decimal

When AudioFormat is set to PCM (0x0001) and BlockAlign is set to 02 (mono 16 bits) Soft Encode read correctly the wav header and is not necessary to open in RAW mode. Opened in RAW mode the bytes of the header is treated as music data and sound like a chirp at the start.

Sakuya
26th February 2005, 03:10
@Paulcat:
In Soft Encode, Encode Options, Audio Service Configuration, it is already set at 48000Hz with the Auto option checked. But it still outputs to 44100Hz. :( I know that it is still 44100Hz because it wouldn't let me input the AC3 in TMPGEnc DVD Author and when I added it to a video stream in Vdub, it says the stream is 44100Hz. If I convert the AC3 to 48000Hz via BeSweet (checking Create 5.1 AC3), would that mess up any AC3 sound quality? Anyway, I just did that and it seems that the AC3 lowers in volume, at least on the computer.

@tebasuna51:
What is offset 0x14 and 0x20? Where can I find that? Also, when I selected in-place mode, it warned me that the trial version can only open files below 200KB in in-place mode. My 6ch WAV is much over 200KB and therefore can only be opened as read-only. :(

tebasuna51
26th February 2005, 13:00
@Sakuya
There are many hexadecimal editors for free, but I don't know other than Winhex (prof) capable to open huge files ( > 2 GB ) like a wav6 from a movie.

Try to use, instead faad, foobar2000 (free, www.foobar2000.org) to convert the aac in a wav6_PCM and after demux in 6 mono wav with Besweet. All of this wav (if < 4 GB) have correct header.

Paulcat
26th February 2005, 17:32
TEBASUNA51:

I tried something yesterday, I opened my 6CHANNEL.WAV with WinHex, changed the 'FE FF' to '01 00', re-saved the file, and opened it with SoftEncode.

SoftEncode read all the channels fine (though I had to re-order them as SE read them in it's EXPECTED order, not the order they were in inside the WAV file). I then ran the encode part of soft encode (which took 30 minutes). I tried to play the resulting ac3 file after in media player classic and I got an error (unable to render the file) and it wouldn't play (using either MPC's built in ac3 decoder or ac3filter ).

I also tried the six mono wav option, using WinHex again to change the 06 byte to 02, and soft encode refused to open half of the six waves, telling me that "the file may be compressed data"

Can besweet open the six wav files and give me a proper ac3 file to work with?

Granted I already made a dvd from the material I have in two-channel audio, and none of this is actually NECESSARY, but dammit, there has to be a way to do this!

Sakuya
26th February 2005, 22:47
Where in foobar2000 can I select the output to be a 6ch PCM WAV? I think I just converted it to 2ch WAV by right-clicking on the AAC file and then "Convert". :(

And can anybody tell me an easier way to convert to 48000Hz before making 6 mono WAVs or the AC3? Currently, here are my steps:

1. AAC > 6ch WAV using FAAD2
2. 6ch WAV > 6 mono WAVs using BeSplit
3. 6 mono WAVs > AC3 using Soft Encode
4. 44100 Hz AC3 > 48000Hz AC3 using BeSweet

BeSweet's AC3 sounds much softer (on the computer) than Soft Encode's AC3 so I'm wondering if there's any other way to do this to decrease the steps and make it easier for myself?

Can anyone tell me if decoding AAC to 6ch WAV and then to 6 mono WAVs and then to AC3 5.1 messes up any sound quality or messes up the sound directionality? The gunfire sounds all seems to come from the center speaker and there is no LFE for it. I'm not sure if it's supposed to be like that since I don't have the source and I don't have a computer 5.1 setup. :( Plus, I don't know how AAC degrades quality when transcoded from AC3 5.1. Can anyone give me more info on this? I already read the AAC FAQ but it doesn't provide this info.

tebasuna51
28th February 2005, 02:22
@Paulcat
IF your 6 mono wav have exactly the same size in bytes and the same header (in Winhex, all the bytes until "data" and the next four) THEN
is a problem in SoftEncode
ELSE
I need more data to help you: exactly size and header of your 6 mono wav and your wav6, logs of your process faad, BeSplit or BeSweet, ...
ENDIF

OR try with Foobar2000 like I say to Sakuya

@Sakuya
If foobar convert the aac (6 channel) to a 2 channel wav maybe you have activate any DSP function like "Convert 5.1 to stereo" or "Simple surround"
Then, before "Convert->Run conversion", you must "Convert->Settings...->Processing->Unmark "Use DSP""

Another program to change 44100 Hz to 48000 Hz is ssrc-1.29 (free, http://shibatch.sourceforge.net/) directly in the 6ch WAV PCM with:
ssrc --rate 48000 wav6_PCM_44.wav wav6_PCM_48.wav

Now your steps:
1. AAC > 6ch WAV using FAAD2 (and Audioformat to PCM) or use Foobar2000
2. 6ch WAV 44100 Hz > 6ch WAV 48000 Hz using ssrc (need Audioformat PCM)
3. 6ch WAV 48000 Hz > AC3 using Soft Encode (realign the channels like say Paulcat)

All re-encode messes up any sound quality, the sound directionality is in your hands.

Sakuya
28th February 2005, 03:38
Sorry, I got mixed up! Foobar2000 did fine in creating the WAV (whether or not it is 6ch I don't know since there is no way to check). What is Audioformat to PCM? How do I do that with Foobar or FAAD2? Does it mess up the 6ch sound?

SSRC is pretty slow. It gives me some notes on what it's doing and I noticed this peculiar line:

nchannels: 8

Since when did I have 8 channels? :eek: Okay, it finished and after 100%, it gives me this error:

ssrc --
unrecognized option : --
st48000

The WAV works though. When I tried to open it in Soft Encode, it said it has more than 6 channels and cannot open it. Is this the reason why I've lost the gunfire sounds from before? :confused: Because there are actually 8 channels? AAC sucks. :(

I did a search and it seems that foobar decodes AAC 6ch to 8ch WAV. Read the comments here:
http://www.hydrogenaudio.org/forums/lofiversion/index.php/t30602.html

So should I stick with FAAD2?

Paulcat
28th February 2005, 14:16
(1) I used mkvextract to extract to an 6channel.aac file
(2) I used FAAD2 to convert to aac file to 6channel.wav
(3) I used besplit to get 6 mono wav files
(4) Used WinHex to alter the $20 byte from 06 to 02.
(5) Loaded the 6 files in the order of 1,3,2,5,6,4 into softencode and produced an ac3 file that plays fine.

My mistake was in WinHex, I changed the 06 to 01 last time instead of 02, Doh!

SAKUYA, when you select 48000 in the encode option of softencode, DO NOT check the AUTO option. Auto will read the value from the first wav file and reset itself (likely 44100).

I was having an issue with the aac file...inside the MKV, it played fine, but when I tried to play just the aac audio after extraction, it wouldn't play, although the 6channel wav file did! Odd...

Sakuya
1st March 2005, 03:55
Thanks for telling me that. Paulcat, were you successful in removing that click? How did you get Winhex to work since I'm sure your AAC file was above 200KB? Or did you buy the program already? :( Are there any other ways for me to remove the click? I tried foobar but as I said, it makes an 8ch WAV.

Paulcat
1st March 2005, 14:22
Yes the clicking sound disappeared. I didn't use the scripts in WinHex, I just opened the file, changed the byte, and re-saved it. The individual wav files were just under 200K, why? Is there a limit in filesize with the trial version?

Sakuya
1st March 2005, 20:30
In WinHex, where do I find the $20 byte? Is that the same as Offset 00000020?

Sakuya
6th March 2005, 22:31
Can anybody help me with this? Just one more little step...:(

Paulcat
7th March 2005, 14:07
The offset and the $20 byte is the same, when I open a file it's the first byte in the third row. Or, since $20 HEX is the same as 32 in decimal, it's the 32nd byte...

Sakuya
7th March 2005, 20:57
Thanks. I used Hexedit because WinHex trial wouldn't let me save. In Offset 00000020, I changed the first number in that row from 06 to 02. Then I saved it as a new WAV. But when I tried to open it in Soft Encode as a PCM WAV, it told me it cannot because it is compressed data. :(

When I loaded all of them into Soft Encode as raw data and then played all the channels at the same time, there is still a "click" in the beginning. :(

I'm guessing I didn't do this part mentioned by tebasuna. How do I do this?

Make a header WAVE_FORMAT_EXTENSIBLE with AudioFormat 0xFFFE ?, this must be changed to AudioFormat PCM 0x0001

Paulcat
7th March 2005, 21:11
Did you change the $20 byte on all six mono wav files? (not the multichannel wav)

Sakuya
7th March 2005, 22:02
Yes I did. In Hexedit, when I tried to highlight the 6 in 06, it only let me highlight the 0 before the 6. So I had to type in "02". Is that okay?

I still think it's the overflow thing with the header that tebasuna mentioned because I didn't do that part. :(

tebasuna51
8th March 2005, 03:31
I hope this info help you to verify yours wav.
This is the correct canonic header of a mono wav 16 bits 48 KHz

Offset
_____
De He Value
__ __ _____
00 00 RIFF (fix literal, 4 bytes) Chunk "RIFF"
04 04 xx xx xx xx (integer, 4 bytes, max. 4 GB) Length of file - 8
08 08 WAVE (fix literal, 4 bytes)
12 0C fmt (fix literal, 4 bytes) Subchunk "fmt "
16 10 10 00 00 00 (integer, 4 bytes) Length of Subchunk fmt - 8 (16)
20 14 01 00 (integer, 2 bytes) AudioFormat (1 = PCM)
22 16 01 00 (integer, 2 bytes) NumChannels (mono)
24 18 80 BB 00 00 (integer, 4 bytes) SampleRate (48000)
28 1C 00 77 01 00 (integer, 4 bytes) ByteRate (96000)
32 20 02 00 (integer, 2 bytes) BlockAlign (2)
34 22 10 00 (integer, 2 bytes) BitsPerSample (16)
36 24 data (fix literal, 4 bytes) Subchunk "data"
40 28 Length of Subchunk data - 8 (integer, 4 bytes)
44 2C sound data ...

Always:
BlockAlign = NumChannels x BitsPerSample / 8
ByteRate = SampleRate x BlockAlign

Integer values with the lower byte first, then:
44 AC 00 00 = 44100 dec = 0000AC44 hex

There are another format well recognized, the float 32 bits with:
AudioFormat = 3 and BitsPerSample = 32 (float)

In the header WAVE_FORMAT_EXTENSIBLE there are more fields (than canonic) in the Subchunk fmt just before the Subchunk data, then:
Length of Subchunk fmt > 24
Offset of Subchunk data = 12 + Length of Subchunk fmt

Soft Encode can read canonic or WAVE_FORMAT_EXTENSIBLE headers if the AudioFormat is 1 or 3, and if all the values are correct (BlokAlign = 2 in a mono 16 bits, file < 4 GB, etc.)
With others values of Audioformat or any field error it read in RAW mode and convert the incorrect header in sound (click).

Sakuya
8th March 2005, 03:57
I am terribly confused. :eek: I cannot discern which part of the codes in my mono WAV file is part of the header and which parts I need to edit. The layout in Hexedit or WinHex does not resemble what you've put down. :( Can you please put it in simpler terms, step-by-step for Hexedit? Sorry for being such a bother! :(

])r. Mario
8th March 2005, 20:48
hello
im also trying to go form aac 5.1 to ac3 5.1
ive used nero to go from aac to a 6 channel wav, then besplit to make 6 mono files. i have soft encode but it doesnt seem to work.
when i encode it it only does the first 7 minutes
are there other progs out there that can take 6 wavs and make an ac3 file? or is there something im doing wrong in soft encode?
any help would be greatly appreciated.


p.s. i thought something might be wrong with my wav files, so i looked into your method of makeing the 6 hannel wav. how do u do that using faad2? i think i downloaded it, but there isnt an .exe anywhere, i cant seem to find anything online either on how to use it

tebasuna51
8th March 2005, 21:09
First I want to explain the wav header with the Winhex tools.
Winhex layout of a 48 KHz mono PCM canonical wav:

Of|_0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _A _B _C _D _E _F| Literal
___________________________________________________________________
00|52 49 46 46 Xx xx xx xx 57 41 56 45 66 6D 74 20|RIFF....WAVEfmt
10|10 00 00 00 01 00 01 00 80 BB 00 00 00 77 01 00|................
20|02 00 10 00 64 61 74 61 Yy yy yy yy Ss ss Ss ss|....data........

The bytes must be grouped in fields in order to understand the meaning. Here I identify the fields by order and by name. Example: [10] BlockAlign. Disregard the "_", is only for align.

First line:
[01] First 4 bytes: ChunkID______ (literal, 4 bytes) Chunk "RIFF"
[02] Next_ 4 bytes: ChunkSize____ (integer, 4 bytes)
[03] Next_ 4 bytes: Format_______ (literal, 4 bytes) Format "WAVE"
[04] Next_ 4 bytes: Subchunk1ID__ (literal, 4 bytes) Subchunk "fmt "
Second line:
[05] First 4 bytes: Subchunk1Size (integer, 4 bytes)
[06] Next_ 2 bytes: AudioFormat__ (integer, 2 bytes)
[07] Next_ 2 bytes: NumChannels__ (integer, 2 bytes)
[08] Next_ 4 bytes: SampleRate___ (integer, 4 bytes)
[09] Next_ 4 bytes: ByteRate_____ (integer, 4 bytes)
Third line:
[10] First 2 bytes: BlockAlign___ (integer, 2 bytes)
[11] Next_ 2 bytes: BitsPerSample (integer, 2 bytes)
[12] Next_ 4 bytes: Subchunk2ID__ (literal, 4 bytes) Subchunk "data"
[13] Next_ 4 bytes: Subchunk2Size (integer, 4 bytes)
[14] Next_ 2 bytes: First_ sound sample (signed integer, 2 bytes)
[15] Next_ 2 bytes: Second sound sample ...

When I say "literal" you can see the value in column literal.
When I say "integer, 4 bytes" you can see the decimal value in the small window Data Interpreter in the line 32 Bit (+)
When I say "integer, 2 bytes" you can see the decimal value in the small window Data Interpreter in the line 16 Bit (+)
When I say "signed integer, 2 bytes" you can see the decimal value in the small window Data Interpreter in the line 16 Bit (ñ)
When I say "Offset" (position of the actual byte in the file, beginning by 0, in hexadecimal) you can see the value in the Status line.

Now the explanation of all fields (group of bytes):
(You can see also http://ccrma.stanford.edu/courses/422/projects/WaveFormat/)

[01] ChunkID = "RIFF"
Identify the file like Resource Interchange File Format

[02] ChunkSize = File length - 8 (Xx xx xx xx in the example)
All size fields contains the value of the REST of data. At this moment we are read 8 bytes (ChunkID + ChunkSize) in the file.
This field have 4 bytes, then the max value is FFFFFFFF hex = 4294967295 dec = 4 GB
Check this value (cursor in Offset 04, value in Data Interpreter) with the value in Menu File->Properties->Size in bytes (-8)
If this values don't match, you have a corrupt wav. And the 6 mono wav must have the same File length

[03] Format = "WAVE"
Identify the file like Waveform data (.WAV). The "WAVE" format consists of two subchunks: "fmt " and "data".
The "RIFF" chunk can have other formats more complex, like "AVI " Audio/visual interleaved data (.AVI).

[04] Subchunk1ID = "fmt "
The "fmt " subchunk describes the sound data's format.

[05] Subchunk1Size = 16
If this value is greater than 16, we have a header WAVE_FORMAT_EXTENSIBLE (not canonical) with more fields in the "fmt " subchunk.
Not problem if Offset of Subchunk data = 20 (dec, 14 hex) + Subchunk1Size

[06] AudioFormat = 1
This is the normal PCM format with BitsPerSample = 16 (signed integer, 2 bytes) for channel.
There are another format well recognized, the float 32 bits with AudioFormat = 3 and BitsPerSample = 32 (float, 4 bytes). It is more accurate but with twice file size.
If the Audioformat is 65534 dec = FFFE hex, like output of faad, you have a problem. You must change to 1, like the example.

[07] NumChannels = 1
Self-explanatory 1 for mono, 2 for stereo, 6 for surround 5.1.

[08] SampleRate = 48000
If you have 44100 and need one ac3 for DVD you must resample the wav to 48000.

[09] ByteRate = 96000
Always must be: ByteRate = SampleRate x NumChannels x BitsPerSample / 8

[10] BlockAlign = 2
Always must be: BlockAlign = NumChannels x BitsPerSample / 8
A bug in BeSplit fix this value to 6. You must change this value to 2 (like example).

[11] BitsPerSample = 16
If Audioformat = 1 this value must be always 16.

[12] Subchunk2ID = "data"
The "data" subchunk contains the size of the data and the actual sound

[13] Subchunk2Size = (Yy yy yy yy in the example)
The size of the data sound.
In this case must be = File length - Subchunk1Size - 28

[14] First sound sample = (Ss ss in the example)
In format signed integer, 2 bytes
In a stereo waw, the first sound sample of the Left channel

[15] Second sound sample ...
In a stereo waw, the first sound sample of the Right channel, ...

-----------------------------------------------
Now in simpler terms, step-by-step for Hexedit.
1) Open a 6 channel wav 48 KHz generated by faad. Look like this:

00|52 49 46 46 Xx xx xx xx 57 41 56 45 66 6d 74 20|RIFF....WAVEfmt
10|28 00 00 00 fe ff 06 00 80 bb 00 00 00 ca 08 00|................
20|0c 00 10 00 ... |....

First and third lines Ok. Modify at 14 and 15 (hex) like this

10|28 00 00 00 01 00 06 00 80 bb 00 00 00 ca 08 00|................

Save the file

If the wav is 44.1 KHs offsets 18 to 1F are different but not problem.

2) Use BeSplit to generate the 6 mono wav and open each of them in Hexedit:

00|52 49 46 46 Xx xx xx xx 57 41 56 45 66 6d 74 20|RIFF....WAVEfmt
10|28 00 00 00 01 00 01 00 80 bb 00 00 00 77 01 00|................
20|06 00 10 00 ... |....

Modify the third line like this

20|02 00 10 00 ... |....

Save the files

3) If you need to convert 44.1 to 48 KHz run ssrc for each wav.

4) Open the files, in correct order, in Soft Encode.

tebasuna51
8th March 2005, 21:17
@])r. Mario

For any question over aac 5.1 to ac3 5.1 put Samplerate and minutes of the aac, and filesize of the 6 channel wav.

Sakuya
9th March 2005, 05:24
@Tebasuna:

Thanks for writing all that for me, it was very helpful! I followed your Hexedit guide using a 44100Hz 6-channel WAV file. I made the changes but the 6-channel WAV after that was sped up. The original length was 25 minutes and 1 second. After processing in Hexedit, it became 22 minutes and 59 seconds. :( I'm thinking of converting to 48000Hz using Soft Encode when I'm making my AC3. So what do I change for a 44100Hz 6-channel WAV?

tebasuna51
9th March 2005, 13:57
@Sakuya

I don't understand this change in lenght.
What program say you this lengths of wav6?
Can you send me the wav6 header?
(In Hexedit mark from first byte to the four next to "data", then Copy (Ctrl+C) and Paste (Ctrl+V) in the post reply)

This is a wav 6 channels 44.1 KHz faad generated

00|52 49 46 46 3c a0 a1 00 57 41 56 45 66 6d 74 20|RIFF....WAVEfmt
10|28 00 00 00 fe ff 06 00 44 ac 00 00 30 13 08 00|................
20|0c 00 10 00 16 00 10 00 3f 00 00 00 01 00 00 00|................
30|00 00 10 00 80 00 00 aa 00 38 9b 71 64 61 74 61|............data
40|00 a0 a1 00 ... |....

Duration in seconds = Subchunk2Size / ByteRate
Where:
Subchunk2Size (offset 40 hex, 4 inverse order bytes) = 00a1a000 = 10592256
ByteRate (offset 1C hex, 4 inverse order bytes) = 00081330 = 529200
Duration in seconds = 10592256 / 529200 = 20.0156

])r. Mario
9th March 2005, 21:49
wow thx for fast response :)

ok the .aac file is 22:50 long
sample rate is 44100 Hz
after conversion 6 channel wave comes out as ~708 MB
split the 6 mono files are about 118 MB

Sakuya
10th March 2005, 03:33
My 6ch 44100Hz WAV header in Hexedit is a bit different from the one that you put in your post above:

00|52 49 46 46 3c 00 5b 2f 57 41 56 45 66 6d 74 20|RIFF<.[/WAVEfmt
10|28 00 00 00 fe ff 06 00 44 ac 00 00 30 13 08 00|(.......D...0...
20|0c 00 10 00 16 00 10 00 3f 00 00 00 01 00 00 00|........?.......
30|00 00 10 00 80 00 00 aa 00 38 9b 71 64 61 74 61|.........8.qdata

The dots to the very right are copied exactly as it is seen in Hexedit. I used FAAD2 to convert my 6ch HE-AAC to 6ch WAV. This is the code I used in FAAD2:

faad.exe -o output.wav input.aac

tebasuna51
10th March 2005, 03:38
@])r. Mario

Are you read this post completely?. The answer is there.
When you open this wavs in Soft Encode see the Time Line. Only 7:36, then Soft Encode finish Ok.
The problem is the bug in BeSplit with the field BlockAlign. Soft Encode see a 6 (must be 2) and read the wav three times short (20:50 / 3 = 7:36) and distorted.

With not huge wav6 files generated by Nero (o Foobar) is better split the file with Besweet:
BeSweet -core( -input g:\wav_6.wav -output g:\ -6CH )

Then you have: g:\FL.wav, C, FR, SL, SR, LFE
My Nero aac plugin put the channel order in the wav6: C, FL, FR, SL, SR, LFE
Then I must change FL.wav <-> C.wav
Foobar put the channel order in the wav6: FL, FR, C, LFE, SL, SR
The I must use the parameter for Besweet: -6ch (lowercase) and the names for the mono wav are ok.

tebasuna51
10th March 2005, 04:50
@Sakuya

1) Open output.wav in Hexedit and modify the Audioformat (second line, bytes 5 and 6) like this:

00|52 49 46 46 3c 00 5b 2f 57 41 56 45 66 6d 74 20|RIFF<.[/WAVEfmt
10|28 00 00 00 01 00 06 00 44 ac 00 00 30 13 08 00|(.......D...0...
20|0c 00 10 00 16 00 10 00 3f 00 00 00 01 00 00 00|........?.......
30|00 00 10 00 80 00 00 aa 00 38 9b 71 64 61 74 61|.........8.qdata
40|00 00 5b 2f

Save as output1.wav

2) Split the wav with Besweet (canonical header, no error in BLockAlign):
BeSweet -core( -input output1.wav -6ch )
Then you have: FL.wav, C, FR, SL, SR, LFE

3) Each mono wav must have 132415532 bytes and the header:

00|52 49 46 46 24 00 48 7e 57 41 56 45 66 6d 74 20|RIFF....WAVEfmt
10|10 00 00 00 01 00 01 00 44 ac 00 00 88 58 01 00|
20|02 00 10 00 64 61 74 61 00 00 48 7e

])r. Mario
10th March 2005, 07:05
@tebasuna51
i read the thread from the beggining, but must have not understood something, sorry :(

so are u saying that i should use besweet to make the 6 channel wave? or to split it?
if the bug is in besplit wont it still affect the wav?
yeah, i noticed right off that nreo wasnt assigning the channels correctly, i had to switch the FL with the C channel.
from what i understand your saying i should make the 6 channle wav from the aac file using besweet. ill try that
thx a lot for the help :)

])r. Mario
10th March 2005, 07:10
oops, just reread the post
u want me to split the 6 chan wav with besweet right?
sorry for the confusion, well, my confusion anyway:)

Sakuya
10th March 2005, 07:52
In BeSweet command line, I entered this but it won't work:

BeSweet -core( -D:\input.wav D:\output1.wav -6ch )

It only shows me definitions of each switch in BeSweet. :( I have a feeling I typed it wrong for the input and output.

tebasuna51
10th March 2005, 18:14
I know, my english is very bad and can't explain you correctly.

@])r. Mario
Three choices:

1) You can open directly the wav6 in Soft Encode. Then in the square icon at the left of the first track, click in the Center Channel. The second track is automatically set to Front Left channel. All is Ok. Encode.
(See PaulCat's comments in this post)

2) If you want to split the wav6 in 6 wav mono use BeSweet

3) If you want to split the wav6 in 6 wav mono with BeSplit, after you must correct the wav header field BlockAlign, like I say to Sakuya, in the six mono wav's.

@Sakuya

BeSweet -core( -D:\input.wav D:\output1.wav -6ch ) ???

If your modified wav, by Hexedit, is D:\output1.wav, use:

BeSweet -core( -input D:\output1.wav -output D:\ -6ch )

BeSweet puts automatically the file names to: D:\FL.wav, C, FR, SL, SR, LFE

Sakuya
12th March 2005, 03:42
Thanks Tebasuna, it worked! But however, my AC3 turned out to be shortened to 22 minutes and 59 seconds by Soft Encode. Why does it do that? :( Like Paulcat said, I set Soft Encode's Encode Settings to 48000Hz and UNCHECKED "Auto". Right now, here are the steps to get everything in perfect condition, including the sample rate:

1. AAC to 6ch WAV using FAAD2
2. Hexedit
3. 44100 to 48000 using SSRC
4. 6 mono WAV using BeSweet
5. AC3 using Soft Encode

Is there a way to compact my steps? For example, do the sample rate change in BeSweet instead of SSRC? That would make it much easier by using just one code in BeSweet to change the sample rate and splitting the 6ch WAV into 6 mono streams.

tebasuna51
13th March 2005, 12:58
I try with:

BeSweet v1.5b29 by DSPguru.
--------------------------
Using Shibatch.dll v0.24 by Naoki Shibata & DSPguru (shibatch.sourceforge.net).

Logging start : 03/13/05 , 12:40:47.

BeSweet -core( -input g:\wav6_44.wav -6ch ) -shibatch( --rate 48000 )

[00:00:00:000] +------- BeSweet -----
[00:00:00:000] | Input : g:\wav6_44.wav
[00:00:00:000] | Output: FL, FR, SL, SR, C, LFE
[00:00:00:000] | Floating-Point Process: No
[00:00:00:000] +------ Shibatch -----
[00:00:00:000] | Source Sample-Rate: 44.1KHz
[00:00:00:000] | Dest. Sample-Rate: 48.0KHz
[00:00:00:000] | Attenuation : 0.0db
[00:00:00:000] +---------------------
[00:00:20:000] Conversion Completed !
[00:00:05:000] <-- Transcoding Duration

Logging ends : 03/13/05 , 12:40:52.

But don't work, erroneous mono wav. Sorry.

Sakuya
13th March 2005, 22:13
Ok then, thanks for the help! I'll use the steps I have above then. :D

Sakuya
8th June 2005, 02:25
Okay, I gave up on the project that needed this sort of conversion several months ago. But now, I need it again. But just in time, Hexedit is not working on me!

I have a split MKV with AAC 5.1 sound. But I don't know if it is LC or HE. I used mkvtoolnix to merge them together and then used mkvextractGUI to get the AAC file. Then I used mp_rel to get the timecodes and the AVI. Fast forward to the 6ch WAV and I have to edit the header. Hexedit loads it and when the window comes up, it crashes. It's happened for the fourth time in a row. Is the WAV too big? It's 2.94GB. Is there another way? What determines that I need to change the header? Can I just skip the header part and proceed to changing the sampling rate to 48000 in SSRC?