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


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: 3)
.zip   audiomedian-0.1-src.zip (Size: 961.25 KB / Downloads: 1)
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:
#5
This looks cool! is there a way to have it do the opposite? [only keeping stuff outside the Median to extract vocals?]
Reply
Thanks given by:
#6
(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.
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Help] How to apply delay to a whole video file, not just the video or audio streams? Red41804 7 2,153 2024-02-12, 11:03 AM
Last Post: Hitcher
Music [Help] Detect whether 2.0 Audio is Dual Mono or Stereo GjRedo 2 1,253 2023-12-09, 08:35 PM
Last Post: Doctor M
Question [Help] Slow down or speed up Audio for projects bendermac 18 7,192 2023-08-25, 01:59 AM
Last Post: Falcon
  [Help] 2 VHS Audio Captures to remove faults. CSchmidlapp 16 11,315 2023-07-03, 12:15 AM
Last Post: wongfeihung
  [Help] Identify and Repair an Audio Artifact axeyou 2 1,394 2023-06-14, 08:59 AM
Last Post: axeyou
  [Help] Automatically Sync The Audio From Another Source? Endocryne 1 1,784 2022-10-09, 09:47 AM
Last Post: Serums
  Working concept syncing different audio sources SIUse 20 9,716 2022-06-23, 05:08 PM
Last Post: alleycat
  [Help] Audio Delay - What does what bendermac 1 1,637 2021-12-10, 12:37 PM
Last Post: resolution
  Need help choosing audio mixing software. Doctor M 5 3,311 2021-07-19, 03:51 AM
Last Post: Doctor M
  Splitting a video file into multiple parts alexpeden2000 1 2,089 2021-06-11, 07:38 AM
Last Post: schorman

Forum Jump:


Users browsing this thread: 1 Guest(s)