Mixing with Surround Channel (01/30/20)
While building my tracked music player that's written in Go, Gotracker, I noticed that a few formats referred to Surround Sound (specifically, Dolby Pro Logic II). I remember researching how to achieve Pro Logic surround sound encoding a few decades ago, but I didn't recall how to achieve it in source code. Apparently, it's really simple - like, extremely so... or so the Internet would have you believe at first glance.
When you go to do your final mix before heading the audio data out to the sound device, you take your surround channel and mix it into the left channel with a +90° phase and the right channel with a -90° phase. However, it's not exactly as simple as that.
Here's the full process, in brief:
1. The Surround channel is a monaural channel that does not link to any other channels via positional variation - cross-fading with the surround channel might not do what you expect.
2. Before it heads into the bandpass filter in step 3, it needs a -3dB attenuation.
3. A bandpass filter is applied that excludes frequences outside the range between 100Hz and 7000Hz, inclusively.
4. A Dolby B-type
noise reduction (or compatible, such as dbx) filter is applied.
5. The result of step 4 is split into two channels, a left at +90° phase shift and a right at -90° phase shift.
6. The final mix occurs with the result of step 5.
In order to be 100% compatible with Pro Logic II, step 4 can't be bypassed. It reduces the fidelity of the audio pretty badly, but it's a fact of dealing with decades-old hardware, I suppose. However, modern implementations of Pro Logic (III and newer) seem to be pretty lenient about how to detect the surround channel out of the left+right channels, so you can probably get by with not implementing the B-type NR and only sometimes get bleed-through of surround audio in the left/right forward channels.
In the process of researching how to write my own, I came across some code that Derek J. Evans wrote for a Reaper JS plugin that takes a quad-channel output and generates a Pro Logic II-compatible downmix to stereo - seems pretty much right on the money for my needs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
Now to convert it to Go and slot it in somehow...