0
$\begingroup$

I have a piece of audio with a sample occurring within it multiple times. I wish to remove these occurances. However, the sample has slightly different amplitudes each time. Some of the samples occur at the same time as other sounds, and these other sounds should not be removed.

I isolate one of the samples where it occurs on its own, and then corrolate it against the audio to find where the samples occur. I then create a track with the phase inverted isolated sample, orruring at each of these locations. However, because the amplitude is slightly different each time the sample occurs, when I mix the audio with my track, I don't remove the samples completely.

enter image description here

How might I solve this issue? The locations I establish for each sample, are integer multiples of sample time. Not sure if this is also an issue. I am using a sample rate of 96kHz.

$\endgroup$

2 Answers 2

0
$\begingroup$

If this is really just a gain change, you can determine the appropriate gain with a simple least square error optimization, such as

$$ g = \text{argmin}_g \sum_n (x[n] -g\cdot s[n])^2 \tag{1}$$

where $x[n]$ is your actual signal and $s[n]$ is the template of the sample you want to remove.

By the looks of it, there is more going on than just a simple gain. If the difference is mostly the result of an LTI system (which includes sub-sample alignment) you can try an adaptive filter.

For anything non-linear or time variant (with the length of the sample) you will need a mathematical model of what's actually happening, identify the model parameters for each sample location and apply the model to the template before subtracting it out.

$\endgroup$
2
  • $\begingroup$ thanks for your answer. Would you have a guess as to what else might be going on than just a simple gain change? I guess the audio file might have compression applied to it, which would complicate what I'm trying to do. $\endgroup$
    – Baz
    Commented Aug 4 at 9:14
  • $\begingroup$ Hard to say without access to the actual data. It looks like a bit of compression and a bit of low pass filtering. Can you ask the person who created the file/recording? $\endgroup$
    – Hilmar
    Commented Aug 4 at 15:08
0
$\begingroup$

1. Because you managed to get a sample of the isolated occurrence, correlating to tell where it happens and then attempting removal is the correct approach.

2. However before correlating

you have to normalize each block signal power to have same energy, same power over the block cycle, as the occurrence to be removed,

then if present remove occurrence, and restore each cycle to the correct amplitude.

3. Split mix signal into time blocks equal span as the isolated occurrence, so split correlations no reaching peak happen.

Choosing correlation period a bit wider than the occurrence duration, which is also the chopping period to produce blocks out of the mix signal, may be prudent.

4. So the processing loop would be

  • Find out isolated occurrence total energy and divide by occurrence time duration.

    You can choose this amount as reference power, to reduce calculations.

    Choosing a different reference power than the occurrence's means both isolated occurrence and mix blocks have to be normalized to whatever chosen power reference.

  • Then take each mix time block, and normalize each to the power reference, one at a time.

  • Correlate each mix block with isolated occurrence: If occurrence showed up, remove. else on to next mix block.

5. If you supply the isolated occurrence and a bit of mixed signal in any common audio format attached to your question I should be able to show how to do it in MATLAB.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.