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

Arp Midi Note Range

Discussion in 'Scripting Workshop' started by foundation77, Apr 8, 2020.

  1. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    I have an arp created using the 'on listener' rather than 'on note' (like the factory script)
    Would it now be possible to limit the range of the arp 'on note'?

    I've noticed on previous threads ED bringing up this as answer to "limit key range/performance scripts"
    But I think this is not what I am looking for or trying to understand.

    Code:
    on note
        if (not (in_range($EVENT_NOTE,<min1>,<max1>) or in_range($EVENT_NOTE,<min2>,<max2>)))
            ignore_event($EVENT_ID)
        end if
    end on
    Assuming I want the key range of the affected notes to start from Middle C (Midi note 48) to a max of C8 (midi note 108)
    And everything below it to not be affected would the above code be useful?
    Or... is there another way perhaps?
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You'd want to "if in_range($EVENT_NOTE, min, max)" the part where the arp is started in note callback.
     
  3. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    Am I wrapping the whole 'on note' code in the 'if' or just the initial part before each case?

    Code:
    on note
    if (in_range($EVENT_NOTE,35,108))
      if ($Arp=1)
        ignore_event($EVENT_ID)
        if (%note_ids[$EVENT_NOTE]>0)
          exit
        else
          %note_ids[$EVENT_NOTE] := $EVENT_ID
        end if
      end if
        select ($Latch)
          case 0
            %note_buffer[$cursor] := $EVENT_NOTE
            %vel_buffer[$cursor] := $EVENT_VELOCITY
            inc($cursor)
          case 1
            if ($ENGINE_UPTIME-$old_latch_time>$LATCH_TIME)
              $i := 0
              while ($i<$cursor)
                %note_buffer[$i] := 0
                inc($i)
              end while
              $cursor := 0
            end if
            %note_buffer[$cursor] := $EVENT_NOTE
            %vel_buffer[$cursor] := $EVENT_VELOCITY
            inc($cursor)
            $old_latch_time := $ENGINE_UPTIME
        end select
        if ($cursor<2 and ($seq_running=0))
          if ($NI_TRANSPORT_RUNNING=0)
            wait($REC_TIME_TRANSPORT_STOPPED*1000)
          else
            wait($REC_TIME_TRANSPORT_RUNNING*1000)
          end if
          call StartSeq
          call TickReceived
        end if
      end if
    end on
     
    Last edited: Apr 8, 2020
  4. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    The above seems to work fine, can you see any errors at all?
    I don't get script warnings so I'm assuming it's okay
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Yeah that should be fine. Make sure to do the same thing in "on release" callback for the arp stuff that's happening there.
     
  6. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    Gotcha! Thanks again for your help, keep safe x
     
  7. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    ED, I'm having some difficulty with the above script.
    If I play a note, I the arp plays (I don't want it to)
    Also the latch functionality is behaving the same way so I think it might be to do with the 'on release' callback

    I added the above if statement to the beginning of the 'on release' callback but if I press a key it plays the arp in latch mode unless I turn it off
    The status of the latch and arp on/off button although visually looks off it's actually on.
    So I have to turn on and off each button for the arp / latch to be off

    Code:
    on release
    if (in_range($EVENT_NOTE,48,108))
      if (get_event_par($EVENT_ID,$EVENT_PAR_SOURCE) # $CURRENT_SCRIPT_SLOT)
        if (%note_ids[$EVENT_NOTE]=0)
          exit
        else
          %note_ids[$EVENT_NOTE] := 0
        end if
        if ($seq_running=1 and ($Latch=0))
          $cursor_helper := 0
          $i := 0
          while ($i<$cursor)
            if ($EVENT_NOTE # %note_buffer[$i])
              %note_buffer[$cursor_helper] := %note_buffer[$i]
              inc($cursor_helper)
            end if
            inc($i)
          end while
          $cursor := $cursor_helper
          if ($seq_running=1 and ($cursor=0))
            call StopSeq
          end if
        end if
      end if
    end if
     
  8. foundation77

    foundation77 NI Product Owner

    Messages:
    147
    To be honest I don't think this script will work for my intended use, in hindsight as if I set the arp octave to -1 that's fine I can loose an octave of notes not affected by the arp but I I want -2 octaves active I loose half the keyboard as I didn't want the lower C1-C4 to be affected by the arp.
    I really think this is a multiple instance of Kontakt scenario