Unisono Portamento Script - PGS Script for Time Control

MTC84
MTC84 Member Posts: 49 Member

Hi,

I am struggling with the PGS scripting for the Portamento Combi Knob (Time). Can anyone help please?

I have tried to follow the instructions from previous posts but keep running into script errors. I simply want a knob in script slot 1 to control the Portamento Time knob in script slot 4.

The script below is where I have got up to but it won't compile as there is a script error.

Thanks for any help.

{SCRIPT SLOT 1}
on init
	declare ui_knob $porta_combi_knob (0, 127, 1)
	make_persistent($porta_combi_knob)
	pgs_create_key(TME, 1)
end on

on ui_control ($porta_combi_knob)
	pgs_set_key_val(TME, 0, $porta_combi_knob)


{BELOW CODE IS COPIED FROM UNISONO PORTAMENTO ON UI_CONTROL ($porta_combi_knob)}

	select ($porta_combi_knob)
		case 0 to 31
			$GlideRel := ($porta_combi_knob * 80)/32
		case 32 to 63
			$GlideRel := (($porta_combi_knob-32) * 120)/32 + 80
		case 64 to 95
			$GlideRel := (($porta_combi_knob-64) * 200)/32 + 200
		case 96 to 127
			$GlideRel := (($porta_combi_knob-96) * 2600)/31 +400
	end select
	$GlideAbs := ($porta_combi_knob*$porta_combi_knob*2000)/(127*127)
	{if ($porta_rel_glide_button = 1)
		set_knob_label($porta_combi_knob,$GlideRel)		
	else
		if ($GlideAbs < 1000)
			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&($GlideAbs mod 100)/10&" s")
		else
			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&" s")	
		end if	
	end if}
end on

function Porta_Time_Function()
	select ($porta_combi_knob)
		case 0 to 31
			$GlideRel := ($porta_combi_knob * 80)/32
		case 32 to 63
			$GlideRel := (($porta_combi_knob-32) * 120)/32 + 80
		case 64 to 95
			$GlideRel := (($porta_combi_knob-64) * 200)/32 + 200
		case 96 to 127
			$GlideRel := (($porta_combi_knob-96) * 2600)/31 +400
	end select
	$GlideAbs := ($porta_combi_knob*$porta_combi_knob*2000)/(127*127)
	{if ($porta_rel_glide_button = 1)
		set_knob_label($porta_combi_knob,$GlideRel)		
	else
		if ($GlideAbs < 1000)
			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&($GlideAbs mod 100)/10&" s")
		else
			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&" s")	
		end if	
	end if}
end function


on ui_control ($porta_combi_knob)
    call Porta_Time_Function()
end on


{PORTAMENTO TIME KNOB - PGS CONTROL}
on pgs_changed
	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
		$porta_combi_knob := pgs_get_key_val(TME, 0)
	end if
end on


{SCRIPT SLOT 4 - UNISONO PORTAMENTO SCRIPT PLUS THE FOLLOWING CODE AT THE END}

{PORTAMENTO TIME KNOB - PGS CONTROL}
on pgs_changed
	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
		$porta_combi_knob := pgs_get_key_val(TME, 0)
	end if
end on

Best Answer

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    I did not say to copy the whole UI control callback from script slot 4! I said to set PGS key value...

    on ui_control ($porta_combi_knob)
        pgs_set_key_val(TME, 0, $porta_combi_knob)
    end on
    


