Hello guest, if you like this forum, why don't you register? https://forum.fanres.com/member.php?action=register (December 14, 2021) x


AudioMedian Tool (Median from multiple audio files)

5 Replies, 2772 Views

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: 3)
.zip   audiomedian-0.1-src.zip (Size: 961.25 KB / Downloads: 1)
(This post was last modified: 2019-02-09, 02:06 AM by TomArrow.)
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
Sadly my projects are lost due to an HDD crash... Sad
Fundamental Collection | Vimeo channel | My blog
(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.
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]
(This post was last modified: 2019-02-09, 03:53 PM by TomArrow.)
This looks cool! is there a way to have it do the opposite? [only keeping stuff outside the Median to extract vocals?]
(2019-08-23, 06:24 AM)Notelu Wrote: This looks cool! is there a way to have it do the opposite? [only keeping stuff outside the Median to extract vocals?]

Well, stictly speaking, I haven't tested the vocal removal with success yet, mainly due to a failure to find 3 perfectly synced sources. Best I found so far were 2 perfectly synced sources. Currently the best use case for this tool is to clean up multiple perfectly synced recordings of the same thing.

However there's a different method for vocal removal that I'm experimenting with, which might also do what you are after. It also requires perfectly synced sources, however it might suffice to have 2 with it.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginners Guide To Syncing Audio alexpeden2000 32 17,137 2024-01-07, 03:57 AM
Last Post: wilcof
  [Help] Fixing surround audio w/o left and right channels. qwertiio 5 2,193 2022-03-22, 02:42 PM
Last Post: Turisu
  [Help] Audio Delay - What does what bendermac 1 2,138 2021-12-10, 12:37 PM
Last Post: resolution
  Working concept syncing different audio sources SIUse 11 1,445 2021-10-17, 05:27 PM
Last Post: spoRv
Question [Help] Slow down or speed up Audio for projects bendermac 12 1,561 2021-08-24, 05:08 AM
Last Post: bendermac
  Need help choosing audio mixing software. Doctor M 5 980 2021-07-19, 03:51 AM
Last Post: Doctor M
  Splitting a video file into multiple parts alexpeden2000 1 797 2021-06-11, 07:38 AM
Last Post: schorman
  [Help] 7 mono WAV files to 6.1 allldu 22 4,621 2021-04-13, 07:36 PM
Last Post: schorman
  Should audio last (almost) as long as video? pipefan413 13 3,501 2021-04-07, 12:57 PM
Last Post: pipefan413
  Any way to test an audio file for resampling/bit-depth conversion? BusterD 5 1,374 2020-12-04, 09:46 PM
Last Post: BusterD



Users browsing this thread: 1 Guest(s)