helper:midi-val   scheme


Defined in:  https://github.com/lambdamusic/extempore-extensions/blob/main/init/init_play.xtm

Implementation

; HELPER:MIDI-VAL
;;;;;;;
;; ensure midi values are within range and integers
;;
;; >>> Be cautious however about the range of MIDI notes that goes from 0 to 127. By adding for instance 4 octaves (+48) to a note of value 96, the total is 144, which is outside the range and may be truncated to 16 (144 - 128) so that a very low note will result.
;; Taken from https://www.cs.cmu.edu/~music/cmsip/readings/MIDI%20tutorial%20for%20programmers.html
;;
;;
(define helper:midi-val
  (lambda (g)
    (let ((p (real->integer g)))
      (if (> g *pitch-vel-upper-limit* ) 
          (begin (print-warn "MIDI value above" *pitch-vel-upper-limit*) *pitch-vel-upper-limit*)
          (if (< g *pitch-vel-lower-limit* )
              (begin (print-warn "MIDI value below" *pitch-vel-lower-limit*)*pitch-vel-lower-limit*)
              g)))))


Back to Index