Answers

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    edited February 2022

    Your script slot 1 doesn't need the portamento function at all. You just send the value for portamento via the PGS key and that's it!

    You do need that function in the actual unisono-portamento script, as you would call it from the PGS callback there, and also from the UI callback of the portamento time knob.

  • MTC84
    MTC84 Member Posts: 49 Member

    Thanks for the reply. You are immensely helpful.

    I'm a little closer (no script errors) but the knob I created is no longer controlling the Portamento Time Knob at all.  

    What am I missing? Thanks.

    {SCRIPT SLOT 1}
    on init
    	declare ui_knob $porta_combi_knob (0, 127, 1)
    	make_persistent($porta_combi_knob)
    	pgs_create_key(TME, 1)
    end on
    
    {PORTAMENTO TIME KNOB - PGS CONTROL}
    on pgs_changed
    	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
    		$porta_combi_knob := pgs_get_key_val(TME, 0)
    	end if
    end on
    
    


    {Script Slot 4 - PORTAMENTO NI SCRIPT PLUS BELOW CODE}
    
    function Porta_Time_Function()
    	select ($porta_combi_knob)
    		case 0 to 31
    			$GlideRel := ($porta_combi_knob * 80)/32
    		case 32 to 63
    			$GlideRel := (($porta_combi_knob-32) * 120)/32 + 80
    		case 64 to 95
    			$GlideRel := (($porta_combi_knob-64) * 200)/32 + 200
    		case 96 to 127
    			$GlideRel := (($porta_combi_knob-96) * 2600)/31 +400
    	end select
    	$GlideAbs := ($porta_combi_knob*$porta_combi_knob*2000)/(127*127)
    	{if ($porta_rel_glide_button = 1)
    		set_knob_label($porta_combi_knob,$GlideRel)		
    	else
    		if ($GlideAbs < 1000)
    			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&($GlideAbs mod 100)/10&" s")
    		else
    			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&" s")	
    		end if	
    	end if}
    end function
    
    on ui_control ($porta_combi_knob)
        call Porta_Time_Function()
    end on
    
    {PORTAMENTO TIME KNOB - PGS CONTROL}
    on pgs_changed
    	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
    		$porta_combi_knob := pgs_get_key_val(TME, 0)
    	end if
    end on
    


  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod

    Do you have a ui_control callback for your portamento knob in script slot 1? You need to set PGS key value from there.

  • MTC84
    MTC84 Member Posts: 49 Member

    When I use the same on ui_control callback in slot 1, I get a script error. Below is the script I have so far.

    Script Slot 4 is the script I pasted above.

    Thanks again for your help with this.

    {Script Slot 1}
    on init
    	declare ui_knob $porta_combi_knob (0, 127, 1)
    	make_persistent($porta_combi_knob)
    	pgs_create_key(TME, 1)
    end on
    
    on ui_control ($porta_combi_knob)
    	select ($porta_combi_knob)
    		case 0 to 31
    			$GlideRel := ($porta_combi_knob * 80)/32
    		case 32 to 63
    			$GlideRel := (($porta_combi_knob-32) * 120)/32 + 80
    		case 64 to 95
    			$GlideRel := (($porta_combi_knob-64) * 200)/32 + 200
    		case 96 to 127
    			$GlideRel := (($porta_combi_knob-96) * 2600)/31 +400
    	end select
    	$GlideAbs := ($porta_combi_knob*$porta_combi_knob*2000)/(127*127)
    	{if ($porta_rel_glide_button = 1)
    		set_knob_label($porta_combi_knob,$GlideRel)		
    	else
    		if ($GlideAbs < 1000)
    			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&($GlideAbs mod 100)/10&" s")
    		else
    			set_knob_label($porta_combi_knob,$Glideabs/1000&"."&($GlideAbs mod 1000)/100&" s")	
    		end if	
    	end if}
    end on
    
    {PORTAMENTO TIME KNOB - PGS CONTROL}
    on pgs_changed
    	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
    		$porta_combi_knob := pgs_get_key_val(TME, 0)
    	end if
    end on
    
  • MTC84
    MTC84 Member Posts: 49 Member
    edited February 2022

    I'm wondering if it has something to do with the links to other controls within the Unisono Portamento script? I obviously don't have controls such as the $GlideAbs or $GlideRel in Script Slot 1 apart from within the on ui_control script that has been copied from the NI script.

  • EvilDragon
    EvilDragon Moderator Posts: 1,022 mod
    Answer ✓

    I did not say to copy the whole UI control callback from script slot 4! I said to set PGS key value...

    on ui_control ($porta_combi_knob)
        pgs_set_key_val(TME, 0, $porta_combi_knob)
    end on
    


  • MTC84
    MTC84 Member Posts: 49 Member

    Thanks as always. There are no script errors but the knob I created in script slot 1 is not updating the Portamento Time control properly. Both knobs are moving in a linked fashion (as I want) but note playback isn't effected. The portamento does update properly when I use the original time knob in script slot 4. I must be missing something still?

    Script Slot 4 code is as pasted above. Script Slot 1 is now as follows:

    on init
    	declare ui_knob $porta_combi_knob (0, 127, 1)
    	make_persistent($porta_combi_knob)
    	pgs_create_key(TME, 1)
    end on
    
    {ON UI CONTROL - PORTA COMBI KNOB - PGS KEY}
    on ui_control ($porta_combi_knob)
        pgs_set_key_val(TME, 0, $porta_combi_knob)
    end on
    
    {PORTAMENTO TIME KNOB - PGS CONTROL}
    on pgs_changed
    	if (pgs_key_exists(TME) and pgs_get_key_val(TME, 0) # $porta_combi_knob)
    		$porta_combi_knob := pgs_get_key_val(TME, 0)
    	end if
    end on
    
  • MTC84
    MTC84 Member Posts: 49 Member
    edited March 2022

    I figured it out....Script Slot 4 was missing the on ui_control code inside the on_pgs changed code block. I also deleted the on pgs_changed code block from Script Slot 1. All is working now.

    Thanks for your help. I appreciate your time.

  • treynterrio
    treynterrio Member Posts: 64 Member

    should I've to copy something into the Unison Portamento Script too to use it in my main script?

    @MTC84 could you send me the complete code that you've used?

  • MTC84
    MTC84 Member Posts: 49 Member
    on init
    {GLIDE SLIDER CONTROL - PGS}
    
    	declare ui_slider$porta_combi_knob(0, 127)
    	move_control_px($porta_combi_knob, 463, 85)
    	make_persistent($porta_combi_knob)
    
    	pgs_create_key(TME, 1)
    end on
    
    
    {ON UI CONTROL - PORTA COMBI KNOB - PGS KEY}
    
    on ui_control ($porta_combi_knob)
        pgs_set_key_val(TME, 0, $porta_combi_knob)
    end on
    
    
    

    I did this so long ago that I have actually forgotten how I did things. I think the code above is what I used though so you can try that. Sorry I can't be more help.

Back To Top