From the original SynthMaker forum (2004–2014), with its members’ names and dates.
tester ·
I'm looking for a simple peak detector, that will indicate only when a stream crosses certain gain threshold (for example change from red to green and stay green until "reset" is pressed). I'm having some difficulties to find it, or I don't understand correctly how it works. As far I understand, I can use "ticker" and "mono to float" (m2f) primitives to get an info from the stream, but I don't know how to make the "peak" long enough to cross the ticking routine?
infuzion ·
peak-follower from compressor/expander.
martinvicanek ·
Like this maybe?
tester ·
Something like that, thanks. However when I added the indicator/autoreset from another thread - there seem to be small problem. Sometimes, when I hit the reset (small orange led, which is also the state indicator), and the level is still above threshold - small indicator does not comes back to light (sometimes there is a doubble re-flash; I guess the reason is the same). Maybe it starts to de-sync that way after playing for a while with reset and gain slider, and it happens occasionally. Something intereferes with something else. Maybe the reset trigger with ticker? I don't know how.
oddson ·
I don't know if there is another problem here but I'd use something like this so that there is a single impulse in the reset stream instead off a blast of signal.
Unfortunately my choice to use stream booleans has stymied me in figuring out the full problem because I can't seem to find how to say the following without a uniary 'not' operator:
out = out & !reset;
(both are boolean streams)
tester ·
Ehm, too large shortcut for me. 🙂 Is tis a code that should replace "trigger pulse" module? Because if so, then it does not works. If it should replace the previons coude, then where are the other inputs (threshold, signal) here? I can't connect blue trigger output to green directly.
By the way - I'm getting an impression, that when I have two "code" primitives in one module (in the same layer/view), then SM tends to crash. It happened before too. One code per module layer/view seems to be fine however.
oddson ·
tester wrote: Is this code that should replace the "trigger pulse" module? Because if so, then it does not work.
It is to replace the 'triggered pulse' but it doesn't work because it's a boolean stream. It was part of a solution I was trying that had a boolean stream trigger as a reset. I couldn't get that to work because I can't remember how to fake a unary 'not' operator.
oddson ·
Like this...
Note the 'peak' values are just there to demonstrate what's happening with the output. You can remove the code lines with the comment tags after them.
EDIT - looks like I'm still having some problems where the reset doesn't work... hmm.
oddson ·
I could just use the following line... since the peak stuff seems to work:
out = peak>threshold;
ChrisHooker ·
oddson wrote: I could just use the following line... since the peak stuff seems to work:
out = peak>threshold;
Also might want to look for intersample peaks. (Look at both preceding and current values (or set the # of samples (sensitivity) to whatever you desire), if both are at maximum/threshold, then also send out a TRUE.)
trogluddite ·
oddson wrote: EDIT - looks like I'm still having some problems where the reset doesn't work... hmm.
Looking at the assembly output, it is an execution order thing, the "=+" is happening before the subtraction.
But boolean FALSE (all bits off) is a genuine zero, so all you need is...
out = out & (reset == 0);
oddson ·
ChrisHooker wrote:
oddson wrote: I could just use the following line... since the peak stuff seems to work:
out = peak>threshold;
Also might want to look for intersample peaks. (Look at both preceding and current values (or set the # of samples (sensitivity) to whatever you desire), if both are at maximum/threshold, then also send out a TRUE.)
This is running at full sample rate... there's nothing 'intersample' to check for 😕
trogluddite wrote: But boolean FALSE (all bits off) is a genuine zero, so all you need is...
out = out & (reset == 0);
Could have sworn I tried that but that might have been with I had an error in my reset code.
Thanks Trog.
trogluddite ·
oddson wrote: This is running at full sample rate... there's nothing 'intersample' to check for 😕
Not sure if it is so important for tester's application, but Chris is quite right, when the waveform is reconstructed it is possible for the resulting analogue waveform to go beyond the value of the sample values either side.
Explained HERE, better than I could.
The example there explains it's relevance to low-quality DAC's, but more commonly these days it can also have nasty effects on compressions codecs - something to watch out for if you are ever designing a mastering limiter.
oddson ·
trogluddite wrote: Not sure if it is so important for tester's application, but Chris is quite right, when the waveform is reconstructed it is possible for the resulting analogue waveform to go beyond the value of the sample values either side.
I thought about wave reconstruction making it possible while posting that message...
But I couldn't see it mattering in such a blunt instrument... but I understand the point.
oddson ·
ChrisHooker wrote: Also might want to look for intersample peaks. (Look at both preceding and current values (or set the # of samples (sensitivity) to whatever you desire), if both are at maximum/threshold, then also send out a TRUE.)
Now I see you were talking about wave reconstruction. But you'd have to look at more than adjacent (you'd more or less have to oversample and filter to reconstruct the wave at a higher resolution). Otherwise a slow-rising sine wave (for example) near your threshold would trigger even though a perfect reconstruction wouldn't really get much closer than the highest sample.
tester ·
In my aplication rather simple things are going on. During making and manipulating the signals live - amplitudes can from time to time exceed the maximum thresholds. When the output exceeds the threshold, indicator lights up to tell me that I should take down some decibels with the slider. Turning off the indicator is manual, to avoid blinking around the threshold and to avoid overlooking/omission on the timeline (I can go, make tea, and when I'm back - I see that there was an unwanted event). Each sub-unit will have it's own indicator, plus one global indicator for master mix. So I just mean simple max peak indication, "CPU-free" module so to speak.
trogluddite ·
tester wrote: Each sub-unit will have it's own indicator, plus one global indicator for master mix. So I just mean simple max peak indication, "CPU-free" module so to speak.
If you're going to need lots of them, these ones might interest you. Same algorithm, but optimised in assembly to remove all of the redundant operations and "peripheral" modules. Note that because of the way Mono-to-Float's work, there will only be a trigger sent from the "indicator" output when the value changes, so there's no need to worry about them generating lots of spurious triggers or redraws.
There's also an ABS version which looks only at the magnitude, which should be useful for bi-polar signals - the assembly ("andps xmm0,ABSmask" trick) is far more efficient than the regular ABS expression in code.
tester ·
@trogluddite - but if I reset the indicator, and the signal is still above the threshold, then indicator is still offline if there is no retrigging?
Regarding intersample peaks - that's true, but if threshold is fixed to ABS 0.9 or 0.95 , then there sould be no such large intersample spikes?
tester ·
I fixed it like this.
trogluddite ·
Aha, it was the internal logic of the button confusing things. There's no need for the button to have its own internal flip-flop etc. in this case, as all of the logic is dealt with by the peak detector itself.
Here's a modified version - if you look inside the knob you can see how the mouse interaction and display are now treated as two independent items (apart from sharing the same view area)...
NB) The button also has no need for a Preset - only its trigger is required, so there is no button state to store.
tester ·
Ah, I forgot, which led I'm using 🙂
My logic is fragmented 😀
So this here is a version for stereo input; I don't need separate L/R indicating, but should be easy to do - independent indication for left/right channel, and common reset of both leds; probably there could be used the previous led I used.
Thanks for help.
//edit: added stereo dual led.
DigitalWhiteByte ·
@tester
about intersample peaks,
I believe that you will not have a real TRUE PEAK reading until you do not oversampling the signal you are analyzing.
tester ·
All depends on kind of signals you work with and the app construction, I think. There is no need for going deeper for me. Single sounding units within my app are digital and I need digital peak detector, to avoid mixing problems (like clicks or trimming effect). Entire output however, i.e. output that is exported to audio file - will be usually at -24dB or less. So there should be no problem at all, I guess.
Wrote something here? To have a post removed or your name hidden, write to [email protected].