sox-users@lists.sourceforge.net unofficial mirror
 help / color / Atom feed
* remove known sample from audio
@ 2018-09-25  9:26 Mikko Olkkonen
  2018-09-25 19:42 ` Jan Stary
  0 siblings, 1 reply; 7+ messages in thread
From: Mikko Olkkonen @ 2018-09-25  9:26 UTC (permalink / raw)
  To: Sox-users

[-- Attachment #1.1: Type: text/plain, Size: 1189 bytes --]

Hello,
What is the best way to subtract a known sample from given audio i.e.
extract/reconstruct the original.wav from final.wav when final.wav has been
created with commands:

sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol <Y>
sox -m original.wav knownsample_delay_gain.wav final.wav

original.wav is not anymore available. knownsample.wav and final.wav are
available. pad delay and the vol parameter are known _roughly_ (X =~10ms,
Y=~0.1)

regards, Mikk00

PS1, I can reconstruct the original with the process below but this method
is very cumbersome:
repeat {
come up with some guessed X and Y
sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol -<Y> // is
also inverted
sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat
} until RMS amplitude reported by stat has reached local minimum
I am after more streamlined way to remove known sample from given audio.

PS2, The original problem is a two musical instruments recorded
simultaneously in the same space. They have their own mics but the other
instrument is audible in each recording. I want to remove the "wrong
instrument" from each recording and have clean audio for both instruments.

[-- Attachment #1.2: Type: text/html, Size: 1635 bytes --]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hello,</div><div>What is the best way to subtract a known sample from given audio i.e. extract/reconstruct the original.wav from final.wav when final.wav has been created with commands:</div><div><br></div><div>sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol &lt;Y&gt;<br><div>sox -m original.wav  knownsample_delay_gain.wav final.wav<br></div></div><div><br></div><div>original.wav is not anymore available. knownsample.wav and final.wav are available. pad delay and the vol parameter are known _roughly_ (X =~10ms, Y=~0.1)<br></div></div><div dir="ltr"><div><br></div><div>regards, Mikk00<br></div><div><div></div><div></div></div><div><br></div><div>PS1, I can reconstruct the original with the process below but this method is very cumbersome:<br></div><div>repeat {</div><div>come up with some guessed X and Y<br></div><div>sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol -&lt;Y&gt; // is also inverted<br><div>sox -m -v 1 original.wav  -v 1 knownsample_delay_gain.wav final.wav stat<br></div></div><div></div><div><div>} until RMS amplitude reported by stat has reached local minimum<br></div><div>I am after more streamlined way to remove known sample from given audio.</div><div><br></div><div>PS2, The original problem is a two musical instruments recorded simultaneously in the same space. They have their own mics but the other instrument is audible in each recording. I want to remove the &quot;wrong instrument&quot; from each recording and have clean audio for both instruments.<br></div><div><br></div><br></div></div></div></div>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-25  9:26 remove known sample from audio Mikko Olkkonen
@ 2018-09-25 19:42 ` Jan Stary
  2018-09-26 13:49   ` Mikko Olkkonen
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Stary @ 2018-09-25 19:42 UTC (permalink / raw)
  To: sox-users

On Sep 25 12:26:36, molkko@gmail.com wrote:
> What is the best way to subtract a known sample from given audio i.e.
> extract/reconstruct the original.wav from final.wav when final.wav has been
> created with commands:
> 
> sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol <Y>
> sox -m original.wav knownsample_delay_gain.wav final.wav

First of all, by "sample", you mean "signal",
not some one sample value, right?

> original.wav is not anymore available. knownsample.wav and final.wav are
> available.

Do you also have knownsample_delay_gain.wav ?

> pad delay and the vol parameter are known _roughly_ (X =~10ms,
> Y=~0.1)

So you want to reconstruct original.wav from the mix
AND one of the originals - that's quite different than reconstructing
from just the mix.wav (which I doubt would be possible).

> PS1, I can reconstruct the original with the process below but this method
> is very cumbersome:
> repeat {
> come up with some guessed X and Y
> sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol -<Y> // is
> also inverted
> sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat
> } until RMS amplitude reported by stat has reached local minimum

You said you no longer have original.wav, but you are using it here.
So what's there to reconstruct?

> PS2, The original problem is a two musical instruments recorded
> simultaneously in the same space. They have their own mics but the other
> instrument is audible in each recording. I want to remove the "wrong
> instrument" from each recording and have clean audio for both instruments.

https://en.wikipedia.org/wiki/Spill_(audio)
This should be your starting paragraph, not PS2.

So show us the files: the mix (final.wav) and
the non-delayed bleeding instrument (knownsample.wav).
Also, name them more plainly (guitar, trumpet, mix - or whatever).

It will be much easier to help you then.


	Jan



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-25 19:42 ` Jan Stary
@ 2018-09-26 13:49   ` Mikko Olkkonen
  2018-09-26 18:16     ` Jan Stary
  0 siblings, 1 reply; 7+ messages in thread
