Jerry,
I took the liberty of modifying the script by @promidi by adding an input field in ticks and removed the line that was preventing the script from setting the new duration. I tested it, but please use it at your own risk.
-- Ron
;;Randomize duration
;;This script will randomize MIDI note duration based on a user
;;provided range in ticks from 1 to 240 ticks. Checks are
;;provided to prevent zero durations.
;;
;;
(do
(int offset)
(int range 30) ;; Change default input value here
(getInt range "Select +/- range (ticks): " 1 240)
(int new_duration)
(int pos_range range)
(int neg_range (*= range -1))
(forEachEvent
(if (== Event.Kind NOTE)
(do
(= offset (random neg_range pos_range))
(= new_duration Note.Dur)
(+= new_duration offset)
(if (>= new_duration 0) ;; Make sure calculated duration is not zero
(= Note.Dur new_duration)
);end if
);end do
);end if
);end for
);end do