Simple Envelope - release not working



  • OK I have a drum sound in a sampler - with a simple envelope attached to manage GainModulation - the Attack works fine - but the release doesnt work at all.

    I suspect this has something to do with the fact I am triggering note playback in my Samplers midi processor - on note call back thus:

    function onNoteOn()
    {
        Message.ignoreEvent(true);
        Synth.playNote(Globals.triggerNote, Message.getVelocity());
        Console.print("playing trigger note:" + Globals.triggerNote);
    }
    

    I suspect here that this is because there is no corresponding note off event for my script triggered play_note. Do I need to keep the play_note noteID in some Global(again) spot and issue a note off for it? Or is there some other way in the note off I can get to the id of my internally triggered note?

    I guess I'm thinking of KSP play_note(some note, some velo, some offset, -1)

    Where "-1" means "releasing the note which started the callback stops the sample"



  • @Lindon I don't see a need to use a global to create the note off (unless you need to turn if off in another script) just a reg variable should be fine. If you want 1 ID per note then use a MIDIList instead.

    function onInit()
    {
        reg noteId;
    }
    
    function onNoteOn()
    {
        Message.ignoreEvent(true);
        noteId = Synth.playNote(Globals.triggerNote, Message.getVelocity());
        Console.print("playing trigger note:" + Globals.triggerNote);
    }
    
    function onNoteOff()
    {
        Synth.noteOffByEventId(noteId);
    }
    

    Another option


Log in to reply
 

5
Online

453
Users

1.5k
Topics

11.3k
Posts