From the original SynthMaker forum (2004–2014), with its members’ names and dates.
AxeSlash ·
First post here, so be gentle 🙂
I'm trying to make an accurate peak meter for a snare drum plug that basically adds a sinewave to the audio; so when the incoming audio goes over a threshold level, a sine wave (with an envelope follower) is triggered.
That part all works fine, except the meters aren't fast enough. I've tried all sorts of stuff to try and get them to see the really fast transients of a snare that's been 'transient designer-ed', to no avail.
Currently the best code I've found is this (think I found this on KVR somewhere):
streamin in;
streamout out;
float max;
float input;
input = in;
max = max(abs(in),(max(max, abs(in)))*0.9999);//0.9999 controls the release time.
out = max;
Then I follow that with a mono to float running off a tick25. Then I've stolen Loopeytunes' green stuff to trigger the individual LEDs.
Something's going wrong somewhere though - a sine wave meters fine with that, but transients are often showing up lower than they should on the meter. I suspect that the code is decaying the signal before the mono to float can pick it up...I'm not too good with code, so is there a better way of doing this? Like holding the max til the ticker has seen it?
The standard envelope followers always seem too slow...
Thanks in advance
nix ·
G'day,
I recommend switching the tick25 for a tick 100
to start with.
It seems like you need to have a longer release,
not faster, hmm
Good luck and all success, Nick
AxeSlash ·
I'm almost there; I figured out that I needed to hold the peak until the ticker has seen it (and how to do it in Excel anyway), so now I got this:
Ticktrig is fed by a Trigger Pulse that is triggered by the Tick 25 (see attached)
This doesn't work. The formulas work fine in Excel, though, it all acts as expected there, but I'm guessing I've somehow messed up in translating it to SE - I just can't figure out where.
cyto ·
Hi AxeSlash and welcome 🙂
I think even if you were to get your second example working, you still might suffer from the same problems. The "green" math and the stream math are done on two different CPU threads and don't really sync up well at all. So I would imagine that expecting sample-perfect timing from that trigger pulse thingy is going to leave you disappointed.
I threw together a quick little example of how I would go about doing it. Basically, the working theory is to hold the peak values for a set amount of time before starting the release envelope. I did this with just a simple counter. To show you how effective this can be, I included in the schematic a little module that sends out a single sample pulse when you trigger it. You'll notice that every single pulse is detected. The "hold" and "release" times are adjustable and will be consistent at different sample rates (the release multiplier in you first example isn't).
If you need anything clarified, let me know and I'll be happy to explain.
-cyto
Mo ·
Looks good cyto. You can optimize the scope by place a "String Changed" between the array and the redraw primitive to stop it from constantly redrawing. Then change to tick 100 to make it more smooth.
AxeSlash ·
I'll have a look at that osm in a sec, cyto, but just out of curiosity, the trigger pulse thing makes the bool true for a period that you can supply (in this case I've set it to 1ms), so the 'sync' (for want of a better term) it's not meant to be sample accurate.
I actually get no LEDs lit at all as it is...
AxeSlash ·
Works perfectly, Cyto 🙂
Although I've just realised my first effort probably worked better than I thought, I had some gain structure issues in my test project (duh!) :P
Thanks guys
AxeSlash ·
And here's the final meter for anyone that's interested, pretty easily customisable.
If anyone has any reccomendations to optimise it, they're welcome 🙂
Wrote something here? To have a post removed or your name hidden, write to [email protected].