CPU overload when turning the attack knob

Reylon
Reylon Member Posts: 23 Member
edited October 22 in Scripting Workshop

Hi guys, my CPU screams when I'm turning the attack knob. The knob is assigned to 1470 groups but that should not be a thing why the CPU overloads...

on ui_control($Caroseria_ADSR_Attack)
    $group_counter:=1
    while($group_counter < $NUM_GROUPS)
    set_engine_par($ENGINE_PAR_ATTACK,$Caroseria_ADSR_Attack,$group_counter,0,-1)
    inc($group_counter)
    end while
end on

Comments

  • EvilDragon
    EvilDragon Moderator Posts: 1,031 mod

    That is exactly why it overloads. You should only update groups that are loaded/unpurged/are making any sound. Then when you change soundsources, transfer the relevant engine parameters to the newly selected group(s). This is how you save a lot of CPU.

  • Reylon
    Reylon Member Posts: 23 Member
    edited September 2022

    Thanks ED,

    I was browsing the forum and found a script.

    with some adjustments...

    Just add purge_group($menu2,1) to $menu_1's ui_control callback, and the other way around, purge_group($menu1,1)to $menu_2's ui_control callback. Also, make sure that menu entry values for group 3 and 4 are 2 and 3, not 0 and 1.

    Might this do it?

    on init
    
        make_perfview
        set_ui_height_px(500)
    
        declare $i
        
        declare ui_menu $menu1
        declare ui_menu $menu2
    
    
        move_control ($menu1,1,3)
        move_control ($menu2, 5,3)
    
    
        add_menu_item($menu1, "Group 1 ", 0)
        add_menu_item($menu1, "Group 2", 1)
    
        add_menu_item($menu2, "Group 3 ", 0)
        add_menu_item($menu2, "Group 4", 1)
    end on
    
    on ui_control ($menu1)
        $i := 0
        while ($i<$NUM_GROUPS)
            purge_group($i,1)
            inc($i)
        end while
    
        purge_group($menu1,0)
    end on
    
    on ui_control ($menu1)
        $i := 0
        while ($i<$NUM_GROUPS)
            purge_group ($i,0)
            inc($i)
        end while
    
        purge_group($menu1,1)
    end on
    
    on ui_control ($menu2)
        $i := 0
        while ($i<$NUM_GROUPS)
            purge_group($i,1)
            inc($i)
        end while
    
        purge_group($menu2,0)
    end on
    
    on ui_control ($menu2)
        $i := 0
        while ($i<$NUM_GROUPS)
            purge_group($i,0)
            inc($i)
        end while
    
        purge_group($menu2,1)
    end on
    
This discussion has been closed.
Back To Top