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

Portamento Help Bypass

Discussion in 'Scripting Workshop' started by Elad A, Mar 22, 2017.

  1. Elad A

    Elad A New Member

    Messages:
    3
    Peace I need helped how to do an ON / OFF button or BYPASS to portmento

    I will thank you very much



    on init
    declare const $pitch_change_interval := 100
    declare $glide_on
    declare $currentnote_id
    declare $newnote_id
    declare $oldnote1_id
    declare $oldnote2_id
    declare $oldnote3_id
    declare $current_pitch
    declare $target_pitch
    declare $pitch_shift
    declare $actual_glide
    declare $interval_cents
    declare polyphonic $this_id
    declare ui_knob $Glide(1000, 1000000, 1000000)
    declare ui_knob $Start(0, 1000000, 1000000)
    declare ui_knob $Scaling(100, 1000, 100)
    declare ui_value_edit $Threshold(0, 127, 1)
    $Glide := 120000
    $Start := 5000
    $Scaling := 125
    $Threshold := 12
    move_control($Glide,1,1)
    move_control($Start,2,1)
    move_control($Scaling,3,1)
    move_control($Threshold,4,1)
    make_persistent($Start)
    make_persistent($Glide)
    make_persistent($Scaling)
    make_persistent($Threshold)
    message("")
    end on

    on note
    if ($glide_on=1)
    ignore_event($EVENT_ID)
    $newnote_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,$Start,-1)
    $this_id := $newnote_id
    change_tune($newnote_id,$current_pitch-($EVENT_NOTE*100000),0)
    $target_pitch := $EVENT_NOTE*100000
    $interval_cents := abs($target_pitch/1000-($current_pitch/1000))
    if ($interval_cents>($Threshold*100))
    $interval_cents := $Threshold*100
    end if
    $actual_glide := $Glide+($Glide*$interval_cents/1200*($Scaling-100)/100)
    fade_out($newnote_id,0,1)
    fade_in($newnote_id,$actual_glide)
    fade_out($currentnote_id,$actual_glide,1)
    note_off($oldnote3_id)
    $oldnote3_id := $oldnote2_id
    $oldnote2_id := $oldnote1_id
    $oldnote1_id := $currentnote_id
    $currentnote_id := $newnote_id
    $pitch_shift := ($target_pitch-$current_pitch)/($actual_glide/$pitch_change_interval)
    wait($pitch_change_interval)
    while (abs($target_pitch-$current_pitch)>abs($pitch_shift))
    if ($currentnote_id=$this_id)
    change_tune($currentnote_id,$pitch_shift,1)
    change_tune($oldnote1_id,$pitch_shift,1)
    change_tune($oldnote2_id,$pitch_shift,1)
    change_tune($oldnote3_id,$pitch_shift,1)
    $current_pitch := $current_pitch+$pitch_shift
    wait($pitch_change_interval)
    else
    exit
    end if
    end while
    if ($currentnote_id=$this_id)
    $pitch_shift := $target_pitch-$current_pitch
    change_tune($currentnote_id,$pitch_shift,1)
    change_tune($oldnote1_id,$pitch_shift,1)
    change_tune($oldnote2_id,$pitch_shift,1)
    change_tune($oldnote3_id,$pitch_shift,1)
    $current_pitch := $target_pitch
    end if
    else
    $currentnote_id := $EVENT_ID
    $current_pitch := $EVENT_NOTE*100000
    $glide_on := 1
    end if
    end on

    on release
    if ($EVENT_ID=$currentnote_id)
    $glide_on := 0
    note_off($oldnote3_id)
    note_off($oldnote2_id)
    note_off($oldnote1_id)
    $current_pitch := $target_pitch
    end if
    if ($glide_on=1 and ($EVENT_ID # $oldnote3_id))
    ignore_event($EVENT_ID)
    wait($Glide)
    note_off($EVENT_ID)
    end if
    end on
     
  2. alswefi

    alswefi NI Product Owner

    Messages:
    51
    on init
    declare ui_switch $pass
    set_control_par(get_ui_id($pass),$CONTROL_PAR_TEXT_ALIGNMENT,1)
    make_persistent($pass)
    move_control($pass,3,1)
    end on

    on ui_control($pass)
    note_off($ALL_EVENTS)

    end on

    on note

    if( $pass= 0)
    exit
    else
    { your script }
    end if
    end on
     
  3. Lindon

    Lindon NI Product Owner

    Messages:
    322
    well the above suggestion from alswefi is a note on/off switch not a portamento on/off switch.

    You need to lookup $ENGINE_PAR_INTMOD_BYPASS to turn your portamento modulator on or off...
     
  4. alswefi

    alswefi NI Product Owner

    Messages:
    51
    sorry but it is an portamento bypass button
    u can try it

    Code:
    on init
       
    declare ui_switch $pass
    set_control_par(get_ui_id($pass),$CONTROL_PAR_TEXT_ALIGNMENT,1)
    make_persistent($pass)
    move_control($pass,3,1)
    
      
    
    declare const $pitch_change_interval := 100
    declare $glide_on
    declare $currentnote_id
    declare $newnote_id
    declare $oldnote1_id
    declare $oldnote2_id
    declare $oldnote3_id
    declare $current_pitch
    declare $target_pitch
    declare $pitch_shift
    declare $actual_glide
    declare $interval_cents
    declare polyphonic $this_id
    declare ui_knob $Glide(1000, 1000000, 1000000)
    declare ui_knob $Start(0, 1000000, 1000000)
    declare ui_knob $Scaling(100, 1000, 100)
    declare ui_value_edit $Threshold(0, 127, 1)
    $Glide := 120000
    $Start := 5000
    $Scaling := 125
    $Threshold := 12
    move_control($Glide,1,1)
    move_control($Start,2,1)
    move_control($Scaling,3,1)
    move_control($Threshold,4,1)
    make_persistent($Start)
    make_persistent($Glide)
    make_persistent($Scaling)
    make_persistent($Threshold)
    message("")
    end on
    
    
    on ui_control($pass)
    note_off($ALL_EVENTS)
    
    end on
    
    on note
    if( $pass= 0)
    exit
    else  
    
    if ($glide_on=1)
    ignore_event($EVENT_ID)
    $newnote_id := play_note($EVENT_NOTE,$EVENT_VELOCITY,$Start,-1)
    $this_id := $newnote_id
    change_tune($newnote_id,$current_pitch-($EVENT_NOTE*100000),0)
    $target_pitch := $EVENT_NOTE*100000
    $interval_cents := abs($target_pitch/1000-($current_pitch/1000))
    if ($interval_cents>($Threshold*100))
    $interval_cents := $Threshold*100
    end if
    $actual_glide := $Glide+($Glide*$interval_cents/1200*($Scaling-100)/100)
    fade_out($newnote_id,0,1)
    fade_in($newnote_id,$actual_glide)
    fade_out($currentnote_id,$actual_glide,1)
    note_off($oldnote3_id)
    $oldnote3_id := $oldnote2_id
    $oldnote2_id := $oldnote1_id
    $oldnote1_id := $currentnote_id
    $currentnote_id := $newnote_id
    $pitch_shift := ($target_pitch-$current_pitch)/($actual_glide/$pitch_change_interval)
    wait($pitch_change_interval)
    while (abs($target_pitch-$current_pitch)>abs($pitch_shift))
    if ($currentnote_id=$this_id)
    change_tune($currentnote_id,$pitch_shift,1)
    change_tune($oldnote1_id,$pitch_shift,1)
    change_tune($oldnote2_id,$pitch_shift,1)
    change_tune($oldnote3_id,$pitch_shift,1)
    $current_pitch := $current_pitch+$pitch_shift
    wait($pitch_change_interval)
    else
    exit
    end if
    end while
    if ($currentnote_id=$this_id)
    $pitch_shift := $target_pitch-$current_pitch
    change_tune($currentnote_id,$pitch_shift,1)
    change_tune($oldnote1_id,$pitch_shift,1)
    change_tune($oldnote2_id,$pitch_shift,1)
    change_tune($oldnote3_id,$pitch_shift,1)
    $current_pitch := $target_pitch
    end if
    else
    $currentnote_id := $EVENT_ID
    $current_pitch := $EVENT_NOTE*100000
    $glide_on := 1
    end if
    end if
    end on
    
    on release
    if ($EVENT_ID=$currentnote_id)
    $glide_on := 0
    note_off($oldnote3_id)
    note_off($oldnote2_id)
    note_off($oldnote1_id)
    $current_pitch := $target_pitch
    end if
    if ($glide_on=1 and ($EVENT_ID # $oldnote3_id))
    ignore_event($EVENT_ID)
    wait($Glide)
    note_off($EVENT_ID)
    end if
    end on
    
     
  5. Lindon

    Lindon NI Product Owner

    Messages:
    322
    this:
    if( $pass= 0)
    exit
    else
    { your script }
    end if
    end on


    [/CODE]

    will not play the note....if off, and do something if ON - so its a note bypassing technique, a better approach is to use the portmento modulator....
     
  6. alswefi

    alswefi NI Product Owner

    Messages:
    51
    exiting the script never stops playing the notes it just exit the portamento mode
    there is not any order to bypass notes before exit or some thing similar.
     
  7. Lindon

    Lindon NI Product Owner

    Messages:
    322
    true enough, if you've hand rolled your own portamento, so yeah iu take it back. If this is the way you want to roll.....
     
  8. alswefi

    alswefi NI Product Owner

    Messages:
    51
    it is not just a portamento script, it is a glide plus mono
    i actually need to add two features to it
    first is splitting both mono and glide with on/off switches
    second is add the last key retrigger if is still held
     
  9. Elad A

    Elad A New Member

    Messages:
    3
    That's exactly what I wanted
    Switch $ pass

    thank you so much, friends