From: Mikko Olkkonen @ 2018-09-26 13:49 UTC (permalink / raw)
  To: sox-users

[-- Attachment #1.1: Type: text/plain, Size: 3379 bytes --]

>First of all, by "sample", you mean "signal",
>not some one sample value, right?

Jan, Thanks for your comments. That wikipedia Spill article describes my
issue very well. That is, you got my request exactly right (despite my
signal vs sample terminology hassle). Anyway, I have two mics (
https://www.piksu.com/eps/tmp/mic1.wav  and
https://www.piksu.com/eps/tmp/mic2.wav) and audible spill in both. I want
to remove the spill from both. I am able to remove the spill in this
specific case (with outstanding results) for example for mic1.wav with
commands
sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13
sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat
i.e. by inverting the other mic and mixing that _at suitable_ point in time
and suitable power to the signal to be cleaned. The problem is that finding
those values ("point in time" 0.0115 and power/"volume" -0.13) is
cumbersome. Basically, I am after a command to find one given signal
embedded in another given signal. Finding means finding the starting point
in time and the volume of the to-be-removed signal.
regards, Mikk00


On Tue, Sep 25, 2018 at 11:10 PM Jan Stary <hans@stare.cz> wrote:

> On Sep 25 12:26:36, molkko@gmail.com wrote:
> > What is the best way to subtract a known sample from given audio i.e.
> > extract/reconstruct the original.wav from final.wav when final.wav has
> been
> > created with commands:
> >
> > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol <Y>
> > sox -m original.wav knownsample_delay_gain.wav final.wav
>
> First of all, by "sample", you mean "signal",
> not some one sample value, right?
>
> > original.wav is not anymore available. knownsample.wav and final.wav are
> > available.
>
> Do you also have knownsample_delay_gain.wav ?
>
> > pad delay and the vol parameter are known _roughly_ (X =~10ms,
> > Y=~0.1)
>
> So you want to reconstruct original.wav from the mix
> AND one of the originals - that's quite different than reconstructing
> from just the mix.wav (which I doubt would be possible).
>
> > PS1, I can reconstruct the original with the process below but this
> method
> > is very cumbersome:
> > repeat {
> > come up with some guessed X and Y
> > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol -<Y> // is
> > also inverted
> > sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat
> > } until RMS amplitude reported by stat has reached local minimum
>
> You said you no longer have original.wav, but you are using it here.
> So what's there to reconstruct?
>
> > PS2, The original problem is a two musical instruments recorded
> > simultaneously in the same space. They have their own mics but the other
> > instrument is audible in each recording. I want to remove the "wrong
> > instrument" from each recording and have clean audio for both
> instruments.
>
> https://en.wikipedia.org/wiki/Spill_(audio)
> This should be your starting paragraph, not PS2.
>
> So show us the files: the mix (final.wav) and
> the non-delayed bleeding instrument (knownsample.wav).
> Also, name them more plainly (guitar, trumpet, mix - or whatever).
>
> It will be much easier to help you then.
>
>
>         Jan
>
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
>


-- 
Terveisin, Mikko
+358-40 506 6146

[-- Attachment #1.2: Type: text/html, Size: 4824 bytes --]

<div dir="ltr"><div dir="ltr"><div dir="ltr">&gt;First of all, by &quot;sample&quot;, you mean &quot;signal&quot;,<br><div>
&gt;not some one sample value, right?<span class="gmail-im"><br></span></div><div><br></div><div></div><div>Jan, Thanks for your comments. That wikipedia Spill article describes my issue very well. That is, you got my request exactly right (despite my signal vs sample terminology hassle). Anyway, I have two mics (<a href="https://www.piksu.com/eps/tmp/mic1.wav">https://www.piksu.com/eps/tmp/mic1.wav</a>  and  <a href="https://www.piksu.com/eps/tmp/mic2.wav">https://www.piksu.com/eps/tmp/mic2.wav</a>) and audible spill in both. I want to remove the spill from both. I am able to remove the spill in this specific case (with outstanding results) for example for mic1.wav with commands</div><div>sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13<br>sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat<br></div>i.e. by inverting the other mic and mixing that _at suitable_ point in time and suitable power to the signal to be cleaned. The problem is that finding those values (&quot;point in time&quot; 0.0115 and power/&quot;volume&quot; -0.13) is cumbersome. Basically, I am after a command to find one given signal embedded in another given signal. Finding means finding the starting point in time and the volume of the to-be-removed signal.</div><div>regards, Mikk00</div><div><br></div><div dir="ltr"><div><span class="gmail-im"></span></div><div><span class="gmail-im"></span></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 25, 2018 at 11:10 PM Jan Stary &lt;<a href="mailto:hans@stare.cz">hans@stare.cz</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sep 25 12:26:36, <a href="mailto:molkko@gmail.com" target="_blank">molkko@gmail.com</a> wrote:<br>
&gt; What is the best way to subtract a known sample from given audio i.e.<br>
&gt; extract/reconstruct the original.wav from final.wav when final.wav has been<br>
&gt; created with commands:<br>
&gt; <br>
&gt; sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol &lt;Y&gt;<br>
&gt; sox -m original.wav knownsample_delay_gain.wav final.wav<br>
<br>
First of all, by &quot;sample&quot;, you mean &quot;signal&quot;,<br>
not some one sample value, right?<br>
<br>
&gt; original.wav is not anymore available. knownsample.wav and final.wav are<br>
&gt; available.<br>
<br>
Do you also have knownsample_delay_gain.wav ?<br>
<br>
&gt; pad delay and the vol parameter are known _roughly_ (X =~10ms,<br>
&gt; Y=~0.1)<br>
<br>
So you want to reconstruct original.wav from the mix<br>
AND one of the originals - that&#39;s quite different than reconstructing<br>
from just the mix.wav (which I doubt would be possible).<br>
<br>
&gt; PS1, I can reconstruct the original with the process below but this method<br>
&gt; is very cumbersome:<br>
&gt; repeat {<br>
&gt; come up with some guessed X and Y<br>
&gt; sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol -&lt;Y&gt; // is<br>
&gt; also inverted<br>
&gt; sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat<br>
&gt; } until RMS amplitude reported by stat has reached local minimum<br>
<br>
You said you no longer have original.wav, but you are using it here.<br>
So what&#39;s there to reconstruct?<br>
<br>
&gt; PS2, The original problem is a two musical instruments recorded<br>
&gt; simultaneously in the same space. They have their own mics but the other<br>
&gt; instrument is audible in each recording. I want to remove the &quot;wrong<br>
&gt; instrument&quot; from each recording and have clean audio for both instruments.<br>
<br>
<a href="https://en.wikipedia.org/wiki/Spill_(audio)" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Spill_(audio)</a><br>
This should be your starting paragraph, not PS2.<br>
<br>
So show us the files: the mix (final.wav) and<br>
the non-delayed bleeding instrument (knownsample.wav).<br>
Also, name them more plainly (guitar, trumpet, mix - or whatever).<br>
<br>
It will be much easier to help you then.<br>
<br>
<br>
        Jan<br>
<br>
<br>
<br>
_______________________________________________<br>
Sox-users mailing list<br>
<a href="mailto:Sox-users@lists.sourceforge.net" target="_blank">Sox-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/sox-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/sox-users</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Terveisin, Mikko</div><div>+358-40 506 6146</div><div><br></div></div></div>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-26 13:49   ` Mikko Olkkonen
@ 2018-09-26 18:16     ` Jan Stary
  2018-09-26 18:35       ` Jan Stary
  2018-09-27  6:24       ` Mikko Olkkonen
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Stary @ 2018-09-26 18:16 UTC (permalink / raw)
  To: sox-users

On Sep 26 16:49:31, molkko@gmail.com wrote:
> I have two mics
> https://www.piksu.com/eps/tmp/mic1.wav
> https://www.piksu.com/eps/tmp/mic2.wav
> and audible spill in both.

Yeah, the bass is not very precise and a bit behind the tempo.

> I want to remove the spill from both.

That's something different from what you described in
the original mail, but I understand your problem now.

> I am able to remove the spill in this
> specific case (with outstanding results)
> for example for mic1.wav with commands
> sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13
> sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat
> i.e. by inverting the other mic and mixing that _at suitable_ point in time
> and suitable power to the signal to be cleaned.

Indeed, it is very good. (The -v 1 are imho not necessary.)

> The problem is that finding those values ("point in time" 0.0115
> and power/"volume" -0.13) is cumbersome. Basically, I am after a command
> to find one given signal embedded in another given signal.

That is very expensive, computation-wise. To find the offset,
I would compute the correlation of the mic1.wav and mic2.wav signals
for every suspected delay (say, for 0 to 0.1, with a step of 0.01)
and take the one where the correlation is maximal.

Then "remove" the properly-delayed mic1id.wav from mic2.wav as above,
again with various levels of vol, and pick the one for which the
resulting "clean" signal has the maximal correlation with
the original mic2.wav.

This problem must be as old as DSP.
http://www.dspguide.com/


	Jan


> 
> On Tue, Sep 25, 2018 at 11:10 PM Jan Stary <hans@stare.cz> wrote:
> 
> > On Sep 25 12:26:36, molkko@gmail.com wrote:
> > > What is the best way to subtract a known sample from given audio i.e.
> > > extract/reconstruct the original.wav from final.wav when final.wav has
> > been
> > > created with commands:
> > >
> > > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol <Y>
> > > sox -m original.wav knownsample_delay_gain.wav final.wav
> >
> > First of all, by "sample", you mean "signal",
> > not some one sample value, right?
> >
> > > original.wav is not anymore available. knownsample.wav and final.wav are
> > > available.
> >
> > Do you also have knownsample_delay_gain.wav ?
> >
> > > pad delay and the vol parameter are known _roughly_ (X =~10ms,
> > > Y=~0.1)
> >
> > So you want to reconstruct original.wav from the mix
> > AND one of the originals - that's quite different than reconstructing
> > from just the mix.wav (which I doubt would be possible).
> >
> > > PS1, I can reconstruct the original with the process below but this
> > method
> > > is very cumbersome:
> > > repeat {
> > > come up with some guessed X and Y
> > > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol -<Y> // is
> > > also inverted
> > > sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat
> > > } until RMS amplitude reported by stat has reached local minimum
> >
> > You said you no longer have original.wav, but you are using it here.
> > So what's there to reconstruct?
> >
> > > PS2, The original problem is a two musical instruments recorded
> > > simultaneously in the same space. They have their own mics but the other
> > > instrument is audible in each recording. I want to remove the "wrong
> > > instrument" from each recording and have clean audio for both
> > instruments.
> >
> > https://en.wikipedia.org/wiki/Spill_(audio)
> > This should be your starting paragraph, not PS2.
> >
> > So show us the files: the mix (final.wav) and
> > the non-delayed bleeding instrument (knownsample.wav).
> > Also, name them more plainly (guitar, trumpet, mix - or whatever).
> >
> > It will be much easier to help you then.
> >
> >
> >         Jan
> >
> >
> >
> > _______________________________________________
> > Sox-users mailing list
> > Sox-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sox-users
> >
> 
> 
> -- 
> Terveisin, Mikko
> +358-40 506 6146


> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-26 18:16     ` Jan Stary
@ 2018-09-26 18:35       ` Jan Stary
  2018-09-27  6:24       ` Mikko Olkkonen
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Stary @ 2018-09-26 18:35 UTC (permalink / raw)
  To: sox-users

On Sep 26 20:16:51, hans@stare.cz wrote:
> > I am able to remove the spill in this
> > specific case (with outstanding results)
> > for example for mic1.wav with commands
> > sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13
> > sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat
> > i.e. by inverting the other mic and mixing that _at suitable_ point in time
> > and suitable power to the signal to be cleaned.

343 * 0.0115 = 3.9445, so was the drums about 4 meters from the bass mic?


I tried fiddling with the constants you found.
For example, shifting the vol from -0.13 by steps of 0.01 to -0.19
(the rest of the process being the same) becomes almost as bad as
the original problem rather rapidly. So the "peak" on the scale
of volume-candidates should be quite sharp.

Even more so for the delay (not surprisingly): both 0.0114 and 0.0116
already sound no good. So the scale for the delay candidates should be
at least as fine as 0.0001, and the peak should again be sharp.

Jan



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-26 18:16     ` Jan Stary
  2018-09-26 18:35       ` Jan Stary
@ 2018-09-27  6:24       ` Mikko Olkkonen
  2018-09-27  9:48         ` Jan Stary
  1 sibling, 1 reply; 7+ messages in thread
From: Mikko Olkkonen @ 2018-09-27  6:24 UTC (permalink / raw)
  To: sox-users

[-- Attachment #1.1: Type: text/plain, Size: 5561 bytes --]

Jan Stary <hans@stare.cz> wrote:
>343 * 0.0115 = 3.9445, so was the drums about 4 meters from the bass mic?
Basically yes. Delays after the mics can be assumed negligible and/or
equal. I can do the spill removal by trying out various values and picking
up with the one with maximal correlation. Or maybe I implement some script
that does that fiddling, lets see. Anyway, my idea when posting this issue
was that maybe there is some clever way to use sox where I could avoid that
manual operation (or scripting) required to find delay and vol that deliver
the maximum correlation. I believe that at least audio watermarking folks
must have streamlined this procedure so that they can detect their
watermarks even if their audio has been (slightly) tweaked. It beats me
that the wikipedia spill article did not discuss this postprocessing
approach. It was all about studio setup that minimizes the problem _during_
the recording.
Mikk00


On Wed, Sep 26, 2018 at 9:17 PM Jan Stary <hans@stare.cz> wrote:

> On Sep 26 16:49:31, molkko@gmail.com wrote:
> > I have two mics
> > https://www.piksu.com/eps/tmp/mic1.wav
> > https://www.piksu.com/eps/tmp/mic2.wav
> > and audible spill in both.
>
> Yeah, the bass is not very precise and a bit behind the tempo.
>
> > I want to remove the spill from both.
>
> That's something different from what you described in
> the original mail, but I understand your problem now.
>
> > I am able to remove the spill in this
> > specific case (with outstanding results)
> > for example for mic1.wav with commands
> > sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13
> > sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat
> > i.e. by inverting the other mic and mixing that _at suitable_ point in
> time
> > and suitable power to the signal to be cleaned.
>
> Indeed, it is very good. (The -v 1 are imho not necessary.)
>
> > The problem is that finding those values ("point in time" 0.0115
> > and power/"volume" -0.13) is cumbersome. Basically, I am after a command
> > to find one given signal embedded in another given signal.
>
> That is very expensive, computation-wise. To find the offset,
> I would compute the correlation of the mic1.wav and mic2.wav signals
> for every suspected delay (say, for 0 to 0.1, with a step of 0.01)
> and take the one where the correlation is maximal.
>
> Then "remove" the properly-delayed mic1id.wav from mic2.wav as above,
> again with various levels of vol, and pick the one for which the
> resulting "clean" signal has the maximal correlation with
> the original mic2.wav.
>
> This problem must be as old as DSP.
> http://www.dspguide.com/
>
>
>         Jan
>
>
> >
> > On Tue, Sep 25, 2018 at 11:10 PM Jan Stary <hans@stare.cz> wrote:
> >
> > > On Sep 25 12:26:36, molkko@gmail.com wrote:
> > > > What is the best way to subtract a known sample from given audio i.e.
> > > > extract/reconstruct the original.wav from final.wav when final.wav
> has
> > > been
> > > > created with commands:
> > > >
> > > > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol <Y>
> > > > sox -m original.wav knownsample_delay_gain.wav final.wav
> > >
> > > First of all, by "sample", you mean "signal",
> > > not some one sample value, right?
> > >
> > > > original.wav is not anymore available. knownsample.wav and final.wav
> are
> > > > available.
> > >
> > > Do you also have knownsample_delay_gain.wav ?
> > >
> > > > pad delay and the vol parameter are known _roughly_ (X =~10ms,
> > > > Y=~0.1)
> > >
> > > So you want to reconstruct original.wav from the mix
> > > AND one of the originals - that's quite different than reconstructing
> > > from just the mix.wav (which I doubt would be possible).
> > >
> > > > PS1, I can reconstruct the original with the process below but this
> > > method
> > > > is very cumbersome:
> > > > repeat {
> > > > come up with some guessed X and Y
> > > > sox knownsample.wav knownsample_delay_gain.wav pad <X> 0 vol -<Y> //
> is
> > > > also inverted
> > > > sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav
> stat
> > > > } until RMS amplitude reported by stat has reached local minimum
> > >
> > > You said you no longer have original.wav, but you are using it here.
> > > So what's there to reconstruct?
> > >
> > > > PS2, The original problem is a two musical instruments recorded
> > > > simultaneously in the same space. They have their own mics but the
> other
> > > > instrument is audible in each recording. I want to remove the "wrong
> > > > instrument" from each recording and have clean audio for both
> > > instruments.
> > >
> > > https://en.wikipedia.org/wiki/Spill_(audio)
> > > This should be your starting paragraph, not PS2.
> > >
> > > So show us the files: the mix (final.wav) and
> > > the non-delayed bleeding instrument (knownsample.wav).
> > > Also, name them more plainly (guitar, trumpet, mix - or whatever).
> > >
> > > It will be much easier to help you then.
> > >
> > >
> > >         Jan
> > >
> > >
> > >
> > > _______________________________________________
> > > Sox-users mailing list
> > > Sox-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/sox-users
> > >
> >
> >
> > --
> > Terveisin, Mikko
> > +358-40 506 6146
>
>
> > _______________________________________________
> > Sox-users mailing list
> > Sox-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/sox-users
>
>
>
> _______________________________________________
> Sox-users mailing list
> Sox-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sox-users
>

[-- Attachment #1.2: Type: text/html, Size: 7989 bytes --]

<div dir="ltr"><div>Jan Stary &lt;<a href="mailto:hans@stare.cz" target="_blank">hans@stare.cz</a>&gt; wrote:</div><div>&gt;343 * 0.0115 = 3.9445, so was the drums about 4 meters from the bass mic?</div><div dir="ltr"></div><div>Basically yes. Delays after the mics can be assumed negligible and/or equal. I can do the spill removal by trying out various values and picking up with the one with maximal correlation. Or maybe I implement some script that does that fiddling, lets see. Anyway, my idea when posting this issue was that maybe there is some clever way to use sox where I could avoid that manual operation (or scripting) required to find delay and vol that deliver the maximum correlation. I believe that at least audio watermarking folks must have streamlined this procedure so that they can detect their watermarks even if their audio has been (slightly) tweaked. It beats me that the wikipedia spill article did not discuss this postprocessing approach. It was all about studio setup that minimizes the problem _during_ the recording.<br></div><div>Mikk00</div><div><br></div><br></div><div class="gmail_quote"><div dir="ltr">On Wed, Sep 26, 2018 at 9:17 PM Jan Stary &lt;<a href="mailto:hans@stare.cz" target="_blank">hans@stare.cz</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sep 26 16:49:31, <a href="mailto:molkko@gmail.com" target="_blank">molkko@gmail.com</a> wrote:<br>
&gt; I have two mics<br>
&gt; <a href="https://www.piksu.com/eps/tmp/mic1.wav" rel="noreferrer" target="_blank">https://www.piksu.com/eps/tmp/mic1.wav</a><br>
&gt; <a href="https://www.piksu.com/eps/tmp/mic2.wav" rel="noreferrer" target="_blank">https://www.piksu.com/eps/tmp/mic2.wav</a><br>
&gt; and audible spill in both.<br>
<br>
Yeah, the bass is not very precise and a bit behind the tempo.<br>
<br>
&gt; I want to remove the spill from both.<br>
<br>
That&#39;s something different from what you described in<br>
the original mail, but I understand your problem now.<br>
<br>
&gt; I am able to remove the spill in this<br>
&gt; specific case (with outstanding results)<br>
&gt; for example for mic1.wav with commands<br>
&gt; sox mic2.wav mic2id.wav pad 0.0115 0 vol -0.13<br>
&gt; sox -m -v 1 mic1.wav -v 1 mic2id.wav mic1clean.wav stat<br>
&gt; i.e. by inverting the other mic and mixing that _at suitable_ point in time<br>
&gt; and suitable power to the signal to be cleaned.<br>
<br>
Indeed, it is very good. (The -v 1 are imho not necessary.)<br>
<br>
&gt; The problem is that finding those values (&quot;point in time&quot; 0.0115<br>
&gt; and power/&quot;volume&quot; -0.13) is cumbersome. Basically, I am after a command<br>
&gt; to find one given signal embedded in another given signal.<br>
<br>
That is very expensive, computation-wise. To find the offset,<br>
I would compute the correlation of the mic1.wav and mic2.wav signals<br>
for every suspected delay (say, for 0 to 0.1, with a step of 0.01)<br>
and take the one where the correlation is maximal.<br>
<br>
Then &quot;remove&quot; the properly-delayed mic1id.wav from mic2.wav as above,<br>
again with various levels of vol, and pick the one for which the<br>
resulting &quot;clean&quot; signal has the maximal correlation with<br>
the original mic2.wav.<br>
<br>
This problem must be as old as DSP.<br>
<a href="http://www.dspguide.com/" rel="noreferrer" target="_blank">http://www.dspguide.com/</a><br>
<br>
<br>
        Jan<br>
<br>
<br>
&gt; <br>
&gt; On Tue, Sep 25, 2018 at 11:10 PM Jan Stary &lt;<a href="mailto:hans@stare.cz" target="_blank">hans@stare.cz</a>&gt; wrote:<br>
&gt; <br>
&gt; &gt; On Sep 25 12:26:36, <a href="mailto:molkko@gmail.com" target="_blank">molkko@gmail.com</a> wrote:<br>
&gt; &gt; &gt; What is the best way to subtract a known sample from given audio i.e.<br>
&gt; &gt; &gt; extract/reconstruct the original.wav from final.wav when final.wav has<br>
&gt; &gt; been<br>
&gt; &gt; &gt; created with commands:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol &lt;Y&gt;<br>
&gt; &gt; &gt; sox -m original.wav knownsample_delay_gain.wav final.wav<br>
&gt; &gt;<br>
&gt; &gt; First of all, by &quot;sample&quot;, you mean &quot;signal&quot;,<br>
&gt; &gt; not some one sample value, right?<br>
&gt; &gt;<br>
&gt; &gt; &gt; original.wav is not anymore available. knownsample.wav and final.wav are<br>
&gt; &gt; &gt; available.<br>
&gt; &gt;<br>
&gt; &gt; Do you also have knownsample_delay_gain.wav ?<br>
&gt; &gt;<br>
&gt; &gt; &gt; pad delay and the vol parameter are known _roughly_ (X =~10ms,<br>
&gt; &gt; &gt; Y=~0.1)<br>
&gt; &gt;<br>
&gt; &gt; So you want to reconstruct original.wav from the mix<br>
&gt; &gt; AND one of the originals - that&#39;s quite different than reconstructing<br>
&gt; &gt; from just the mix.wav (which I doubt would be possible).<br>
&gt; &gt;<br>
&gt; &gt; &gt; PS1, I can reconstruct the original with the process below but this<br>
&gt; &gt; method<br>
&gt; &gt; &gt; is very cumbersome:<br>
&gt; &gt; &gt; repeat {<br>
&gt; &gt; &gt; come up with some guessed X and Y<br>
&gt; &gt; &gt; sox knownsample.wav knownsample_delay_gain.wav pad &lt;X&gt; 0 vol -&lt;Y&gt; // is<br>
&gt; &gt; &gt; also inverted<br>
&gt; &gt; &gt; sox -m -v 1 original.wav -v 1 knownsample_delay_gain.wav final.wav stat<br>
&gt; &gt; &gt; } until RMS amplitude reported by stat has reached local minimum<br>
&gt; &gt;<br>
&gt; &gt; You said you no longer have original.wav, but you are using it here.<br>
&gt; &gt; So what&#39;s there to reconstruct?<br>
&gt; &gt;<br>
&gt; &gt; &gt; PS2, The original problem is a two musical instruments recorded<br>
&gt; &gt; &gt; simultaneously in the same space. They have their own mics but the other<br>
&gt; &gt; &gt; instrument is audible in each recording. I want to remove the &quot;wrong<br>
&gt; &gt; &gt; instrument&quot; from each recording and have clean audio for both<br>
&gt; &gt; instruments.<br>
&gt; &gt;<br>
&gt; &gt; <a href="https://en.wikipedia.org/wiki/Spill_(audio)" rel="noreferrer" target="_blank">https://en.wikipedia.org/wiki/Spill_(audio)</a><br>
&gt; &gt; This should be your starting paragraph, not PS2.<br>
&gt; &gt;<br>
&gt; &gt; So show us the files: the mix (final.wav) and<br>
&gt; &gt; the non-delayed bleeding instrument (knownsample.wav).<br>
&gt; &gt; Also, name them more plainly (guitar, trumpet, mix - or whatever).<br>
&gt; &gt;<br>
&gt; &gt; It will be much easier to help you then.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;         Jan<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Sox-users mailing list<br>
&gt; &gt; <a href="mailto:Sox-users@lists.sourceforge.net" target="_blank">Sox-users@lists.sourceforge.net</a><br>
&gt; &gt; <a href="https://lists.sourceforge.net/lists/listinfo/sox-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/sox-users</a><br>
&gt; &gt;<br>
&gt; <br>
&gt; <br>
&gt; -- <br>
&gt; Terveisin, Mikko<br>
&gt; +358-40 506 6146<br>
<br>
<br>
&gt; _______________________________________________<br>
&gt; Sox-users mailing list<br>
&gt; <a href="mailto:Sox-users@lists.sourceforge.net" target="_blank">Sox-users@lists.sourceforge.net</a><br>
&gt; <a href="https://lists.sourceforge.net/lists/listinfo/sox-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/sox-users</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Sox-users mailing list<br>
<a href="mailto:Sox-users@lists.sourceforge.net" target="_blank">Sox-users@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/sox-users" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/sox-users</a><br>
</blockquote></div>

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: remove known sample from audio
  2018-09-27  6:24       ` Mikko Olkkonen
@ 2018-09-27  9:48         ` Jan Stary
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Stary @ 2018-09-27  9:48 UTC (permalink / raw)
  To: sox-users

On Sep 27 09:24:59, molkko@gmail.com wrote:
> I can do the spill removal by trying out various values and picking
> up with the one with maximal correlation. Or maybe I implement some script
> that does that fiddling, lets see.

It goes without saying you do that with a program, not by hand :-)

> Anyway, my idea when posting this issue
> was that maybe there is some clever way to use sox where I could avoid that
> manual operation (or scripting) required to find delay and vol that deliver
> the maximum correlation.

I don't think it can be done with just sox itself.

	Jan



_______________________________________________
Sox-users mailing list
Sox-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, back to index

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25  9:26 remove known sample from audio Mikko Olkkonen
2018-09-25 19:42 ` Jan Stary
2018-09-26 13:49   ` Mikko Olkkonen
2018-09-26 18:16     ` Jan Stary
2018-09-26 18:35       ` Jan Stary
2018-09-27  6:24       ` Mikko Olkkonen
2018-09-27  9:48         ` Jan Stary

sox-users@lists.sourceforge.net unofficial mirror

Archives are clonable: git clone --mirror https://public-inbox.org/sox-users

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.sox
	nntp://ou63pmih66umazou.onion/inbox.comp.audio.sox
	nntp://news.gmane.org/gmane.comp.audio.sox

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox