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

simple portamento script

Discussion in 'Scripting Workshop' started by dylan789, May 28, 2015.

  1. dylan789

    dylan789 New Member

    Messages:
    1
    I need a more simple version of the "unisono-portamento" script. I just need the Portamento settings not the "mono mode" or "unisono" settings. I have been trying to find the parts I need in the script but the script is very large.
     
  2. alswefi

    alswefi NI Product Owner

    Messages:
    51
    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, 200, 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
     
  3. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You can also just use the Glide modulator if all you need is simple portamento all the time.
     
  4. T.S.

    T.S. NI Product Owner

    Messages:
    581
    I just wanted to say thank you alswefi, this script did exactly what I wanted to do.

    I tried the "Glide" as ED mentioned, but that just didn't work well at all. But this script did. :)

    I only posted this because I think there are at least a few that are looking for a simple portamento type script.
     
  5. Dan Brown Jr

    Dan Brown Jr New Member

    Messages:
    3
    How do you add this to an existing code? I get an parse error? Thoughts?
     
  6. T.S.

    T.S. NI Product Owner

    Messages:
    581
    Yeah, you can't just throw it into a script, you have integrate it. :cool: