Activate and deactivate groups / then no more sound

Options
treynterrio
treynterrio Member Posts: 64 Member

Hi there, I have a question maybe anyone could help me with this.

This is my code on "on note" I allow and disallow the groups to be active and in the on ui_control I mute a group and "active" volume up a group. My problem is when I click the first group and then the second and the third and I want to active the first group again there is no more sound and on the second one is no sound as well even the main group (0) is deactivated does anyone have a idea where the problem is? When I delete the "on note" part it works but then all groups are still active and the CPU goes up very high.

Thanks!


on init
  declare $i
  declare ui_button $group1
  declare ui_button $group2
  declare ui_button $group3
  declare ui_button $group4
  declare ui_button $group5

  declare %buttonIds[5]
    %buttonIds[0] := get_ui_id($group1)
    %buttonIds[1] := get_ui_id($group2)
    %buttonIds[2] := get_ui_id($group3)
    %buttonIds[3] := get_ui_id($group4)
    %buttonIds[4] := get_ui_id($group5)
end on

on note

disallow_group($ALL_GROUPS)
allow_group(0)
allow_group(6)

if ($group1 = 1)
disallow_group(0)
allow_group(1)
allow_group(6)
end if

if ($group2 = 1)
disallow_group(1)
disallow_group(3)
disallow_group(4)
disallow_group(5)
allow_group(2)
allow_group(6)
end if

if ($group3 = 1)
disallow_group(1)
disallow_group(2)
disallow_group(4)
disallow_group(5)
allow_group(3)
allow_group(6)
end if

if ($group4 = 1)
disallow_group(1)
disallow_group(2)
disallow_group(3)
disallow_group(5)
allow_group(4)
allow_group(6)
end if

if ($group5 = 1)
disallow_group(1)
disallow_group(2)
disallow_group(3)
disallow_group(4)
allow_group(5)
allow_group(6)
end if

end on

on ui_control($group1)
if ($group1 = 1)
$i := 0
while ($i < num_elements(%buttonIds))
set_control_par(%buttonIds[$i], $CONTROL_PAR_VALUE, 0)
inc($i)
end while
$group1 := 1
end if
if ($group1_enabled = 0)
set_engine_par($ENGINE_PAR_VOLUME, 630000, 1, -1, 0)
set_engine_par($ENGINE_PAR_VOLUME, 0, 0, -1, 0)
$group1_enabled := 1
disallow_group($ALL_GROUPS)
allow_group(0)
allow_group(6)
else
set_engine_par($ENGINE_PAR_VOLUME, 630000, 0, -1, 0)
set_engine_par($ENGINE_PAR_VOLUME, 0, 1, -1, 0)
$group1_enabled := 0
end if
end on

on ui_control($group2)
...
end on

on ui_control($group3)
...
end on

on ui_control($group4)
...
end on

on ui_control($group5)
...
end on


Back To Top