Sound Devices patent for their method might be informative. Lots of formulas...
Thanks for pointing this out! Very useful reading. Here's also a link to a version that includes the images, which makes things more clear:
https://patentimages.storage.googleapis.com/a7/6b/f5/77e31e68cca8b7/US9654134.pdfIn fact, while I was working on the software program, I started thinking things might not be so easy as I initially thought. So far the program calculates the gain delta between the two tracks for both left and right channels, but then it made me think:
- Gain will likely drift over time independantly for both main and safety tracks (e.g. due to temperature fluctuations)
- There will be a DC offset (no matter how small), which also will drift over time
I'm not sure how big the impact of the DC offset is, and how much gain and DC offset will drift in real life situations, but it likely means I'd have to keep track of 'the current gain delta' and 'current DC offset' of both tracks in order to be able to accurately convert samples from the safety track to the level of the main track. These are some of the things that are addressed by the techniques described in the SD patent.
Another thing that's tricky and I didn't realize so far, is that a 'clipping event' can have nasty effects on the waverform for a relative long period (e.g. hundreds of milliseconds) even after the input (and output!) has lowered below clipping level, all depending the amount and duration of clipping. Dealing with this effect is also covered by the patent. As I don't have an example set of tracks of the R07, I cannot say if this effect also applies to that recorder, but I guess it will... Finally there's the 'delay difference' between the two tracks. Apparently SD's also noticed a varying signal delay in the output of the two ADC, which they apparently correct for. I don't know if it's a practical issue or a theoretical issue, and if they really correct for it, but at least it's mentioned in the patent.
Now I don't want to copy-paste the methods of solving such issues from the patent (even if I could! I'm not a mathematician

), as that would mean copyright infingement. And if I'd use more simple methods to solve these challenges in my program, I'd likely never reach the output quality of the SD devices.
I am curious how Zoom and Tascam merge the outputs of the two ADC's into a single file. Will they use the SD algorithms and pay some license fees (or not)? Have they developed their own algorithms, and how would these work? I guess nobody here knows, and those who do know are likely not allowed to tell...