What's new

Detuning keyswitch script

Troy M

Member
I already have a very detailed script but we would like to add an octave range of keyswitches that control the pitch of every sample. I've seen this done in other libraries and even have access to the code of one. But I can't seem to figure it out. I don't know where to start on this... Does anyone have a working script for this?
 
Yes.. reverxis by pulsesetter has a keyswitch setup that changes the pitch of each sample. It uses a $detuner that I can't find any info on. The code is open but it's tied into an effects menu etc completely different setup to what I'm using. Way more complicated than I need.
 
It's pretty simple...

Code:
on init
    declare const $KS_TRANSPOSE := 44
    declare const $TRANSPOSE_RANGE := 6

    declare $i
    declare $detune
    make_persistent($detune)
end on

function KeyColor()
    $i := $KS_TRANSPOSE - $TRANSPOSE_RANGE
    while ($i <= $KS_TRANSPOSE + $TRANSPOSE_RANGE)
        set_key_color($i, $KEY_COLOR_RED)
        inc($i)
    end while
    set_key_color($KS_TRANSPOSE, $KEY_COLOR_YELLOW)
    set_key_color($KS_TRANSPOSE + $detune, $KEY_COLOR_GREEN)
end function

on persistence_changed
    call KeyColor()
end on

on note
    if (in_range($EVENT_NOTE, $KS_TRANSPOSE - $TRANSPOSE_RANGE, $KS_TRANSPOSE + $TRANSPOSE_RANGE))
        ignore_event($EVENT_ID)
        $detune := $EVENT_NOTE - $KS_TRANSPOSE

        change_tune($ALL_EVENTS, $detune * 100000, 0)

        call KeyColor()
    else
        change_tune($EVENT_ID, $detune * 100000, 0)
    end if
end on
 
YESSS!!! Brilliant.. I just need the centre keyswitch to be C and its perfect!!
 
I changed
declare const $KS_TRANSPOSE := 44
to
declare const $KS_TRANSPOSE := 36

Thanks Evil Dragon!!!!!!! YOU THE MAN!!!
 
Top Bottom