define key_lo, key_hi MIDI range

composer808
composer808 Member Posts: 8 Newcomer

Hi everyone! I want to specify different MIDI ranges per group, but when I switched to Group 3, I could not trigger a sample below 60, whereas I've listed it as 57. I've figured out that Group 0 defines the MIDI range, but even with a note in_range callback, I can still trigger a note outside of the specified range.

I imagine these are two different issues, but I figured they were connected.

Does anyone have suggestions on how to fix this?

declare %ks_list[$NUM_SOUNDS] := (0, 1, 2, 3, 4, 5, 6)
        declare %key_lo[$NUM_SOUNDS] := (60, 62, 60, 57, 60, 57, 59)
        declare %key_hi[$NUM_SOUNDS] := (97, 79, 79, 74, 77, 67, 66)

 if (not in_range($EVENT_NOTE, %key_lo[$sel_ks], %key_hi[$sel_ks]))
            ignore_event($EVENT_ID)
            exit
        end if

Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    In KSP, groups are ordered 0-based, so group 1 is 0, group 2 is 1, group 3 is 2, so it seems this might be tripping you up - what is being read from your $sel_ks is third entry in %key_lo/hi arrays, rather than fourth.

  • composer808
    composer808 Member Posts: 8 Newcomer

    Yes, thanks! Sorry, for the sake of being clear, I had referred to it improperly. I want Group 4 MIDI parameters from 57 - 74, Group 6 from 57 - 67, and Group 7 from 59 - 66.

    However, these groups (4, 6, 7) cannot play below 60.

    But when I change the key_lo of Group 0 to 57, Groups 4, 6, and 7 can also start at 57.

    I should mention that the key-colored range works correctly, but the MIDI range doesn't correspond.

    Thanks for double-checking with me!

    I had thought the issue might be in this "on persistance_changed"...

     on persistence_changed
            call ButtonCB()
            call KeyColor()
    		play_note (0,127,0,0)
        end on
    
  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Why are you doing that play_note()? If you're doing your own keyswitching that is entirely unnecessary (my assumption being that you're trying to set the default keyswitch this way - but doing it like that would undo whichever keyswitch you have previously selected and stored into $sel_ks)...

    That said, I cannot see anything wrong with that code - if keycoloring works as it should and groups don't play properly, the only thing that is left is to check if the groups are actually mapped properly within those designated ranges.

  • composer808
    composer808 Member Posts: 8 Newcomer

    but doing it like that would undo whichever keyswitch you have previously selected and stored into $sel_ks)...

    Yes, exactly my reasoning! I figured this as well, and I've taken that out now, but no change.

     to check if the groups are actually mapped properly within those designated ranges.

    Understood. Thanks for checking! I've double-checked that now, and everything is OK.

    I've confirmed that Group 0 defines the MIDI trigger parameters for all groups, and the key_lo, key_hi, only defines the key color range. So my intuition is that it's this bit here, and group 0 is "Normal".

    while ($i < $NUM_BUTTONS)
                %ID[$i] := get_ui_id($Normal) + $i
                inc($i)
            end while
    
  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Hmmm that is unrelated to what you posted in the first post. It's just gathering UI IDs for your articulation buttons. Are those buttons declared sequentially (one after another, with no other variable declarations in between)?

  • composer808
    composer808 Member Posts: 8 Newcomer

    ...It's just gathering UI IDs for your articulation buttons. Are those buttons declared sequentially (one after another, with no other variable declarations in between)?

    OK, I wondered if they were connected and didn't necessarily think they were. Thanks for clearing that up for me!

    Yes, and to confirm that I've done it properly.

    declare const $NUM_BUTTONS := 7
          declare const $NUM_SOUNDS := 7
    	  declare const $Norm_Group_0 := 0
          declare const $PedalTone_Group_0 := 5
    	  declare const $Chords_Group_0 := 7
    	  declare const $BendUp_Group_0 := 10
    	  declare const $BendDown_Group_0 := 13
    	  declare const $Wobble_Group_0 := 15
    	  declare const $Rips_Group_0 := 17
          declare $Norm_Robin
          declare $PedalTone_Robin
    	  declare $Chords_Robin
    	  declare $BendUp_Robin
    	  declare $BendDown_Robin
    	  declare $Wobble_Robin
    	  declare $Rips_Robin
    
    
    		declare $a
            declare $i
            declare $j
            declare $sel_ks
            declare $find_ks
            declare $old_btn
            declare $sel_btn
            declare %ID[$NUM_BUTTONS]
    
    
    		declare %ks_list[$NUM_SOUNDS] := (0, 1, 2, 3, 4, 5, 6)
            declare %key_lo[$NUM_SOUNDS] := (60, 62, 60, 57, 60, 57, 59)
            declare %key_hi[$NUM_SOUNDS] := (97, 79, 79, 74, 77, 67, 66)
    
    
            declare ui_button $Normal
            declare ui_button $PedalTone
            declare ui_button $Chords
            declare ui_button $BendUp
    		declare ui_button $BendDown
    		declare ui_button $Wobble
    		declare ui_button $Rips
    

    My other guess is that the wrong event note is triggered in the on note callback—an error with the event note and key_lo, key_hi array.

    $find_ks := search(%ks_list, $EVENT_NOTE)
    
    
            if ($find_ks # -1)
                $sel_ks := $find_ks
                call KeyColor()
            end if
    
    
            if (not in_range($EVENT_NOTE, %key_lo[$sel_ks], %key_hi[$sel_ks]))
                ignore_event($EVENT_ID)
                exit
            end if
    

    Or finally, is it possible that the function KeyColor defines what MIDI is triggered?

    Either way, thank you so much for taking the time to go through this with me!

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Keycoloring has nothing to do with what gets triggered - it's just a UI thing.

    That said, and this is just a minor thing, but you don't need exitwhen you ignore_event().

  • composer808
    composer808 Member Posts: 8 Newcomer

    Keycoloring has nothing to do with what gets triggered - it's just a UI thing.

    Thanks for clearing this up! I had figured as much but wanted to double-check. I'll dig through to spot any inconsistencies and start a new thread if needed. Thank you so much for taking the time to go through this!

    That said, and this is just a minor thing, but you don't need exitwhen you ignore_event().

    Got it! Thanks again!

Back To Top