# Bus Solo from KSP?



## polypx (Aug 27, 2012)

Does anyone know a way to get at the bus solo from KSP?

(Can't find it in the manual.)

cheers
Dan


----------



## sonaht (Aug 27, 2012)

I don't think there is a way to script that button through KSP. 

I'm not sure what you are trying to do but an alternate way to create a "Solo" bus functionality would be with switches and bringing every other bus volume down but the one you want.

A similar function is built into Studio Drummer's mixer script if you want to take a look at that.


----------



## mk282 (Aug 28, 2012)

Instead of bringing the volume of all other busses down (which will not make the CPU usage go away), I would suggest bypassing all effects in all busses that are supposed to be muted. You might get a pop here and there, but it will save CPU.

Another way of doing it might be storing the current bus volumes in an array (and of course update that array when volume sliders are moved), then set volumes for busses to be muted to -oo dB (simply go through bus volumes by using the array and multiply with 0 or 1, depending which bus needs to be muted or not), then bypassing all effects on muted busses (using another array for storing bypass states of all effects in all busses). That way, you're not getting pops, and as an added benefit you save CPU.

I presume if all NI Drummers did this (which they are not!), they would consume a lot less CPU than they do. Alas, that doesn't seem to be the case (and yes, I have the latest updates which promise less CPU usage up to 40%... which is not really true in practice) ... sonaht, if you programmed those scripts, I would advise one more update with the method I suggested, because it will further reduce CPU usage of those products (which is higher than most other competitor products).


----------



## polypx (Aug 28, 2012)

Thanks for the suggestions guys. I guess I have to build it myself then... good point about the bypass states MK, cheers.

Dan.


----------



## Raptor4 (Aug 28, 2012)

Hi Dan
To my opinion there is a way to make the trick by controlling the bus volume levels and storing them into an array. You need another array which must watch the UI Solo button status as well as mk282 pointed above, as well as a counter which will care for getting the bus levels etc. As a whole it is a matter of a few functions so you can recall the same functions during each UI button CB. This way it will not boost the CPU cause it is based on "searching the flag" etc.
I just created something for you - get it from the attachment and try.
Have fun ! :wink: 

R4


----------



## polypx (Aug 28, 2012)

Hey thanks R4! That's very useful.

cheers
Dan


----------



## mk282 (Aug 28, 2012)

You don't need another array which would watch the UI solo buttons - you can simply use get_control_par(<ID>,$CONTROL_PAR_VALUE) to get the value directly. If you've declared the solo buttons sequentially, you can easily get the button values in a while loop, too (by using get_control_par(<first button ID> + $I,$CONTROL_PAR_VALUE)). Same is valid for bus volume sliders (if they are used in the interface). Less memory usage this way.


----------



## polypx (Aug 28, 2012)

Good point... I didn't think about $CONTROL_PAR_VALUE either. I've already got an array for my UIDs anyway, used in the init, so I could re-use that in the functions.


----------



## mk282 (Aug 28, 2012)

I'm doing a test example with 4 busses for ya, stay tuned...


And I just remembered, the arrays for mute/solo ARE needed, because you need to cover one case, when all mute and solo buttons are not active - then all busses are supposed to play. This is covered easily with search() on the respective arrays. So yeah, my bad on that one.


Anyways, an example incoming...


----------



## mk282 (Aug 28, 2012)

Here we go:


```
import "Parameters.ksp"

on init

    declare i
    declare j
    declare fx_state[4 * 8]
    declare mute[4]
    declare solo[4]
    declare state[4]

    declare ui_switch Mute1
    declare ui_switch Mute2
    declare ui_switch Mute3
    declare ui_switch Mute4
    declare ui_switch Solo1
    declare ui_switch Solo2
    declare ui_switch Solo3
    declare ui_switch Solo4
    declare ui_slider Bus1 (0,631000)
    declare ui_slider Bus2 (0,631000)
    declare ui_slider Bus3 (0,631000)
    declare ui_slider Bus4 (0,631000)

    declare ID[12]
    ID[ 0] := get_ui_id(Mute1)
    ID[ 1] := get_ui_id(Mute2)
    ID[ 2] := get_ui_id(Mute3)
    ID[ 3] := get_ui_id(Mute4)
    ID[ 4] := get_ui_id(Solo1)
    ID[ 5] := get_ui_id(Solo2)
    ID[ 6] := get_ui_id(Solo3)
    ID[ 7] := get_ui_id(Solo4)
    ID[ 8] := get_ui_id(Bus1)
    ID[ 9] := get_ui_id(Bus2)
    ID[10] := get_ui_id(Bus3)
    ID[11] := get_ui_id(Bus4)
    
    Bus1 := bus[0].slot[-1].volume
    Bus2 := bus[1].slot[-1].volume
    Bus3 := bus[2].slot[-1].volume
    Bus4 := bus[3].slot[-1].volume
    
    make_persistent(Mute1)
    make_persistent(Mute2)
    make_persistent(Mute3)
    make_persistent(Mute4)
    make_persistent(Solo1)
    make_persistent(Solo2)
    make_persistent(Solo3)
    make_persistent(Solo4)
    make_persistent(Bus1)
    make_persistent(Bus2)
    make_persistent(Bus3)
    make_persistent(Bus4)
    
    make_persistent(fx_state)
    make_persistent(mute)
    make_persistent(solo)
    make_persistent(state)
    
    move_control(Mute1,1,1)
    move_control(Mute2,2,1)
    move_control(Mute3,3,1)
    move_control(Mute4,4,1)
    move_control(Solo1,1,2)
    move_control(Solo2,2,2)
    move_control(Solo3,3,2)
    move_control(Solo4,4,2)
    move_control(Bus1,1,3)
    move_control(Bus2,2,3)
    move_control(Bus3,3,3)
    move_control(Bus4,4,3)

    message("")
end on

function MuteSolo
    { default value - bus plays }
    for i := 0 to 3
        state[i] := 1
    end for

    { processing soloes }
    if search(solo,1) # -1
        for i := 0 to 3
            state[i] := solo[i]
        end for
    end if

    { processing mutes }
    for i := 0 to 3
        if mute[i] = 1
            state[i] := 0
        end if
    end for
    
    { setting bus volumes }
    for i := 0 to 3
        bus[i].slot[-1].volume := ID[8 + i] -> value * state[i]
    end for
    
    { setting FX bypass }
    for i := 0 to 3
        for j := 0 to 7
            if state[i] = 0
                bus[i].slot[j].ifx_bypass := 1
            else
                bus[i].slot[j].ifx_bypass := fx_state[(i * 8) + j]
            end if
        end for
    end for
end function


macro MuteControl(#name#,#no#)
on ui_control (#name#)
    if ID[#no#] -> key_control = 1
        for i := 0 to 3
            ID[i] -> value := 0
            mute[i]:= 0
        end for
        #name# := 1
        mute[#no#] := 1
    else
        mute[#no#] := #name#
    end if
    call MuteSolo()
end on
end macro

macro SoloControl(#name#,#no#)
on ui_control (#name#)
    if ID[4 + #no#] -> key_control = 1
        for i := 0 to 3
            ID[4 + i] -> value := 0
            solo[i] := 0
        end for
        #name# := 1
        solo[#no#] := 1
    else
        solo[#no#] := #name#
    end if
    call MuteSolo()
end on
end macro


MuteControl(Mute1,0)
MuteControl(Mute2,1)
MuteControl(Mute3,2)
MuteControl(Mute4,3)
SoloControl(Solo1,0)
SoloControl(Solo2,1)
SoloControl(Solo3,2)
SoloControl(Solo4,3)


on ui_update
    { getting FX states - normally you would do this in UI callbacks for bus effect bypass buttons!
      NOTE - ui_update doesn't refresh when you click the bypass button in the FX slot!
      For testing purposes, after you set the bypasses to test the script, just click on any knob (non-scripted) to trigger this callback! }
    for i := 0 to 3
        for j := 0 to 7
            fx_state[(i * 8) + j] := bus[i].slot[j].ifx_bypass
        end for
    end for
end on
```


You will need my Parameters.ksp include for this! Here you go:

http://pastebin.com/raw.php?i=JWbwXCr4

Just save this raw test as Parameters.ksp, and put it in the same folder as your test KScript. Don't forget you need to use the new compiler for this enhanced syntax!


Cheers!


----------



## Raptor4 (Aug 28, 2012)

Hi Dan,
Today I did not have much time to polish the prototype. By the way my v1.0 has one problem with the counter (i.e the prototype gets the Bus levels on the first solo entry only). It is supposed to make Bus level changes on the soloed Buses so my v1.0 can not handle with that very well.
Right now I had some time to update the prototype to v2.0. I added UI Level knobs in that version so you can use them for extra Bus level control and see what's going on when tweak the solo buttons (It's a plain prototype so I have not make any UI design - i.e you can move the UI control where you want etc).
Have fun... o[]) 

