Skip to main content

Topic: Help me w/ maths for decelerating attack curves + predicting durations (Read 4852 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • db1989
  • [*][*][*][*][*]
  • Global Moderator
Help me w/ maths for decelerating attack curves + predicting durations
Preface: As tends to happen whenever I start writing, this got out of control quite quickly. I’m going to refrain from deleting much lest I make my core thoughts even more difficult to follow, but I’ve emboldened what I think are my key points – if I can be said to have any at all…

I’ve started quantifying parameters of a hardware synthesiser for reference and comparison, and just maybe the future design of an emulator.

What is baking my brain is the attack phase of the envelope. Decay was easy to quantify and proceeds by a constant number of dBU/s that scales exponentially with the rate chosen; in other words, decay is linear on a scale of dBU. Attack, on the other hand, is apparently modelled on observations that natural instruments often have exponential attacks. Accordingly, attack is claimed to follow an inverted version of the decay curve but multiplied by a factor that depends upon the instantaneous distance between (current level) and (target level). In other words, on a logarithmic scale, the curve initially rises quite steeply but then progressively becomes shallower as the level approaches its final value.

My lack of skill with mathematics probably means I’m confusing things with a lot of vague descriptions and inconsistent/misnamed terminology, but I did manage to mess around enough to obtain something that resembles the curve I’m talking about. It looks like this:

Code: [Select]
y = x * (1 + (1 - x))
0 <= x <= 1
0 <= y <= 1
Which gives this:
), I want to be able to calculate the mean rate of attack that corresponds to a given rate of decay (and hence the duration of said attack phase, etc.).

Thanks a lot to anyone who has the mental power and/or masochism to have read this far! Guidance for a hopeless non-mathematician will be greatly appreciated.
  • Last Edit: 29 April, 2013, 09:04:42 AM by db1989

  • db1989
  • [*][*][*][*][*]
  • Global Moderator
Help me w/ maths for decelerating attack curves + predicting durations
Reply #1
My lack of skill with mathematics probably means I’m confusing things with a lot of vague descriptions and inconsistent/misnamed terminology, but I did manage to mess around enough to obtain something that resembles the curve I’m talking about. It looks like this:

Code: [Select]
y = x * (1 + (1 - x))
0 <= x <= 1
0 <= y <= 1

Derp. As now seems obvious, after some thought, that’s actually this:
Code: [Select]
y = x * (1 + (1 - x))
y = x * (2 - x)
y = 2x - x^2
So, it’s a parabola that intersects the x-axis at y=0 and has its apex at y=1, of which my earlier graph was merely an excerpt for 0 ? x,y ? 1. Albeit from the same formula expressed in an unnecessarily convoluted way, which maybe gave someone a little chuckle if nothing else.

Anyhow, aside from showing how much I’ve forgotten since school, this doesn’t actually help much. Obviously it does nothing to indicate the elapsed time without substituting in a pre-existing rate. Differentiating it may be vaguely informative, but I suspect its relevance is limited in any case. ‘Pure’ mathematics do not seem to be the answer here as the actual implementation in hardware seems to be considerably less sophisticated. It seems to use a fairly coarse method to scale the ‘basal’ rate (i.e. the ‘corresponding’ decay) by a factor that ‘steps’ quite noticeably. That involves a bunch of components whose values are currently completely mysterious to me. Oh well!

  • Gecko
  • [*][*][*][*][*]
Help me w/ maths for decelerating attack curves + predicting durations
Reply #2
I would love to try to help, but I'm having a very hard time understanding your problem. You are talking about this https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope, correct?

Your question seems to concern the attack part, but then you mention decay. In what way are those two related? Do you set the decay on the synth and it automatically sets the attack? Are they connected by some ratio? I'm aware of the first statement in bold, but I can't make sense of it, mainly due to relationship to the decay.

The rest sort of sounds like you are describing a linear differential equation... the solution to which involves exponential functions.

It could be possible that the synth implements the attack using a capacitor. Charging a capacitor would lead to a curve similar to the one you drew (voltage over time). This can be expressed as u(t) = u_max * (1 - exp(-t/tau)). tau is your time constant. For a simple RC circuit tau = R*C. See https://en.wikipedia.org/wiki/RC_circuit for details. So the synth might use a variable resistor to control the duration of the attack.

