6th channel gets corrupted in .ogg files

I’ve been trying to find a way to fix this since a few days ago. It’s an issue me and some other people I know are facing and we have no idea what to do.

Here’s the deal, I’m making a music mod for a game that uses .ogg files for the music files. These tracks have 6 channels so their replacements must also have 6 channels. Obviously I set up the options accordingly so I can output 6 channel tracks: http://i.imgur.com/8eTtjy3.png

Now here’s the .mp3 file I wanna add to the game: https://drive.google.com/open?id=0B4BntwD_yaDUMmhOemg1a3pXLXc

Nothing weird so far. Converting it to 16 bit 48000Hz stereo file results in what’s expected: https://drive.google.com/open?id=0B4BntwD_yaDUcnJKdE9EckxCbWc

Now the problem is when I try to convert it to a 6 channel track. The idea is to have the song from the .mp3 in the first two channels, then have two empty channels (3 and 4) and then have the same song in channels 5 and 6. All of that can be done with ease as the procedure is simple, I add two empty channels (Shift + Ctrl + N) and then drag the song into Audacity again so it takes channel 5 and 6. Everything is resampled accordingly and everything is set to 16 bit as required by the game I’m trying to mod.

My issue is that after saving the new .ogg file with 6 channels and opening it again with audacity I find out that the last channel is corrupted and sounds all bad: https://drive.google.com/open?id=0B4BntwD_yaDUemFOUVVkQ1FucUU

This happened with every song I tried to convert into a 6 channel .ogg file. Curiously enough Audacity does not corrupt the song at all if I save it as a 5 channel .ogg and neither if I save it as a 6 channel .FLAC (And most likely any other format that supports 6 channels).

So Audacity seems to have a glitch with .ogg files with 6 channels. For extra info I’m using version 2.1.2 (Should be the last one) and running this on Windows 10 64 bit. I really need some help here in order to continue with my music mods.

This appears to be a “feature” of the Ogg encoder.
If you look at the spectrum of the 6th track you will notice that the frequencies cut off at about 2000 Hz:


Now read “1.2.3 mapping” in the Vorbis I specification:
https://xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-140001.2.3

The problem is that you need a non-standard 6 channel file that conflicts with the vorbis specification. Audacity uses the official ogg encoder (from Xiph, who write the specification).

I’ll see if I can find a workaround