R4


----------



## polypx (Aug 28, 2012)

Hey thanks guys... I'll have a look at these tomorrow, and see if they're much better than my own.

(They're both very likely much more intelligent than my version.)

cheers, Dan


EDIT - Thanks Mario for the ui_update section. I will be doing that in UI callbacks, as you suggest. But it helps clear things up.


----------



## bouziane faycel (Jan 15, 2017)

hey
plz how can i show the meters of bus instrument on the interface of kontakt. 
or wat's the fault or the problem on my script becaus all is ready just i cant see the fonction of meter like the meter of bus instrument

on init

make_perfview 
set_script_title("MASTER") 
set_ui_height_px(100) 
set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"wallpaper") 
set_control_par_str($INST_ICON_ID,$CONTROL_PAR_PICTURE,"logo") 

declare ui_slider $Volume1(0, 1000000) 
set_control_par_str(get_ui_id($Volume1), $CONTROL_PAR_PICTURE, "Knob 02") 
set_control_par(get_ui_id($Volume1),$CONTROL_PAR_MOUSE_BEHAVIOUR,-750)
move_control_px($Volume1, 100, 50) 
make_persistent($Volume1) 
make_persistent($Volume1)
message("")

$Volume1 := get_engine_par($ENGINE_PAR_VOLUME,0,0,-1)

