SynthMaker

ADSR Attack bug?

Archive · 2005 14 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

Shifrin ·

Hi,

I was playing with the ADSR and an Analyser/GraphLin. I made a schematic that draws the AD envelope after applied to a waveform. So you can see how it affects it. Just mucking around.

The schematics look like :-

And :-

The AD part of the envelope can have a maximum length of 1024 samples, 512 for each of Attack and Decay, then I pass a Sine wave with this AD envelope applied to the Analyser which I use to analyse a max of 1024 samples before drawing 🙂

The problem comes when you set the Attack to a very small value, the waveform display seems to 'ripple' and then to jump in size. Try for yourself. The Decay knob affects the Sine wave as expected. But like I said with 'very' short Attack times things go weird

Here's the .osm :-

ADSR-Bug.osm

Hope you can fix it 😉 Or at least explain what's going on if indeed it's *not* a bug!!!

Thanks,

Shif.

lalo ·

🙂

Is the ADSR linear?

i think is because the adsr is calculated every 4 samples.

lalo

Shifrin ·

lalo wrote: http://www.synthmaker.com/forum/viewtopic.php?t=158

i think is because the adsr is calculated every 4 samples.

Cheers for the heads-up 🙂

Jorge/Malc, any new info on this?

Shif.

malc ·

Hi Shif,

Jorge is your man for this. I know he's spoken with lalo about it in the past but I can't remember what the conclusions were.

As lalo said the ADSR is not calculated for every sample. I believe that much of the time that kind of rate is not required and so by calculating less frequently you get better performance.

Shifrin ·

Just to add, even if the ADSR is updated every 4 samples, I still don't see why there is a problem seemingly only with the first dozen or so samples of the Attack portion of the envelope. Indeed, it appears that the value output from the ADSR for the first few samples is greater than 1! Which I don't understand at all - I say this as the sine wave drawn jumps in size and goes off-screen!!!

Am I right in assuming the ADSR should output values between 0.0 - 1.0?

Hmm, weird...

Shif.

Shifrin ·

Oh, cheers Malc, was just posting my last post when you must have replied. Hope Jorge can drop by and explain a few things 😉

I understand completely the reasons for not updating env positions every sample, but like I just said the problem I've found isn't necessarily to do with that. Maybe another 'bug'?

Shif.

lalo ·

i'm still thinkin about it... maybe a sample rate adsr segment can be intialized if the required attack/decay/release time is under a certain amount of ms... cause the problem is noticed only with very fast time.....if over a certain ms every 4 samples is enought....even if it inserts a little amount of wave 'distortion' as i showed in this thread.

Is the ADSR linear?

any more opinions?

thanx lalo

lalo ·

Shifrin wrote: Just to add, even if the ADSR is updated every 4 samples, I still don't see why there is a problem seemingly only with the first dozen or so samples of the Attack portion of the envelope. Indeed, it appears that the value output from the ADSR for the first few samples is greater than 1! Which I don't understand at all - I say this as the sine wave drawn jumps in size and goes off-screen!!!

Am I right in assuming the ADSR should output values between 0.0 - 1.0?

Hmm, weird...

Shif.

yes Shifrin this maybe another little issue with the adsr.... i noticed in my previous works that (very often) when the sample values sent to adsr are 0 most of the times something unpredictable come out..even with the example schematic... maybe this can be related

but jorge will put light on this for sure 🙂

lalo

Shifrin ·

lalo wrote: but jorge will put light on this for sure 🙂

Yep!

One of the reasons I found this out was that I'd assumed the ADSR values were between 0.0 and 1.0 - so in order to create a non-linear Attack, Decay and Release portion I was multiplying the output of the ADSR with itself, indeed you can cube it or even higher to get sharper curves! However I noticed some odd behaviour and when I investigated I saw the weirdness with very short attack times etc.

Shif.

jorge ·

Hi Shifrin, thanks for your bug report

With the latest incremental release there is a new ADSRsr component that works at sampling rate ( I had it nearly ready because lalo has been asking for it for a while ), it seems to get rid of the problem at least when using the schematic you posted. The ADSRsr component will use nearly 4 times as much processing as the normal ADSR, eventually I'll create an ADSR that adapts the rate of processing depending on the input parameters.

