Invalid $KSP_TIMER?
When I use this code (in a multiscript):
on midi_in
if ($MIDI_COMMAND=$MIDI_COMMAND_NOTE_ON)
reset_ksp_timer
$count := 1
while ($count<12)
wait(10000)
add_text_line($back,$count*10 & " " & ($KSP_TIMER/1000))
inc($count)
end while
end if
end on
I get:
10 0
20 39
30 39
40 39
50 39
60 79
70 79
80 79
90 79
100 119
110 119
Please explain the inconsistency between the wait function and $KSP_TIMER.
Comments
-
It’d be great if you could clarify what you’re aiming for. Based on your code, the output makes sense; it updates the
$back
label every time the counter increments (up to 12). The label shows the counter value (1 to 11) multiplied by 10, plus the KSP timer divided by 1000. When the counter hits 12, the label stops at 110 and 119 (counter x10 | timer value).Not sure what your while loop is supposed to achieve, but if you want the label to show 0 or 1 instead, you’d need to reset the KSP timer on a MIDI note on event and display that value without involving the counter or the loop in general. Unless I'm missing something :) Cheers!
0 -
Thanks for responding.
I'm sorry; I made the code far more complicated than was necessary. From the KSP manual:
wait(<wait-time>): Pauses the callback for the specified time in microseconds.
$KSP_TIMER: This variable returns the time period in microseconds.
So, for the code:
reset_ksp_timer
wait(1000)
add_text_line($back,$KSP_TIMER)
wait(1000)
add_text_line($back,$KSP_TIMER)
wait(1000)
add_text_line($back,$KSP_TIMER)
I should see:
1000
2000
3000
but what I get is inconsistent values (on each pass) like:
11
21
24
It makes no difference whether it's in a script or a multiscript.0
Categories
- All Categories
- 19 Welcome
- 1.3K Hangout
- 59 NI News
- 710 Tech Talks
- 3.7K Native Access
- 15.2K Komplete
- 1.8K Komplete General
- 4K Komplete Kontrol
- 5.3K Kontakt
- 1.5K Reaktor
- 356 Battery 4
- 787 Guitar Rig & FX
- 403 Massive X & Synths
- 1.1K Other Software & Hardware
- 5.3K 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