Peak detector (is it good ??)

DSP related issues, mathematics, processing and techniques
Post Reply
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Peak detector (is it good ??)

Post by Tepeix »

Hi,
What do you think of this peak detector ??
I wanted one that could flash fastly, detect the transient, then stop fastly too.
Was struggling a lot to make it works like i want.
This is for overdrive/distortion that would affect more the transient.
Wanted also that one note or multiple notes does approximately the same think.
(one note would normally do less envelope)

I'd like the result for now but not sure if in some way it could be too much sensible, or do some bad think...
I already seen a little problem but with not so much disagreement : Sometime it would make a peak after some note, when there is no more signal; but that's not so much a problem to distort an inexistent signal.

Any advice to make it better or problem spotting ?
Attachments
Peakdd.png
Peakdd.png (61.11 KiB) Viewed 29324 times
Peak detector.fsm
(43.12 KiB) Downloaded 1028 times
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: Peak detector (is it good ??)

Post by Tepeix »

I spot a little problem with bass..
When multiple bass notes are played the detector could continue to be up and down when we are no more on transient..
(Should have name this a transient detector more than a peak.)

I could make the release longer but not sure it's really what i want..
Separating bass and treble and treat them separately ? But this give more latency (even if it's a very little.)

I think about a cross detector that will adapt the release according to the frequency...
Attachments
TransientBass.png
TransientBass.png (64.46 KiB) Viewed 29268 times
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: Peak detector (is it good ??)

Post by Tepeix »

After day trying, i see more and more why this is difficult...

I really want to detect transient in the faster possible way. With no delay to the signal.
(I could use some and make the daw compensate..
But this is for overdrive, i'd like the idea that someone play it in real time,
also multiple filter might also be used that will add more latency... ...)

When only one note are played this is very easy.
The problem occur with multiple notes.
The resulting envelope will go up and down so much that it's hard to know if new note are done or not..
Also it's hard to know if we have a code that will works in any situation, what happens with other's waveform, dynamics, and more noise...

So the paradox of time come fastly in any direction..
If i separate the signal in band i get latency, but what happens to signal that are between the band ?
Image
Will some notes have more or less weight ??

But if not using band, it's difficult to have some setting that works well with treble and bass..

Also for the purpose of overdrive, it's really important that the detector do not oscillate when they are no transient.. Or we probably get some tremolo sound that ruin the realism..

So well it's very hard to get good result in any situation..

But finally, how an analog overdrive would do this ? Maybe it's not so much the new transient that are more affected but depending on the energy it will more overdrive when it have suddenly to produce more energy ?
Getting me to another direction...
nmakinen
Posts: 5
Joined: Fri Oct 28, 2011 5:31 am

Re: Peak detector (is it good ??)

Post by nmakinen »

Hello,

I'm not sure I understand everything you're saying, but to me it seems that you might be overcomplicating the task. In my experience the best way to separate transients from the rest is by using a simple envelope follower. The parts in the input signal that are louder than the follower's output, are basically transients.

- Nikko
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: Peak detector (is it good ??)

Post by Tepeix »

Hum it's very possible that i overcomplicate.
But the problem i have with simple envelope is that with some setting,
fast treble notes will not trigger (when after another note), and multiple bass would be ok.
Or in a different setting, treble will trigger, but multiple bass would make the trigger on and off when there's no more transient.
I even try to make the envelope not going down for 8 cross zero cycle. But it doesn't change so much..
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Peak detector (is it good ??)

Post by Spogg »

I finally had a look at this and your example.

I’ve attached an envelope follower made by Martin Vicanek that I’ve used frequently when I needed such a thing.

Maybe you could use 2 of these set with different Window sizes then subtract the outputs to give a difference signal and amplify that. The difference would give the change of level corresponding to a transient.

As you point out though, this would not play well with chords, due to the addition and subtraction that happens when you mix 2 or more sounds at different frequencies.

You might be interested to look inside an old project of mine:

viewtopic.php?f=3&t=7698&p=32288&hilit=transient#p32288
Attachments
rms envelope follower by Martin Vicanek.fsm
3.06
(178.46 KiB) Downloaded 1012 times
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: Peak detector (is it good ??)

Post by Tepeix »

Thanks, very interesting !

In fact i'm a very stupid cause i seen the envelope follower from Martin, but i notice there's a little latency, then i get the idea of some envelope that could have a very fast attack but in the end i finish with even more latency and another system !)
And now i also see that the latency is so much short that impossible to hear..

Like said Nmakinen, it's maybe not necessary to have 2 envelope, now i try to compare the original signal with the envelope, the signal is always a little louder but we could just multiply the envelope by a certain amount.
(Make me some time to understand this advice.)
..
I get some promising advancement, but as my typical problem working with flowstone, i get annother idea,
so i go to a very different region of dsp and let the project i work so much for later... Then maybe i forget some complexity of the project making hard to work again with... ...

But i hope i come back to this after finishing another code idea !)
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Peak detector (is it good ??)

Post by Spogg »

Oh dear! I forgot to attach the fsm. :oops:

Done now.
Tepeix
Posts: 361
Joined: Sat Oct 16, 2021 3:11 pm

Re: Peak detector (is it good ??)

Post by Tepeix »

Thanks, i found it but not sure i isolated it well.
I come back a little to the transient but would like to experiment more later.
Now i think about some way to separate the signal in multiple band to try avoid false trigger when a lot of note is played.. But this add more latency and not sure it's a good move..
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: Peak detector (is it good ??)

Post by Spogg »

Experimentation is a good thing and I learned a lot by doing just that. Even if you end up in a dead end the time isn’t wasted.

In my view it should be perfectly acceptable to offer a plugin as monophonic only (one note at a time). For example, pitch correction plugins are normally monophonic because to sort out a polyphonic signal is immensely difficult. I’m not convinced that band splitting would help, because the problem is worse when two or more pitches are close together so the combined signal will have higher peaks and a lower rate of interference. The side chain ripple would be less the further apart the notes are.
Post Reply