Play_Note Keeps Retrigging on All PGS Callbacks

Gravez Member Posts: 5 Member


So recently I've been running into a weird issue that i'm having trouble solving.

I have been trying to create a noise texture menu that will play a looping texture (vinyl noise, rain, forest sounds. etc.) when selected from a dropdown menu. This will loop in the background of the kontakt instrument while you play and can be triggered on and off with a bypass button.

I have successfully been able to get this script to work with multiple approaches in it's on separate script slot but the issue always repeats itself when I set up a PGS callback to control the par from the first script slot.

Whenever I set up the PGS callback in "slot 1" the controls work however when I touch any knob , slider or switch that triggers a PGS event it ends up "retriggering" the selected "play_note" noise from "slot 2" from the beginning which creates a stuttering like effecting when simple turning a knob or a "clicking noise" when pressing a button.

This issue only happens when I turn a PGS control in script slot 1 which includes the sliders I have controlling other scripts (slot 3 and 4) as well. I also stripped both codes down to just the instrument and noise script and still got the same result.

I'm unsure how to approach fixing this issue or if there is a better way to incorporate a background "noise select menu". I appreciate any time and help on this matter as I am really grateful for the assistance this community has provided over the years.


Here's a sample of the "Noise Menu" script. I figured this is what someone could take a look at since the issue can be replicated when creating a PGS trigger with any script.

{----- INIT -----}	
{paste INIT code under here}

  on init	


  declare ui_button $NoiseButton

  declare ui_menu $SelectNoise
  add_menu_item ($SelectNoise, "Select Noise",0) 
  add_menu_item ($SelectNoise, "Ampex-102 Noise Floor",1)
  add_menu_item ($SelectNoise, "Juno-106 Noise Floor",2)
  add_menu_item ($SelectNoise, "Moog One Noise Floor",3)
  add_menu_item ($SelectNoise, "OB-6 Noise Floor",4)
  add_menu_item ($SelectNoise, "Old Record Noise Floor",5)
  add_menu_item ($SelectNoise, "Record Vinyl Noise A",6)
  add_menu_item ($SelectNoise, "Record Vinyl Noise B",7)
  add_menu_item ($SelectNoise, "Record Vinyl Noise C",8)
  add_menu_item ($SelectNoise, "Record Vinyl Noise D",9)
  add_menu_item ($SelectNoise, "Record Vinyl Noise E",10)
  add_menu_item ($SelectNoise, "After The Rain Texture",11)
  add_menu_item ($SelectNoise, "Lost at Sea Texture",12)
  add_menu_item ($SelectNoise, "Rain in Dubai Texture",13)
  add_menu_item ($SelectNoise, "Room Tone Texture",14)
  add_menu_item ($SelectNoise, "The Woods Texture",15)
  add_menu_item ($SelectNoise, "Time in London Texture",16)
  add_menu_item ($SelectNoise, "Tour in France Texture",17)
  add_menu_item ($SelectNoise, "Walk to Mexico Texture",18)
  add_menu_item ($SelectNoise, "Warm Night Swim Texture",19)
  add_menu_item ($SelectNoise, "Wet Parked Car Texture",20)

  declare $noteID

end on 

{----- ON NOTE -----}
{paste ON NOTE code under here}

{----- ON CONTROLLER -----}
{paste CONTROLLER code under here}

{----- FUNCTIONS -----}	
{paste FUNCTION code under here}	

function NoiseMode()

	if ($NoiseButton = 0)


		if ($NoiseButton = 1 and $SelectNoise = 0)
		end if
		if ($NoiseButton = 1 and $SelectNoise = 1)
			$noteID := play_note(0,127,0,-1)
   			set_event_par_arr($noteID,$EVENT_PAR_ALLOW_GROUP,1,find_group("Ampex-102 Noise Floor"))
   		end if

		if ($NoiseButton = 1 and $SelectNoise = 2)
			$noteID := play_note(0,127,0,-1)
   			set_event_par_arr($noteID,$EVENT_PAR_ALLOW_GROUP,1,find_group("Juno-106 Noise Floor"))
   		end if
   	end if

end function

{----- CONTROLS -----}	
{paste CONTROL code under here}	


on ui_control($NoiseButton)
 	call NoiseMode()
end on


on ui_control($SelectNoise)
 	call NoiseMode()
end on

{----- PGS -----}	
{paste PGS code under here}

on pgs_changed

	if (pgs_key_exists(NOISE_BUTTON))
		$NoiseButton := pgs_get_key_val(NOISE_BUTTON,0)
		call NoiseMode()
	end if

	if (pgs_key_exists(SELECT_NOISE))
		$SelectNoise := pgs_get_key_val(SELECT_NOISE,0)
		call NoiseMode()
	end if

end on


  • EvilDragon
    EvilDragon Moderator Posts: 1,017 mod

    You only need to execute those function calls if $NoiseButton (or $SelectNoise) have actually changed value, so add a check for that:

    if (pgs_key_exists(NOISE_BUTTON) and pgs_get_key_val(NOISE_BUTTON, 0) # $NoiseButton)

  • Gravez
    Gravez Member Posts: 5 Member

    OMG !!!! EvilDragon !!! I freaking love you dude !!!

    Checking for those changed values worked flawlessly. I don't know how to repay you cause this was driving me crazy for days and I knew it had to be something simple that i'm obviously missing.

    I really appreciate your help and taking the time man.

    Your are a legend !

Back To Top