tula's DSP modules

Post any examples or modules that you want to share here
adamszabo
Posts: 667
Joined: Sun Jul 11, 2010 7:21 am

Re: tula's DSP modules

Post by adamszabo »

By the way in martins exponential envelope posted by Spogg, there is an error in the assembly code on line 52 the last part its: addps xmm1,xmm41; the last should be "xmm4" and not "xmm41". I dont know if its there in the original code or it was added there later by accident.
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: tula's DSP modules

Post by Spogg »

adamszabo wrote:By the way in martins exponential envelope posted by Spogg, there is an error in the assembly code on line 52 the last part its: addps xmm1,xmm41; the last should be "xmm4" and not "xmm41". I dont know if its there in the original code or it was added there later by accident.

OMG :o

I've made extensive use of this in pretty much all of my projects!
What are the consequences?

Cheers

Spogg
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: tula's DSP modules

Post by martinvicanek »

adamszabo wrote:in martins exponential envelope posted by Spogg, there is an error

Thanks for spotting that, Adam!
@Spogg, the fact that it has remained unnoticed suggests that the impact is less than devastating. Indeed, the bug affects fast release - a feature that is not vital. What happens is that xmm41 is treated as an (undeclared!) variable not a 128 bit register. Often the value of xmm41 will be zero, however it is unpredictable and may in the worst case lead to freezing or crashing the plugin. So please synchronize paint all ADSR modules in each of your plugins and replace xmm41 by xmm4 in the ASM code.
REALLY SORRY! :oops:
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: tula's DSP modules

Post by martinvicanek »

Spogg wrote:
martinvicanek wrote:Have fun!


I can't because I don't understand what you did there :?

Sorry about the cryptic post. What I did there was what Adam and KG had described: add and subtract some number to reduce bit depth. My modest contribution was to specify that magic number in terms of bit depth, which, btw, works for both positive and negative input. The staircase diagram was to show the quantization effect.

Here is a hopefully less confusing schematic.
Attachments
FastStreamBitcrusher(noASM).fsm
Revised Schematic
(3.25 KiB) Downloaded 1126 times
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: tula's DSP modules

Post by tulamide »

Hey Martin,

I'm aware that this is not on topic, but since we are already at it, would you please be so kind to give a hint about the relationship of the input numbers to sample rate and actual number of samples? I tried to find out on my own, but A and D (and R), although fed with the same number, are different in resulting times. D and R are probably 5+ times longer than A on max input (176k). Which rule applies?

(I'm talking of the ADSR :oops: )
"There lies the dog buried" (German saying translated literally)
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Exponential Decay

Post by martinvicanek »

Unlike linear decay, exponential decay is never really "done". So how can we assign a characteristic "decay time" in that case?

Consider the expression

a(t) = a0*exp(-t/T)

There is this time constant T which is a measure of how fast things change. If the decay continued at the initial rate, then it would be complete by the time t = T (dashed line in the image). Since the decay is exponential, however, at t = T the amplitude is still at roughly 37% of its initial value.
expoDecay.png
expoDecay.png (6.51 KiB) Viewed 26465 times

There are other possibilities to characterize exponential decay times. Some common examples are:
1. Half-life T_1/2 in radioactive decay. Obviously that time is shorter than T. The relation is T_1/2 ≈ 0.69*T
2. Decay to ten percent is after T_10% ≈ 2.3*T
3. In reverbs, it is common to state the time forthe reverb tail to drop to -60dB. Assuming an exponential law, that duration is T_60 ≈ 6,9*T

So you see, there is no unique definition.

My expo module has four inputs:
A: Attack, linear rise time in samples (rounded to a multiple of 16).
D: Decay, exponetial decay time T in samples (rounded to a multiple of 16). Note that decay is not to zero but to the sustainn level.
S: Sustain level, a number between 0 and 1.
R: Release, exponetial release time T in samples (rounded to a multiple of 16).

If yo prefer to supply seconds instead of samples, you can convert seconds to samples by multiplying the time in seconds by the sample rate.
Attachments
ADSR optimized expo.fsm
(7.8 KiB) Downloaded 1173 times
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: tula's DSP modules

Post by RJHollins »

Thank-you Martin. 8-)
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: tula's DSP modules

Post by Spogg »

Back to Bit crushers :lol:

Here is the one I made for emulating vintage digital synths, taken right out of my ASS.
I’ve added a 4 bit mode for the demo.

Based on what I’ve seen here it ain’t too clever but it gets the job done.

Cheers

Spogg
Attachments
Bit crusher out of Spogg's ASS.fsm
(223.05 KiB) Downloaded 1132 times
User avatar
rocknrollkat
Posts: 213
Joined: Mon Jan 04, 2016 7:04 pm
Location: Oakland Gardens, New York City, U.S.A.
Contact:

Re: tula's DSP modules

Post by rocknrollkat »

Spogg wrote:Back to Bit crushers :lol:

Here is the one I made for emulating vintage digital synths, taken right out of my ASS.
I’ve added a 4 bit mode for the demo.

Based on what I’ve seen here it ain’t too clever but it gets the job done.

Cheers

Spogg


Getting the job done is what counts, dubious origins notwithstanding.

ROXY :D
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Exponential Decay

Post by tulamide »

martinvicanek wrote:Unlike linear decay, exponential decay is never really "done". So how can we assign a characteristic "decay time" in that case?

Consider the expression

a(t) = a0*exp(-t/T)

There is this time constant T which is a measure of how fast things change. If the decay continued at the initial rate, then it would be complete by the time t = T (dashed line in the image). Since the decay is exponential, however, at t = T the amplitude is still at roughly 37% of its initial value.
expoDecay.png

There are other possibilities to characterize exponential decay times. Some common examples are:
1. Half-life T_1/2 in radioactive decay. Obviously that time is shorter than T. The relation is T_1/2 ≈ 0.69*T
2. Decay to ten percent is after T_10% ≈ 2.3*T
3. In reverbs, it is common to state the time forthe reverb tail to drop to -60dB. Assuming an exponential law, that duration is T_60 ≈ 6,9*T

So you see, there is no unique definition.

My expo module has four inputs:
A: Attack, linear rise time in samples (rounded to a multiple of 16).
D: Decay, exponetial decay time T in samples (rounded to a multiple of 16). Note that decay is not to zero but to the sustainn level.
S: Sustain level, a number between 0 and 1.
R: Release, exponetial release time T in samples (rounded to a multiple of 16).

If yo prefer to supply seconds instead of samples, you can convert seconds to samples by multiplying the time in seconds by the sample rate.

Thank you Martin. I understand the problematic. With attack being linear, my first question has been answered instantly. The time advice is very important for me. Just to make sure, I'm not making a mistake:
If I would want an exponential decay towards sustain of 20 seconds (at 44.1 kHz), I'd pass 882000? Likewise, exponential release time 35 seconds, I'd pass 1543500?

Spogg
I had a look at your solution, and it is pretty much the same method I initially used. I just wonder why you have a maximum of 16 bits (32768), when Flowstone works with 32-bit floats? That means you alter the incoming signal even if no bit-reduction is chosen. But maybe that was never planned?
"There lies the dog buried" (German saying translated literally)
Post Reply