Waiting 1 microsec before change_vol() results in ~50 millisec attack

Options
Reid115
Reid115 Member Posts: 47 Member
on init
    declare $new_id
end on

on note
    ignore_event($EVENT_ID)
    
    $new_id := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, 500000)
    change_vol($new_id, -100000, 0)
    change_vol($new_id, 0, 0)
    
    wait(600000)
    
    $new_id := play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, 500000)
    change_vol($new_id, -100000, 0)
    wait(1)
    change_vol($new_id, 0, 0)
end on

Take a look at this script. When you press a key, two notes will fire. Both events will start at -100db, but will immediately raise to 0db. The only difference is that the second event waits a single microsecond before raising the volume. The thing is, there's no way you should be able to tell the difference; 1 millisecond would be hard to identify, let alone 1 microsecond. But what ends up happening is that the second event sounds like it has a smooth ~50 millisecond attack. Am I missing something?

If you test the script yourself, make sure you have no volume AHDSR.

Best Answer

  • medusa
    medusa Member Posts: 86 Helper
    Answer ✓
    Options

    That's because change_vol has a slew, a smoothing. If there is no wait at all, the first change_vol is overwritten before it's even applied.

Answers

  • medusa
    medusa Member Posts: 86 Helper
    Answer ✓
    Options

    That's because change_vol has a slew, a smoothing. If there is no wait at all, the first change_vol is overwritten before it's even applied.

  • Reid115
    Reid115 Member Posts: 47 Member
    edited February 2022
    Options

    Is there any work-around for this? I'm using 200 consecutive calls to change_vol(..., ..., 1) according to specific curve equations for fading in/out different marks of voices. When the fade-in time is really short (like < 20 milliseconds), I get this really noticeable fade-in from the change_vol() slew.

  • medusa
    medusa Member Posts: 86 Helper
    Options

    I don't think there's any way to change it or turn it off, no, it's fixed.

    It's also very likely that your curve won't be what you intend, if you use change_vol to try and make a curve, because of that slew.

    Can you not design your curves with envelopes? Flexi envelopes? They're much more precise.

  • Reid115
    Reid115 Member Posts: 47 Member
    Options

    No, the envelope has to be completely from the script for what I'm doing. The envelope gets applied under different circumstances, and to different marks of voices. If I used an internal envelope, I wouldn't have the control I need. I wrote the equations by ear with the iterative change_vol() mechanic already in place, so the curves sound as I want them to. I wonder if I should scrap the change_vol() algorithm and instead use a from_script modulator on the volume knob. It would require me to completely redo the math because the volume knob doesn't scale linearly (and also because the changes would be absolute, not relative), but that may be my only option.

  • medusa
    medusa Member Posts: 86 Helper
    Options

    Yeah, listen to the difference between change vol and from_script in this test! Pretty extreme.



Back To Top