Author Topic: Envelope Followers in SpinCAD Designer  (Read 3109 times)

Digital Larry

Envelope Followers in SpinCAD Designer
« on: February 01, 2021, 10:24:52 AM »
There are two as of build 1023.  Let's start by talking about the first one, "Envelope".

This one is a peak-following envelope detector.  Here's the code it generates:

Code: [Select]
; Untitled
; null
; Pot 0:
; Pot 1:
; Pot 2:
;
;
; ----------------------------
;------ Pot 0
;------ Input
;------ Envelope
; read the input, multiply by pot0 (sensitivity),
RDAX ADCL,1.0000000000
MULX POT0
; rectify and scale it up by 12 dB (x4)
ABSA
SOF -2.0000000000,0.0000000000
SOF -2.0000000000,0.0000000000
; apply a low pass filter and save in Reg0.
RDFX REG0,0.0001500000
WRAX REG0,0.0000000000
; do another low pass filter using the Reg1 result and save in Reg2.
RDAX REG1,1.0000000000
SOF -0.0001000000,0.0000000000
RDAX REG1,1.0000000000
WRAX REG2,0.0000000000
; get the filtered input and see which one is higher, the filter #1 or filter #2.  write that to reg1
RDAX REG0,1.0000000000
MAXX REG2,1.0000000000
WRAX REG1,0.0000000000
;------ Output
; write reg1 to DACL
RDAX REG1,1.0000000000
WRAX DACL,0.0000000000
; write reg0 to DACR
RDAX REG0,1.0000000000
WRAX DACR,0.0000000000
Interesting that I used RDFX for the first filter but not the second.  I don't remember why.

Anyway, this has a peak detector that goes into an LPF which sets the attack/release time on the single-slope output.
That signal goes into another LPF and a comparator which takes the highest of either the first or the second filter.  This is sent to the dual-slope output.
So that means that you cannot have a long attack and a short release.  The release is always going to be longer than the attack because it includes the attack's rise/fall time.

I did some reading in my Will Pirkle VST book.  He describes the above structure as a generic peak-holding envelope follower and referenced "Reiss, 2011" for more info.  So I found this, which is a fairly exhaustive analysis of envelope follower strategies primarily for use in compressors.

http://www.eecs.qmul.ac.uk/~josh/documents/2012/GiannoulisMassbergReiss-dynamicrangecompression-JAES2012.pdf

To develop the optimal type of follower for compression, I should:
- use RMS or MS instead of peak
- do a log conversion of the level and handle threshold/etc. in that domain
- come up with a structure to decouple attack from release

Well, I might do it or I might not.  But if anyone wants to try to develop this code for inclusion into SpinCAD, let me know.
« Last Edit: February 01, 2021, 12:13:51 PM by Digital Larry »
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

Re: Envelope Followers in SpinCAD Designer
« Reply #1 on: April 09, 2021, 04:20:21 AM »
battle of spambots?
It's crazy how we are being invaded by spambots lately, and I don't get what is their purpose... some of them (like the ones above) sneak in a spam link, but some just drop a random message in a post....

[Edit]: My commnent now seems silly as the spambot messages have been deleted... :)
« Last Edit: April 09, 2021, 09:39:44 AM by potul »

Digital Larry

Re: Envelope Followers in SpinCAD Designer
« Reply #2 on: April 13, 2021, 08:10:14 AM »
After a few months off I've started enhancing the SpinCAD Designer program again. Now I've read a few comments here saying it uses too many instructions, registers, etc. and the fact is that yes, whenever you connect a block to another one that it uses one register that might not really need to be there were you to write the code by hand.
Hi Allen,

You are very brave.  Yes, the use of extra registers to stitch blocks together is really the main source of code inefficiency IMO.  The ability to optimize the Spin ASM easily by hand after the fact was my "workaround", plus my experience was that most of the time I was not pushing the limits of how many instructions or registers I was using, making it a moot point.  Take a look here for thoughts I had about it at the time.

https://github.com/HolyCityAudio/SpinCAD-Designer/blob/master/docs/optimizing-spin-asm-code-generation.pdf

While I was moving everything over to Github a year or two back I also created a list of issues that I was aware of.  Maybe 2 or 3 of these are probably simple and I'd even tackle them myself.  Take a look and feel free to add to it.

https://github.com/HolyCityAudio/SpinCAD-Designer/issues

Let me know any questions you have about the code.  I'll have to poke my head back in there to remind myself, but I might be motivated to do so if someone else does the heavy lifting.  Just start a new thread in this forum and we'll discuss it right out in the open so that anyone so inclined can follow along.

Thanks,

DL
« Last Edit: April 13, 2021, 08:23:26 AM by Digital Larry »
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

Re: Envelope Followers in SpinCAD Designer
« Reply #3 on: April 14, 2021, 11:42:37 AM »
Hi Larry,

don't waste your time with Allen, it's a spambot..... typical profile:

-New user with only one message
-The reply has some relationship to the topic, but you can't really make the connection of what he says vs the topic of the thread.

If you do a google on the sentence: "After a few months off I've started enhancing the SpinCAD Designer program again. Now I've read a few comments here saying it uses too many instructions ....." You will find out this sentece was written by YOU some months ago in "thegearpage" forum.

I guess these bots use some AI combined with google seach to find sentences that are vaguely related to the topic with the intention to fool us all. It's really a flood of spambots lately in this forum, it's very annoying.

Mat




duck_arse

Re: Envelope Followers in SpinCAD Designer
« Reply #4 on: April 14, 2021, 12:02:37 PM »
^ this seems to happen a lot in the digital sub-board. posts like the above are perfect candidates to be "report to moderator"-erised, Aron loves sorting thru them!
pernickets cantankered here.

Digital Larry

Re: Envelope Followers in SpinCAD Designer
« Reply #5 on: April 14, 2021, 01:33:56 PM »
I see.  I've used my super powers to delete Allen's post.  That's too bad.  I almost thought someone was going to contribute to move SpinCAD forward while I swill Mai Tais on the shore.

DL
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

potul

Re: Envelope Followers in SpinCAD Designer
« Reply #6 on: April 14, 2021, 03:36:58 PM »
I see.  I've used my super powers to delete Allen's post. 
That's probably my fault. I reported the message earlier this morning.
Quote
That's too bad.  I almost thought someone was going to contribute to move SpinCAD forward while I swill Mai Tais on the shore.

DL
good try  :icon_biggrin: :icon_biggrin: