"change_tune is not Allowed in this callback type" but the script is fine!

hey, im trying to "program" an neighbor round robin script, i had some help in a different forum but its still not working, here is the script:
"on init
declare $NewNoteID
declare $RandResult
end on
on note
ignore_event($EVENT_ID)
$RandResult := random(1,3)
select ($RandResult)
case 1
play_note($EVENT_NOTE, $EVENT_VELOCITY,0,-1)
case 2
$NewNoteID := play_note($EVENT_NOTE + 1, $EVENT_VELOCITY,0,-1)
change_tune($NewNoteID, -100000,0)
case 3
$NewNoteID := play_note($EVENT_NOTE - 1, $EVENT_VELOCITY,0,-1)
change_tune($NewNoteID, 100000,0)
end select
end on"
Kontakt says "change_tune is not Allowed in this callback type"
Can someone help me??
Im using Kontakt 6.7.1
Comments
-
The error message you're seeing is due to the fact that
change_tune
is not allowed to be used within theon note
callback in KSP.Your logic seems to be to randomly play one of three notes when a key is pressed: the actual note, the note above, or the note below. For the latter two, you're attempting to compensate for the change in pitch with
change_tune
, but since this function isn't allowed in theon note
callback, you'll have to approach this problem differently.Instead of adjusting the pitch with
change_tune
, you can prepare your samples in advance so they match the desired pitches, allowing you to simply trigger the corresponding sample directly. If this is not feasible, you might consider using other methods such as adjusting the group tuning in real-time or employing other real-time pitch manipulation techniques compatible with your Kontakt version.However, if the core of your goal is simply to play neighboring notes in a round-robin fashion, you don't need to adjust tuning at all. You can use the
play_note
function alone to trigger the notes.Here's an example that should work:
on init declare $RandResult end on on note ignore_event($EVENT_ID) $RandResult := random(1,3) select ($RandResult) case 1 play_note($EVENT_NOTE, $EVENT_VELOCITY, 0, -1) case 2 play_note($EVENT_NOTE + 1, $EVENT_VELOCITY, 0, -1) case 3 play_note($EVENT_NOTE - 1, $EVENT_VELOCITY, 0, -1) end select end on
0 -
You must have missed something out when you copied your code. What you published is accepted perfectly well in my K5 Script Editor. (I haven't tested the script)
on init declare $NewNoteID declare $RandResult end on on note ignore_event($EVENT_ID) $RandResult := random(1,3) select ($RandResult) case 1 play_note($EVENT_NOTE, $EVENT_VELOCITY,0,-1) case 2 $NewNoteID := play_note($EVENT_NOTE + 1, $EVENT_VELOCITY,0,-1) change_tune($NewNoteID, -100000,0) case 3 $NewNoteID := play_note($EVENT_NOTE - 1, $EVENT_VELOCITY,0,-1) change_tune($NewNoteID, 100000,0) end select end on
(Sudden thought. This is an instrument script, not a multiscript, right?) Correct me if I'm wrong.
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 65 NI News
- 797 Tech Talks
- 4.1K Native Access
- 16.8K Komplete
- 2K Komplete General
- 4.4K Komplete Kontrol
- 5.8K Kontakt
- 1.6K Reaktor
- 386 Battery 4
- 854 Guitar Rig & FX
- 434 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.9K Maschine
- 7.4K Traktor
- 7.4K 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