1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Why is this simple Core envelope not working? (Based on ReaktorTutorials guide)

Discussion in 'REAKTOR' started by mike_jm, Jul 16, 2017.

  1. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Hey guys,

    I just built my first Reaktor core based custom envelope. The intent is to build a simple envelope useful for modeling guitar/piano/drums. To do this, I am seeking a DAHDR design (delay-attack-hold-decay-release). To be acoustically accurate, the attack, decay, and release stages all will also need exponential "curve controls".

    Fortunately, SalamanderAnagram did a pair of great tutorials here at ReaktorTutorials which explain how to do all this:

    https://www.reaktortutorials.com/media/10-envelopes-1/33976/feature
    https://www.reaktortutorials.com/media/11-envelopes-2/33965/feature

    Unfortunately, the envelope I've built from this isn't really working, and I can't figure out why. I haven't yet added the curve controls/functions. This is just a simple linear envelope so far. But it's not doing what it should be.

    Any ideas for what I screwed up? Core cell and some screen shots attached.

    (Each of the internal guts of the "Delay/Attack/Hold/Decay/Release" stage macros are identical so I have only screen shot one to be representative of all.)

    Thanks.

    envelope-core-2.PNG

    envelope-core-1.PNG

    envelope-core-3.PNG
     

    Attached Files:

  2. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    howdy, the problem is with the changes between R5 and R6 using the z^-1 module, which used to operate like what is now called a latch[-1].

    i think in this instance, it's causing a signal to always be flowing from the release section. just replace it with a latch[-1] and try again.
     
    • Like Like x 1
  3. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Hey Salamander,

    Tried that and it still doesn't seem to be working properly. Any other ideas?

    Thanks

    envelope-core-4.PNG
     

    Attached Files:

    Last edited: Jul 17, 2017
  4. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    you have the output set to event rate?

    another thing that changed from r5 to r6...
     
  5. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Thanks Salamander.

    Progress!

    It was already set to "even rate output", but while I was there, I noticed the checkbox for "allow audio events" which was unchecked. Checking it allows this thing to actually work as an envelope:

    envelope-core-5.PNG

    Only one problem now. The release portion is not working as it should be. I have tried three macros in place of the "old z^-1" in your tutorial. None of them produce ideal results as demonstrated below.

    The most normal release function comes from the z^-1 feedforward macro in Reaktor 6. Sounds normal for anything above zero release. But it doesn't work at all when release is set to zero (no audio):
    release - z-1.png

    The other two options (latch -1, and a modified latch to match what the Reaktor 5 z^-1 looks like in your 'Working with Reaktor 6' video) work fine at zero but take forever to release if set to anything but zero:

    release - latch-1.png

    release - modified.png

    What a pain in the ass this must be for you, to have put so much work into your tutorials and have Reaktor 6 changes screw them up. Do you still have the project videos in their original format or did you lose them in your computer crash? It would be nice for future learners if you could update these to correct for these small things. But I get how busy you are. Not trying to find you more work. :)

    Appreciate your help.
     
  6. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    it should to be set to audio rate, not event rate. it's an audio device.

    it it doesn't work when release is set to 0, it's because you are dividing by 0. simple solution: clip the release so it never goes below 1/sample rate

    i can't replicate your problems with the latch[-1], but it's the tool that you should be using IMO

    as for editing all of these videos, it's simply not going to happen. there are dozens of changes that occurred since i started making these videos. i am planning on doing a bunch of new beginner videos in the near future, so hopefully i can just make a new series that supersedes the existing content
     
  7. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    the issue as i see it, is you have a constant release time even though the delay may be at any point when you release. in reality you may wish to have the release time scale with the level of the envelope when the release phase begins, it may create a more realistic effect.
     
  8. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Here's a quick ensemble showing the problem with the latch[-1], as well as the other three options for quick wiring.

    There are actually two problems with the latch[-1]:
    - It seems to be calculating release in seconds, so a 7 on the release knob releases for around 7 seconds.
    - The release is not smooth. It will release about 50% of the way (based on my dB meters) for the duration it runs for, then it just drops to zero.

    By contrast, the z^-1 feedforward macro does release normally with millisecond increments and smoothly. It just doesn't work at "zero" release due to the issue you are suggesting (dividing by zero). This can be fixed with the clip as you suggest.

    I attached two versions of the ensemble so you can see for yourself. One version is with the original design from your tutorial and the latch[-1] with the abnormal release. And another with the z^1 feedforward macro ("fixed") and a clip above zero. Not sure how many decimals I needed to be accurate so I just went with 13. :D

    Screenshot of what sounds like a working ensemble with the clip to prevent dividing by zero:

    release - z-1 (fixed).png


    There is a follow up also to be noted on the divide by zero issue. This concept was bothering me during the build in other areas as well. For example, if delay is set to zero, the "x" going into the delay macro will be an error as well (divided by zero).

    In testing, this actually creates a "click sound". There is a click any time any of the knobs are set to zero.

    From what I can tell, this can be partially fixed by either of two methods:
    (1) You divide by the knob value + a tiny non zero number.
    (2) You clip with a minimal value of a tiny non zero number.

    Both seem to work in some stages. I've attached a screenshot here to show both fixes simultaneously (redundant obviously). Not sure which the "best" fix is, but both eliminate the click for at least some knobs.

    envelope-core-7.PNG

    With this solution, having attack at zero still creates a click. Not sure why zero attack creates a click. Zero attack in the standard ADSR shipped with Reaktor does not click.

    I also can't get zero decay to work properly no matter what I do. It either clicks (even with the clipping fix) or doesn't decay at all (with adding a nonzero constant). Zero decay also works normally in the standard Reaktor ADSR with no click...
     

    Attached Files:

    Last edited: Jul 17, 2017
  9. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    here it is, working fine in my opinion, using a latch[-1] and clipping the times like i suggested.

    if it still clicks, increase the values in the clippers until it works.
     

    Attached Files:

    Last edited: Jul 17, 2017
  10. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    okay that one clicks, try this:
     

    Attached Files:

  11. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Hey Salamander,

    Cool. Thanks. That one works with no clicks and makes sense.

    The problem with that solution though is you can't have any faster stages than 1 ms. ie. The minimum attack is 1 ms, the minimum hold is 1 ms, the minimum release is 1 ms, etc.

    I'm not sure of the solution, but that's not ideal envelope function, especially not for a digital envelope which should be as fast as we want it to be...

    Would upsampling at some stage be the correct solution for that? I wonder how Reaktor does it in their envelopes.

    Or maybe I'm just being stupid. 1 ms is probably a very very small time. I'm not sure. But I know at least in mixing, having as low as a 1 ms or 2 ms attack is normal on a digital compressor. So it is obviously a significant amount of time in other musical circumstances.

    At 44.1 kHz sampling, I think a millisecond is 44.1 samples which is definitely significant from that perspective. A digital envelope should be able to go down to 1 sample resolution ideally without clicking.
     
  12. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Perhaps this envelope design structure is simply flawed in some way.

    I note sellotape suggested in another thread that Core comes with an "envelope toolkit" in Reaktor 6:

    adsr.PNG

    At least from my superficial glance, the general design seems more to match the one you used for your Blocks envelope tutorial. It also comes with a built in "bend" function.

    Perhaps I will try with that design method next to see if it provides more sample accurate responses.
     
  13. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    the built-in adsr envelopes click loudly when you give them a time of zero, so not really sure what you are talking about.

    if you mean the primary envelopes, they give a time of 1ms when you set them to zero. the one you have a picture of in your last message clicks just like mine does.

    not really sure what you are expecting - envelopes click.

    anyway, good luck.
     
  14. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Oh! Good to know. I didn't realize that. Yeah, I meant the primary envelopes. I did not know they were already adding 1 ms to everything. I assumed zero was zero.

    So no difference either way ... Thanks for saving me the time. I like your design better than theirs anyway since I understand yours from your tutorial and it's simple.

    Thanks again. Now on to adding the exponential curves...
     
  15. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    another way to reduce (or remove entirely) the clicking is to re-start your oscillators at the beginning of the envelope with a sync function. then you should be able to have a much shorter attack time.
     
  16. mike_jm

    mike_jm NI Product Owner

    Messages:
    281
    Is the click essentially from the envelope being mis-timed relative to the oscillator? ie. "Opening" on an oscillator mid cycle while the oscillator is at a non zero value?

    I googled and found this article on syncing but it is talking about syncing one oscillator to another, not an oscillator to an envelope or "gate" function:
    https://www.adsrsounds.com/reaktor-tutorials/digital-hard-sync-in-reaktor/

    I tried subbing in an oscillator with a sync function and hooking the Gate up to it. But that didn't allow removal of the click at zero knob settings (dropping the clipping threshold). I also tried running the envelope into the sync function but no benefit there either.

    Honestly, may not even be necessary to worry about. Thanks again.

    I'm gonna get working on the exponential functions next. That visualizer function you added is super cool btw. Great in polyphonic display too. Very helpful.
     
    Last edited: Jul 17, 2017
  17. sellotape

    sellotape NI Product Owner

    Messages:
    345
    What exactly is meant with clicking. I mean every envelope with very short time settings gives a clicky sound. There is a whole music genre using this effect. In the most cases you would use a logarithmic control for the times so it's easy to set a minimum time of 1ms. So they should behave just like the primary ones or not? Using finite or infite decay and relases stages also makes a huge difference. Another thing leading to clicks is the attack reset, i think the delay stage forces one too.
     
  18. salamanderanagram

    salamanderanagram NI Product Owner

    Messages:
    3,454
    you don't need to tell me! as you quoted me saying - "envelopes click".
     
    Last edited: Jul 17, 2017
  19. colB

    colB NI Product Owner

    Messages:
    3,969
    This will bandlimit the discontinuity caused by resetting the oscillator. There will still be a click if the oscillator was in use at the time it is reset (e.g. monophonic synth), it will just be a tasty DSP nerdtastic anti-aliased click

    @mike_jm
    Think about what a sound is in a digital audio context - a level oscillating between negative and positive following some waveform...
    This becomes sound because it is converted to a voltage which is used to move a speaker cone in and out causing a pressure wave... etc.

    What if there is no repeated oscillation - a hypothetical signal that moves the cone of the speaker from in to out (or from out to in - basically from one position to another) just one time?
    This would create a pressure wave as well, just without the cyclic repetition. If it happened quickly enough, it would be clearly audible and depending on how quick, it would sound like a thud or a click. A bit like hitting a drum but without letting the stick bounce back so the drum doesn't ring...

    Now think about a low frequency sound... like a bass note at 80Hz. At this rate, the full wave cycle takes 551.25 samples at 44.1Khz sample rate. So the level goes from positive maximum to negative maximum and back again in this time... At this rate, the time taken to go from zero to peak level is 137.8 samples

    Now think of a 1ms envelope attack - the volume is taken from 0 to maximum in 44.1, this is much faster than the rate of change of the bass note. So much that the envelope attack will be completed over a small part of the notes wave cycle.

    If the 80 Hz notes waveform is near a peak (negative or positive) when the envelope is triggered, the result is a strong click as the signal transitions from 0 to some level close to the peak level of the waveform in 44.1 samples time. The frequency of the click is higher than the frequency of the 80Hz note, and is near to the full volume of the sound.
    However, if the envelope is triggered while the 80Hz notes waveform is near a zero crossing, the attack will cause a transition from zero to this near zero position, and the click will much less audible...

    This gives the clicks an intermittent quality - some sounding louder, others barely audible, making the clicks more annoying and less musical...

    You can try to fix this a bit by resetting the phase of the oscillator every time a note is triggered, but this can also create problems if the oscillator was already audible (often the case in a monophonic context) because the phase reset causes a discontinuity in the waveform creating - whaddayaknow - a click :)

    If the note being played is a much higher frequency, the same 1 ms attack won't be a problem because there will be multiple oscillator cycles during the attack phase, the click of the attack is at a lower frequency compared with the note, and it is relatively constant rather than varying in a seemingly random fashion. If the attack is faster than 1ms, the click will be higher frequency and more noticeable... it will also be more annoying on higher pitched sounds.

    So basically, live with the click, and tweak the attack rate depending on what type of sound you are designing.
     
    Last edited: Jul 17, 2017
    • Like Like x 1
  20. sellotape

    sellotape NI Product Owner

    Messages:
    345
    I just got confused because it sounded like there is something wrong with the envelope toolkit. That is why i asked what was meant by clicking.