Is any of this helping you at all?

P.S.: note that I have no idea of the actual inner workings of classic analog synthesizers.

  • benski
  • [*][*][*][*][*]
  • Developer
Help me w/ maths for decelerating attack curves + predicting durations
Reply #3
Just take the derivative

Your formula:
Code: [Select]
y = 2x - x^2

rate of change, in terms of voltage
Code: [Select]
dy = (2 - 2x)dx


to convert voltage to dB
Code: [Select]
u = 20*ln(y)/ln(10)
u = 20*ln(2x - x^2)/ln(10)

to calculate rate of change, in terms of dB
Code: [Select]
du = 20/ln(10) * (2-2x)dx/(2x-x^2)


Hope that helps!
  • Last Edit: 01 May, 2013, 11:12:57 AM by benski

  • Woodinville
  • [*][*][*][*][*]
Help me w/ maths for decelerating attack curves + predicting durations
Reply #4
is K( 1 - e ^ (-at)) the function you were looking for?
-----
J. D. (jj) Johnston

  • db1989
  • [*][*][*][*][*]
  • Global Moderator
Help me w/ maths for decelerating attack curves + predicting durations
Reply #5
I would love to try to help, but I'm having a very hard time understanding your problem. You are talking about this https://en.wikipedia.org/wiki/Synthesizer#ADSR_envelope, correct?

Your question seems to concern the attack part, but then you mention decay. In what way are those two related? Do you set the decay on the synth and it automatically sets the attack? Are they connected by some ratio? I'm aware of the first statement in bold, but I can't make sense of it, mainly due to relationship to the decay.
Decay and attack can be set to values in the same range, and there are indications elsewhere (from similar but not equivalent synths) that the rate of attack is a transformation of the rate of decay. I’ve pretty much characterised the rate of decay, which was fairly trivial, although I haven’t worked out the underlying logic (yet?). Anyway, decay is a linear decrease on a logarithmic scale (i.e. always n dBU/s), whereas an attack of the corresponding setting is supposedly based upon the rate for the equivalent decay but starting out more rapidly and then decelerating. So, the rate for the decay is multiplied by some high factor to begin with, then that factor decreases as the level approaches the final level (which isn’t constrained to 0 dBU).

Quote
The rest sort of sounds like you are describing a linear differential equation... the solution to which involves exponential functions.
I thought something like that might provide a usable means to estimate the duration, if not the underlying mechanism, but as I mentioned in my last post, it seems to work less smoothly than that.

Quote
Is any of this helping you at all?

P.S.: note that I have no idea of the actual inner workings of classic analog synthesizers.
That’s fine: this one is digital.

Just take the derivative

[…]

Hope that helps!
It might work as a basis of estimation, at least. Of course, the overall shape and time of the attack depend upon the nominal rate, the distance between the starting and ending levels, and the particular range of steps by which the rate is scaled over specific portions of the attacking distance.

I think this is a bit beyond me at the moment… I started out just wanting to compile a table of durations in seconds, but that was painstaking and boring (maybe there’s an editor that can somewhat automate things like this; I don’t know), and I would inevitably end up wanting to have a more accurate—and fast!—way of doing things. Plus, an unrealistic part of me wants to start writing an emulator… :S Haha.

is K( 1 - e ^ (-at)) the function you were looking for?
I have no idea! What does that do? I can speculate about the curve slightly, but not much without knowing the identities of the variables. Thanks anyway, I guess.

Thanks to everyone who replied. I guess I might need to do more boring recording and measuring, heh.

  • Woodinville
  • [*][*][*][*][*]
Help me w/ maths for decelerating attack curves + predicting durations
Reply #6
is K( 1 - e ^ (-at)) the function you were looking for?
I have no idea! What does that do? I can speculate about the curve slightly, but not much without knowing the identities of the variables. Thanks anyway, I guess.

Thanks to everyone who replied. I guess I might need to do more boring recording and measuring, heh.


K is gain constant. A is a positive number. t is time. e is, well, 'e'.

I would suggest you plot it. If you're doing this kind of work, you need to be very familiar with that particular function, it is the natural attack envelope function of a resonant system.
-----
J. D. (jj) Johnston