Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AudioMedian Tool (Median from multiple audio files)
#1
Hey guys,

finally managed to scrape together some miniscule skills to create this.

It's a little commandline tool for Windows, written in C# and it works like this:

Code:
audiomedian input1.wav input2.wav input3.wav -o output.wav

Say for example, you use an external hardware effect (like a Surround decoder), but your soundcard has a lot of noise. Well, just create multiple recordings and then let it run through audiomedian. For each single audio sample, the Median will be calculated and written to the output file. The output file is always a 32 bit floating point WAV.

Same could probably work for capturing VHS audio tracks or analogue Laserdisc tracks, but it's important to note that the audio has to be absolutely perfectly in sync for this to work properly, otherwise you are likely to get some form of distortion/artifacts. And with perfectly, I mean sample-perfect.

Another thing I hope it might theoretically be used for is to take audio from multiple languages of a movie and use this to try and eliminate voice from the audio, to be left with only music and SFX. Though whether that can work reasonably has to be tested, as the soundmix is never 100% identical and often not 100% in sync, and even if it was, it's not clear if this would actually work. But hey, it's something to play with!

Here is the full readme for caveats, disclaimers and whatnot:
usage:

audiomedian input1.wav input2.wav input3.wav -o output.wav

Can receive odd number of input clips, that means: 3,5,7,9,11,13, etc.

Notes:
- output file will never be overwritten, make sure it doesn't exist yet.
- It doesn't matter whether you put the -o parameter in the beginning or end, or in between
- Needs odd number of input files
- Output file is 32 bit floating point WAV, no matter the input format
- Number of channels doesn't matter
- Audio formats (bit depth/sample rate/channel number) should match across all files, otherwise undefined behavior - in other words, unpredictable. You may get a result, but it may not be clear what exactly you are getting.
- Has the normal 4GB WAV file size limit. Note that the output wav has the limit too, and it's always 32 bit per channel, so it might be bigger than your input file.
- Doesn't like every WAV file. Will sometimes refuse a WAV file for weird reasons. Try resaving it with a few different tools and see if it helps.
- Code may have bugs, I'm a noob. Use at your own risk.
- There is no progress bar, just watch the output file grow
- RAM usage should be reasonable, as it doesn't read the entire files into memory, only works on the samples it currently needs. You can combine multiple 2 GB files with this no problem.

This tool uses the NAudio library for all this stuff, with a modified SampleProvider that creates the Median.

Code may have bugs, I'm a noob. Use at your own risk.

You need .NET Framework 4 I think. Possibly 3.5 for NAudio. Not 100% sure. Check source code/project if in doubt. This project was made in VS 2017 Community Edition.

Copyright: I don't care. Do whatever you want with the parts that I made. Otherwise NAudio probably has their own license or whatever.

You need .NET Framework 4.0 and possibly 3.5. I hope you don't need any others, but feel free to let me know if that is wrong.

P.S. I can not guarantee that this is mathematically/scientifically sound or whatever, as audio is a complicated subject. So in doubt, listen to your ears. Smile

Edit: I tested this with a recording done through my Dolby SDU4. Unfortunately the source noise level was already so high that not much change is noticeable, but it managed to cleanly remove some small spikes (probably voltage spikes or so?) that were present in the original captures. I wouldn't have even noticed them, as they are so quiet, but now I am glad they are gone. Smile. I did that with 3 input files.


Attached Files
.zip   audiomedian-0.1.zip (Size: 190.65 KB / Downloads: 1)
.zip   audiomedian-0.1-src.zip (Size: 961.25 KB / Downloads: 0)
Reply
Thanks given by: spoRv , PDB
#2
Nice tool!!! Ok

A question: does it work also with 5 (or 7, or 9 etc) input files?
And, would you mind (if you can) to make an easy GUI for that? Wink
Reply
Thanks given by:
#3
(2019-02-09, 02:31 AM)spoRv Wrote: Nice tool!!! Ok

A question: does it work also with 5 (or 7, or 9 etc) input files?
And, would you mind (if you can) to make an easy GUI for that? Wink

Thanks! Yes, of course. It works for any odd number of input files. Though it's possible that you might reach some limits or get crashes when you start going at it with 1001 files. Big Grin

This is also mentioned in the readme (which is included in OP as a spoiler), which I suggest you read for various disclaimers and stuff. Smile

I originally started out doing this with a GUI, but I'm kind of a C# beginner and was quickly frustrated with some issues when it comes to GUI programming. But hey, I included the source. If anyone feels like making a GUI for it, go ahead. If someday I get good enough, I might update it to have a GUI. For now, this will have to do.
Reply
Thanks given by: spoRv
#4
I did a little spectrogram comparison of the quiet intro. Again, Median made from 3 sources. See for yourself: http://screenshotcomparison.com/comparison/129750

I think there's a clear reduction in noise. Note that the source *already* has a lot of base noise that naturally cannot be filtered out, so it's kind of a bad example, but still, a proof of concept. Smile

Also note that in this spectrogram, I applied 80dB gain to even make that quiet stuff visible. That only shows that the hardware I use already has a pretty good baseline, so again, this may give even better results with some cheapo soundcards, or so I hope. If anyone tests this, please let me know, I'm thrilled to see some even more impressive results! Smile

Here's a backup, for when the screenshotcomparison link inevitably goes offline:
[Image: comparison2-crop-normal.png][Image: comparison2-crop-median.png]

For reference, here is how the original Laserdisc PCM track before decoding looks:

[Image: comparison2-crop-reference-original.png]
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Help] Fixing drift when syncing audio NeonBible 17 945 2019-08-17, 01:25 PM
Last Post: TomArrow
  Beginners Guide To Syncing Audio alexpeden2000 19 6,905 2019-08-01, 09:47 PM
Last Post: NeonBible
  Synchronizing Laserdisc audio to Bluray - missing frames Colek 14 4,057 2019-02-28, 08:11 PM
Last Post: Stamper
  Comparing Audio Fidelity alexpeden2000 3 291 2019-02-17, 04:32 PM
Last Post: alexpeden2000
  Editing mkv files Serums 2 902 2018-06-21, 08:46 AM
Last Post: Serums
  Audio and frame rates? Serums 2 804 2018-05-08, 02:56 PM
Last Post: Serums
  [Help] 2 VHS Audio Captures to remove faults. CSchmidlapp 9 1,955 2018-04-13, 06:46 PM
Last Post: CSchmidlapp
Information The Importance of the "Original-Speed" Audio jerryshadoe 25 9,135 2017-04-12, 02:16 PM
Last Post: jerryshadoe
  Mastering Laserdisc audio Colek 7 4,074 2016-01-23, 01:11 AM
Last Post: jerryshadoe

Forum Jump:


Users browsing this thread: 1 Guest(s)