OK, here’s a workaround. I’ve only tested this on Linux, but I think it should also work on Windows.

  1. You need to install the command-line Ogg encoder (oggenc). It’s available here: http://www.rarewares.org/ogg-oggenc.php
    (I know that the web address looks dodgy, but it’s a well known site for audio encoders/decoders. As with all downloads, you should check the safety of the download with an up-to-date reputable malware scanner, such as: https://www.virustotal.com/)

  2. Set Audacity preferences for “custom mix” (Edit >Preferences > Export)

  3. Import / record / create your stereo file.
    No need to make multiple tracks. We can use Audacity’s channel mapper (“Advanced Mixing Options”)

  4. Export audio with the “(external program)” option, and enter the following as the command:

oggenc -r -C 6 --advanced-encode-option disable_coupling=Y - -o "%f"

Also tick the “show output” option so that you can see any error messages.

Note: You must include the file extension in the file name, for example: test-file-6-chan.ogg
(I prefer to avoid spaces in file names because they can cause problems with applications)

  1. In the “Advanced Mixing Options”, move the slider up to 6 channels, then click on the boxes as necessary to create a channel map like this:
    channel-map.png
    And, fingers crossed, that should do it.

Thanks, Steve for that research.

One thing to add for Windows is that you’ll have to click the “Browse…” button to right of where you enter the command, or otherwise type the full path to oggenc2.exe. If the path contains spaces, you must enclose the path in quotes.


Gale

Thank you very much! This definitely solved my issue with the sixth channel. There are a few issues to iron that weren’t present before though.

  1. The channel order in the finished product is different. I ordered channels 1 to 6 from shortest to longest and this was the result: http://i.imgur.com/b8ZcWM9.png This also happens if you just have 2 channels and add the rest via the channel mapping option. This is the least important of my issues since I can just readjust my workflow with this in mind and adds no extra time needed for each conversion really so it’s not an issue that needs fixing.

  2. It gets rid of my metadata. I can simply edit it via winamp but if there’s a way to keep the metadata from the original file or at least get the metadata edit prompt before finishing the export so I can write the 3 needed parameters by myself that would be awesome.

  3. IMPORTANT ISSUE: The finished product is set to 44100Hz instead of 48000Hz no matter what I do. The song is resampled beforehand, the project rate is set to 48000Hz too and the default rate for any new channel created is also set to 48000Hz. The output is still a 16-bit PCM as expected but I really need a way to have this one thing fixed.

I am guessing that having decoupled you are stuck with the different order. Perhaps Steve knows more.

See Ubuntu Manpage: oggenc - encode audio into the Ogg Vorbis format if you need to add tags back. There are examples at the bottom of that page.

For the sample rate issue I think you will need to add

-R 48000

Gale

Thank you for your help guys! I can finally add the custom music to the game thanks to all this new info. I’ll just use winamp to take care of the custom metadata info and the channel order is fixed by simply having the channels arranged before exporting the track to compensate for the weird channel switching so is not a big deal.

OK I just found a veeeeeeeeeery minor problem. There’s a little crack sound that lasts not even 1/4 of a second at the start of the songs. Guess I’ll have to deal with that, I hope anyone who uses the mod never notices it.

You mean the crack is only in the OGG exported with oggenc? Not in the MP3 and not in the OGG exported with Audacity’s OGG encoder? Is it only in the game that you hear this problem?


Gale

Ah sorry I wasn’t clear enough. The tiny crack is only present in the finished .ogg file after the exporting is done: http://i.imgur.com/3ZBzyAr.png

See that veeeeeery slim blue vertical line right at the beginning of every channel, including the empty ones? That makes a very tiny cracking noise. This is an example file: https://drive.google.com/open?id=0B4BntwD_yaDULUExU1VwUDhoUkU

And only oggenc does this, not Audacity’s OGG encoder?

Does it happen if you don’t add metadata in WinAmp? Does it happen if before exporting you open File > Edit Metadata Tags… and remove the existing metadata?


Gale

Only oggenc causes the cracks. I grabbed a .mp3 file, cleaned the metadata and then converted it to .ogg via the standard methods and opened that .ogg in another Audacity window and no cracks where present.

If I do the same with oggenc instead then the cracks appear.

The oggenc starting click problem only happens in Audacity, whether because of the necessity of specifying raw input or due to something else, I don’t know.

After importing your file https://drive.google.com/file/d/0B4BntwD_yaDULUExU1VwUDhoUkU/view into Audacity, I emptied the metadata (not that metadata is the cause) and deleted the click noise in all tracks, then exported as 48000 Hz 6-channel 16-bit WAV, called “6.wav”.

Then I let oggenc2 convert 6.wav on its own:

C:\Program Files (x86)\oggenc2.88-1.3.5-generic>oggenc2 6.wav --advanced-encode-option disable_coupling=Y -o 6.ogg
Opening with wav module: WAV file reader
Encoding "6.wav" to
         "6.ogg"
at quality 3.00
Setting advanced encoder option "disable_coupling" to Y
        [ 99.8%] [ 0m00s remaining] -

Done encoding file "6.ogg"

        File length:  3m 07.0s
        Elapsed time: 0m 25.0s
        Rate:         7.4825
        Average bitrate: 395.8 kb/s

I imported the resulting “6.ogg” into Audacity and there is no noise. So there is your workaround. But you will have to change the track order again in Audacity to get it right. 6.ogg converted as above ended up with the two empty channels as channels 2 and 6.


Gale

Yep! That got rid of the clicking sound. The channels are rearranged quite a lot so I’ll have to change their order in the .wav before the final exporting but other than that this pretty much solves my last issue. Nice!

Standalone oggenc2 also adds the starting click if you specify raw input then give it a WAV file to process. The click is the headers in the WAV file, which stands to reason. If you give oggenc2 a headerless PCM file and specify raw input, there is no click.

But you don’t actually need to specify raw input in Audacity. Assuming the Audacity project rate is already 48000 Hz, all you need is:

"C:\Program Files (x86)\oggenc2.88-1.3.5-generic\oggenc2.exe"  --advanced-encode-option disable_coupling=Y - -o "%f"

Gale

That did the trick, thanks! No issues left on my end now.