Multiple Octave controls
I would like to control the octave of several groups separately, that is to say an octave control for groups 1, 2, 3 ($oct1) and a separate octave control for other groups 5, 6, 7 ($oct2 ) .
However, I can't separate these two controls into dedicated groups: I tried to differentiate the groups in 2 arrays ( %firstctrl, %secondctrl) but do not know how to use these arrays corresponding to the ID of the groups from on note part . 😟
For now, only the $oct1 slider only works fine, with this script :
on init set_ui_height_px(483) set_ui_width_px(1000) make_perfview
message("") declare $count declare $new_note declare %firstctrl[3] := (0, 1, 2) declare %secondctrl[3] := (5, 6, 7) declare %switch_red[6] declare ui_switch $triangl1 %switch_red[0] := get_ui_id($triangl1) move_control_px($triangl1, 365, 123) declare ui_switch $saw1 %switch_red[1] := get_ui_id($saw1) move_control_px($saw1, 428, 123) $saw1 := 0 declare ui_switch $pulse1 %switch_red[2] := get_ui_id($pulse1) move_control_px($pulse1, 490, 123) $pulse1 := 0 declare ui_switch $triangl2 %switch_red[3] := get_ui_id($triangl2) move_control_px($triangl2, 365, 254) declare ui_switch $saw2 %switch_red[4] := get_ui_id($saw2) move_control_px($saw2, 428, 254) $saw2 := 0 declare ui_switch $pulse2 %switch_red[5] := get_ui_id($pulse2) move_control_px($pulse2, 490, 254) $pulse2 := 0 $count := 0 while($count < 6) set_control_par_str(%switch_red[$count],$CONTROL_PAR_TEXT,"") set_control_par(%switch_red[$count],$CONTROL_PAR_HEIGHT, 50) inc($count) end while declare %octav_ui[3] declare ui_slider $oct1 (0, 4) %octav_ui[0] := get_ui_id($oct1) move_control_px($oct1, 134, 106) declare ui_slider $oct2 (0, 1000000) %octav_ui[1] := get_ui_id($oct2) move_control_px($oct2, 135, 234) $count := 0 while($count < 2) set_control_par(%octav_ui[$count],$CONTROL_PAR_MOUSE_BEHAVIOUR,-400) inc($count) end while end on on note disallow_group($ALL_GROUPS) allow_group(3) { Noise Group permanent } if ($triangl1 = 1) allow_group(0) end if if ($saw1 = 1) allow_group(1) end if if ($pulse1 = 1) allow_group(2) end if change_note($EVENT_ID, (12 * ($oct1 + 2)) + ($EVENT_NOTE mod 12)) if ($triangl2 = 1) allow_group(5) end if if ($saw2 = 1) allow_group(6) end if if ($pulse2 = 1) allow_group(7) end if end on
Can you help me so that these octave controls can act on different groups and not all ?
Comments
-
First off, your first octave slider range is spot on (0 to 4), but the second one's way off (0 to 1 million). Also, using change_note with
EVENT_ID
changes the note globally, not for different groups. Try using two custom events and handle them separately in the on note callback. You'll need an array with octave values (0, 12, 24…) to add to theEVENT_NOTE
. Here's a quick example:
on init
declare ui_slider $octave_1(0,3)
make_persistent($octave_1)
declare ui_slider $octave_2(0,3)
make_persistent($octave_2)
declare %octave_values[4] := (0, 12, 24, 36)
declare $event_1
declare $event_2
end on on note
ignore_event($EVENT_ID)
$event_1 := play_note($EVENT_NOTE+%octave_values[$octave_1],$EVENT_VELOCITY,0,-1)
$event_2 := play_note($EVENT_NOTE+%octave_values[$octave_2],$EVENT_VELOCITY,0,-1)
set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,0,-1)
set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,1,0)
set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,0,-1)
set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,1)
end on0 -
I understand a little but now I hear all the groups simultaneously and can no longer select them using their own switch. Wouldn't this be due to the following four lines ?
set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,0,-1) set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,1,0) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,1)
I am surprised by the number -1 at the end of two lines; would this be the sign of non-attribution ?
0 -
set_event_par_arr() You could look at it as an alternative way of allowing and disallowing groups, but you can handle that on an event basis too.
Just a minor edit: Accidentally, I allowed the same group for both events. It should look like this:
set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,0,-1) {disallows (-1) the groups} set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,0,0) {allows (0) the first group (0)} set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,1)
The example I shared was just a basic version to show what you wanted to achieve. You'll obviously need to tweak the code to fit your main script and needs. In the code you shared, you use if clauses to allow specific groups based on switch states. Maybe try doing the same thing using the example I posted :)
0 -
Thanks: I'm almost there.
0 -
The octave selection by the two sliders ($oct1, $oct2) work fine according to my wishes.
But when selecting the last three waveforms ($triangl2, $saw2, $pulse2), $saw1 also goes up even though I did not select it.I think I'm almost done but it's stuck on the group selection aspect.
Every time I call $triangl2, $saw2, $pulse2 there is saw1(group1) which also appears.I admit to being at my limits of logic but I think we're close to the goal.
on note disallow_group($ALL_GROUPS) allow_group(3) { Permanent Noise File } ignore_event($EVENT_ID) $event_1 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,0,-1) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,5,-1) if ($triangl1 = 1) allow_group(0) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,0,1) end if if ($saw1 = 1) allow_group(1) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,1) end if if ($pulse1 = 1) allow_group(2) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,2,1) end if if ($triangl2 = 1) allow_group(5) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,5,1) end if if ($saw2 = 1) allow_group(6) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,6,1) end if if ($pulse2 = 1) allow_group(7) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,0,-1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,7,1) end if end on
Here is the order of the groups in the instrument .
0 -
I'd suggest checking the example I shared to understand the structure of your code.
For
EVENT_PAR_ALLOW_GROUP
, you don't need thedisallow_group
orallow_group
lines. Every time you allow a group for an event, first disallow the group withset_event_par_arr($event_1, $EVENT_PAR_ALLOW_GROUP, 0, -1)
, then allow the desired group.Also, note that the
event_1
event is triggered in your code but lacksEVENT_PAR_ALLOW_GROUP
code. Review the example carefully, understand its workings, and then apply the if statements as you did in your code :)0 -
Many thanks you for your patience; I have therefore arrived at what I wanted and will continue for a third oscillator bringing other waveforms.
I have badly exposed my project and don't need to deactivate each time by starting with the order of disallow the group because pressing a switch must not deselect those in service.
on note disallow_group($ALL_GROUPS) allow_group(3) { Permanent Noise File } ignore_event($EVENT_ID) $event_1 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,0,-1) $event_1 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,1,-1) $event_1 := play_note($EVENT_NOTE+%octave_values[$oct1],$EVENT_VELOCITY,2,-1) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,5,-1) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,6,-1) $event_2 := play_note($EVENT_NOTE+%octave_values[$oct2],$EVENT_VELOCITY,7,-1) if ($triangl1 = 1) set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,1,0) end if if ($saw1 = 1) set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,1,1) end if if ($pulse1 = 1) set_event_par_arr($event_1,$EVENT_PAR_ALLOW_GROUP,1,2) end if if ($triangl2 = 1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,5) end if if ($saw2 = 1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,6) end if if ($pulse2 = 1) set_event_par_arr($event_2,$EVENT_PAR_ALLOW_GROUP,1,7) end if end on
I will continue on the 3rd oscillator by bringing it the Low Frequency option so that it behaves like an LFO. It is not won given the structure of Kontakt but it can be interesting.
EDIT: for the code $EVENT_PAR_ALLOW_GROUP, I had previously reversed the last two digits (value and group index) hence my incomprehension . 🙄
0 -
By the way, you're probably using the
play_note
line wrong. You've duplicated both events three times (it means thatevent_1
andevent_2
will be played 3 times each), and the sample offset slot has different numbers (meaning that you push the starting point of your sample by 1 microsecond - which doesn't really make sense). Look up play_note in the KSP manual.As I mentioned before, you need to disallow the groups first and then allow the group you want. Don’t use
disallow_group
andallow_group
lines since you're using the EVENT_PAR_ALLOW_GROUP line on an event level.0 -
Yes, thanks .I removed the extra $event1 and $event2 .
I thought I was acting on different groups when it was just the microsecond value; it's complicated .
In the end, these mistakes are good lessons !
1
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 785 Tech Talks
- 4.1K Native Access
- 16.5K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 379 Battery 4
- 845 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators