# Velocity meter script warning message



## Claud9 (Aug 24, 2016)

Hello everybody,
I found on this forum this script for a velocity meter.
It works great but when you play some notes you got this script warning message :
"Invalid slider value (clipped to max value)! Line: 22, Program: 0"

Any suggestion to avoid the warning message?
Thanks in advance for any help!

on init
make_perfview 
set_ui_height(4) 
declare $cn :=0
declare ui_slider $knob (1,39)
set_control_par_str(get_ui_id($knob),$CONTROL_PAR_TEXT,"")
set_control_par_str(get_ui_id($knob),$CONTROL_PAR_PICTURE,"peak")
set_control_par(get_ui_id($knob), $CONTROL_PAR_MOUSE_BEHAVIOUR, -500)
set_control_par(get_ui_id($knob), $CONTROL_PAR_POS_X, 60)
set_control_par(get_ui_id($knob), $CONTROL_PAR_POS_Y, 36)
end on

on note 
while($cn < $EVENT_VELOCITY / 3) 
$knob := $cn
inc($cn)
end while
end on

on release
while($cn > 0)
$knob := $cn
wait(15000)
dec($cn)
end while
end on


----------



## d.healey (Aug 24, 2016)

I guess this

```
declare ui_slider $knob (1,39)
```
should be this

```
declare ui_slider $knob (0,127)
```

Also it's really not a good idea to call a slider $knob


----------



## Claud9 (Aug 24, 2016)

I have already tried to change those values as you wrote but the warning message is still there


----------



## d.healey (Aug 24, 2016)




----------



## Claud9 (Aug 24, 2016)

Thanks I have already tried this script. You don't have the warning message but this script have the problem that if you play two notes consecutively fast, the slider (meter) goes down to zero even if you're still playing the second note.


----------



## Levitanus (Aug 24, 2016)

why so conplicated? it's pretty simple task.
just

```
on init
declare $slider (0,127)
declare $counter
end on
on note
inc ($counter)
$slider := $EVENT_VELOCITY
end on
on release
dec ($counter)
if ($counter = 0)
$slider := 0
end if
end on
```


----------



## Levitanus (Aug 24, 2016)

and the better way to use ui_label with picture state. Label can be done with knobman


----------



## d.healey (Aug 25, 2016)

Claud9 said:


> Thanks I have already tried this script. You don't have the warning message but this script have the problem that if you play two notes consecutively fast, the slider (meter) goes down to zero even if you're still playing the second note.


I think if you reduce the wait time it will fix this issue


----------



## Claud9 (Aug 25, 2016)

Hi Levitanus thanks.
Yes this works great, but the slider (meter) goes down to zero very quickly.
Is not possible to add a string of code in order to have the slider (meter) to go to zero more smoothly (in order to simulate an analog Vu Meter?)
I think it should be added the "wait 15000" like in the other script?

thanks in advance for any help!




Levitanus said:


> why so conplicated? it's pretty simple task.
> just
> 
> ```
> ...


----------



## Levitanus (Aug 25, 2016)

15000 is 150 ms if i'm not wrong. 
here tested variant for one velocity meter per instrument.

```
on init
declare ui_slider $slider (0,127)
declare $counter
declare $i
end on
on note
inc ($counter)
$slider := $EVENT_VELOCITY
end on
on release
dec ($counter)
if ($counter = 0)
$i := $slider
while ($i # 0)
wait (2000)
if ($counter # 0)
exit
end if
$slider := $i
dec ($i)
end while
end if
end on
```


----------



## Claud9 (Aug 25, 2016)

Thanks a lot it works!!!



Levitanus said:


> 15000 is 150 ms if i'm not wrong.
> here tested variant for one velocity meter per instrument.
> 
> ```
> ...


----------



## EvilDragon (Aug 25, 2016)

Levitanus said:


> 15000 is 150 ms if i'm not wrong.



15 ms.


----------



## Levitanus (Aug 25, 2016)

@EvilDragon, I know that in manual that is microseconds, so 15000 /1000 is 15. But or i have bad time feeling, or 100000 is too long for 100ms as i know them from ping in games and from calculation as 1/10 of the second... Never my counts of kontakt microseconds were equal to the real state, so for me every time it's just taking the numbers once and once more again until i'm glad to see the result.


----------



## EvilDragon (Aug 25, 2016)

Wait is not 100% exact in Kontakt, but it should be roughly around the number it states.


----------