[old link]

Shifrin ·

jorge wrote: Hi Shifrin, thanks for your bug report

With the latest incremental release there is a new ADSRsr component that works at sampling rate ( I had it nearly ready because lalo has been asking for it for a while ), it seems to get rid of the problem at least when using the schematic you posted. The ADSRsr component will use nearly 4 times as much processing as the normal ADSR, eventually I'll create an ADSR that adapts the rate of processing depending on the input parameters.

[old link]

Thanks very much Jorge, I'm just on my way out now but will test it out as soon as I get home 🙂

That adaptive ADSR sounds great!

Shif.

Shifrin ·

jorge wrote: it seems to get rid of the problem at least when using the schematic you posted.

Not quite unfortunately 🙁 The problem of the Attack portion seeming to go out of bounds (i.e. greater than 1.0) is gone. But the 'ripple' or 'dancing' is still there in the Attack portion with the new ADSRsr. Load the schematic I posted and change to the new ADSRsr. Then change the float multiplier for the Attack from 512 down to 64. So we've got an attack in the range of 0 to 64 samples in length. Set the Decay to full (512 samples). Now slowly turn the Attack knob from 0 through to 1 and watch the waveform. It dances/jumps about like crazy (albeit by a small amount) in the y-axis.

jorge wrote: The ADSRsr component will use nearly 4 times as much processing as the normal ADSR

Well, I said that the sample rate ADSR solved the 'out of bounds' problem, but I have another question 😉 Why was this a problem with the 'every 4 samples' ADSR anyway?!

Hmmmmmm, hope I've not caused too many problems for you 🙂

Cheers for looking at this!

Shif.

jorge ·

Hi Shifrin,

Shifrin wrote: Load the schematic I posted and change to the new ADSRsr. Then change to float multiplier for the Attack from 512 down to 64. So we've got an attack in the range of 0 to 64 samples in length. Set the Decay to full (512 samples). Now slowly turn the Attack knob from 0 through to 1 and watch the waveform. It dances/jumps about like crazy (albeit by a small amount) in the y-axis.

I did that and I noticed what you said, it seems to me like a tiny variation in amplitude. It needs fixing but do you think it is important considering it is so small? also it happens only while you're changing the input parameters.

Shifrin wrote: Well, I said that the sample rate ADSR solved the 'out of bounds' problem, but I have another question 😉 Why was this a problem with the 'every 4 samples' ADSR anyway?!

I'll try to explain how it works. The ADSR works with increments, for example for Attack=10 you have an increment of 1/10=0.1 which means that if you keep adding it for 10 samples it gets to 1.0. There's a comparison to find out if it reached 1.0 in which case the ADSR moves to Decay stage. I think the bug might be in that comparison causing the ADSR to overshooth and go over by 1 increment value. When the ADSR was calculating every 4th sample, the overshooting was more apparent as it would in worst case be 4*increment or 0.4. Also the problem is more obvious for very short Attacks as they'd have the highest increments. I think after your detailed report it might be easy to fix. Also the ADSR processing only every 4th sample might work fine after fixing it although it would still have the problem that lalo mentioned.

Shifrin wrote: Hmmmmmm, hope I've not caused too many problems for you 🙂

🙂 You're not causing the problems, you're just finding them out and it's very useful specially when we get a detailed report like yours including a schematic etc. Thanks

Shifrin ·

Hi Jorge,

jorge wrote: It needs fixing but do you think it is important considering it is so small? also it happens only while you're changing the input parameters.

Well it's not that important to be honest with you 🙂 Just that it had me confused for a while! I wasn't sure if I was doing something wrong!!!

jorge wrote: I'll try to explain how it works......

Cheers for the explanation, made perfect sense to me! A fix would be great if possible.

jorge wrote: You're not causing the problems, you're just finding them out and it's very useful specially when we get a detailed report like yours including a schematic etc. Thanks

You're very welcome Jorge 😀 I just want to help make Synthmaker the best product (and down-right best RAD VST/i tool) it can be!!!

Shif.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.