declare ui_slider $Volume2(0, 1000000) 
set_control_par_str(get_ui_id($Volume2), $CONTROL_PAR_PICTURE, "Knob 02") 
set_control_par(get_ui_id($Volume2),$CONTROL_PAR_MOUSE_BEHAVIOUR,-750)
move_control_px($Volume2, 250, 50) 
make_persistent($Volume2) 
make_persistent($Volume2)
message("")

$Volume2 := get_engine_par($ENGINE_PAR_VOLUME,1,0,-1)

declare ui_level_meter $level1
move_control($level1, 1, 1)
attach_level_meter(get_ui_id($level1), -1, -1, 0, -1)

declare ui_level_meter $level2
move_control($level2, 1, 1)
attach_level_meter(get_ui_id($level2), 0, -1, 0, 0)
end on

on ui_control ($Volume1)
set_engine_par($ENGINE_PAR_VOLUME,$Volume1,0,0,-1)
set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$NI_BUS_OFFSET + 0,0,0,-1)
end on 
on ui_control ($Volume2)
set_engine_par($ENGINE_PAR_VOLUME,$Volume2,1,0,-1)
set_engine_par($ENGINE_PAR_OUTPUT_CHANNEL,$NI_BUS_OFFSET + 1,1,0,-1)
end on


----------



## EvilDragon (Jan 16, 2017)

You didn't attach the first meter correctly. Needs to be -1, -1, 0, 0 (group, slot, channel, bus). That's only showing the left channel of bus 1 then. The second meter is already working, shows the left channel of bus 1, so change the third number to 1 to show the right channel of bus 1. Use two meters per bus


----------



## geronimo (Jan 16, 2017)

Yes, I confirm because the level meters can only be attached to the Kontakt buses (or Instrument Master) and their outputs are stereo: I have also discovery this particularity in the actual KSP Reference Manual, page 34 .
A good example is there and should be able to help you, bouziane facel .


----------



## bouziane faycel (Jan 16, 2017)

thanks Evil for your halp. now i have left and right level for the groupe 1. now how kan i creat an other meter left rigth for the groupe 2. and groupe 3 ............., etch groupe has a level meter like a levels of bus. sur i creat an others level with new declaration but how can i related them with the buses to when i play the groupe 1 i see the level of groupe 1 only make signal . when i play the group 2 i see the an other level signal .................simply i creat. library and i want to creat meter for each chanel like the picture.


----------



## EvilDragon (Jan 16, 2017)

You need to change the last number in attach_level_meter for the bus you want to connect it to. Read the KSP Reference, it's all listed in there.


----------



## bouziane faycel (Jan 16, 2017)

thanks Evil you are so halpfull man.The operation was successful. thank you very much


----------



## bouziane faycel (Jan 17, 2017)

hey Evil Thanks again for your halp. now every thing is good. just i want to ask you if there is a way to chang the color of meter. i have just a way for the with and red color and the degree of theme. but if i want to change the color to green for exemple.
just these combintion what i found but is just for red and with color
$CONTROL_PAR_ON_COLOR / RED COLOR
RED/ 9aa0000h very dark
RED/ 9bb0000h
RED/ 9cc0000h
RED/ 9dd0000h
RED/ 9ee0000h
RED/ 9ff0000h very clear
------------------------------------
$CONTROL_PAR_BAR_COLOR / WITH COLOR


----------



## EvilDragon (Jan 17, 2017)

Sure you can change various colors, see KSP reference, all control parameters for level meter are listed in there.

You need to specify the color as a RGB mixture in hexadecimal format. So, 9RRGGBBh.


----------



## bouziane faycel (Jan 17, 2017)

thanks Evil is perfect


----------

