Creating an instrument and KSP errors
Hello everyone :) !!
I'm new to scripting in general so probably I'm overlooking something very simple here.
I keep getting errors like "newline expected" or "'else' or 'end if'" expected (even when I closed all 'if' blocks.
Here's my current script:
on init
declare %low_samples[4]
declare %mid_samples[4]
declare %high_samples[4]
%low_samples[0] := 0 { Group index for Low_C }
%low_samples[1] := 1 { Group index for Low_C# }
%low_samples[2] := 2 { Group index for Low_D }
%low_samples[3] := 3 { Group index for Low_D# }
%mid_samples[0] := 4 { Group index for Mid_C }
%mid_samples[1] := 5 { Group index for Mid_C# }
%mid_samples[2] := 6 { Group index for Mid_D }
%mid_samples[3] := 7 { Group index for Mid_D# }
%high_samples[0] := 8 { Group index for High_C }
%high_samples[1] := 9 { Group index for High_C# }
%high_samples[2] := 10 { Group index for High_D }
%high_samples[3] := 11 { Group index for High_D# }
declare $root_note := 0
message("Initialization complete")
end on
on note
message("Note received: " & $EVENT_NOTE)
if ($EVENT_NOTE >= 12 and $EVENT_NOTE <= 23)
$root_note := $EVENT_NOTE - 12
ignore_event($EVENT_ID)
message("Root note set to: " & $root_note)
end if
if ($EVENT_NOTE >= 36 and $EVENT_NOTE <= 47)
ignore_event($EVENT_ID)
message("Playing low sample group: " & %low_samples[$root_note])
change_group(%low_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
end if
if ($EVENT_NOTE >= 48 and $EVENT_NOTE <= 59)
ignore_event($EVENT_ID)
message("Playing mid sample group: " & %mid_samples[$root_note])
change_group(%mid_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
end if
if ($EVENT_NOTE >= 60 and $EVENT_NOTE <= 71)
ignore_event($EVENT_ID)
message("Playing high sample group: " & %high_samples[$root_note])
change_group(%high_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
end if
if ($EVENT_NOTE >= 24 and $EVENT_NOTE <= 35)
ignore_event($EVENT_ID)
message("Playing all layers for note: " & $EVENT_NOTE)
change_group(%low_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
change_group(%mid_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
change_group(%high_samples[$root_note])
play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1)
end if
end on
For some reason I have the 'else' or 'end if' error in line 38.
For context, I'm trying to build a multilayered instrument. There's 3 layers (low, mid and high).
I want the C0 octave to set the key of the samples played, the C1 octave to trigger all 3 layers simultaneously, the C2 octave to trigger only the low layer, the C3 octave to trigger the mid layer, the C4 octave to trigger the high layer.
So I could change the tunning on the fly with the C0 octave, play 'pre-designed' sounds with the C1 octave (becuase C1 triggers the samples in C2,C3,C4, C#1 triggers the samples in C#2,C#3,C#4.. etc..) and also trigger any note, together or alone, from C2-B4 to design new sounds - always in the tunning set by the C0 key.
So I can play D0 - setting the key to D, then play D#1 - to trigger a pre-design sound or just play any combination of the other 3 octaves to create new sounds composed of any number of layers.
Currently only testing with 4 samples per layer (C, C#, D, D#) but eventually it should be 12 different samples in 12 different keys for low and the same for Mid and the same for High.
Right now I have 12 (because 4 samples x 3 layers) groups, so each sample is in it's own group (all labeled accordingly: 'Low C', 'Low C#'…. until 'High D#'
Sorry if it's confusing, it's a bit complicated to explain.
I'm in kontakt 6 btw - full version
Categories
- All Categories
- 19 Welcome
- 1.3K Hangout
- 59 NI News
- 706 Tech Talks
- 3.6K Native Access
- 15.2K Komplete
- 1.8K Komplete General
- 4K Komplete Kontrol
- 5.2K Kontakt
- 1.5K Reaktor
- 354 Battery 4
- 783 Guitar Rig & FX
- 403 Massive X & Synths
- 1.1K Other Software & Hardware
- 5.2K Maschine
- 6.7K Traktor
- 6.7K 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