while NOTE_HELD puzzle

Lovechld2000
Lovechld2000 Member Posts: 29 Member
edited July 2022 in Scripting Workshop

I'd like to run a loop while a note is held.

The loop has a play_note in it fed by a buffer generated on_note

if I call my loop inside on_note, the play_note loop instances for each note held, <-bad

instead of just one continuous loop while any amount of notes held. (which i want)

I can't set a var to be 1 on_note and 0 on_release because when the play_note loop happens, on_release happens stopping the loop

It seems like this loop will have to run called elsewhere whether notes are down or not? or is there another way for the ONCB to call the loop without starting multiple new instances of the loop each time?🤔

Comments

  • medusa
    medusa Member Posts: 85 Helper

    count held notes? start loop when count = 1, stop it when count = 0

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member
    edited July 2022

    yes where can i put the counter? if I put count = 1 on note, then i have to put count = 0 on release, but as soon as play_note happens in my loop , you get an on release. It's for a granular looping note. It works if you put the loop on note, but each on_note starts another loop process. I can just have a switch turn on the loop but then I'm stealing cycles even when no notes are playing.

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member
    edited July 2022

    maybe i could somehow make on note monophonic if I'm collecting chords in the buffer anyway

  • Lovechld2000
    Lovechld2000 Member Posts: 29 Member
    edited July 2022

    here's my crude p.o.c . I think if i can get the ORCB to check everything from a more elaborate buffer ( and build a decent buffer) it might work


    { Compiled on Thu Jul 28 16:05:43 2022 }
    on init
      declare $granflag
      declare $my_n_buffer
      declare $my_v_buffer
      declare $myid
      declare ui_button $gran_enable
    end on
    
    
    function gran_me
      while ($gran_enable=1)
        if ($granflag=1)
          $myid := play_note($my_n_buffer,$my_v_buffer,0,10000)
        end if
        wait(300000)
      end while
    end function
    
    
    on note
      $granflag := 1
      ignore_event($EVENT_ID)
      $my_n_buffer := $EVENT_NOTE
      $my_v_buffer := $EVENT_VELOCITY
    end on
    
    
    on release
      if ($EVENT_ID # $myid)
        $granflag := 0
      end if
    end on
    
    
    on ui_control($gran_enable)
      call gran_me
    end on
    
    
    


Back To Top