id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
752
math.lisp
cac-t-u-s_om-sharp/src/packages/score/math/math.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (load (merge-pathnames "cercle/n-cercle" *load-pathname*)) (load (merge-pathnames "cercle/n-cercle-editor" *load-pathname*)) (omNG-make-package "Math" :container-pack *om-package-tree* :doc "Mathematical tools / Set theory / ..." :classes '(n-cercle) :functions '(chord2c c2chord c2chord-seq chord-seq2c c2rhythm rhythm2c nc-rotate nc-complement nc-inverse) :subpackages nil)
1,165
Common Lisp
.lisp
25
44.32
77
0.544894
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
e1c6a9ada17638f6fd4636ac18b0433327747ce12d5e07db397baba477093023
752
[ -1 ]
753
n-cercle-editor.lisp
cac-t-u-s_om-sharp/src/packages/score/math/n-cercle-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ (in-package :om) (defclass CercleEditor (OMEditor) ((front :accessor front :initform 0) (bg-mode :accessor bg-mode :initform :draw-all))) (defmethod object-has-editor ((self n-cercle)) t) (defmethod get-editor-class ((self n-cercle)) 'CercleEditor) (defclass CercleView (omeditorview) ()) ;;; UPDATE AFTER EVAL (defmethod update-to-editor ((self cercleeditor) (from OMBox)) (let ((obj (object-value self))) (when (>= (front self) (length (puntos obj))) (setf (front self) 0)) (om-invalidate-view (main-view self)))) ;;; BUILD (defmethod make-editor-window-contents ((self CercleEditor)) (let* ((view (om-make-view 'cercleview :editor self :size (omp 200 200) :bg-color (om-def-color :white))) (di-h 18) (controls (om-make-layout 'om-row-layout :size (omp nil di-h) :align :center :subviews (list (om-make-di 'om-simple-text :text "N=" :font (om-def-font :gui) :size (omp 20 di-h)) (om-make-view 'om-view ;;; needed to get the scroll-feature of numbox to work :size (omp nil di-h) :subviews (list (om-make-graphic-object 'numbox :value (n (object-value self)) :bg-color (om-def-color :white) :position (omp 0 0) :db-click t :decimals 0 :size (om-make-point 40 18) :font (om-def-font :large) :min-val 1 :max-val 120 :after-fun #'(lambda (item) (setf (n (object-value self)) (get-value item)) (report-modifications self) (om-invalidate-view view) )) )) nil (om-make-di 'om-simple-text :text "background" :font (om-def-font :gui) :size (omp 70 di-h)) (om-make-di 'om-popup-list :items (list :draw-all :light :hide) :size (omp 80 24) :font (om-def-font :gui) :di-action #'(lambda (item) (setf (bg-mode self) (om-get-selected-item item)) (om-invalidate-view view)) ))))) (values (om-make-layout 'om-column-layout :ratios '(100 1) :subviews (list view controls)) view) )) ;;; DRAW (defmethod om-draw-contents ((self CercleView)) (let* ((ed (editor self)) (obj (object-value ed)) (step (/ (* pi 2) (n obj))) (cx (round (w self) 2)) (cy (round (h self) 2)) (r (round (min (w self) (h self)) 2.5))) (om-with-line-size 2 (om-draw-circle cx cy r)) (draw-point-list-in-circle (loop for i from 0 to (- (n obj) 1) collect (* step i)) cx cy r :thickness 2) (let ((colorlist (loop for i from 0 to (1- (length (puntos obj))) collect (1+ (mod i 16))))) ;;; bacground puntos (unless (equal (bg-mode ed) :hide) (loop for point-list in (append (subseq (puntos obj) 0 (front ed)) (subseq (puntos obj) (1+ (front ed)))) for c in (append (subseq colorlist 0 (front ed)) (subseq colorlist (1+ (front ed)))) do (draw-point-list-in-circle (om* point-list step) cx cy r :thickness (if (equal (bg-mode ed) :light) 1 1) :color (if (equal (bg-mode ed) :light) (om-make-color-alpha (get-midi-channel-color c) .3) (get-midi-channel-color c)) :lines t) )) ;;; front puntos (draw-point-list-in-circle (om* (nth (front ed) (puntos obj)) step) cx cy r :thickness 2 :color (get-midi-channel-color (nth (front ed) colorlist)) :lines t) (om-draw-string 10 (- (h self) 20) (if (> (length (puntos obj)) 1) (format nil "~D/~D: ~A" (1+ (front ed)) (length (puntos obj)) (nth (front ed) (puntos obj))) (format nil "~A" (nth (front ed) (puntos obj)))) :font (om-def-font :large-b) :color (om-def-color :dark-gray)) ))) ;;; TRANSFORMATIONS (defmethod rotate-front-list ((self cercleeditor) n) (let ((obj (object-value self))) (setf (nth (front self) (puntos obj)) (sort (loop for p in (nth (front self) (puntos obj)) collect (mod (+ p n) (n obj))) '<)) (report-modifications self) )) (defmethod inverse-front-list ((self cercleeditor)) (let ((obj (object-value self))) (setf (nth (front self) (puntos obj)) (sort (x->dx (reverse (dx->x 0 (nth (front self) (puntos obj))))) '<)) (report-modifications self))) (defmethod complement-front-list ((self cercleeditor)) (let ((obj (object-value self))) (setf (nth (front self) (puntos obj)) (loop for item from 0 to (- (n obj) 1) when (not (find item (nth (front self) (puntos obj)) :test #'(lambda (a b) (= (mod a (n obj)) (mod b (n obj)))))) collect item)) (report-modifications self))) (defmethod add-remove-point-at ((self cercleview) clic-pos) ;;; copied from the drawing method... (let* ((ed (editor self)) (obj (object-value ed)) (step (/ (* pi 2) (n obj))) (points-angles (loop for i from 0 to (- (n obj) 1) collect (* step i))) (cx (round (w self) 2)) (cy (round (h self) 2)) (r (round (min (w self) (h self)) 2.5)) (points-xy (loop for theta in points-angles collect (multiple-value-bind (x y) (pol->car r (+ theta (/ pi -2))) (list (+ cx x) (+ cy y))))) (delta 5) (position-in-list (position-if #'(lambda (p) (and (<= (abs (- (om-point-x clic-pos) (car p))) delta) (<= (abs (- (om-point-y clic-pos) (cadr p))) delta))) points-xy))) (when position-in-list (if (find position-in-list (nth (front ed) (puntos obj))) (setf (nth (front ed) (puntos obj)) (remove position-in-list (nth (front ed) (puntos obj)))) (setf (nth (front ed) (puntos obj)) (sort (cons position-in-list (nth (front ed) (puntos obj))) '<))) (report-modifications ed) (om-invalidate-view self) ) )) ;;; USER ACTION CALLBACKS (defmethod editor-key-action ((self cercleeditor) key) (case key (:om-key-tab (setf (front self) (mod (1+ (front self)) (length (puntos (object-value self))))) (om-invalidate-view (main-view self))) (#\r (rotate-front-list self 1) (om-invalidate-view (main-view self))) (#\i (inverse-front-list self) (om-invalidate-view (main-view self))) (#\c (complement-front-list self) (om-invalidate-view (main-view self))) (otherwise (om-beep)) )) (defmethod om-view-click-handler ((self cercleview) position) (when (om-add-key-down) (add-remove-point-at self position)))
9,693
Common Lisp
.lisp
192
31.265625
119
0.424764
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
28d188193f380a4e43cffd5be666a7a9880f4c0459ecae9bff2e88758151a6d9
753
[ -1 ]
754
draw-score-spacing.lisp
cac-t-u-s_om-sharp/src/packages/score/draw/draw-score-spacing.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;============ ;;; TIME-MAP ;;;============ #| (position-if #'(lambda (e) (and (<= (car e) 4200) (not (caddr e)))) '((0 10) (0 110) (4000 210) (8000 310))) |# ;;; time-map is a simple BPF-like list with (time pos) pairs ;; before is the space needed before a timed-symbol (e.g. for let accidentals etc.) ;; after is the space needed after (depends also on the duration symbol) ;; extra is some independent, extra time needed (typically for measures bars and time signature) (defstruct space-point (onset) (before) (after) (extra)) ;;;===================================== ;;; Rebuilding time-map ;;;===================================== ;;; at creating the display-cache (e.g. when the object is reevaluated) (defmethod get-cache-display-for-draw ((object voice) (box OMBoxEditCall)) (when (equal object (get-box-value box)) ;;; ... don't do if the object of the box is for instance a poly ;;; otherwise the wrong time-map will be applied to the poly (set-edit-param box :time-map (build-time-map object))) (call-next-method) t) (defmethod get-cache-display-for-draw ((object poly) (box OMBoxEditCall)) (set-edit-param box :time-map (build-time-map object)) (call-next-method) t) (defmethod is-rhythmic ((obj t)) nil) (defmethod is-rhythmic ((obj voice)) t) (defmethod is-rhythmic ((obj poly)) t) ;;; Main function to build time-map (defmethod build-time-map (object) ;; (print (list "build time-map for" object)) (when (is-rhythmic object) ;; (om-print-format "Rebuild time-map for ~A" (list object)) (let* ((time-space (sort (build-object-time-space object nil) ;;; no tempo: this object must be either VOICE or POLY high-level #'< :key #'space-point-onset)) (merged-list ())) ;;; build-object-time-space returns a list of (onset (space_nedded_before space_needed_after)) ;;; objects with same onsets must be grouped, and space maximized ;;; negative space (e.g. from measures) will affect the space of previous item (loop for item in time-space do (if (and (car merged-list) (= (space-point-onset item) (space-point-onset (car merged-list)))) ;;; already something there (setf (space-point-before (car merged-list)) (max (space-point-before (car merged-list)) (space-point-before item)) (space-point-after (car merged-list)) (max (space-point-after (car merged-list)) (space-point-after item)) (space-point-extra (car merged-list)) (max (space-point-extra (car merged-list)) (space-point-extra item)) ;;; onlty one item at a time adds extra space, otherwise it increases, ;;; e.g. when several voices have bars at the same time ; (+ (space-point-extra (car merged-list)) (space-point-extra item)) ) ;;; new point in the time-map (push item merged-list))) (when merged-list (setf merged-list (reverse merged-list)) (cons (list (space-point-onset (car merged-list)) (+ (space-point-before (car merged-list)) (space-point-extra (car merged-list)))) (loop with curr-x = (+ (space-point-before (car merged-list)) (space-point-extra (car merged-list))) for rest on merged-list while (cdr rest) do (setf curr-x (+ curr-x (space-point-after (car rest)) (space-point-before (cadr rest)) (space-point-extra (cadr rest)))) collect (list (space-point-onset (cadr rest)) curr-x)) )) ))) (defmethod build-object-time-space ((self t) tempo) (declare (ignore tempo)) nil) (defmethod build-object-time-space ((self voice) tempo) (declare (ignore tempo)) ;;; voice itself holds the tempo (cons ;;; for the beginning of the score... (make-space-point :onset -1000 :before 0 :after 1 :extra 0) (loop with prev-signature = nil for m in (inside self) for position from 1 append (build-measure-time-space m (tempo self) position (not (equal (car (tree m)) prev-signature))) do (setf prev-signature (car (tree m)))))) (defmethod build-object-time-space ((self poly) tempo) (declare (ignore tempo)) ;;; voice holds the tempo (loop for voice in (inside self) append (build-object-time-space voice nil))) ;;; measure requires special arguments (defmethod build-measure-time-space ((self measure) tempo position with-signature) (cons (make-space-point :onset (beat-to-time (symbolic-date self) tempo) :before 0 :after 0 :extra (+ (if (= position 1) 0 6) ;; no bar for first measure (if with-signature 4 0) ;; space if signature )) (loop for sub in (inside self) append (build-object-time-space sub tempo)) )) ;;; ;;; data for specific objects: ;;; this is for a group (defmethod build-object-time-space ((self group) tempo) (let ((space (object-space-in-units self))) (cons (make-space-point :onset (beat-to-time (symbolic-date self) tempo) :before (first space) :after (second space) :extra (or (third space) 0)) (loop for sub in (inside self) append (build-object-time-space sub tempo)) ) )) ;;; TERMINAL OBJECTS IN TIME-SPACE (no deeper inside) ;;; Units required (before after extra) (defmethod object-space-in-units ((self t)) '(0 0 0)) (defmethod object-space-in-units ((self chord)) (let ((notes (notes self))) (list ;;; space in units before: (+ 2 (* .5 (length (notes self))) ;;; number of notes with accident (* .8 (count-if #'(lambda (n) (pitch-to-acc (midic n))) notes))) ;;; space in units after: (+ (* .5 (length notes)) (* 10 (symbolic-dur self)))))) (defmethod object-space-in-units ((self continuation-chord)) (object-space-in-units (previous-chord self))) (defmethod object-space-in-units ((self r-rest)) (list 2 (+ 1 (* 10 (symbolic-dur self))))) (defmethod build-object-time-space ((self chord) tempo) (let ((space (object-space-in-units self)) (time (beat-to-time (symbolic-date self) tempo))) (list (make-space-point :onset time :before (first space) :after (second space) :extra (or (third space) 0))) )) (defmethod build-object-time-space ((self continuation-chord) tempo) (let ((space (object-space-in-units self))) (list (make-space-point :onset (beat-to-time (symbolic-date self) tempo) :before (first space) :after (second space) :extra (or (third space) 0))) )) (defmethod build-object-time-space ((self r-rest) tempo) (let ((space (object-space-in-units self))) (list (make-space-point :onset (beat-to-time (symbolic-date self) tempo) :before (first space) :after (second space) :extra (or (third space) 0))))) ;;; Time-function: ;;; returns the position ins score units of a give time (defmethod score-time-to-units (time-map time) (unless time-map (setf time-map '((0 0)))) (if time-map (if (listp time) ;;; a convention when we're asking for the position of measure elements (let* ((point-pos (or (position (car time) time-map :test #'= :key #'car) (progn (om-print-dbg "Error in score construction: measure doesn't start on a beat-time (t=~A)" (list (car time))) (or (position (car time) time-map :test #'<= :key #'car) (1- (length time-map)))))) (point (nth point-pos time-map)) (prev-point (nth (max 0 (1- point-pos)) time-map))) (/ (+ (cadr prev-point) (cadr point)) 2.0)) (let* ((prev-point-pos (or (position time time-map :test #'>= :key #'car :from-end t) 0)) (prev-point (nth prev-point-pos time-map)) (next-point (nth (1+ prev-point-pos) time-map))) (cond (;;; the point was in the list (= time (car prev-point)) (cadr prev-point)) (;;; interpolate between prev and next next-point (+ (cadr prev-point) (* (- time (car prev-point)) (/ (- (cadr next-point) (cadr prev-point)) (- (car next-point) (car prev-point))))) ) ((= prev-point-pos 0) ;; only 1 point (cadr prev-point) ) (t ;;; we are after the last: extrapolate from last (let ((prev-prev-point (nth (1- prev-point-pos) time-map))) (+ (cadr prev-point) (* (- time (car prev-point)) (/ (- (cadr prev-point) (cadr prev-prev-point)) (- (car prev-point) (car prev-prev-point))))) ))) )) (progn (om-print "Error in score display: no time-map!") 0)) ) (defmethod score-units-to-time (time-map pos) (if time-map (let* ((prev-point-pos (or (position pos time-map :test #'>= :key #'cadr :from-end t) 0)) (prev-point (nth prev-point-pos time-map)) (next-point (nth (1+ prev-point-pos) time-map))) (cond (;;; the point was in the list (= pos (car prev-point)) (car prev-point)) (;;; interpolate between prev and next next-point (+ (car prev-point) (* (- pos (cadr prev-point)) (/ (- (car next-point) (car prev-point)) (- (cadr next-point) (cadr prev-point))))) ) ((= prev-point-pos 0) ;; only 1 point (car prev-point) ) (t ;;; we are after the last: extrapolate from last (let ((prev-prev-point (nth (1- prev-point-pos) time-map))) (+ (car prev-point) (* (- pos (cadr prev-point)) (/ (- (car prev-point) (car prev-prev-point)) (- (cadr prev-point) (cadr prev-prev-point))))) ))) ) (progn (om-print "Error time-mapping: no time-map!") 0)) )
11,550
Common Lisp
.lisp
244
36.979508
139
0.544888
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
b4b5357cffab454c3ed97499b2d51ba4fab43f805b745656b54550ce16ff5859
754
[ -1 ]
755
draw-score-rhythm.lisp
cac-t-u-s_om-sharp/src/packages/score/draw/draw-score-rhythm.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;; RHYTHMIC ASPECTS OF SCORE DRAWING (IN VOICE/POLY EDITORS) (in-package :om) ;;;=============================================== ;;; MEASURE ;;;=============================================== (defmethod draw-measure ((object measure) tempo param-obj view &key staff font-size position with-signature selection (stretch 1) (x-shift 0) (y-shift 0) time-function) (let* ((unit (font-size-to-unit font-size)) ; (extra-units-for-bar (if (= position 1) 0 4)) ; (extra-units-for-sig (if with-signature 6 0)) (extra-units-for-bar (if (numberp stretch) 0 12)) (extra-units-for-sig (if with-signature 0 0)) (extra-pixels (if (typep view 'sequencer-track-view) 0 ; in sequencer track we draw everything proportional :-s (* (+ extra-units-for-bar extra-units-for-sig) ;;; the stretch factor: (if (numberp stretch) ;;; rhythmic with stretch (* unit stretch) ;;; proportional: (if (= position 1) (/ unit 1.5) 1))))) (bar-x-pix (- (+ (* x-shift unit) (funcall (or time-function #'(lambda (time) (time-to-pixel view time))) (list ;; as a concvention we pass measure times as lists to ;; the time-function, so we can take adequate decisions to position bars etc. (beat-to-time (symbolic-date object) tempo))) ) extra-pixels)) (sig-x-pix (+ bar-x-pix (* (if (= position 1) -4 2) (if (numberp stretch) (* unit stretch) 1))))) (om-with-fg-color (when (find object selection) *score-selection-color*) (unless (= position 1) (draw-measure-bar bar-x-pix y-shift font-size staff) (om-draw-string bar-x-pix (* (+ 2 y-shift) unit) (number-to-string position) :font (om-def-font :normal :size (/ font-size 3)))) (when with-signature (draw-time-signature (car (tree object)) sig-x-pix y-shift font-size staff)) ) ;;; contents (let ((measure-beat-unit (/ (fdenominator (car (tree object))) (find-beat-symbol (fdenominator (car (tree object))))))) (loop for element in (inside object) for i from 0 do (draw-rhytmic-element element tempo param-obj view :level 1 :position i :x-shift x-shift :y-shift y-shift :font-size font-size :beat-unit measure-beat-unit :selection selection :time-function time-function )) ) (when (typep view 'score-view) (let ((staff-y-minmax (staff-y-range staff y-shift unit))) (setf (b-box object) (make-b-box :x1 (min bar-x-pix sig-x-pix) :x2 (if with-signature (+ sig-x-pix (* 4 unit)) (+ bar-x-pix (* 4 unit))) :y1 (car staff-y-minmax) :y2 (cadr staff-y-minmax) )) )) )) ;;;======================== ;;; BEAMING / GROUPS ;;;======================== (defstruct beam-info (line) (direction) (beams)) ;;; select up or down according to the mean-picth in this group vs. center of the current staff ;;; accordingly, the beam-point is <beam-size> above max pitch, or below min-pitch ;;; won't work for sub-groups... (defmethod find-group-beam-line ((self group) staff beat-unit) (let* ((medium (staff-medium-pitch staff)) (chords (get-all-chords self)) ;;; can be nil if only rests !! (best-directions (loop for c in chords when (get-notes c) collect (stem-direction c staff))) (pitches (loop for c in chords append (mapcar #'midic (get-notes c)))) (default (staff-medium-pitch (car (last (staff-split staff))))) (p-max (or (list-max pitches) default)) ;;; default = middle ? (p-min (or (list-min pitches) default)) ;;; default = middle ? ;; (mean (* (+ p-max p-min) .5)) ;(/ (apply '+ pitches) (length pitches)) (max-beams (or (list-max (mapcar #'(lambda (c) (get-number-of-beams (* (symbolic-dur c) beat-unit))) chords)) 0)) (stem-length (+ *stem-height* (* (max 0 (- max-beams 2)) *beamthickness* 1.5))) ;; if more than 1 beams, add 2xbeam-h by beam ) (cond ((and (> (abs (- p-min medium)) (abs (- p-max medium))) (< (- p-min medium) -1200)) ;;; p-min is really low ;;; up (make-beam-info :line (+ (pitch-to-line p-max) stem-length) :direction :up)) ((> (- p-max medium) 1200) ;;; p-max is really high ;;; down (make-beam-info :line (- (pitch-to-line p-min) stem-length) :direction :down)) (t (if (>= (count :up best-directions) (count :down best-directions)) (make-beam-info :line (+ (pitch-to-line p-max) stem-length) :direction :up) (make-beam-info :line (- (pitch-to-line p-min) stem-length) :direction :down) )) ) )) (defun find-group-symbol (val) (let* ((den (denominator val)) (bef (bin-value-below den))) (list (note-strict-beams (/ 1 bef)) (denominator (/ bef den))))) (defun note-strict-beams (val) (cond ((or (= val 1/4) (= val 1/2) (>= val 1)) 0) ((= val 1/8) 1) ((= val 1/16) 2) ((= val 1/32) 3) ((= val 1/64) 4) ((= val 1/128) 5) ((= val 1/256) 6) ((= val 1/512) 7) ((is-binaire? val) (round (- (log (denominator val) 2) 2))) (t (find-group-symbol val)))) ;;; gives number of beams for a given division ;;; might return a list if the denominator is not a power of two ;;; => entry in the process of determining the beaming for a given chord. ;;; this code is directly adapted from OM6 score editors (defun get-beaming (val) (let* ((num (numerator val)) (den (denominator val)) (bef (bin-value-below num))) (cond ((= bef num) (note-strict-beams (/ num den))) ((= (* bef 1.5) num) (note-strict-beams (/ bef den))) ((= (* bef 1.75) num) (note-strict-beams (/ bef den))) (t 0)) )) (defun get-number-of-beams (val) (let ((beams (get-beaming val))) (if (listp beams) (car beams) beams))) (defmethod beam-num ((self score-element) dur) (get-number-of-beams dur)) ;;; gets the minimum number of beams in a group (defmethod beam-num ((self group) dur) (let ((nd (or (numdenom self) (list 1 1)))) (loop for element in (inside self) minimize (beam-num element (* (/ (car nd) (cadr nd)) (/ (symbolic-dur element) (symbolic-dur self)) dur))) )) ;;; Get the depth of num/dem line in a group (defmethod calcule-chiff-level ((self t)) 0) (defmethod calcule-chiff-level ((self group)) (+ (if (numdenom self) 1 0) (loop for item in (inside self) maximize (calcule-chiff-level item)))) ;;; just for debug (defmethod draw-group-rect ((object group) view tempo level) (om-draw-rect (time-to-pixel view (beat-to-time (symbolic-date object) tempo)) 0 (- (time-to-pixel view (beat-to-time (+ (symbolic-date object) (symbolic-dur object)) tempo)) (time-to-pixel view (beat-to-time (symbolic-date object) tempo))) (- (h view) (* level 10)) :color (om-random-color .5) :fill t)) (defun get-mean-pitch (group) (let ((pitches (mapcar #'midic (loop for elt in (get-all-chords group) append (get-notes elt))))) (and pitches (/ (apply #'+ pitches) (length pitches))) )) ;;; beam-info : beam-pos (line) , beam-direction (:up/:down) , beams-already-drawn (list of indices) (defmethod draw-rhytmic-element ((object group) tempo param-obj view &key font-size (x-shift 0) (y-shift 0) (level 1) position beam-info beat-unit rest-line selection time-function) (declare (ignore position)) ;(print (list "==========")) ;(print (list "GROUP" (tree object) (numdenom object) (symbolic-dur object))) (let* ((staff (get-edit-param param-obj :staff)) (unit (font-size-to-unit font-size)) (x-shift-pix (* x-shift unit)) (group-ratio (if (numdenom object) (fullratio (numdenom object)) 1)) (beam-pos-and-dir (if beam-info ;; the rest actual list of beams will be set later (make-beam-info :line (beam-info-line beam-info) :direction (beam-info-direction beam-info)) (find-group-beam-line object staff (* beat-unit group-ratio)))) (beams-from-parent (and beam-info (beam-info-beams beam-info))) (chords (get-all-chords object)) (pix-beg (+ x-shift-pix ;; (time-to-pixel view (beat-to-time (symbolic-date (car chords)) tempo)) (funcall (or time-function #'(lambda (time) (time-to-pixel view time))) (beat-to-time (symbolic-date (car chords)) tempo)) )) (pix-end (+ x-shift-pix ;; (time-to-pixel view (beat-to-time (symbolic-date (car (last chords))) tempo)) (funcall (or time-function #'(lambda (time) (time-to-pixel view time))) (beat-to-time (symbolic-date (car (last chords))) tempo)) )) (n-beams (beam-num object (* (symbolic-dur object) beat-unit))) (group-beams (arithm-ser 1 n-beams 1))) (om-with-fg-color (if (find object selection) *score-selection-color* nil) ;(print (list group-beams beams-from-parent)) ;(draw-group-rect object view tempo level) (when (and group-beams (list-subtypep (inside object) 'group)) ;;; here we allow subgroups to get grouped individiually ;;; (is that always correct?) (setf group-beams (list (car group-beams)))) ;;; local variables for the loop (let ((beams-drawn-in-sub-group nil)) ;; the first group catching a beam information transfers to all descendants (loop with sub-group-beams = 0 for element in (inside object) for i from 0 do ;;; here we hanlde "virtual sub-group" displayed as tied beams ;;; when a sucession of atomic elements in a same group have the same beaming (unless (typep element 'group) (let* ((graphic-dur (* (symbolic-dur element) group-ratio beat-unit)) (n-beams-in-current (beam-num element graphic-dur)) (prev (previous-in-list (inside object) element nil)) (next (next-in-list (inside object) element nil)) (n-beams-in-previous (and prev (beam-num prev (* (symbolic-dur prev) group-ratio beat-unit)))) (n-beams-in-next (and next (beam-num next (* (symbolic-dur next) group-ratio beat-unit))))) (when (> n-beams-in-current sub-group-beams) ;;; first of a new "sub-group" (same number of sub-beams) ;;; will draw additional single-beams on the right if any (setq sub-group-beams n-beams-in-current) ;;; if there's more beams on the right than on the left, individual beam will be towards right ;;; => to do so, position in group is artificially reset to 0 (when (and prev next (not (typep next 'group)) ;; also if this one is the last of its group (> n-beams-in-next n-beams-in-previous)) (setq i 0)) ) (when (> n-beams-in-current n-beams) ;;; more beams than the current "real" container group (if (= i 0) ;;; this is the 1st element (setq beams-drawn-in-sub-group (arithm-ser 1 (min n-beams-in-current (or n-beams-in-next 0)) 1)) (progn (setq beams-drawn-in-sub-group (arithm-ser 1 (min n-beams-in-current (or n-beams-in-previous 0)) 1)) ;;; draw beams between i and (i-1) and update the beaming count for sub-elements (draw-beams (+ x-shift-pix ;;(time-to-pixel view (beat-to-time (symbolic-date prev) tempo)) (funcall (or time-function #'(lambda (time) (time-to-pixel view time))) (beat-to-time (symbolic-date prev) tempo)) ) (+ x-shift-pix ;; (time-to-pixel view (beat-to-time (symbolic-date element) tempo)) (funcall (or time-function #'(lambda (time) (time-to-pixel view time))) (beat-to-time (symbolic-date element) tempo)) ) (beam-info-line beam-pos-and-dir) ;; the beam init line (beam-info-direction beam-pos-and-dir) ;; the beam direction beams-drawn-in-sub-group ;; the beam numbers y-shift staff font-size) ))) )) (draw-rhytmic-element element tempo param-obj view :x-shift x-shift :y-shift y-shift :font-size font-size :level (1+ level) :beam-info (when beam-pos-and-dir ;;; send the beams already drawn in 3rd position ; passing '(0) at min will force the stem height of sub-chords ; even if there is no beams (setf (beam-info-beams beam-pos-and-dir) (append (or group-beams '(0)) beams-drawn-in-sub-group)) beam-pos-and-dir) :position i :beat-unit (* beat-unit group-ratio) :rest-line (or rest-line (let ((mean-pitch (get-mean-pitch object))) (when mean-pitch (pitch-to-line mean-pitch)))) ;;; the higher-level group will determine the y-position for all rests :selection selection :time-function time-function ) )) ;;; sub-groups or chords wont have to draw these beams (draw-beams pix-beg pix-end (beam-info-line beam-pos-and-dir) ;; the beam init line (beam-info-direction beam-pos-and-dir) ;; the beam direction (set-difference group-beams beams-from-parent) ;; the beam numbers y-shift staff font-size) ;;; subdivision line and numbers (when (numdenom object) (let* ((numdenom-level (calcule-chiff-level object))) ;;; chiflevel tells us how much above or below the beam this should be placed ;; (print (list object chiflevel (numdenom object))) (draw-group-div (numdenom object) numdenom-level pix-beg pix-end (beam-info-line beam-pos-and-dir) ;; the beam init line (beam-info-direction beam-pos-and-dir) ;; the beam direction y-shift staff font-size) )) (when (typep view 'score-view) (loop for sub in (inside object) minimize (b-box-x1 (b-box sub)) into x1 maximize (b-box-x2 (b-box sub)) into x2 minimize (b-box-y1 (b-box sub)) into y1 maximize (b-box-y2 (b-box sub)) into y2 finally (setf (b-box object) (make-b-box :x1 x1 :x2 x2 :y1 y1 :y2 y2))) ; (draw-b-box object) ) ))) #| ;;; passed through groups as "durtot" in OM6: ;;; starting at (* symb-beat-val factor) in measure (real-beat-val (/ 1 (fdenominator (first tree)))) (symb-beat-val (/ 1 (find-beat-symbol (fdenominator (first tree))))) (dur-obj-noire (/ (extent item) (qvalue item))) (factor (/ (* 1/4 dur-obj-noire) real-beat-val)) (unite (/ durtot denom)) ;;; => ;;; NO GROUP RATIO: (let* ((dur-obj (/ (/ (extent item) (qvalue item)) (/ (extent self) (qvalue self))))) (* dur-obj durtot)) ;;; GROUP RATIO: (let* ((operation (/ (/ (extent item) (qvalue item)) (/ (extent self) (qvalue self)))) (dur-obj (numerator operation))) (setf dur-obj (* dur-obj (/ num (denominator operation)))) (* dur-obj unite))) ;;; passed through groups as "ryth" ;;; starting at (list real-beat-val (nth i (cadr (tree self)))) in measure ;;; => (list (/ (car (second ryth)) (first ryth)) (nth i (cadr (second ryth)))) |# ; (note-head-and-points 3/8) ;;;=================== ;;; CHORD ;;;=================== ;;; beam-info : beam-pos (line) , beam-direction (:up/:down) , beams-already-drawn (list of indices) (defmethod draw-rhytmic-element ((object chord) tempo param-obj view &key font-size (x-shift 0) (y-shift 0) (level 1) (position 0) beam-info beat-unit rest-line selection time-function) (declare (ignore rest-line)) (let* ((begin (beat-to-time (symbolic-date object) tempo)) (s-dur (symbolic-dur object)) (staff (get-edit-param param-obj :staff)) (scale (get-edit-param param-obj :scale)) (chan (get-edit-param param-obj :channel-display)) (vel (get-edit-param param-obj :velocity-display)) (port (get-edit-param param-obj :port-display)) (dur (get-edit-param param-obj :duration-display)) (offsets (get-edit-param param-obj :offsets)) ;; (parent-nd (nth 3 beam-info)) ;; (parent-ratio (if parent-nd (/ (car parent-nd) (cadr parent-nd)) 1)) (graphic-dur (* s-dur beat-unit)) ;;; from OM6.. (beams-num (get-number-of-beams graphic-dur)) (beams-from-parent (when beam-info (beam-info-beams beam-info))) (beams-to-draw (set-difference (arithm-ser 1 beams-num 1) beams-from-parent)) ;; (propre-group (if (listp beams) (cadr beams))) (beam-start-line (if beams-from-parent (beam-info-line beam-info) (if (and beam-info (equal :up (beam-info-direction beam-info))) (+ (pitch-to-line (list-max (lmidic object))) *stem-height* (* beams-num .25)) (- (pitch-to-line (list-min (lmidic object))) *stem-height* (* beams-num .25))))) (create-bboxes (typep view 'score-view))) ;;; (print (list "chord" s-dur "unit:" beat-unit "=>" graphic-dur)) ;; in fact propre-group (= when a standalone chord has a small group indication) will never happen (in OM) (let ((bbox? (draw-chord object begin x-shift y-shift 0 0 (w view) (h view) font-size :head (multiple-value-list (note-head-and-points graphic-dur)) :stem (or (= level 1) beam-start-line) ;; (car beam-info) is the beam-line :beams (list beams-to-draw position) :staff staff :scale scale :draw-chans chan :draw-vels vel :draw-ports port :draw-durs dur :offsets offsets :selection (if (find object selection) T selection) :time-function (or time-function #'(lambda (time) (time-to-pixel view time))) :build-b-boxes create-bboxes ))) (when create-bboxes (setf (b-box object) bbox?)) bbox?))) ;;;=================== ;;; CONTINUATION-CHORD ;;;=================== (defmethod draw-rhytmic-element ((object continuation-chord) tempo param-obj view &key font-size (x-shift 0) (y-shift 0) (level 1) (position 0) beam-info beat-unit rest-line selection time-function) (declare (ignore rest-line)) (let* ((begin (beat-to-time (symbolic-date object) tempo)) (staff (get-edit-param param-obj :staff)) (scale (get-edit-param param-obj :scale)) (s-dur (symbolic-dur object)) ;(parent-nd (nth 3 beam-info)) ;(parent-ratio (if parent-nd (/ (car parent-nd) (cadr parent-nd)) 1)) (graphic-dur (* s-dur beat-unit)) ;;; from OM6.. (beams-num (get-number-of-beams graphic-dur)) (beams-from-parent (and beam-info (beam-info-beams beam-info))) (beams-to-draw (set-difference (arithm-ser 1 beams-num 1) beams-from-parent)) ;;(propre-group (if (listp beams) (cadr beams))) (beam-start-line (and beam-info (beam-info-line beam-info))) ;(if (equal :up (beam-info-direction beam-info)) ; (+ (pitch-to-line (list-max (lmidic (get-real-chord object)))) *stem-height* (* beams-num .25)) ; (- (pitch-to-line (list-min (lmidic (get-real-chord object)))) *stem-height* (* beams-num .25))))) (create-bboxes (typep view 'score-view)) ) (let ((bbox? (draw-chord (get-real-chord object) begin x-shift y-shift 0 0 (w view) (h view) font-size :head (multiple-value-list (note-head-and-points graphic-dur)) :stem (or (= level 1) beam-start-line) :beams (list beams-to-draw position) :staff staff :scale scale :selection (if (find object selection) T selection) :tied-to-ms (beat-to-time (symbolic-date (previous-chord object)) tempo) :time-function (or time-function #'(lambda (time) (time-to-pixel view time))) ; no b-box for notes inside a continuation chord: ; they actually just refer to the main chord's notes :build-b-boxes nil ))) (when create-bboxes (setf (b-box object) bbox?)) bbox?) )) ;;;========= ;;; REST ;;;========= (defmethod draw-rhytmic-element ((object r-rest) tempo param-obj view &key font-size (x-shift 0) (y-shift 0) (level 1) position beam-info beat-unit rest-line selection time-function) (declare (ignore level)) (let* ((begin (beat-to-time (symbolic-date object) tempo)) (graphic-dur (* (symbolic-dur object) beat-unit)) (beams-num (get-number-of-beams graphic-dur)) (beams-from-parent (and beam-info (beam-info-beams beam-info))) (beams-to-draw (set-difference (arithm-ser 1 beams-num 1) beams-from-parent)) (beam-start-line (when beam-info (beam-info-line beam-info)))) ;; (print (list beams-from-parent beams-to-draw beam-start-line)) (let* ((create-bboxes (typep view 'score-view)) (bbox? (draw-rest object begin x-shift y-shift 0 0 (w view) (h view) font-size :head (multiple-value-list (rest-head-and-points graphic-dur)) :line rest-line ;; can be NIL for display at default y-pos :stem (when beams-from-parent beam-start-line) :beams (list beams-to-draw position) :staff (get-edit-param param-obj :staff) :selection (if (find object selection) T selection) :time-function (or time-function #'(lambda (time) (time-to-pixel view time))) :build-b-boxes create-bboxes ))) (when create-bboxes (setf (b-box object) bbox?)) )))
26,641
Common Lisp
.lisp
491
38.525458
134
0.50169
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
313ec2a344153dbee0deff9e227b01d75f46f8bf89d9b4e9649d5d8def581ac4
755
[ -1 ]
756
draw-score-basic.lisp
cac-t-u-s_om-sharp/src/packages/score/draw/draw-score-basic.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;=============== ;;; SMuFL fonts ;;;=============== (defvar *score-font* "Bravura") (defvar *score-font-metadata-table* nil) (defvar *score-font-bbox-table* nil) (defvar *stemThickness* 0.12) (defvar *beamThickness* 0.5) (defvar *staffLineThickness* 0.13) (defvar *legerLineThickness* 0.16) (defvar *legerLineExtension* 0.4) (defvar *thinBarlineThickness* 0.16) (defvar *noteheadBlack_StemUpSE* '(1.18 0.168)) (defvar *noteheadBlack_StemDownNW* '(0.0 -0.168)) (defvar *noteheadBlack_bBoxNE* '(1.18 0.5)) (defvar *noteheadBlack_bBoxSW* '(0.0 -0.5)) (defparameter *stem-height* 3.25) (defun get-smufl-metadata (key &optional table) (if (consp key) (let ((subtable (gethash (car key) (or table *score-font-metadata-table*)))) (get-smufl-metadata (cdr key) subtable)) table)) ;;; return (x1 y1 x2 y2) (defun get-font-bbox (smufl-name) (let ((ne (get-smufl-metadata (list smufl-name "bBoxNE") *score-font-bbox-table*)) (sw (get-smufl-metadata (list smufl-name "bBoxSW") *score-font-bbox-table*))) (list (car sw) (- (cadr ne)) (car ne) (- (cadr sw))))) (defun get-font-width (smufl-name) (let ((bbox (get-font-bbox smufl-name))) (- (nth 2 bbox) (nth 0 bbox)))) (defun get-font-heigth (smufl-name) (let ((bbox (get-font-bbox smufl-name))) (- (nth 3 bbox) (nth 1 bbox)))) ;(get-font-bbox "noteheadBlack") (defun load-font-defaults () (let* ((metadatafile (merge-pathnames "fonts/bravura_metadata.json" (om-resources-folder)))) (setq *score-font-metadata-table* (yason:parse metadatafile)) (setq *score-font-bbox-table* (get-smufl-metadata '("glyphBBoxes"))) ;;; cache some of the most used values (setq *stemThickness* (get-smufl-metadata '("engravingDefaults" "stemThickness"))) (setq *beamThickness* (get-smufl-metadata '("engravingDefaults" "beamThickness"))) (setq *staffLineThickness* (get-smufl-metadata '("engravingDefaults" "staffLineThickness"))) (setq *legerLineThickness* (get-smufl-metadata '("engravingDefaults" "legerLineThickness"))) (setq *legerLineExtension* (get-smufl-metadata '("engravingDefaults" "legerLineExtension"))) (setq *thinBarlineThickness* (get-smufl-metadata '("engravingDefaults" "thinBarlineThickness"))) (setq *noteheadBlack_StemUpSE* (get-smufl-metadata '("glyphsWithAnchors" "noteheadBlack" "stemUpSE"))) (setq *noteheadBlack_StemDownNW* (get-smufl-metadata '("glyphsWithAnchors" "noteheadBlack" "stemDownNW"))) (setq *noteheadBlack_bBoxNE* (get-smufl-metadata '("glyphBBoxes" "noteheadBlack" "bBoxNE"))) (setq *noteheadBlack_bBoxSW* (get-smufl-metadata '("glyphBBoxes" "noteheadBlack" "bBoxSW"))) t)) ; (load-font-defaults) (add-om-init-fun 'load-font-defaults) ;;;=============== ;;; SMUFL CHARS ;;;=============== ;;; all symbols below have a string identifyier in SMuFL which alows to retrieve some metadata ;;; the functions below return two values: char-code and SMuFL string ID ;;; - actually the char code is also retrievable from this ID in the standard's glyphnames.json file (defun accident-char (acc) (case acc (:flat (values (code-char #xE260) "accidentalFlat")) (:natural (values (code-char #xE261) "accidentalNatural")) (:sharp (values (code-char #xE262) "accidentalSharp")) (:db-sharp (values (code-char #xE263) "accidentalDoubleSharp")) (:1/4-flat (values (code-char #xE280) "accidentalQuarterToneFlatStein")) (:3/4-flat (values (code-char #xE281) "accidentalThreeQuarterTonesFlatZimmermann")) (:1/4-sharp (values (code-char #xE282) "accidentalQuarterToneSharpStein")) (:3/4-sharp (values (code-char #xE283) "accidentalThreeQuarterTonesSharpStein")) (:1/8-sharp (values (code-char #xE27A) "accidentalArrowUp")) (:3/8-sharp (values (code-char #xE299) "accidentalHalfSharpArrowUp")) (:5/8-sharp (values (code-char #xE274) "accidentalThreeQuarterTonesSharpArrowUp")) (:7/8-sharp (values (code-char #xE29B) "accidentalOneAndAHalfSharpsArrowUp")) (otherwise nil))) (defun staff-key-char (staff) (case staff (:g (values (code-char #xE050) "gClef")) (:g+ (values (code-char #xE050) "gClef")) (:g- (values (code-char #xE052) "gClef8vb")) (:f (values (code-char #xE062) "fClef")) (:f- (values (code-char #xE062) "fClef")) (:line (values (code-char #xE069) "unpitchedPercussionClef1")) (otherwise nil) )) (defun dynamics-char (symbol) (case symbol (:ppp (values (code-char #xE52A) "dynamicPPP")) (:pp (values (code-char #xE52B) "dynamicPP")) (:p (values (code-char #xE520) "dynamicPiano")) (:mp (values (code-char #xE52C) "dynamicMP")) (:mf(values (code-char #xE52D) "dynamicMF")) (:f (values (code-char #xE522) "dynamicForte")) (:ff (values (code-char #xE52F) "dynamicFF")) (:fff (values (code-char #xE530) "dynamicFFF")) (otherwise nil))) (defparameter *smufl-note-heads* '(("noteheadHalf" #xE0A3) ("noteheadBlack" #xE0A4) ("noteheadXBlack" #xE0A9) ("noteheadCircleX" #xE0B3) ("noteheadSquareWhite" #xE0B8) ("noteheadSquareWhite" #xE0B9) ("noteheadTriangleUpWhite" #xE0BD) ("noteheadTriangleUpBlack" #xE0BE) ("noteheadDiamondBlackWide" #xE0DC) ("noteheadDiamondWhiteWide" #xE0DE))) (defmethod* notehead-char-codes (char) :icon :score :initvals '(#xE0A3) :doc "Some SMuFL note heads char-codes. See more in https://www.smufl.org/version/latest/range/noteheads/ " :menuins (list (list 0 *smufl-note-heads*)) char) (defun char-code-to-head-char (code) (values (code-char code) (car (find code *smufl-note-heads* :key #'cadr)) )) (defun note-head-char (symbol) (case symbol (:head-1/4 (values (code-char #xE0A4) "noteheadBlack")) (:head-1/2 (values (code-char #xE0A3) "noteheadHalf")) (:head-1 (values (code-char #xE0A2) "noteheadWhole")) (:head-2 (values (code-char #xE0A1) "noteheadDoubleWholeSquare")) (:breve (values (code-char #xE0A0) "noteheadDoubleWhole")) ;; this is equivalent to :head-2 (:head-4 (values (code-char #xE937) "mensuralNoteheadLongaWhite")) (:head-8 (values (code-char #xE933) "mensuralNoteheadMaximaWhite")) (otherwise (cond ((consp symbol) ;;; super-longa (note-head-char :head-8)) ((numberp symbol) (char-code-to-head-char symbol)) (t (note-head-char :head-1/4)))) )) (defun flag-char (orientation n) (if (equal orientation :up) (case n ;(1 (values (code-char #xE240) "flag8thUp")) (1 (values (code-char #xE250) "flagInternalUp")) (2 (values (code-char #xE242) "flag16thUp")) (3 (values (code-char #xE244) "flag32ndUp")) (4 (values (code-char #xE246) "flag64thUp")) (5 (values (code-char #xE248) "flag128thUp")) (6 (values (code-char #xE24A) "flag256thUp"))) (case n ;(1 (values (code-char #xE241) "flag8thUp")) (1 (values (code-char #xE251) "flagInternalDown")) (2 (values (code-char #xE243) "flag16thUp")) (3 (values (code-char #xE245) "flag32ndUp")) (4 (values (code-char #xE247) "flag64thUp")) (5 (values (code-char #xE249) "flag128thUp")) (6 (values (code-char #xE24B) "flag256thUp"))) )) (defun rest-char (symbol) (case symbol (:rest-4 (values (code-char #xE4E1) "restLonga")) (:rest-2 (values (code-char #xE4E2) "restDoubleWhole")) (:rest-1 (values (code-char #xE4E3) "restWhole")) (:rest-1/2 (values (code-char #xE4E4) "restHalf")) (:rest-1/4 (values (code-char #xE4E5) "restQuarter")) (:rest-1/8 (values (code-char #xE4E6) "rest8th")) (:rest-1/16 (values (code-char #xE4E7) "rest16th")) (:rest-1/32 (values (code-char #xE4E8) "rest32nd")) (:rest-1/64 (values (code-char #xE4E9) "rest64th")) (:rest-1/128 (values (code-char #xE4EA) "rest128th")) (otherwise (if (consp symbol) ;;; super-longa (values (code-char #xE4EE) "restHBar") (rest-char :head-1/128))) )) (defun timesig-number-char (char) (case char (#\0 (values (code-char #xE080) "timeSig0")) (#\1 (values (code-char #xE081) "timeSig1")) (#\2 (values (code-char #xE082) "timeSig2")) (#\3 (values (code-char #xE083) "timeSig3")) (#\4 (values (code-char #xE084) "timeSig4")) (#\5 (values (code-char #xE085) "timeSig5")) (#\6 (values (code-char #xE086) "timeSig6")) (#\7 (values (code-char #xE087) "timeSig7")) (#\8 (values (code-char #xE088) "timeSig8")) (#\9 (values (code-char #xE089) "timeSig9")) )) (defun tempo-note (fig) (case fig (1/8 (values (code-char #xE1D7) "noteEighthUp")) ;; <= verify this (otherwise (values (code-char #xE1D5) "noteQuarterUp")))) ; alternate: ; (values (code-char #xE1FC) "textAugmentationDot") (defun dot-char () (values (code-char #xE1E7) "augmentationDot")) ;;;=============== ;;; STAVES ;;;=============== (defparameter *score-staff-options* '(:g :f :g- :gf :gg :ff :ggf :gff :ggff :line :empty)) (defparameter *score-fontsize-options* #+darwin '(8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96) #-darwin '(6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90)) (defun staff-split (staff-symbol) (case staff-symbol (:g '(:g)) (:f '(:f)) (:g- '(:g-)) (:f- '(:f-)) (:g+ '(:g+)) (:gg '(:g :g+)) (:ff '(:f- :f)) (:gf '(:f :g)) (:ggf '(:f :g :g+)) (:gff '(:f- :f :g)) (:ggff '(:f- :f :g :g+)) (:line '(:line)) (:empty '(:empty)) )) ;;; we consider line 0 = E3 (defun staff-lines (staff) (case staff (:g+ '(8 9 10 11 12)) (:g '(1 2 3 4 5)) (:g- '(-2.5 -1.5 -0.5 0.5 1.5)) (:f '(-5 -4 -3 -2 -1)) (:f- '(-12 -11 -10 -9 -8)) (:line '(0)) (:empty '(0)) )) (defun staff-lower-line (staff) (car (staff-lines (car (staff-split staff))))) (defun staff-higher-line (staff) (last-elem (staff-lines (last-elem (staff-split staff))))) (defun staff-line-range (staff) (let ((split-staffs (staff-split staff))) (- (last-elem (staff-lines (last-elem split-staffs))) (car (staff-lines (car split-staffs)))))) (defun head-leger-lines (head-line staff-lines) (when (> (length staff-lines) 1) ;;; don't do it for empty or "line" staffs (cond ((>= head-line (1+ (car (last staff-lines)))) (loop for i from (1+ (car (last staff-lines))) to head-line collect i)) ((<= head-line (1- (car staff-lines))) (loop for i = (1- (car staff-lines)) then (- i 1) while (>= i head-line) collect i)) ((and (<= head-line 7) (>= head-line 6)) '(6 7)) ((and (= head-line 0) (<= (- (car (last staff-lines)) (car staff-lines)) 5)) nil) ((= head-line 0) '(0)) ((and (<= head-line -6) (>= head-line -7)) '(-6 -7)) (t nil)))) (defun staff-key-line (staff) (case staff (:g 2) (:g+ 9) (:g- -1.5) (:f -2) (:f- -9) (:line 0) (:empty 0) )) (defun staff-line-pitch-range (staff) (case staff (:g '(6400 7700)) (:g+ '(8800 10100)) (:g- '(5200 6500)) (:f '(4300 5700)) (:f- '(1900 3300)) (:line '(6000 6000)) (:empty '(6000 6000)) )) (defun staff-medium-pitch (staff-symb) (let ((lines (staff-split staff-symb))) (round (+ (cadr (staff-line-pitch-range (car (last lines)))) (car (staff-line-pitch-range (car lines)))) 2))) ;;; global display shift-down of the line-0(in number of lines) (defun calculate-staff-line-shift (staff) (+ 4 ;;; arbitrary top margin in units (line-h) ;;; + shift of the max number of lines above line-0 (C3) (last-elem (staff-lines (last-elem (staff-split staff)))))) ;;;================== ;;; SCALES ;;;================== (defun pitch-to-line (pitch &optional scale) (multiple-value-bind (octave interval) (floor pitch 1200) (let* ((scale (append (or scale *default-scale*) `((1200 3.5 nil))) ;; in cas ewe are actually closer to the next octave ) (scale-step (closest-match interval scale :key #'car ))) (values ;;; line 0 is at 5th octave ;;; 1 octave is 3.5 lines (+ (* 3.5 (- octave 5)) (nth 1 scale-step) ) ;;; returns the accidental as second value (nth 2 scale-step)) ))) (defun pitch-to-acc (pitch &optional scale) (multiple-value-bind (octave interval) (round pitch 1200) (declare (ignore octave)) (let* ((scale (append (or scale *default-scale*) `((1200 3.5 nil))) ;; in cas ewe are actually closer to the next octave ) (scale-step (closest-match interval scale :key #'car ))) (nth 2 scale-step)))) ;;; (lines are also the score "unit") (defun line-to-pitch (line &optional scale) (let ((sc (or scale *default-scale*))) (multiple-value-bind (oct deg) (floor line 3.5) (let ((scale-step (car (find deg sc :key 'cadr :test '=)))) ; the pitch corresponding to the scale (unless scale-step ;;; not exacltly on the line (accidents and micro-intervals) (let* ((low-pos (position (* (floor deg .5) .5) sc :key 'cadr :test '=)) (high-pos (or (position (* (ceiling deg .5) .5) sc :key 'cadr :test '=) (length sc))) (delta (* 2 (mod deg .5))) ;; factor 0.0-1.0 between low and high (pos (mod (+ low-pos (round (* delta (- high-pos low-pos)))) (length sc)))) (when (and (= pos 0) (= high-pos (length sc))) (setq oct (1+ oct))) (setq scale-step (car (nth pos sc))))) (+ 6000 ;; the pitch of line 0, by convention (* 1200 oct) ;;; the number-of-3.5 line above or under line 0 scale-step )) ))) ;; (* .5 (floor 3.37 .5)) ;; (find 0.3 *default-scale* :key 'cadr :test '<=) ;; (line-to-pitch 1.874) ;;;================== ;;; SYMBOLS ;;;================== (defun velocity-char (val) (dynamics-char (nth (position val '(20 40 55 60 85 100 115 127) :test '<=) '(:ppp :pp :p :mp :mf :f :ff :fff)))) ;;;================== ;;; DRAW ;;;================== (defun font-size-to-unit (size) (* size .25)) (defun unit-to-font-size (u) (* u 4)) ;;; by convention, unit = staff interline in PIXEL (defun line-to-ypos (line shift unit) (* (- shift line) unit)) (defparameter *score-selection-color* (om-def-color :dark-red)) ;;;======================= ;;; STAFF ;;;======================= (defun staff-y-range (staff y-shift unit) (let ((y-full-shift (+ y-shift (calculate-staff-line-shift staff))) (staff-elems (staff-split staff))) (list (line-to-ypos (last-elem (staff-lines (last-elem staff-elems))) y-full-shift unit) (line-to-ypos (car (staff-lines (car staff-elems))) y-full-shift unit)))) ;;; x and y are in pixels ;;; y-u is additional shift in score-units ;;; w and h are pixel-size of the frame ;;; margins in units (= proportional to fontsize) (defun draw-staff (x y y-u w h fontsize staff &key (margin-l 0) (margin-r 0) (keys t)) (declare (ignore h)) (unless (equal staff :empty) (let* ((staff-elems (staff-split staff)) (unit (font-size-to-unit fontsize)) (shift (+ y-u (calculate-staff-line-shift staff))) (thinBarlineThickness (* *thinBarLineThickness* unit)) (staffLineThickness (* *staffLineThickness* unit)) (x1 (+ x (* (or margin-l 0) unit))) (x2 (+ x (- w (* (or margin-r 0) unit))))) (flet ((adjust-line-ypos (pos) (+ y (if (> unit 5) (round pos) pos)))) (om-with-font (om-make-font *score-font* #+darwin fontsize #-darwin (* 3/4 fontsize)) (loop for staff-symb in staff-elems do ;;; lines (loop for line in (staff-lines staff-symb) do (om-draw-line x1 (adjust-line-ypos (line-to-ypos line shift unit)) x2 (adjust-line-ypos (line-to-ypos line shift unit)) :line staffLineThickness )) ;;; clef (when keys (om-draw-char (+ x1 (* unit 1)) (adjust-line-ypos (line-to-ypos (staff-key-line staff-symb) shift unit)) (staff-key-char staff-symb)) ))) ;;; vertical lines at beginning and the end (when margin-l (om-draw-line x1 (adjust-line-ypos (line-to-ypos (car (staff-lines (car staff-elems))) shift unit)) x1 (adjust-line-ypos (line-to-ypos (last-elem (staff-lines (last-elem staff-elems))) shift unit)) :line thinBarlineThickness)) (when margin-r (om-draw-line x2 (adjust-line-ypos (line-to-ypos (car (staff-lines (car staff-elems))) shift unit)) x2 (adjust-line-ypos (line-to-ypos (last-elem (staff-lines (last-elem staff-elems))) shift unit)) :line thinBarlineThickness) ))) )) ;;;======================= ;;; MESURE BARS ;;;======================= (defun draw-measure-bar (x-pix y-units fontsize staff) (let* ((unit (font-size-to-unit fontsize)) (staff-y-minmax (staff-y-range staff y-units unit)) (thinBarlineThickness (* *thinBarLineThickness* unit))) (om-draw-line x-pix (- (car staff-y-minmax) 1) x-pix (+ (cadr staff-y-minmax) 1) :line thinBarlineThickness) )) ;; we must use lwx::bmp-string here because string by default only supports base-char charcaters ;; another possibility is to do (lispworks:set-default-character-element-type 'character) (defun draw-time-signature (signature x-pix y-units fontsize staff) (let* ((staff-elems (staff-split staff)) (unit (font-size-to-unit fontsize)) (shift (+ y-units (calculate-staff-line-shift staff)))) (om-with-font (om-make-font *score-font* #+darwin fontsize #-darwin (* 3/4 fontsize)) (loop for staff-elem in staff-elems do (let ((mid-line (+ (car (staff-lines staff-elem)) (/ (- (car (last (staff-lines staff-elem))) (car (staff-lines staff-elem))) 2)))) (om-draw-string x-pix (line-to-ypos (+ mid-line 1) shift unit) (map 'lw::bmp-string #'timesig-number-char (number-to-string (car signature)))) (om-draw-string x-pix (line-to-ypos (- mid-line 1) shift unit) (map 'lw::bmp-string #'timesig-number-char (number-to-string (cadr signature)))) )) ))) (defmethod draw-tempo ((object t) x-pix y-pix font-size) nil) (defmethod draw-tempo ((object voice) x-pix y-pix font-size) (let* ((unit (font-size-to-unit font-size))) (om-draw-char x-pix y-pix (tempo-note :quater) :font (om-make-font *score-font* #+darwin (/ font-size 2) #-darwin (* 3/8 font-size))) (om-draw-string (+ x-pix unit) y-pix (format nil "= ~D" (tempo object)) :font (om-def-font :normal :size (round font-size 2.2))) )) ;;;======================= ;;; RHYTHM ;;;======================= ;;;======================== ;;; HEADS ;;;======================== (defun note-symbol (val) (cond ((>= val 8) (list val)) ((= val 8) :head-8) ;;; will never happen becvause of previous statement: fix that ((= val 4) :head-4) ((= val 2) :head-2) ((= val 1) :head-1) ((= val 1/2) :head-1/2) (t :head-1/4))) (defun rest-symbol (val) (cond ((> val 4) (list val)) ((= val 4) :rest-4) ((= val 2) :rest-2) ((= val 1) :rest-1) ((= val 1/2) :rest-1/2) ((= val 1/4) :rest-1/4) ((= val 1/8) :rest-1/8) ((= val 1/16) :rest-1/16) ((= val 1/32) :rest-1/32) ((= val 1/64) :rest-1/64) ((= val 1/128) :rest-1/128) (t :rest-1/128))) ;;; get the notehead symbol and eventually points corresponding to a given duration (defun note-head-and-points (dur) (let* ((num (numerator dur)) (den (denominator dur)) (bef (bin-value-below num)) (points 0) (symbol :head-1/4)) (cond ((= bef num) (setf symbol (note-symbol (/ num den)))) ((= (* bef 1.5) num) (setf symbol (note-symbol (/ bef den))) (setf points 1)) ((= (* bef 1.75) num) (setf symbol (note-symbol (/ bef den))) (setf points 2))) (values symbol points))) (defun rest-head-and-points (dur) (let* ((num (numerator dur)) (den (denominator dur)) (bef (bin-value-below num)) (points 0) (symbol :rest-1/4)) (cond ((= bef num) (setf symbol (rest-symbol (/ num den)))) ((= (* bef 1.5) num) (setf symbol (rest-symbol (/ bef den))) (setf points 1)) ((= (* bef 1.75) num) (setf symbol (rest-symbol (/ bef den))) (setf points 2))) (values symbol points))) ;;;======================== ;;; BEAMING ;;;======================== (defun draw-beams (begin-pix end-pix beam-line direction beams y-shift staff fontsize) (let* ((unit (font-size-to-unit fontsize)) (beamThickness (* *beamThickness* unit)) (yshift (+ y-shift (calculate-staff-line-shift staff)))) (loop for i in beams do (if (equal direction :up) (om-draw-rect (1- (+ begin-pix (* unit (car *noteheadBlack_StemUpSE*)))) ;;; floor ? (- (line-to-ypos (- beam-line (* i .75) -1) yshift unit) 0) (2+ (- end-pix begin-pix)) (1+ beamThickness) ;:color (om-random-color .8) :fill t) (om-draw-rect (1- (+ begin-pix (* unit (car *noteheadBlack_StemDownNW*)))) (1+ (round (- (line-to-ypos (+ beam-line (* i .75) -1) yshift unit) beamThickness))) (2+ (- end-pix begin-pix)) (1+ beamThickness) ;:color (om-random-color 0.7) :fill t) ) ))) ;;;======================== ;;; GROUP DIV NOTATION ;;;======================== (defun draw-group-div (num-den level begin-pix end-pix line direction y-shift staff fontsize) (let* ((unit (font-size-to-unit fontsize)) (linethickness (ceiling (* *stemthickness* unit))) (yshift (+ y-shift (calculate-staff-line-shift staff))) (width (- end-pix begin-pix)) (x (if (equal direction :up) (floor (+ begin-pix (* unit (car *noteheadBlack_StemUpSE*)))) (floor (+ begin-pix (* unit (car *noteheadBlack_StemDownNW*)))))) (y (if (equal direction :up) (line-to-ypos (+ line (* 2 level)) yshift unit) (line-to-ypos (- line (* 2 level)) yshift unit))) (dy (round (if (equal direction :up) unit (- unit)) 2.)) (div-str (if (power-of-two-p (cadr num-den)) (format nil "~A" (car num-den)) (format nil "~A:~A" (car num-den) (cadr num-den)))) (font (om-def-font :normal :size (round fontsize 2.2))) (mid-space (* (1+ (length div-str)) unit))) ;; (om-draw-string begin-pix 20 (format nil "~A" level)) (om-draw-string (+ x (round (- width mid-space) 2) (* unit .5)) (if (equal direction :up) (+ y 4) (+ y unit -4)) div-str :font font) (om-draw-line x y (+ x (round (- width mid-space) 2)) y :line linethickness) (om-draw-line x y x (+ y dy) :line linethickness) (om-draw-line (+ x (round (+ width mid-space) 2)) y (+ x width) y :line linethickness) (om-draw-line (+ x width) y (+ x width) (+ y dy) :line linethickness) )) ;;;======================== ;;; STEM ;;;======================== ;;; also works if chord is a 'note' (defun stem-direction (chord staff) (let* ((pitches (sort (mapcar 'midic (get-notes chord)) '<)) (pmin (car pitches)) (pmax (car (last pitches))) (test-op (if (or (equal staff :line) (equal staff :empty)) '> '>=))) (if (and pmax pmin (funcall test-op (/ (+ pmax pmin) 2) (staff-medium-pitch staff))) :down :up))) ;;;======================= ;;; CHORDS ;;;======================= ;;; just for debug (defmethod draw-b-box ((self score-element)) (when (b-box self) (om-draw-rect (b-box-x1 (b-box self)) (b-box-y1 (b-box self)) (b-box-w (b-box self)) (b-box-h (b-box self)) :style '(2 2))) (b-box self)) ;;; also works if chord is just a 'note': (defun draw-chord (chord x-ms ; x in ms x-units ; a global x-shift in units y-units ; y-position in score units x y ; absolute offsets in pixels w h ; frame dimensions for drawing fontsize &key (head :head-1/4) (scale :scale-1/2) (staff :gf) (stem t) ;; stem can be T or a position (in line or score units) (beams '(nil 0)) ;; (beams position-in-group) draw-chans draw-ports draw-vels draw-durs draw-dur-ruler selection tied-to-ms offsets (time-function #'identity) build-b-boxes) (declare (ignore w)) (when (get-notes chord) (om-with-translation x y (let* ((head-symb (let ((extra-head (find 'head-extra (extras chord) :key #'type-of))) (if extra-head (head-char extra-head) (if (consp head) (car head) head)))) (n-points (if (consp head) (cadr head) 0)) (head-extra-number (if (listp head-symb) (car head-symb))) (scale (get-the-scale scale))) ;;; (print (list head head-symb)) ;;; TODO ;;; if head-symb is a list => long figure and the value in (car head-symb) is the duration (multiple-value-bind (head-char head-name) (note-head-char head-symb) (let* ((unit (font-size-to-unit fontsize)) (x-pix (+ (* x-units unit) (funcall time-function x-ms))) (notes (get-notes chord)) (shift (+ y-units (calculate-staff-line-shift staff))) (staff-elems (staff-split staff)) (staff-lines (apply 'append (mapcar 'staff-lines staff-elems))) (head-box (get-font-bbox (or head-name "noteheadBlack"))) (head-w (- (nth 2 head-box) (nth 0 head-box))) ;;; the width in units of a note-head (head-h (- (nth 3 head-box) (nth 1 head-box))) ;;; the height in units of a note-head (head-w-pix (* head-w unit)) ;;; the width in pixels of a note-head (acc-w (* (get-font-width "accidentalSharp") unit 1.5)) ;;; the width in pixels of an accident symbol (stem-direction :up) cx1 cx2 cy1 cy2 ;;; chord bounding-box values (in pixels) (dur-max (apply #'max (mapcar 'dur notes))) ;; (dur-factor (/ (- w 80) (* dur-max 2))) ;;; we will multiply durations by this to display them on half-width of the view (unique-channel (and (not (equal draw-chans :hidden)) (all-equal (mapcar 'chan notes)) (chan (car notes)))) (unique-vel (and (all-equal (mapcar 'vel notes)) (vel (car notes)))) (unique-port (and draw-ports (all-equal (mapcar 'port notes)) (or (port (car notes)) :default)))) (om-with-font (om-make-font *score-font* #+darwin fontsize #-darwin (* 3/4 fontsize)) ;;; in case of a unique channel we set the color right here (om-with-fg-color (if (equal selection t) *score-selection-color* (and unique-channel (member draw-chans '(:color :color-and-number)) (get-midi-channel-color unique-channel))) ;;; Global stuff here (not needed for the head loop) (let* ((chord-notes (if (and (equal offsets :grace-note) (find 0 notes :key #'offset)) (remove-if-not #'zerop notes :key #'offset) notes)) (pitches (sort (mapcar 'midic chord-notes) '<)) (pmin (car pitches)) (pmax (car (last pitches))) (l-min (pitch-to-line pmin scale)) (l-max (pitch-to-line pmax scale)) (y-min (line-to-ypos l-min shift unit)) (y-max (line-to-ypos l-max shift unit)) (stem? (and stem ;;; passed as argument (not (or (consp head-symb) (member head-symb '(:head-1 :head-2 :head-4 :head-8))))))) ;;; STEM (when stem? ;;; determine direction (default is :up) (setq stem-direction (if (numberp stem) ;;; in a group: stem is already decided (if (> stem l-min) :up :down) ;;; stem is higher than the min note of the chord: :down (stem-direction chord staff) )) (let ((stem-size (* unit *stem-height*)) (stemThickness (* *stemThickness* unit)) (stemUpSE-x (* unit (car *noteheadBlack_StemUpSE*))) ;;; SE = anchor for stem-up (stemUpSE-y (* unit (cadr *noteheadBlack_StemUpSE*))) (stemDownNW-x (* unit (car *noteheadBlack_StemDownNW*))) ;;; NW = anchor for stem-down (stemDownNW-y (* unit (cadr *noteheadBlack_StemDownNW*))) (n-beams (car beams)) (pos-in-group (cadr beams))) (if (numberp stem) ;;; we are in a group and the max position is fixed (stem, in line-number) (let ((stem-pos (line-to-ypos stem shift unit))) (if (equal stem-direction :up) ;;; up (progn (om-draw-line (+ x-pix stemUpSE-x) (- y-min stemUpSE-y) (+ x-pix stemUpSE-x) stem-pos :line stemThickness :end-style :projecting) (when n-beams (if (zerop pos-in-group) ;; first elem (draw-beams x-pix (+ x-pix head-w-pix) stem :up n-beams y-units staff fontsize) (draw-beams (- x-pix head-w-pix) x-pix stem :up n-beams y-units staff fontsize) )) (setf cy1 stem-pos)) ;;; down (progn (om-draw-line (+ x-pix stemDownNW-x) (- y-max stemDownNW-y) (+ x-pix stemDownNW-x) stem-pos :line stemThickness :end-style :projecting) (when n-beams (if (zerop pos-in-group) ;; first elem (draw-beams x-pix (+ x-pix head-w-pix) stem :down n-beams y-units staff fontsize) (draw-beams (- x-pix head-w-pix) x-pix stem :down n-beams y-units staff fontsize) )) (setf cy2 stem-pos)) ) ) ;;; otherwise, this is a standalone chord with stem (if (equal stem-direction :up) ;;; stem up (let ((stem-x (+ x-pix stemUpSE-x))) (om-draw-line stem-x (- y-min stemUpSE-y) stem-x (- y-max stemUpSE-y stem-size) :line stemThickness) ;; initial extesion for the chord bounding-box (setf cy1 (- y-max stemUpSE-y stem-size)) (when n-beams (let ((flag-char (flag-char :up (list-max n-beams)))) (om-draw-char stem-x (- y-max stemUpSE-y stem-size) flag-char) )) ) ;;; stem down (let ((stem-x (+ x-pix stemDownNW-x))) (om-draw-line stem-x (- y-max stemDownNW-y) stem-x (- y-min stemDownNW-y (- stem-size)) :line stemThickness) ;; initial extesion for the chord bounding-box (setf cy2 (- y-min stemDownNW-y (- stem-size))) (when n-beams (let ((flag-char (flag-char :down (list-max n-beams)))) (om-draw-char stem-x (- y-min stemDownNW-y (- stem-size)) flag-char) )) ) ) ) )) ;;; GLOBAL CHANNEL (when (and (member draw-chans '(:number :color-and-number)) unique-channel) ;;; if there's just one channel in the chord we'll display it here (om-draw-string (+ x-pix (* head-w-pix 2)) (+ y-min (* unit .5)) (format nil "~D" unique-channel) :font (om-def-font :normal :size (round fontsize 2)))) ;;; GLOBAL MIDI PORT (when (and draw-ports unique-port) ;;; if there's just one port in the chord we'll display it here (if (member draw-chans '(:number :color-and-number)) (om-draw-string (+ x-pix (* head-w-pix 3)) (+ y-min (* unit 1.5)) (format nil "(~D)" unique-port) :font (om-def-font :normal :size (round fontsize 2.5))) (om-draw-string (+ x-pix (* head-w-pix 2)) (+ y-min unit) (format nil "(~D)" unique-port) :font (om-def-font :normal :size (round fontsize 2))) )) ;;; GLOBAL VELOCITY VALUE OR SYMBOL (let ((vel-extra (find 'vel-extra (extras chord) :key #'type-of))) (when (or (and draw-vels unique-vel) ;;; if there's just one velocity in the chord we'll display it somewhere else vel-extra) ;;; ... or if there is a vel-extra (let ((vel-x-pix (+ x-pix (if vel-extra (* (or (dx vel-extra) 0) unit) 0))) (vel-y-pix (+ y-min (* unit 4) (if vel-extra (* (or (dy vel-extra) 0) unit) 0)))) (cond ((or vel-extra (equal :symbol draw-vels)) (om-draw-char vel-x-pix vel-y-pix (velocity-char unique-vel))) ((equal :value draw-vels) (om-draw-string vel-x-pix vel-y-pix (format nil "~D" unique-vel) :font (om-def-font :normal :size (round fontsize 2.5)))) )))) (when (and draw-durs draw-dur-ruler) (let ((end-pix (+ (* x-units unit) (funcall time-function (+ x-ms dur-max))))) (om-draw-line x-pix (- h 50) end-pix (- h 50) :style '(2 2)) (om-draw-line x-pix (- h 54) x-pix (- h 46)) (om-draw-line end-pix (- h 54) end-pix (- h 46)) (om-draw-string (+ end-pix -20) (- h 55) (format nil "~D ms" dur-max) :font (om-def-font :normal)))) ; draw symbolic dur (for debug) ;(om-draw-string x-pix (- h 55) (format nil "~D" (symbolic-dur chord)) :font (om-def-font :normal)) ; draw absolute dur (for debug) ;(om-draw-string x-pix (- h 35) (format nil "~D" (ldur chord)) :font (om-def-font :normal)) ;;; for the note-heads loop (let* ((accidental-columns nil) (head-columns nil) (leger-lines nil) (legerLineThickness (* *legerLineThickness* unit)) (legerLineExtension (* *legerLineExtension* unit))) ;; number for big durations (when head-extra-number (let ((font (om-def-font :normal :size (round fontsize 2.2)))) (om-draw-string (+ x-pix (* head-w-pix .1)) (+ y-min (* unit 2)) (number-to-string head-extra-number) :font font) )) (loop for n in (sort (copy-list notes) '< :key 'midic) do (multiple-value-bind (line acc) (pitch-to-line (midic n) scale) (let* ((line-y (line-to-ypos line shift unit)) (head-col (position line head-columns :test #'(lambda (line col) ;;; there's no other note in this col at less than 1 line away (not (find line col :test #'(lambda (a b) (< (abs (- b a)) 1))))))) (display-offset (and (not (zerop (offset n))) offsets (not (equal offsets :hidden)))) (head-x nil) (note-font (cond ((equal draw-vels :size) (om-make-font *score-font* (* #+darwin 1 #-darwin 3/4 (vel n) fontsize .02))) ((and display-offset (equal offsets :grace-note)) (om-make-font *score-font* (* fontsize .7))) (t nil)))) (if head-col (push line (nth head-col head-columns)) (setf head-col (length head-columns) ;; add a new column head-columns (append head-columns (list (list line))))) (setq head-x (if display-offset ;;; specific offset: (+ (* x-units unit) (funcall time-function (+ x-ms (offset n)))) ;;; x-pix from head-col (+ x-pix (* head-col head-w unit)))) (let (;;; bounding-box values (nx1 head-x) (nx2 (+ head-x head-w-pix)) (ny1 (line-to-ypos (+ line (* head-h .5)) shift unit)) (ny2 (line-to-ypos (- line (* head-h .5)) shift unit))) ;;; lines are expressed bottom-up !! ;;; bounding-box is in pixels ;;; update the chord bbox as well.. (setf cx1 (if cx1 (min cx1 nx1) nx1) cx2 (if cx2 (max cx2 nx2) nx2) cy1 (if cy1 (min cy1 ny1) ny1) cy2 (if cy2 (max cy2 ny2) ny2)) (when build-b-boxes (setf (b-box n) (make-b-box :x1 nx1 :x2 nx2 :y1 ny1 :y2 ny2))) ;;; LEGER-LINES (let ((l-lines (head-leger-lines line staff-lines))) ;;; draw add leger-line(s) to the record if they are not already there (loop for ll in l-lines unless (find ll leger-lines) do (let ((ypos (line-to-ypos ll shift unit))) (om-draw-line (- x-pix legerLineExtension) ypos (+ x-pix head-w-pix legerLineExtension) ypos :line legerLineThickness) (push ll leger-lines)))) (om-with-fg-color (if (or (equal selection t) (and (listp selection) (find n selection))) *score-selection-color* (cond ((member draw-chans '(:color :color-and-number)) (om-make-color-alpha (get-midi-channel-color (chan n)) (if (equal draw-vels :alpha) (/ (vel n) 127) 1))) ((equal draw-vels :alpha) (om-make-color 0 0 0 (/ (vel n) 127))) (t nil))) ;;; HEAD (let ((note-head (if (and display-offset (equal offsets :grace-note)) (tempo-note 1/8) head-char))) (om-draw-char head-x line-y note-head :font note-font) ) ;;; DOTS (when (> n-points 0) (let ((p-y (+ line-y (* unit (if (zerop (rem line 1)) -0.45 0.05))))) (om-draw-char (+ head-x (* 1.5 head-w-pix)) p-y (dot-char)) (when (= n-points 2) (om-draw-char (+ head-x (* 2.5 head-w-pix)) p-y (dot-char)) ))) ;;; ACCIDENT (if any) (when acc (let ((col (position (midic n) accidental-columns :test #'(lambda (pitch col) ;;; there's no other note in this col at less than an octave (not (find pitch col :test #'(lambda (a b) (< (abs (- b a)) 1200)))))))) (if col (push (midic n) (nth col accidental-columns)) (setf col (length accidental-columns) ;; add a new column accidental-columns (append accidental-columns (list (list (midic n)))))) (om-draw-char (if display-offset (- head-x (* acc-w (if (equal offsets :grace-note) .7 1))) (- x-pix (* (1+ col) acc-w))) line-y (accident-char acc) :font note-font) )) ;;; DURATION line (maybe) (when draw-durs (let ((end-pix (+ (* x-units unit) (funcall time-function (+ x-ms (dur n)))))) (om-with-fg-color (if t ;(member draw-chans '(:color :color-and-number)) (om-make-color-alpha (get-midi-channel-color (chan n)) .5) (om-make-color 0 0 0 .5)) (om-draw-rect (if display-offset head-x x-pix) (- line-y (* unit .25)) (- end-pix x-pix) (* unit .5) :fill t)) )) ;;; MIDI channel (maybe) ;;; if there's just one channel in the chord we'll display it somewhere else (when (and (member draw-chans '(:number :color-and-number)) (not unique-channel)) (om-draw-string (+ x-pix (* head-w-pix 2)) (+ line-y (* unit .5)) (format nil "~D" (chan n)) :font (om-def-font :normal :size (round fontsize 2))) ) ;;; MIDI port (maybe) ;;; if there's just one port in the chord we'll display it somewhere else (when (and draw-ports (not unique-port)) (om-draw-string (+ x-pix (if (member draw-chans '(:number :color-and-number)) (* head-w-pix 3.5) (* head-w-pix 2.5))) (+ line-y unit) (format nil "(~D)" (port n)) :font (om-def-font :normal :size (round fontsize 2.5))) ) ;;; VELOCITY (maybe) ;;; if there's just one velocity in the chord we'll display it somewhere else (when (and draw-vels (not unique-vel)) (case draw-vels (:value (om-draw-string x-pix (+ line-y (* unit 2)) (format nil "~D" (vel n)) :font (om-def-font :normal :size (round fontsize 2.5)))) (:symbol (om-draw-char x-pix (+ line-y (* unit 2)) (velocity-char (vel n)))) )) ;;; TIES (when tied-to-ms (let* ((x0 (+ (* x-units unit) (funcall time-function tied-to-ms) head-w-pix (* .3 unit))) (tie-h (if (> (abs (/ (- x-pix x0) unit)) 5) unit (* unit .5)))) (om-with-line-size (* *stemThickness* unit 1.8) (let ((tie-direction (if (= (length pitches) 1) ;;; if only one note (if (equal stem-direction :up) :down :up) ;;; opposed to beam (if (>= (position (midic n) pitches :test '=) (ceiling (length pitches) 2)) ;;; depends on position (rank) in the chord :up :down)))) (if (equal tie-direction :up) (om-draw-arc x0 (- ny1 tie-h) (- x-pix x0 (* .3 unit)) (* 2 tie-h) 0 pi) (om-draw-arc x0 (- ny2 tie-h) (- x-pix x0 (* .3 unit)) (* 2 tie-h) 0 (- pi))) ) ) )) )) ))) ;;; END LOOP ) ;;; END NOTES LET ;;; DRAW EXTRAS (when (extras chord) (loop for e in (get-extras chord 'text-extra) do (om-with-font (om-make-font (font e) (/ fontsize 2)) (om-draw-string (+ x-pix (* (or (dx e) 0) unit)) (+ y-min (* unit (+ 4 (or (dy e) 0)))) (text e))) ) (loop for e in (get-extras chord 'symb-extra) do (om-draw-char (+ x-pix (*(or (dx e) 0) unit)) (+ y-min (* unit (+ 4 (or (dy e) 0)))) (code-char (symb-char e))) ) (loop for e in (get-extras chord 'score-marker) do (om-with-fg-color (if (equal selection t) *score-selection-color* (om-def-color :steelblue)) (om-draw-line x-pix 0 x-pix h :line (/ fontsize 20)) (when (data e) (om-draw-string (+ x-pix unit) (- h 20) (format nil "~A" (data e)) :font (om-def-font :normal :size (/ fontsize 2)))) )) ) ) ;;; END OF THE NOTE-HEADS LET )) ;;; return the bounding box (always) (when t ;build-b-boxes (make-b-box :x1 cx1 :x2 cx2 :y1 cy1 :y2 cy2)) ) ))))) ;;;========================================================== ;;; RESTS (defun draw-rest (rest x-ms ; x-pos in ms x-units y-units ; ref-position in score units x y ; absolute offsets in pixels w h ; frame for drawing fontsize &key (head :rest-1/4) line stem beams (staff :gf) selection (time-function #'identity) build-b-boxes) (declare (ignore w h)) (om-with-translation x y (let* ((unit (font-size-to-unit fontsize)) (x-pix (+ (* x-units unit) (funcall time-function x-ms))) (head-symb (if (consp head) (car head) head)) (n-points (if (consp head) (cadr head) 0))) (multiple-value-bind (head-char head-name) (rest-char head-symb) (let* ((shift (+ y-units (calculate-staff-line-shift staff))) (head-box (get-font-bbox (or head-name "noteheadBlack"))) (head-w (- (nth 2 head-box) (nth 0 head-box))) ;;; the width in units of a note-head (head-h (- (nth 3 head-box) (nth 1 head-box))) ;;; the height in units of a note-head (staff-lines (staff-lines (car (last (staff-split staff))))) (line-pos (or line (+ (car staff-lines) (/ (- (car (last staff-lines)) (car staff-lines)) 2)))) ;;; the default position is the middle of the top staff ) (cond ((and (equal head-symb :rest-1) ;; the whole rest is 1 line upper (except on 1-lien staff) (not (equal staff :line))) (setf line-pos (floor (1+ line-pos)))) ((or (equal head-symb :rest-1) (equal head-symb :rest-1/2)) ;; the 1/2 rest on a line (setf line-pos (floor line-pos)))) ;(print (list line-pos head-symb staff-lines)) ;;; positions (in pixels) (flet ((x-pos (a) (+ x-pix 1 (* a unit)))) (let ((head-x (x-pos 0)) (line-y (line-to-ypos line-pos shift unit)) (head-extra-number (if (listp head-symb) (car head-symb)))) (om-with-font (om-make-font *score-font* fontsize) (om-with-fg-color (if (or (equal selection t) (and (listp selection) (find rest selection))) *score-selection-color* nil) (when head-extra-number (setf head-x (+ head-x (* unit 1))) (let ((font (om-def-font :normal :size (round fontsize 2.2)))) (om-draw-string (+ head-x (* head-w unit .3)) (- line-y (* unit 1)) (number-to-string head-extra-number) :font font) ) ) ;;; SYMBOL (om-draw-char head-x line-y head-char) ;;; DOTS (when (> n-points 0) (let ((p-y (+ line-y (* unit (if (zerop (rem line-pos 1)) ;; avoid dots on a line -0.45 0.05)) (if (equal head-symb :rest-1) unit 0) ;; the whole rest is on the upper line (4) ) )) (om-draw-char (+ head-x (* (+ head-w .5) unit)) p-y (dot-char)) (when (= n-points 2) (om-draw-char (+ head-x (* (+ head-w .5) 2 unit)) p-y (dot-char)) ))) ;; special case for whole rest and half-rest: draw a small line when needed (when (or (equal head-symb :rest-1)(equal head-symb :rest-1/2)) (om-draw-line (- head-x (* unit .5)) line-y (+ head-x (* unit (+ head-w .5))) line-y :line (* *thinBarLineThickness* unit))) )) ;;; draw a small beam (when the rest is in a group) (when stem (let ((stemThickness (* *stemThickness* unit)) (beam-y (line-to-ypos stem shift unit)) (head-w-pix (* (car *noteheadBlack_StemUpSE*) unit)) ;;; to align with beam position (head-h-pix (* head-h unit)) (n-beams (car beams)) (pos-in-group (cadr beams))) (if (>= stem line-pos) ;;; stem up (progn (om-draw-line (+ head-x head-w-pix -1) (- line-y (/ (+ head-h-pix unit) 2)) (+ head-x head-w-pix -1) beam-y :line stemThickness :end-style :projecting) (when n-beams (if (zerop pos-in-group) ;; first elem (draw-beams x-pix (+ x-pix head-w-pix) stem :up n-beams y-units staff fontsize) (draw-beams (- x-pix head-w-pix) x-pix stem :up n-beams y-units staff fontsize) )) ) ;;; down (progn (om-draw-line x-pix (+ line-y (/ (+ head-h-pix unit) 2)) x-pix beam-y :line stemThickness :end-style :projecting) (when n-beams (if (zerop pos-in-group) ;; first elem (draw-beams x-pix (+ x-pix head-w-pix) stem :down n-beams y-units staff fontsize) (draw-beams (- x-pix head-w-pix) x-pix stem :down n-beams y-units staff fontsize) )) ) ) )) ;;; return the bounding box (when t ; build-b-boxes (make-b-box :x1 head-x :x2 (+ head-x (* head-w unit)) :y1 (line-to-ypos (+ line-pos (* head-h .5)) shift unit) ;;; lines are expressed bottom-up !! :y2 (line-to-ypos (- line-pos (* head-h .5)) shift unit)) ) ))) )) ) )
58,229
Common Lisp
.lisp
1,076
36.864312
146
0.46201
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
c30495e1517c4c8df86aaed630c524ef111aca25954727319e29aa089dd890a4
756
[ -1 ]
757
basic.lisp
cac-t-u-s_om-sharp/src/packages/basic/basic.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (mapc #'(lambda (filename) (compile&load (decode-local-path filename))) '( "functions/lists" "functions/numbers" "functions/sets" "functions/combinatorial" "functions/series" "functions/interpolations" "bpf-bpc/bpf" "bpf-bpc/bpc" "bpf-bpc/bpf-tools" "bpf-bpc/bpf-editor" "functions/modulations" "text/textbuffer" "automation/automation" "automation/tempo-automation" "automation/automation-editor" "containers/2d-array" "compatibility" "basic-pack" ))
1,448
Common Lisp
.lisp
37
31.675676
78
0.496006
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
9ec77060d18e8521c59cde28d8a2e2970001682a8a767956741979530b04e9b9
757
[ -1 ]
758
compatibility.lisp
cac-t-u-s_om-sharp/src/packages/basic/compatibility.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;; LOAD OBJECTS AND CODE FROM OM6 (in-package :om) ;================== ; Functions ;================== ;;; compat API: (defmethod update-arg-names ((reference (eql 'om-sample))) '(("sample-rate" "nbs-sr"))) ;;; => do it for other arithmetic functions... (defmethod update-arg-names ((reference (eql 'om*))) '(("self" "arg1") ("num" "arg2"))) (defmethod update-arg-names ((reference (eql 'om/))) '(("self" "arg1") ("num" "arg2"))) (defmethod update-arg-names ((reference (eql 'om+))) '(("self" "arg1") ("num" "arg2"))) (defmethod update-arg-names ((reference (eql 'om-))) '(("self" "arg1") ("num" "arg2"))) ;;;================ ;;; BPF ;;;================ (defun simple-bpf-from-list (x-points y-points &optional (class 'bpf) (decimals 0)) (make-instance class :x-points x-points :y-points y-points :decimals decimals)) (defmethod (setf bpfcolor) ((c t) (self bpf)) (when c (setf (slot-value self 'color) (om-correct-color c)))) (defmethod bpfcolor ((self bpf)) (color self)) (defun 3Dc-from-list (xlist ylist zlist &optional (class '3DC) (decimals 0)) (make-instance class :x-points xlist :y-points ylist :z-points zlist :decimals decimals)) ;;; xxx-LIBs (defclass bpf-lib () ((bpf-list :accessor bpf-list :initarg :bpf-list :initform nil))) (defclass bpc-lib (bpf-lib) ()) (defclass 3DC-lib (bpc-lib) ()) ;;; compat API: (defmethod update-reference ((ref (eql 'bpf-lib))) 'collection) (defmethod update-reference ((ref (eql 'bpc-lib))) 'collection) (defmethod update-reference ((ref (eql '3dc-lib))) 'collection) (defmethod update-value ((self bpf-lib)) (make-instance 'collection :obj-list (bpf-list self))) (defmethod update-reference ((ref (eql '3D-trajectory))) '3DC) ;;;=================== ;;; TEXTFILE/TEXTBUFER ;;;=================== ;;; text contents (defun load-buffer-textfile (listline class edmode &optional (evmode "text")) (declare (ignore class edmode evmode)) (omng-load `(:object (:class textbuffer) (:slots ((:contents ,(omng-save listline))))))) ;;; linked to a file ;;; !! pathname can be relative ("infile/...") (defun load-textfile (pathname class edmode &optional (evmode "text")) (declare (ignore class edmode evmode)) (omng-load `(:object (:class textbuffer) (:slots ((:contents ,(omng-save (lines-from-file pathname)))))))) (defmethod om-load-editor-box1 (name (reference (eql 'textfile)) inputs position size value lock &optional fname editparams spict meditor pictlist show-name) (declare (ignore reference fname editparams meditor pictlist)) (let* ((eval-mode-str (find-value-in-kv-list (cdr (eval (fourth inputs))) :value)) (eval-mode (cond ((string-equal eval-mode-str "text") :text-list) ((string-equal eval-mode-str "data list") :lines-cols) ((string-equal eval-mode-str "list") :list) ((string-equal eval-mode-str "value") :value) ))) `(:box (:type :object) (:reference textbuffer) (:name ,name) (:value ,value) (:x ,(om-point-x position)) (:y ,(om-point-y position)) (:w ,(om-point-x size)) (:h ,(om-point-y size)) (:lock ,(if lock (cond ((string-equal lock "x") :locked) ((string-equal lock "&") :eval-once)))) (:showname ,show-name) (:display ,(if spict :mini-view :hidden)) (:edition-params (:output-mode ,eval-mode)) (:inputs (:input (:type :standard) (:name "self") (:value nil)) (:input (:type :standard) (:name "contents") (:value nil)) (:input (:type :key) (:name "output-mode") (:value ,eval-mode)) ) ))) ;;;================ ;;; CLASS-ARRAY ;;;================ ;;; refefines the base method here... (not good) (defmethod update-arg-names (reference) (when (find-class reference nil) (cond ((subtypep reference 'class-array) '(("numcols" "elts"))) (t nil)))) (defun get-init-slots-of-class (class) (mapcar #'(lambda (slot) (list (slot-definition-name slot) (slot-definition-type slot))) (class-slots (find-class class)))) (defmethod (setf lcontrols) (val obj) nil) (defmethod (setf data) (data (array class-array)) ;; init-array-from-csound-instr (om-init-instance array) ;(cons array ; (loop for field in (cr::cs-description-params (cr::cs-instr array)) ; for field-data in data collect ; (make-array-field :name field-name :data field-data :decimals 4)) (setf (slot-value array 'data) (if (every #'array-field-p data) data (loop for array-field in (data array) for field-data in data collect (make-array-field :name (array-field-name array-field) :decimals (array-field-decimals array-field) :default (array-field-default array-field) :type (array-field-type array-field) :doc (array-field-doc array-field) :data field-data) ))) )
6,146
Common Lisp
.lisp
134
38.052239
98
0.556511
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
5ddc79187df4fe2fb18b8861a38b4bdcd229834ed414be9024453dca6a5542e7
758
[ -1 ]
759
basic-pack.lisp
cac-t-u-s_om-sharp/src/packages/basic/basic-pack.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (omNG-make-package "Basic Tools" :container-pack *om-package-tree* :doc "Objects and tools for data representation and processing" :subpackages (list (omNG-make-package "List Processing" :doc "" :functions '(last-elem last-n first-n x-append flat create-list expand-lst mat-trans group-list remove-dup subs-posn interlock list-modulo list-explode list-filter table-filter band-filter range-filter posn-match)) (omNG-make-package "Arithmetic" :doc "" :functions '(om+ om- om* om/ om// om^ om-e om-abs om-min om-max list-min list-max all-equal om-mean om-log om-round om-scale om-scale/sum reduce-tree interpolation factorize om-random perturbation om< om> om<= om>= om= om/=)) (omNG-make-package "Combinatorial" :doc "" :functions '(sort-list rotate nth-random permut-random posn-order permutations)) (omNG-make-package "Series" :doc "" :functions '(arithm-ser geometric-ser fibo-ser inharm-ser prime-ser prime? x->dx dx->x)) (omNG-make-package "Sets" :doc "" :functions '(x-union x-intersect x-Xor x-diff included?)) (omNG-make-package "Interpolation" :doc "" :functions '(x-transfer y-transfer om-sample linear-fun reduce-points reduce-n-points)) (omNG-make-package "Curves & Functions" :doc "" :functions '(point-pairs bpf-interpol bpf-scale bpf-extract bpf-offset bpf-crossfade bpf-spline set-color jitter vibrato param-process) :classes '(bpf bpc)) (omNG-make-package "Text" :doc "" :functions '(textbuffer-eval textbuffer-read) :classes '(textbuffer)) (omNG-make-package "Arrays" :doc "" :classes '(2D-array) :functions '(get-field) :subpackages (list (omNG-make-package "Class-Array and Components" :doc "" :classes '(class-array) :functions '(new-comp get-comp add-comp remove-comp comp-list comp-field) ))) )) ;;; PICT: Missing tools and functions: ;;; picture get-RGB picture-size save-picture
3,674
Common Lisp
.lisp
66
37.787879
128
0.465723
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
4fea53d4015640eb85c689392cded4f7d045972974609537da6473070320fbf8
759
[ -1 ]
760
bpc.lisp
cac-t-u-s_om-sharp/src/packages/basic/bpf-bpc/bpc.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;======================================== ;;; TIMED POINT ;;;======================================== ; TimeTypes can be : ; nil : not defined ; t :defined ; :master --> Master point for interpolations (defstruct (tpoint (:include bpfpoint)) time internal-time) (defun om-make-tpoint (x y &optional time type) (make-tpoint :x x :y y :time time :internal-time time :type type)) (defmethod om-point-time ((self tpoint)) (tpoint-time self)) (defmethod om-point-time ((self t)) nil) (defmethod om-copy ((self tpoint)) (make-tpoint :x (tpoint-x self) :y (tpoint-y self) :time (tpoint-time self) :internal-time (tpoint-internal-time self) :type (tpoint-type self))) (defmethod om-point-set ((point tpoint) &key x y time type) (if x (setf (tpoint-x point) x)) (if y (setf (tpoint-y point) y)) (if time (progn (setf (tpoint-time point) time) (setf (tpoint-internal-time point) time))) (if type (setf (tpoint-type point) type)) point) (defmethod om-point-set-values-from-point ((point tpoint) (target tpoint)) (setf (tpoint-x point) (tpoint-x target) (tpoint-y point) (tpoint-y target) (tpoint-time point) (tpoint-time target) (tpoint-internal-time point) (tpoint-internal-time target) (tpoint-type point) (tpoint-type target)) point) (defmethod om-point-mv ((point tpoint) &key x y time) (if x (setf (tpoint-x point) (+ (tpoint-x point) x))) (if y (setf (tpoint-y point) (+ (tpoint-y point) y))) (if time (progn (setf (tpoint-time point) (+ (tpoint-time point) time)) (setf (tpoint-internal-time point) (tpoint-time point)))) point) (defmethod om-points-equal-p ((p1 tpoint) (p2 tpoint)) (and (= (tpoint-x p1) (tpoint-x p2)) (= (tpoint-y p1) (tpoint-y p2)) (= (tpoint-time p1) (tpoint-time p2)))) ;;; not necessarily at the same time ! (defmethod om-points-at-same-position ((p1 ompoint) (p2 ompoint)) (and (= (om-point-x p1) (om-point-x p2)) (= (om-point-y p1) (om-point-y p2)))) (defmethod calc-intermediate-point-at-time ((p1 tpoint) (p2 tpoint) time) (let* ((dur (- (tpoint-internal-time p2) (tpoint-internal-time p1))) (factor (/ (- time (tpoint-internal-time p1)) dur)) (x (+ (* (- (tpoint-x p2) (tpoint-x p1)) factor) (tpoint-x p1))) (y (+ (* (- (tpoint-y p2) (tpoint-y p1)) factor) (tpoint-y p1)))) (om-make-tpoint x y time))) ;;; Need to define it for for BPF points, too (defmethod calc-intermediate-point-at-time ((p1 ompoint) (p2 ompoint) time) (let* ((dur (- (om-point-x p2) (om-point-x p1))) (factor (/ (- time (om-point-x p1)) dur)) (y (+ (* (- (om-point-y p2) (om-point-y p1)) factor) (om-point-y p1)))) (om-make-point time y))) ;;; TIMED-ITEM IMPLEMENTATION (defmethod item-get-time ((self tpoint)) (tpoint-time self)) (defmethod item-set-time ((self tpoint) time) (setf (tpoint-time self) time)) (defmethod item-get-internal-time ((self tpoint)) (tpoint-internal-time self)) (defmethod item-set-internal-time ((self tpoint) time) (setf (tpoint-internal-time self) time)) (defmethod item-get-type ((self tpoint)) (tpoint-type self)) (defmethod item-set-type ((self tpoint) type) (setf (tpoint-type self) type)) ;;;======================================== ;;; BPC ;;;======================================== (defclass class-with-times-slot () ((times :initform nil :initarg :times :accessor times))) (defclass* BPC (bpf class-with-times-slot) ((x-points :initform nil :initarg :x-points) (y-points :initform nil :initarg :y-points)) (:icon 'bpc) (:documentation "Break-Points Curve: a 2D path defined by a list of [x,y] coordinates. BPC objects are constructed from the list of X coordinates (<x-points>) and the list of Y coordinates (<y-points>). The values in <x-point> are not necesarily increasing (contrary to BPF objects). - If <x-list> and <y-list> are not of the same length, the last step in the shorter one is repeated. - <decimals> determines the floating-point precision of the function (0 = integers, n > 0 = number of decimals).")) (defmethod additional-class-attributes ((self BPC)) (append '(times) (call-next-method))) ;;; BPCs have a special accessor for times (defmethod times ((self BPC)) (time-sequence-get-times self)) (defmethod (setf times) ((times t) (self BPC)) (time-sequence-set-times self times) times) (defmethod om-init-instance ((self bpc) &optional initargs) ;;; save/load will work with slot-value only (when (slot-value self 'times) (time-sequence-set-times self (slot-value self 'times))) (call-next-method)) ;; need to redefine from BPF (defmethod time-sequence-get-times ((self BPC)) (time-values-from-points self)) (defmethod time-sequence-set-times ((self BPC) times) (set-bpf-points self :time times) (time-sequence-update-internal-times self)) (defmethod bpc-p ((self bpc)) t) (defmethod bpc-p ((self t)) nil) (defmethod time-values-from-points ((self BPC)) (mapcar #'om-point-time (point-list self))) (defmethod (setf decimals) ((decimals t) (self BPC)) (let ((x (x-values-from-points self)) (y (y-values-from-points self)) (times (time-values-from-points self))) (setf (slot-value self 'decimals) decimals) (check-decimals self) (set-bpf-points self :x x :y y :time times) (time-sequence-update-internal-times self) (decimals self))) (defmethod init-bpf-points ((self BPC)) (set-bpf-points self :x (slot-value self 'x-points) :y (slot-value self 'y-points) :time (slot-value self 'times) :time-types (slot-value self 'time-types)) (time-sequence-update-internal-times self) self) ;;; NO X-SORT IN BPC (defmethod set-bpf-points ((self bpc) &key x y z time time-types) (declare (ignore z)) (let ((point-list (make-points-from-lists (or x (x-values-from-points self)) ; (slot-value self 'x-points)) (or y (y-values-from-points self)) ; (slot-value self 'y-points)) (decimals self) 'om-make-tpoint)) (times (or time (time-values-from-points self)))) (when times (loop for p in point-list for time in times do (setf (tpoint-time p) time))) (when time-types (loop for p in point-list for type in time-types do (om-point-set p :type type))) (setf (point-list self) point-list) (setf (slot-value self 'x-points) NIL) (setf (slot-value self 'y-points) NIL) (setf (slot-value self 'times) NIL) (setf (slot-value self 'time-types) NIL))) (defmethod duplicate-coordinates ((p1 tpoint) (p2 tpoint)) (and (= (tpoint-x p1) (tpoint-x p2)) (= (tpoint-y p1) (tpoint-y p2)) (equal (tpoint-time p1) (tpoint-time p2)))) (defmethod replace-current ((new tpoint) (current tpoint)) (and (equal (bpfpoint-type new) :master) (not (equal (bpfpoint-type current) :master)))) ;;; In BPC all moves are possible (defmethod possible-move ((self bpc) points xkey deltax ykey deltay) t) (defmethod possible-set ((self bpc) point x y) t) (defmethod adapt-point ((self bpc) point) (setf (tpoint-x point) (funcall (truncate-function (decimals self)) (tpoint-x point)) (tpoint-y point) (funcall (truncate-function (decimals self)) (tpoint-y point))) point) ;;; In BPC we add the new points at the end (defmethod insert-point ((self bpc) new-point &optional position) (let ((p (adapt-point self new-point)) (pp (or position (length (point-list self))))) (setf (point-list self) (insert-in-list (point-list self) p pp)) pp )) (defmethod set-point-in-bpc ((self bpc) point x y time) (let ((xx (funcall (truncate-function (decimals self)) (or x (om-point-x point)))) (yy (funcall (truncate-function (decimals self)) (or y (om-point-y point))))) (setf (tpoint-x point) xx (tpoint-y point) yy (tpoint-time point) time) point)) ;;;========================================= ;;; TIME-SEQUENCE METHODS ;;;========================================= (defmethod get-obj-dur ((self BPC)) (if (point-list self) (tpoint-internal-time (car (last (point-list self)))) 0)) (defmethod time-sequence-make-timed-item-at ((self bpc) at) (make-default-tpoint-at-time self at)) ;;; Create a new point that preserves the motion of the object (defmethod make-default-tpoint-at-time ((self bpc) time) (if (times self) (let ((pos (or (position time (point-list self) :key 'tpoint-internal-time :test '<= ) (length (point-list self)))) (len (length (point-list self)))) ;if length is 1 or if the point is before the others or after use the same position than the before or after point (if (or (= len 1) (or (= pos 0) (= pos len))) (let ((point (nth (min pos (1- len)) (point-list self)))) (om-make-tpoint (om-point-x point) (om-point-y point) time)) ; if several points, preserve the motion (let ((p1 (nth (1- pos) (point-list self))) (p2 (nth pos (point-list self)))) (calc-intermediate-point-at-time p1 p2 time)))) ;if no points, create a points a pos (om-make-tpoint 0 0 time))) (defmethod* get-interpolated-sequence ((self bpc) &optional (interpol-time 100)) :numouts 3 (if (point-list self) (let* ((interpol-times (arithm-ser (tpoint-internal-time (car (point-list self))) (tpoint-internal-time (car (last (point-list self)))) interpol-time)) (new-points (loop for time in interpol-times collect (make-default-tpoint-at-time self time))) (new-obj (make-instance (type-of self) :decimals (decimals self)))) (setf (point-list new-obj) new-points) (values new-obj (x-points new-obj) (y-points new-obj))) (values (make-instance (type-of self) :x-points nil :y-points nil :decimals (decimals self)) nil nil))) ;;; Get the min max points in x and y axis ;;; using reduce 'mix/max is fatser when interpreted but not when compiled (defmethod nice-bpf-range ((self bpc)) (multiple-value-bind (x1 x2 y1 y2 t1 t2) (loop for x in (x-values-from-points self) for y in (y-values-from-points self) for time in (time-sequence-get-internal-times self) minimize x into x1 maximize x into x2 minimize y into y1 maximize y into y2 minimize time into t1 maximize time into t2 finally (return (values x1 x2 y1 y2 t1 t2))) (append (list x1 x2) (list y1 y2) (list t1 t2)) ; (if (< (- x2 x1) 10) (list (- x1 5) (+ x2 5)) (list x1 x2)) ; (if (< (- y2 y1) 10) (list (- y1 5) (+ y2 5)) (list y1 y2))) )) ;;; to be redefined by objects if they have a specific miniview for the sequencer (defmethod draw-sequencer-mini-view ((self bpc) (box t) x y w h &optional time) (let* ((x-col (om-def-color :red)) (y-col (om-def-color :green)) (ranges (nice-bpf-range self)) (times (time-sequence-get-internal-times self)) (x-t-list (mat-trans (list times (x-points self)))) (x-t-ranges (list 0 (nth 5 ranges) (car ranges) (cadr ranges))) (y-t-list (mat-trans (list times (y-points self)))) (y-t-ranges (list 0 (nth 5 ranges) (caddr ranges) (cadddr ranges)))) ;draw x = f(t) (draw-bpf-points-in-rect x-t-list x-col x-t-ranges ;(+ x 7) (+ y 10) (- w 14) (- h 20) x (+ y 10) w (- h 20) ) ;draw y = f(t) (draw-bpf-points-in-rect y-t-list y-col y-t-ranges ;(+ x 7) (+ y 10) (- w 14) (- h 20) x (+ y 10) w (- h 20) ) t)) ;;;============================ ;;; PLAYER ;;;============================ (defmethod get-action-list-for-play ((object bpc) interval &optional parent) (when (action object) (if (number-? (interpol object)) (let* ((root (get-active-interpol-time object (car interval)))) (loop for interpolated-time in (arithm-ser root (1- (cadr interval)) (number-number (interpol object))) collect (list interpolated-time #'(lambda (pt) (funcall (action-fun object) pt)) (make-default-tpoint-at-time object interpolated-time)))) (loop for pt in (filter-list (point-list object) (car interval) (cadr interval) :key 'tpoint-internal-time) collect (list (tpoint-internal-time pt) #'(lambda (ptmp) (funcall (action-fun object) ptmp)) (list pt)))))) ;;;========================================= ;;; METHODS CALLED FROM OUTSIDE ;;;========================================= (defmethod arguments-for-action ((fun (eql 'send-xy-as-osc))) `((:string address "/point/xy") (:string host ,(get-pref-value :osc :out-host)) (:int port ,(get-pref-value :osc :out-port)))) (defun send-xy-as-osc (point &optional (address "/point/xy") (host "localhost") (port 3000)) (osc-send (list address (om-point-x point) (om-point-y point)) host port)) (defmethod get-def-action-list ((object BPC)) '(print send-xy-as-osc bpc-midi-controller))
14,396
Common Lisp
.lisp
282
43.77305
122
0.590715
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
c5c90b7625ef0a8bbf07e60eb34248f9c6d982d607942a3951e38fd2c2d1dbc4
760
[ -1 ]
761
bpf-tools.lisp
cac-t-u-s_om-sharp/src/packages/basic/bpf-bpc/bpf-tools.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;=========================== ;;; POINTS ACCESS ;;;=========================== (defmethod* point-pairs ((self bpf)) :initvals '(nil) :indoc '("a BPC or BPF") :doc "Retruns the list of points in <self> as a list ((x1 y1) (x2 y2) ...) or ((x1 y1 t1) (x2 y2 t2) ...)" :icon :bpf (mat-trans (list (x-points self) (y-points self)))) (defmethod* point-pairs ((self bpc)) (mat-trans (list (x-points self) (y-points self)))) ;;; compat (defmethod* paires ((self bpf)) :icon 128 (point-pairs self)) ;;; called (for instance) in save-as-text (defmethod write-data ((self bpf) out) (loop for x in (x-points self) for y in (y-points self) do (format out "~D ~D~%" x y))) ;;;=========================== ;;; COLOR ;;;=========================== (defmethod* set-color ((self bpf) color &optional (new? t)) :initvals '(nil nil t) :indoc '("a BPF or BPC" " color" "create a new object") :icon :bpf-colors :doc "Sets the color of <self> with <color>. If <new?> the function will retrun a new colored object; otherwise it will change the color of <self>. If <color> is :random, will choose a random color. It can also be a color symbol designator (:red, :blue, etc..) or a color created from om-make-color. " (let ((bpf (if new? (clone self) self))) (setf (color bpf) (cond ((equal color :random) (om-random-color)) ((symbolp color) (om-def-color color)) (t color))) bpf)) ;;;=========================================== ;;; BASIC FUNCTIONS ADAPTED TO BPFS ;;;=========================================== ;;; TRANSFERs (defmethod* y-transfer ((self bpf) (y0 number) &optional (dec nil)) (y-transfer (point-pairs self) y0 dec)) (defmethod* x-transfer ((self bpf) x-val &optional (dec nil)) (x-transfer (point-pairs self) x-val dec)) (defmethod! bpf-extract ((self bpf) x1 x2) :indoc '("a BPF" "x1" "x2") :initvals '(nil nil nil) :doc "Extracts a segment (between <x1> and <x2>) from <self>." :icon :bpf-extract (let* ((xpts (x-points self)) (x1-exact-pos (if x1 (position x1 xpts :test '=) 0)) (x1-pos (or x1-exact-pos (position x1 xpts :test '<) (length xpts))) (x2-exact-pos (if x2 (position x2 xpts :test '=) (1- (length xpts)))) (x2-pos (or x2-exact-pos (position x2 xpts :test '> :from-end t) 0)) ) (om-make-bpf (type-of self) (om- (append (unless x1-exact-pos (list x1)) (subseq xpts x1-pos (1+ x2-pos)) (unless x2-exact-pos (list x2))) (or x1 (car xpts))) (append (unless x1-exact-pos (list (x-transfer self x1))) (subseq (y-points self) x1-pos (1+ x2-pos)) (unless x2-exact-pos (list (x-transfer self x2)))) (decimals self)))) ;;; REDUCTION (defmethod* reduce-points ((self bpf) &optional (approx 0.02)) (let ((reduced-points (reduce-points (point-pairs self) approx))) (make-instance (type-of self) :x-points (mapcar 'car reduced-points) :y-points (mapcar 'cadr reduced-points) :decimals (decimals self) :action (action self) ))) (defmethod* reduce-n-points ((self bpf) n &optional (precision 10) (verbose nil)) (let ((reduced-points (reduce-n-points (point-pairs self) n precision verbose))) (make-instance (type-of self) :x-points (mapcar 'car reduced-points) :y-points (mapcar 'cadr reduced-points) :decimals (decimals self) :action (action self) ))) ;;;=========================================== ;;; OM-SAMPLE FOR BPF ;;;=========================================== (defmethod* om-sample ((self bpf) (nbs-sr number) &optional xmin xmax dec) :numouts 3 (if (point-list self) (let* ((x0 (or xmin (first (x-points self)))) (x1 (or xmax (car (last (x-points self))))) (nn (if (integerp nbs-sr) nbs-sr (+ 1 (floor (/ (- x1 x0) nbs-sr))) )) (ylist (interpole (x-points self) (y-points self) x0 x1 nn)) (xlist (if (integerp nbs-sr) (cond ((> nbs-sr 1) (sample-interval x0 x1 nbs-sr)) ((= nbs-sr 1) (list (+ x0 (/ (- x1 x0) 2.0)))) (t (om-beep-msg "Number of sample must be > 0 !!!"))) (arithm-ser x0 x1 nbs-sr))) (rep (om-copy self))) (when dec (change-precision rep dec)) (when (and xlist ylist) (set-bpf-points rep :x xlist :y ylist)) (values (and xlist ylist rep) xlist (if dec (om-round ylist dec) ylist)) ) (values (om-copy self) nil nil) )) (defmethod* om-sample ((self BPC) (nbs-sr number) &optional xmin xmax dec) :numouts 3 (let* ((pts (point-pairs self)) (seg-len (loop for i from 0 to (- (length pts) 2) collect (pts-distance (car (nth i pts)) (cadr (nth i pts)) (car (nth (1+ i) pts)) (cadr (nth (1+ i) pts))))) (total-length (reduce '+ seg-len :initial-value 0)) (ratios (mapcar #'(lambda (l) (/ l total-length)) seg-len)) (nsamples (if (integerp nbs-sr) nbs-sr (ceiling total-length nbs-sr))) (npts-per-seg (mapcar #'(lambda (r) (round (* r nsamples))) ratios)) (samples nil) (xylist nil)) (if (>= nsamples (length pts)) (setf samples (cons (car pts) (loop for p1 in pts for p2 in (cdr pts) for np in npts-per-seg append (cond ((< np 1) nil) ((< np 2) (list p2)) (t (let (x1 x2 y1 y2 vals) (if (= (car p1) (car p2)) ;; particular case (setf x1 (cadr p1) x2 (cadr p2) y1 (car p1) y2 (car p2)) (setf x1 (car p1) x2 (car p2) y1 (cadr p1) y2 (cadr p2))) (setf vals (multiple-value-list (om-sample (linear-fun x1 y1 x2 y2) np x1 x2))) (mat-trans (if (= (car p1) (car p2)) (list (third vals) (second vals)) (list (second vals) (third vals)))))))))) (let ((segpos (dx->x 0 seg-len)) (samplepos (arithm-ser 0 total-length (/ total-length nsamples) nsamples))) (setf samples (loop for sp in samplepos collect (let ((po1 (position sp segpos :test '>= :from-end t)) (po2 (position sp segpos :test '<=)) p1 p2 pt) (if po1 (setq p1 (nth po1 pts))) (if po2 (setq p2 (nth po2 pts))) (if (and p1 (not p2)) (setq pt (copy-list p1))) (if (and p2 (not p1)) (setq pt (copy-list p2))) (if (and p1 2) (setq pt (list (linear-interpol (nth po1 segpos) (nth po2 segpos) (car p1) (car p2) sp) (linear-interpol (nth po1 segpos) (nth po2 segpos) (cadr p1) (cadr p2) sp)))) pt)))) ) (let ((rep (om-copy self))) (when dec (change-precision rep dec)) (setq xylist (mat-trans samples)) (set-bpf-points rep :x (car xylist) :y (cadr xylist)) (values (om-init-instance rep) (car xylist) (cadr xylist)) ;;;npts-per-seg ))) ;;;=========================================== ;;; OM-SAMPLE FOR BPF ;;;=========================================== (defmethod* bpf-sample ((self bpf) xmin xmax (nbsamples integer) &optional (coeff 1) (nbdec 0)) :initvals (list (make-instance 'bpf) nil nil 10 1 0) :indoc '("a BPF" "a number" "a number" "an integer" "a number" "an integer") :icon :bpf-sample :doc "DEPRECATED - see OM-SAMPLE" (let ((min (or xmin (first (x-points self)))) (max (or xmax (car (last (x-points self)))))) (cond ((= 0 nbsamples) 0) ((= 1 nbsamples) min) (t (let ((interpolation (interpole (x-points self) (y-points self) min max nbsamples))) (unless (= coeff 1) (setf interpolation (om* interpolation coeff))) (om-round interpolation nbdec)))))) ;;;=========================================== ;;; SPLINE CURVE FROM BPF ;;;=========================================== (defmethod* bpf-spline ((self bpf) (resolution integer) (degree integer)) :icon :bpf-spline :initvals '(nil 100 3) :indoc '("a BPF or BPC" "number of points" "interpolation degree") :numouts 3 :doc "Computes a B-Spline curve from the points in the BPF or BPC. B-Splines are smoothed curves where each point is computed by polynomial interpolation from a set of control points. Returned values : - The result as an object (BPF or BPC) (1st output) - The list of x points (2nd output) - The list of sample values (3rd output) <resolution> is the number of points in the resulting curve <degree> is the degree of the polynomial interpolation. higher degrees give smoother curves Note that splines are supposed to be computed from BPFs with reltively few control points. " (let* ((points (point-pairs self)) (N (- (length points) 1)) (knots (SplineKnots N degree)) (splc (SplineCurve2D points N knots degree resolution)) (xylist (mat-trans splc)) (rep (om-copy self))) (set-bpf-points rep :x (car xylist) :y (cadr xylist)) (values rep (car xylist) (cadr xylist) ))) ;;; Compatibility (defmethod* om-spline ((self bpf) (resolution integer) (degree integer)) :doc "Deprecated: See BPF-SPLINE." (bpf-spline self resolution degree)) ;;;=========================================== ;;; BPF INTERPOLATIONS ;;;=========================================== (defmethod* bpf-interpol ((first bpf) (second bpf) (steps number) &optional (curve 0.0) (decimals nil) (mode 'points)) :icon 'bpf-interpol :initvals '(nil nil 1 0.0 nil points) :indoc '("a bpf or bpc" "a bpf or bpc" "number of steps" "interpolation curve" "precision" "interpolation mode") :outdoc '("list of BPFs" "list of x-points" "list of y-points") :numouts 3 :menuins '((5 (("points to point" points) ("resample curves" sample)))) :doc "Interpolates between two BPFs or two BPCs (<first> and <second>). <steps> is the number of interpolated curves wanted, including <first> and <second>. 1 means one value between <first> and <seconds>. 2 will return only <first> and <second>. 3 will return <first> and <second> with one more curve in between. etc. <curve> in an exponential factor for the interpolation curve (0 = linear). <decimals> is the precision (number of decimals) in the returned curves (default NIL = precision of <first>). <mode> determines how interpolation is done : - 'points is point-by-point interpolation: the curves must have the same number of points, or the biggest one will be truncated. - 'sample means that the curves are resampled before interpolation. In case of BPfs, x-points will be added if needed so that the interpolated curves all have the same x points. In case of BPCs, the one with fewer points is resampled, then point-by-point interpolation is applied. Outputs 1) list of interpolated BPFs/BPCs 2) list of x-points 3) list of y-points " (cond ((equal mode 'points) (let ((interp-x (interpolation (x-points first) (x-points second) steps curve)) (interp-y (interpolation (y-points first) (y-points second) steps curve))) (values (loop for x1 in interp-x for y1 in interp-y collect (make-instance (type-of first) :x-points x1 :y-points y1 :decimals (or decimals (decimals first)))) interp-x interp-y))) ((equal mode 'sample) (let* ((allxpoints (sort (x-union (copy-list (x-points first)) (copy-list (x-points second))) '<)) (ypts-a (x-transfer first allxpoints)) (ypts-b (x-transfer second allxpoints)) (interp-y (interpolation ypts-a ypts-b steps curve))) (values (loop for ylist in interp-y collect (make-instance (type-of first) :x-points allxpoints :y-points ylist :decimals (or decimals (decimals first)))) (make-list steps :initial-element allxpoints) interp-y) ))) ) (defmethod* bpf-interpol ((first bpc) (second bpc) (steps number) &optional (curve 0.0) (decimals nil) (mode 'points)) (cond ((equal mode 'points) (let ((interp-x (interpolation (x-points first) (x-points second) steps curve)) (interp-y (interpolation (y-points first) (y-points second) steps curve))) (values (loop for x1 in interp-x for y1 in interp-y collect (make-instance (type-of first) :x-points x1 :y-points y1 :decimals (or decimals (decimals first)))) interp-x interp-y) )) ((equal mode 'sample) (let ((l1 (length (point-list first))) (l2 (length (point-list second)))) (cond ((> l1 l2) (bpf-interpol first (om-sample second l1) steps curve decimals 'points)) ((> l2 l1) (bpf-interpol (om-sample first l2) second steps curve decimals 'points)) (t (bpf-interpol first second steps curve decimals 'points))) )) )) ;;;=========================================== ;;; BPF TRANSFORMATIONS ;;;=========================================== (defmethod* bpf-scale ((self bpf) &key x1 x2 y1 y2) :icon :bpf :indoc '("a BPF" "xmin" "xmax" "ymin" "ymax") :initvals '(nil 0 100 0 100) :doc "Rescales <self> betwenn the supplied X (<x1>,<x2>) and/or Y (<y1>,<y2>) values." (let* ((xp (x-points self)) (yp (y-points self)) (xlist (if (or x1 x2) (om-scale xp (or x1 (car xp)) (or x2 (last-elem xp))) xp)) (ylist (if (or y1 y2) (om-scale yp (or y1 (car yp)) (or y2 (last-elem yp))) yp)) (rep (om-copy self))) (set-bpf-points rep :x xlist :y ylist) (om-init-instance rep) )) (defmethod! bpf-offset ((self bpf) offset) :icon :bpf :initvals '(nil 0) :indoc '("a bpf" "x offset") :outdoc '("offset BPF") :numouts 1 :doc "Generates a new BPF by addif <offset> to the x-points of <self>" (let ((newbpf (clone self))) (setf (x-points newbpf) (om+ (x-points self) offset)) newbpf)) (defmethod! bpf-crossfade ((bpf1 bpf) (bpf2 bpf) &key xfade-profile) :icon :bpf :initvals '(nil nil nil nil) :indoc '("bpf" "bpf" "crossfade profile (bpf)") :outdoc '("merged/crossfaded BPF") :numouts 1 :doc "Generates a new BPF by crossfading the overlapping interval between BPF1 and BPF2. <xfade-profile> determines the general crossfade profile (default = linear). " (let* ((first bpf1) (second bpf2)) (when (< (caar (point-pairs second)) (caar (point-pairs first))) (setf first second) (setf second bpf1)) (let* ((t1 (car (car (point-pairs second)))) (t2 (car (last-elem (point-pairs first)))) (commonxpoints (band-filter (sort (x-union (copy-list (x-points first)) (copy-list (x-points second))) '<) (list (list t1 t2)) 'pass)) (scaled-profile (if (< t1 t2) (if xfade-profile (om-make-bpf 'bpf (om-scale (x-points xfade-profile) (car commonxpoints) (last-elem commonxpoints)) (om-scale (y-points xfade-profile) 0.0 1.0) 3) (om-make-bpf 'bpf (list (car commonxpoints) (last-elem commonxpoints)) '(0.0 1.0) 3) ) (om-make-bpf 'bpf '(0.5 0.5) '(0.0 1.0) 3) )) (seg1 (loop for p in (point-pairs first) while (< (car p) t1) collect p)) (seg2 (loop for p in (point-pairs second) when (> (car p) t2) collect p)) (segx (loop for xp in commonxpoints collect (let ((y1 (x-transfer first xp)) (y2 (x-transfer second xp)) (itpfact (x-transfer scaled-profile xp))) (list xp (linear-interpol 0.0 1.0 y1 y2 itpfact))))) ) (om-make-bpf (type-of bpf1) (mapcar 'car (append seg1 segx seg2)) (mapcar 'cadr (append seg1 segx seg2)) (max (decimals bpf1) (decimals bpf2))) )))
18,730
Common Lisp
.lisp
364
39.041209
281
0.509595
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
dbca033fcc945a560a8d1d1ba85917ab05166083ad8f21ee69c39a4ccc304dcd
761
[ -1 ]
762
bpf-editor.lisp
cac-t-u-s_om-sharp/src/packages/basic/bpf-bpc/bpf-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;distance treshold to add a new point in pen mode (defvar *add-point-distance-treshold* 5) (defclass bpf-editor (multi-display-editor-mixin OMEditor play-editor-mixin undoable-editor-mixin) ((edit-mode :accessor edit-mode :initform :mouse) (decimals :accessor decimals :initform 0 :initarg :decimals) ;;; multi-view (x-axis-key :accessor x-axis-key :initarg :x-axis-key :initform :x) (y-axis-key :accessor y-axis-key :initarg :y-axis-key :initform :y) (make-point-function :accessor make-point-function :initarg :make-point-function :initform 'om-make-bpfpoint) ;;; mini-dialog (point-editor :initform nil :accessor point-editor) ;;; timeline (timeline-editor :accessor timeline-editor :initform nil) )) ;;; background elements are just visible in the BPF/BPC/3DC editors ;;; can be pictures, speakers, etc. (defclass background-element () ()) (defmethod draw-background-element ((self background-element) view editor &optional x1 y1 x2 y2)) (defmethod object-default-edition-params ((self BPF)) '((:draw-style :default) (:background nil) (:display-min nil) (:display-max nil))) (defun x-axis-accessor (editor) (case (x-axis-key editor) (:x 'om-point-x) (:y 'om-point-y) (:z 'om-point-z) (:time 'om-point-time))) (defun y-axis-accessor (editor) (case (y-axis-key editor) (:x 'om-point-x) (:y 'om-point-y) (:z 'om-point-z))) (defun editor-make-point (editor x y) (funcall (make-point-function editor) x y)) (defun editor-point-x (editor point) (funcall (x-axis-accessor editor) point)) (defun editor-point-y (editor point) (funcall (y-axis-accessor editor) point)) (defun editor-point-set-x (editor point x) (funcall 'om-point-set point (x-axis-key editor) x)) (defun editor-point-set-y (editor point y) (funcall 'om-point-set point (y-axis-key editor) y)) (defmethod additional-box-attributes ((self bpf)) '((:background "sets one or more background-element(s) in the editor" nil) (:display-min "sets a min y-value for display" nil) (:display-max "sets a max y-value for display" nil))) (defmethod editor-window-init-size ((self bpf-editor)) (om-make-point 550 400)) (defmethod object-has-editor ((self bpf)) t) (defmethod get-editor-class ((self bpf)) 'bpf-editor) ;;; from play-editor-mixin (defmethod get-obj-to-play ((self bpf-editor)) (object-value self)) (defmethod handle-multi-display ((self bpf-editor)) t) (defmethod get-object-slots-for-undo ((self bpf)) (append (call-next-method) '(point-list name))) (defmethod update-after-state-change ((self bpf-editor)) (update-view-contents (get-g-component self :default-view)) (set-decimals-in-editor self (decimals (object-value self))) (call-next-method)) (defparameter +bpf-editor-modes+ '(:mouse :pen :hand)) ; :zoomin :zoomout)) (defclass bpf-bpc-panel (OMEditorView multi-view-editor-view) ((scale-fact :accessor scale-fact :initarg :scale-fact :initform 1) (x-ruler :accessor x-ruler :initform nil) (y-ruler :accessor y-ruler :initform nil)) (:default-initargs :input-model (om-input-model :touch-pan t))) (defmethod set-x-ruler-range ((self bpf-bpc-panel) x1 x2) (when (x-ruler self) (set-ruler-range (x-ruler self) x1 x2))) (defmethod set-y-ruler-range ((self bpf-bpc-panel) y1 y2) (when (y-ruler self) (set-ruler-range (y-ruler self) y1 y2))) (defclass bpf-panel (bpf-bpc-panel x-cursor-graduated-view y-graduated-view) ()) (defmethod get-curve-panel-class ((self bpf-editor)) 'bpf-panel) (defmethod pix-to-x ((self bpf-bpc-panel) pix) (/ (call-next-method) (scale-fact self))) (defmethod dpix-to-dx ((self bpf-bpc-panel) dpix) (/ (call-next-method) (scale-fact self))) (defmethod x-to-pix ((self bpf-bpc-panel) x) (call-next-method self (* x (scale-fact self)))) (defmethod dx-to-dpix ((self bpf-bpc-panel) dx) (call-next-method self (* dx (scale-fact self)))) (defmethod pix-to-y ((self bpf-bpc-panel) pix) (/ (call-next-method) (scale-fact self))) (defmethod dpix-to-dy ((self bpf-bpc-panel) dpix) (/ (call-next-method) (scale-fact self))) (defmethod y-to-pix ((self bpf-bpc-panel) y) (call-next-method self (* y (scale-fact self)))) (defmethod dy-to-dpix ((self bpf-bpc-panel) dy) (call-next-method self (* dy (scale-fact self)))) ;;;========================== ;;; Special BPC ;;;========================== (defclass bpc-editor (bpf-editor) ;;;reference time for gesture capture while drawing (BPC only) ((gesture-time-ref :accessor gesture-time-ref :initform 0) (gesture-interval-time :initform 500 :accessor gesture-interval-time :initarg :gesture-interval-time)) (:default-initargs :make-point-function 'om-make-tpoint)) (defmethod get-editor-class ((self bpc)) 'bpc-editor) (defclass bpc-panel (bpf-bpc-panel x-graduated-view y-graduated-view) ()) (defmethod get-curve-panel-class ((self bpc-editor)) 'bpc-panel) ;;;========================== ;;; play-editor-mixin methods ;;;========================== (defmethod cursor-panes ((self bpf-editor)) (cons (get-g-component self :main-panel) (if (timeline-editor self) (cursor-panes (timeline-editor self))))) (defmethod cursor-panes ((self bpc-editor)) (when (timeline-editor self) (cursor-panes (timeline-editor self)))) (defmethod play-editor-callback ((self bpc-editor) time) (call-next-method) ;;; no very good :) (om-invalidate-view (get-g-component self :main-panel))) (defmethod set-time-display ((self bpc-editor) time) (set-time-display (timeline-editor self) time) (call-next-method)) ;;;========================== ;;; SYSTEM CALLBACKS ;;;========================== (defmethod init-editor ((self bpf-editor)) (setf (decimals self) (decimals (object-value self))) (setf (timeline-editor self) (make-instance 'timeline-editor :object (object self) :container-editor self))) (defmethod init-editor ((self bpc-editor)) (call-next-method) (time-sequence-update-internal-times (object-value self) self)) (defmethod make-timeline-left-item ((self bpf-editor) id) (om-make-view 'om-view :size (omp 30 15))) (defmethod draw-modes-for-object ((self bpf-editor)) '(:default :points :lines :histogram)) ;;; for a BPF editor the 'main-view' is the whole layout (defmethod make-editor-window-contents ((editor bpf-editor)) (let* ((object (object-value editor)) (panel (om-make-view (get-curve-panel-class editor) :size (omp 50 100) :direct-draw t :bg-color (om-def-color :white) :scrollbars nil :scale-fact (expt 10 (decimals editor)) :editor editor)) (rx (om-make-view 'x-ruler-view :related-views (list panel) :size (omp nil 20) :bg-color (om-def-color :white) :decimals (decimals editor))) (ry (om-make-view 'y-ruler-view :related-views (list panel) :size (omp 30 nil) :bg-color (om-def-color :white) :decimals (decimals editor))) (mousepos-txt (om-make-graphic-object 'om-item-text :size (omp 200 20))) ;(name-txt (om-make-graphic-object 'om-item-text :size (omp 60 16) :text (name object))) (timeline-editor (timeline-editor editor)) (timeline (om-make-layout 'om-row-layout)) (top-area (om-make-layout 'om-row-layout :align :center :ratios '(nil nil 0.5 0.05 0.05) :subviews (list nil mousepos-txt nil (make-time-monitor editor :time (if (action object) 0 nil)) (om-make-layout 'om-row-layout :subviews (list (make-play-button editor :enable t) (make-repeat-button editor :enable t) (make-pause-button editor :enable t) (make-stop-button editor :enable t))) ))) (bottom-area nil) (font (om-def-font :gui))) ;create the bottom area (needed to add remove the timeline-time-monitor (setf bottom-area (om-make-layout 'om-row-layout :align :bottom :size (omp nil 40) :subviews (list (om-make-di 'om-simple-text :text "Display:" :size (omp 40 20) :font font) (om-make-di 'om-popup-list :items (draw-modes-for-object editor) :size (omp 80 24) :font font :value (editor-get-edit-param editor :draw-style) :di-action #'(lambda (list) (editor-set-edit-param editor :draw-style (om-get-selected-item list)))) nil (om-make-di 'om-check-box :text "indices" :size (omp 60 24) :font font :checked-p (editor-get-edit-param editor :show-indices) :di-action #'(lambda (item) (editor-set-edit-param editor :show-indices (om-checked-p item)))) (om-make-di 'om-check-box :text "times" :size (omp 60 24) :font font :checked-p (editor-get-edit-param editor :show-times) :di-action #'(lambda (item) (editor-set-edit-param editor :show-times (om-checked-p item)))) (om-make-di 'om-check-box :text "grid" :size (omp 45 24) :font font :checked-p (editor-get-edit-param editor :grid) :di-action #'(lambda (item) (editor-set-edit-param editor :grid (om-checked-p item)))) (when timeline-editor (om-make-di 'om-check-box :text "timeline" :size (omp 120 24) :font font :checked-p (editor-get-edit-param editor :show-timeline) :di-action #'(lambda (item) (editor-set-edit-param editor :show-timeline (om-checked-p item)) (clear-timeline timeline-editor) (om-invalidate-view timeline) (when (om-checked-p item) (make-timeline-view timeline-editor)) (om-update-layout (main-view editor))) )) nil ))) (set-g-component editor :mousepos-txt mousepos-txt) (set-g-component editor :main-panel panel) (setf (x-ruler panel) rx (y-ruler panel) ry) ;timeline (when timeline-editor (set-g-component timeline-editor :main-panel timeline) (when (editor-get-edit-param editor :show-timeline) (make-timeline-view timeline-editor))) (om-make-layout 'om-row-layout :ratios '(9.9 0.1) :subviews (list (om-make-layout 'om-column-layout :ratios '(0.96 nil 0.02) :subviews (list (om-make-layout 'om-grid-layout :align :right :dimensions '(2 3) :delta 2 :ratios '((0.01 0.99) (0.01 0.98 0.01)) :subviews (list nil top-area ry panel nil rx) ) (when timeline timeline) bottom-area)) ;;; default "property" editor: (call-next-method))) )) (defmethod initialize-instance :after ((self bpf-bpc-panel) &rest args) (let* ((editor (editor self)) (mode-buttons (list (om-make-graphic-object 'om-icon-button :position (omp 10 5) :size (omp 20 20) :icon :mouse :icon-pushed :mouse-pushed :lock-push t :pushed (equal (edit-mode editor) :mouse) :id :mouse :action #'(lambda (b) (declare (ignore b)) (editor-set-edit-mode editor :mouse))) (om-make-graphic-object 'om-icon-button :position (omp 30 5) :size (omp 20 20) :icon :pen :icon-pushed :pen-pushed :lock-push t :pushed (equal (edit-mode editor) :pen) :id :pen :action #'(lambda (b) (declare (ignore b)) (editor-set-edit-mode editor :pen))) (om-make-graphic-object 'om-icon-button :position (omp 50 5) :size (omp 20 20) :icon :hand :icon-pushed :hand-pushed :lock-push t :pushed (equal (edit-mode editor) :hand) :id :hand :action #'(lambda (b) (declare (ignore b)) (editor-set-edit-mode editor :hand)))))) (set-g-component editor :mode-buttons mode-buttons) (apply 'om-add-subviews (cons self mode-buttons)) )) ;;; happens when the window is already built (defmethod init-editor-window ((editor bpf-editor)) (call-next-method) (reinit-ranges editor)) (defmethod om-view-cursor ((self bpf-bpc-panel)) (let ((editor (or (editor self) (editor (om-view-window self))))) (case (edit-mode editor) (:pen (if (om-add-key-down) nil (om-get-cursor :pen))) (:hand (om-get-cursor :hand)) ;(:zoomin (om-get-cursor :loupe)) (otherwise (if (om-add-key-down) (om-get-cursor :add) nil))))) (defmethod set-decimals-in-editor ((self bpf-editor) val) (let ((panel (get-g-component self :main-panel))) (when (x-ruler panel) (setf (decimals (x-ruler panel)) val) (scale-ruler (x-ruler panel) (expt 10 (- val (decimals self))))) (when (y-ruler panel) (setf (decimals (y-ruler panel)) val) (scale-ruler (y-ruler panel) (expt 10 (- val (decimals self))))) (when panel (setf (scale-fact panel) (expt 10 val))) (setf (decimals self) val))) ;;; called at eval (defmethod update-to-editor ((editor bpf-editor) (from t)) (call-next-method) (let ((object (object-value editor))) (when (g-components editor) (when object (set-decimals-in-editor editor (decimals object)) (enable-play-controls editor (action object))) (om-invalidate-view (get-g-component editor :main-panel))) (when (timeline-editor editor) (update-to-editor (timeline-editor editor) editor)))) (defmethod update-to-editor ((editor bpf-editor) (from timeline-editor)) (call-next-method) (om-invalidate-view (get-g-component editor :main-panel)) (update-timeline-editor editor) (report-modifications editor)) (defmethod update-to-editor ((self bpc-editor) (from t)) (call-next-method) (time-sequence-update-internal-times (object-value self))) ;;; called from the default-editor part ;;; update: I think this is never called: the arguments are (view object) (defmethod update-after-prop-edit ((view OMEditorWindow) (editor bpf-editor)) (let ((value (object-value editor)) (box (object editor))) (editor-invalidate-views editor) (when box (setf (name box) (name value))) (enable-play-controls editor (action value)) (report-modifications editor))) (defmethod editor-invalidate-views ((self bpf-editor)) (call-next-method) (om-invalidate-view (get-g-component self :main-panel)) (when (timeline-editor self) (editor-invalidate-views (timeline-editor self)))) ;;;========================== ;;; DRAW ;;;========================== (defmethod time-to-draw ((self bpf) (editor bpf-editor) pt i) (om-point-x pt)) ;times are negatives values if they are not user defined (for display differenciation) (defmethod time-to-draw ((self bpc) editor pt i) (or (om-point-time pt) (let ((ti (nth i (time-sequence-get-internal-times self)))) (and ti (- ti))))) (defun draw-bpf-point (p editor &key index time selected) (cond ((and time (equal (player-get-object-state (player editor) (object-value editor)) :play) (< (abs time) (player-get-object-time (player editor) (object-value editor))) ) (om-with-fg-color (om-def-color :dark-red) (om-draw-circle (car p) (cadr p) 4 :fill t))) (selected (om-with-fg-color (om-def-color :dark-red) (om-draw-circle (car p) (cadr p) 4 :fill t))) ;;; draw normal except if lines only ((not (equal (editor-get-edit-param editor :draw-style) :lines)) (om-draw-circle (car p) (cadr p) 3 :fill t)) (t nil)) (when index (om-draw-string (car p) (+ (cadr p) 15) (number-to-string index))) (when (and time (editor-get-edit-param editor :show-times)) (om-with-fg-color (if (minusp time) (om-def-color :gray) (om-def-color :dark-blue) ) (om-draw-string (car p) (- (cadr p) 15) (number-to-string (abs time) 0)))) ) (defun draw-interpol-point (p editor &key time) (if (and time (equal (player-get-object-state (player editor) (object-value editor)) :play) (>= (player-get-object-time (player editor) (object-value editor)) time)) (om-with-fg-color (om-def-color :dark-red) (om-draw-circle (car p) (cadr p) 1 :fill nil)) (om-draw-circle (car p) (cadr p) 1 :fill nil) )) (defun point-visible-p (pt x1 x2 y1 y2) (and (> (car pt) x1) (< (car pt) x2) (> (cadr pt) y1) (< (cadr pt) y2))) (defmethod draw-one-bpf ((bpf bpf) view editor foreground? &optional x1 x2 y1 y2) (om-trap-errors (let ((pts (point-list bpf))) (when pts (let ((first-pt (list (x-to-pix view (editor-point-x editor (car pts))) (y-to-pix view (editor-point-y editor (car pts))))) (selection (and foreground? (selection editor))) (show-indice (editor-get-edit-param editor :show-indices))) (cond ;;; draw only points ((equal (editor-get-edit-param editor :draw-style) :points) (draw-bpf-point first-pt editor :selected (and (consp selection) (find 0 selection)) :index (and foreground? show-indice 0) :time (and foreground? (time-to-draw bpf editor (car pts) 0))) ;TODO Change drawing args here ! (loop for pt in (cdr pts) for i = 1 then (1+ i) do (let ((p (list (x-to-pix view (editor-point-x editor pt)) (y-to-pix view (editor-point-y editor pt))))) (when (point-visible-p p x1 x2 y1 y2) (draw-bpf-point p editor :selected (and (consp selection) (find i selection)) :index (and foreground? show-indice i) :time (and foreground? (time-to-draw bpf editor pt i))) )))) ;;; histogram ((equal (editor-get-edit-param editor :draw-style) :histogram) (let ((origin-y (y-to-pix view (editor-point-y editor (omp 0 0))))) (loop for i from 0 to (1- (length pts)) do (let* ((pt (nth i pts)) (x (x-to-pix view (editor-point-x editor pt))) (y (y-to-pix view (editor-point-y editor pt))) (next-pt (nth (1+ i) pts)) (next-x (if next-pt (x-to-pix view (editor-point-x editor next-pt)) (if (plusp i) ;;; repeat last width (let ((prev-pt (nth (1- i) pts))) (+ x (- x (x-to-pix view (editor-point-x editor prev-pt))))) ;;; last case: only one point (+ x 100))))) (om-draw-rect x origin-y (- next-x x) (- y origin-y) :fill nil) (om-draw-rect x origin-y (- next-x x) (- y origin-y) :fill t :color (om-def-color :gray)) (draw-bpf-point (list x y) editor :selected (and (consp selection) (find i selection)) :index (and foreground? show-indice i) :time (and foreground? (time-to-draw bpf editor pt i))) (om-draw-string (+ x 2) (- origin-y 4) (format nil "~D" (om-point-y pt)) :font (om-def-font :tiny) :color (om-def-color :white)) )) )) ;;; draw lines (with/without points) (t (draw-bpf-point first-pt editor :selected (and (consp selection) (find 0 selection)) :index (and foreground? show-indice 0) :time (and foreground? (time-to-draw bpf editor (car pts) 0))) ;TODO Change drawing args here ! (let ((pt-list (loop for rest on pts for i = 1 then (1+ i) while (cadr rest) append (let* ((p1 (car rest)) (p2 (cadr rest)) (pp1 (list (x-to-pix view (editor-point-x editor p1)) (y-to-pix view (editor-point-y editor p1)))) (pp2 (list (x-to-pix view (editor-point-x editor p2)) (y-to-pix view (editor-point-y editor p2))))) ;(when ;(or (point-visible-p pp1 x xmax y ymax) ; (point-visible-p pp2 x xmax y ymax) ; (and (> x (car pp1)) (< x (car pp2)))) (unless (or (and (< (car pp1) x1) (< (car pp2) x1)) (and (> (car pp1) x2) (> (car pp2) x2))) ;;; will not draw the point if line-only, except if selected etc. (draw-bpf-point pp2 editor :selected (and (consp selection) (find i selection)) :index (and foreground? show-indice i) :time (and foreground? (time-to-draw bpf editor p2 i))) (append pp1 pp2) ) )))) (om-with-line-size (if (find T selection) 2 1) (om-draw-lines pt-list)) ))) (when (number-? (interpol bpf)) (let ((interpol-times (arithm-ser (get-first-time bpf) (get-obj-dur bpf) (number-number (interpol bpf))))) (loop for time in interpol-times do (let ((new-p (time-sequence-make-timed-item-at bpf time))) (draw-interpol-point (list (x-to-pix view (editor-point-x editor new-p)) (y-to-pix view (editor-point-y editor new-p))) editor :time (and foreground? time)))))) ))))) (defmethod om-draw-contents-area ((self bpf-bpc-panel) x y w h) (let* ((editor (editor self)) (obj (object-value editor)) (xmax (+ x w)) (ymax (+ y h))) (when obj (om-with-font (om-def-font :normal) ;;; GRID (when (editor-get-edit-param editor :grid) ;(om-with-line '(2 2) ;; seems tpo cost a lot in drawing... (om-with-fg-color (om-make-color 0.95 0.95 0.95) (draw-grid-from-ruler self (x-ruler self)) (draw-grid-from-ruler self (y-ruler self)) )) ;;; AXES (om-with-fg-color (om-def-color :gray) (let ((center (list (x-to-pix self 0) (y-to-pix self 0)))) (when (and (> (cadr center) 0) (< (cadr center) (h self))) (om-draw-line 0 (cadr center) (w self) (cadr center))) (when (and (> (car center) 0) (< (car center) (w self))) (om-draw-line (car center) 0 (car center) (h self))) )) (mapc #'(lambda (elt) (draw-background-element elt self editor x y xmax ymax)) (list! (get-edit-param (object editor) :background))) ;;; draw multi ? (when (multi-display-p editor) (loop for bg-bpf in (remove obj (multi-obj-list editor)) do (om-with-fg-color (om-make-color-alpha (or (color bg-bpf) (om-def-color :dark-gray)) 0.4) (draw-one-bpf bg-bpf self editor nil x xmax y ymax)))) (when (point-list obj) (om-with-fg-color (if (find T (selection editor)) (om-def-color :dark-red) (or (color obj) (om-def-color :dark-gray))) (draw-one-bpf obj self editor t x xmax y ymax) )) )) )) ;;;========================== ;;; MENUS ;;;========================== (defun bpf-edit-menu-items (self) (list (om-make-menu-comp (list (om-make-menu-item "Undo" #'(lambda () (funcall (undo-command self))) :key "z" :enabled #'(lambda () (and (undo-command self) t))) (om-make-menu-item "Redo" #'(lambda () (funcall (redo-command self))) :key "Z" :enabled #'(lambda () (and (redo-command self) t))))) (om-make-menu-comp (list (om-make-menu-item "Delete selection" #'(lambda () (funcall (clear-command self))) :enabled (and (clear-command self) (selection self) t)) (om-make-menu-item "Cleanup duplicate-coordinate points" #'(lambda () (cleanup-bpf-points self))) )) (om-make-menu-comp (list (om-make-menu-item "Select All" #'(lambda () (funcall (select-all-command self))) :key "a" :enabled (and (select-all-command self) t)))) (om-make-menu-comp (list (om-make-menu-item "Reverse Points" #'(lambda () (reverse-points self)) :key "r" ))) (om-make-menu-comp (list (om-make-menu-item "OSC Input Manager" #'(lambda () (funcall (open-osc-manager-command self))) :enabled (and (open-osc-manager-command self) t)))) )) (defmethod om-menu-items ((self bpf-editor)) (remove nil (list (main-app-menu-item) (om-make-menu "File" (default-file-menu-items self)) (om-make-menu "Edit" (bpf-edit-menu-items self)) (om-make-menu "Windows" (default-windows-menu-items self)) (om-make-menu "Help" (default-help-menu-items self)) ))) (defmethod select-all-command ((self bpf-editor)) #'(lambda () (setf (selection self) (list T)) (update-timeline-editor self) (editor-invalidate-views self) (select-bpf self))) (defmethod clear-command ((self bpf-editor)) #'(lambda () (store-current-state-for-undo self) (delete-editor-selection self) (report-modifications self) (editor-invalidate-views self))) (defmethod open-osc-manager-command ((self bpf-editor)) nil) ;;;========================== ;;; ACTIONS ;;;========================== (defmethod editor-set-edit-mode ((self bpf-editor) mode) (mapcar #'(lambda (b) (if (equal mode (id b)) (button-select b) (button-unselect b))) (get-g-component self :mode-buttons)) (setf (edit-mode self) mode) (om-set-view-cursor (get-g-component self :main-panel) (om-view-cursor (get-g-component self :main-panel)))) ;;; depending on where is the panel... (defmethod position-display ((editor t) pos-pix) nil) (defmethod position-display ((editor bpf-editor) pos-pix) (when (get-g-component editor :mousepos-txt) (let* ((decimals (decimals editor)) (point (omp (pix-to-x (get-g-component editor :main-panel) (om-point-x pos-pix)) (pix-to-y (get-g-component editor :main-panel) (om-point-y pos-pix))))) (om-set-text (get-g-component editor :mousepos-txt) (if (zerop decimals) (format nil "[~D,~D]" (round (om-point-x point)) (round (om-point-y point))) (format nil (format nil "[~~,~DF,~~,~DF]" decimals decimals) (om-point-x point) (om-point-y point)))) ) )) (defmethod reinit-ranges ((self bpf-editor)) ;;; ignore bg-pict for the moment (bpf-picture-ranges (pict (editor self))) (let ((bpf (object-value self)) (scaler (expt 10 (decimals self)))) (when bpf (let ((ranges (space-ranges (loop for x in (mapcar (x-axis-accessor self) (point-list bpf)) for y in (mapcar (y-axis-accessor self) (point-list bpf)) minimize x into x1 maximize x into x2 minimize y into y1 maximize y into y2 finally (return (list x1 x2 y1 y2))) 0.05 (/ 100 (expt 10 (decimals self)))))) (set-x-ruler-range (get-g-component self :main-panel) (* (nth 0 ranges) scaler) (* (nth 1 ranges) scaler)) (set-y-ruler-range (get-g-component self :main-panel) (* (nth 2 ranges) scaler) (* (nth 3 ranges) scaler)) )) )) (defmethod set-rulers-from-selection ((self bpf-editor) x1 x2 y1 y2) (let ((panel (get-g-component self :main-panel))) (set-ruler-range (x-ruler panel) (pix-to-x panel x1) (pix-to-x panel x2)) (set-ruler-range (y-ruler panel) (pix-to-y panel y1) (pix-to-y panel y2)))) (defmethod find-clicked-point-or-curve ((editor bpf-editor) (object bpf) position) (let ((points (point-list object)) (panel (get-g-component editor :main-panel))) (when points (let* ((xx (pix-to-x panel (om-point-x position))) (pos (or (position xx points :key #'(lambda (p) (editor-point-x editor p)) :test '>= :from-end t) 0)) (p1 (nth pos points)) (p2 (when (< (1+ pos) (length points)) (nth (1+ pos) points))) (delta 4)) (or (and p1 (om-point-in-rect-p position (- (round (x-to-pix panel (editor-point-x editor p1))) delta) (- (round (y-to-pix panel (editor-point-y editor p1))) delta) (* delta 2) (* delta 2)) pos) (and p2 (om-point-in-rect-p position (- (x-to-pix panel (editor-point-x editor p2)) delta) (- (y-to-pix panel (editor-point-y editor p2)) delta) (* delta 2) (* delta 2)) (1+ pos)) (and p1 p2 (not (find (editor-get-edit-param editor :draw-style) '(:points :histogram))) (om-point-in-line-p position (om-make-point (x-to-pix panel (editor-point-x editor p1)) (y-to-pix panel (editor-point-y editor p1))) (om-make-point (x-to-pix panel (editor-point-x editor p2)) (y-to-pix panel (editor-point-y editor p2))) delta) t) ) )))) (defmethod find-clicked-point-or-curve ((editor bpc-editor) (object bpc) position) (let ((points (point-list object)) (panel (get-g-component editor :main-panel))) (when points (let* ((delta 4) (rep nil)) (if (om-point-in-rect-p position (- (x-to-pix panel (editor-point-x editor (car points))) delta) (- (y-to-pix panel (editor-point-y editor (car points))) delta) (* delta 2) (* delta 2)) (setf rep 0) (loop for restpoints on points for i = 1 then (1+ i) while (and (cdr restpoints) (not rep)) do (let ((p (cadr restpoints))) (if (om-point-in-rect-p position (- (x-to-pix panel (editor-point-x editor p)) delta) (- (y-to-pix panel (editor-point-y editor p)) delta) (* delta 2) (* delta 2)) (setf rep i) (if (not (equal (editor-get-edit-param editor :draw-style) :points)) (setf rep (om-point-in-line-p position (om-make-point (x-to-pix panel (editor-point-x editor p)) (y-to-pix panel (editor-point-y editor p))) (om-make-point (x-to-pix panel (editor-point-x editor (car restpoints))) (y-to-pix panel (editor-point-y editor (car restpoints)))) delta))) )))) rep)))) ;;; do nothing... (defmethod select-bpf ((editor bpf-editor) &optional n)) (defmethod points-in-area ((editor bpf-editor) p1 p2) (let* ((panel (get-g-component editor :main-panel)) (x1 (pix-to-x panel (om-point-x p1))) (x2 (pix-to-x panel (om-point-x p2))) (y1 (pix-to-y panel (om-point-y p1))) (y2 (pix-to-y panel (om-point-y p2))) (xmin (min x1 x2)) (xmax (max x1 x2)) (ymin (min y1 y2)) (ymax (max y1 y2)) (points (point-list (object-value editor)))) (loop for p in points for i = 0 then (1+ i) when (and (>= (editor-point-x editor p) xmin) (<= (editor-point-x editor p) xmax) (>= (editor-point-y editor p) ymin) (<= (editor-point-y editor p) ymax)) collect i) )) ;;; return the position of the inserted point (defmethod add-point-at-pix ((editor bpf-editor) (object bpf) position &optional (time nil)) (let* ((panel (get-g-component editor :main-panel)) (new-point (editor-make-point editor (pix-to-x panel (om-point-x position)) (pix-to-y panel (om-point-y position))))) (insert-point object new-point))) ;;; systematically at the end of the point list (e.g. called when drawing) ;;; return the position of the inserted point (defmethod add-point-at-pix ((editor bpc-editor) (object bpc) position &optional (time nil)) (let* ((panel (get-g-component editor :main-panel)) (new-point (editor-make-point editor (pix-to-x panel (om-point-x position)) (pix-to-y panel (om-point-y position))))) (when time (setf (tpoint-time new-point) time)) (time-sequence-insert-timed-item-and-update object new-point))) ;;; insert at the correct place in BPF ;;; if the point exist : move it ;;; draw or not = the same ;;; return the position of the inserted point (defmethod insert-point-at-pix ((editor bpf-editor) (object bpf) position &optional (time nil)) (add-point-at-pix editor object position time)) ;;; insert at the correct place in BPC ;;; if in a segment, insert, else add at the end ;;; => don't call this in 'draw' mode ;;; return the position of the inserted point (defmethod insert-point-at-pix ((editor bpf-editor) (object bpc) position &optional (time nil)) (let* ((panel (get-g-component editor :main-panel)) (new-point (editor-make-point editor (pix-to-x panel (om-point-x position)) (pix-to-y panel (om-point-y position)))) (segment nil) (delta 4)) (loop for restpoints on (point-list object) for i = 1 then (1+ i) while (and (cdr restpoints) (not segment)) when (om-point-in-line-p position (om-make-point (x-to-pix panel (editor-point-x editor (car restpoints))) (y-to-pix panel (editor-point-y editor (car restpoints)))) (om-make-point (x-to-pix panel (editor-point-x editor (cadr restpoints))) (y-to-pix panel (editor-point-y editor (cadr restpoints)))) delta) do (setf segment i)) (when (and time (not segment)) (setf (tpoint-time new-point) time)) (time-sequence-insert-timed-item-and-update object new-point (or segment (length (point-list object)))) )) (defmethod move-editor-selection ((self bpf-editor) &key (dx 0) (dy 0)) (when (selection self) (let ((bpf (object-value self))) (cond ((find T (selection self)) (loop for point in (point-list bpf) do (editor-point-set-x self point (+ (editor-point-x self point) dx)) (editor-point-set-y self point (+ (editor-point-y self point) dy)))) (t (let ((points (loop for pos in (selection self) collect (nth pos (point-list bpf))))) (funcall 'move-points-in-bpf bpf points dx dy (x-axis-key self) (y-axis-key self)))) )))) (defmethod delete-editor-selection ((self bpf-editor)) (when (selection self) (let ((object (object-value self))) (if (find T (selection self)) (setf (point-list object) nil) (mapcar #'(lambda (i) (remove-nth-point object i)) (sort (selection self) '>) )) (setf (selection self) nil) (time-sequence-update-internal-times object)) (when (timeline-editor self) (update-to-editor (timeline-editor self) self)))) (defmethod delete-editor-selection ((self bpc-editor)) (when (selection self) (let ((object (object-value self))) (if (find T (selection self)) (setf (point-list (object-value self)) nil) (mapcar #'(lambda (p) (time-sequence-remove-nth-timed-item object p)) (sort (selection self) '>))) (setf (selection self) nil) (time-sequence-update-internal-times object)) (update-to-editor (timeline-editor self) self))) (defmethod round-point-values ((editor bpf-editor)) (set-bpf-point-values (object-value editor))) (defmethod set-point-in-obj ((self bpf-editor) point values) (set-point-in-bpf (object-value self) point (car values) (cadr values)) (setf (point-list (object-value self)) (sort (point-list (object-value self)) '< :key 'om-point-x)) (when (container-editor self) (update-to-editor (container-editor self) self)) (editor-invalidate-views self)) (defmethod set-point-in-obj ((self bpc-editor) point values) (set-point-in-bpc (object-value self) point (car values) (cadr values) (cadddr values)) (setf (point-list (object-value self)) (sort (point-list (object-value self)) '< :key 'tpoint-internal-time)) (time-sequence-update-internal-times (object-value self)) (when (container-editor self) (update-to-editor (container-editor self) self)) (editor-invalidate-views self)) (defmethod close-point-editor ((self bpf-editor)) (when (point-editor self) (om-close-window (point-editor self)) (setf (point-editor self) nil))) (defmethod open-point-editor ((self bpf-editor) p &key (z nil z-supplied-p) (time nil time-supplied-p)) (let* ((x (om-point-x p)) (y (om-point-y p)) xt yt zt tt cb ob win) (let ((return-from-point-editor #'(lambda (item) (declare (ignore item)) (set-point-in-obj self p (list (read-number (om-dialog-item-text xt)) (read-number (om-dialog-item-text yt)) (and zt (read-number (om-dialog-item-text zt))) (and tt (read-number (om-dialog-item-text tt))))) (close-point-editor self)))) (setf xt (om-make-di 'om-editable-text :text (number-to-string x) :border t :bg-color (om-def-color :white) :size (omp 80 32)) ; :di-action return-from-point-editor) yt (om-make-di 'om-editable-text :text (number-to-string y) :border t :bg-color (om-def-color :white) :size (omp 80 32)) ; :di-action return-from-point-editor) zt (when z-supplied-p (om-make-di 'om-editable-text :text (number-to-string z) :border t :bg-color (om-def-color :white) :size (omp 80 32))) ; :di-action return-from-point-editor)) tt (when time-supplied-p (om-make-di 'om-editable-text :text (number-to-string time) :border t :bg-color (om-def-color :white) :size (omp 80 32))) ; :di-action return-from-point-editor)) cb (om-make-di 'om-button :text "Cancel" :size (omp 80 25) :di-action #'(lambda (b) (declare (ignore b)) (close-point-editor self))) ob (om-make-di 'om-button :text "OK" :size (omp 80 25) :default t :focus t :di-action return-from-point-editor)) (setf win (om-make-window 'om-no-border-win :resizable nil :position (om-add-points (om-view-position (window self)) (om-mouse-position (window self))) :win-layout (om-make-layout 'om-column-layout :ratios '(1 1 2) :align :left :subviews (list (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "X") xt)) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "Y") yt)) (when zt (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "Z") zt))) (when tt (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "Time" :size (omp 40 nil)) tt))) (om-make-view 'om-view :size (omp nil 20)) (om-make-layout 'om-row-layout :subviews (list cb ob)) ))))) (setf (point-editor self) win) (om-show-window win))) (defmethod edit-editor-point ((self bpf-editor) i) (let ((p (nth i (point-list (object-value self))))) (close-point-editor self) (open-point-editor self p))) (defmethod edit-editor-point ((self bpc-editor) i) (let* ((object (object-value self)) (p (nth i (point-list object)))) (close-point-editor self) (open-point-editor self p :time (nth i (times object))))) (defmethod reverse-points ((self bpf-editor)) (store-current-state-for-undo self) (with-schedulable-object (object-value self) (time-sequence-reverse (object-value self))) (editor-invalidate-views self) (update-to-editor (timeline-editor self) self) (report-modifications self)) (defmethod cleanup-bpf-points ((self bpf-editor)) (store-current-state-for-undo self) (with-schedulable-object (object-value self) (cleanup-points (object-value self))) (editor-invalidate-views self) (update-to-editor (timeline-editor self) self) (report-modifications self)) ;;;========================== ;;; USER ;;;========================== (defmethod om-view-mouse-motion-handler ((self bpf-bpc-panel) position) (let ((editor (editor self))) (position-display editor position))) (defmethod om-view-scrolled ((self bpf-bpc-panel) xy) nil) (defmethod om-view-doubleclick-handler ((self bpf-bpc-panel) position) (let ((editor (editor self))) (cond ((equal (edit-mode editor) :hand) (reinit-ranges editor)) (t (let ((selection (find-clicked-point-or-curve editor (object-value editor) position))) (set-selection editor selection) (om-invalidate-view self) (update-timeline-editor editor) (if (numberp selection) (edit-editor-point editor selection) (call-next-method)) ))) )) (defmethod om-view-doubleclick-handler ((self bpc-panel) position) (let* ((editor (editor self)) (obj (object-value editor))) (when obj (if (find-clicked-point-or-curve editor obj position) (call-next-method) (reinit-ranges editor)) ))) (defmethod om-view-click-handler ((self bpf-bpc-panel) position) (let* ((editor (editor self)) (p0 position) (t0 (get-internal-real-time)) (obj (object-value editor))) (close-point-editor editor) (when obj (case (edit-mode editor) (:mouse (cond ((om-add-key-down) (store-current-state-for-undo editor) (let ((p (with-schedulable-object obj (insert-point-at-pix editor obj position)))) (when p (setf (selection editor) (list p)) ; (position p (point-list obj)) (report-modifications editor) (om-invalidate-view self) (update-timeline-editor editor) ;;; move the new point (om-init-temp-graphics-motion self position nil :min-move 10 :motion #'(lambda (view pos) (declare (ignore view)) (let ((dx (dpix-to-dx self (- (om-point-x pos) (om-point-x p0)))) (dy (dpix-to-dy self (- (om-point-y p0) (om-point-y pos))))) (store-current-state-for-undo editor :action :move :item (selection editor)) (move-editor-selection editor :dx dx :dy dy) (setf p0 pos) (editor-invalidate-views editor) (position-display editor pos))) :release #'(lambda (view pos) (declare (ignore pos)) (reset-undoable-editor-action editor) (round-point-values editor) (time-sequence-update-internal-times obj) (notify-scheduler obj) (report-modifications editor) (om-invalidate-view view) (update-timeline-editor editor)) ) ))) (t (let ((selection (find-clicked-point-or-curve editor obj position))) (set-selection editor selection) (om-invalidate-view self) (update-timeline-editor editor) ;;; move the selection or select rectangle (if selection (let () (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (declare (ignore view)) (let ((dx (dpix-to-dx self (- (om-point-x pos) (om-point-x p0)))) (dy (dpix-to-dy self (- (om-point-y p0) (om-point-y pos))))) (store-current-state-for-undo editor :action :move :item (selection editor)) (move-editor-selection editor :dx dx :dy dy) (setf p0 pos) (position-display editor pos) (editor-invalidate-views editor) )) :release #'(lambda (view pos) (declare (ignore pos)) (reset-undoable-editor-action editor) (round-point-values editor) (time-sequence-update-internal-times obj) (notify-scheduler obj) (report-modifications editor) (om-invalidate-view view) (update-timeline-editor editor)) :min-move 4) ) (om-init-temp-graphics-motion self position (om-make-graphic-object 'selection-rectangle :position position :size (om-make-point 4 4)) :min-move 10 :release #'(lambda (view position) (set-selection editor (points-in-area editor p0 position)) (om-invalidate-view view) (update-timeline-editor editor) ) ) ))) )) (:pen (cond ((om-add-key-down) (om-init-temp-graphics-motion self position (om-make-graphic-object 'selection-rectangle :position position :size (om-make-point 4 4)) :min-move 10 :release #'(lambda (view position) (set-selection editor (points-in-area editor p0 position)) (om-invalidate-view view) (update-timeline-editor editor)) )) (t (set-selection editor nil) (when (equal (class-of editor) 'bpc-editor) (setf (gesture-time-ref editor) t0)) (let ((time-offset 0)) (when (and (bpc-p obj) (> (length (point-list obj)) 0)) ;find last time and add the default-offset (setf time-offset (+ (get-obj-dur obj) ;;; (gesture-interval-time editor) (let ((tlist (time-sequence-get-internal-times obj))) (cond ((> (length tlist) 1) (- (car (last tlist)) (car (last tlist 2)))) ((= (length tlist) 1) (if (plusp (car tlist)) (car tlist) (gesture-interval-time editor))) (t 0))) ))) (store-current-state-for-undo editor) (insert-point-at-pix editor obj position time-offset) (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (when (> (om-points-distance p0 pos) *add-point-distance-treshold*) (add-point-at-pix editor obj pos (+ (- (get-internal-real-time) t0) time-offset)) (setf p0 pos) (om-invalidate-view view) )) :release #'(lambda (view pos) (declare (ignore pos)) (time-sequence-update-internal-times obj) (notify-scheduler obj) (report-modifications editor) (om-invalidate-view view) (update-timeline-editor editor))) (report-modifications editor) (om-invalidate-view self) (update-timeline-editor editor) ))) ) (:hand (let ((curr-pos position)) (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (declare (ignore view)) (move-rulers self :dx (- (om-point-x pos) (om-point-x curr-pos)) :dy (- (om-point-y pos) (om-point-y curr-pos))) (setf curr-pos pos) )))) )))) (defmethod om-view-pan-handler ((self bpf-bpc-panel) position dx dy) (let ((fact 10)) (move-rulers self :dx (* fact dx) :dy (* fact dy)))) (defmethod om-view-zoom-handler ((self bpf-bpc-panel) position zoom) (zoom-rulers self :dx (- 1 zoom) :dy (- 1 zoom) :center position)) (defmethod move-rulers ((self bpf-bpc-panel) &key (dx 0) (dy 0)) (let* ((rx (x-ruler self)) (ry (y-ruler self)) (dxx (* (/ dx (w rx)) (- (v2 rx) (v1 rx)))) (dyy (* (/ dy (h ry)) (- (v2 ry) (v1 ry))))) (unless (or (and (plusp dxx) (vmin rx) (= (vmin rx) (v1 rx))) (and (minusp dxx) (vmax rx) (= (vmax rx) (v2 rx)))) (set-ruler-range rx (if (vmin rx) (max (vmin rx) (- (v1 rx) dxx)) (- (v1 rx) dxx)) (if (vmax rx) (min (vmax rx) (- (v2 rx) dxx)) (- (v2 rx) dxx)))) (unless (or (and (plusp dyy) (vmin ry) (= (vmin ry) (v1 ry))) (and (minusp dyy) (vmax ry) (= (vmax ry) (v2 ry)))) (set-ruler-range ry (if (vmin ry) (max (vmin ry) (- (v1 ry) dyy)) (+ (v1 ry) dyy)) (if (vmax ry) (min (vmax ry) (- (v2 ry) dyy)) (+ (v2 ry) dyy)))) )) (defmethod zoom-rulers ((panel bpf-bpc-panel) &key (dx 0.1) (dy 0.1) center) (let* ((position (or center (omp (* (w panel) .5) (* (h panel) .5)))) (x-pos (* (pix-to-x panel (om-point-x position)) (scale-fact panel))) (y-pos (* (pix-to-y panel (om-point-y position)) (scale-fact panel))) (curr-w (- (x2 panel) (x1 panel))) (curr-h (- (y2 panel) (y1 panel))) (new-w (round (* curr-w (1+ dx)))) (new-h (round (* curr-h (1+ dy)))) (new-x1 (round (- x-pos (/ (* (- x-pos (x1 panel)) new-w) curr-w)))) (new-y1 (round (- y-pos (/ (* (- y-pos (y1 panel)) new-h) curr-h))))) (set-x-ruler-range panel new-x1 (+ new-x1 new-w)) (set-y-ruler-range panel new-y1 (+ new-y1 new-h)) )) (defmethod editor-key-action ((editor bpf-editor) key) (let ((panel (get-g-component editor :main-panel)) (object (object-value editor))) (case key (#\- (zoom-rulers panel :dx -0.1 :dy -0.1)) ;;; zoom out : the ruler gets bigger (#\+ (zoom-rulers panel :dx 0.1 :dy 0.1)) ;;; zoom in : the ruler gets smaller (:om-key-delete (store-current-state-for-undo editor) (with-schedulable-object object (delete-editor-selection editor)) (report-modifications editor) (editor-invalidate-views editor) ) (:om-key-esc (setf (selection editor) nil) (call-next-method) ;;; will also reset the cursor interval (editor-invalidate-views editor)) (:om-key-left (store-current-state-for-undo editor :action :move-l :item (selection editor)) (with-schedulable-object object (move-editor-selection editor :dx (/ (- (get-units (x-ruler panel) (if (om-shift-key-p) 400 40))) (scale-fact panel))) (time-sequence-update-internal-times object)) (update-timeline-editor editor) (editor-invalidate-views editor) (report-modifications editor) ) (:om-key-right (store-current-state-for-undo editor :action :move-r :item (selection editor)) (with-schedulable-object object (move-editor-selection editor :dx (/ (get-units (x-ruler panel) (if (om-shift-key-p) 400 40)) (scale-fact panel))) (time-sequence-update-internal-times object)) (update-timeline-editor editor) (editor-invalidate-views editor) (report-modifications editor)) (:om-key-up (store-current-state-for-undo editor :action :move-u :item (selection editor)) (with-schedulable-object object (move-editor-selection editor :dy (/ (get-units (y-ruler panel) (if (om-shift-key-p) 400 40)) (scale-fact panel))) (time-sequence-update-internal-times object)) (update-timeline-editor editor) (editor-invalidate-views editor) (report-modifications editor)) (:om-key-down (store-current-state-for-undo editor :action :move-d :item (selection editor)) (with-schedulable-object object (move-editor-selection editor :dy (/ (- (get-units (y-ruler panel) (if (om-shift-key-p) 400 40))) (scale-fact panel))) (time-sequence-update-internal-times object)) (update-timeline-editor editor) (editor-invalidate-views editor) (report-modifications editor)) (:om-key-tab (let* ((p (position (edit-mode editor) +bpf-editor-modes+))) (when p (editor-set-edit-mode editor (nth (mod (1+ p) (length +bpf-editor-modes+)) +bpf-editor-modes+))))) (otherwise (when (timeline-editor editor) (editor-key-action (timeline-editor editor) key) )) ))) (defmethod get-color ((self bpf)) (or (color self) (om-def-color :dark-gray)))
62,669
Common Lisp
.lisp
1,099
39.310282
150
0.497328
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
ae2d7e15271bbba66c99b85fd2d4842a1f70c84abfb232bd3a39bdb5928fca6e
762
[ -1 ]
763
bpf.lisp
cac-t-u-s_om-sharp/src/packages/basic/bpf-bpc/bpf.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;=========================================== ;;; BPF OBJECT ;;;=========================================== (in-package :om) (defclass internalBPF (named-object schedulable-object object-with-action) ((point-list :initform nil :accessor point-list) (color :initform (om-def-color :black) :accessor color :initarg :color) (decimals :initform 2 :accessor decimals :initarg :decimals :documentation "precision (integer) [0-10]"))) (defmethod additional-slots-to-copy ((self internalBPF)) '(point-list action-fun)) ;;; POINTS IN BPF ;;; VIRTUALLY IMPLEMENTS TIMED-ITEM INTERFACE ;;; - adds the 'type' slot ;;; - time is X (defstruct (bpfpoint (:include oa::ompoint)) type) (defun om-make-bpfpoint (x y &optional type) (make-bpfpoint :x x :y y :type type)) ;;; necessary ? (defmethod make-load-form ((self bpfpoint) &optional env) (declare (ignore env)) `(make-bpfpoint :x ,(oa::ompoint-x self) :y ,(oa::ompoint-y self) :type ,(bpfpoint-type self))) (defmethod om-copy ((self bpfpoint)) (make-bpfpoint :x (bpfpoint-x self) :y (bpfpoint-y self) :type (bpfpoint-type self))) (defmethod om-point-set ((point bpfpoint) &key x y type) (if x (setf (bpfpoint-x point) x)) (if y (setf (bpfpoint-y point) y)) (if type (setf (bpfpoint-type point) type)) point) (defmethod om-point-set-values-from-point ((point bpfpoint) (from bpfpoint)) (setf (bpfpoint-x point) (bpfpoint-x from)) (setf (bpfpoint-y point) (bpfpoint-y from)) (setf (bpfpoint-type point) (bpfpoint-type from)) point) (defmethod item-get-time ((self bpfpoint)) (om-point-x self)) (defmethod item-set-time ((self bpfpoint) time) (om-point-set self :x time)) (defmethod item-get-internal-time ((self bpfpoint)) (om-point-x self)) (defmethod item-set-internal-time ((self bpfpoint) time) nil) (defmethod item-get-type ((self bpfpoint)) (bpfpoint-type self)) (defmethod item-set-type ((self bpfpoint) type) (om-point-set self :type type)) (defmethod items-merged-p ((i1 bpfpoint) (i2 bpfpoint)) (om-points-at-same-position i1 i2)) (defmethod items-distance ((i1 bpfpoint) (i2 bpfpoint)) (om-points-distance i1 i2)) (defclass* BPF (internalbpf time-sequence) ((x-points :initform '(0 2000) :initarg :x-points :documentation "X coordinates (list)") (y-points :initform '(0 100) :initarg :y-points :documentation "Y coordinates (list)") (gain :initform 1 :accessor gain :documentation "A gain factor for Y values")) (:icon 'bpf) (:documentation "Break-Points Function: a 2D function defined as y=f(x) by a list of [x,y] coordinates (<x-points> / <y-points>). - <x-point> must be stricly increasing or will be sorted at initialization. - If <x-list> and <y-list> are not of the same length, the last step in the shorter one is repeated." )) (defmethod bpf-p ((self bpf)) t) (defmethod bpf-p ((self t)) nil) (defmethod additional-class-attributes ((self BPF)) '(decimals color name action interpol)) (defmethod additional-slots-to-copy ((self BPF)) (append (call-next-method) '(time-types))) ;;; decimals will be set because it is initarg (defmethod initialize-instance ((self bpf) &rest args) (call-next-method) (check-decimals self) (init-bpf-points self) self) (defun om-make-bpf (type xpts ypts dec) (make-instance type :x-points xpts :y-points ypts :decimals dec)) ;;;=============================== (defmethod get-properties-list ((self bpf)) `(("" (:decimals "Precision (decimals)" :number precision-accessor (0 10)) (:color "Color" :color color) (:name "Name" :string name) (:action "Action" :action action-accessor) (:interpol "Interpolation" ,(make-number-or-nil :min 20 :max 1000) interpol) ))) (defun send-as-osc (bpf-point &optional (address "/bpf-point") (host "localhost") (port 3000)) (osc-send (cons address bpf-point) host port)) (defmethod arguments-for-action ((fun (eql 'send-as-osc))) `((:string address "/bpf-point") (:string host ,(get-pref-value :osc :out-host)) (:int port ,(get-pref-value :osc :out-port)))) (defmethod get-def-action-list ((object BPF)) '(print send-as-osc midi-controller)) (defmethod action-accessor ((self bpf) &optional (value nil value-supplied-p)) (if value-supplied-p (set-action self value) (action self))) ;;;=============================== (defmethod precision-accessor ((self bpf) &optional (value nil value-supplied-p)) (if value-supplied-p (change-precision self value) (decimals self))) (defmethod check-decimals ((self bpf)) (unless (and (integerp (decimals self)) (> (decimals self) 0) (<= (decimals self) 10)) (cond ((not (integerp (decimals self))) (om-beep-msg "BPF decimals must be an integer value! (def = 2)") (setf (slot-value self 'decimals) 2)) ((minusp (decimals self)) (om-beep-msg "BPF decimals must be a positive integer! (set to 0)") (setf (slot-value self 'decimals) 0)) ((> (decimals self) 10) (om-beep-msg "BPF only support up to 10 decimals!") (setf (slot-value self 'decimals) 10)) ))) ;; called in make-value-from-model/set-value-slots (defmethod (setf decimals) ((decimals t) (self bpf)) (let ((x (x-values-from-points self)) (y (y-values-from-points self))) (setf (slot-value self 'decimals) decimals) (check-decimals self) (set-bpf-points self :x x :y y) (decimals self))) (defmethod change-precision ((self bpf) decimals) (setf (decimals self) decimals) (decimals self)) ;;; depending on decimals, the BPF will truncate float numbers (defun truncate-function (decimals) (if (zerop decimals) #'round (let ((factor (expt 10 decimals))) #'(lambda (n) (/ (round (* n factor)) (float factor)))))) (defmethod x-values-from-points ((self bpf)) (mapcar #'om-point-x (point-list self))) (defmethod y-values-from-points ((self bpf)) (mapcar #'om-point-y (point-list self))) (defmethod xy-values-from-points ((self bpf) &optional from to) (mapcar #'(lambda (p) (list (om-point-x p) (om-point-y p))) (filter-list (point-list self) from to :key 'om-point-x))) (defmethod set-bpf-points ((self bpf) &key x y z time time-types) (declare (ignore time z)) (let ((point-list (sort (make-points-from-lists (or x (x-values-from-points self)) (or y (y-values-from-points self)) (decimals self) 'om-make-bpfpoint) '< :key 'om-point-x))) (when time-types (loop for p in point-list for type in time-types do (om-point-set p :type type))) (setf (point-list self) point-list) (setf (slot-value self 'x-points) NIL) (setf (slot-value self 'y-points) NIL))) (defmethod duplicate-coordinates ((p1 ompoint) (p2 ompoint)) (= (om-point-x p1) (om-point-x p2))) (defmethod set-bpf-points :after ((self bpf) &key x y z time time-types) (declare (ignore x y z time time-types)) (when (loop for p in (point-list self) for next in (cdr (point-list self)) do (when (duplicate-coordinates p next) (return t))) (om-beep-msg "Warning: Duplicate point coordinates in ~A!" self))) (defmethod replace-current ((new ompoint) (current ompoint)) (> (om-point-y new) (om-point-y current))) (defmethod replace-current ((new bpfpoint) (current bpfpoint)) (if (equal (bpfpoint-type new) (bpfpoint-type current)) (> (om-point-y new) (om-point-y current)) (equal (bpfpoint-type new) :master))) (defmethod cleanup-points ((self bpf)) (let ((newlist ())) (loop for p in (point-list self) do (if (and newlist (duplicate-coordinates p (car newlist))) (when (replace-current p (car newlist)) (setf (car newlist) p)) ;; otherwise just drop p from the list (push p newlist))) (setf (point-list self) (reverse newlist)))) (defmethod (setf x-points) ((x-points t) (self bpf)) (set-bpf-points self :x x-points) x-points) (defmethod (setf y-points) ((y-points t) (self bpf)) (set-bpf-points self :y y-points) y-points) (defmethod x-points ((self bpf)) (x-values-from-points self)) (defmethod y-points ((self bpf)) (y-values-from-points self)) (defmethod init-bpf-points ((self bpf)) (set-bpf-points self :x (slot-value self 'x-points) :y (slot-value self 'y-points) :time-types (slot-value self 'time-types))) (defmethod make-points-from-lists ((listx list) (listy list) &optional (decimals 0) (mkpoint 'om-make-point)) (when (or listx listy) (if (and (list-subtypep listx 'number) (list-subtypep listy 'number)) (let* ((listx (mapcar (truncate-function decimals) (or listx '(0 1)))) (listy (mapcar (truncate-function decimals) (or listy '(0 1)))) (defx (if (= 1 (length listx)) (car listx) (- (car (last listx)) (car (last listx 2))))) (defy (if (= 1 (length listy)) (car listy) (- (car (last listy)) (car (last listy 2)))))) (loop for ypoin = (if listy (pop listy) 0) then (if listy (pop listy) (+ ypoin defy)) for xpoin = (if listx (pop listx) 0) then (if listx (pop listx) (+ xpoin defx)) while (or listy listx) collect (funcall mkpoint xpoin ypoin) into rep finally (return (append rep (list (funcall mkpoint xpoin ypoin))))) ) (om-beep-msg "BUILD BPF POINTS: input coordinates are not (all) numbers!") ))) (defmethod make-points-from-lists ((pointx number) (listy list) &optional (decimals 0) (mkpoint 'om-make-point)) (if (list-subtypep listy 'number) (let* ((pointx (funcall (truncate-function decimals) pointx)) (listy (mapcar (truncate-function decimals) listy))) (loop for ypoin in listy for x = 0 then (+ x pointx) collect (funcall mkpoint x ypoin))) (om-beep-msg "BUILD BPF POINTS: Y-coordinates are not (all) numbers!") )) (defmethod make-points-from-lists ((listx list) (pointy number) &optional (decimals 0) (mkpoint 'om-make-point)) (if (list-subtypep listx 'number) (let* ((pointy (funcall (truncate-function decimals) pointy)) (listx (mapcar (truncate-function decimals) listx))) (loop for xpoin in listx collect (funcall mkpoint xpoin pointy))) (om-beep-msg "BUILD BPF POINTS: X-coordinates are not (all) numbers!") )) (defmethod make-points-from-lists ((pointx t) (pointy t) &optional (decimals 0) (mkpoint 'om-make-point)) (om-beep-msg "CAN'T BUILD BPF POINTS from [~A ~A]" pointx pointy)) ;;;===================================== ;;; TIME-SEQUENCE API ;======================================= (defmethod time-sequence-get-timed-item-list ((self bpf)) (point-list self)) (defmethod time-sequence-set-timed-item-list ((self bpf) points) (setf (point-list self) points) (call-next-method)) (defmethod time-sequence-get-times ((self bpf)) (x-points self)) (defmethod time-sequence-insert-timed-item ((self bpf) point &optional position) (insert-point self point position)) (defmethod time-sequence-make-timed-item-at ((self bpf) at) (om-make-bpfpoint at (x-transfer self at (decimals self)))) ;;; redefine this to be a little bit safer wrt floating point errors ;;; (since BPF can have sub-millisecond time-point values...) (defmethod point-exists-at-time ((self bpf) time) (let* ((fact (expt 10 (decimals self))) (rounded-time (round (* time fact)))) (loop for point in (time-sequence-get-timed-item-list self) when (and (= (round (* (item-get-internal-time point) fact)) rounded-time)) return point))) ;======================================= ;WHEN IN A COLLECTION... ;======================================= (defmethod homogenize-collection ((self bpf) list) (let* ((maxdecimals (loop for item in list maximize (decimals item)))) ;;; newlist all at the same (max) precision (loop for bpf in list unless (= (decimals bpf) maxdecimals) do (change-precision bpf maxdecimals)) list)) ;======================================= ;OPERATIONS ;======================================= (defmethod set-bpf-point-values ((self bpf)) (let ((tf (truncate-function (decimals self)))) (loop for p in (point-list self) do (om-point-set p :x (funcall tf (om-point-x p)) :y (funcall tf (om-point-y p)))))) ;============================= ; Insert a point at the right position (x ordered) returns the position ;============================== (defmethod adapt-point ((self bpf) point) (om-point-set point :x (funcall (truncate-function (decimals self)) (om-point-x point)) :y (funcall (truncate-function (decimals self)) (om-point-y point))) point) ;;; MUST RETURN THE POSITION (defmethod insert-point ((self bpf) point &optional position) (let* ((new-point (adapt-point self point)) (pos (or position ;;; in principle there is no need to specify the position with BPFs (position (om-point-x new-point) (point-list self) :key 'om-point-x :test '<=) ;(length (point-list self)) )) (new-point-list (copy-tree (point-list self)))) (if new-point-list (if pos (if (= (om-point-x (nth pos new-point-list)) (om-point-x new-point)) (setf (nth pos new-point-list) new-point) (if (= pos 0) (push new-point new-point-list) (push new-point (nthcdr pos new-point-list)))) ;;; pos = NIL : insert at the end (nconc new-point-list (list new-point)) ) (setf new-point-list (list new-point))) (setf (point-list self) new-point-list) ;;; return the position (or pos (1- (length new-point-list))))) ;============================= ; Delete a point ;============================= (defmethod remove-point ((self bpf) point) (setf (point-list self) (remove point (point-list self) :test 'om-points-equal-p))) (defmethod remove-nth-point ((self bpf) n) (setf (point-list self) (append (subseq (point-list self) 0 n) (subseq (point-list self) (1+ n))))) ;============================= ; Move the point in x and y ;============================= (defmethod possible-move ((self bpf) points x-key deltax y-key deltay) (let ((point-before (find (om-point-x (car points)) (point-list self) :key 'om-point-x :test '> :from-end t)) (point-after (find (om-point-x (car (last points))) (point-list self) :key 'om-point-x :test '<))) (and (or (null point-before) (> (+ (om-point-x (car points)) deltax) (om-point-x point-before))) (or (null point-after) (< (+ (om-point-x (car (last points))) deltax) (om-point-x point-after))) ) )) (defmethod possible-set ((self bpf) point x y) (let ((point-before (find (om-point-x point) (point-list self) :key 'om-point-x :test '> :from-end t)) (point-after (find (om-point-x point) (point-list self) :key 'om-point-x :test '<))) (and (or (null point-before) (> x (om-point-x point-before))) (or (null point-after) (< x (om-point-x point-after)))))) ;;; move-plist = '(:x dx :y dy ...) ;TODO Add axis keys to check and move in correct dimension if internal bpf (defmethod move-points-in-bpf ((self bpf) points dx dy &optional (x-key :x) (y-key :y)) (when (possible-move self points x-key dx y-key dy) (loop for p in points do (funcall 'om-point-mv p x-key dx y-key dy)) points)) (defmethod set-point-in-bpf ((self bpf) point x y) (let ((xx (funcall (truncate-function (decimals self)) (or x (om-point-x point)))) (yy (funcall (truncate-function (decimals self)) (or y (om-point-y point))))) (when (possible-set self point xx yy) (om-point-set point :x xx :y yy)) point)) ;======================================= ;ACCESSORS ;======================================= ; Get the x values of prev et next points of point (defmethod give-prev+next-x ((self bpf) point) (let ((pos (position point (point-list self) :test #'eql))) (when pos (list (and (plusp pos) (nth (1- pos) (point-list self))) (nth (1+ pos) (point-list self)))))) ; Get the prev and next points for a point not in the bpf (defmethod give-closest-points ((self bpf) point) (let ((pos (position (om-point-x point) (point-list self) :test '< :key 'om-point-x))) (cond ((zerop pos) (list nil (car (point-list self)))) (pos (list (nth (1- pos) (point-list self)) (nth pos (point-list self)))) (t (append (last (point-list self)) '(nil)))) )) ; Get the points that fall in the interval (x1 x2) (defmethod give-points-in-x-range ((self bpf) x1 x2) (loop for x in (point-list self) while (<= (om-point-x x) x2) ;;; because points are ordered when (>= (om-point-x x) x1) collect x)) ; Get the points that fall in the interval (y1 y2) (defmethod give-points-in-y-range ((self bpf) y1 y2) (loop for point in (point-list self) when (and (>= y2 (om-point-y point)) (<= y1 (om-point-y point))) collect point)) ; Get the points that fall in the given rect (tl br) (defmethod give-points-in-rect ((self bpf) tl br) (let* ((x (om-point-x tl)) (y (om-point-y tl)) (w (- (om-point-x br) x)) (h (- (om-point-y br) y))) (loop for p in (point-list self) when (om-point-in-rect-p p x y w h) collect p))) ;======================================= ;BOX ;======================================= (defmethod display-modes-for-object ((self bpf)) '(:mini-view :text :hidden)) ; Get the min - max points in x and y axis ; using reduce 'mix/max is fatser when interpreted but not when compiled (defmethod nice-bpf-range ((self bpf)) (multiple-value-bind (x1 x2 y1 y2) (loop for x in (x-values-from-points self) for y in (y-values-from-points self) minimize x into x1 maximize x into x2 minimize y into y1 maximize y into y2 finally (return (values x1 x2 y1 y2))) (append (list x1 x2) (list y1 y2)) ; (if (< (- x2 x1) 10) (list (- x1 5) (+ x2 5)) (list x1 x2)) ; (if (< (- y2 y1) 10) (list (- y1 5) (+ y2 5)) (list y1 y2))) )) (defmethod nice-bpf-range ((self list)) (loop for item in self for range = (nice-bpf-range item) minimize (first range) into x1 maximize (second range) into x2 minimize (third range) into y1 maximize (fourth range) into y2 finally (return (list x1 x2 y1 y2)))) (defmethod get-cache-display-for-draw ((self bpf) box) (list (nice-bpf-range self) (if (<= (length (point-pairs self)) 500) (point-pairs self) ;(reduce-n-points (point-pairs self) 1000 100) ;(min-max-points (point-pairs self) 1000) (point-pairs (om-sample self 500)) ) )) (defmethod draw-mini-view ((self bpf) (box t) x y w h &optional time) (let* ((display-cache (ensure-cache-display-draw box self)) (ranges (car display-cache)) (x-range (list (nth 0 ranges) (nth 1 ranges))) (y-range (list (or (get-edit-param box :display-min) (nth 2 ranges)) (or (get-edit-param box :display-max) (nth 3 ranges)))) (font (om-def-font :tiny))) (draw-bpf-points-in-rect (cadr display-cache) (color self) (append x-range y-range) (+ x 2) (+ y 10) (- w 4) (- h 20) ;x (+ y 10) w (- h 20) (get-edit-param box :draw-style)) (om-with-font font (om-draw-string (+ x 10) (+ y (- h 4)) (number-to-string (nth 0 x-range))) (om-draw-string (+ x (- w (om-string-size (number-to-string (nth 1 x-range)) font) 4)) (+ y (- h 4)) (number-to-string (nth 1 ranges))) (om-draw-string x (+ y (- h 14)) (number-to-string (nth 0 y-range))) (om-draw-string x (+ y 10) (number-to-string (nth 1 y-range))) ) t)) (defmethod draw-sequencer-mini-view ((self bpf) (box t) x y w h &optional time) (let* ((display-cache (ensure-cache-display-draw box self)) (ranges (car display-cache)) (x-range (list 0 (nth 1 ranges))) (y-range (list (or (get-edit-param box :display-min) (nth 2 ranges)) (or (get-edit-param box :display-max) (nth 3 ranges))))) (draw-bpf-points-in-rect (cadr display-cache) (color self) (append x-range y-range) (+ x 2) (+ y 10) (- w 4) (- h 20) (get-edit-param box :draw-style)) (om-with-fg-color (om-def-color :gray) (om-with-font (om-def-font :tiny) (om-draw-string x (+ y (- h 14)) (number-to-string (nth 0 y-range))) (om-draw-string x (+ y 10) (number-to-string (nth 1 y-range))) )) t)) (defun conversion-factor-and-offset (min max w delta) (let* ((range (- max min)) (factor (if (zerop range) 1 (/ w range)))) (values factor (- delta (* min factor))))) (defun draw-bpf-points-in-rect (points color ranges x y w h &optional style) (multiple-value-bind (fx ox) (conversion-factor-and-offset (car ranges) (cadr ranges) w x) (multiple-value-bind (fy oy) ;;; Y ranges are reversed !! (conversion-factor-and-offset (cadddr ranges) (caddr ranges) h y) (when points (flet ((px (p) (if (om-point-p p) (om-point-x p) (car p))) (py (p) (if (om-point-p p) (om-point-y p) (cadr p)))) (cond ((equal style :points) (om-with-fg-color (om-def-color :dark-gray) (loop for pt in points do (om-draw-circle (+ ox (* fx (px pt))) (+ oy (* fy (py pt))) 3 :fill t)) )) ((or (equal style :lines) (null style)) (let ((lines (loop for pts on points while (cadr pts) append (let ((p1 (car pts)) (p2 (cadr pts))) (om+ 0.5 (list (+ ox (* fx (px p1))) (+ oy (* fy (py p1))) (+ ox (* fx (px p2))) (+ oy (* fy (py p2))))) )))) (om-with-fg-color (or color (om-def-color :dark-gray)) (om-draw-lines lines)) )) ((equal style :histogram) (loop for i from 0 to (1- (length points)) do (let* ((p (nth i points)) (x (+ ox (* fx (px p)))) (prev-p (if (plusp i) (nth (1- i) points))) (next-p (nth (1+ i) points)) (prev-px (if prev-p (+ ox (* fx (px prev-p))))) (next-px (if next-p (+ ox (* fx (px next-p))))) (x1 (if prev-px (/ (+ x prev-px) 2) (if next-px (- x (- next-px x)) (- x 1)))) (x2 (if next-px (/ (+ x next-px) 2) (if prev-px (+ x (- x prev-px)) (+ x 1))))) (om-draw-rect x1 oy (- x2 x1) (* fy (py p)) :fill nil) (om-draw-rect x1 oy (- x2 x1) (* fy (py p)) :fill t :color (om-def-color :gray)) (om-draw-string (+ x1 1) (- oy 4) (format nil "~D" (py p)) :font (om-def-font :tiny) :color (om-def-color :white)) )) ) (t (om-with-fg-color (om-def-color :gray) ; first point (om-draw-circle (+ ox (* fx (px (car points)))) (+ oy (* fy (py (car points)))) 3 :fill t) (let ((lines (loop for pts on points while (cadr pts) append (let ((p1 (car pts)) (p2 (cadr pts))) (om-draw-circle (+ ox (* fx (px p2))) (+ oy (* fy (py p2))) 3 :fill t) ;;; collect for lines (om+ 0.5 (list (+ ox (* fx (px p1))) (+ oy (* fy (py p1))) (+ ox (* fx (px p2))) (+ oy (* fy (py p2))))) )))) (om-with-fg-color (or color (om-def-color :dark-gray)) (om-draw-lines lines)) ))) )) ) ))) ;;;============================= ;;; FOR DRAW ON COLLECTION BOXES ;;;============================= (defmethod collection-draw-mini-view ((type BPF) list box x y w h time) (if (list-subtypep list 'BPF) ;;; works only is all objects are BPFs ;;; with BPFs we wan to gather info (ranges) from all different caches of teh collection-box multi-cache list (multiple-value-bind (ranges bpf-points-list) (loop with temp-cache = nil for o in list do (setf (cache-display box) nil) do (setf temp-cache (ensure-cache-display-draw box o)) collect (cadr temp-cache) into bpf-points-list minimize (first (car temp-cache)) into x1 maximize (second (car temp-cache)) into x2 minimize (third (car temp-cache)) into y1 maximize (fourth (car temp-cache)) into y2 finally (return (values (list x1 x2 y1 y2) bpf-points-list))) (let* ((n-bpfs (length list)) (max-n 40) ;;; LIMIT TO .... ? (step (max 1 (floor n-bpfs max-n)))) (loop for i from 0 to (1- n-bpfs) by step do (draw-bpf-points-in-rect (nth i bpf-points-list) (color (nth i list)) ranges x (+ y 10) w (- h 20) :lines) )) (let ((font (om-def-font :tiny))) (om-with-font font (om-draw-string (+ x 10) (+ y (- h 4)) (number-to-string (nth 0 ranges))) (om-draw-string (+ x (- w (om-string-size (number-to-string (nth 1 ranges)) font) 4)) (+ y (- h 4)) (number-to-string (nth 1 ranges))) (om-draw-string x (+ y (- h 14)) (number-to-string (nth 2 ranges))) (om-draw-string x (+ y 10) (number-to-string (nth 3 ranges))) ) ) ) (call-next-method)) ) ;;;============================= ;;; BPF PLAY ;;;============================= (defmethod play-obj? ((self bpf)) t) ;(action self) (defmethod get-obj-dur ((self bpf)) (or (car (last (x-points self))) 0)) (defmethod point-time ((self bpf) p) (om-point-x p)) ;(defmethod get-all-times ((self bpf)) (x-points self)) ;;; RETURNS A LIST OF (TIME ACTION) TO PERFORM IN TIME-INTERVAL (defmethod get-action-list-for-play ((object BPF) time-interval &optional parent) (when (action object) (if (number-? (interpol object)) (let* ((t1 (max 0 (car time-interval))) (t2 (min (get-obj-dur object) (cadr time-interval))) (time-list (arithm-ser (get-active-interpol-time object t1) t2 (number-number (interpol object))))) (loop for interpolated-time in time-list for val in (x-transfer object time-list) collect (let ((v val) (ti interpolated-time)) (list ti #'(lambda () (funcall (action-fun object) (list ti (float (* (gain object) v))))))))) ;;; no interpolation (mapcar #'(lambda (xy) (list (car xy) #'(lambda () (funcall (action-fun object) (list (car xy) (* (gain object) (cadr xy))))))) (xy-values-from-points object (car time-interval) (cadr time-interval)))))) ;;; DB: ;;; in order to limit replanning operations, it is preferrable to ;;; call (setf point-list) only once all modifications are performed ;;; For example, when drawing a curve, don't call (setf point-list) on ;;; each insert-point but only once the mouse is released ;(defmethod (setf point-list) ((point-list t) (self bpf)) ; (with-schedulable-object ; self ; (setf (slot-value self 'point-list) point-list))) ;;;=============================================== ;;; SVG export ;;;=============================================== (defmethod export-svg ((self bpf) file-path &key with-points (w 300) (h 300) (margins 20) (line-size 1)) :icon 908 :indoc '("a BPF object" "a pathname" "draw-points" "image width" "image height" "margins size" "line-size") :initvals '(nil nil nil 300 300 20 1) :doc " Exports <self> to SVG format. " (let* ((pathname (or file-path (om-choose-new-file-dialog :directory (def-save-directory) :prompt "New SVG file" :types '("SVG Files" "*.svg"))))) (when pathname (setf *last-saved-dir* (make-pathname :directory (pathname-directory pathname))) (let* ((bpf-points (point-pairs (bpf-scale self :x1 margins :x2 (- w margins) :y2 margins :y1 (- h margins)))) ; y2 and y1 switched to have the correct orientation (scene (svg::make-svg-toplevel 'svg::svg-1.1-toplevel :height h :width w)) (prev_p nil) (path (svg::make-path)) (color (or (color self) (om-def-color :black))) (bpfcolorstr (format nil "rgb(~D, ~D, ~D)" (round (* 255 (om-color-r color))) (round (* 255 (om-color-g color))) (round (* 255 (om-color-b color)))))) ;draw line (loop for pt in bpf-points do (svg::with-path path (if prev_p (svg::line-to (car pt) (cadr pt)) (svg::move-to (car pt) (cadr pt)))) (setf prev_p pt)) (svg::draw scene (:path :d path) :fill "none" :stroke bpfcolorstr :stroke-width line-size) ;if points, draw points (when with-points (loop for pt in bpf-points do (svg::draw scene (:circle :cx (car pt) :cy (cadr pt) :r (if (numberp with-points) with-points 2)) :stroke "rgb(0, 0, 0)" :fill bpfcolorstr))) (with-open-file (s pathname :direction :output :if-exists :supersede) (svg::stream-out s scene))) pathname )))
32,995
Common Lisp
.lisp
663
39.108597
169
0.535205
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
77d65fe63d20c5e4c03ce1914af68c1c5ec86bbb60ecb2cf4377076a8c0c12db
763
[ -1 ]
764
sets.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/sets.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (code form OM6) ;========================================================================= (in-package :om) (defun norep-union (lists oper test key) (let ((the-union (list! (car lists)))) (dolist (one-in (cdr lists)) (setq the-union (funcall oper the-union (list! one-in) :test test :key key))) the-union)) (defmethod* x-union ((l1? list) (l2? list) &optional (test 'equal) (key 'identity) &rest lists) :initvals '(nil nil equal identity) :indoc '("a list" "a list" "test function" "test key" "more lists") :doc "Merges lists (<l1?> and <l2?> and possibly more) into a single list with no repetitions. <test> is a function or function name for a binary comparison. <key> is a name or function name to apply to the elements before comparison. Ex. (x-union '(1 2 3 4 5) '(4 5 6 7 8)) => (8 7 6 1 2 3 4 5) " :icon 'set (noRep-union (list* l1? l2? (and lists (list! lists))) 'union test key)) (defmethod* x-intersect ((l1? list) (l2? list) &optional (test 'equal) (key 'identity) &rest list) :initvals '(nil nil equal identity) :indoc '("a list" "a list" "test function" "test key" "more lists") :doc "Returns the intersection (i.e. common elements) from lists (<l1?> and <l2?> and possibly more) into a single list. <test> is a function or function name for a binary comparison. <key> is a name or function name to apply to the elements before comparison. Ex. (x-intersect '(1 2 3 4 5) '(4 5 6 7 8)) => (4 5)" :icon 'set (nreverse (noRep-union (list* l1? l2? (and list (list! list))) 'intersection test key))) (defmethod* x-xor ((l1? list) (l2? list) &optional (test 'equal) (key 'identity) &rest list) :initvals '(nil nil equal identity) :indoc '("a list" "a list" "test function" "test key" "more lists") :doc "XOR's lists (<l1?> and <l2?> and possibly more) into a single list. XOR keeps only the elements present in one list and not in the other one(s). <test> is a function or function name for a binary comparison. <key> is a name or function name to apply to the elements before comparison. Ex. (x-xor '(1 2 3 4 5) '(4 5 6 7 8)) => (1 2 3 6 7 8)" :icon 'set (nreverse (noRep-union (list* l1? l2? (and list (list! list))) 'set-exclusive-or test key))) (x-xor '(1 2 3 4 5) '(4 5 6 7 8)) (defmethod* x-diff ((l1? list) (l2? list) &optional (test 'equal) (key 'identity) &rest list) :initvals '(nil nil equal identity) :indoc '("a list" "a list" "test function" "test key" "more lists") :doc "Returns the list of elements present in <l1?> but not in <l2?>. <test> is a function or function name for a binary comparison. <key> is a name or function name to apply to the elements before comparison. Ex. (x-diff '(1 2 3 4 5) '(4 5 6 7 8)) => (1 2 3)" :icon 'set (nreverse (noRep-union (list* l1? l2? (and list (list! list))) 'set-difference test key))) (defmethod* included? ((lst1 list) (lst2 list) &optional (test 'equal)) :initvals '(nil nil equal) :indoc '("a list" "a list" "test") :doc "Tests if <lst1> is included in <lst2>. <test> is a function or function name for a binary comparison. Ex. (included? '(1 2 3 4 5) '(4 5 6 7 8)) => NIL Ex. (included? '(5 6) '(4 5 6 7 8)) => T " :icon 'set (subsetp lst1 lst2 :test test)) (defmethod* included? ((lst1 number) (lst2 list) &optional (test 'equal)) (included? (list lst1) lst2 test))
4,282
Common Lisp
.lisp
79
48.556962
123
0.590417
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
865d5eab773f0a59667bfc439fad4c19d2163c5d8c9493ccd82e006356f92800
764
[ -1 ]
765
combinatorial.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/combinatorial.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ;; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (code from OM6) ;========================================================================= (in-package :om) ;;; compat (defmethod* sort. ((lst list) &optional (test '<) (key nil)) :initvals '(nil < nil) :indoc '("the list" "test" "key") :doc "Sorts a list. (Deprecated - Use sort-list) " (sort-list lst :test test :key key)) (defmethod* sort-list ((lst list) &key (test '<) (key nil) (rec nil)) :initvals '(nil < nil nil) :menuins '((3 (("Yes" t) ("No" nil)))) :indoc '("a list" "test function" "test key" "recursive sort") :doc "Returns a sorted version of <lst>. <test> is a binary function or function name indicating how to compare elements. <key> is a function or function name that will be applied to elements before the test. If <rec> is T, then the sort will be applied recursively to the sub-lists in <lst>. Ex. (sort-list '(3 6 7 2 1)) => (1 2 3 6 7) Ex. (sort-list '(3 6 7 2 1) :test '>) => (7 6 3 2 1) Ex. (sort-list '((a 3) (b 6) (c 7) (d 2) (e 1)) :test '> :key 'second) => ((c 7) (b 6) (a 3) (d 2) (e 1)) Ex. (sort-list '((7 8 9 1) (5 2 4 3)) :test '< :key 'first) => ((5 2 4 3) (7 8 9 1)) Ex. (sort-list '((7 8 9 1) (5 2 4 3)) :test '< :rec t) => ((1 7 8 9) (2 3 4 5)) " :icon 'combinatory (let ((l (copy-list lst))) (if rec (cond ((null lst) nil) ((atom (first lst)) (sort lst (or test #'<) :key key)) (t (cons (sort-list (first l) :test (or test #'<) :key key :rec rec) (sort-list (rest l) :test (or test #'<) :key key :rec rec)))) (sort l (or test #'<) :key key)) )) (defmethod permut-circn ((list list) &optional (nth 1)) (when list (let ((length (length list)) n-1thcdr) (setq nth (mod nth length)) (if (zerop nth) list (prog1 (cdr (nconc (setq n-1thcdr (nthcdr (1- nth) list)) list)) (rplacd n-1thcdr ())))))) (defmethod* rotate ((list list) &optional (nth 1)) :initvals '(nil 1) :indoc '("the list" "nth") :doc "Returns a circular permutation of <list> starting from its <nth> element. Ex. (rotate '(a b c d e) 1) => (b c d e a) Ex. (rotate '(a b c d e) 3) => (d e a b c)" :icon 'combinatory (permut-circn (copy-list list) nth)) (defmethod* nth-random ((list list)) :initvals '(nil) :indoc '("a list") :doc "Returns a randomly chosen element from <list>." :icon 'combinatory (nth (om-random-value (length list)) list)) (defmethod npermut-random ((list list)) "destructive random permutation of <list>." (let ((result ()) (length (length list)) (list (copy-list list))) (nconc list list) (loop for i from 0 to length do (setq list (nthcdr (om-random-value length) list) result (rplacd (prog1 (cdr list) (rplacd list (cddr list))) result) length (1- length))) result)) (defmethod* permut-random ((list list)) :initvals '(nil) :indoc '("a list") :doc "Returns a random permutation of <list> Ex. (permut-random '(1 2 3 4 5)) => (4 5 2 3 1)" :icon 'combinatory (if (or (null list) (= (length list) 1)) list (npermut-random (copy-list list)))) (defmethod* posn-order ((list list) (test symbol)) :initvals '(nil '<) :indoc '("a list" "test function") :doc "Returns a list of indices according to a sort function. The indexes of items in <list> (from 0 to length-1) will be sorted according to <test>. <test> may be a function or function name (symbol) for a binary comparison function. Ex. (posn-order '(4 5 6 7 8) '<) => (0 1 2 3 4) Ex. (posn-order '(4 5 6 7 8) '>) => (4 3 2 1 0) " :icon 'combinatory (do-posn-order list test)) (defmethod* posn-order ((list list) (test function)) (do-posn-order list test)) (defun do-posn-order (list test) (let* ((thelist (sort-list list :test test)) rep) (mapc #'(lambda (x) (let* ((repons (position x thelist)) (i 0)) (loop while (position repons rep) do (incf i) (setf repons (position x thelist :start (+ (position x thelist) i)))) (setf rep (cons repons rep)))) list) (reverse rep))) (defmethod* permutations ((bag list)) :initvals '(nil ) :indoc '("a list") :icon 'combinatory :doc "Return a list of all the permutations of <bag>. Ex. (permutations '(a b c)) => ((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))" (if (null bag) '(()) ;; Otherwise, take an element, e, out of the bag. ;; Generate all permutations of the remaining elements, ;; And add e to the front of each of these. ;; Do this for all possible e to generate all permutations. (mapcan #'(lambda (e) (mapcar #'(lambda (p) (cons e p)) (permutations (remove e bag :count 1 :test #'eq)))) bag)))
5,638
Common Lisp
.lisp
125
39
106
0.558818
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
cbf44dd8bd04f2c6964a16e991dc7d2087a4af4786fba42c1ad1061305761c48
765
[ -1 ]
766
numbers.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/numbers.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (code from OM6) ;========================================================================= (in-package :om) ;=========================== ; Comparison functions ; simple wrappers around lisp comparisons ;=========================== (defmethod* om< ((num1 number) (num2 number)) :initvals '(0 1) :indoc '("a number" "a number") :doc "Tests if <num1> is smaller than <num2>. Returns T if the test is verified and NIL if not. " (< num1 num2)) (defmethod* om> ((num1 number) (num2 number)) :initvals '(0 1) :indoc '("a number" "a number") :doc "Tests if <num1> is greater than <num2> Returns T if the test is verified and NIL if not." (> num1 num2)) (defmethod* om<= ((num1 number) (num2 number)) :initvals '(0 1) :indoc '("a number" "a number") :doc "Tests if <num1> is smaller or equal to <num2> Returns T if the test is verified and NIL if not." (<= num1 num2)) (defmethod* om>= ((num1 number) (num2 number)) :initvals '(0 1) :indoc '("a number" "a number") :doc "Tests if <num1> is greater or equal to <num2> Returns T if the test is verified and NIL if not." (>= num1 num2)) (defmethod* om= ((num1 number) (num2 number)) :initvals '(0 0) :indoc '("a number" "a number") :doc "Tests if <num1> is equal to <num2> Returns T if the test is verified and NIL if not." (= num1 num2)) (defmethod* om/= ((num1 number) (num2 number)) :initvals '(0 0) :indoc '("a number" "a number") :doc "Tests if <num1> is NOT equal to <num2> Returns T if the test is verified and NIL if not." (/= num1 num2)) ;=========================== ; Tools ;=========================== (defun round_0 (arg &optional div) (if (plusp arg) (truncate (+ (/ arg div) 0.5)) (truncate (- (/ arg div) 0.5)))) (defun approx-decimals (x y nbdec) (let ((ndec (if (> nbdec 0 ) (float (expt 10 nbdec)) (expt 10 nbdec)))) (/ (round_0 (/ x y) (/ ndec)) ndec))) (defun mulalea (n percent) (* n (+ 1 (om-random (- percent) (float percent))))) (defmethod tree-min ((self list) &optional (min MOST-POSITIVE-LONG-FLOAT)) (if (null self) min (tree-min (rest self) (tree-min (first self) min)))) (defmethod tree-min ((self number) &optional (min MOST-POSITIVE-LONG-FLOAT)) (min self min)) (defmethod tree-max ((self list) &optional (max MOST-NEGATIVE-LONG-FLOAT)) (if (null self) max (tree-max (rest self) (tree-max (first self) max)))) (defmethod tree-max ((self number) &optional (max MOST-NEGATIVE-LONG-FLOAT)) (max self max)) ;=========================== ; ADDITIONS ;=========================== (defmethod* om+ ((arg1 number) (arg2 number)) :initvals '(0 0) :indoc '("number or list" "number or list") :doc "Sum of two numbers or lists. Ex. (om+ 2 3) => 5 Ex. (om+ 2 '(3 4)) => (5 6) Ex. (om+ '(1 2) '(3 4)) => (4 6) " :icon 'om-plus (+ arg1 arg2)) (defmethod* om+ ((arg1 number) (arg2 list)) (mapcar #'(lambda (input) (om+ arg1 input)) arg2)) (defmethod* om+ ((arg1 list) (arg2 number)) (mapcar #'(lambda (input) (om+ input arg2)) arg1)) (defmethod* om+ ((arg1 list) (arg2 list)) (mapcar #'(lambda (input1 input2) (om+ input1 input2)) arg1 arg2)) ;=========================== ; MULTIPLICATIONS ;=========================== (defmethod* om* ((arg1 number) (arg2 number)) :initvals '(0 0) :indoc '("number or list" "number or list") :icon 'om-times :doc "Product of two numbers or lists. Ex. (om* 2 3) => 6 Ex. (om* 2 '(3 4)) => (6 8) Ex. (om* '(1 2) '(3 4)) => (3 8) " (* arg1 arg2)) (defmethod* om* ((arg1 number) (arg2 list)) (mapcar #'(lambda (input) (om* arg1 input)) arg2)) (defmethod* om* ((arg1 list) (arg2 number)) (mapcar #'(lambda (input) (om* input arg2)) arg1)) (defmethod* om* ((arg1 list) (arg2 list)) (mapcar #'(lambda (input1 input2) (om* input1 input2)) arg1 arg2)) ;=========================== ; SQUARE ;=========================== (defmethod* om-square ((arg1 number)) :initvals '(0) :indoc '("number or list") :icon 'om-times :doc "Square of a number or list. Ex. (om-square 2) => 4 Ex. (om-square '(3 4)) => (9 16) " (* arg1 arg1)) (defmethod* om-square ((arg1 list)) (mapcar #'(lambda (n) (* n n)) arg1)) ;=========================== ; SUBTRACTIONS ;=========================== (defmethod* om- ((arg1 number) (arg2 number)) :initvals '(0 0) :indoc '("number or list" "number or list") :icon 'om-minus :doc "Difference of two numbers or lists. Ex. (om- 5 2) => 3 Ex. (om- 5 '(2 4)) => (3 1) Ex. (om- '(5 4) '2) => (3 2) Ex. (om- '(5 4) '(2 4)) => (3 0) " (- arg1 arg2)) (defmethod* om- ((arg1 number) (arg2 list)) (mapcar #'(lambda (input) (om- arg1 input)) arg2)) (defmethod* om- ((arg1 list) (arg2 number)) (mapcar #'(lambda (input) (om- input arg2)) arg1)) (defmethod* om- ((arg1 list) (arg2 list)) (mapcar #'(lambda (input input2) (om- input input2)) arg1 arg2)) ;=========================== ; DIVISIONS ;=========================== (defmethod* om/ ((arg1 number) (arg2 number)) :initvals '(1 1) :indoc '("number or list" "number or list") :icon 'om-div :doc "Division of two numbers or lists. Ex. (om/ 8 2) => 4 Ex. (om/ 8 '(2 4)) => (4 2) Ex. (om/ '(8 5) '(2 4)) => (4 5/4)" (/ arg1 arg2)) (defmethod* om/ ((arg1 number) (arg2 list)) (mapcar #'(lambda (input) (om/ arg1 input)) arg2)) (defmethod* om/ ((arg1 list) (arg2 number)) (mapcar #'(lambda (input) (om/ input arg2)) arg1)) (defmethod* om/ ((arg1 list) (arg2 list)) (mapcar #'(lambda (input input2) (om/ input input2)) arg1 arg2)) ;=========================== ; POWERS ;=========================== (defmethod* om^ ((a number) (b number)) :initvals '(1 1) :indoc '("number or list" "number or list") :doc "Exponentiation of base a and exponent b. Corresponds to the multiplication of <a> repeated <b> times. Can be used on numbers or lists. Ex. (om^ 2 3) => 8 Ex. (om^ 2 '(3 4 5)) => (8 16 32) Ex. (om^ '(2 3 4) 3) => (8 27 64) Ex. (om^ '(2 3 4) '(2 3 4)) => (4 27 256) " (expt a b)) (defmethod* om^ ((a number) (b list)) (mapcar #'(lambda (input) (om^ a input)) b)) (defmethod* om^ ((a list) (b number)) (mapcar #'(lambda (input) (om^ input b)) a)) (defmethod* om^ ((a list) (b list)) (mapcar #'(lambda (input1 input2) (om^ input1 input2)) a b)) ;=========================== ; EXPONENTIAL ;=========================== (defmethod* om-e ((n number)) :initvals '(1) :indoc '("number or list") :doc "Exponential function. This function can be applied on numbers or lists. Ex. (om-e 4) => 54.59815 Ex. (om-e '(3 4)) => (20.085537 54.59815) " (exp n)) (defmethod* om-e ((n list)) (mapcar #'(lambda (input) (om-e input)) n)) ;=========================== ; LOGARITHM ;=========================== (defmethod* om-log ((n number) &optional (base (exp 1))) :initvals (list 1 (exp 1)) :indoc '("a number or list" "a number") :doc "Logarithm function. (the logarithm of a number to the base is the power to which the base must be raised in order to produce the number) The <base> argument is optional. By default, <base> is equal to the number 'e', so om-log computes the 'natural' logarithm of <n>. This function can be applied to numbers or lists. Ex. (om-log 3) => 1.0986123 Ex. (om-log 3 10) => 0.47712126 Ex. (om-log '(3 4)) => (1.0986123 1.3862944) " (log n base)) (defmethod* om-log ((n list) &optional (base (exp 1))) (mapcar #'(lambda (input) (om-log input base)) n)) ;=========================== ; ROUNDING ;=========================== (defmethod* om-round ((n number) &optional (decimals 0) (divisor 1)) :initvals '(1 0 1) :indoc '("number or list" "number of decimals" "divisor") :doc "Rounds a number or a list of numbers with a given number of decimals (default = 0, i.e. returns integer values) and a divisor. This function can be applied to numbers or lists. Ex. (om-round 4.3) => 4 Ex. (om-round '(4.3 5.0 6.8)) => (4 5 7) Ex. (om-round '(4.308 5.167 6.809) 2) => (4.31 5.17 6.81) Ex. (om-round '(4.308 5.167 6.809) 0 2) => (2 3 3) Ex. (om-round '(4.308 5.167 6.809) 1 2) => (2.2 2.6 3.4) " (approx-decimals n divisor decimals)) (defmethod* om-round ((n list) &optional (decimals 0) (divisor 1)) (mapcar #'(lambda (input) (om-round input decimals divisor)) n)) ;=========================== ; EUCLIDIAN DIVISION (WITH REST) ;=========================== (defmethod mat-trans-with-nil ((matrix list)) (let ((maxl (1- (loop for elt in matrix maximize (length elt)))) result) (loop for i from 0 to maxl do (push (mapcar #'(lambda (list) (nth i list)) matrix) result)) (nreverse result))) (defmethod* om// ((n number) (divisor number)) :initvals '(1 1) :indoc '("number or list" "number or list") :numouts 2 :doc "Euclidean division of <n> and <divisor>. Yields an integer result and the rest of the division. When the divisor is 1, the operation is known as 'floor'. <n> and <divisor> can be numbers or lists. Ex. (om// 5.5 2) => 2 , 1.5 Ex. (om// 5.5 1) => 5 , 0.5 Ex. (om// '(5.5 6) 2) => (2 3) , (1.5 0) Ex. (om// 5.5 '(2 3)) => (2 1) , (1.5 2.5) Ex. (om// '(5.5 6) '(2 3)) => (2 2) , (1.5 0) " (floor n divisor)) (defmethod* om// ((n number) (divisor list)) (values-list (mat-trans-with-nil (mapcar #'(lambda (input) (multiple-value-list (om// n input))) divisor)))) (defmethod* om// ((n list) (divisor number)) (if (null n) (values nil nil) (values-list (mat-trans-with-nil (mapcar #'(lambda (input) (multiple-value-list (om// input divisor))) n))))) (defmethod* om// ((n list) (divisor list)) (values-list (mat-trans-with-nil (mapcar #'(lambda (input1 input2) (multiple-value-list (om// input1 input2))) n divisor)))) ;=========================== ; ABSOLUTE VALUE ;=========================== (defmethod* om-abs ((self number)) :initvals (list 1 ) :indoc '("number or tree" ) :doc "Absolute value. This function can be applied to numbers or lists. Ex. (om-abs 3) => 3 Ex. (om-abs -3) => 3 Ex. (om-abs '(3 -4 -1.5 6)) => (3 4 1.5 6) " (abs self )) (defmethod* om-abs ((self list)) (mapcar #'(lambda (input) (om-abs input)) self)) ;=========================== ; MIN/MAX ;=========================== (defmethod* om-min ((a number) (b number)) :initvals '(1 1) :indoc '("number or list" "number or list") :doc "Minimum of two numbers. This function can be applied to numbers or lists. Ex. (om-min 3 4) => 3 Ex. (om-min 3 '(1 2 3 4)) => (1 2 3 3) Ex. (om-min '(4 3 2 1) '(1 2 3 4)) => (1 2 2 1) " (min a b)) (defmethod* om-min ((a number) (b null)) a) (defmethod* om-min ((a null) (b number)) b) (defmethod* om-min ((a number) (b list)) (mapcar #'(lambda (input) (om-min a input)) b)) (defmethod* om-min ((a list) (b number)) (mapcar #'(lambda (input) (om-min input b)) a)) (defmethod* om-min ((a list) (b list)) (mapcar #'(lambda (input1 input2) (om-min input1 input2)) a b)) (defmethod* list-min ((self list)) :initvals '((0 1 2)) :indoc '("a list") :doc "Returns the minimum element in a list. Ex. (list-min '(2 3 1 4)) => 1" (and (remove nil self) (list-min2 (remove nil self) MOST-POSITIVE-LONG-FLOAT))) (defmethod* list-min ((self t)) self) (defun list-min2 (l minimum) (if (null l) minimum (if (atom (first l)) (list-min2 (rest l) (min minimum (first l))) (list-min2 (first l) (min minimum (list-min2 (rest l) minimum)))))) (defmethod* om-max ((a number) (b number)) :initvals '(1 1) :indoc '("number or list" "number or list") :doc "Maximum of two numbers. This function can be applied to numbers or lists. Ex. (om-max 3 4) => 4 Ex. (om-max 3 '(1 2 3 4)) => (3 3 3 4) Ex. (om-max '(4 3 2 1) '(1 2 3 4)) => (4 3 3 4)" (max a b)) (defmethod* om-max ((a number) (b null)) a) (defmethod* om-max ((a null) (b number)) b) (defmethod* om-max ((a number) (b list)) (mapcar #'(lambda (input) (om-max a input)) b)) (defmethod* om-max ((a list) (b number)) (mapcar #'(lambda (input) (om-max input b)) a)) (defmethod* om-max ((a list) (b list)) (mapcar #'(lambda (input1 input2) (om-max input1 input2)) a b)) (defun list-max2 (l minimum) (if (null l) minimum (if (atom (first l)) (list-max2 (rest l) (max minimum (first l))) (list-max2 (first l) (max minimum (list-max2 (rest l) minimum)))))) (defmethod* list-max ((self list) ) :initvals '((0 1 2)) :indoc '("a list") :doc "Returns the maximum element in a list. Ex. (list-max '(2 4 1 3)) => 4" (and (remove nil self) (list-max2 (remove nil self) MOST-NEGATIVE-LONG-FLOAT))) (defmethod* list-max ((self t)) self) ;=========================== ; ALL-EQUAL TEST ;=========================== (defmethod* all-equal ((list list) &optional (test #'equal)) :initvals '(nil equal) :indoc '("a list" "a binary test function") :doc "Tests if all elements of <list> are equal (using <test>). Returns the value if this is true. Ex. (all-equal '(8 8 8) '=) => 8 Ex. (all-equal '(8 8 7 8) '=) => NIL" (if (loop for ll on list while (or (null (cdr ll)) ;; last elem (funcall test (car ll) (cadr ll))) finally (return ll)) ;; if this is nil, then all elements were equal NIL (values T (car list)))) ;=========================== ; INCREMENT (incf) ;=========================== (defmethod* om-1+ (a &optional (test t)) :initvals '(0 t) :indoc '("a value" "something or nil") :doc "increments <a> if <test> is non-NIL" (if test (1+ a) a)) ;=========================== ; MEAN ;=========================== (defmethod* om-mean ((self list) &optional (weights 1)) :initvals (list '(1) 1) :indoc '("list of numbers" "list of numbers") :doc "Arithmetic mean of numbers in a list. The optional input <weights> is a list of weights used to ponderate the successive elements in the list. Ex. (om-mean '(1 2 3 4)) => 2.5 Ex. (om-mean '(1 2 3 4) '(3 2 1 1)) => 2.0 " (average self weights)) ;=========================== ; RANDOM GENERATORS ;=========================== ;;; COMPATIBILITY (defmethod* aleanum ((high number) (low number)) :initvals '(0 0) :indoc '("min" "max") (om-random high low)) (defmethod* om-random ((low number) (high number)) :initvals '(0 1) :indoc '("min value" "max value") :icon :alea :doc "Returns a random number between <low> and <high>." (if (zerop (- low high)) (+ low high (- high)) (let ((low-min (min low high))) (if (or (floatp low) (floatp high)) (+ (om-random-value (- (max low high) low-min)) low-min) (+ (om-random-value (- (1+ (max low high)) low-min)) low-min))))) (defmethod* perturbation ((self number) (percent number)) :initvals '(1 0.0) :indoc '("number or list" "number or list") :icon :alea :doc "Applies to <self> a random deviation bounded by the <percent> parameter, a value in [0.0 1.0]. <self> and <percent> can be numbers or lists." (mulalea self percent)) (defmethod* perturbation ((self number) (num list)) (mapcar #'(lambda (input) (perturbation self input)) num)) (defmethod* perturbation ((self list) (num number)) (mapcar #'(lambda (input) (perturbation input num)) self)) (defmethod* perturbation ((self list) (num list)) (mapcar #'(lambda (input1 input2) (perturbation input1 input2)) self num)) ;=========================== ; SCALES ;=========================== (defmethod* om-scale ((self number) (minout number) (maxout number) &optional (minin 0) (maxin 0)) :initvals '(1 0 1 0 1) :indoc '("number or list" "a number" "a number" ) :icon :scale :doc "Scales <self> (a number or list of numbers) considered to be in the interval [<minin> <maxin>] towards the interval [<minout> <maxout>]. If [<minin> <maxin>] not specified or equal to [0 0], it is bound to the min and the max of the list. Ex. (om-scale 5 0 100 0 10) => 50 Ex. (om-scale '(0 2 5) 0 100 0 10) => (0 20 50) Ex. (om-scale '(0 2 5) 0 100) => (0 40 100) " (if (= maxin minin) minin (+ minout (/ (* (- self minin) (- maxout minout)) (- maxin minin))))) (defmethod* om-scale ((self list) (minout number) (maxout number) &optional (minin 0) (maxin 0)) (let ((min minin) (max maxin)) (when (= minin maxin) (setf min (list-min self) max (list-max self))) (when (= min max) (setf min 0 max (abs max))) (mapcar #'(lambda (item) (om-scale item minout maxout min max)) self))) (defmethod* om-scale ((self null) (minout number) (maxout number) &optional (minin 0) (maxin 0)) nil) ;------------------------------------------------------------------------ ; this comes directly from PW. makes some functions generic ; (defmethod less-tree-mapcar ((fun function) (arg1 number) (arg2 number) &optional deep) (funcall fun (list arg1) (if deep arg2 (list arg2)))) (defmethod less-tree-mapcar ((fun function) (arg1 cons) (arg2 number) &optional deep) (if (consp (first arg1)) (cons (less-tree-mapcar fun (car arg1) arg2 deep) (less-tree-mapcar fun (cdr arg1) arg2 deep)) (funcall fun arg1 (if deep arg2 (list arg2))))) (defmethod less-tree-mapcar ((fun function) (arg1 null) arg2 &optional deep) (declare (ignore arg1 arg2 deep)) nil) (defmethod less-tree-mapcar ((fun function) (arg1 number) (arg2 cons) &optional deep) (if (consp (first arg2)) (cons (less-tree-mapcar fun arg1 (car arg2) deep) (less-tree-mapcar fun arg1 (cdr arg2) deep)) (funcall fun (list arg1) (car arg2)))) (defmethod less-tree-mapcar ((fun function) arg1 (arg2 null) &optional deep) (declare (ignore arg1 arg2 deep)) nil) (defmethod less-tree-mapcar ((fun function) (arg1 cons) (arg2 cons) &optional deep) (if (or deep (consp (first arg1)) (consp (first arg2))) (cons (less-tree-mapcar fun (car arg1) (car arg2) deep) (less-tree-mapcar fun (cdr arg1) (cdr arg2) deep)) (funcall fun arg1 arg2))) (defun g-scaling/sum (list sum) "scales <list> (may be tree) so that its sum becomes <sum>. Trees must be well-formed. The children of a node must be either all leaves or all nonleaves. " (less-tree-mapcar #'(lambda (x y) (om* x (/ y (apply #'+ x)))) list sum t)) (defmethod* om-scale/sum ((self list) (sum number)) :initvals (list '(1 2 3) 10) :indoc '("number or list" "number" ) :doc "Scales <self> so that the sum of its elements become <sum> Ex. (om-scale/sum '(2 3 5) 30) => (6 9 15) " (g-scaling/sum self sum)) (defmethod* om-scale/sum ((self number) (sum number) ) (g-scaling/sum self sum)) ;=========================== ; FACTORIZATION ;=========================== (defmethod* factorize ((number number)) :initvals '(100) :indoc '("an integer") :doc "Returns the prime decomposition of <number> in the form ((prime1 exponent1) (prime2 exponent2) ...) Primes known to the system are the 1230 primes ranging from 1 to 9973. Ex. (factorize 100) => ((2 2) (5 2)) [100 = 2^2 * 5^2]" (prime-facts number)) ;; curve exp => 0 = lineaire (defun number-interpolation (n1 n2 n curve) (+ n1 (* (- n2 n1) (expt n (exp curve))))) (defun number-interpole-values (begin end samples curve) (if (<= samples 1) (list (number-interpolation begin end 0.5 curve)) (let ((step (/ 1 (1- samples)))) (loop for j from 0 to (1- samples) collect (number-interpolation begin end (* j step) (- curve)))))) (defmethod* interpolation ((begin number) (end number) (samples integer) (curve number)) :initvals '(0 1 5 0.0) :icon :bpf-interpol :indoc '("number or list" "number or list" "integer" "number") :doc "Interpolates 2 numbers or lists (from <begin> to <end>) through <samples> steps. <curve> is an exponential factor interpolation (0 = linear). " (number-interpole-values begin end samples curve)) (defmethod* interpolation ((begin number) (end list) (samples integer) (curve number)) (mat-trans (mapcar #'(lambda (item) (interpolation begin item samples curve)) end))) (defmethod* interpolation ((begin list) (end number) (samples integer) (curve number)) (mat-trans (mapcar #'(lambda (item) (interpolation item end samples curve)) begin))) (defmethod* interpolation ((begin list) (end list) (samples integer) (curve number)) (mat-trans (mapcar #'(lambda (item1 item2) (interpolation item1 item2 samples curve)) begin end))) ;============================== ; GREATEST COMMON DIVISOR ;============================== (defmethod pgcd ((a rational) (b rational)) "Find the greats common divisor bethween 2 rational." (let ((x (* (denominator a) (numerator b))) (y (* (denominator b) (numerator a))) (d (* (denominator a) (denominator b)))) (/ (gcd x y) d))) (defmethod pgcd ((a integer) (b integer)) "Find the greats common divisor bethween 2 rational." (gcd a b)) (defmethod pgcd ((a number) (b number)) "Find the greats common divisor bethween 2 rational." (pgcd (rational a) (rational b)))
22,110
Common Lisp
.lisp
543
36.858195
139
0.577825
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
43be7853efe34c6b02ab20b8619f6acb70d34a7c02275610732cf7f78be140f3
766
[ -1 ]
767
interpolations.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/interpolations.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (adapted from OM6) ;========================================================================= ;;;============================================================= ;;; FUNCTIONS FOR NUMERICAL INTERPOLATIONS, RESAMPLING, ETC... ;;;============================================================= (in-package :om) ;;;========================== ;;; ditance between points ;;;========================== (defun pts-distance (x1 y1 x2 y2) (sqrt (+ (expt (- y2 y1) 2) (expt (- x2 x1) 2)))) (defmethod om-points-distance ((p1 list) (p2 list)) (sqrt (apply '+ (mapcar #'(lambda (coord) (expt (- (cadr coord) (car coord)) 2)) (mat-trans (list p1 p2)))))) (defmethod om-points-distance ((p1 ompoint) (p2 ompoint)) (sqrt (+ (om-square (- (om-point-x p1) (om-point-x p2))) (om-square (- (om-point-y p1) (om-point-y p2)))))) ;;;========================== ;;; FUNCTION GENERATOR ;;;========================== (defun linear (x0 y0 x1 y1) (if (= x0 x1) ;;; special case/to do. For now: if x == x0, y = 1, else y = 0. (let* ((xx x0)) (eval `(function (lambda (x) (if (= x ,xx) 1 0))))) (let* ((a (/ (- y1 y0) (- x1 x0))) (b (- y1 (* x1 a)))) (eval `(function (lambda (x) (+ ,b (* x ,a)))))))) (defmethod* linear-fun ((x0 number) (y0 number) (x1 number) (y1 number)) :initvals '(0 0 1 1) :indoc '("x0" "y0" "x1" "y1") :doc "Constructs a linear function passing through the points (x0 y0) and (x1 y1). The resulting function can be connected for example to OM-SAMPLE." (linear x0 y0 x1 y1)) ;;;========================== ;;; INTERPOLATION ;;;========================== (defun x-around (x paires) "Finds pairs below-above x" (let ((plus-grand (find x paires :test #'(lambda (x r) (<= x (first r)))))) (if plus-grand (let* ((rang (if (< (1- (first (rang-p paires plus-grand 'equalp))) 0) 0 (1- (first (rang-p paires plus-grand 'equalp))))) (plus-petit (nth rang paires))) (list (if (< rang 0) plus-grand plus-petit) plus-grand)) (let ((max (car (last paires)))) (list max max))))) ;(x-around 70 '((0 0) (41 3) (50 6) (69 5) (100 8))) (defun y-around (y paires) "Finds pairs below-above y" (let ((lst '())) (loop for i in paires for r in (rest paires) do (if (or (and (<= (second i) y) (>= (second r) y)) (and (>= (second i) y) (<= (second r) y))) (push (list i r) lst))) (reverse lst))) ;(y-around 5.5 '((0 0) (41 3) (50 6) (69 5) (100 8))) (defun linear-interpol (x1 x2 y1 y2 x) " ^ | | y2|..................* | . y0|............X . | . . y1|......* . . | . . . | . . . | . . . |______._____._____.______> x1 x x2 " (if (= x1 x2) y1 (+ y1 (* (- y2 y1) (/ (- x x1) (- x2 x1)))))) (defun interpolate (list-x list-y step) (loop with x1 with y1 with x2 = (pop list-x) with y2 = (pop list-y) for pointer from (first list-x) by step if (>= pointer x2) do (setf x1 x2 y1 y2 x2 (pop list-x) y2 (pop list-y)) if (null x2) collect y1 and do (loop-finish) collect (linear-interpol x1 x2 y1 y2 pointer))) (defun interpole (list-x list-y x-min x-max nbsamples) (if (= 1 nbsamples) (list (x-transfer (mat-trans (list list-x list-y)) (+ x-min (/ (- x-max x-min) 2)))) (let* ((step (/ (- x-max x-min) (1- (float nbsamples)))) (last-point (car (last list-y))) (series (loop with x = (pop list-x) and xx = (pop list-x) and y = (pop list-y) and yy = (pop list-y) with x-index = x-min with s-index = 0 while (and xx (< s-index nbsamples)) if (and (>= x-index x) (<= x-index xx)) collect (linear-interpol x xx y yy x-index) and do (setf x-index (+ x-min (* (incf s-index) step))) else do (setf x xx xx (pop list-x) y yy yy (pop list-y))))) (if (> (+ x-min (* step (1- nbsamples))) x-max) ;; this can happend because of floatig-point errors ;; (< (length series) nbsamples) ;; equivalent (append series (list last-point)) series) ))) ;;; in om-sample for BPF ;;; it could be smart to put this directly into arithm-ser (defun sample-interval (x1 x2 nb-samples) (if (= x1 x2) (make-list nb-samples :initial-element x1) (let* ((inter (/ (- x2 x1) (1- nb-samples))) (series (loop for i from x1 to x2 by inter collect i))) (if (> (+ x1 (* inter (1- nb-samples))) x2) ;; the loop has stopped before reaching x2 ;; this can happend because of floatig-point errors ;; (< (length series) nb-samples) ;; equivalent (append series (list x2)) series)) )) ;;================================== ;; x/y transfer tools ;;;========================== (defmethod* y-transfer ((self list) (y0 number) &optional (dec nil)) :initvals (list nil 10 0) :indoc '("list of points, BPF or BPC" "Y value" "number of decimals") :icon :bpf-y-transfer :doc "Returns a list of interpolated X values corresponding to a list of points ((x1 y1) (x2 y2) ...), or a BPF/BPC (<self>) and a Y position <y0>. Optional <dec> is the number of decimals in the result." (let* ((paires self) (y-around (y-around y0 paires)) (xpts (loop for i in y-around collect (om-round (linear-interpol (second (first i)) (second (second i)) (first (first i)) (first (second i)) y0))))) (if dec (om-round xpts dec) xpts))) (defmethod* x-transfer ((self list) (x-val number) &optional (dec nil)) :icon :bpf-x-transfer :indoc '("a list or BPF" "X value" "number of decimals") :initvals '(((0 0) (100 100)) 50 nil) :doc "Returns the interpolated Y value(s) in a BPF or a list ((x1 y1) (x2 y2) ...) corresponding to an X value or a list of X values (<x-val>). Optional <dec> is the number of decimals in the result." (let* ((paires self) (bornes (x-around x-val paires)) (ypts (linear-interpol (first (first bornes)) (first (second bornes)) (second (first bornes)) (second (second bornes)) x-val))) (if dec (om-round ypts dec) ypts))) (defmethod* x-transfer ((self list) (x-val list) &optional (dec nil)) (mapcar #'(lambda (x) (x-transfer self x dec)) x-val)) ;;;========================== ;;; GENERAL SAMPLE FUNCTION ;;;========================== (defmethod* om-sample ((self t) (nbs-sr number) &optional xmin xmax dec) :initvals '(nil 10 nil nil nil) :indoc '("object to resample" "number of samples (int) or sample rate (float)" "" "" "decimals") :icon 'bpf-sample :numouts 3 :outdoc '("sampled object" "x-points" "y-points") :doc "Resamples a function, a list, a BPF or a BPC object. Returns : - The result as an object (BPF or BPC) (1st output) - The list of x points (2nd output) - The list of sample values (3rd output) If <nbs-sr> is an integer (e.g. 100) it is interpreted as the number of samples to be returned If <nbs-sr> is an float (e.g. 0.5, 1.0...) it is interpreted as the sample rate (or step between two samples) of the function to return <xmin> and <xmax> specify the x-range to resample. <dec> (decimals) is the precision of the result. " nil) (defmethod* om-sample ((self function) (nbs-sr number) &optional xmin xmax dec) :numouts 3 (let* ((x0 (if xmin (float xmin) 0.0)) (x1 (if xmax (float xmax) 1.0)) (xlist (if (integerp nbs-sr) (arithm-ser x0 x1 (float (/ (- x1 x0) (max 1 nbs-sr))) nbs-sr) (arithm-ser x0 x1 nbs-sr))) (ylist (mapcar self xlist))) (values (make-instance 'bpf :x-points xlist :y-points ylist :decimals (or dec 4)) xlist (if dec (om-round ylist dec) ylist) ) )) (defmethod* om-sample ((self symbol) (nbs-sr number) &optional xmin xmax dec) :numouts 3 (when (fboundp self) (om-sample (symbol-function self) nbs-sr xmin xmax dec))) (defmethod* om-sample ((self list) (nbs-sr number) &optional xmin xmax dec) :numouts 3 (cond ((bpf-p (car self)) (values-list (mat-trans (mapcar #'(lambda (bpf) (multiple-value-list (om-sample bpf nbs-sr xmin xmax dec))) self)))) ((numberp (car self)) (let* ((x0 (or xmin 0)) (x1 (or xmax (1- (length self)))) (lst (subseq self x0 (1+ x1))) (xpts (arithm-ser 0 (1- (length lst)) 1)) (ylist (if (integerp nbs-sr) (interpole xpts lst x0 x1 nbs-sr) (interpolate xpts lst nbs-sr))) (xlist (arithm-ser 0 (1- (length ylist)) 1))) (values (make-instance 'bpf :x-points xlist :y-points ylist :decimals (or dec 4)) xlist (if dec (om-round ylist dec) ylist) ))) (t nil))) ;;;==================================== ;;; Interpole with profile ;;; (todo: merge with "interpolation") ;;;==================================== (defmethod* interpole-points ((v1 t) (v2 t) (nbsteps integer) &optional profil) :indoc '("value 1" "value 2" "number or intermediate steps" "interpolation profile") :doc "Interpolates <nbsteps> values between <v1> and <v2> following a profile. <v1> and <v2> can be either numbers or list (supposed to be of the same length) <profile> is a BPF. If nil, a linear profile is used." (unless profil (setf profil (make-instance 'bpf))) (let ((weightfun (om-scale (nth 2 (multiple-value-list (om-sample profil (+ 2 nbsteps)))) 0.0 1.0))) (loop for i from 0 to (+ 1 nbsteps) collect (om+ (om* v2 (nth i weightfun)) (om* v1 (om- 1 (nth i weightfun))))))) ; A helper function to interpolate in the cr-control patch (defmethod* interpol-value ((list1 list) (list2 list) (nbsteps integer) i &optional profil) (nth i (interpole-points list1 list2 nbsteps profil))) ;;;==================================== ;;; Function reduction tools ;;; from S. Lemouton's code for Chroma ;;;==================================== (defmethod* reduce-points ((points list) &optional (approx 0.02)) :indoc '("a list of (x y) points or a BPF" "a number between 0.0 and 1.0") :initvals '(nil 0.02) :icon :bpf-sample :doc "Reduces <points> by removing all points closer than [<approx> * the amplitude range of the function] to the corresponding interpolated values. <approx> = 1 means the maximum reduction (all intermediate points are removed) <approx> = 0 means reduction without loss (only exact matching points are removed)" (let* ((before (list (car points))) (after (cdr points)) (ymin (cadr (car before))) (ymax (cadr (car before))) (amplitude 0)) (loop for p in after do (if (> (cadr p) ymax) (setf ymax (cadr p)) (if (< (cadr p) ymin) (setf ymin (cadr p))))) (setf amplitude (- ymax ymin)) (if (= 0. amplitude) (setf before (append before (last after))) (loop for listrest on after while (cdr listrest) do (let* ((x_val (caar listrest)) (y_val (cadar listrest)) (interpolated-y (linear-interpol (car (car (last before))) (car (cadr listrest)) (cadr (car (last before))) (cadr (cadr listrest)) x_val)) (error (/ (abs (- interpolated-y y_val)) amplitude))) (if (> error approx) (setf before (append before (list (car listrest)))))) finally (setf before (append before (last points))))) before)) (defmethod* reduce-n-points (points n &optional (precision 10) (verbose nil)) :indoc '("a list of (x y) points or a BPF" "a number (int)" "a number (int)") :initvals '(nil 20 10) :icon :bpf-sample :doc "Reduces <points> to less than <n> points using approximations with the function REDUCE-POINTS. <precision> sets the maximum number of iterations for searching the closest result possible. " (let ((borneMax t) ; si npoints borne superieure (min_factor 0) (max_factor 1) (curr_factor 0) result) (loop for i from 0 to precision do (setf result (reduce-points points curr_factor)) while (not (eq (length result) n)) do (if (> (length result) n) (setf min_factor curr_factor) (setf max_factor curr_factor)) (setf curr_factor (/ (+ min_factor max_factor) 2))) (if (and borneMax (not (eq (length result) n))) (setf result (reduce-points points max_factor))) (when verbose (om-print (format nil "reduce ~D -> ~D (approx. ~,2F %)" (length points) (length result) (* 100 curr_factor)) "REDUCE-N-POINTS")) result ))
14,386
Common Lisp
.lisp
308
38.006494
150
0.520474
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
7d861c3b06d510ba2000acffaec737802ff263688587d5e49257bd9d06bd4780
767
[ -1 ]
768
lists.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/lists.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (code from OM6) ;========================================================================= (in-package :om) (defmethod* last-elem ((list list)) :initvals '(nil) :indoc '("a list") :doc "Returns the last element of <list> Ex. (last-elem '(1 2 3 4 5)) => 5 " :icon 'list (first (last (list! list)))) (defmethod* last-n ((list list) (n integer)) :initvals '(nil 0) :indoc '("a list" "number of elements") :icon 'list :doc "Returns the <n> last elements of <list> Ex. (last-n '(1 2 3 4 5) 3) => (3 4 5) " (last list n)) (defmethod* first-n ((list list) (n integer)) :initvals '(nil 0) :indoc '("a list" "number of elements") :icon 'list :doc "Returns the <n> first elements of <list> Ex. (first-n '(1 2 3 4 5) 3) => (1 2 3) " (cond ((< (length list) n) list) (t (butlast list (- (length list) n))))) (defmethod* x-append ((l1? list) (l2? list) &rest lst?) :initvals '(nil nil nil) :indoc '("first element" "second element" "additional elements") :icon 'list :doc "Appends lists or atoms together to form a new list. Ex. (x-append '(1 2 3) '(4 5)) => (1 2 3 4 5) Ex. (x-append 1 '(4 5)) => (1 4 5) Ex. (x-append '(1 2 3) 4) => (1 2 3 4) This function also works with additional elements. Ex. (x-append '(1 2 3) 4 '(5 6 7)) => (1 2 3 4 5 6 7) " (apply 'append l1? l2? (mapcar #'list! lst?))) (defmethod* x-append ((l1? t) (l2? list) &rest lst?) (apply 'append (list l1?) l2? (mapcar #'list! lst?))) (defmethod* x-append ((l1? list) (l2? t) &rest lst?) (apply 'append l1? (list l2?) (mapcar #'list! lst?))) (defmethod* x-append ((l1? t) (l2? t) &rest lst?) (apply 'append (list l1?) (list l2?) (mapcar #'list! lst?))) (defun rev-flat (lst) (let ((l ())) (loop while lst do (if (not (consp (car lst))) (push (pop lst) l) (setq l (nconc (rev-flat (pop lst)) l)))) l)) (defun lo-flat (list) (cond ((atom list) list) ((atom (car list)) (cons (car list) (lo-flat (cdr list)))) ((atom (caar list)) (apply 'append list)) (t (cons (lo-flat (car list)) (lo-flat (cdr list)))))) (defmethod flat-low ((list list)) (lo-flat list)) (defmethod flat-once ((list list)) (if (consp (car list)) (apply 'append list) list)) (defmethod flat-one ((list list)) (loop for item in list append (list! item))) (defmethod n-flat-one ((list list) (level integer)) (let ((rep list)) (loop for i from 1 to level do (setf rep (flat-one rep))) rep)) (defmethod* flat ((lst list) &optional (level nil)) :initvals '(nil nil) :indoc '("a list" "level of parenthesis") :icon 'list :doc "Transforms a tree-list (i.e. a list of lists) into a flat list. If <level> is 1 (resp n) remove 1 (resp. n) level(s) of list imbrication. If <level> is NIL (default) remove all levels of imbrication, down to a purely flat list. Ex. (flat '((a b) c ((d e) f))) => (a b c d e f) Ex. (flat '((a b) c ((d e) f)) 1) => (a b c (d e) f) [1 level of parenthesis] " (cond ((null level) (nreverse (rev-flat lst))) ((= level 0) lst) ((and (integerp level) (plusp level)) (n-flat-one lst level)) (t lst))) (defmethod* create-list ((count integer) (elem t)) :initvals '(10 nil) :indoc '("number of elements" "initial element") :icon 'list :doc "Returns a list of length <count> filled with repetitions of element <elem> Ex. (create-list 4 'a) => (a a a a)" (make-list count :initial-element elem)) (defmethod* mat-trans ((matrix list)) :initvals '(nil) :indoc '("a list of lists") :doc "Matrix transposition. The matrix is represented by a list of rows. Each row is a list of items. Rows and columns are interchanged. Ex. (mat-trans '((1 2 3) (a b c) (4 5 6)) => ((1 a 4) (2 b 5) (3 c 6))" :icon 'mat-trans (let ((maxl (1- (loop for elt in matrix maximize (length elt)))) result) (loop for i from 0 to maxl do (push (mapcar #'(lambda (list) (nth i list)) matrix) result)) (nreverse result))) (defvar *valid-expand-chars* '(#\* #\_)) (defun is-in (list chars) (let (res) (dolist (ch chars res) (if (setq res (member ch list :test #'char=)) (return res))))) (defmethod* expand-lst ((list list)) :icon 'list :initvals '('(3*(2 4) 0_8)) :indoc '("a list to expand") :doc "Expands a list following repetition patterns. 1. <number>* (x1 ...x2) repeats the pattern x1...x2 <number> times. 2. <n>_<m>s<k> appends an arithmetic series counting from <n> to <m> by step <k>. s<k> can be omitted (k=1). Ex. (expand-lst (3* (2 4) 0_8)) => (2 4 2 4 2 4 0 1 2 3 4 5 6 7 8) Ex. (2* (a z 2* (4 12) (1_5 )) 0_16s2) => (a z 4 12 4 12 (1 2 3 4 5) a z 4 12 4 12 (1 2 3 4 5) 0 2 4 6 8 10 12 14 16)" (and list (let ((lists (list! list)) result) (loop while lists do (let ((next-elem (pop lists))) (cond ((symbolp next-elem) (let* ((form (coerce (format () "~A" next-elem) 'list)) (from-char (is-in form *valid-expand-chars*)) (char-symb (car from-char)) (third (cdr from-char)) (int (butlast form (length from-char))) up-to) (cond ((and (not third) char-symb (char= #\* char-symb) int (numberp (setq int (read-from-string (coerce int 'string))))) (push (apply #'append (make-list int :initial-element (expand-lst (pop lists)))) result)) ((and char-symb (char= #\_ char-symb) third (numberp (setq int (read-from-string (coerce int 'string))))) (if (setq from-char (member #\s ;;;[CR, 14/01/99] #\S third :test #'char=)) (progn (setq up-to (butlast third (length from-char)) char-symb (car from-char) third (cdr from-char)) (if (and char-symb (char= #\s ;;;[CR, 14/01/99] #\S char-symb) (or (null third) (numberp (setq third (read-from-string (coerce third 'string))))) (numberp (setq up-to (read-from-string (coerce up-to 'string))))) (push (arithm-ser int up-to (or third 1)) result) (push (list next-elem) result))) (progn (setq up-to (read-from-string (coerce third 'string))) (push (arithm-ser int up-to 1) result)) )) (t (push (list next-elem) result))))) ((consp next-elem) (push (list (expand-lst next-elem)) result)) (t (push (list next-elem) result))))) (apply #'append (nreverse result))))) (defmethod* group-list ((list list) (segmentation list) mode) :icon 'list :initvals '((1 2 3 4) (1 3) linear) :indoc '("list to group (anything)" "list of group lengths (numbers)" "linear or circular") :doc "Segments a <list> in successives sublists which lengths are successive values of the list <segmentation>. <mode> indicates if <list> is to be read in a circular way. Ex. (group-list '(1 2 3 4) '(1 3) 'linear) => ((1) (2 3 4)) Ex. (group-list '(1 2 3 4) '(1 2 3) 'linear) => ((1) (2 3) (4)) Ex. (group-list '(1 2 3 4) '(1 2 3) 'circular) => ((1) (2 3) (4 1 2)) " :menuins '((2 (("linear" linear) ("circular" circular)))) (let ((list2 list) (res nil)) (catch 'gl (loop for segment in segmentation while (or list2 (eq mode 'circular)) do (push (loop for i from 1 to segment when (null list2) do (case mode (linear (push sublist res) (throw 'gl 0)) (circular (setf list2 list))) end collect (pop list2) into sublist finally (return sublist)) res)) ) (nreverse res) )) (defmethod* group-list ((list list) (segmentation number) mode) (group-list list (make-list (ceiling (length list) segmentation) :initial-element segmentation) 'linear)) (defmethod* remove-dup ((list list) (test symbol) (depth integer)) :icon 'list :initvals (list '(1 2 3 4) 'eq 1) :indoc '("a list" "equality test (function or function name)" "an integer") :doc "Removes duplicates elements from <list>. If <depth> is more than 1 duplicates are removed from sublists of level <depth>. Ex. (remove-dup '(1 2 3 2 2 4) '= 1) => (1 3 2 4) Ex. (remove-dup '((1 2) (3 2 2) 4) '= 2) => ((1 2) (3 2) 4) " (remove-dup list (symbol-function test) depth)) (defmethod* remove-dup ((list list) (test function) (depth integer)) (if (<= depth 1) (remove-duplicates list :test test) (mapcar #'(lambda (x) (remove-dup x test (1- depth))) list))) (defmethod* remove-dup ((list t) (test t) (depth integer)) list) (defmethod* list-modulo ((list list) (ncol integer)) :initvals '(nil 2) :indoc '("a list" "modulo") :icon 'list :doc "Groups the elements of a list distant of a regular interval <ncol> and returns these groups as a list of lists. Ex. (list-modulo '(1 2 3 4 5 6 7 8 9) 2) => ((1 3 5 7 9) (2 4 6 8)) Ex. (list-modulo '(1 2 3 4 5 6 7 8 9) 3) => ((1 4 7) (2 5 8) (3 6 9)) " (when (and (> ncol 0) (< ncol (length list))) (list-part list ncol))) (defun list-part (list ncol) (let ((vector (make-array ncol)) (res nil)) (loop while list do (loop for i from 0 to (1- ncol) do (and list (setf (svref vector i) (push (pop list) (svref vector i)))))) (loop for i from 0 to (1- ncol) do (push (remove nil (nreverse (svref vector i))) res)) (nreverse res))) (defmethod* interlock ((lis1 list) (lis2 list) (plc1 list)) :initvals '((0 1 2 3) (a b) (1 3)) :indoc '("a list" "a list" "a list of indexes") :icon 'list :doc "Inserts the successive elements of <lis2> in <lis1> before the elements of <lis1> of respective positions from <plc1>. Ex. (interlock '(0 1 2 3 ) '(a b) '(1 3)) => (0 a 1 2 b 3)" (let ((aux) (pointeur 0)) (dotimes (n (length lis1) (reverse aux)) (when (member n plc1) (progn () (push (nth pointeur lis2) aux) (incf pointeur))) (push (nth n lis1) aux)))) (defmethod* subs-posn ((lis1 list) posn val) :initvals '((0 1 2 3) (1 3) (a b)) :indoc '("a list" "a list of indices" "a list or value") :icon 'list :doc "Substitutes the elements of <lis1> at position(s) <posn> (if they exist) with the corresponding elements in <val>. Ex. (subs-posn '(0 1 2 3) 2 'a) => (0 1 a 3) Ex. (subs-posn '(0 1 2 3) '(1 3) '(a b)) => (0 a 2 b) " (let ((copy (copy-list lis1))) (loop for item in (list! posn) for i = 0 then (+ i 1) do (setf (nth item copy) (if (listp val) (nth i val) val))) copy)) (defmethod* reduce-tree ((self t) (function symbol) &optional (accum nil)) :initvals (list '(10 10) '+ nil) :icon 'list :indoc '("a tree (list)" "a function or a patch" "a neutral value for <function>") :doc "Applies the commutative binary <function> recursively throughout the list <self>. (Applies to the first elements, then the result to the next one, and so forth until the list is exhausted.) Function '+, for instance, makes reduce-tree computing the sum of all elements in the list. Optional <accum> should be the neutral element for the <function> considered (i.e. initial result value). If <accum> is nil, figures out what the neutral can be (works for +,*,min,max)." (reduce-tree self (symbol-function function) accum)) (defmethod* reduce-tree ((self list) (function function) &optional (accum nil)) (unless accum (setf accum (neutral-element function))) (if (null self) accum (reduce-tree (rest self) function (reduce-tree (first self) function accum)))) (defmethod* reduce-tree ((self number) (function function) &optional (accum nil)) (funcall function self accum)) (defun neutral-element (function) (case (function-name function) (+ 0) (* 1) (min MOST-POSITIVE-LONG-FLOAT) (max MOST-NEGATIVE-LONG-FLOAT) (t 0))) (defmethod* rang-p ((liste list) (elem number) &optional (test 'eq) (key nil)) :initvals '((6000) 2) :indoc '("a list" "element to look for" "test function" "key function") :icon 'list :doc "Returns the position(s) of <elem> in <liste>. <test> is a function or function name used to test if the elements of the list are equal to <elem>. <key> is a function or function name that will be applied to elements before the test. Ex. (rang-p '(0 1 2 3 4 3 2) 3) => (3 5) Ex. (rang-p '(0 1 2 3 4 3 2) 3 '<) => (0 1 2 6) [elements at positions 0, 1,2 and 6 are lower than 3] " (let ((aux nil) (index 0)) (mapcar #'(lambda (z) (progn (when (funcall test (if key (funcall key z) z) elem) (push index aux)) (incf index))) liste) (reverse aux))) (defmethod* rang-p ((liste list) (elem list) &optional (test 'eq) (key nil)) (let ((aux nil) (index 0)) (mapcar #'(lambda (z) (progn (when (funcall test (if key (funcall key z) z) elem) (push index aux)) (incf index))) liste) (reverse aux))) (defmethod* list-explode ((list list) (nlists integer)) :initvals '((1 2 3 4 5 6) 2) :indoc '("List" "segment size") :icon 'list :doc "Segments <list> into <nlist> sublists of (if possible) equal length. Ex. (list-explode '(1 2 3 4 5 6 7 8 9) 2) => ((1 2 3 4 5) (6 7 8 9)) Ex. (list-explode '(1 2 3 4 5 6 7 8 9) 5) => ((1 2) (3 4) (5 6) (7 8) (9)). If the number of divisions exceeds the number of elements in the list, the divisions will have one element each, and remaining divisions are repeat the last division value. Ex. (list-explode '(1 2 3 4 5 6 7 8 9) 12) => ((1) (2) (3) (4) (5) (6) (7) (8) (9) (9) (9) (9)) " (if (> nlists (length list)) (setq list (append list (make-list (- nlists (length list)) :initial-element (first (last list)))))) (if (<= nlists 1) list (let* ((length (length list)) (low (floor length nlists)) (high (ceiling length nlists)) (step (if (< (abs (- length (* (1- nlists) high))) (abs (- length (* nlists low)))) high low)) (rest (mod length nlists)) (end (- length 1 rest)) (ser (arithm-ser 0 (1- step) 1)) res) (loop for i from 0 to end by step do (push (remove () (posn-match list (om+ i ser))) res)) (setq low (length (flat-once res))) (if (< low length) (setq res (cons (append (first res) (nthcdr low list)) (rest res)))) (cond ((> (length res) nlists) (nreverse (cons (nconc (second res) (first res)) (nthcdr 2 res)))) ((< (length res) nlists) (when (= (length (first res)) 1) (setq res (cons (nconc (second res) (first res)) (nthcdr 2 res)))) (nreverse (nconc (nreverse (list-explode (first res) (1+ (- nlists (length res))))) (rest res)))) (t (nreverse res)))))) (defmethod* list-filter ((test symbol) (list list) (mode symbol)) :initvals '(numberp (1 2 3) pass) :indoc '("function or function name" "a list" "pass or reject") :menuins '((2 (("Reject" reject) ("Pass" pass)))) :icon 'list :doc "Filters out <list> using the predicate <test>. <test> may be a function name (a symbol) or it may be a visual function or patch in 'lambda' mode. If <list> is a list of lists, the filter is applied recursively in the sub-lists. <mode> 'reject' means reject elements that verify <test>. <mode>'pass' means retain only elements that verify <test>. Ex. (list-filter 'numberp '(5 6 aaa bbb 8) 'pass) => (5 6 8) Ex. (list-filter 'numberp '(5 6 aaa bbb 8) 'reject) => (aaa bbb) " (list-filter (symbol-function test) list mode)) (defmethod* list-filter ((test function) (list list) (mode symbol)) (if (eq mode 'reject) (do-filter list #'(lambda (x) (not (funcall test x)))) (do-filter list test))) (defmethod* table-filter ((test symbol) (list list) (numcol integer) (mode symbol)) :initvals '(numberp ((1 2) (1 2)) 1 pass) :indoc '("function or function name" "list of lists" "rank" "pass or reject") :menuins '((3 (("Reject" 'reject) ("Pass" 'pass)))) :icon 'list :doc "Filters out <list> (a list of lists) using the predicate <test>. <test> may be a function name (a symbol) or it may be a visual function or patch in 'lambda' mode. The predicate <test> is applied to the element of rank <numcol> in every sublist in <list> and filters the whole sublists. <numcol> counts from 0. <mode> 'reject' means reject elements whose <numcol>th element verifies <test>. <mode>'pass' means retain only elements whose <numcol>th element verifies <test>. Ex. (table-filter 'oddp '((1 2 3) (4 5 6) (7 8 9)) 1 'pass) --> ((4 5 6)) [keeps lists which first element is odd] Ex. (table-filter 'oddp '((1 2 3) (4 5 6) (7 8 9)) 1 'reject) --> ((1 2 3) (7 8 9)) [rejects lists which first element is odd] " (table-filter (symbol-function test) list numcol mode)) (defmethod* table-filter ((test function) (list list) (numcol integer) (mode symbol)) (if (eq mode 'reject) (do-table-filter list #'(lambda (x) (not (funcall test x))) numcol) (do-table-filter list test numcol))) (defmethod* band-filter ((list list) (bounds list) (mode symbol)) :initvals '((1 2 3 4 5) ((0 2) (5 10)) pass) :indoc '("a list" "a list of (low high) pairs" "pass or reject" ) :menuins '((2 (("Reject" reject) ("Pass" pass)))) :icon 'list :doc "Filters out <list> using <bounds>. <bounds> is a pair or list of pairs (min-value max-value). If <list> is a list of lists, the filter is applied recursively in the sub-lists. If <bounds> is a list of pairs, each pair is applied to each successive element in <list> <mode> 'reject' means reject elements between the bounds <mode> 'pass' means retain only elements between the bounds " (list-filter #'(lambda (item) (some #'(lambda (bound) (and (>= item (first bound)) (<= item (second bound)))) bounds)) list mode)) (defmethod* range-filter ((list list) (posn list) (mode symbol)) :initvals '((1 2 3 4 5) ((0 1) (3 4)) reject) :indoc '("a list" "position bounds" "pass or reject") :menuins '((2 (("Reject" reject) ("Pass" pass)))) :icon 'list :doc "Select elements in <list> whose positions (couting from 0) in the list are defined by <posn> <posn> is a list of pairs (min-pos max-pos) in increasing order with no everlap. <mode> 'reject' means reject the selected elements. <mode> 'pass' means retain only the selected elements. Ex. (range-filter '(10 11 12 13 14 15 16) '((0 1) (3 4)) 'pass) => (10 11 13 14) Ex. (range-filter '(10 11 12 13 14 15 16) '((0 1) (3 4)) 'reject) => (12 13) " (loop with bound = (pop posn) for item in list for i from 0 while bound when (and (eq mode 'pass) (>= i (first bound)) (<= i (second bound))) collect item when (and (eq mode 'reject) (or (< i (first bound)) (> i (second bound)))) collect item when (> i (second bound)) do (setf bound (pop posn)))) (defmethod* posn-match ((list list) (positions list)) :initvals '((10 20 30 40 50 60 70 80 90) ((0 1) 4 (6)) ) :indoc '("a list" "a list positions") :icon 'list :doc "Constructs a new list by peeking elements in <list> at positions defined by <positions> (a list or tree of positions). <positions> supports the syntax of 'expand-lst'. Ex. (posn-match '(10 20 30 40 50 60 70 80 90) '((0 1) 4 (6))) => ((10 20) 40 (60)) Ex. (posn-match '(10 20 30 40 50 60 70 80 90) '(3*(0) 3_6)) => (10 10 10 40 50 60 70) " (do-posn-match list (expand-lst positions))) (defmethod* posn-match ((list list) (positions integer) ) (nth positions list )) (defmethod do-posn-match ((self list) (positions list)) (cond ((numberp positions) (nth positions self)) ((listp positions) (loop for pos in positions collect (do-posn-match self pos))))) (defmethod do-posn-match ((self list) (positions number)) (nth positions self)) (defmethod do-filter ((self t) (test function)) (if (funcall test self) self 'fail)) (defmethod do-filter ((self cons) (test function)) (loop for item in self for elt = (do-filter item test) when (not (eq elt 'fail)) collect elt)) (defmethod do-table-filter ((list list) (test function) (numcol integer)) (loop for sublist in list when (funcall test (nth numcol sublist)) collect sublist)) ;=========================== ; Utils ;=========================== ;find all positions of an element in a list (defun om-all-positions (a L) (loop for element in L and position from 0 when (eql element a) collect position)) (defun remove-nth (n lst) (if (= n 0) (cdr lst) (append (subseq lst 0 n) (subseq lst (1+ n) (length lst))))) (defun delete-nth (n lst) (if (zerop n) (cdr lst) (let ((cons (nthcdr (1- n) lst))) (if cons (setf (cdr cons) (cddr cons)) cons)))) (defun insert-after (lst index newelt) (push newelt (cdr (nthcdr index lst))) lst)
23,563
Common Lisp
.lisp
487
39.603696
173
0.557537
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
f0030ba85c30a3a0a22ba95d2ac67ba6f447c4abd939f3dc4681043dbc559f9c
768
[ -1 ]
769
series.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/series.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;========================================================================= ; Authors: G. Assayag, C. Agon, J. Bresson (code from OM6) ;========================================================================= (in-package :om) (defmethod* x->dx ((self list)) :initvals '(0 1) :indoc '("a list of numbers") :icon 'series :doc "Computes a list of intervals from a list of points. X->DX can be used for instance to get intervals from absolute pitches or to get a list of durations from time onsets: Ex. (x->dx '(6000 6700 6900)) => (700 200) Ex. (x->dx '(0 1000 1200 2000 5000)) => (1000 200 800 3000) " (loop for x in self for y in (rest self) collect (- y x)) ) (defmethod* dx->x ((start number) (list list)) :initvals '(0 (1 1)) :indoc '("a number" "a list of numbers") :icon 'series :doc "Computes a list of points from a list of intervals and a initial point (<start>) DX->X can be used for instance to get absolute pitches from intervals or to get onsets from durations: Ex. (dx->x 6000 '(700 200)) => (6000 6700 6900) Ex. (dx->x 0 '(1000 200 800 3000)) => (0 1000 1200 2000 5000)) " (cons start (loop for dx in list sum dx into thesum collect (+ start thesum)) )) ;=========================== ; ARITHMETIC SERIES ;=========================== (defmethod* arithm-ser ((begin number) (end number) (step number) &optional (nummax MOST-POSITIVE-FIXNUM)) :initvals `(0 10 1 ,MOST-POSITIVE-FIXNUM) :indoc '("begin" "end " "step" "nummax") :icon 'series :doc "Arithmetic series: returns a list of numbers from <begin> to <end> with increment of <step>. <nummax> limits the number of elements returned. Ex. (arithm-ser 1 5 0.5) => (1 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0)" (if (plusp step) (loop for i from begin to end by step for counter from 1 to nummax collect i) (loop for i from begin downto end by (abs step) for counter from 1 to nummax collect i))) ;=========================== ; FIBONACCI SERIES ;=========================== (defmethod* fibo-ser ((seed1 number) (seed2 number) (limit number) &optional (begin 0) (end MOST-POSITIVE-FIXNUM)) :initvals `(0 1 10 0 ,MOST-POSITIVE-FIXNUM) :indoc '("a number" "a number" "a number" "a number" "a number") :icon 'series :doc "Fibonacci series: f(i) = f(i-1) + f(i-2) <seed1> = f(0) the first element of the series <seed1> = f(1) the second element of the series <limit> is the limit of this list. <begin> and <end> can be used to limit the calculation of the series. Ex. (fibo-ser 0 1 10) => (0 1 1 2 3 5 8) Ex. (fibo-ser 1 3 10) => (1 3 4 7) " (labels ((compute-fibo (a b m n) (cond ((> m n) (values nil nil)) ((= m n) (values a b)) (t (compute-fibo b (+ a b) (1+ m) n))))) (let (res) (multiple-value-bind (ac1 ac2) (compute-fibo seed1 seed2 0 begin) (list ac1 ac2) ;(if (< begin 2) (if (and ac1 (> limit ac1)) (push ac1 res) ) (if (> limit ac2) (push ac2 res)) (setf res (dotimes (k (- end begin 1) (nreverse res)) (multiple-value-bind (a b) (compute-fibo ac1 ac2 (+ begin k) (+ begin k 1)) (setq ac1 a ac2 b) (if (> limit b) ; (and (<= (length res) nummax) (> limit b)) (push b res) (return (nreverse res))))) ) )))) ;=========================== ; GEOMETRIC SERIES ;=========================== (defmethod* geometric-ser ((seed number) (factor number) (limit number) &optional (nummax (expt 2 32)) (begin 0) (end (expt 2 32))) :initvals '(1 2 10 10 0 10) :indoc '("seed" "factor" "limit" "nummax" "begin" "end") :icon 'series :doc "Geometric series: starts from <seed> and returns a list with f(i) = factor * f(i-1) <limit> is the limit of returned list list. <begin> and <end> delimit the series. <nummax> limits the number of elements. Ex. (geometric-ser 1 3 60) => (1 3 9 27) Ex. (geometric-ser 2 3 60) => (2 6 18 54) " (let ((test (if (< factor 1) #'< #'>)) res) (do ((accum seed (* accum factor)) (index 0 (1+ index))) ((funcall test accum limit) (nreverse res)) (when (> (length res) nummax) (return (nreverse res))) (when (> index end) (return (nreverse res))) (unless (< index begin) (push accum res))))) ;=========================== ; PRIME NUMBERS ;=========================== (defvar *prime-numbers*) (setf *prime-numbers* #(1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083 3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221 3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331 3343 3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467 3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581 3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 3691 3697 3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823 3833 3847 3851 3853 3863 3877 3881 3889 3907 3911 3917 3919 3923 3929 3931 3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073 4079 4091 4093 4099 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211 4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 4297 4327 4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457 4463 4481 4483 4493 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591 4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721 4723 4729 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861 4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973 4987 4993 4999 5003 5009 5011 5021 5023 5039 5051 5059 5077 5081 5087 5099 5101 5107 5113 5119 5147 5153 5167 5171 5179 5189 5197 5209 5227 5231 5233 5237 5261 5273 5279 5281 5297 5303 5309 5323 5333 5347 5351 5381 5387 5393 5399 5407 5413 5417 5419 5431 5437 5441 5443 5449 5471 5477 5479 5483 5501 5503 5507 5519 5521 5527 5531 5557 5563 5569 5573 5581 5591 5623 5639 5641 5647 5651 5653 5657 5659 5669 5683 5689 5693 5701 5711 5717 5737 5741 5743 5749 5779 5783 5791 5801 5807 5813 5821 5827 5839 5843 5849 5851 5857 5861 5867 5869 5879 5881 5897 5903 5923 5927 5939 5953 5981 5987 6007 6011 6029 6037 6043 6047 6053 6067 6073 6079 6089 6091 6101 6113 6121 6131 6133 6143 6151 6163 6173 6197 6199 6203 6211 6217 6221 6229 6247 6257 6263 6269 6271 6277 6287 6299 6301 6311 6317 6323 6329 6337 6343 6353 6359 6361 6367 6373 6379 6389 6397 6421 6427 6449 6451 6469 6473 6481 6491 6521 6529 6547 6551 6553 6563 6569 6571 6577 6581 6599 6607 6619 6637 6653 6659 6661 6673 6679 6689 6691 6701 6703 6709 6719 6733 6737 6761 6763 6779 6781 6791 6793 6803 6823 6827 6829 6833 6841 6857 6863 6869 6871 6883 6899 6907 6911 6917 6947 6949 6959 6961 6967 6971 6977 6983 6991 6997 7001 7013 7019 7027 7039 7043 7057 7069 7079 7103 7109 7121 7127 7129 7151 7159 7177 7187 7193 7207 7211 7213 7219 7229 7237 7243 7247 7253 7283 7297 7307 7309 7321 7331 7333 7349 7351 7369 7393 7411 7417 7433 7451 7457 7459 7477 7481 7487 7489 7499 7507 7517 7523 7529 7537 7541 7547 7549 7559 7561 7573 7577 7583 7589 7591 7603 7607 7621 7639 7643 7649 7669 7673 7681 7687 7691 7699 7703 7717 7723 7727 7741 7753 7757 7759 7789 7793 7817 7823 7829 7841 7853 7867 7873 7877 7879 7883 7901 7907 7919 7927 7933 7937 7949 7951 7963 7993 8009 8011 8017 8039 8053 8059 8069 8081 8087 8089 8093 8101 8111 8117 8123 8147 8161 8167 8171 8179 8191 8209 8219 8221 8231 8233 8237 8243 8263 8269 8273 8287 8291 8293 8297 8311 8317 8329 8353 8363 8369 8377 8387 8389 8419 8423 8429 8431 8443 8447 8461 8467 8501 8513 8521 8527 8537 8539 8543 8563 8573 8581 8597 8599 8609 8623 8627 8629 8641 8647 8663 8669 8677 8681 8689 8693 8699 8707 8713 8719 8731 8737 8741 8747 8753 8761 8779 8783 8803 8807 8819 8821 8831 8837 8839 8849 8861 8863 8867 8887 8893 8923 8929 8933 8941 8951 8963 8969 8971 8999 9001 9007 9011 9013 9029 9041 9043 9049 9059 9067 9091 9103 9109 9127 9133 9137 9151 9157 9161 9173 9181 9187 9199 9203 9209 9221 9227 9239 9241 9257 9277 9281 9283 9293 9311 9319 9323 9337 9341 9343 9349 9371 9377 9391 9397 9403 9413 9419 9421 9431 9433 9437 9439 9461 9463 9467 9473 9479 9491 9497 9511 9521 9533 9539 9547 9551 9587 9601 9613 9619 9623 9629 9631 9643 9649 9661 9677 9679 9689 9697 9719 9721 9733 9739 9743 9749 9767 9769 9781 9787 9791 9803 9811 9817 9829 9833 9839 9851 9857 9859 9871 9883 9887 9901 9907 9923 9929 9931 9941 9949 9967 9973)) (defun test-prime (n primes) (or (member n primes) (and (> n (car (last primes))) (dolist (p primes) (when (> p (sqrt n)) (return-from test-prime t)) (when (zerop (mod n p)) (return-from test-prime nil)))))) (defmethod* prime? ((n number)) :initvals '(0) :indoc '("a number") :doc "Tests if <n> is a prime number. <number> must be smaller than 99460729. Ex. (prime? 53) => T Ex. (prime? 56) => NIL " (and (test-prime n (coerce *prime-numbers* 'list)) t)) ;=========================== ; PRIME SERIES ;=========================== (defun gen-prime (pmax maxnum) (let ((prime-list (list 2 )) (last)) (setf last (last prime-list)) (do ((i (1+ (first last)) (1+ i))) ((or (> i pmax) (> (length prime-list) (- maxnum 1))) prime-list) (when (test-prime i prime-list) (setf (cdr last) (cons i nil) last (cdr last)))) (coerce (cons 1 prime-list) 'vector))) (defmethod* prime-ser ((max number) &optional (numelem (expt 2 32))) :initvals '(100 10) :indoc '("max prime" "max elements") :icon 'series :doc "Prime numbers series: returns the set of prime-numbers ranging from 0 upto <max>. The optional parametre <numelem> limits the number of elements." (coerce (gen-prime max numelem) 'list)) ;=========================== ; PRIME FACTORS ;=========================== (defun prime-facts (x) (let ((ip 1) (r) (n 0)) (loop while (and (> x 1) (<= (* (aref *prime-numbers* ip) (aref *prime-numbers* ip)) x)) do (when (= 0 (mod x (aref *prime-numbers* ip))) (setq n 1) (loop while (= 0 (progn (setq x (/ x (aref *prime-numbers* ip))) (mod x (aref *prime-numbers* ip)))) do (incf n)) (push (list (aref *prime-numbers* ip) n) r)) (incf ip)) (when (/= x 1) (push (list x 1) r)) (or (reverse r) (list (list 1 1))))) (defmethod* prime-factors ((number number)) :initvals '(100) :indoc '("number") :doc "Returns the prime decomposition of <number> in the form (... (prime exponent) ...) Primes known to the system are the 1230 primes ranging from 1 to 9973." (prime-facts number)) ;=========================== ; INHARMONIC SERIES ;=========================== (defmethod* inharm-ser ((begin number) (dist number) (npart number)) :indoc '("begin" "distortion" "number of elements (partials)") :initvals '(1 1 1) :icon 'series :doc "Generates a list of <npart> partials from <begin> when partial n = <begin> * n^<dist>" (let ((L ())) (dotimes (n npart (reverse L)) (push (* begin (expt (1+ n) dist)) L))))
14,783
Common Lisp
.lisp
242
52.640496
120
0.615619
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
9278d4f5cd74318bbe5037443c2f11a1291e4cb128164b93df0063780a4b32bb
769
[ -1 ]
770
modulations.lisp
cac-t-u-s_om-sharp/src/packages/basic/functions/modulations.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson, Marco Stroppa ;============================================================================ ;;;=========================== ;;; Parameter modulation effects ;;;=========================== (in-package :om) (defun train (freqs dur) (let ((delta 0.01) ; if freq<0.01, keep this freq to compute the increment (t0 0) (rep (list 0.0)) (realdur (+ dur 0.0002))) ; to avoid roundup errors (loop while (< t0 realdur) do (let ((f0 (x-transfer freqs t0))) (if (< f0 delta) (incf t0 (/ 1.0 delta)) (progn (incf t0 (/ 1 (float f0))) (pushr t0 rep))))) rep)) (defclass processing-function () ()) (defmethod generate-function-bpfs (fun begin end resolution) (om-beep-msg (string+ "Warning: unknown type of processing function: " fun))) (defmethod generate-function-bpfs ((fun bpf) begin end resolution) (list fun)) (defmethod generate-function-bpfs ((fun list) begin end resolution) (loop for f in fun append (generate-function-bpfs f begin end resolution))) (defmethod! param-process (initval process duration kt op &optional decimals) :menuins '((4 (("add" 'a) ("multiply" 'm)))) :initvals '(nil nil nil nil 'a) :indoc '("initial value or BPF" "processing function(s)" "process duration" "control period" "operator" "number of decimals (result)") :outdoc '("processed values (BPF)") :icon :process :doc "Generates a modulated BPF starying from <initval> and <process>. - <initval> can be either a simple value or a BPF. - <process> can be either one of VIBRATO or JITTER function, a BPF or a list of several of them. The resulting BPF is a modulation of <initval> following the curve or functions in <process> applied on a given <duration> and at a given control period <kt>. - <op> determines whether the effet is applied as a multiplication (Y = X * FACT) of the initial values, or as an addition. The addition actually corresponds to a proportinal modulation Y = X + (X * FACT). Notes: - <kt> is not considered in JITTER effects where the period is determined by the jitter frequency(ies). If not specified, it is automatically set for VIBRATO effects at 1/4*f_vib. - <duration> is not considered in BPF effects where it is determined by the BPF itself (time = x axis in seconds) " (let* ((xinit (if (bpf-p initval) (x-points initval) '(0.0 1.0))) (dur (or duration (- (car (last xinit)) (car xinit)))) (begin (car xinit)) (end (+ begin dur)) (dec (or decimals (and (bpf-p initval) (decimals initval)) 6)) (jit-bpfs (generate-function-bpfs process begin end kt)) (final-jit (if (= 1 (length jit-bpfs)) (car jit-bpfs) (merge-bpfs jit-bpfs))) (jit-points (point-pairs final-jit)) (ope (cond ((equal op 'a) #'(lambda (x a) (+ x (* x a)))) ((equal op 'm) #'*) (t op)))) (if (numberp initval) (make-instance 'bpf :x-points (mapcar 'car jit-points) :y-points (mapcar #'(lambda (pt) (apply ope (list initval (cadr pt)))) jit-points) :decimals dec) (let* ((init-points (point-pairs initval)) ;(all-points (sort (append init-points jit-points) '< :key 'car)) (all-points jit-points) ; (if resolution (precise-arithm-ser begin end resolution) ...) (all-x-points (mapcar 'car all-points))) (make-instance 'bpf :x-points all-x-points :y-points (loop for pt in all-points collect (let ((val (x-transfer init-points (car pt) dec))) (apply ope (list val (cadr pt))) )) :decimals dec) )) )) (defun precise-arithm-ser (begin end step) (let* ((ndec (length (cadr (multiple-value-list (string-until-char (format nil "~D" step) "."))))) (tmpfact (expt 10 ndec))) (om/ (arithm-ser (* begin tmpfact) (* end tmpfact) (* step tmpfact)) tmpfact))) (defun merge-bpfs (bpf-list) (let* ((points (mapcar #'point-pairs bpf-list)) (xpts (sort (remove-duplicates (loop for bp in points append (car (mat-trans bp))) :test '=) '<)) (dec (list-max (mapcar 'decimals bpf-list)))) (make-instance 'bpf :x-points xpts :y-points (loop for xpt in xpts collect (apply '+ (mapcar #'(lambda (bpfptlist) (x-transfer bpfptlist xpt dec)) points))) :decimals dec))) (defclass! jitter-effect (processing-function) ((freq :accessor freq :initarg :freq :initform 20) (amp :accessor amp :initarg :amp :initform 1.0)) (:icon :effect-jit)) (defmethod! jitter (freqs amps) :initvals '(20 1.0) :indoc '("jitter frequency(-ies)" "jitter amplitude(s)") :outdoc '("jitter effect") :icon :effect-jit :doc "Generates a JITTER effect (aleatoric pertubation) to be connected to PARAM-PROCESS in order to modulate an input value. <freqs> and <amps> can be single values or lists of values." (make-instance 'jitter-effect :freq freqs :amp amps)) (defmethod generate-function-bpfs ((fun jitter-effect) begin end resolution) ;; ignore resolution (let* ((freqs (list! (freq fun))) (amps (if (consp (amp fun)) (amp fun) (make-list (length freqs) :initial-element (amp fun))))) (loop for f in freqs for a in amps collect (let ((x-list (if (bpf-p f) (om+ begin (train f (- end begin))) (precise-arithm-ser begin end (/ 1.0 f))))) (make-instance 'bpf :x-points x-list :y-points (loop for x in x-list collect (let ((amp (if (bpf-p a) (x-transfer a x) a))) (om-random (- amp) amp))) :decimals 6))))) (defclass! vibrato-effect (processing-function) ((freq :accessor freq :initarg :freq :initform 6.0) (amp :accessor amp :initarg :amp :initform 0.06) (ph :accessor ph :initarg :ph :initform 0.0)) (:icon :effect-vib)) (defmethod! vibrato (freqs amps &optional (ph 0.0)) :initvals '(6.0 0.06 0.0) :indoc '("vibrato frequency(-ies)" "vibrato amplitude(s)" "initial phase [rad]") :outdoc '("vibrato effect") :icon :effect-vib :doc "Generates a VIBRATO effect (sinusoidal modulation) to be connected to PARAM-PROCESS in order to modulate an input value. <freqs> and <amps> can be single values or lists of values, <ph> is the initial phase." (make-instance 'vibrato-effect :freq freqs :amp amps :ph ph)) (defmethod generate-function-bpfs ((fun vibrato-effect) begin end resolution) (let* ((freqs (list! (freq fun))) (phase (if (consp (ph fun)) (ph fun) (make-list (length freqs) :initial-element (ph fun)))) (amps (if (consp (amp fun)) (amp fun) (make-list (length freqs) :initial-element (amp fun)))) (res (or resolution (om-beep-msg "Warning: no resolution specified for the vibrato. Default= 1 / (4 * f)")))) (loop for f in freqs for a in amps for p in phase collect (let* ((x-list (precise-arithm-ser begin end (or res (/ 1 (float (* 4 (if (bpf-p f) (list-max (y-points f)) f))))))) (f-vals (if (bpf-p f) (let* ((fpts (point-pairs f)) (fx (om-scale (mapcar 'car fpts) begin end)) (fy (mapcar 'cadr fpts))) (x-transfer (mat-trans (list fx fy)) x-list)) f)) (sin-vals (if (listp f-vals) (let ((cycles-beg (train (mat-trans (list x-list f-vals)) (- end begin)))) (loop for c on cycles-beg when (cadr c) append (let* ((t1 (car c)) (t2 (cadr c)) (n (length (band-filter x-list (list (list t1 t2)) 'pass)))) (nth 2 (multiple-value-list (om-sample #'(lambda (x) (sin (+ x p))) n 0 (* 2 pi) 3)))))))) (a-vals (if (bpf-p a) (let* ((apts (point-pairs a)) (ax (om-scale (mapcar 'car apts) begin end)) (ay (mapcar 'cadr apts))) (x-transfer (mat-trans (list ax ay)) x-list)) a))) (make-instance 'bpf :x-points x-list :y-points (loop for x in x-list for i = 0 then (+ i 1) collect (* (if (listp a-vals) (nth i a-vals) a-vals) (if sin-vals (nth i sin-vals) (sin (+ p (* 2 pi x (car (list! f-vals)))))) )) :decimals 6)))))
9,887
Common Lisp
.lisp
166
46.506024
205
0.534132
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
503414cd48897b80d354e9ea0763bd2a98ac380472dff4c9c568ab73d6e5306c
770
[ -1 ]
771
automation.lisp
cac-t-u-s_om-sharp/src/packages/basic/automation/automation.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; Author: D. Bouche ;========================================================================= ;=========================================================================== ; Automations ;=========================================================================== (in-package :om) ;;=========================================================================== ;;;Automation Point = A point to define a curve between two dates ;;=========================================================================== ;;;Structure (defstruct (automation-point (:include bpfpoint) ;(:print-object ; (lambda (a stream) ; (print-unreadable-object (a stream :type t :identity t) ; (princ `(:value ,(ap-y a) :at ,(ap-x a) :ms) stream)))) (:conc-name ap-)) (coeff 0.5) (fun nil) (lock nil)) (defmethod item-get-time ((self automation-point)) (om-point-x self)) (defmethod item-set-time ((self automation-point) time) (setf (ap-x self) time)) (defmethod item-get-internal-time ((self automation-point)) (om-point-x self)) (defmethod item-set-internal-time ((self automation-point) time) nil) (defmethod item-get-type ((self automation-point)) (ap-type self)) (defmethod item-set-type ((self automation-point) type) (setf (ap-type self) type)) (defmethod items-merged-p ((i1 automation-point) (i2 automation-point)) (= (ap-x i1) (ap-x i2))) (defmethod items-distance ((i1 automation-point) (i2 automation-point)) (- (ap-x i2) (ap-x i1))) (defun om-make-automationpoint (x y &optional type) (declare (ignore type)) (make-automation-point :x x :y y)) (defmethod get-coeff ((self automation-point)) (ap-coeff self)) (defmethod om-copy ((self automation-point)) (make-automation-point :x (ap-x self) :y (ap-y self) :lock (ap-lock self) :coeff (ap-coeff self))) ;;=========================================================================== ;;;Automation = An object containing automation points ;;=========================================================================== ;;;Structure (defclass automation (BPF) ((x-points :initform '(0.0 2000.0) :initarg :x-points) (y-points :initform '(0.0 100.0) :initarg :y-points) (c-points :initform '(0.5 0.5) :accessor c-points :initarg :c-points)) (:default-initargs :interpol (make-number-or-nil :number 10 :t-or-nil t)) ) (defmethod automation-stretch ((self automation) k) (let ((res (make-instance 'automation))) (setf (point-list res) (mapcar #'(lambda (pt) (let ((ptn (om-copy pt))) (setf (ap-x ptn) (* (ap-x ptn) k)) ptn)) (point-list self))) res)) ;(defmethod x-points ((self automation)) ; (mapcar 'start-date (point-list self))) ;(defmethod y-points ((self automation)) ; (mapcar 'start-value (point-list self))) (defmethod c-points ((self automation)) (mapcar 'ap-coeff (point-list self))) ;;;Property list (like bpf but hidden interpolation) (defmethod get-properties-list ((self automation)) (hide-properties (call-next-method) '(:interpol))) ;;;Object duration (defmethod get-obj-dur ((self automation)) (start-date (last-elem (point-list self)))) ;;;Getters and Setters;;; ;;;Point start date (x) (defmethod start-date ((self automation-point)) (ap-x self)) (defmethod (setf start-date) (date (self automation-point)) (setf (ap-x self) date)) ;;;Point end date (next point x) (defmethod end-date ((self automation-point) (obj automation)) (let ((np (next-point obj self))) (start-date (or np self)))) ;;;Point start value (y) (defmethod start-value ((self automation-point)) (ap-y self)) (defmethod (setf start-value) (val (self automation-point)) (setf (ap-y self) val)) ;;;Point end value (next-point y) (defmethod end-value ((self automation-point) (obj automation)) (let ((np (next-point obj self))) (start-value (or np self)))) ;;;Point function (defmethod fun ((self automation-point) (obj automation)) (or (ap-fun self) (setf (ap-fun self) (get-function self obj)))) (defmethod (setf fun) (f (self automation-point)) (setf (ap-fun self) f)) ;;;Get point function: ;x = start-date -> end-date ;y = start-value -> end-value ;curve shape <-> coeff (defmethod get-function ((self automation-point) (obj automation)) (if (= (start-value self) (end-value self obj)) (constantly (start-value self)) #'(lambda (d) (+ (* (expt (/ (max 0 (- d (start-date self))) (- (end-date self obj) (start-date self))) (log 0.5 (ap-coeff self))) (- (end-value self obj) (start-value self))) (start-value self))))) ;;;Initialization (defmethod initialize-instance :after ((self automation) &rest args) ;(loop for coeff in (getf args :c-points) ; for pt in (point-list self) ; do (setf (ap-coeff pt) coeff)) self) (defmethod set-bpf-points ((self automation) &key x y z time time-types) (declare (ignore z time time-types)) (let ((point-list (make-points-from-lists (or x (x-values-from-points self)) ; (slot-value self 'x-points)) (or y (y-values-from-points self)) ; (slot-value self 'y-points)) (decimals self) 'om-make-automationpoint))) ;;; verify this c-cpoints slot management... (loop for coeff in (slot-value self 'c-points) for pt in point-list do (setf (ap-coeff pt) coeff)) (setf (point-list self) point-list) (setf (slot-value self 'x-points) NIL) (setf (slot-value self 'y-points) NIL))) (defmethod om-point-mv ((point automation-point) &key x y) (if (and x (not (ap-lock point))) (setf (ap-x point) (+ (ap-x point) x))) (if y (setf (ap-y point) (+ (ap-y point) y))) point) ;;;Refresh points functions (useful?) (defmethod refresh-automation-points ((self automation)) (loop for pt in (point-list self) do (setf (ap-fun pt) (get-function pt self)))) ;;;Get next point (defmethod next-point ((self automation) (pt automation-point)) (nth (1+ (position pt (point-list self))) (point-list self))) ;;;Get previous point (defmethod prev-point ((self automation) (pt automation-point)) (if (not (eq pt (car (point-list self)))) (nth (1- (position pt (point-list self))) (point-list self)))) ;;;Draw (defmethod draw-mini-view ((self automation) (box t) x y w h &optional time) (let* ((points (point-list self)) (y (+ y 10)) (h (- h 20)) (npts 100) ranges step) (when points (setq ranges (list (start-date (car points)) (start-date (last-elem points)) (reduce #'min points :key 'start-value) (reduce #'max points :key 'start-value))) (when (= (car ranges) (cadr ranges) (setf (cadr ranges) (+ (cadr ranges) 1000)))) (setq step (/ (- (cadr ranges) (car ranges)) npts)) (multiple-value-bind (fx ox) (conversion-factor-and-offset (car ranges) (cadr ranges) w x) (multiple-value-bind (fy oy) ;;; Y ranges are reversed !! (conversion-factor-and-offset (cadddr ranges) (caddr ranges) h y) (om-with-fg-color (om-def-color :gray) (loop for pt in points do (progn (om-draw-circle (+ ox (* fx (start-date pt))) (+ oy (* fy (start-value pt))) 3 :fill t) (let (val lastti) (loop with prevvi = (start-value pt) for ti from (+ step (start-date pt)) to (end-date pt self) by step do (om-draw-line (+ ox (* fx (- ti step))) (+ oy (* fy prevvi)) (+ ox (* fx ti)) (+ oy (* fy (setq val (funcall (fun pt self) ti))))) (setq prevvi val lastti ti)) (if (and lastti val) (om-draw-line (+ ox (* fx lastti)) (+ oy (* fy val)) (+ ox (* fx (end-date pt self))) (+ oy (* fy (end-value pt self)))))) )))))))) ;;;GET THE VALUE OF THE AUTOMATION FUNCTION AT A SPECIFIC DATE (defmethod get-value-at-time-unit ((self automation) date) (funcall (fun (nth (max 0 (1- (or (position date (point-list self) :test '< :key 'start-date) (length (point-list self))))) (point-list self)) self) date)) ;;;Scheduler Redefinitions (defmethod get-action-list-for-play ((self automation) time-interval &optional parent) (when (action-fun self) (loop for ti from (car time-interval) to (1- (cadr time-interval)) by (number-number (interpol self)) collect (let ((tmp ti)) (list tmp #'(lambda () (funcall (action-fun self) (list tmp (get-value-at-time-unit self tmp)))))))))
10,019
Common Lisp
.lisp
211
38.810427
121
0.535081
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
3d1e1d7011ef6575e78ad1d53028c0c12598bfa4aa503b60686fe702fad4a6a1
771
[ -1 ]
772
automation-editor.lisp
cac-t-u-s_om-sharp/src/packages/basic/automation/automation-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; Author: D. Bouche ;============================================================================ ;;=========================================================================== ; Automation Editor ;;=========================================================================== (in-package :om) ;;;Editor class (defmethod get-editor-class ((self automation)) 'automation-editor) (defclass automation-editor (bpf-editor) () (:default-initargs :make-point-function 'om-make-automationpoint)) (defclass automation-panel (bpf-panel om-tt-view) ()) (defmethod get-curve-panel-class ((self automation-editor)) 'automation-panel) (defmethod draw-modes-for-object ((self automation-editor)) '(:default :lines)) (defmethod insert-point-at-pix ((editor automation-editor) (object automation) position &optional (time nil)) (let ((res (call-next-method))) (refresh-automation-points object) res)) (defmethod delete-editor-selection ((self automation-editor)) (call-next-method) (refresh-automation-points (object-value self))) (defmethod draw-coeff-ruler ((self automation-panel) position size) (let* ((h (h self)) (w (w self)) (x (om-point-x position)) (left-side (> x (/ w 2.0))) (xr (if left-side (- x 20) (+ x 20))) (xc (if left-side (- xr 24) (+ xr 10)))) (om-with-line-size 1 (om-with-fg-color (om-def-color :dark-gray) (om-draw-line xr 0 xr h) (loop for y from 0 to 1 by (float (/ 1 10)) for y2 = (abs (1- y)) do (om-draw-line (- xr 4) (* y2 h) (+ xr 4) (* y2 h)) (if (> y 0) (om-with-font (om-def-font :tiny) (om-draw-string xc (+ (* y2 h) 2) (format nil "~1$" y))))))))) (defmethod draw-grid-from-ruler ((self automation-panel) (ruler y-ruler-view)) (let ((unit-dur (get-units ruler))) (loop for line from (* (ceiling (v1 ruler) unit-dur) unit-dur) to (* (floor (v2 ruler) unit-dur) unit-dur) by unit-dur do (let ((y (ruler-value-to-pix ruler line))) (om-draw-string 0 y (number-to-string line)) (draw-grid-line-from-ruler self ruler y))))) ;;;Draw a vertical ruler when holding shift while moving the mouse ;;;Only when stopped to not kill the cursor (defmethod om-view-mouse-motion-handler ((self automation-panel) position) (if (eq (state (object-value (editor self))) :stop) (if (om-shift-key-p) (om-start-transient-drawing self #'draw-coeff-ruler position (omp 0 2)) (om-stop-transient-drawing self))) ;(call-next-method) ) ;;;Same as for bpf-panel with one more option: ;;;click when holding shift in mouse mode changes coeff (curve shape) (defmethod om-view-click-handler ((self automation-panel) position) (if (and (equal (edit-mode (editor self)) :mouse) (om-shift-key-p)) (let* ((p0 position) (obj (object-value (editor self)))) (close-point-editor (editor self)) (om-init-temp-graphics-motion self position nil :motion #'(lambda (view position) (declare (ignore view)) (let ((pos (position (pix-to-x self (om-point-x p0)) (point-list obj) :test '<= :key 'ap-x)) (val (float (/ (om-point-y position) (h self))))) (when (and pos (> pos 0) (<= pos (length (point-list obj)))) (setf (ap-coeff (nth (1- pos) (point-list obj))) (max 0.00001 (min 0.95 val))) ;(update-automation-data obj) (om-invalidate-view self))))) ) (call-next-method))) ;; makes everypoint equal to the predecessor (defun egalise-points (editor) (let* ((bpf (object-value editor)) (points (loop for pos in (selection editor) collect (nth pos (point-list bpf))))) (loop for point in points when (prev-point bpf point) do (om-point-set point :y (om-point-y (prev-point bpf point)))) )) (defun lock-selection (editor) (let* ((bpf (object-value editor)) (points (loop for pos in (selection editor) collect (nth pos (point-list bpf))))) (loop for point in points do (setf (ap-lock point) (not (ap-lock point)))))) (defmethod editor-key-action ((editor automation-editor) key) (case key (#\= (egalise-points editor) (editor-invalidate-views editor) (report-modifications editor)) (#\b (lock-selection editor) (editor-invalidate-views editor)) (otherwise (call-next-method)) )) (defmethod draw-one-bpf ((obj automation) view editor foreground? &optional x1 x2 y1 y2) (let ((points (point-list obj)) (selection (and foreground? (selection editor))) (show-indice (editor-get-edit-param editor :show-indices))) (when points (let* ((t1 (/ (x1 view) (expt 10 (decimals obj)))) (t2 (/ (x2 view) (expt 10 (decimals obj)))) (p1 (max (1- (or (position t1 points :test '<= :key 'om-point-x) 0)) 0)) (p2 (or (position t2 points :test '<= :key 'om-point-x) (length points)))) ;;;loop through points (visibles + previous + next) (loop for pt in (subseq points p1 p2) for i = p1 then (1+ i) do ;;;draw point if visible (when (in-interval (start-date pt) (list t1 t2)) (let ((px (x-to-pix view (start-date pt))) (py (y-to-pix view (start-value pt)))) (draw-bpf-point (list px py) editor :selected (and (consp selection) (find i selection)) :index (and foreground? show-indice i) :time (and foreground? (time-to-draw obj editor pt i))) (when (and (ap-lock pt) (not (equal :lines (editor-get-edit-param editor :draw-style)))) (om-draw-circle px py 5 :fill nil))) ) ;;;draw curves using 1000 lines by curve ;;(should rely on coeff for each point) (if (= (ap-coeff pt) 0.5) (om-draw-line (x-to-pix view (start-date pt)) (y-to-pix view (start-value pt)) (x-to-pix view (end-date pt obj)) (y-to-pix view (end-value pt obj))) (let* ((step (max 0.01 (/ (- (end-date pt obj) (start-date pt)) 100))) (start-t (min (end-date pt obj) (max t1 (start-date pt)))) (end-t (min (end-date pt obj) t2))) (loop for ti from start-t to end-t by step do (om-draw-line (x-to-pix view ti) (y-to-pix view (funcall (fun pt obj) ti)) (x-to-pix view (min (end-date pt obj) (+ step ti))) (y-to-pix view (funcall (fun pt obj) (min (end-date pt obj) (+ step ti))))))) ) ) )) )) (defmethod om-draw-contents ((self automation-panel)) (om-draw-contents-area self nil nil nil nil))
8,142
Common Lisp
.lisp
165
37.975758
115
0.517441
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
d112adfba15648d83d828baced15c78e217a76a67d9dadd290422802839d0046
772
[ -1 ]
773
tempo-automation.lisp
cac-t-u-s_om-sharp/src/packages/basic/automation/tempo-automation.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; Author: D. Bouche ;============================================================================ ;=========================================================================== ; Tempo Automation ;=========================================================================== (in-package :om) (defvar *curve-N-factor* 512) (defstruct (tempo-point (:include automation-point (x 0) (y 120)) (:print-object (lambda (a stream) (print-unreadable-object (a stream :type t :identity t) (princ `(:bpm ,(tp-y a) :at :beat ,(tp-x a)) stream)))) (:conc-name tp-))) ;;=========================================================================== ;;;Tempo Automation = An automation for tempo ;;=========================================================================== (defclass tempo-automation (automation) ((past-beat :initform 0 :initarg :past-beat :accessor past-beat) (past-time :initform 0 :initarg :past-time :accessor past-time))) (defmethod beat-date ((self tempo-point) (obj tempo-automation) beat) (let* ((dm (start-date self)) (fun (fun self obj)) (xk #'(lambda (k) (+ dm (* k (/ (- beat dm) *curve-N-factor*)))))) (* (/ (- beat dm) (* 3 *curve-N-factor*)) (+ (/ 1 (funcall fun (funcall xk (start-value self)))) (loop for k from 1 to (- (round *curve-N-factor* 2) 1) sum (/ 2 (funcall fun (funcall xk (* 2 k))))) (loop for k from 1 to (round *curve-N-factor* 2) sum (/ 4 (funcall fun (funcall xk (- (* 2 k) 1))))) (/ 1 (funcall fun (funcall xk *curve-N-factor*)))) 60000))) (defmethod get-beat-date ((self tempo-automation) beat) (let ((points (point-list self)) (current-time 0)) (loop for i from 0 to (1- (length points)) do (if (and (nth (1+ i) points) (< (start-date (nth (1+ i) points)) beat)) (incf current-time (beat-date (nth i points) self (start-date (nth (1+ i) points)))) (progn (incf current-time (beat-date (nth i points) self beat)) (return)))) (round current-time))) (defmethod initialize-instance :after ((self tempo-automation) &rest args) (setf (point-list self) (loop for x in (or (getf args :x-points) '(0 2000)) for y in (or (getf args :y-points) '(120 120)) for coeff in (or (getf args :c-points) '(0.5 0.5)) collect (make-tempo-point :x x :y y :coeff coeff))) (loop for pt in (point-list self) do (setf (tp-fun pt) (get-function pt self))) self) ;;; why not to do it like in BPF ? (defmethod (setf point-list) ((point-list t) (self tempo-automation)) (setf (slot-value self 'point-list) point-list)) (defmethod tp-start-date ((self tempo-point) (obj tempo-automation)) (get-beat-date obj (tp-x self))) (defmethod tp-end-date ((self tempo-point) (obj tempo-automation)) (get-beat-date obj (tp-x (or (next-point obj self) self)))) (defmethod tp-start-beat ((self tempo-point)) (tp-x self)) (defmethod (setf tp-start-beat) (beat (self tempo-point)) (setf (tp-x self) beat)) (defmethod tp-end-beat ((self tempo-point) (obj tempo-automation)) (tp-x (or (next-point obj self) self))) (defmethod tp-start-value ((self tempo-point)) (tp-y self)) (defmethod tp-end-value ((self tempo-point) (obj tempo-automation)) (tp-y (or (next-point obj self) self))) (defmethod fun ((self tempo-point) (obj tempo-automation)) (or (ap-fun self) (setf (ap-fun self) (get-function self obj)))) (defmethod (setf fun) (f (self tempo-point)) (setf (ap-fun self) f)) (defmethod get-function ((self tempo-point) (obj tempo-automation)) (if (= (tp-start-value self) (tp-end-value self obj)) (constantly (tp-start-value self)) #'(lambda (d) (+ (* (expt (/ (- d (tp-start-beat self)) (- (tp-end-beat self obj) (tp-start-beat self))) (log 0.5 (tp-coeff self))) (- (tp-end-value self obj) (tp-start-value self))) (tp-start-value self))))) ;;;============================================ ;;; called from outside (sequencer/ruler/etc.) ;;;============================================ (defmethod tempo-automation-get-beat-date ((self tempo-automation) beat) (get-beat-date self beat)) (defmethod tempo-automation-tempo-at-beat ((self tempo-automation) beat) (let ((pt (find beat (point-list self) :test #'(lambda (x y) (and (>= x (tp-start-beat y)) (< x (tp-end-beat y self))))))) (if pt (funcall (get-function pt self) beat) 0))) (defmethod tempo-automation-get-beat-grid ((self tempo-automation) tmin tmax &optional (beat-rate 1)) (let* ((pt-index (position-if #'(lambda (x) (and (>= tmin (get-beat-date self (start-date x))) (< tmin (get-beat-date self (end-date x self))))) (point-list self))) (grid '()) (date 0)) (when pt-index (if (= pt-index (1- (length (point-list self)))) (let* ((pt (car (last (point-list self)))) (b1 (tp-start-beat pt)) (t1 (tp-start-date pt self)) (tp (tp-start-value pt)) (beat-dur (/ 60000 tp)) (bs (+ b1 (floor (- tmin t1) (/ 60000 tp)))) (be (+ b1 (ceiling (- tmax t1) (/ 60000 tp))))) (loop for beat from (- bs (mod bs beat-rate)) to be by beat-rate for n from 0 do (setq date (+ t1 (* beat-dur (- beat b1)))) (if (= (mod beat 1) 0) (push (list date beat) grid) (push (list date (list (mod n (/ 1 beat-rate)) (/ 1 beat-rate))) grid)))) (loop for beat from (tp-start-beat (nth pt-index (point-list self))) by beat-rate for n from 0 do (setq date (get-beat-date self beat)) (if (and (< date tmax) (>= date tmin)) (if (= (mod beat 1) 0) (push (list date beat) grid) (push (list date (list (mod n (/ 1 beat-rate)) (/ 1 beat-rate))) grid)) (if (>= date tmax) (return))))) (reverse grid)))) (defmethod tempo-automation-get-display-beat-factor ((self tempo-automation) t1 t2) (let ((factor (/ (- t2 t1) (/ 60000 (/ (reduce '+ (point-list self) :key 'start-value) (length (point-list self))))))) (if (<= factor 10) (/ (expt 2 (round (log (/ factor 40)) 2)) 2) (expt 2 (round (log (1+ (/ factor 40)) 2)))))) #| ;;;============================================ ;;; never called anywhere ;;;============================================ (defmethod get-function-auto ((self tempo-point) (auto tempo-automation)) (or (ap-fun self) (let* ((next (nth (1+ (position self (point-list auto))) (point-list auto))) (end-beat (if next (tp-start-beat next) *positive-infinity*))) (if (= (tp-start-value self) (tp-end-value self auto)) (constantly (tp-start-value self)) #'(lambda (d) (+ (* (expt (/ (- d (tp-start-beat self)) (- end-beat (tp-start-beat self))) (log 0.5 (ap-coeff self))) (- (tp-end-value self auto) (tp-start-value self))) (tp-start-value self))))))) (defmethod max-tempo ((self tempo-automation)) (reduce 'max (point-list self) :key 'tp-start-value)) ; (never!) called by player (defmethod get-action-list-for-play ((self tempo-automation) time-interval &optional parent) (loop for ti from (car time-interval) to (cadr time-interval) by (interpol self) collect (list ti #'(lambda () (funcall (action self) (tempo-at-date self ti)))))) |#
8,944
Common Lisp
.lisp
180
39.483333
104
0.492327
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
6d79443f172bacacb92931ae20a5293b3d32efafbafd577b374ce8eb0d409cf9
773
[ -1 ]
774
2d-array.lisp
cac-t-u-s_om-sharp/src/packages/basic/containers/2d-array.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;============================================================ ; ARRAY OBJECTS ;============================================================ (in-package :om) ;============================================================ ;;; SUPERCLASS DEFINING COMMON ARRAY FEATURES ;============================================================ (defclass OMArray () ((elts :initform 0 :accessor elts :documentation "number of elements (a.k.a lines)") (fields :initform 0 :accessor fields :documentation "number of fields (a.k.a columns)") (field-names :initform nil :accessor field-names :initarg :field-names :documentation "field (column) names ") (data :initform nil :accessor data :documentation "data matrix"))) ;(defmethod initialize-instance :after ((self OMArray) &rest args) ; (update-contents self)) (defmethod object-box-label ((self OMArray)) (string+ (string-upcase (type-of self)) " [" (number-to-string (fields self)) "x" (number-to-string (elts self)) "]")) (defmethod get-field-name ((self OMArray) (col integer)) (or (nth col (field-names self)) (format nil "c_~D" col))) ;;; deprecated - use get-field (defmethod get-col ((self OMArray) col &key (warn-if-not-found t)) (get-field self col :warn-if-not-found warn-if-not-found)) (defmethod display-modes-for-object ((self OMArray)) '(:mini-view :text :hidden)) (defmethod draw-mini-view ((self OMArray) (box t) x y w h &optional time) (ensure-cache-display-draw box self) ;;; check if this is really needed... (let* ((font (om-def-font :small)) (n-lines (length (data self))) (inter-line 1) (v-margin 8) (line-h (if (data self) (/ (- h v-margin (* inter-line (1- n-lines))) n-lines) (- h v-margin))) (h-margin (+ x 2)) (line-w (- w 4))) (when (data self) (loop for n from 0 to (1- n-lines) for yy = v-margin then (+ yy line-h inter-line) do (om-draw-rect h-margin yy line-w line-h :color (om-def-color :white) :fill t) (om-draw-string (+ x (- line-w (om-string-size (get-field-name self n) font))) (+ yy 10) (get-field-name self n) :font font :color (om-make-color .6 .6 .7)) (draw-field-on-box self (nth n (data self)) h-margin yy line-w line-h) )))) ;;; general case ;;; redefined for class-array (defmethod get-array-field-data ((field list)) field) (defmethod draw-field-on-box ((self OMArray) field x y w h) (when (> (elts self) 0) (let ((x-space (/ w (elts self))) (mid-y (+ y (/ h 2))) (margin-y 2) ; (min 8 (/ h 2))) (field-data (get-array-field-data field))) (flet ((nth-x-pos (n) (+ x (* x-space (+ n 0.5)))) (draw-cross (x y) (om-draw-line (- x 1) y (+ x 1) y :color (om-def-color :light-gray)) (om-draw-line x (- y 1) x (+ y 1) :color (om-def-color :light-gray)))) (om-with-font (om-def-font :tiny) (cond ((null field-data) (om-draw-string (- (* w 0.5) 40) mid-y "[no data]")) ((list-subtypep field-data 'number) ;; Numbers: draw bpf-kind (let* ((min-y-val (list-min field-data)) (max-y-val (list-max field-data)) (y-values-range (- max-y-val min-y-val)) (y-factor (if (zerop y-values-range) 1 (float (/ (- h (* 2 margin-y)) y-values-range)))) (draw-annex-elements (and (> h 20) (< (length field-data) 100)))) (let* ((x0 (nth-x-pos 0)) (val (car field-data)) (y0 (if (zerop y-values-range) mid-y (+ y (- h margin-y (* (- val min-y-val) y-factor))))) (step (ceiling (/ (length field-data) w)))) ;;; draw the first element (when draw-annex-elements (draw-cross x0 mid-y) (om-draw-circle x0 y0 2 :fill t)) (om-draw-string x0 (- y0 6) (format nil "~A" val)) (if (= y-values-range 0) (setf max-y-val nil)) ;; just to prevent drawing the value again (loop for n from 1 to (1- (length field-data)) by step do ;(if (> step 1) (setf n (min (1- (length field-data)) (+ n (om-random 0 step))))) (let* ((xx (nth-x-pos n)) (val (nth n field-data)) (yy (if (zerop y-values-range) mid-y (+ y (- h margin-y (* (- val min-y-val) y-factor)))))) (when draw-annex-elements (draw-cross xx mid-y) (om-draw-circle xx yy 2 :fill t)) (when (and max-y-val (= val max-y-val)) (om-draw-string xx yy (format nil "~A" val)) (setf max-y-val nil)) (om-draw-line x0 y0 xx yy) (setf x0 xx y0 yy)) ) (when (> step 1) (om-draw-rect (- (* w 0.5) 60) (- mid-y 10) 125 15 :color (om-make-color-alpha (om-def-color :white) 0.8) :fill t) (om-draw-string (- (* w 0.5) 58) mid-y (format nil "[display down-sampled x 1/~D]" step) :color (om-make-color .7 .6 .7))) )) ) ;;; NaN ((< (length field-data) 200) (dotimes (n (length field-data)) (let* ((xx (nth-x-pos n)) (val (nth n field-data)) (yy (+ y (* h .5)))) (draw-cross xx mid-y) (draw-element-in-array-field val xx yy x-space h) ))) (t (om-draw-string (- (* w 0.5) 40) mid-y "[...(list too long)...]"))) ) ;; end COND )))) (defmethod draw-element-in-array-field ((self t) center-x center-y w h) (om-draw-string center-x center-y (format nil "~A" self))) (defmethod draw-element-in-array-field ((self bpf) center-x center-y w h) (let ((dummy-cache (get-cache-display-for-draw self nil))) ;; dummy because it is not cached actually (bad) (om-draw-line (+ center-x (* w .5)) (- center-y (* h .48)) (+ center-x (* w .5)) (+ center-y (* h .48)) :style '(2 2) :color (om-def-color :dark-blue)) (draw-bpf-points-in-rect (cadr dummy-cache) (color self) (car dummy-cache) ;(+ x 7) (+ y 10) (- w 14) (- h 20) (- center-x (* w .45)) (- center-y (* h .45)) (* w .9) (* h .9) :lines))) ;============================================================ ; SIMPLE 2D-ARRAY ; Initialized mainly with the data (a nested list) ;============================================================ ;; <data> is redefined with :initarg so as to appear as a box input (defclass* 2D-array (OMArray) ((data :initform nil :initarg :data :accessor data :documentation "data matrix / list of lists : (col1 col2 ...)")) (:documentation "A simple 2D container. <data> is a list containing the data. Each element can be a list, or a constant value for the whole array row. <field-names> (optional) is a list of string / names of the array rows. ")) (defmethod additional-class-attributes ((self 2D-array)) '(field-names)) ;;; collect the raw internal data / redefined in class-array (defmethod get-array-data ((self 2D-array)) (data self)) ;; array dimensions are set according to <data> (defmethod om-init-instance ((self 2D-array) &optional initargs) (call-next-method) (setf (data self) (list! (data self))) ;;; fields and elts are not necessary set (especially if called from a patch) ;;; fields is reset in any case to match with the data (setf (fields self) (length (data self))) ;; (get-array-data self) (unless (and (elts self) (plusp (elts self))) (setf (elts self) (loop for field in (data self) when (listp field) maximize (length field)))) ;; (get-array-field-data field) ;;; if a field is specified as a single/constant value: reset data as a list with this values (setf (data self) (loop for i from 0 to (1- (fields self)) collect (if (listp (nth i (data self))) (nth i (data self)) (make-list (elts self) :initial-element (nth i (data self)))) )) self) (defmethod get-field ((self 2D-array) (col integer) &key (warn-if-not-found t)) (if (< col (length (data self))) (nth col (data self)) (if warn-if-not-found (om-beep-msg "Field #~D not found in '~A'" col self)))) (defmethod get-field ((self 2D-array) (col string) &key (warn-if-not-found t)) (let ((pos (position col (field-names self) :test 'string-equal))) (if pos (get-field self pos :warn-if-not-found warn-if-not-found) (if warn-if-not-found (om-beep-msg "Field ~s not found in '~A'" col self))))) (defmethod get-cache-display-for-text ((self 2D-array) box) (declare (ignore box)) (loop for field in (data self) for i = 0 then (1+ i) collect (list (format nil "[~D]" i) field))) ;;;============================================================ ;;; CLASS-ARRAY / OM6-LIKE ;;; A 2D-ARRAY with more explicit semantics assigned to each field. ;;; data are matrix-fields (not just data) ;;; fields declares a number of main matrix-fields + defaults ;;;============================================================ (defstruct array-field (name) (doc) (type) (default) (data) (decimals)) (defmethod om-copy ((self array-field)) (make-array-field :name (array-field-name self) :doc (array-field-doc self) :type (array-field-type self) :decimals (array-field-decimals self) :default (array-field-default self) :data (array-field-data self))) (defmethod omng-save ((self array-field)) `(:array-field (:name ,(array-field-name self)) (:doc ,(array-field-doc self)) (:type ,(omng-save (array-field-type self))) (:decimals ,(array-field-decimals self)) (:default ,(omng-save (array-field-default self))) (:data ,(omng-save (array-field-data self))))) (defmethod om-load-from-id ((id (eql :array-field)) data) (make-array-field :name (find-value-in-kv-list data :name) :doc (find-value-in-kv-list data :doc) :type (omng-load (find-value-in-kv-list data :type)) :decimals (find-value-in-kv-list data :decimals) :default (omng-load (find-value-in-kv-list data :default)) :data (omng-load (find-value-in-kv-list data :data)))) (defmethod get-array-field-data ((field array-field)) (array-field-data field)) ;;; the <data> slot is not visible and set according to the meta-info + optional additionl box inputs ;;; (requires a dedicated box type) (defclass* class-array (OMArray) ((field-names :initform nil :initarg :field-names :accessor field-names :documentation "field (column) names ") (elts :initform 1 :initarg :elts :accessor elts :documentation "number of elements (lines)") (attached-components :accessor attached-components :initform nil) ;; a temporary list of 'active' accessed components ) (:documentation " CLASS-ARRAY is a special implementation of a 2D-array where specific semantics is given to the different fields (columns). <field-names> is a list of strings. Each name in it initializes a column which becomes accessible through the additional/optional inputs of the CLASS-ARRAY box. <elts> is the number of lines/elements in the array. Data instanciation in a column is done according to the specified number of lines/elements (<elts>), either by - Repeating a single value - Applying list values - Looping through the list of value (if shorter than <elts>) - Sampling a BPF - Evaluating a lambda function of 0 or 1 argument (if 1, the argument is the element index in the array). ")) #| ;;; TO BUILD A CH-FOF (or other class-array) in Lisp, use : (defun test () (om-init-instance (make-instance 'om::class-array :elts 4) '((:freq (440 880 1200)) (:bw (59 70 90 80)))) ) |# (defmethod additional-slots-to-save ((self class-array)) '(data)) (defmethod additional-slots-to-copy ((self class-array)) '(data)) (defmethod default-array-field-from-slot ((self class-array) (field string)) (let ((slot (find field (class-slots (class-of self)) :key 'slot-name :test 'string-equal))) (when slot (make-array-field :name field :decimals 4 :default (slot-initform slot) :type (slot-type slot) :doc (slot-doc slot)) ))) (defmethod om-init-instance ((self class-array) &optional initargs) ;;; no next-method actually (T) (call-next-method) ;;; find the potential extra-controls and add them as field names (setf (om::field-names self) (append (om::field-names self) (remove nil (loop for initarg in initargs when (car initarg) ;; sometimes initargs = (nil) collect (let ((arg-name (symbol-name (car initarg)))) (unless (or ;; already there from previous initialization (e.g. from Csound orc) (find arg-name (om::field-names self) :test 'string-equal) ;; member of the 'invisible' slots (find arg-name (om::class-slots (class-of self)) :key 'om::slot-name :test 'string-equal) ) arg-name)))) )) ;;; in class-array some 'meta-data' determine the contents of the actual data (setf (fields self) (length (field-names self))) (unless (elts self) (setf (elts self) 0)) (when initargs ;; INITARGS = NIL means we are loading a saved object (data is already in) (setf (data self) ;; (SETF DATA) will recall this initialization methods with :initargs = NIL :( (loop for field in (field-names self) collect (let* ((input-data (find-value-in-kv-list initargs (intern-k field))) (existing-field (or ;; the field can already be in the data ;; if this data was copied or initialized from a subclass (e.g. cs-evt in OMChroma) (find field (data self) :test 'string-equal :key 'array-field-name) ;; the class definition contains infprmation about this field in its own declaration (default-array-field-from-slot self field)))) (cond (input-data ;; the field is to be set from specified data, whatever existed before (let ((type (and existing-field (array-field-type existing-field)))) (make-array-field :name field :decimals 4 :default (and existing-field (array-field-default existing-field)) :type type :doc (and existing-field (array-field-doc existing-field)) :data (get-array-data-from-input input-data (elts self) type)))) (existing-field ;; the field already exists (make-array-field :name field :decimals 4 :default (array-field-default existing-field) :type (array-field-type existing-field) :doc (array-field-doc existing-field) :data (get-array-data-from-input (or (array-field-data existing-field) (array-field-default existing-field)) (elts self) (array-field-type existing-field)))) (t ;; the field will be filled from the default value (if any) or NIL (make-array-field :name field :decimals 4 :data (get-array-data-from-input nil (elts self) nil))) ) ))) ) self) (defmethod get-field ((self class-array) (col integer) &key (warn-if-not-found t)) (if (< col (length (data self))) (array-field-data (nth col (data self))) (if warn-if-not-found (om-beep-msg "Field #~D not found in '~A'" col self)))) (defmethod get-field ((self class-array) (col string) &key (warn-if-not-found t)) (let ((array-field (find col (data self) :test 'string-equal :key #'array-field-name))) (if array-field (array-field-data array-field) (if warn-if-not-found (om-beep-msg "Field '~A' not found in '~A'" col self))))) (defmethod get-field-name ((self class-array) (col integer)) (or (and (< col (length (data self))) ;;; v (array-field-name (nth col (data self)))) ;;; in principle these are the same (nth col (fields self)) ;;; ^ (format nil "c_~D" col))) (defmethod get-field-type ((self class-array) (col integer)) (and (< col (length (data self))) (array-field-type (nth col (data self))))) (defmethod get-field-default ((self class-array) (col integer)) (and (< col (length (data self))) (array-field-default (nth col (data self))))) (defmethod get-field-id ((self class-array) (field string)) (position field (field-names self) :test 'string-equal)) ;;; collect the raw internal data (defmethod get-array-data ((self class-array)) (mapcar #'array-field-data (data self))) ;;; methods for filling data (defmethod get-array-data-from-input ((input t) n type) (declare (ignore type)) (make-list n :initial-element (om-copy input))) (defmethod get-array-data-from-input ((input cons) n type) (declare (ignore type)) (cond ((= (length input) n) (om-copy input)) ((< (length input) n) (get-array-data-from-input (append (om-copy input) (om-copy input)) n type)) ((> (length input) n) (first-n (om-copy input) n)))) (defmethod get-array-data-from-input ((input function) n type) (declare (ignore type)) (case (length (function-arg-list input)) (1 (mapcar input (loop for i from 1 to n collect i))) (0 (loop for i from 1 to n collect (funcall input))) (otherwise (om-beep-msg "functions as array input must have 1 or 0 arguments!")) )) (defmethod get-array-data-from-input ((input symbol) n type) (declare (ignore type)) (if (fboundp input) (get-array-data-from-input (fdefinition input) n type) (call-next-method))) (defmethod get-array-data-from-input ((input bpf) n type) (declare (ignore type)) (multiple-value-bind (bpf xx yy) (om-sample input n) (declare (ignore bpf xx)) yy)) ;;;============================ ;;; Special box for class-array ;;;============================ (defclass ClassArrayBox (OMBoxEditCall) ((keywords :initform nil :accessor keywords :initarg :keywords))) (defmethod special-box-type ((class-name (eql 'class-array))) 'ClassArrayBox) (defmethod default-size ((self ClassArrayBox)) (om-make-point 100 100)) ;;; class-array can be added "free fields" (defmethod allow-extra-controls ((self class-array)) t) (defmethod box-free-keyword-name ((self ClassArrayBox)) 'add-field) ;;; list of proposed keywords are the declared names (defmethod get-all-keywords ((self ClassArrayBox)) (append (if (keywords self) (list (keywords self)) (call-next-method)) ;; additional-class-attributes of the reference (when (and (get-box-value self) (allow-extra-controls (get-box-value self))) `((,(box-free-keyword-name self)))) )) (defmethod update-key-inputs ((self ClassArrayBox)) (when (get-box-value self) (setf (keywords self) (mapcar #'(lambda (f) (intern-k (array-field-name f))) (data (get-box-value self))))) (when (frame self) (set-frame-areas (frame self)) (om-invalidate-view (frame self)))) (defmethod initialize-instance :after ((self ClassArrayBox) &rest args) (declare (ignore args)) (update-key-inputs self)) (defmethod get-input-doc ((self ClassArrayBox) name) (or (call-next-method) (when (get-box-value self) ;;; sometimes at the very beginning of box creation there is not yet a value... (let ((field (find name (data (get-box-value self)) :test 'string-equal :key 'array-field-name))) (when field (array-field-doc field)))))) (defmethod get-input-def-value ((self ClassArrayBox) name) (or (call-next-method) (when (get-box-value self) ;;; sometimes at the very beginning of box creation there is not yet a value... (let ((field (find name (data (get-box-value self)) :test 'string-equal :key 'array-field-name))) (when field (array-field-default field)))))) #| ;;; this will eventually call (setf value) anyway... => removed (defmethod omng-box-value :after ((self ClassArrayBox) &optional numout) (update-key-inputs self)) |# (defmethod (setf value) :after (val (self ClassArrayBox)) (update-key-inputs self)) (defmethod rep-editor ((box ClassArrayBox) num) (let ((num-direct-in-outs (1+ (length (remove-if-not #'slot-initargs (class-direct-instance-slots (find-class (reference box)))))))) (if (or (null num) (< num num-direct-in-outs)) (call-next-method) (let* ((field-name (name (nth num (outputs box))))) (get-field (get-box-value box) field-name))))) ;;; redefinition from main methods (defmethod get-slot-val ((self class-array) slot-name) (or (get-field self (string slot-name) :warn-if-not-found nil) (call-next-method))) (defmethod get-cache-display-for-text ((self class-array) box) (declare (ignore box)) (append (call-next-method) (loop for array-field in (data self) collect (list (intern-k (array-field-name array-field)) (array-field-data array-field))) )) ;;;============================================== ;;; Components are temporary structures ;;; used internally by OMChroma ;;; to parse the contents of arrays by column ;;;============================================== ;;; currently 'used' components of a same array ;;; are stored in a temporary slot of the array (attached-components) ;;; in order to maintain the indexes when components are added or removed. (defstruct component (array nil) (vals nil) (index 0)) ;-----------Tools-------------- (defmethod om-copy ((self component)) (make-component :array (component-array self) :vals (om-copy (component-vals self)) :index nil)) (defmethod get-field-id ((self component) (field string)) (get-field-id (component-array self) field)) (defmethod get-array-element ((self class-array) n) (loop for array-field in (data self) collect (nth n (array-field-data array-field)))) (defmethod add-array-element ((self class-array) pos val-list) (loop for array-field in (data self) for val in val-list do (setf (array-field-data array-field) (insert-in-list (array-field-data array-field) val pos))) (setf (elts self) (1+ (elts self)))) (defmethod set-array-element ((self class-array) pos val-list) (loop for array-field in (data self) for val in val-list do (setf (nth pos (array-field-data array-field)) val))) (defmethod remove-array-element ((self class-array) pos) (loop for array-field in (data self) do (setf (array-field-data array-field) (remove-nth pos (array-field-data array-field)))) (setf (elts self) (1- (elts self)))) ;-----------Interface----------- (defmethod* new-comp (vals) :initvals '(nil) :indoc '("component values") :doc "Creates a new component filled with <vals>." :icon 'array-comp (make-component :vals vals)) (defmethod* get-comp ((self class-array) (n integer)) :initvals '(nil 0) :indoc '("a class-array instance" "component number") :doc "Returns the <n>th component in <self> (a class-array object). Components are returned as instances of the class 'component' and can be accessed using the functions comp-field, comp-list, fill-comp." :icon 'array-comp (or (find n (attached-components self) :key 'component-index :test '=) (when (< n (elts self)) (let ((comp (make-component :array self :vals (get-array-element self n) :index n))) (pushr comp (attached-components self)) comp)))) (defmethod* add-comp ((self class-array) (comp component) &optional position) :initvals '(nil nil) :indoc '("a class-array instance" "a component" "position in the array") :doc "Adds <comp> in <self> at <pos>. If <pos> is not specified, the component is added at the end of the array." :icon 'array-comp (let* ((pos (or position (elts self)))) (setf (component-array comp) self) (setf (component-index comp) pos) (add-array-element self pos (component-vals comp)) (loop for cmp in (attached-components self) do (when (>= (component-index cmp) pos) (setf (component-index cmp) (1+ (component-index cmp))))) (pushr comp (attached-components self)) comp)) (defmethod* remove-comp ((self component)) :initvals '(nil) :indoc '("a class-array component") :doc "Remove component <self> from its associated array. The modification is immediately applied in the original array." :icon 'array-comp (remove-array-element (component-array self) (component-index self)) (remove (component-index self) (attached-components (component-array self)) :key 'index :test '=) ;;; !!! comp-array is still "self" for other removed components of same index (loop for cmp in (attached-components (component-array self)) do (when (> (component-index cmp) (component-index self)) (setf (component-index cmp) (1- (component-index cmp))))) (setf (component-array self) nil) self) (defmethod! comp-list ((self component) &optional val-list) :initvals '(nil) :indoc '("a class-array component") :doc "Sets (if <val-list> is supplied) or returns (if not) the values in <self> (a class-array component). If <val-list> is supplied, the component itself is returned. If the component is attached to an array, i.e. previously passed through 'get-comp' or 'add-comp', then the modifications are immediately stored in the original array." :icon 'array-comp (if val-list (progn (setf (component-vals self) val-list) (when (and (component-array self) (component-index self)) (set-array-element (component-array self) (component-index self) (component-vals self))) self) (component-vals self))) (defmethod* comp-field ((self component) (LineId integer) &optional val) :initvals '(nil 0 nil) :indoc '("a class-array component" "a line identifier" "a value") :doc "Sets (if <val> is supplied) or returns (if not) the value of line <lineid> for component <self>. If <val>, the component itself is returned. If the component is attached to an array, i.e. previously passed through 'get-comp' or 'add-comp', then the modifications are immediately stored in the original array. <lineid> can be a number (index of the line) or a string (name of the line)." :icon 'array-comp (if val (progn (setf (nth LineId (component-vals self)) val) (when (and (component-array self) (component-index self)) (set-array-element (component-array self) (component-index self) (component-vals self))) self) (nth LineId (component-vals self)))) (defmethod* comp-field ((self component) (LineId string) &optional val) (comp-field self (get-field-id self LineId) val))
29,617
Common Lisp
.lisp
565
42.663717
160
0.57388
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
2bdcd3e4d919fe12b23a2a53db1f0f65c705550ec35fb3c72169d7e95c7e0d58
774
[ -1 ]
775
midi-setup.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-setup.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defun midi-get-ports-settings () (let ((newsetup (om-midi::portmidi-setup (get-pref-value :midi :ports)))) (when newsetup (set-pref :midi :ports newsetup) t))) (defun midi-apply-ports-settings () (om-midi::portmidi-connect-ports (get-pref-value :midi :ports))) (defun midi-setup () (before-restart-midi) (when (midi-get-ports-settings) (midi-apply-ports-settings))) (defparameter *running-midi-boxes* nil) (defparameter *running-midi-recorders* nil) (defun before-restart-midi () (when (or *running-midi-boxes* *running-midi-recorders*) (om-message-dialog (format nil "Warning: Restarting MIDI will stop all currently running MIDI receive loops.~%[currently: ~D running]" (+ (length *running-midi-boxes*) (length *running-midi-recorders*)))) (mapcar #'stop-box *running-midi-boxes*) (mapcar #'editor-record-off *running-midi-recorders*) )) (add-preference-module :midi "MIDI") (add-preference-section :midi "MIDI In/Out") (add-preference :midi :ports "Configuration" :action 'midi-setup) (add-preference :midi :out-port "Default Output port" (make-number-in-range :min 0 :max 99 :decimals 0) 0 ;; default value "MIDI events/notes are sent by default through this port number when their port is NIL") (add-preference :midi :in-port "Default Input port" (make-number-in-range :min 0 :max 99 :decimals 0) 0 ;; default value "Incoming MIDI are received on this port number") (add-preference :midi :thru-port "Default Thru port" (make-number-in-range :min 0 :max 99 :decimals 0) 0 ;; default value "MIDI events are redirected to this port when the 'thru' function is activated") (add-preference :midi :thru "MIDI Thru" :bool T ;; default value "Redirect incoming MIDI events to the 'thru' port") (add-preference-section :midi "MIDI Channel colors") (let ((colors (loop for h from 0 to 1 by (/ 1 32) collect (om-make-color-hsv h .8 .78)))) (add-preference :midi :midi-ch1-color " 1" :color (nth 0 colors)) (add-preference :midi :midi-ch2-color " 2" :color (nth 3 colors)) (add-preference :midi :midi-ch3-color " 3" :color (nth 5 colors)) (add-preference :midi :midi-ch4-color " 4" :color (nth 7 colors)) (add-preference :midi :midi-ch5-color " 5" :color (nth 16 colors)) (add-preference :midi :midi-ch6-color " 6" :color (nth 18 colors)) (add-preference :midi :midi-ch7-color " 7" :color (nth 21 colors)) (add-preference :midi :midi-ch8-color " 8" :color (nth 24 colors)) (add-preference :midi :midi-ch9-color " 9" :color (nth 29 colors)) (add-preference :midi :midi-ch10-color "10" :color (om-def-color :steelblue4)) (add-preference :midi :midi-ch11-color "11" :color (om-def-color :yellow4)) (add-preference :midi :midi-ch12-color "12" :color (om-def-color :burlywood4)) (add-preference :midi :midi-ch13-color "13" :color (om-def-color :lightpink4)) (add-preference :midi :midi-ch14-color "14" :color (om-def-color ::saddlebrown)) (add-preference :midi :midi-ch15-color "15" :color (om-def-color :darkgreen)) (add-preference :midi :midi-ch16-color "16" :color (om-def-color :darkslategrey)) ) ;; (color::get-all-color-names) (defun get-midi-channel-color (n) (case n (1 (get-pref-value :midi :midi-ch1-color)) (2 (get-pref-value :midi :midi-ch2-color)) (3 (get-pref-value :midi :midi-ch3-color)) (4 (get-pref-value :midi :midi-ch4-color)) (5 (get-pref-value :midi :midi-ch5-color)) (6 (get-pref-value :midi :midi-ch6-color)) (7 (get-pref-value :midi :midi-ch7-color)) (8 (get-pref-value :midi :midi-ch8-color)) (9 (get-pref-value :midi :midi-ch9-color)) (10 (get-pref-value :midi :midi-ch10-color)) (11 (get-pref-value :midi :midi-ch11-color)) (12 (get-pref-value :midi :midi-ch12-color)) (13 (get-pref-value :midi :midi-ch13-color)) (14 (get-pref-value :midi :midi-ch14-color)) (15 (get-pref-value :midi :midi-ch15-color)) (16 (get-pref-value :midi :midi-ch16-color)) (otherwise (om-def-color :gray)) ))
4,895
Common Lisp
.lisp
92
48.554348
120
0.636003
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
48d4239a6c3f57ba36b6fd49ca9d0cfc31a8592bd05f66a9262cc2e02e60cf4a
775
[ -1 ]
776
compatibility.lisp
cac-t-u-s_om-sharp/src/packages/midi/compatibility.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;; LOAD OBJECTS AND CODE FROM OM6 (in-package :om) (defmethod update-reference ((ref (eql 'midifile))) 'midi-track) (defmethod update-reference ((ref (eql 'eventmidi-seq))) 'midi-track) (defmethod function-changed-name ((reference (eql 'test-type))) 'test-midi-type) (defmethod function-changed-name ((reference (eql 'test-channel))) 'test-midi-channel) (defmethod function-changed-name ((reference (eql 'test-port))) 'test-midi-port) (defmethod function-changed-name ((reference (eql 'test-track))) 'test-midi-track) (defun load-midi (path) (make-instance 'midi-track :midi-events (import-midi-notes path)))
1,376
Common Lisp
.lisp
25
53
86
0.576637
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
0a797a15744177b9b06391df93965892c5d5de3aafbec6be44374f3d44c212a3
776
[ -1 ]
777
midi.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defpackage :om-midi) (compile&load (merge-pathnames "midi-api/midi-api" *load-pathname*)) (compile&load (merge-pathnames "midi-setup" *load-pathname*)) (compile&load (merge-pathnames "tools/midi-values" *load-pathname*)) (compile&load (merge-pathnames "tools/midi-import-export" *load-pathname*)) (compile&load (merge-pathnames "objects/midi-event" *load-pathname*)) (compile&load (merge-pathnames "objects/midi-track" *load-pathname*)) (compile&load (merge-pathnames "objects/midi-controllers" *load-pathname*)) (compile&load (merge-pathnames "objects/midi-mix" *load-pathname*)) (compile&load (merge-pathnames "tools/midi-extract" *load-pathname*)) (compile&load (merge-pathnames "tools/midi-out" *load-pathname*)) (compile&load (merge-pathnames "tools/midi-in" *load-pathname*)) (compile&load (merge-pathnames "compatibility" *load-pathname*)) (omNG-make-package "MIDI" :container-pack *om-package-tree* :doc "MIDI tools and objects" :classes '(midi-track midi-note midievent midi-mix-console) :functions nil :subpackages (list (omNG-make-package "Import/Export/Conversions" :doc "MIDI import and conversion utilities" :functions '(import-midi get-midievents get-midi-notes get-tempomap mf-info get-mf-lyrics save-as-midi)) (omNG-make-package "Filters" :doc "Tools to filter MIDI events" :functions '(test-midi-type test-date test-midi-track test-midi-channel test-midi-port)) (omNG-make-package "Utils" :doc "Other MIDI utilities" :functions '(midi-type midi-control-change gm-program gm-drumnote mc-to-pitchwheel convert-textinfo evt-to-string separate-channels)) (omNG-make-package "Out" :doc "Send MIDI events out" :functions '(pgmout pitchwheel ctrlchg volume midi-reset send-midi-note)) (omNG-make-package "In" :doc "Receive MIDI events" :functions '(midi-in)) ))
2,889
Common Lisp
.lisp
60
41.183333
98
0.598794
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
67e6fe63dd519c271b1f91638a7abfec40aed1c7c501c22ddb948dd413075143
777
[ -1 ]
778
midi-event.lisp
cac-t-u-s_om-sharp/src/packages/midi/objects/midi-event.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defvar *midi-event-types* '(("KeyOn " :KeyOn) ("KeyOff" :KeyOff) ("KeyPress" :KeyPress) ("CtrlChange" :CtrlChange) ("ProgChange" :ProgChange) ("ChanPress" :ChanPress) ("PitchWheel/PitchBend" :PitchBend) ("SongPos" :SongPos) ("SongSel" :SongSel) ("Clock" :Clock) ("Start" :Start) ("Continue" :Continue) ("Stop" :Stop) ("Tune" :Tune) ("ActiveSens" :ActiveSens) ("Reset" :Reset) ("SysEx" :SysEx) ("Stream" :Stream) ("Private" :Private) ("Process" :Process) ("DProcess" :DProcess) ("QFrame" :QFrame) ("Ctrl14b" :Ctrl14b) ("NonRegParam" :NonRegParam) ("RegParam" :RegParam) ("SeqNum" :SeqNum) ("Textual" :Textual) ("Copyright" :Copyright) ("SeqName" :SeqName) ("InstrName" :InstrName) ("Lyric" :Lyric) ("Marker" :Marker) ("CuePoint" :CuePoint) ("ChanPrefix" :ChanPrefix) ("EndTrack" :EndTrack) ("Tempo" :Tempo) ("SMPTEOffset" :SMPTEOffset) ("TimeSign" :TimeSign) ("KeySign" :KeySign) ("Specific" :Specific) )) (defmethod* midi-type (evt) :initvals '(nil) :indoc '("click to select a type of event") :menuins (list (list 0 *midi-event-types*)) :doc "Outputs the event-type identifier for MIDIEVENT." :icon :midi evt) ;;;============================ ;;; MIDI-EVENT AS A DATA-FRAME (see data-track container) ;;; A high-lev / graphical class, representing a MIDI event from the MIDI-API ;;;============================ (defclass* midievent (data-frame) ((onset :accessor onset :initform 0 :initarg :onset ; :initarg :date :initarg :ev-date ;;; different possible initargs (for compatibility) :documentation "date/time of the object") (ev-type :accessor ev-type :initarg :ev-type :initform :keyon :documentation "type of event") (ev-chan :accessor ev-chan :initarg :ev-chan :initform 1 :documentation "MIDI channel (1-16)") (ev-values :accessor ev-values :initarg :ev-values :initarg :ev-fields :initform nil :documentation "value(s)") (ev-port :accessor ev-port :initarg :ev-port :initform 0 :documentation "target MIDI port") (ev-track :accessor ev-track :initform 0 :documentation "track of the MIDI evevnt")) (:documentation "A MIDI message represented and processed in OM# visual programs. Can be extracted from MIDI or score objets, transformed, or just created from parameters, and either played through a MIDI port, or used to reconsruct musical structures.")) ;;; in case users initialize with a single value ;(defmethod om-init-instance ((self MIDIEvent) &optional initargs) ; (let ((rep (call-next-method))) ; (unless (listp (ev-values self)) ; (setf (ev-values self) (list (ev-values self)))) ; rep)) (defmethod additional-class-attributes ((self midievent)) '(ev-track)) (defun make-midievent (&key ev-date ev-type ev-chan ev-port ev-values ev-track) (let ((evt (make-instance 'MIDIEvent :onset ev-date :ev-type ev-type :ev-chan ev-chan :ev-values (list! ev-values) :ev-port ev-port))) (when ev-track (setf (ev-track evt) ev-track)) evt)) (defmethod data-frame-text-description ((self midievent)) (list "MIDI EVENT" (format nil "~A (~A): ~A" (ev-type self) (ev-chan self) (ev-values self)))) (defmethod* evt-to-string ((self MidiEvent)) :indoc '("MIDIEVENT(s)") :doc "A MIDIEVENT or list of MIDIEVENTs to a readable string format." :icon :midi-filter :outdoc '("list of strings describing MIDI events.") (format nil "MIDIEVENT: @~D ~A chan ~D track ~D port ~D: ~D" (onset self) (ev-type self) (ev-chan self) (ev-track self) (ev-port self) (ev-values self))) (defmethod* evt-to-string ((self list)) (mapcar #'evt-to-string self)) (defmethod send-midievent ((self midievent)) (om-midi::midi-send-evt (om-midi:make-midi-evt :type (ev-type self) :chan (ev-chan self) :port (or (ev-port self) (get-pref-value :midi :out-port)) :fields (if (istextual (ev-type self)) (map 'list #'char-code (car (ev-values self))) (ev-values self)) ))) ;;; play in a DATA-TRACK (defmethod get-frame-action ((self midievent)) #'(lambda () (send-midievent self))) ;;; PLAY BY ITSELF IN A SEQUENCER... ;;; Interval is the interval INSIDE THE OBJECT (defmethod get-action-list-for-play ((self midievent) interval &optional parent) (when (in-interval 0 interval :exclude-high-bound t) (list (list 0 #'(lambda (e) (send-midievent e)) (list self)) ))) ;====================================== ; MIDI-IMPORT ;====================================== (defmethod* get-midievents ((self t) &optional test) :indoc '("something") :doc "Converts anything into a list of MIDIEVENTs." :icon :midi nil) (defmethod* get-midievents ((self list) &optional test) (remove nil (loop for elt in self append (get-midievents elt test)))) (defmethod* get-midievents ((self om-midi::midi-evt) &optional test) (let ((evt (make-midievent :ev-date (om-midi::midi-evt-date self) :ev-type (om-midi::midi-evt-type self) :ev-chan (om-midi::midi-evt-chan self) :ev-values (om-midi:midi-evt-fields self) :ev-port (om-midi:midi-evt-port self) :ev-track (om-midi:midi-evt-ref self)))) (when (or (null test) (funcall test evt)) (list evt)))) (defmethod* get-midievents ((self midievent) &optional test) (when (or (null test) (funcall test self)) (list (om-copy self)))) ;====================================== ; MIDI-EXPORT ;====================================== (defmethod export-midi ((self midievent)) (om-midi:make-midi-evt :date (onset self) :type (ev-type self) :chan (ev-chan self) :port (ev-port self) :ref (ev-track self) :fields (ev-values self) )) ;====================================== ; Test functions for MIDI events ;====================================== (defmethod* test-date ((self midievent) tmin tmax) :initvals '(nil nil nil) :indoc '("a MIDIevent" "min date" "max date") :doc "Tests if <self> falls between <tmin> (included) and <tmax> (excluded)." :icon :midi-filter (when (and (or (not tmin) (>= (onset self) tmin)) (or (not tmax) (< (onset self) tmax))) self)) (defmethod* test-midi-channel ((self midievent) channel) :initvals '(nil nil) :indoc '("a MidiEvent" "MIDI channel number (1-16) or channel list") :doc "Tests if <self> is in channel <channel>." :icon :midi-filter (when (or (not channel) (member (ev-chan self) (list! channel))) self)) (defmethod* test-midi-port ((self midievent) port) :initvals '(nil nil) :indoc '("a MidiEvent" "output port number (or list)") :doc "Tests if <self> ouputs to <port>." :icon :midi-filter (when (or (not port) (member (ev-port self) (list! port))) self)) (defmethod* test-midi-track ((self midievent) track) :initvals '(nil nil) :indoc '("a MidiEvent" "a track number or list") :doc "Tests <self> is in track <track>." :icon :midi-filter (when (or (not track) (member (ev-track self) (list! track))) self)) (defmethod* test-midi-type ((self midievent) type) :initvals '(nil nil) :indoc '("a MidiEvent" "a MIDI event type") :menuins (list (list 1 *midi-event-types*)) :doc "Tests if <self> is of type <type>. See utility function MIDI-TYPE for a list and chooser of valid MIDI event type.)" :icon :midi-filter (when (or (not type) (if (symbolp type) (equal (ev-type self) type) (member (ev-type self) (list! type)))) self)) (defmethod* midi-filter ((self midievent) type track port channel) :initvals '(nil nil nil nil nil) :indoc '("a MIDIEvent" "event type(s)" "track number(s)" "output port(s)" "MIDI channel(s)") :doc "Tests the attributes of <self>. Returns T if <self> matches <type>, <track>, <port> and <channel>. If a test is NIL, the test is not performed on this attribute. " :icon :midi-filter (when (and (or (not type) (member (ev-type self) (list! type))) (or (not track) (member (ev-track self) (list! track))) (or (not port) (member (ev-port self) (list! port))) (or (not channel) (member (ev-chan self) (list! channel)))) self)) ;====================================== ; UTIL ;====================================== (defmethod* separate-channels ((self midievent)) :indoc '("a MIDIEVENT or list of MIDIEvents") :initvals '(nil) :doc "Separates MIDI channels on diferents MIDI tacks." :icon :midi (setf (ev-track self) (ev-chan self)) self) (defmethod* separate-channels ((self list)) (mapcar #'separate-channels self))
10,871
Common Lisp
.lisp
239
35.464435
173
0.532703
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
10716572aa9a9a641d6c37f5d291983d656cf5e4a9a8f7b2d1527c8fdb87f28c
778
[ -1 ]
779
midi-mix.lisp
cac-t-u-s_om-sharp/src/packages/midi/objects/midi-mix.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;================================================ ;=== CHANNEL CONTROLLER ;=== a single track controller ;================================================ (defclass channel-controls () ((midiport :initform nil :initarg :midiport :accessor midiport :type integer) (midichannel :initform 1 :initarg :midichannel :accessor midichannel :type integer) (program :initform 0 :initarg :program :accessor program :type integer) (pan-ctrl :initform 64 :initarg :pan-ctrl :accessor pan-ctrl :type integer) (control1-num :initform 1 :initarg :control1-num :accessor control1-num :type integer) (control2-num :initform 2 :initarg :control2-num :accessor control2-num :type integer) (control1-val :initform 0 :initarg :control1-val :accessor control1-val :type integer) (control2-val :initform 0 :initarg :control2-val :accessor control2-val :type integer) (vol-ctrl :initform 100 :initarg :vol-ctrl :accessor vol-ctrl :type integer) (pitch-ctrl :initform 8192 :initarg :pitch-ctrl :accessor pitch-ctrl :type integer))) (defclass* midi-mix-console (data-frame) ((midiport :initform nil :accessor midiport :type integer :documentation "output port number") (miditrack :initform 0 :accessor miditrack) (channels-ctrl :initform nil :accessor channels-ctrl)) (:documentation "A container for a variety of settings applying to the 16 MIDI channels. The MIDI-MIX-CONSOLE editor offers a mixing-table-like UI to set MIDI controllers and either send them in real-time, or store them for use with MIDI containers along with other MIDI or score objects. Applies to port <port>, or to the default MIDI out port is <port> is NIL.")) (defmethod additional-class-attributes ((self midi-mix-console)) '(midiport)) (defmethod initialize-instance :after ((self midi-mix-console) &rest l) (declare (ignore args)) (setf (channels-ctrl self) (loop for i from 1 to 16 collect (make-instance 'channel-controls :midiport (midiport self) :midichannel i))) ) ;====================== ; GET-MIDIEVENTS ;====================== (defmethod! get-midievents ((self midi-mix-console) &optional test) (let ((evt-list (loop for chan-ctrl in (channels-ctrl self) append (get-midievents chan-ctrl test)))) (when (miditrack self) (setf evt-list (loop for tr in (list! (miditrack self)) append (loop for evt in evt-list collect (let ((new-ev (clone evt))) (setf (ev-track new-ev) tr) new-ev)))) ) ;;; in case the test had to do with track number... ? (get-midievents evt-list test))) (defmethod! get-midievents ((self channel-controls) &optional test) (list (make-midievent :ev-date 0 :ev-type :ProgChange :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (list (program self))) (make-midievent :ev-date 0 :ev-type :CtrlChange :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (list 7 (vol-ctrl self))) (make-midievent :ev-date 0 :ev-type :CtrlChange :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (list 10 (pan-ctrl self))) (make-midievent :ev-date 0 :ev-type :PitchBend :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (val2lsbmsb (pitch-ctrl self))) (make-midievent :ev-date 0 :ev-type :CtrlChange :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (list (control1-num self) (control1-val self))) (make-midievent :ev-date 0 :ev-type :CtrlChange :ev-chan (midichannel self) :ev-port (midiport self) :ev-values (list (control2-num self) (control2-val self))) )) ;================================= ; SENDING CONTROLLER MIDI ;================================= (defmethod channel-send-prog ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :ProgChange :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (list (program self))))) (om-midi::midi-send-evt event) t)) (defmethod channel-send-vol ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (list 7 (vol-ctrl self))))) (om-midi::midi-send-evt event) t)) (defmethod channel-send-pan ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (list 10 (pan-ctrl self))))) (om-midi::midi-send-evt event) t)) (defmethod channel-send-ct1 ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (list (control1-num self) (control1-val self))))) (om-midi::midi-send-evt event) t)) (defmethod channel-send-ct2 ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (list (control2-num self) (control2-val self))))) (om-midi::midi-send-evt event) t)) (defmethod channel-send-pitch ((self channel-controls)) (let ((event (om-midi::make-midi-evt :type :PitchBend :chan (midichannel self) :port (or (midiport self) (get-pref-value :midi :out-port)) :fields (pitch-ctrl self)))) (om-midi::midi-send-evt event) t)) (defmethod send-midi-settings ((self channel-controls)) (channel-send-prog self) (channel-send-vol self) (channel-send-pan self) (channel-send-ct1 self) (channel-send-ct2 self) (channel-send-pitch self)) (defmethod send-midi-settings ((self midi-mix-console)) (loop for chan-ctrl in (channels-ctrl self) do (send-midi-settings chan-ctrl))) ;================================= ; PLAY ;================================= ;;; play in a DATA-TRACK (defmethod get-frame-action ((self midi-mix-console)) #'(lambda () (loop for e in (get-midievents self) do (funcall (get-frame-action e))) )) ;;; PLAY BY ITSELF IN A SEQUENCER... ;;; Interval is the interval INSIDE THE OBJECT (defmethod get-action-list-for-play ((self midi-mix-console) interval &optional parent) (when (in-interval 0 interval :exclude-high-bound t) (list (list 0 #'(lambda (obj) (funcall (get-frame-action obj))) (list self)) ))) ;================================= ; EDITOR ;================================= (defclass midi-mix-editor (omeditor) ((channel-panels :accessor channel-panels :initform nil))) (defmethod object-default-edition-params ((self midi-mix-console)) '((:auto-send t))) (defclass channel-panel (om-column-layout) ((channel-controller :initarg :channel-controller :accessor channel-controller :initform nil) (programMenu :initform nil :accessor programMenu) (volumeText :initform nil :accessor volumeText) (volumpeSlider :initform nil :accessor volumeSlider) (pitchText :initform nil :accessor pitchText) (pitchSlider :initform nil :accessor pitchSlider) (panText :initform nil :accessor panText) (panSlider :initform nil :accessor panSlider) (ctrl1menu :initform nil :accessor ctrl1menu) (ctrl1Val :initform nil :accessor ctrl1Val) (ctrl1Slider :initform nil :accessor ctrl1Slider) (ctrl2menu :initform nil :accessor ctrl2menu) (ctrl2Val :initform nil :accessor ctrl2Val) (ctrl2Slider :initform nil :accessor ctrl2Slider) )) (defmethod object-has-editor ((self midi-mix-console)) t) (defmethod get-editor-class ((self midi-mix-console)) 'midi-mix-editor) (defmethod editor-view-class ((self midi-mix-editor)) 'channel-panel) (defmethod get-obj-to-play ((self midi-mix-editor)) (object-value self)) ;============================== ; ACTIONS ON CHANNEL PANELS: ;============================== (defun pan2str (panvalue) (let* ((value (- panvalue 64)) (new-str (cond ((= value 0) (number-to-string value)) ((< value 0) (format nil "L~D" (- value))) ((> value 0) (format nil "R~D" value))))) new-str)) (defmethod set-values-on-panel ((cc channel-controls) (panel channel-panel)) (om-set-selected-item (programMenu panel) (number-to-name (program cc) *midi-gm-programs*)) (om-set-slider-value (panSlider panel) (pan-ctrl cc)) (om-set-dialog-item-text (panText panel) (string+ "Pan " (pan2str (pan-ctrl cc)))) (om-set-slider-value (volumeSlider panel) (vol-ctrl cc)) (om-set-dialog-item-text (volumeText panel) (format nil "Vol ~D" (vol-ctrl cc))) (om-set-slider-value (pitchSlider panel) (pitch-ctrl cc)) (om-set-dialog-item-text (pitchText panel) (format nil "Pitch ~4D mc" (pitchwheel-to-mc (pitch-ctrl cc)))) (om-set-selected-item (ctrl1Menu panel) (number-to-name (control1-num cc) *midi-controllers*)) (om-set-slider-value (ctrl1Slider panel) (control1-val cc)) (om-set-dialog-item-text (ctrl1Val panel) (number-to-string (control1-val cc))) (om-set-selected-item (ctrl2Menu panel) (number-to-name (control2-num cc) *midi-controllers*)) (om-set-slider-value (ctrl2Slider panel) (control2-val cc)) (om-set-dialog-item-text (ctrl2Val panel) (number-to-string (control1-val cc))) ) ;;; change program from menu (defmethod change-channel-program ((self channel-panel) editor value) (let ((cc (channel-controller self))) (setf (program cc) value) (report-modifications editor) (when (editor-get-edit-param editor :auto-send) (channel-send-prog cc)))) ;;; change pan from slider (defmethod change-channel-pan ((self channel-panel) editor value) (let ((cc (channel-controller self))) (unless (= value (pan-ctrl cc)) (setf (pan-ctrl cc) value) (om-set-dialog-item-text (panText self) (string+ "Pan " (pan2str value))) (report-modifications editor)) (when (editor-get-edit-param editor :auto-send) (channel-send-pan cc)))) (defmethod change-channel-vol ((self channel-panel) editor value) (let ((cc (channel-controller self))) (unless (= value (pan-ctrl cc)) (setf (vol-ctrl cc) value) (om-set-dialog-item-text (VolumeText self) (format nil "Vol ~D" value)) (report-modifications editor)) (when (editor-get-edit-param editor :auto-send) (channel-send-vol cc)) )) (defmethod change-channel-pitchbend ((self channel-panel) editor value) (let ((cc (channel-controller self))) (unless (= value (pitch-ctrl cc)) (setf (pitch-ctrl cc) value) (om-set-dialog-item-text (PitchText self) (format nil "Pitch ~4D mc" (pitchwheel-to-mc value))) (report-modifications editor)) (when (editor-get-edit-param editor :auto-send) (channel-send-pitch cc)) )) ;;; change ctrl1 from menu (defmethod change-channel-ctrl1 ((self channel-panel) editor value) (let ((cc (channel-controller self))) (setf (control1-num cc) value) (report-modifications editor) (when (editor-get-edit-param editor :auto-send) (channel-send-ct1 cc)))) ;;; change ctrl2 from menu (defmethod change-channel-ctrl2 ((self channel-panel) editor value) (let ((cc (channel-controller self))) (setf (control2-num cc) value) (report-modifications editor) (when (editor-get-edit-param editor :auto-send) (channel-send-ct2 cc)))) ;;; change ctrl1 val from slider (defmethod change-channel-ctrl1-val ((self channel-panel) editor value) (let ((cc (channel-controller self))) (unless (= value (control1-val cc)) (setf (control1-val cc) value) (om-set-dialog-item-text (Ctrl1Val self) (format nil "~D" value)) (report-modifications editor)) (when (editor-get-edit-param editor :auto-send) (channel-send-ct1 cc)) )) ;;; change ctrl2 val from slider (defmethod change-channel-ctrl2-val ((self channel-panel) editor value) (let ((cc (channel-controller self))) (unless (= value (control2-val cc)) (setf (control2-val cc) value) (om-set-dialog-item-text (Ctrl2Val self) (format nil "~D" value)) (report-modifications editor)) (when (editor-get-edit-param editor :auto-send) (channel-send-ct2 cc)) )) ;;; reset from button ;;; note: doesn't reset the choic of CTL1 et CTL2 controllers ;;; probably shouldn't reset GM program either... ? (defmethod reset-all-values ((self channel-panel) editor) (change-channel-program self editor 0) (om-set-selected-item (programMenu self) (number-to-name 0 *midi-gm-programs*)) (change-channel-pan self editor 64) (om-set-slider-value (panSlider self) 64) (change-channel-vol self editor 100) (om-set-slider-value (volumeSlider self) 100) (change-channel-pitchbend self editor 8192) (om-set-slider-value (pitchSlider self) 8192) (change-channel-ctrl1-val self editor 0) (om-set-slider-value (ctrl1Slider self) 0) (change-channel-ctrl2-val self editor 0) (om-set-slider-value (ctrl2Slider self) 0) ) (defmethod make-channel-track-view ((self channel-controls) editor) (let ((font (om-def-font :normal)) (w 80) (panel (om-make-layout 'channel-panel :align :center :channel-controller self))) (om-add-subviews panel (om-make-di 'om-simple-text :size (omp 16 20) :font (om-def-font :large-b) :text (format nil "~D" (midichannel self)) ) (setf (programMenu panel) (om-make-di 'om-popup-list :size (omp w 24) :font font :items (mapcar #'car *midi-gm-programs*) :value (number-to-name (program self) *midi-gm-programs*) :di-action #'(lambda (item) (change-channel-program panel editor (name-to-number (om-get-selected-item item) *midi-gm-programs*))) )) (setf (pantext panel) (om-make-di 'om-simple-text :size (omp w 20) :font font :text (string+ "Pan " (pan2str (pan-ctrl self))) )) (setf (panSlider panel) (om-make-di 'om-slider :size (om-make-point w 24) :di-action #'(lambda (item) (change-channel-pan panel editor (om-slider-value item))) :increment 1 :range '(0 127) :value (pan-ctrl self) :direction :horizontal :tick-side :none )) :separator (setf (volumetext panel) (om-make-di 'om-simple-text :size (omp 46 20) :font font :text (format nil "Vol ~D" (vol-ctrl self)) )) (setf (volumeSlider panel) (om-make-di 'om-slider :size (om-make-point 24 100) :di-action #'(lambda (item) (change-channel-vol panel editor (om-slider-value item))) :increment 1 :range '(0 127) :value (vol-ctrl self) :direction :vertical :tick-side :none )) :separator (setf (pitchtext panel) (om-make-di 'om-simple-text :size (omp w 20) :font font :text (format nil "Pitch ~4D mc" (pitchwheel-to-mc (pitch-ctrl self))) )) (setf (pitchSlider panel) (om-make-di 'om-slider :size (om-make-point w 24) :di-action #'(lambda (item) (change-channel-pitchbend panel editor (om-slider-value item))) :increment 1 :range '(0 16383) :value (pitch-ctrl self) :direction :horizontal :tick-side :none )) :separator (om-make-di 'om-simple-text :size (omp w 20) :font (om-def-font :normal) :text "Ctrl Changes" ) (setf (Ctrl1Menu panel) (om-make-di 'om-popup-list :size (omp w 24) :font font :items (mapcar #'car *midi-controllers*) :value (number-to-name (control1-num self) *midi-controllers*) :di-action #'(lambda (item) (change-channel-ctrl1 panel editor (name-to-number (om-get-selected-item item) *midi-controllers*))) )) (setf (Ctrl1Slider panel) (om-make-di 'om-slider :size (om-make-point w 24) :di-action #'(lambda (item) (change-channel-ctrl1-val panel editor (om-slider-value item))) :increment 1 :range '(0 127) :value (control1-val self) :direction :horizontal :tick-side :none )) (setf (Ctrl1Val panel) (om-make-di 'om-simple-text :size (omp w 20) :font font :text (format nil "~D" (control1-val self)) )) (setf (Ctrl2Menu panel) (om-make-di 'om-popup-list :size (omp w 24) :font font :items (mapcar #'car *midi-controllers*) :value (number-to-name (control2-num self) *midi-controllers*) :di-action #'(lambda (item) (change-channel-ctrl2 panel editor (name-to-number (om-get-selected-item item) *midi-controllers*))) )) (setf (Ctrl2Slider panel) (om-make-di 'om-slider :size (om-make-point w 24) :di-action #'(lambda (item) (change-channel-ctrl2-val panel editor (om-slider-value item))) :increment 1 :range '(0 127) :value (control2-val self) :direction :horizontal :tick-side :none )) (setf (Ctrl2Val panel) (om-make-di 'om-simple-text :size (omp w 20) :font font :text (format nil "~D" (control2-val self)) )) :separator (om-make-di 'om-button :text "Reset" :font font :size (omp 80 24) :di-action #'(lambda (item) (declare (ignore item)) (reset-all-values panel editor)) ) ;;; end add-subviews ) panel)) (defmethod make-editor-window-contents ((editor midi-mix-editor)) (let ((obj (object-value editor))) (setf (channel-panels editor) (cdr (loop for cc in (channels-ctrl obj) append (list :separator (make-channel-track-view cc editor))))) (let ((port-box ;;; needs to be enabled/disabled by other items... (om-make-graphic-object 'numbox :size (omp 40 20) :position (omp 0 0) :font (om-def-font :normal) :bg-color (om-def-color :white) :value (or (midiport obj) (get-pref-value :midi :out-port)) :enabled (midiport obj) :after-fun #'(lambda (item) (setf (midiport obj) (value item)) (report-modifications editor)) ))) (om-make-layout 'om-column-layout :subviews (list (om-make-layout 'om-row-layout :subviews (channel-panels editor)) :separator (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-check-box :size (omp 100 20) :font (om-def-font :normal) :text "Out MIDI port:" :checked-p (midiport obj) :di-action #'(lambda (item) (if (om-checked-p item) (progn (enable-numbox port-box t) (setf (midiport obj) (get-pref-value :midi :out-port))) (progn (set-value port-box (get-pref-value :midi :out-port)) (enable-numbox port-box nil) (setf (midiport obj) nil))) (report-modifications editor))) (om-make-view 'om-view :size (omp 80 20) :subviews (list port-box)) nil (om-make-di 'om-check-box :size (omp 120 20) :font (om-def-font :normal) :text "send on edit" :checked-p (editor-get-edit-param editor :auto-send) :di-action #'(lambda (item) (editor-set-edit-param editor :auto-send (om-checked-p item))) ) )) )) )))
24,376
Common Lisp
.lisp
523
33.246654
199
0.526045
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
32c1e10bf69eacaed21d2d4ff55b7f80a748f50142f9f80f8ffd2e420571774d
779
[ -1 ]
780
midi-track.lisp
cac-t-u-s_om-sharp/src/packages/midi/objects/midi-track.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;====================================== ;;; BASIC MIDI NOTES / PIANO ROLL ;;; (just a data-stram with frames = midi-notes) ;;; (om-midi::portmidi-connect-ports (om-midi::portmidi-setup nil)) ;;;====================================== ;;; MIDI Note is a special kind of MIDI-Events representing two events (KeyOn/KeyOff) ;;; The MIDI 'values' are also split in two different slots (pitch / vel) ;;; <dur> determines the delay between the two events (defclass* midi-note (MIDIEvent) ((onset :accessor onset :initform 0 :initarg :onset :initarg :date ;;; two possible initargs (for compatibility) :documentation "date/time of the object") ;;; Note-specific slots (pitch :accessor pitch :initarg :pitch :initform 60 :documentation "pitch (MIDI)") (vel :accessor vel :initarg :vel :initform 100 :documentation "velocity (0-127)") (dur :accessor dur :initarg :dur :initform 500 :documentation "duration (ms)") ;;; these two slots are repeated from MIDIEvent: (ev-chan :accessor ev-chan :initarg :ev-chan :initform 1 :documentation "MIDI channel (1-16)") (ev-port :accessor ev-port :initarg :ev-port :initform 0 :documentation "MIDI port (0-...)")) (:default-initargs :ev-type :note) ;; <= this is how we differenciate it from a "real" event (:documentation "An extension of MIDIEVENT suitable for use in a MIDI-TRACK container. Internally a MIDI-NOTE is converted into two MIDIEVENTs (KeyOn and KeyOff). MIDI-NOTE manipulates them as a single entity.") ) (defun midinote-onset (midinote) (onset midinote)) ;;; round pitch: during drag operations, pitch can have float values ;;; (it is rounded only when drag terminates) (defun midinote-pitch (midinote) (round (pitch midinote))) (defun midinote-vel (midinote) (vel midinote)) (defun midinote-dur (midinote) (dur midinote)) (defun midinote-channel (midinote) (ev-chan midinote)) (defun midinote-port (midinote) (ev-port midinote)) (defun midinote-track (midinote) (ev-track midinote)) (defun midinote-end (midinote) (+ (midinote-onset midinote) (midinote-dur midinote))) ;;; redefined from timed-item (defmethod item-get-duration ((self midi-note)) (midinote-dur self)) (defmethod item-set-duration ((self midi-note) dur) (setf (dur self) dur)) (defun make-midinote (&key (onset 0) (pitch 60) (vel 100) (dur 1000) (chan 1) (port 0) (track 0)) (let ((n (make-instance 'midi-note :onset onset :pitch pitch :vel vel :dur dur :ev-chan chan :ev-port port))) (when track (setf (ev-track n) track)) n)) (defmethod initialize-instance ((self midi-note) &rest args) (call-next-method) (setf (ev-values self) (list (pitch self) (vel self)))) (defmethod data-frame-text-description ((self midi-note)) (list (format nil "MIDI NOTE (channel ~A)" (ev-chan self)) (format nil "~A - ~A" (pitch self) (vel self)))) ;;; when midi-note is in a data-track (= not good in principle) ;;; otherwise see get-action-list-for-play (midi-track) (defmethod get-frame-action ((note midi-note)) #'(lambda () (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOn :chan (or (midinote-channel note) 1) :port 0 :fields (list (midinote-pitch note) (midinote-vel note)))) (mp:schedule-timer-relative-milliseconds (mp::make-timer #'(lambda () (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOff :chan (or (midinote-channel note) 1) :port (or (midinote-port note) (get-pref-value :midi :out-port)) :fields (list (midinote-pitch note) 0))))) (midinote-dur note)))) ;;; utility (for tests) (defun gen-random-midi-notes (n &optional (tmax 10000) (channel 1)) (loop for i from 0 to (1- n) collect (make-midinote :onset (om-random 0 tmax) :pitch (om-random 50 90) :vel 100 :dur (om-random 200 500) :chan (or channel (om-random 1 16))))) ;;;=================================================== ;;; MIDI-TRACK IS JUST A SPECIAL KIND OF DATA-TRACK ;;;=================================================== (defclass* midi-track (data-track) ((midi-events :initarg :midi-events :initform '() :documentation "a list of MIDI-NOTEs or MIDIEVENTs")) (:default-initargs :default-frame-type 'midi-note) (:documentation "A container for MIDI-NOTE and other MIDIEVENT objects. MIDI-TRACK is a special kind of DATA-TRACK with adapted visualization and editing of MIDI events. Can import MIDI files by connecting a pathname to the <self> input, or using the keyword :file to open a file chooser.")) (defmethod midi-events ((self midi-track)) (data-track-get-frames self)) (defmethod initialize-instance ((self midi-track) &rest initargs) (call-next-method) (data-track-set-frames self (midievents-to-midinotes (slot-value self 'midi-events) :collect-other-events t)) (setf (slot-value self 'midi-events) nil) self) ;;; redefined from time-sequence (defmethod time-sequence-default-duration ((self midi-track)) 1000) ;;;=================================== ;;; IMPORT NOTES FROM MIDI ;;;=================================== (defmethod midi-key-evt-pitch ((evt MIDIEvent)) (car (ev-values evt))) (defmethod midi-key-evt-vel ((evt MIDIEvent)) (cadr (ev-values evt))) (defun close-note-on (notelist chan pitch date) (flet ((match (x) (and (equal (midinote-pitch x) pitch) (equal (midinote-channel x) chan) (not (plusp (midinote-dur x))) ;;; note is still "open" ;;; (equal (sixth x) track) (equal (seventh x) port) ;;; not used (yet) ))) (let ((pos (position-if #'match notelist :from-end t))) (if pos (setf (dur (nth pos notelist)) (- date (* -1 (midinote-dur (nth pos notelist))))) (om-print-format "Warning: this MIDI sequence has orphan KeyOff messages in channel ~D: ~D (t=~Dms)." (list chan pitch date))) ))) (defun midievents-to-midinotes (evtlist &key collect-other-events) (let ((notelist nil) (other-events nil)) (loop for event in (sort evtlist #'< :key #'onset) do (case (ev-type event) (:KeyOn (if (= (midi-key-evt-vel event) 0) ;;; actually it's a KeyOff (close-note-on notelist (ev-chan event) (midi-key-evt-pitch event) (onset event)) ;;; put a note on with duration open in the list (push (make-midinote :onset (onset event) :pitch (midi-key-evt-pitch event) :dur (* -1 (onset event)) :vel (midi-key-evt-vel event) :chan (ev-chan event) :port (ev-port event) :track (ev-track event) ) ; (ev-track event) ;;; not used notelist)) ) (:KeyOff (close-note-on notelist (ev-chan event) (midi-key-evt-pitch event) (onset event))) (otherwise (when collect-other-events (push (om-copy event) other-events) )) ) ) (when (find-if 'minusp notelist :key 'midinote-dur) (om-print (format nil "Warning: this MIDI sequence has unterminated notes!"))) (sort (append (reverse notelist) (reverse other-events)) #'< :key #'onset) )) (defun import-midi-notes (&optional file) (midievents-to-midinotes (get-midievents (import-midi-events file)) ;; #'(lambda (evt) (test-midi-type evt '(:keyon :keyoff)))) :collect-other-events t)) (defmethod objFromObjs ((model pathname) (target midi-track)) (data-track-set-frames target (import-midi-notes model)) target) ;;; :choose-file ? (defmethod box-def-self-in ((self (eql 'midi-track))) nil) (defmethod objFromObjs ((model (eql (or :file :choose-file))) (target midi-track)) (let ((file (om-choose-file-dialog :prompt "Choose a MIDI file..." :types '("MIDI files" "*.mid;*.midi")))) (if file (objFromObjs file target) (abort-eval)))) ;;; DATA-TRACK=>MIDI-TRACK ;;; Converts KeyOn/KeyOff events to MIDI-NOTEs (defmethod objfromobjs ((model data-track) (target midi-track)) (data-track-set-frames target (midievents-to-midinotes (frames model) :collect-other-events t)) target) ;;; Drop a MIDI file in patch (pushr '(:midi ("mid" "midi") "MIDI files") *doctypes*) (defmethod omNG-make-new-box-from-file ((type (eql :midi)) file pos) (let* ((miditrack (objfromobjs file (make-instance 'midi-track))) (box (make-new-box-with-instance (om-init-instance miditrack) pos))) (set-lock-state box :locked) box)) ;;;=================================== ;;; TO MIDIEVENT ;;;=================================== (defmethod* get-midievents ((self midi-track) &optional test) (let ((evtlist (sort (remove nil (loop for n in (midi-events self) append (if (equal (ev-type n) :note) (list (make-MIDIEvent :ev-date (midinote-onset n) :ev-type :keyon :ev-chan (midinote-channel n) :ev-values (list (midinote-pitch n) (midinote-vel n)) :ev-port (midinote-port n) :ev-track (midinote-track n)) (make-MIDIEvent :ev-date (midinote-end n) :ev-type :keyoff :ev-chan (midinote-channel n) :ev-values (list (midinote-pitch n) 0) :ev-port (midinote-port n) :ev-track (midinote-track n))) ;;; normal event (list (om-copy n)))) ) #'< :key #'onset))) (if test (get-midievents evtlist test) evtlist))) ;;;====================================== ;;; EDITOR ;;;====================================== (defclass midi-track-editor (data-track-editor) ((recording-notes :accessor recording-notes :initform nil))) (defmethod get-editor-class ((self midi-track)) 'midi-track-editor) (defmethod frame-display-modes-for-object ((self data-track-editor) (object midi-track)) '(:blocks)) (defparameter *MIN-MIDI-KEY* 36) (defparameter *MAX-MIDI-KEY* 96) (defmethod object-default-edition-params ((self midi-track)) `((:display-mode :blocks) (:grid t) (:x1 0) (:x2 nil) (:y1 ,*MIN-MIDI-KEY*) (:y2 ,*MAX-MIDI-KEY*))) (defmethod resizable-frame ((self midi-note)) t) (defmethod resizable-frame ((self midievent)) nil) (defmethod get-frame-color ((self midievent)) (if (ev-chan self) (get-midi-channel-color (ev-chan self)) (om-make-color 0 0 0))) (defmethod get-frame-color ((self midi-note)) (get-midi-channel-color (ev-chan self))) (defmethod get-frame-posy ((self midievent)) *MAX-MIDI-KEY* - 4) ;;; MIDIevents are just displayed at the top of the roll (defmethod get-frame-posy ((self midi-note)) (pitch self)) (defmethod get-frame-sizey ((self midi-note)) 1) (defmethod get-frame-sizey ((self midievent)) 4) (defmethod get-frame-area ((frame midievent) editor) (let ((panel (active-panel editor))) (values (x-to-pix panel (date frame)) (y-to-pix panel (get-frame-posy frame)) (max 3 (dx-to-dpix panel (get-frame-graphic-duration frame))) (min -3 (dy-to-dpix panel (get-frame-sizey frame))) ;; !! upwards ))) (defmethod move-editor-selection ((self midi-track-editor) &key (dx 0) (dy 0)) (let* ((midi-track (object-value self)) (frames (loop for fp in (selection self) collect (nth fp (data-track-get-frames midi-track))))) (unless (equal (editor-play-state self) :stop) (close-open-midinotes-at-time frames (get-obj-time midi-track))) (loop for frame in frames do (when (equal (ev-type frame) :note) (setf (pitch frame) (min (1- *MAX-MIDI-KEY*) (max *MIN-MIDI-KEY* (if (equal dy :round) (round (pitch frame)) (+ (pitch frame) dy))))) (when (equal dx :round) (item-set-time frame (round (item-get-time frame)))) )) (call-next-method))) (defmethod resize-editor-selection ((self midi-track-editor) &key (dx 0) (dy 0)) (declare (ignore dy)) (unless (or (equal (editor-play-state self) :stop) (zerop dx)) (let* ((midi-track (object-value self)) (frames (loop for fp in (selection self) collect (nth fp (data-track-get-frames midi-track))))) (close-open-midinotes-at-time frames (get-obj-time midi-track)))) (call-next-method)) (defmethod delete-editor-selection ((self midi-track-editor)) (unless (equal (editor-play-state self) :stop) (let* ((midi-track (object-value self)) (frames (loop for fp in (selection self) collect (nth fp (data-track-get-frames midi-track))))) (close-open-midinotes-at-time frames (get-obj-time midi-track)))) (call-next-method)) (defmethod finalize-data-frame ((frame midi-note) &rest args) (when (equal (ev-type frame) :note) (let ((posy (getf args :posy))) (when posy (setf (pitch frame) (round posy)))))) ;;;================== ;; Keyborad on the left ;;;================== (defclass keyboard-view (om-view) ((pitch-min :accessor pitch-min :initarg :pitch-min :initform 36) (pitch-max :accessor pitch-max :initarg :pitch-max :initform 96))) (defmethod make-left-panel-for-object ((editor data-track-editor) (object midi-track) view) (declare (ignore view)) (om-make-view 'keyboard-view :size (omp 20 nil))) ;;; the small view at the left of teh timeline should be sized according to the editor's layout (defmethod make-timeline-left-item ((self midi-track-editor) id) (om-make-view 'om-view :size (omp 20 15))) (defun draw-keyboard-octave (i x y w h &optional (alpha 1) (borders nil) (octaves nil)) (let ((unit (/ h 12)) (blackpos '(1 3 6 8 10)) (whitepos '(0 1.5 3.5 5 6.5 8.5 10.5 12))) (loop for wk on whitepos when (cadr wk) do (let* ((y1 (- y (* (car wk) unit))) (y2 (- y (* (cadr wk) unit)))) (om-draw-rect x y1 w (- y2 y1) :fill t :color (om-make-color 1 1 1 alpha)) (when borders (om-draw-rect x y1 w (- y2 y1) :fill nil :color (om-make-color 0 0 0 alpha))) )) (om-with-fg-color (om-make-color 0.2 0.2 0.2) (loop for bp in blackpos do (om-draw-rect x (- y (* unit bp)) (/ w 1.8) (- unit) :fill t :color (om-make-color 0 0 0 alpha))) (when octaves (om-with-font (om-def-font :tiny) (om-draw-string (+ x (/ w 2)) (- y 2) (format nil "C~D" i)))) ))) (defun draw-keyboard (x y w h pitch-min pitch-max &optional (alpha 1) borders octaves) (let* ((n-oct (round (- pitch-max pitch-min) 12)) (oct-h (/ h n-oct))) (loop for i from y to (1- n-oct) do (draw-keyboard-octave (1+ i) x (- h (* i oct-h)) w oct-h alpha borders octaves) ) )) (defmethod om-draw-contents ((self keyboard-view)) (draw-keyboard 0 0 (om-width self) (om-height self) (pitch-min self) (pitch-max self) 1 nil t)) (defmethod draw-background ((editor midi-track-editor) (view data-track-panel)) (when (om-add-key-down) (draw-keyboard (- (om-point-x (om-mouse-position view)) 40) 0 40 (h view) *MIN-MIDI-KEY* *MAX-MIDI-KEY* 0.1 t nil) )) (defmethod position-display ((self midi-track-editor) position) (when (om-add-key-down) (om-invalidate-view (active-panel self))) (call-next-method)) (defun select-channel-dialog (&key (default 1)) (let ((win (om-make-window 'om-dialog :title "MIDI channel")) (list (om-make-di 'om-popup-list :size (omp 80 30) :items '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16) :value default))) (om-add-subviews win (om-make-layout 'om-column-layout :align :right :subviews (list (om-make-di 'om-simple-text :text "Select a MIDI channel for the note selection" :size (omp 260 20)) list (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-button :text "Cancel" :size (omp 80 30) :di-action #'(lambda (b) (declare (ignore b)) (om-return-from-modal-dialog win nil))) (om-make-di 'om-button :text "OK" :size (omp 80 30) :di-action #'(lambda (b) (declare (ignore b)) (om-return-from-modal-dialog win (om-get-selected-item list))))) )))) (om-modal-dialog win) )) (defmethod editor-key-action ((editor midi-track-editor) key) (let* ((panel (active-panel editor)) (pr (object-value editor))) (case key (:om-key-up (store-current-state-for-undo editor) (move-editor-selection editor :dy (if (om-shift-key-p) 12 1)) (om-invalidate-view panel) (update-timeline-editor editor) (report-modifications editor)) (:om-key-down (store-current-state-for-undo editor) (move-editor-selection editor :dy (if (om-shift-key-p) -12 -1)) (om-invalidate-view panel) (report-modifications editor)) (#\c (when (selection editor) (let ((c (select-channel-dialog :default (chan (nth (car (selection editor)) (data-track-get-frames pr)))))) (when c (loop for notep in (selection editor) do (let ((note (nth notep (data-track-get-frames pr)))) (setf (chan note) c) ))) )) (om-invalidate-view panel) (report-modifications editor)) (otherwise (call-next-method)) ))) ;;;====================================== ;;; PLAY ;;;====================================== (defmethod get-action-list-for-play ((object midi-track) interval &optional parent) (sort (loop for evt in (midi-events object) when (or (in-interval (onset evt) interval :exclude-high-bound t) (in-interval (+ (onset evt) (get-obj-dur evt)) interval :exclude-high-bound t)) append (case (ev-type evt) (:note (remove nil (list (when (in-interval (midinote-onset evt) interval :exclude-high-bound t) (list (midinote-onset evt) #'(lambda (note) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOn :chan (or (midinote-channel note) 1) :port (or (midinote-port note) (get-pref-value :midi :out-port)) :fields (list (midinote-pitch note) (midinote-vel note))))) (list evt))) (when (in-interval (midinote-end evt) interval :exclude-high-bound t) (list (midinote-end evt) #'(lambda (note) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOff :chan (or (midinote-channel note) 1) :port (or (midinote-port note) (get-pref-value :midi :out-port)) :fields (list (midinote-pitch note) 0)))) (list evt))) ))) (:tempo nil) (otherwise (list (list (onset evt) #'(lambda (e) (send-midievent e)) (list evt))) ))) '< :key 'car) ) (defun close-open-midinotes-at-time (notes time) (loop for note in notes do (when (or (zerop time) (and (<= (midinote-onset note) time) (>= (midinote-end note) time))) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOff :chan (or (midinote-channel note) 1) :port (or (midinote-port note) (get-pref-value :midi :out-port)) :fields (list (midinote-pitch note) 0))) ))) (defmethod send-current-midi-key-offs ((self midi-track)) (close-open-midinotes-at-time (remove-if-not #'(lambda (n) (typep n 'midi-note)) (data-track-get-frames self)) (get-obj-time self))) (defmethod player-stop-object ((self scheduler) (object midi-track)) (send-current-midi-key-offs object) (call-next-method)) (defmethod player-pause-object ((self scheduler) (object midi-track)) (send-current-midi-key-offs object) (call-next-method)) (defmethod player-loop-object ((self scheduler) (object midi-track)) (send-current-midi-key-offs object) (call-next-method)) (defmethod set-object-current-time ((self midi-track) time) (declare (ignore time)) (send-current-midi-key-offs self) (call-next-method)) ;;;====================================== ;;; RECORD ;;;====================================== (defmethod can-record ((self midi-track-editor)) t) (defmethod close-recording-notes ((self midi-track-editor)) (let ((obj (get-obj-to-play self))) (when (recording-notes self) (let ((time-ms (player-get-object-time (player self) obj)) (max-time (or (cadr (play-interval self)) (get-obj-dur obj)))) (maphash #'(lambda (pitch note) (declare (ignore pitch)) (setf (dur note) (- (if (> time-ms (midinote-onset note)) time-ms max-time) (midinote-onset note)))) (recording-notes self)) (clrhash (recording-notes self)))) (time-sequence-update-obj-dur obj) )) (defmethod editor-record-on ((self midi-track-editor)) (let ((midi-track (get-obj-to-play self)) (in-port (get-pref-value :midi :in-port))) (setf (recording-notes self) (make-hash-table)) (setf (record-process self) (om-midi::portmidi-in-start in-port #'(lambda (message time) (declare (ignore time)) (when (equal :play (editor-play-state self)) (let ((time-ms (player-get-object-time (player self) midi-track)) (max-time (or (cadr (play-interval self)) (get-obj-dur midi-track))) (pitch (car (om-midi:midi-evt-fields message)))) (case (om-midi::midi-evt-type message) (:KeyOn (let ((note (make-midinote :onset time-ms :dur 100 :pitch (car (om-midi:midi-evt-fields message)) :vel (cadr (om-midi:midi-evt-fields message)) :chan (om-midi:midi-evt-chan message) :port (om-midi:midi-evt-port message) :track (om-midi:midi-evt-ref message) ))) (setf (gethash pitch (recording-notes self)) note) (time-sequence-insert-timed-item-and-update midi-track note) (report-modifications self) (update-timeline-editor self) (editor-invalidate-views self) )) (:KeyOff (let ((note (gethash pitch (recording-notes self)))) (when note (setf (dur note) (- (if (> time-ms (midinote-onset note)) time-ms max-time) (midinote-onset note))) (remhash pitch (recording-notes self))) (editor-invalidate-views self))) (otherwise nil))))) 1 (and (get-pref-value :midi :thru) (get-pref-value :midi :thru-port)) )) (push self *running-midi-recorders*) (om-print-format "Start recording in ~A (port ~D)" (list (or (name (object self)) (type-of (get-obj-to-play self))) in-port) "MIDI") )) (defmethod editor-record-off ((self midi-track-editor)) (when (record-process self) (om-print-format "Stop recording in ~A" (list (or (name (object self)) (type-of (get-obj-to-play self)))) "MIDI") (om-midi::portmidi-in-stop (record-process self))) (close-recording-notes self) (setf *running-midi-recorders* (remove self *running-midi-recorders*))) (defmethod editor-stop ((self midi-track-editor)) (close-recording-notes self) (call-next-method)) (defmethod editor-pause ((self midi-track-editor)) (close-recording-notes self) (call-next-method)) ;;;====================================== ;;; DRAW ;;;====================================== (defmethod display-modes-for-object ((self midi-track)) '(:mini-view :text :hidden)) ;; (defmethod get-cache-display-for-draw ((self midi-track) box) (list 30 100)) (defmethod draw-mini-view ((self midi-track) (box t) x y w h &optional time) (multiple-value-bind (fx ox) (conversion-factor-and-offset 0 (get-obj-dur (get-box-value box)) w x) (multiple-value-bind (fy oy) (conversion-factor-and-offset 96 36 (- h 20) (+ y 10)) (om-with-line-size 2 (loop for evt in (midi-events self) do (if (subtypep (type-of evt) 'midi-note) (om-with-fg-color (get-midi-channel-color (midinote-channel evt)) (om-draw-line (round (+ ox (* fx (midinote-onset evt)))) (round (+ oy (* fy (midinote-pitch evt)))) (round (+ ox (* fx (midinote-end evt)))) (round(+ oy (* fy (midinote-pitch evt))))) ) (om-with-fg-color (or (get-midi-channel-color (ev-chan evt)) (om-make-color 0 0 0)) (om-draw-line (round (+ ox (* fx (onset evt)))) y (round (+ ox (* fx (onset evt)))) (+ y 10)) ) ) )) t)))
28,498
Common Lisp
.lisp
580
37.308621
134
0.537219
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
1631a077f22124f451d02bed7538c302e3970d41839f658489036a5e4e5836f5
780
[ -1 ]
781
midi-controllers.lisp
cac-t-u-s_om-sharp/src/packages/midi/objects/midi-controllers.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;; FUNCTION SPECIFIED IN BPF (defun midi-controller (bpf-point &optional (control-num 7) (channel 1) (port 0)) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :CtrlChange :chan channel :port port :fields (list control-num (round (cadr bpf-point)))))) ;;; FUNCTION SPECIFIED IN BPC (defun bpc-midi-controller (tpoint &optional (control-num-x 1) (control-num-y 2) (channel 1) (port 0)) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :CtrlChange :chan channel :port port :fields (list control-num-x (round (tpoint-x tpoint))))) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :CtrlChange :chan channel :port port :fields (list control-num-y (round (tpoint-y tpoint))))) ) (defmethod arguments-for-action ((fun (eql 'midi-controller))) '((:int control-num 7) (:int channel 1) (:int port 0))) (defmethod arguments-for-action ((fun (eql 'bpc-midi-controller))) '((:int control-num 1) (:int control-num 2) (:int channel 1) (:int port 0))) ;;; more specific (defun midi-volume-controller (bpf-point &optional (channel 1) (port 0)) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :CtrlChange :chan channel :port port :fields (list 7 (round (cadr bpf-point)))))) (defmethod arguments-for-action ((fun (eql 'midi-volume-controller))) '((:int channel 1) (:int port 0))) (defun midi-pitchbend-controller (bpf-point &optional (channel 1) (port 0)) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :PitchBend :chan channel :port port :fields (list 7 (round (cadr bpf-point)))))) (defmethod arguments-for-action ((fun (eql 'midi-pitchbend-controller))) '((:int channel 1) (:int port 0))) ;======================================= ; MIDI conversions ;======================================= (defmethod! get-continuous-ctrl ((self midi-track) ctrl track port channel) :initvals '(nil nil nil 0 1) :indoc '("a MIDI-TRACK" "type of controller (symbol or number)" "track" "MIDI port" "MIDI channel (1-16)") :doc " Extracts control events of type <ctrl> from a MIDI file or sequence at channel <channel>, track <track> and port <port> anf returns a BPF object. <ctrl> can be a control-change number (see MIDI-CONTROL-CHANGE) or one of the special controls: :Tempo :KeyPress :ChanPress :PitchBend or :Private " :icon :midi-filter (let* ((eventtype (if (numberp ctrl) :CtrlChange ctrl)) (evtList (get-midievents self #'(lambda (e) (and (test-midi-port e port) (test-midi-track e track) (test-midi-channel e channel) (and (equal (ev-type e) eventtype) (if (equal (ev-type e) :CtrlChange) (or (= ctrl (first (ev-values e))) (and (lsb-controller ctrl) (= (- ctrl 32) (first (ev-values e)))) nil) t) ) )))) values dates) (when evtList (let ((last-date -1) (curr-val 0)) (loop for event in evtList do (cond ((equal eventtype :Tempo) (setf curr-val (first (ev-values event)))) ((equal eventtype :PitchBend) (setf curr-val (msb-lsb2value (second (ev-values event)) (first (ev-values event))))) ((equal eventtype :KeyPress) (setf curr-val (second (ev-values event)))) ((equal eventtype :ChanPress) (setf curr-val (first (ev-values event)))) ((equal eventtype :Private) (setf curr-val (first (ev-values event)))) ((equal eventtype :CtrlChange) (if (lsb-controller ctrl) (setf curr-val (if (= (first (ev-values event)) ctrl) (msb-lsb2value (msb curr-val) (second (ev-values event))) (msb-lsb2value (second (ev-values event)) (lsb curr-val)))) (setf curr-val (second (ev-values event)))) )) (if (= last-date (onset event)) (setf (first values) curr-val) (progn (push (onset event) dates) (push curr-val values))) (setf last-date (onset event))))) (make-instance 'BPF :x-points (reverse dates) :y-points (reverse values) :decimals 0) )) (defmethod bpf-to-midi ((self BPF) control-type channel &key track port) (let ((type (if (numberp control-type) :ctrlchange control-type))) (loop for p in (point-pairs self) collect (make-midievent :ev-type type :ev-date (car p) :ev-values (if (numberp control-type) (list control-type (cadr p)) (list (cadr p))) :ev-chan channel :ev-track track :ev-port port) )))
6,283
Common Lisp
.lisp
132
34.992424
146
0.504989
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
229120a10e2f337ff6ae0cc443a30acfb1e5d5a38c1138b493b7f177ab14e51d
781
[ -1 ]
782
midi-values.lisp
cac-t-u-s_om-sharp/src/packages/midi/tools/midi-values.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;; table is one of teh global variables below (defun name-to-number (name table) (cadr (find name table :key 'car :test 'string-equal))) (defun number-to-name (num table) (or (car (find num table :key 'cadr :test '=)) "Undefined")) ;====================== ; LSB/MSP UTILS ;====================== ;=== tests if a controller num corresponds ;=== to LSB value of another one (defun lsb-controller (ctrlNum) (and (>= ctrlNum 32) (<= ctrlNum 63))) ;=== gets MSB from a 14bits value (defun msb (value) (floor (/ value 128))) ;=== gets LSB from a 14bits value (defun lsb (value) (- value (* (msb value) 128))) ;=== decomposes a value in two 7 bytes blocks (defun val2lsbmsb (value) (let ((msb (msb value))) (list (- value (* msb 128)) msb))) ;=== Converts msb lsb to a value (defun msb-lsb2value (msb lsb) (+ lsb (* 128 msb))) ;; 7 bits to 14 bits ;; 7b = 0-127 ;; 14b = 0-16383 (defun 7b-to-14b (v) (* v 128)) ;(round (* (/ pb 127) 16383))) ;====================== ; PITCHBEND/WHEEL ;====================== (defmethod* mc-to-pitchwheel ((midic number) &optional (pw-range 200)) :initvals '(0 200) :indoc '("value in midicents" "variation range") :doc "Outputs a MIDI PitchWheel value corresponding to a variation of <midic> (midicents). <pw-range> is the maximum pitch-wheel range (can vary depending on synthesizers)." :icon :midi (cond ((zerop midic) 8192) ((minusp midic) (round (+ 8192 (* (/ midic pw-range) 8192)))) (t (floor (+ 8192 (* (/ midic pw-range) 8191)))))) ; (mc-to-pitchwheel 50) (defmethod* mc-to-pitchwheel ((midic list) &optional (pw-range 200)) (mapcar #'(lambda (n) (mc-to-pitchwheel n pw-range)) midic)) ;;; pb = (0-127) ;;; total range = +/- 200 midicents (defun pitchbend-to-mc (pb) (- (round (* pb 400) 127) 200)) ;;; pw = (0-16383) ;;; total range = +/- 200 midicents (defun pitchwheel-to-mc (pw) (- (round (* pw 400) 16383) 200)) ;====================== ; CONTINUOUS CONTROLLERS ;====================== (defvar *midi-controllers* '(("BankSelect" 0) ("ModulationWheel" 1) ("BreathController" 2) ("Undefined" 3) ("FootController" 4) ("PortamentoTime" 5) ("DataEntryMSB" 6) ("ChannelVolume" 7) ("Balance" 8) ("Undefined" 9) ("Pan" 10) ("ExpressionController" 11) ("EffectControl1" 12) ("EffectControl2" 13) ("Undefined" 14) ("Undefined" 15) ("GeneralPurposeController1" 16) ("GeneralPurposeController2" 17) ("GeneralPurposeController3" 18) ("GeneralPurposeController4" 19) ("BankSelectFine" 32) ("ModulationWheelFine" 33) ("BreathControllerFine" 34) ("Ctrl03 (Undefined) Fine" 35) ("FootControllerFine" 36) ("PortamentoTimeFine" 37) ("DataEntryMSBLSB" 38) ("ChannelVolumeFine" 39) ("BalanceFine" 40) ("Ctrl09 (Undefined) Fine" 41) ("PanFine" 42) ("ExpressionControllerFine" 43) ("EffectControl1Fine" 44) ("EffectControl2Fine" 45) ("Ctrl14 (Undefined) Fine" 46) ("Ctrl15 (Undefined) Fine" 47) ("GeneralPurposeController1Fine" 48) ("GeneralPurposeController2Fine" 49) ("GeneralPurposeController3Fine" 50) ("GeneralPurposeController4Fine" 51) ("DamperPedal" 64) ("Portamento" 65) ("Sustenuto" 66) ("SoftPedal" 67) ("LegatoFootswitch" 68) ("Hold2" 69) ("SoundController1" 70) ("SoundController2" 71) ("SoundController3" 72) ("SoundController4" 73) ("SoundController5" 74) ("SoundController6" 75) ("SoundController7" 76) ("SoundController8" 77) ("SoundController9" 78) ("SoundController10" 79) ("PortamentoControl" 84) ("Effects1Depth" 91) ("Effects2Depth" 92) ("Effects3Depth" 93) ("Effects4Depth" 94) ("Effects5Depth" 95) ("DataIncrement" 96))) (defmethod* midi-control-change (ctrl) :initvals '(nil) :indoc '("control name") :menuins `((0 ,*midi-controllers*)) :doc "Outputs the MIDI ControlChange number corresponding to <ctrl>." :icon :midi (cond ((stringp ctrl) (name-to-number ctrl *midi-controllers*)) ((numberp ctrl) ;; eg just coming from teh menuins ctrl) (t nil))) ;============================== ; GENERAL MIDI ;============================== ;=== General MIDI programs with program numbers (defvar *midi-gm-programs* '(("0 - Acoustic Grand Piano" 0) ("1 - Bright Acoustic Piano" 1) ("2 - Electric Grand Piano" 2) ("3 - Honki Tonk Piano" 3) ("4 - Electric Piano 1" 4) ("5 - Electric Piano 2" 5) ("6 - Harpsichord" 6) ("7 - Clavinet" 7) ("8 - Celesta" 8) ("9 - Glockenspiel" 9) ("10 - Music Box" 10) ("11 - Vibraphone" 11) ("12 - Marimba" 12) ("13 - Xylophone" 13) ("14 - Tubular bells" 14) ("15 - Dulcimer" 15) ("16 - Drawbar Organ" 16) ("17 - Percussive Organ" 17) ("18 - Rock Organ" 18) ("19 - Church Organ" 19) ("20 - Reed Organ" 20) ("21 - Accordion" 21) ("22 - Harmonica" 22) ("23 - Tango Accordion" 23) ("24 - Nylon Acoustic Guitar" 24) ("25 - Steel Acoustic Guitar" 25) ("26 - Jazz Electric Guitar" 26) ("27 - Clean Electric Guitar" 27) ("28 - Muted Electric Guitar" 28) ("29 - Overdrive Guitar" 29) ("30 - Distorted Guitar" 30) ("31 - Guitar Harmonics" 31) ("32 - Acoustic Bass" 32) ("33 - Electric Fingered Bass" 33) ("34 - Electric Picked Bass" 34) ("35 - Fretless Bass" 35) ("36 - Slap Bass 1" 36) ("37 - Slap Bass 2" 37) ("38 - Synth Bass 1" 38) ("39 - Synth Bass 2" 39) ("40 - Violin" 40) ("41 - Viola" 41) ("42 - Cello" 42) ("43 - Contrabass" 43) ("44 - Tremolo Strings" 44) ("45 - Pizzicato Strings" 45) ("46 - Orchestral Harp" 46) ("47 - Timpani" 47) ("48 - String Ensemble 1" 48) ("49 - String Ensemble 2" 49) ("50 - Synth Strings 1" 50) ("51 - Synth Strings 2" 51) ("52 - Choir Aahs" 52) ("53 - Voice Oohs" 53) ("54 - Synth Voice" 54) ("55 - Orchestra Hit" 55) ("56 - Trumpet" 56) ("57 - Trombone" 57) ("58 - Tuba" 58) ("59 - Muted Trumpet" 59) ("60 - French Horn" 60) ("61 - Brass Section" 61) ("62 - Synth Brass 1" 62) ("63 - Synth Brass 2" 63) ("64 - Soprano Sax" 64) ("65 - Alto Sax" 65) ("66 - Tenor Sax" 66) ("67 - Baritone Sax" 67) ("68 - Oboe" 68) ("69 - English Horn" 69) ("70 - Bassoon" 70) ("71 - Clarinet" 71) ("72 - Piccolo" 72) ("73 - Flute" 73) ("74 - Recorder" 74) ("75 - Pan Flute" 75) ("76 - Bottle Blow" 76) ("77 - Shakuhachi" 77) ("78 - Whistle" 78) ("79 - Ocarina" 79) ("80 - Syn Square Wave" 80) ("81 - Syn Sawtooth Wave" 81) ("82 - Syn Calliope" 82) ("83 - Syn Chiff" 83) ("84 - Syn Charang" 84) ("85 - Syn Voice" 85) ("86 - Syn Fifths Sawtooth w-Wave" 86) ("87 - Syn Brass and Lead" 87) ("88 - New Age Syn Pad" 88) ("89 - Warm Syn Pad" 89) ("90 - Polysynth Syn Pad" 90) ("91 - Choir Syn Pad" 91) ("92 - Bowed Syn Pad" 92) ("93 - Metal Syn Pad" 93) ("94 - Halo Syn Pad" 94) ("95 - Sweep Syn Pad" 95) ("96 - FX Rain" 96) ("97 - FX Soundtrack" 97) ("98 - FX Crystal" 98) ("99 - FX Atmosphere" 99) ("100 - FX Brightness" 100) ("101 - FX Goblins" 101) ("102 - FX Echoes" 102) ("103 - FX Sci-fi" 103) ("104 - Sitar" 104) ("105 - Banjo" 105) ("106 - Shamisen" 106) ("107 - Koto" 107) ("108 - Kalimba" 108) ("109 - Bag Pipe" 109) ("110 - Fiddle" 110) ("111 - Shanai" 111) ("112 - Tinkle Bell" 112) ("113 - Agogo" 113) ("114 - Steel Drums" 114) ("115 - Woodblock" 115) ("116 - Taiko Drum" 116) ("117 - Melodic Tom" 117) ("118 - Syn Drum" 118) ("119 - Reverse Cymbal" 119) ("120 - Guitar Fret Noise" 120) ("121 - Breath Noise" 121) ("122 - Seashore" 122) ("123 - Bird Tweet" 123) ("124 - Telephone Ring" 124) ("125 - Helicopter" 125) ("126 - Applause" 126) ("127 - Gun Shot" 127))) ; Pitches for General MIDI drum notes (channel 10) (defvar *midi-gm-drum-notes* '(("Acoustic Bass Drum" 35) ("Bass Drum 1" 36) ("Side Stick" 37) ("Acoustic Snare" 38) ("Hand Clap" 39) ("Electric Snare" 40) ("Low Floor Tom" 41) ("Closed Hi Hat" 42) ("High Floor Tom" 43) ("Pedal Hi Hat" 44) ("Low Tom" 45) ("Open Hi Hat" 46) ("Low Mid Tom" 47) ("High Mid Tom" 48) ("Crash Cymbal 1" 49) ("High Tom" 50) ("Ride Cymbal 1" 51) ("Chinese Cymbal" 52) ("Ride Bell" 53) ("Tambourine" 54) ("Splash Cymbal" 55) ("Cowbell" 56) ("Crash Cymbal 2" 57) ("Vibraslap" 58) ("Ride Cymbal 2" 59) ("High Bongo" 60) ("Low Bongo" 61) ("Mute High Conga" 62) ("Open High Conga" 63) ("Low Conga" 64) ("High Timbale" 65) ("Low Timbale" 66) ("High Agogo" 67) ("Low Agogo" 68) ("Cabasa" 69) ("Maracas" 70) ("Short Whistle" 71) ("Long Whistle" 72) ("Short Guiro" 73) ("Long Guiro" 74) ("Claves" 75) ("High Wood Block" 76) ("Low Wood Block" 77) ("Mute Cuica" 78) ("Open Cuica" 79) ("Mute Triangle" 80) ("Open Triangle" 81))) ;================================== ; SELECTION BOXES FOR OM (defmethod* gm-program (program-name) :initvals '(nil) :indoc '("Instrument name") :menuins `((0 ,*midi-gm-programs*)) :doc "Outputs the General MIDI program number corresponding to <program-name>." :icon :synth program-name) (defmethod! GM-DrumNote (drumName &optional (midicents t)) :initvals '(nil) :indoc '("Drum name") :menuins `((0 ,*midi-gm-drum-notes*)) :doc "Outputs key value corresponding to <drumname> (in General MIDI standard)." :icon :drum (if midicents (* drumName 100) drumName) )
14,979
Common Lisp
.lisp
344
26.473837
92
0.401165
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
e1fa6101669f41482cc8f2ff9febec94694c8e38b0a05b28a433cbf7f4aa80a6
782
[ -1 ]
783
midi-extract.lisp
cac-t-u-s_om-sharp/src/packages/midi/tools/midi-extract.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;================= ; MIDI NOTES ;================= (defmethod* mf-info ((self midi-track) &optional (tracknum nil)) :initvals '(nil nil) :icon :midi :indoc '("a MIDI-TRACK object" "a track number or nil") :doc "Converts a MIDI-TRACK object into a list of note infos. The result is a list of tracks. Each track is a list of notes. Each note is a list of parameters in the form : (pitch, onset-time, duration, velocity, channel) - <tracknum> allows choosing a single track." :icon :midi :outdoc '("list of list of note infos") (if tracknum (loop for evt in (midi-events self) when (and (equal :note (ev-type evt)) (and (numberp (ev-track evt)) (= tracknum (ev-track evt)))) collect (list (midinote-pitch evt) (midinote-onset evt) (midinote-dur evt) (midinote-vel evt) (midinote-channel evt))) (let ((tracks (make-list (1+ (list-max (loop for evt in (midi-events self) when (equal :note (ev-type evt)) collect (or (ev-track evt) 0)))) :initial-element nil))) (loop for evt in (midi-events self) when (equal :note (ev-type evt)) do (let ((track (or (ev-track evt) 0))) (setf (nth track tracks) (append (nth track tracks) (list (list (midinote-pitch evt) (midinote-onset evt) (midinote-dur evt) (midinote-vel evt) (midinote-channel evt)) ))) )) (remove nil tracks)) )) ;;; same with MIDI-NOTEs (defmethod* get-midi-notes ((self midi-track) &optional (tracknum nil)) :initvals '(nil) :indoc '("a MIDI file or sequence") :icon :midi :doc "Extracts and returns the MIDI-NOTEs from <self> (a MIDI-TRACK)." :icon :midi :outdoc '("list of MIDI-NOTEs") (when (midi-events self) (if tracknum (loop for evt in (midi-events self) when (and (equal :note (ev-type evt)) (and (numberp (ev-track evt)) (= tracknum (ev-track evt)))) collect (make-midinote :onset (midinote-onset evt) :pitch (midinote-pitch evt) :vel (midinote-vel evt) :dur (midinote-dur evt) :chan (midinote-channel evt))) (let ((tracks (make-list (1+ (or (list-max (loop for evt in (midi-events self) when (equal :note (ev-type evt)) collect (or (ev-track evt) 0))) 0)) :initial-element nil))) (loop for evt in (midi-events self) when (equal :note (ev-type evt)) do (let ((track (or (ev-track evt) 0))) (setf (nth track tracks) (append (nth track tracks) (list (make-midinote :onset (midinote-onset evt) :pitch (midinote-pitch evt) :vel (midinote-vel evt) :dur (midinote-dur evt) :chan (midinote-channel evt)) ))) )) tracks) ))) ;================= ; LYRICS / TEXT ;================= (defun isTextual (type) (find type '(:Textual :Copyright :SeqName :InstrName :Lyric :Marker :CuePoint) :test 'equal)) ; Converts an integer (ascii codes) list into a string (defun list2string (list) (let ((rep "")) (loop for item in list do (if (not (= 10 item)) (setf rep (string+ rep (string (code-char item)))))) rep)) ; converts to string the slot "fields" of a textual MidiEvent (defmethod* convert-textinfo ((self MidiEvent)) :indoc '("a MIDIEvent or list of MIDIEvents") :icon :midi-filter :doc " Returns the MIDIEvent or list after converting to string the data (ev-field) of all textual events (e.g. types 'textual', 'copyright', 'lyrics', 'instrname', etc.) " (let ((newEvt (om-copy self))) (when (istextual (ev-type self)) (setf (ev-values newEvt) (list2string (ev-values self)))) newEvt)) (defmethod* convert-textinfo ((self list)) (mapcar #'convert-textinfo self)) ; compat (defmethod me-textinfo ((self t)) (convert-textinfo self)) (defmethod* get-mf-lyrics ((self midi-track)) :initvals '(nil) :indoc '("a MIDI file or sequence") :numouts 2 :doc "Extracts lyrics (event type 'Lyric') from <self>. The second output returns the corresponding dates." :icon :write :outdoc '("list of lyrics texts (strings)" "list of times (ms)") (let ((rep (mat-trans (loop for evt in (midi-events self) when (equal (ev-type evt) :Lyric) collect (list (if (stringp (car (list! (ev-values evt)))) (ev-values evt) (list2string (ev-values evt))) (onset evt))) ))) (values (car rep) (cadr rep)))) ;================= ; TEMPO ;================= (defmethod! get-tempomap ((self midi-track)) :initvals '(nil) :indoc '("a MIDI-TRACK") :icon :midi :doc "Extracts the MIDI tempo changes from <self>. Returns a list of lists (time tempo)." :outdoc '("list of (time tempo) pairs") (let ((tempo-events (get-midievents self #'(lambda (x) (test-midi-type x :tempo))))) (loop for event in tempo-events collect (list (onset event) (first (ev-values event))))))
7,059
Common Lisp
.lisp
159
31.251572
163
0.480996
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
b8ff9158fca240499969dbe87bbe35fd6350159dedbaf05c709afbc876e8d240
783
[ -1 ]
784
midi-out.lisp
cac-t-u-s_om-sharp/src/packages/midi/tools/midi-out.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;=================== ; PITCHBEND & PITCHWHEEL ;=================== (defmethod* pitchwheel ((val number) (chans number) &optional port) :icon :midi-out :indoc '("pitch wheel value(s)" "MIDI channel(s) (1-16)" "output port number") :initvals '(8192 1 nil) :doc "Sends one or more MIDI pitch wheel message(s) of <vals> in the MIDI channel(s) <chans>. <values> and <chans> can be single numbers or lists. The range of pitch wheel is between 0 and 16383 (inclusive). 8192 (default) means no bend. " (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :PitchBend :chan chans :port aport :fields (val2lsbmsb val)))) (om-midi::midi-send-evt event) ))) (defmethod* pitchwheel ((vals number) (chans list) &optional port) (loop for item in chans do (pitchwheel vals item port))) (defmethod* pitchwheel ((vals list) (chans list) &optional port) (loop for item in chans for item1 in vals do (pitchwheel item1 item port))) (defmethod* pitchwheel ((vals list) (chans number) &optional port) (loop for chan from chans for val in vals do (pitchwheel val chan port))) (defmethod* pitchbend ((val number) (chan number) &optional port) :icon :midi-out :indoc '("pitch bend value(s)" "MIDI channel(s) (1-16)" "output port number") :initvals '(64 1 nil) :doc "Sends one or more MIDI pitch bend message(s) of <vals> in the MIDI channel(s) <chans>. <values> and <chans> can be single numbers or lists. The range of pitch bend is between 0 and 127. 64 (default) means no bend. [COMPATIBILITY: PITCHBEND strictly equivalent to PITCHWHEEL with less precision.] " (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :PitchBend :chan chan :port aport :fields (list 0 val)))) (om-midi::midi-send-evt event) ))) (defmethod* pitchbend ((vals number) (chans list) &optional port) (loop for item in chans do (pitchbend vals item port))) (defmethod* pitchbend ((vals list) (chans list) &optional port) (loop for item in chans for item1 in vals do (pitchbend item1 item port))) ;=================== ; PROGRAM CHANGE ;=================== (defmethod* pgmout ((progm integer) (chans integer) &optional port) :icon :midi-out :indoc '("program number" "MIDI channel(s)" "output port number") :initvals '(2 1 nil) :doc "Sends a program change event with program number <progm> to channel(s) <chans>. <progm> and <chans> can be single numbers or lists." (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :ProgChange :chan chans :port aport :fields (list progm)))) (when event (om-midi::midi-send-evt event) t)))) (defmethod* pgmout ((progm number) (chans list) &optional port) (loop for item in chans do (pgmout progm item port))) (defmethod* pgmout ((progm list) (chans list) &optional port) (if (or (null port) (integerp port)) (loop for item in chans for item1 in progm do (pgmout item1 item port)) (loop for item in chans for item1 in progm for item2 in port do (pgmout item1 item item2)))) ;=================== ; POLY KEY PRESSURE ;=================== (defmethod* polyKeypres ((val integer) (pitch integer) (chans integer) &optional port) :icon :midi-out :indoc '("pressure value" "target pitch" "MIDI channel (1-16)" "output port number") :initvals '(100 6000 1 nil) :doc " Sends a key pressure event with pressure <values> and <pitch> on channel <cahns> and port <port>. Arguments can be single numbers or lists. " (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :KeyPress :chan chans :port aport :fields (list (round pitch 100) val)))) (when event (om-midi::midi-send-evt event))) )) (defmethod* polyKeypres ((vals list) (pitch list) (chans list) &optional port) (loop for item in pitch for val in vals for chan in chans do (polyKeypres val item chan port))) (defmethod* polyKeypres ((val integer) (pitch list) (chans integer) &optional port) (loop for item in pitch do (polyKeypres val item chans port))) (defmethod* polyKeypres ((val integer) (pitch list) (chans list) &optional port) (loop for item in pitch for chan in chans do (polyKeypres val item chan port))) (defmethod* polyKeypres ((vals list) (pitch integer) (chans list) &optional port) (loop for val in vals for chan in chans do (polyKeypres val pitch chan port))) (defmethod* polyKeypres ((vals list) (pitch integer) (chans integer) &optional port) (loop for val in vals do (polyKeypres val pitch chans port))) (defmethod* polyKeypres ((vals list) (pitch list) (chans integer) &optional port) (loop for item in pitch for val in vals do (polyKeypres val item chans port))) ;=================== ; AFTER TOUCH ;=================== (defmethod* aftertouch ((val integer) (chans integer) &optional port) :icon :midi-out :indoc '("pressurev value" "MIDI channel (1-16)" "output port number") :initvals '(100 1 nil) :doc "Sends an after touch event of <val> to channel <chans> and port <port>. Arguments can be can be single numbers or lists. " (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :ChanPress :chan chans :port aport :fields (list val)))) (when event (om-midi::midi-send-evt event))) )) (defmethod* aftertouch ((vals number) (chans list) &optional port) (loop for item in chans do (aftertouch vals item port))) (defmethod* aftertouch ((vals list) (chans list) &optional port) (if (or (null port) (integerp port)) (loop for item in vals for val in chans do (aftertouch item val port)) (loop for item in vals for val in chans for item2 in port do (aftertouch item val item2)))) ;=================== ; CONTROL CHANGE ;=================== (defmethod* ctrlchg ((ctrlnum integer) (val integer) (chans integer) &optional port) :icon :midi-out :indoc '("control number" "value" "MIDI channel (1-16)" "output port number") :initvals '(7 100 1 nil) :doc "Sends a control change event with control number <ctrlnum> and value <val> to channel <chans> (and port <port>)." (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan chans :port aport :fields (list ctrlnum val)))) (when event (om-midi::midi-send-evt event))))) (defmethod* ctrlchg ((ctrlnum integer) (val integer) (chans list) &optional port) (loop for item in chans do (ctrlchg ctrlnum val item port))) (defmethod* ctrlchg ((ctrlnum list) (val list) (chans list) &optional port) (loop for ctrl in ctrlnum for item in chans for aval in val do (ctrlchg ctrl aval item port))) (defmethod* ctrlchg ((ctrlnum list) (val list) (chans integer) &optional port) (loop for ctrl in ctrlnum for aval in val do (ctrlchg ctrl aval chans port))) (defmethod* ctrlchg ((ctrlnum list) (val integer) (chans integer) &optional port) (loop for ctrl in ctrlnum do (ctrlchg ctrl val chans port))) (defmethod* ctrlchg ((ctrlnum list) (val integer) (chans list) &optional port) (loop for ctrl in ctrlnum for item in chans do (ctrlchg ctrl val item port))) (defmethod* ctrlchg ((ctrlnum integer) (val list) (chans list) &optional port) (loop for item in chans for aval in val do (ctrlchg ctrlnum aval item port))) ;=================== ; VOLUME ;=================== (defmethod* volume ((vol integer) (chans integer) &optional port) :icon :midi-out :indoc '("value" "MIDI channel (1-16)" "output port number") :initvals '(100 1 nil) :doc "Sends MIDI volume message(s) to channel(s) <chans> and port <port>. Arguments can be numbers or lists. The range of volume values is 0-127. " (unless port (setf port (get-pref-value :midi :out-port))) (setf port (list! port)) (loop for aport in port do (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan chans :port aport :fields (list 7 vol)))) (when event (om-midi::midi-send-evt event))))) (defmethod* volume ((volume number) (chans list) &optional port) (loop for item in chans do (volume volume item port))) (defmethod* volume ((volume list) (chans list) &optional port) (if (or (null port) (integerp port)) (loop for item in volume for val in chans do (volume item val port)) (loop for item in volume for val in chans for item2 in port do (volume item val item2)))) ;=================== ; ALL NOTES OFF ;=================== (defmethod* midi-allnotesoff (&optional port) :icon :midi-out :indoc '("output port number") :initvals '(nil) :doc "Turns all notes off on all channels" (unless port (setf port (get-pref-value :midi :out-port))) (loop for aport in (list! port) do (loop for c from 1 to 16 do (let ((event (om-midi::make-midi-evt :type :CtrlChange :chan c :port aport :fields (list 120 0)))) (when event (om-midi::midi-send-evt event))) )) t) ;=================== ; RESET ;=================== (defmethod* midi-reset (port) :icon :midi-out :indoc '("ouput MIDI port") :initvals '(0) :doc "Sends a MIDI Reset message on port <port>." (loop for chan from 1 to 16 do (let ((event (om-midi::make-midi-evt :type :CtrlChange :port (or port (get-pref-value :midi :out-port)) :chan chan :fields '(121 0)))) (when event (om-midi::midi-send-evt event)))) t) ;=================== ; SEND FREE BYTES ;=================== ;;; THIS FUNCTION WILL PROBABLY NOT WORK ;;; LOW-LEVEL API SHOULD HANDLE THIS TYPE OF EVENTS... OR NOT (defmethod* midi-o ((bytes list) &optional port) :icon :midi-out :indoc '("data bytes" "output port number") :initvals '((144 60 64) nil) :doc "Sends <bytes> out of the port number <port>. " (when bytes (unless port (setf port (get-pref-value :midi :out-port))) (if (list-subtypep bytes 'list) ;;; bytes is a list of lists (if (integerp port) ;;; send all lists one by one to port (loop for item in bytes do (midi-o item port)) ;;; send all lists, one to each port (loop for item in bytes for item1 in port do (midi-o item item1))) ;;; send the bytes list (loop for aport in (list! port) do (om-midi::midi-send-bytes bytes aport)) ) t)) (defmethod* sysex ((databytes list) &optional port) :icon :midi-out :indoc '("data bytes (ID data)" "output port number") :initvals '((1 1) nil) :doc "Sends a system exclusive MIDI message on <port> with any number of data bytes. The data will be framed between SysEx begin/end messages (F0/F7)." (when databytes (unless port (setf port (get-pref-value :midi :out-port))) (if (list-subtypep databytes 'list) (if (integerp port) (loop for item in databytes do (sysex item port)) (loop for item in databytes for item1 in port do (sysex item item1))) (loop for aport in (list! port) do (om-midi::midi-send-bytes (cons #xF0 databytes) aport) (om-midi::midi-send-bytes (cons #xF7 '(0 0)) aport) )) t)) ;=================== ; SEND ONE NOTE ;=================== (defmethod! send-midi-note (port chan pitch vel dur) :icon :midi-out :initvals '(0 1 60 100 1000) :doc "Sends a MIDI note on port <port>, channel <chan>, key <pitch>, with velocity <vel>, and duration <dur>." (let ((note (make-midinote :port port :chan chan :pitch pitch :vel vel :dur dur))) (funcall (get-frame-action note)))) ; (send-midi-note 0 1 60 100 1000)
14,365
Common Lisp
.lisp
334
34.892216
153
0.577061
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
eff34f0985d69b4894b1517ed8dffbbba77b3d6a3287fd1461ad7f4ed16644e0
784
[ -1 ]
785
midi-import-export.lisp
cac-t-u-s_om-sharp/src/packages/midi/tools/midi-import-export.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ; MIDI tempo ; 1000000 microseconds / beat ; i.e. tempo = 60 (defvar *midi-init-tempo* 1000000) ;;; from OM6 (defun logical-time (abstract-time cur-tempo tempo-change-abst-time tempo-change-log-time unit/sec) (+ tempo-change-log-time (round (* (/ 1000.0 unit/sec) (* (- abstract-time tempo-change-abst-time) (/ cur-tempo *midi-init-tempo*)))))) (defun mstempo2bpm (mstempo) (round (* (/ *midi-init-tempo* mstempo) 60))) (defun bpm2mstempo (bpm) (round (* (/ 60 bpm) *midi-init-tempo*))) ;;;================================== ;;; IMPORT ;;;================================== (defun midievents-to-milliseconds (evtseq units/sec) (let ((cur-tempo *midi-init-tempo*) (tempo-change-abst-time 0) (tempo-change-log-time 0) (initdate (om-midi::midi-evt-date (car evtseq)))) (loop for event in evtseq collect (let ((type (om-midi::midi-evt-type event)) (fields (om-midi:midi-evt-fields event))) (when (equal type :Tempo) (let ((date (- (om-midi::midi-evt-date event) initdate))) (setq tempo-change-log-time (logical-time date cur-tempo tempo-change-abst-time tempo-change-log-time units/sec)) (setq cur-tempo (car fields)) (setq tempo-change-abst-time date) (setq fields (list (mstempo2bpm(car fields)))))) (let ((date-ms (logical-time (om-midi::midi-evt-date event) cur-tempo tempo-change-abst-time tempo-change-log-time units/sec))) (om-midi::make-midi-evt :date date-ms :type (om-midi::midi-evt-type event) :chan (om-midi::midi-evt-chan event) :ref (om-midi::midi-evt-ref event) :port (om-midi::midi-evt-port event) :fields fields) ))))) ;;; RETURNS A SORTED LIST OF CL-MIDI's MIDI-EVT structs ;;; Deletes tempo events and converts all dates to milliseconds (defun import-midi-events (&optional file) (multiple-value-bind (evt-list ntracks unit format) (om-midi::midi-import file) (declare (ignore ntracks format)) (when evt-list (midievents-to-milliseconds (sort evt-list '< :key 'om-midi::midi-evt-date) unit) ))) ;;; MAIN: GENERATES A MIDI-TRACK (defmethod* import-midi (&optional file) :initvals '(nil) :icon :midi-import :doc "Returns a MIDI-TRACK containing the MIDI notes and events imported from in <file>." (if file (when (probe-file (pathname file)) (objFromObjs (pathname file) (make-instance 'midi-track))) (let ((path (om-choose-file-dialog :types '("MIDI Files" "*.mid;*.midi")))) (when path (import-midi path))) )) ;;;================================== ;;; EXPORT ;;;================================== ; KEY FUNCTION : to upgrade when voice accept tempo map... ; Converts a sequence in tempo 60 into other tempo ; Returns a new seq (defun insert-tempo-info (seq tempo) (let ((tempoFactor (/ (bpm2mstempo 60) *midi-init-tempo*))) (cons (om-midi::make-midi-evt :type :Tempo :date 0 :ref 0 :fields (list (bpm2mstempo tempo))) (loop for event in seq collect (let ((newevent (om-midi::copy-midi-evt event))) (setf (om-midi::midi-evt-date newevent) (round (/ (om-midi::midi-evt-date event) tempoFactor))) ;(when (equal (om-midi::midi-evt-type event) :Note) ; (om-midi::midi-evt-dur newevent (round (/ (om-midi::midi-evt-dur event) tempoFactor)))) newevent)) ))) ;= Saves sequence with tempo 60 if no tempo is given ;= modif ---> clicks = 1000 so that 1 click = 1ms at tempo 60 (defun export-midi-file (list file &key tempo format) (let ((seq (sort list 'om-midi::midi-evt-<))) (when seq (if tempo ;;; add a tempo event and convert milliseconds (setf seq (insert-tempo-info seq tempo)) ;;; insert a 60 bpm tempo event and times remain in milliseconds (push (om-midi::make-midi-evt :type :Tempo :date 0 :fields (list *midi-init-tempo*)) seq)) (om-midi::midi-export seq file (or format 1) 1000) ))) ;;; MAIN (defmethod* save-as-midi ((object t) filename &key (format nil) retune-channels) :initvals '(nil nil 2 nil nil) :icon :midi-export :doc "Saves <object> as a MIDI file. <filename> defines the target pathname. If not specified, will be asked through a file choose dialog. <approx> specifies the tone division (2, 4 or 8). <format> selects the MIDIFile format (0 or 1). <retune-channels> (t or nil) send pitchbend message per channel to fit setting for approx. For POLY objects: If all voice have same tempo, this tempo is saved in MidiFile. Otherwise all voices are saved at tempo 60." (let ((evtlist (loop for ev in (get-midievents object) collect (export-midi ev)))) (when retune-channels (setf evtlist (append (micro-bend-messages) evtlist))) (export-midi-file evtlist filename :tempo 60 :format format) ))
6,054
Common Lisp
.lisp
123
41.081301
129
0.57441
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
75ebf884f8639177407c2f412d5a94009b95fa22909bf69f02f298e238181c3b
785
[ -1 ]
786
midi-in.lisp
cac-t-u-s_om-sharp/src/packages/midi/tools/midi-in.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defmethod* midi-in (port msg-processing &optional thru) :icon 'midi :indoc '("port number" "incoming message processing patch" "thru port number") :initvals '(nil nil nil) :doc "A local MIDI input receiver. Use 'R' to set the box reactive and activate/deactivate the server. When the MICI receiver is on, MIDI-IN waits for MIDI messages on port <port> and calls <msg-processing> with the decoded message as parameter. If <port> is NIL, the default MIDI In port applies. <msg-processing> (if not NIL) must be a patch in mode 'lambda' with 1 input corresponding to a MIDI message. This patch should handle and process the incoming messages. If <thru> is non-NIL, this should be a port number designating an output MIDI port to redirect incoming messages (e.g. to a MIDI synthesizers). Otherwise, the default MIDI Thru port applies. " t) (defmethod boxclass-from-function-name ((self (eql 'midi-in))) 'OMReceiveBox) (defmethod start-receive-process ((self (eql 'midi-in))) 'start-midi-in) (defmethod stop-receive-process ((self (eql 'midi-in))) 'stop-midi-in) (defun msg-to-midievent (event &optional p) (make-instance 'midievent :ev-type (om-midi::midi-evt-type event) :ev-fields (om-midi::midi-evt-fields event) :ev-chan (om-midi::midi-evt-chan event) :ev-port p)) (defmethod start-midi-in ((box OMReceiveBox) args) (let ((port (or (car args) (get-pref-value :midi :in-port))) (fun (cadr args)) (thru (or (caddr args) (and (get-pref-value :midi :thru) (get-pref-value :midi :thru-port))))) (let ((process (om-midi::portmidi-in-start port #'(lambda (message time) (declare (ignore time)) (let* ((me (msg-to-midievent message port)) (delivered (if fun (funcall fun me) me))) (when delivered (set-delivered-value box delivered))) ) 1 thru))) (when process (om-print-format "MIDI-IN start recording on port ~D" (list port) "MIDI") (push box *running-midi-boxes*) process)) )) (defmethod stop-midi-in ((box OMReceiveBox) process) (when process (om-midi::portmidi-in-stop process) (om-print "MIDI-IN stop recording" "MIDI")) (setf *running-midi-boxes* (remove box *running-midi-boxes*)) t)
3,283
Common Lisp
.lisp
64
43.390625
168
0.580313
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
459a1586cbf58542bfa0e7ec793ea26bfaa5a7e79fff7e1e10274d5087f5b966
786
[ -1 ]
787
midi-api.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/midi-api.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;=========================================================================== ; MIDI functions called by OpenMusic ;;=========================================================================== (in-package :om-midi) (cl-user::compile&load (merge-pathnames "portmidi/portmidi" *load-pathname*)) (cl-user::compile&load (merge-pathnames "portmidi/portmidi-api" *load-pathname*)) (cl-user::compile&load (merge-pathnames "portmidi/portmidi-setup" *load-pathname*)) (cl-user::compile&load (merge-pathnames "CL-MIDI/midi-20070618/midi" *load-pathname*)) (cl-user::compile&load (merge-pathnames "CL-MIDI/clmidi-api" *load-pathname*)) (export '(make-midi-evt midi-evt-date midi-evt-type midi-evt-chan midi-evt-ref midi-evt-port midi-evt-fields copy-midi-evt midi-evt-< midi-send-evt midi-send-bytes midi-import midi-export ) :om-midi) (defvar om-midi::*libportmidi* nil) (defun load-midi-lib () (setf om-midi::*libportmidi* (om-fi::om-load-foreign-library "PortMidi" `((:macosx ,(om-fi::om-foreign-library-pathname "libportmidi.dylib")) (:windows (:or ,(om-fi::om-foreign-library-pathname "libportmidi.dll") (:default "libportmidi"))) (:linux (:or "libportmidi.so" ,(om-fi::om-foreign-library-pathname "libportmidi.so"))) ((:default "libportmidi")))))) (om-fi::add-foreign-loader 'load-midi-lib) (om::add-om-init-fun 'om-midi::om-start-portmidi) ;;; Conventions: channels = 1-16 (defstruct midi-evt (date) (type) (chan) (ref) (port) (fields)) (defparameter *key-ons* (make-list 16)) ;;; input: channels = [1-16] (defun midi-send-evt (evt) (cond ((or (equal (om-midi::midi-evt-type evt) :keyOff) (and (equal (om-midi::midi-evt-type evt) :keyOn) (= 0 (cadr (om-midi::midi-evt-fields evt))))) (setf (nth (1- (om-midi::midi-evt-chan evt)) *key-ons*) (delete (list (om-midi::midi-evt-port evt) (car (om-midi::midi-evt-fields evt))) (nth (1- (om-midi::midi-evt-chan evt)) *key-ons*) :test 'equal))) ((equal (om-midi::midi-evt-type evt) :keyOn) (pushnew (list (om-midi::midi-evt-port evt) (car (om-midi::midi-evt-fields evt))) (nth (1- (om-midi::midi-evt-chan evt)) *key-ons*) :test 'equal))) (portmidi-send-evt evt)) ;;; exported call (defun midi-send-bytes (datalist port) (portmidi-send-bytes datalist port)) ;(defmethod midi-start () ; (portmidi-start)) (defmethod midi-all-keys-off () ;(portmidi-stop) (loop for ch in *key-ons* for c = 1 then (+ c 1) do (loop for note in ch do (midi-send-evt (om-midi::make-midi-evt :type :keyOff :chan c :date 0 :ref 0 :port (car note) :fields (list (cadr note) 0)) ))) (setf *key-ons* (make-list 16))) ;;; A IS BEFORE B IF... (defun midi-evt-< (a b) (or (< (midi-evt-date a) (midi-evt-date b)) ;;; A IS BEFORE B (and (= (midi-evt-date a) (midi-evt-date b)) ;;; A IS = B (not (find (midi-evt-type a) (list :KeyOn :KeyOff)))) ;;; BUT A IS NOT A NOTE MESSAGE (and (= (midi-evt-date a) (midi-evt-date b)) (equal (midi-evt-type a) :KeyOff) (equal (midi-evt-type a) :KeyOn)))) ;;; SEND NOTE OFF MESSAGES FIRST ; MIDI event type identifiers ; = list of supported MIDI events ;(export '(Note KeyOn KeyOff KeyPress CtrlChange ProgChange ChanPress PitchBend ; SongPos SongSel Clock Start Continue Stop Tune ActiveSens Reset ; SysEx Stream Private Process DProcess QFrame Ctrl14b NonRegParam ; RegParam SeqNum Textual Copyright SeqName InstrName Lyric Marker ; CuePoint ChanPrefix EndTrack Tempo SMPTEOffset TimeSign KeySign ; Specific PortPrefix RcvAlarm ApplAlarm Reserved dead) ; :om-midi) (defun midi-import (&optional filename) (let ((file (or filename (om-api:om-choose-file-dialog :types '("MIDI file" "*.mid;*.midi"))))) (when file (if (probe-file file) (cl-midi-load-file file) (progn (print (format nil "File not found: ~s" (namestring file))) nil))))) (defun midi-export (evtlist &optional filename (format 1) (clicks 1000)) (let ((file (or filename (om-api:om-choose-new-file-dialog :types '("MIDI file" "*.mid;*.midi"))))) (when file (cl-midi-save-file evtlist file format clicks) file)))
5,328
Common Lisp
.lisp
108
42.842593
151
0.569859
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
7e79ec747e22d8e714bdd698b138317d72fbed009ad23dee9a4925d76f5f51cd
787
[ -1 ]
788
clmidi-api.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/CL-MIDI/clmidi-api.lisp
;;=========================================================================== ;;; midi-api-cl.lisp ;;; Common Lisp Midi API - based on ms:: versions found in midi-api.lisp ;;; ;;; This program is free software;;; you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License ;;; as published by the Free Software Foundation;;; either version 2 ;;; of the License, or (at your option) any later version. ;;; ;;; See file LICENSE for further informations on licensing terms. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY;;; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program;;; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;;; ;;; Author: Anders Vinjar ;;=========================================================================== ; DocFile ; MIDI functions called by OpenMusic ; Using lisp-based SMF I/O + events ; Sources at Goldsmiths, Univ. of London: http://www.doc.gold.ac.uk/isms/lisp/midi/ ;;=========================================================================== (in-package :om-midi) ;;; FILE OUTPUT: building useful midi-messages, writing SMF's: ;;; smf refs: ;;; ;;; http://acad.carleton.edu/courses/musc108-00-f14/pages/04/04StandardMIDIFiles.html ;;; http://cs.fit.edu/~ryan/cse4051/projects/midi/midi.html ;;; ;;; ;;; BOOKKEEPING, REGISTER SPECIALISED FUNCTIONS TO MAKE MIDI:*MESSAGE FOR EACH MIDI-EVT-TYPE ;;; ;; DEFINE FUNCTION AND REGISTER IN LOOKUP TABLE: (defvar *event-to-message-functions* '()) (defmacro defevt2msg ((name type) &body body) `(prog1 (defun ,name (ev) ,@body) (pushnew (cons ,type #',name) *event-to-message-functions*))) (defun get-event-to-message-func (type) (cdr (assoc type *event-to-message-functions*))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; START OF MESSAGE TYPES ;;; ;; voice messages (defconstant +note-off-opcode+ #x80) (defconstant +note-on-opcode+ #x90) (defconstant +key-pressure-opcode+ #xA0) (defconstant +control-change-opcode+ #xB0) (defconstant +program-change-opcode+ #xC0) (defconstant +channel-pressure-opcode+ #xD0) (defconstant +pitch-bend-opcode+ #xE0) ;; mode messages (defconstant +mode-messages-opcode+ #xB0) ;; meta messages, all have status-byte=#xFF (defconstant +meta-messages-opcode+ #xFF) ;;;============================ ;;; VOICE MESSAGES ;;;============================ (defmethod midi-channel ((event t)) nil) (defmethod midi-channel ((event midi::channel-message)) ;; used where channel isn't set explicit in instance (- (slot-value event 'midi::status) (slot-value event 'midi::status-min))) (defmethod midi-message-time ((msg midi::message)) (midi::message-time msg)) (defmethod midi-message-channel ((msg midi::channel-message)) (midi::message-channel msg)) (defmethod midi-message-channel ((msg t)) -1) ;;; Accessors to define for the different types of MIDI messages (defmethod midi-message-type ((msg t)) (intern (concatenate 'string "unknown/" (string (type-of msg))))) (defmethod midi-message-fields ((msg t)) nil) ;; NOTE OFF (defmethod midi-message-type ((msg midi::note-off-message)) :KeyOff) (defmethod midi-message-fields ((msg midi::note-off-message)) (list (midi::message-key msg) (midi::message-velocity msg))) (defevt2msg (event2note-off :KeyOff) (let* ((fields (midi-evt-fields ev)) (key (first fields)) (vel (second fields)) (chan (1- (midi-evt-chan ev)))) ;TODO: find where this goes to 1-based offset (make-instance 'midi:note-off-message :time (midi-evt-date ev) :key key :velocity vel :status (logior +note-off-opcode+ chan)))) (defun make-note-off-message (time key vel chan) (make-instance 'midi:note-off-message :key key :time time :velocity vel :status (logior +note-off-opcode+ chan))) ;; NOTE ON (defmethod midi-message-type ((msg midi::note-on-message)) :KeyOn) (defmethod midi-message-fields ((msg midi::note-on-message)) (list (midi::message-key msg) (midi::message-velocity msg))) (defevt2msg (event2note-on :KeyOn) (let* ((fields (midi-evt-fields ev)) (key (first fields)) (vel (second fields)) (chan (1- (midi-evt-chan ev)))) (make-instance 'midi:note-on-message :time (midi-evt-date ev) :key key :velocity vel :status (logior +note-on-opcode+ chan)))) (defun make-note-on-message (time key vel chan) (make-instance 'midi:note-on-message :key key :time time :velocity vel :status (logior +note-on-opcode+ chan))) ;; POLY-KEY PRESSURE (defmethod midi-message-type ((msg midi::polyphonic-key-pressure-message)) :KeyPress) (defmethod midi-message-fields ((msg midi::polyphonic-key-pressure-message)) (list (slot-value msg 'midi::key) (slot-value msg 'midi::pressure))) (defevt2msg (event2keypress :KeyPress) (let ((msg (make-instance 'midi:note-on-message :time (midi-evt-date ev) :status (logior +note-on-opcode+ (1- (midi-evt-chan ev)))))) (setf (slot-value msg 'midi::key) (car (midi-evt-fields ev))) (setf (slot-value msg 'midi::pressure) (cadr (midi-evt-fields ev))) msg)) ;; CONTROL CHANGE (defmethod midi-message-type ((msg midi::control-change-message)) :CtrlChange) (defmethod midi-message-fields ((msg midi::control-change-message)) (list (slot-value msg 'midi::controller) (slot-value msg 'midi::value))) (defevt2msg (event2control-change :CtrlChange) (let* ((fields (midi-evt-fields ev)) (controller (first fields)) (value (second (midi-evt-fields ev)))) (make-instance 'midi::control-change-message :time (midi-evt-date ev) :controller controller :value value :status (logior +control-change-opcode+ (1- (midi-evt-chan ev)))))) ;; PROGRAM CHANGE (defmethod midi-message-type ((msg midi:program-change-message)) :ProgChange) (defmethod midi-message-fields ((msg midi:program-change-message)) (list (midi::message-program msg))) (defevt2msg (event2program-change-message :ProgChange) (make-instance 'midi:program-change-message :time (midi-evt-date ev) :program (first (midi-evt-fields ev)) :status (logior +program-change-opcode+ (1- (midi-evt-chan ev))))) ;; CHANNEL PRESSURE (defmethod midi-message-type ((msg midi::channel-pressure-message)) :ChanPress) (defmethod midi-message-fields ((msg midi::channel-pressure-message)) (list (slot-value msg 'midi::pressure))) (defevt2msg (event2chanpress :ChanPress) (let ((msg (make-instance 'midi:note-on-message :time (midi-evt-date ev) :status (logior +note-on-opcode+ (1- (midi-evt-chan ev)))))) (setf (slot-value msg 'midi::pressure) (car (midi-evt-fields ev))) msg)) ;; PITCH BEND (defmethod midi-message-type ((msg midi::pitch-bend-message)) :PitchBend) (defmethod midi-message-fields ((msg midi::pitch-bend-message)) (list (midi::message-value msg))) (defevt2msg (event2pitch-bend :PitchBend) (when (midi-evt-fields ev) (make-instance 'midi::pitch-bend-message :time (midi-evt-date ev) :value (first (midi-evt-fields ev)) :status (logior +pitch-bend-opcode+ (1- (midi-evt-chan ev)))))) ;;;============================ ;;; MODE MESSAGES ;;;============================ (defmethod midi-message-fields ((msg midi::mode-message)) (list (slot-value msg 'midi::channel))) ;; :ResetAllControllers (defmethod midi-message-type ((msg midi::reset-all-controllers-message)) :ResetAllControllers) (defevt2msg (event2reset-all-controllers-message :ResetAllControllers) (make-instance 'midi::reset-all-controllers-message :time (midi-evt-date ev) :status (logior +mode-messages-opcode+ (1- (midi-evt-chan ev))))) ;; :AllNotesOff (defmethod midi-message-type ((msg midi::all-notes-off-message)) :AllNotesOff) (defevt2msg (event2all-notes-off-message :AllNotesOff) (make-instance 'midi::all-notes-off-message :time (midi-evt-date ev) :status (logior +mode-messages-opcode+ (1- (midi-evt-chan ev))))) ;;;============================ ;;; META MESSAGES ;;;============================ ;;; for all text messages : ;;; read fileds as a list with a string inside (defmethod midi-message-fields ((msg midi::text-message)) ;; (map 'list #'char-code (slot-value msg 'midi::text)) ;; restore the list of ASCII.. ? (list (slot-value msg 'midi::text)) ) (defun midi-fields-to-string (fields) (if (stringp (car fields)) (car fields) (map 'string #'code-char fields))) ;; SEQUENCE NUMBER (defmethod midi-message-type ((msg midi::sequence-number-message)) :SeqNum) (defmethod midi-message-fields ((msg midi::sequence-number-message)) (list (slot-value msg 'midi::sequence))) (defevt2msg (event2seqnum :SeqNum) (let ((msg (make-instance 'midi::sequence-number-message :time (midi-evt-date ev) :status +meta-messages-opcode+))) (setf (slot-value msg 'midi::sequence) (car (midi-evt-fields ev))) )) ;; TEXT (defmethod midi-message-type ((msg midi::general-text-message)) :Textual) (defevt2msg (event2text :Textual) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::general-text-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; COPYRIGHT (defmethod midi-message-type ((msg midi::copyright-message)) :CopyRight) (defevt2msg (event2copyright :CopyRight) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::copyright-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; TRACK NAME (defmethod midi-message-type ((msg midi:sequence/track-name-message)) :SeqName) (defevt2msg (event2seqname :SeqName) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::sequence/track-name-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; INSTR NAME (defmethod midi-message-type ((msg midi::instrument-message)) :InstrName) (defevt2msg (event2instrument :InstrName) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::instrument-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; LYRICS (defmethod midi-message-type ((msg midi::lyric-message)) :Lyric) (defevt2msg (event2lyric :Lyric) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::lyric-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; MARKER (defmethod midi-message-type ((msg midi::marker-message)) :Marker) (defevt2msg (event2marker :Marker) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::marker-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; CUE MARKER (defmethod midi-message-type ((msg midi::cue-point-message)) :CuePoint) (defevt2msg (event2cue-point :CuePoint) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::cue-point-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; PROGRAM NAME (defmethod midi-message-type ((msg midi::program-name-message)) :ProgName) (defevt2msg (event2progname :ProgName) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::program-name-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;;; DEVICE NAME (defmethod midi-message-type ((msg midi::device-name-message)) :DeviceName) (defevt2msg (event2devicename :DeviceName) (let ((time (midi-evt-date ev)) (value (midi-fields-to-string (midi-evt-fields ev)))) (let ((inst (make-instance 'midi::device-name-message :time time :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::text) value) inst))) ;; CHANNEL PREFIX PORT (defmethod midi-message-type ((msg midi::channel-prefix-message)) :ChannelPrefix) (defmethod midi-message-fields ((msg midi::channel-prefix-message)) (list (slot-value msg 'midi::channel))) (defevt2msg (event2channel-prefix-msg :MidiPortMsg) (let ((inst (make-instance 'midi::channel-prefix-message :time (midi-evt-date ev) :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::channel) (car (midi-evt-fields ev))) inst)) ;; MIDI PORT (defmethod midi-message-type ((msg midi::midi-port-message)) :MidiPortMsg) (defmethod midi-message-fields ((msg midi::midi-port-message)) (list (slot-value msg 'midi::port))) (defevt2msg (event2midi-port-msg :MidiPortMsg) (let ((inst (make-instance 'midi::midi-port-message :time (midi-evt-date ev) :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::port) (car (midi-evt-fields ev))) inst)) ;; END OF TRACK (defmethod midi-message-type ((msg midi::end-of-track-message)) :EndOfTrackMsg) (defevt2msg (event2end-of-track-msg :EndOfTrackMsg) (let ((inst (make-instance 'midi::end-of-track-message :time (midi-evt-date ev) :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::status) (midi-evt-fields ev)) inst)) ;; TEMPO (defmethod midi-message-type ((msg midi::tempo-message)) :Tempo) (defmethod midi-message-fields ((msg midi::tempo-message)) (list (midi::message-tempo msg))) (defevt2msg (event2tempo :Tempo) (make-instance 'midi:tempo-message :time (midi-evt-date ev) :tempo (first (midi-evt-fields ev)) :status +meta-messages-opcode+)) ;; SMPTE OFFSET ;; => todo: midi:smpte-offset-message ;; TIME SIGNATURE (defmethod midi-message-type ((msg midi::time-signature-message)) :TimeSign) (defmethod midi-message-fields ((msg midi::time-signature-message)) (list (midi::message-numerator msg) (midi::message-denominator msg) ;power of 2 (slot-value msg 'midi::cc) ;midi clocks pr. metronome click (slot-value msg 'midi::bb))) ;n 32nd notes notated per quarter note (defevt2msg (event2time-signature :TimeSign) (let ((inst (make-instance 'midi::time-signature-message :time (midi-evt-date ev) :status +meta-messages-opcode+)) (data (midi-evt-fields ev))) (setf (slot-value inst 'midi::nn) (first data) (slot-value inst 'midi::dd) (second data) (slot-value inst 'midi::cc) (third data) (slot-value inst 'midi::bb) (fourth data)) inst)) ;; KEY SIGNATURE (defmethod midi-message-type ((msg midi::key-signature-message)) :KeySign) (defmethod midi-message-fields ((msg midi::key-signature-message)) (list (midi::message-sf msg) (midi::message-mi msg))) (defevt2msg (event2key-signature :KeySign) (let ((inst (make-instance 'midi::key-signature-message :time (midi-evt-date ev) :status +meta-messages-opcode+))) (setf (slot-value inst 'midi::sf) (first (midi-evt-fields ev)) (slot-value inst 'midi::mi) (second (midi-evt-fields ev))) inst)) ;; SPECIFIC/PROPRIETARY EVENT ;; => todo : midi::proprietary-event ;;;============================ ;;; READ/WRITE ;;;============================ ;; takes instances of the various midi:*message classes, returning a list of midi-evt (defun make-event-from-message (msg ref) (make-midi-evt :type (midi-message-type msg) :date (midi::message-time msg) :chan (1+ (midi-message-channel msg)) :ref ref :fields (midi-message-fields msg))) (defun make-messages-from-event (ev) (let* ((type (midi-evt-type ev)) (func (get-event-to-message-func type))) ;; (when (equal type :TimeSign) ;; (print (list (midi-evt-fields ev) func))) (if func (funcall func ev) (progn (print (format nil "(cl-midi) message-type ~A isn't supported yet" type)) NIL)))) (defun tracks2seq (tracks) (sort (loop for track in tracks for ref = 0 then (+ ref 1) append (loop for msg in track collect (make-event-from-message msg ref))) #'midi-evt-<)) (defun seq2tracks (seq) (let ((tracks nil)) (loop for ev in seq for msg = (make-messages-from-event ev) do (let* ((tracknum (or (midi-evt-ref ev) 0)) (trackpos (position tracknum tracks :key 'car :test '=))) (if trackpos (setf (nth trackpos tracks) (list tracknum (append (cadr (nth trackpos tracks)) (if (listp msg) msg (list msg))))) (push (list tracknum (if (listp msg) msg (list msg))) tracks)))) (mapcar 'cadr (sort tracks '< :key 'car)))) ;;; FUNCTION CALLED BY OM ;;; Returns a flat list of midi-evt with :ref = track num (defun cl-midi-load-file (pathname) (let ((f (midi:read-midi-file pathname))) (values (tracks2seq (midi:midifile-tracks f)) (length (midi:midifile-tracks f)) (midi:midifile-division f) (midi:midifile-format f)))) ;;; FUNCTION CALLED BY OM ;;; Saves a flat list of midi-evt where :ref = track num (defun cl-midi-save-file (seq filename fileformat clicks) (let ((mf (make-instance 'midi:midifile :format fileformat :division clicks))) (setf (slot-value mf 'midi::tracks) (seq2tracks seq)) #+lispworks(sys::ENSURE-DIRECTORIES-EXIST filename :verbose t) ;;; !!! LW specific (midi:write-midi-file mf filename) filename))
18,710
Common Lisp
.lisp
379
43.593668
115
0.647609
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
2e54b02f6d8a6cfd1e0aa2088151d9480e4ef2b1b7332cb0e92421f9e5eb8310
788
[ -1 ]
789
midi.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/CL-MIDI/midi-20070618/midi.lisp
;;; (c) copyright 2003 by Mathieu Chabanne, Camille Constant, ;;; Emmanuel Necibar and Stephanie Recco ;;; ;;; (c) copyright 2003 by Robert Strandh ([email protected]) ;;; ;;; (c) copyright 2007 by David Lewis, Marcus Pearce, Christophe ;;; Rhodes and contributors ;;; ;;; This library is free software; you can redistribute it and/or ;;; modify it under the terms of version 2 of the GNU Lesser General ;;; Public License as published by the Free Software Foundation. ;;; ;;; This library is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; Lesser General Public License for more details. ;;; ;;; You should have received a copy of the GNU Lesser General Public ;;; License along with this library; if not, write to the ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;;; Boston, MA 02111-1307 USA. ;;; ;;; This file contains library for MIDI and Midifiles. Messages are ;;; represented as CLOS class instances in a class hierarchy that ;;; reflects interesting aspects of the messages themselves. (defpackage :midi (:use :common-lisp) (:export #:read-midi-file #:write-midi-file #:midifile #:midifile-format #:midifile-tracks #:midifile-division #:message #:note-off-message #:note-on-message #:tempo-message #:program-change-message #:pitch-bend-message #:key-signature-message #:time-signature-message #:smpte-offset-message #:sequence/track-name-message #:message-channel #:message-key #:message-time #:message-velocity #:message-numerator #:message-denominator #:message-sf #:message-mi #:message-tempo #:message-program #:message-value #:header #:header-type #:unknown-event #:status #:data-byte)) (in-package :midi) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Midifile protocol (defgeneric midifile-format (midifile)) (defgeneric (setf midifile-format) (format midifile)) (defgeneric midifile-division (midifile)) (defgeneric midifile-tracks (midifile)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Message protocol (defgeneric message-time (message)) (defgeneric (setf message-time) (time message)) (defgeneric message-status (message)) (defgeneric message-channel (message)) (defgeneric message-key (message)) (defgeneric message-velocity (message)) (defgeneric message-tempo (message)) (defgeneric message-numerator (message)) (defgeneric message-denominator (message)) (defgeneric message-sf (message)) (defgeneric message-mi (message)) ;; added 03-05-07 (defgeneric message-program (message)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; File support ;; compute the ASCII-based numerical value of the string ;; [warning: works only if the chars are coded in ASCII] ;(eval-when (:compile-toplevel) (defun string-code (s) (let ((v 0)) (loop for i from 0 to (1- (length s)) do (setf v (+ (* v 256) (char-code (aref s i))))) v)) ;) ;(defconstant +header-mthd+ #.(string-code "MThd")) ;(defconstant +header-mtrk+ #.(string-code "MTrk")) (defconstant +header-mthd+ 1297377380) ;; = (string-code "MThd")) (defconstant +header-mtrk+ 1297379947) ;; = (string-code "MTrk")) (defconstant +header-mthd-length+ 6 "value of the header MThd data's length") (defparameter *midi-input* nil "stream for reading a Midifile") (defparameter *input-buffer* '() "used for unreading bytes from *midi-input") (defparameter *midi-output* nil "stream for writing a Midifile") (define-condition unknown-event () ((status :initarg :status :reader status) (data-byte :initform "" :initarg :data-byte :reader data-byte)) (:documentation "condition when the event does not exist in the library")) (define-condition header () ((header-type :initarg :header :reader header-type)) (:documentation "condition when the header is not correct")) (defun read-next-byte () "read an unsigned 8-bit byte from *midi-input* checking for unread bytes" (if *input-buffer* (pop *input-buffer*) (read-byte *midi-input*))) (defun unread-byte (byte) "unread a byte from *midi-input*" (push byte *input-buffer*)) (defun write-bytes (&rest bytes) "write an arbitrary number of bytes to *midi-output*" (mapc #'(lambda (byte) (write-byte byte *midi-output*)) bytes)) (defun read-fixed-length-quantity (nb-bytes) "read an unsigned integer of nb-bytes bytes from *midi-input*" (loop with result = 0 for i from 1 to nb-bytes do (setf result (logior (ash result 8) (read-next-byte))) finally (return result))) (defun write-fixed-length-quantity (quantity nb-bytes) "write an unsigned integer of nb-bytes bytes to *midi-output*" (unless (zerop nb-bytes) (write-fixed-length-quantity (ash quantity -8) (1- nb-bytes)) (write-bytes (logand quantity #xff)))) (defmacro with-midi-input ((pathname &rest open-args &key &allow-other-keys) &body body) "execute body with *midi-input* assigned to a stream from pathname" `(with-open-file (*midi-input* ,pathname :direction :input :element-type '(unsigned-byte 8) ,@open-args) ,@body)) (defmacro with-midi-output ((pathname &rest open-args &key &allow-other-keys) &body body) "execute body with *midi-output* assigned to a stream from pathname" `(with-open-file (*midi-output* ,pathname :direction :output :element-type '(unsigned-byte 8) ,@open-args) ,@body)) (defun read-variable-length-quantity () "read a MIDI variable length quantity from *midi-input*" (loop with result = 0 with byte do (setf byte (read-next-byte) result (logior (ash result 7) (logand byte #x7f))) until (< byte #x80) finally (return result))) (defun write-variable-length-quantity (quantity &optional (termination 0)) (when (> quantity 127) (write-variable-length-quantity (ash quantity -7) #x80)) (write-bytes (logior (logand quantity #x7f) termination))) (defun length-of-variables-length-quantity (quantity) (1+ (if (< quantity 128) 0 (length-of-variables-length-quantity (ash quantity -7))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; MIDI file representation (defclass midifile () ((format :initarg :format :reader midifile-format) (division :initarg :division :reader midifile-division) (tracks :initarg :tracks :reader midifile-tracks)) (:documentation "the class that represents a Midifile in core")) (defparameter *status* nil "the status while reading an event") (defparameter *running-status* nil "the running status while reading an event") (defparameter *dispatch-table* (make-array 256 :initial-element nil) "given values of status (and perhaps data1), find a class to create") (defun read-message () "read a message without time indication from *midi-input*" (let ((classname-or-subtype (aref *dispatch-table* *status*))) (unless classname-or-subtype (error (make-condition 'unknown-event :status *status*))) (if (symbolp classname-or-subtype) (make-instance classname-or-subtype) (let* ((data-byte (read-next-byte)) (classname (aref classname-or-subtype data-byte))) (unless classname (error (make-condition 'unknown-event :status *status* :data-byte data-byte))) (unread-byte data-byte) (make-instance classname))))) (defparameter *time* 0 "accumulated time from the start of the track") (defun read-timed-message () "read a message preceded with a delta-time indication" (let ((delta-time (read-variable-length-quantity)) (status-or-data (read-next-byte))) (if (>= status-or-data #x80) (progn (setf *status* status-or-data) (when (<= *status* #xef) (setf *running-status* *status*))) (progn (unread-byte status-or-data) (setf *status* *running-status*))) (let ((message (read-message))) (fill-message message) (setf (message-time message) (incf *time* delta-time)) message))) (defun write-timed-message (message) "write a message preceded with a delta-time indication" (write-variable-length-quantity (- (message-time message) *time*)) (setf *time* (message-time message)) (write-message message)) (defun read-track () "read a track as a list of timed messages, excluding the end-of-track message" (let ((type (read-fixed-length-quantity 4)) (length (read-fixed-length-quantity 4))) (declare (ignore length)) (unless (= type +header-mtrk+) (error (make-condition 'header :header "MTrk"))) ; (print (list "read track" type length)) (loop with message = nil for i = 0 then (+ i 1) do (setf message (read-timed-message)) ;do (print (list i (type-of message))) until (typep message 'end-of-track-message) collect message))) (defun write-track (track) "write a track (which does not contain the end-of-track message)" (write-fixed-length-quantity +header-mtrk+ 4) (let ((end-of-track-message (make-instance 'end-of-track-message))) ;; write the length of the track (write-fixed-length-quantity (+ (reduce #'+ track :key #'length-message) (length-message end-of-track-message) (loop with time = *time* for message in track sum (prog1 (length-of-variables-length-quantity (- (message-time message) time)) (setf time (message-time message)))) 1) ; the delta time of the end-of-track message 4) (dolist (message track) (write-timed-message message)) (setf (message-time end-of-track-message) *time*) (write-timed-message end-of-track-message))) (defun read-midi-file (filename) "read an entire Midifile from the file with name given as argument" (setf *time* 0) (with-midi-input (filename) (let ((type (read-fixed-length-quantity 4)) (length (read-fixed-length-quantity 4)) (format (read-fixed-length-quantity 2)) (nb-tracks (read-fixed-length-quantity 2)) (division (read-fixed-length-quantity 2))) (unless (and (= length +header-mthd-length+) (= type +header-mthd+)) (error (make-condition 'header :header "MThd"))) ; (print format) (make-instance 'midifile :format format :division division :tracks (loop repeat nb-tracks do (setf *time* 0) ; (when (= format 1) (setf *time* 0)) collect (read-track)))))) (defun write-midi-file (midifile filename) (with-midi-output (filename :if-exists :supersede) (write-fixed-length-quantity +header-mthd+ 4) (write-fixed-length-quantity +header-mthd-length+ 4) (with-slots (format division tracks) midifile (write-fixed-length-quantity format 2) (write-fixed-length-quantity (length tracks) 2) (write-fixed-length-quantity division 2) (setf *time* 0) (loop for track in tracks do (write-track track) (when (= (slot-value midifile 'format) 1) (setf *time* 0)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Conversion routines (defun format1-tracks-to-format0-tracks (tracks) (list (reduce (lambda (t1 t2) (merge 'list t1 t2 #'< :key #'message-time)) (copy-tree tracks)))) (defun format0-tracks-to-format1-tracks (tracks) (assert (null (cdr tracks))) (let (tempo-map track) (dolist (message (car tracks) (list (nreverse tempo-map) (nreverse track))) (if (typep message 'tempo-map-message) (push message tempo-map) (push message track))))) (defun change-to-format-0 (midifile) (assert (= (midifile-format midifile) 1)) (setf (slot-value midifile 'format) 0 (slot-value midifile 'tracks) (format1-tracks-to-format0-tracks (midifile-tracks midifile)))) (defun change-to-format-1 (midifile) (assert (= (midifile-format midifile) 0)) (setf (slot-value midifile 'format) 1 (slot-value midifile 'tracks) (format0-tracks-to-format1-tracks (midifile-tracks midifile)))) (defmethod (setf midifile-format) (new-value midifile) (cond ((= (midifile-format midifile) new-value) new-value) ((and (= new-value 0) (= (midifile-format midifile) 1)) (change-to-format-0 midifile) new-value) ((and (= new-value 1) (= (midifile-format midifile) 0)) (change-to-format-1 midifile) new-value) (t (error "Unsupported conversion from format ~S to format ~S" (midifile-format midifile) new-value)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Macro for defining midi messages (defparameter *status-min* (make-hash-table :test #'eq) "given a class name, find the minimum status value for the type of message") (defparameter *status-max* (make-hash-table :test #'eq) "given a class name, find the maximum status value for the type of message") (defparameter *data-min* (make-hash-table :test #'eq) "given a class name, find the minimum data1 value for the type of message") (defparameter *data-max* (make-hash-table :test #'eq) "given a class name, find the maximum data1 value for the type of message") (defun register-class (class superclass status-min status-max data-min data-max) (unless status-min (setf status-min (gethash superclass *status-min*))) (unless status-max (setf status-max (gethash superclass *status-max*))) (unless data-min (setf data-min (gethash superclass *data-min*))) (unless data-max (setf data-max (gethash superclass *data-max*))) ;; set status values for this class (setf (gethash class *status-min*) status-min) (setf (gethash class *status-max*) status-max) (setf (gethash class *data-min*) data-min) (setf (gethash class *data-max*) data-max) ;; update the dispatch table (when status-min (if data-min (progn (unless (arrayp (aref *dispatch-table* status-min)) (let ((secondary-dispatch (make-array 256 :initial-element nil))) (loop for i from status-min to status-max do (setf (aref *dispatch-table* i) secondary-dispatch)))) (loop for i from data-min to data-max do (setf (aref (aref *dispatch-table* status-min) i) class))) (loop for i from status-min to status-max do (setf (aref *dispatch-table* i) class))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; main filler, length, and writer methods (defgeneric fill-message (message)) (defgeneric write-message (message)) (defgeneric length-message (message) (:method-combination +)) (defmethod fill-message (message) (declare (ignore message)) nil) (defmethod length-message + (message) (declare (ignore message)) 0) (defmethod write-message (message) (declare (ignore message)) nil) (defmacro define-midi-message (name superclasses &key slots filler (length 0) writer status-min status-max data-min data-max) `(progn (register-class ',name ',(car superclasses) ,status-min ,status-max ,data-min ,data-max) (defclass ,name ,superclasses ((status-min :initform ,status-min :allocation :class) (status-max :initform ,status-max :allocation :class) (data-min :initform ,data-min :allocation :class) (data-max :initform ,data-max :allocation :class) ,@slots)) (defmethod fill-message :after ((message ,name)) (with-slots ,(mapcar #'car slots) message (symbol-macrolet ((next-byte (read-next-byte))) ,filler))) (defmethod length-message + ((message ,name)) (with-slots (status-min status-max data-min data-max ,@(mapcar #'car slots)) message ,length)) (defmethod write-message :after ((message ,name)) (with-slots (status-min status-max data-min data-max ,@(mapcar #'car slots)) message ,writer)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; midi messages (define-midi-message message () :slots ((time :initarg :time :accessor message-time) (status :initarg :status :reader message-status)) :length 1 :filler (setf status *status*) :writer (write-bytes status)) (define-midi-message channel-message (message) :slots ((channel :reader message-channel)) :filler (setf channel (logand *status* #x0f))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; voice messages (define-midi-message voice-message (channel-message)) (define-midi-message note-off-message (voice-message) :status-min #x80 :status-max #x8f :slots ((key :initarg :key :reader message-key) (velocity :initarg :velocity :reader message-velocity)) :filler (setf key next-byte velocity next-byte) :length 2 :writer (write-bytes key velocity)) (define-midi-message note-on-message (voice-message) :status-min #x90 :status-max #x9f :slots ((key :initarg :key :reader message-key) (velocity :initarg :velocity :reader message-velocity)) :filler (setf key next-byte velocity next-byte) :length 2 :writer (write-bytes key velocity)) (define-midi-message polyphonic-key-pressure-message (voice-message) :status-min #xa0 :status-max #xaf :slots ((key) (pressure)) :filler (setf key next-byte pressure next-byte) :length 2 :writer (write-bytes key pressure)) (define-midi-message control-change-message (voice-message) :status-min #xb0 :status-max #xbf :data-min #x00 :data-max #x78 :slots ((controller :initarg :controller :reader message-controller) (value :initarg :value :reader message-value)) :filler (setf controller next-byte value next-byte) :length 2 :writer (write-bytes controller value)) (define-midi-message program-change-message (voice-message) :status-min #xc0 :status-max #xcf :slots ((program :initarg :program :reader message-program)) :filler (setf program next-byte) :length 1 :writer (write-bytes program)) (define-midi-message channel-pressure-message (voice-message) :status-min #xd0 :status-max #xdf :slots ((pressure)) :filler (setf pressure next-byte) :length 1 :writer (write-bytes pressure)) (define-midi-message pitch-bend-message (voice-message) :status-min #xe0 :status-max #xef :slots ((value :initarg :value :reader message-value)) :filler (setf value (logior next-byte (ash next-byte 7))) :length 2 :writer (write-bytes (logand value #x7f) (logand (ash value -7) #x7f))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; mode messages (define-midi-message mode-message (channel-message) :filler next-byte) ; consume data byte (define-midi-message reset-all-controllers-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x79 :data-max #x79 :filler next-byte ; consume unused byte :length 2 :writer (write-bytes #x79 0)) (define-midi-message local-control-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7a :data-max #x7a :slots ((mode)) :filler (setf mode (if (= next-byte 0) :off :on)) :length 2 :writer (write-bytes #x7a (if (eq mode :off) 0 127))) (define-midi-message all-notes-off-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7b :data-max #x7b :filler next-byte ; consume unused byte :length 2 :writer (write-bytes #x7b 0)) (define-midi-message omni-mode-off-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7c :data-max #x7c :filler next-byte ; consume unused byte :length 2 :writer (write-bytes #x7c 0)) (define-midi-message omni-mode-on-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7d :data-max #x7d :filler next-byte ; consume unused byte :length 2 :writer (write-bytes #x7d 0)) (define-midi-message mono-mode-on-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7e :data-max #x7e :slots ((nb-channels)) :filler (setf nb-channels next-byte) :length 2 :writer (write-bytes #x7e nb-channels)) (define-midi-message poly-mode-on-message (mode-message) :status-min #xb0 :status-max #xbf :data-min #x7f :data-max #x7f :filler next-byte ; consume unused byte :length 2 :writer (write-bytes #x7f 0)) (define-midi-message system-message (message)) (define-midi-message tempo-map-message (message)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; system common messages (define-midi-message common-message (system-message)) (define-midi-message timing-code-message (common-message) :status-min #xf1 :status-max #xf1 :slots ((code)) :filler (setf code next-byte) :length 1 :writer (write-bytes code)) (define-midi-message song-position-pointer-message (common-message) :status-min #xf2 :status-max #xf2 :slots ((pointer)) :filler (setf pointer (logior next-byte (ash next-byte 7))) :length 2 :writer (write-bytes (logand pointer #x7f) (logand (ash pointer -7) #x7f))) (define-midi-message song-select-message (common-message) :status-min #xf3 :status-max #xf3 :slots ((song)) :filler (setf song next-byte) :length 1 :writer (write-bytes song)) (define-midi-message tune-request-message (common-message) :status-min #xf6 :status-max #xf6) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; system real-time messages (define-midi-message real-time-message (system-message)) (define-midi-message timing-clock-message (real-time-message) :status-min #xf8 :status-max #xf8) (define-midi-message start-sequence-message (real-time-message) :status-min #xfa :status-max #xfa) (define-midi-message continue-sequence-message (real-time-message) :status-min #xfb :status-max #xfb) (define-midi-message stop-sequence-message (real-time-message) :status-min #xfc :status-max #xfc) (define-midi-message active-sensing-message (real-time-message) :status-min #xfe :status-max #xfe) ;; (define-midi-message tune-request-message (real-time-message) ;; :status-min #xf6 :status-max #xf6) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; system exclusive messages (define-midi-message system-exclusive-message (system-message) :status-min #xf0 :status-max #xf0 :slots ((data)) :filler (loop with len = (read-variable-length-quantity) initially (setf data (make-array len :element-type '(unsigned-byte 8))) for i from 0 below len do (setf (aref data i) next-byte)) :length (+ (length-of-variables-length-quantity (length data)) (length data)) :writer (progn (write-variable-length-quantity (length data)) (loop for elem across data do (write-bytes elem)))) (define-midi-message authorization-system-exclusive-message (system-message) :status-min #xf7 :status-max #xf7 :slots ((data)) :filler (loop with len = (read-variable-length-quantity) initially (setf data (make-array len :element-type '(unsigned-byte 8))) for i from 0 below len do (setf (aref data i) next-byte)) :length (+ (length-of-variables-length-quantity (length data)) (length data)) :writer (progn (write-variable-length-quantity (length data)) (loop for elem across data do (write-bytes elem)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; meta messages (define-midi-message meta-message (message) :status-min #xff :status-max #xff :length 2 ; the first data byte and the length byte :filler next-byte ; the first data byte which gives the type of meta message :writer (write-bytes data-min)) (define-midi-message sequence-number-message (meta-message tempo-map-message) :data-min #x00 :data-max #x00 :slots ((sequence)) :filler (let ((data2 next-byte)) (setf sequence (if (zerop data2) 0 (logior (ash next-byte 8) next-byte)))) :length (if (zerop sequence) 0 2) :writer (unless (zerop sequence) (write-bytes (ash sequence -8) (logand sequence #xf)))) (define-midi-message text-message (meta-message) :slots ((text)) :filler (setf text (loop with len = next-byte with str = (make-string len) for i from 0 below len do (setf (aref str i) (code-char next-byte)) finally (return str))) :length (length text) :writer (progn (write-bytes (length text)) (loop for char across text do (write-bytes (char-code char))))) (define-midi-message general-text-message (text-message) :data-min #x01 :data-max #x01) (define-midi-message copyright-message (text-message) :data-min #x02 :data-max #x02) (define-midi-message sequence/track-name-message (text-message tempo-map-message) :data-min #x03 :data-max #x03) (define-midi-message instrument-message (text-message) :data-min #x04 :data-max #x04) (define-midi-message lyric-message (text-message) :data-min #x05 :data-max #x05) (define-midi-message marker-message (text-message tempo-map-message) :data-min #x06 :data-max #x06) (define-midi-message cue-point-message (text-message) :data-min #x07 :data-max #x07) (define-midi-message program-name-message (text-message) :data-min #x08 :data-max #x08) (define-midi-message device-name-message (text-message) :data-min #x09 :data-max #x09) (define-midi-message channel-prefix-message (meta-message) :data-min #x20 :data-max #x20 :slots ((channel)) :length 1 :filler (progn next-byte (setf channel next-byte)) :writer (write-bytes 1 channel)) (define-midi-message midi-port-message (meta-message) :data-min #x21 :data-max #x21 :slots ((port)) :length 1 :filler (progn next-byte (setf port next-byte)) :writer (write-bytes 1 port)) (define-midi-message end-of-track-message (meta-message) :data-min #x2f :data-max #x2f :slots ((status :initform #xff)) :filler next-byte :length 0 :writer (write-bytes 0)) (define-midi-message tempo-message (meta-message tempo-map-message) :data-min #x51 :data-max #x51 :slots ((tempo :initarg :tempo :reader message-tempo)) :filler (progn next-byte (setf tempo (read-fixed-length-quantity 3))) :length 3 :writer (progn (write-bytes 3) (write-fixed-length-quantity tempo 3))) (define-midi-message smpte-offset-message (meta-message tempo-map-message) :data-min #x54 :data-max #x54 :slots ((hr) (mn) (se) (fr) (ff)) :filler (progn next-byte (setf hr next-byte mn next-byte se next-byte fr next-byte ff next-byte)) :length 5 :writer (write-bytes 5 hr mn se fr ff)) (define-midi-message time-signature-message (meta-message tempo-map-message) :data-min #x58 :data-max #x58 :slots ((nn :reader message-numerator) (dd :reader message-denominator) (cc) (bb)) :filler (progn next-byte (setf nn next-byte dd next-byte cc next-byte bb next-byte)) :length 4 :writer (write-bytes 4 nn dd cc bb)) (define-midi-message key-signature-message (meta-message) :data-min #x59 :data-max #x59 :slots ((sf :reader message-sf) (mi :reader message-mi)) :filler (progn next-byte (setf sf (let ((temp-sf next-byte)) (if (> temp-sf 127) (- temp-sf 256) temp-sf)) mi next-byte)) :length 2 :writer (write-bytes 2 (if (< sf 0) (+ sf 256) sf) mi)) (define-midi-message proprietary-event (meta-message) :data-min #x7f :data-max #x7f :slots ((data)) :filler (setf data (loop with len = (read-variable-length-quantity) with vec = (make-array len :element-type '(unsigned-byte 8)) for i from 0 below len do (setf (aref vec i) next-byte) finally (return vec))) :writer (map nil (lambda (byte) (write-bytes byte)) data)) ; FIXME
33,056
Common Lisp
.lisp
661
37.704992
101
0.560285
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
644bd589633b5249ef4e691783490a7c47458918ce69fe00b562768fa1fd802a
789
[ -1 ]
790
portmidi-setup.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/portmidi/portmidi-setup.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;============================== ;;; PORTMIDI PORTS SETUP TOOL ;;;============================== ;;; SETTINGS = ;;; (((IN1 ("IN-DEVICE-NAME" ...)) ;;; ...) ;;; ((OUT1 ("OUT-DEVICE-NAME" ...)) ;;; ...)) ;;; (portmidi-connect-ports (portmidi-setup nil nil)) (in-package :om-midi) ;;; tables ((port name stream) ...) (defvar *portmidi-in-ports-table* nil) (defvar *portmidi-out-ports-table* nil) (defparameter *portmidi-def-buffer-size* 1024) (defun portmidi-close-all-midi-ports () (mapcar #'pm::pm-close (mapcar #'third (remove-duplicates *portmidi-in-ports-table* :key 'cadr :test 'string-equal))) (mapcar #'pm::pm-close (mapcar #'third (remove-duplicates *portmidi-out-ports-table* :key 'cadr :test 'string-equal))) (setf *portmidi-in-ports-table* nil *portmidi-out-ports-table* nil)) (defun portmidi-connect-ports (settings) (portmidi-restart) (om-lisp::om-print "ports setup" "MIDI") (unless (pm-time-started) (pm-time-start)) (let ((pm-devices (list-devices))) ;;; IN (loop for item in (car settings) do (loop for indevice in (cadr item) do (let ((stream (nth 2 (find indevice *portmidi-in-ports-table* :key 'cadr :test 'string-equal)))) (unless stream ;;; no stream is open for this device : create stream and open it (let ((device-id (car (find-if #'(lambda (device) (and (string-equal (getf (cdr device) :name) indevice) (getf (cdr device) :input))) pm-devices)))) (when device-id (setf stream (pm::pm-open-input device-id *portmidi-def-buffer-size*)) ))) (om-lisp::om-print-format "[in] ~D => ~A~A" (list (car item) indevice (if stream "" ": device not found!")) "MIDI") (push (list (car item) indevice stream) *portmidi-in-ports-table*) ;;; add this port/stream pair in the table ))) ;;; OUT (loop for item in (cadr settings) do (loop for outdevice in (cadr item) do (let ((stream (nth 2 (find outdevice *portmidi-out-ports-table* :key 'cadr :test 'string-equal)))) (unless stream ;;; no stream is open for this device : create stream and open it (let ((device-id (car (find-if #'(lambda (device) (and (string-equal (getf (cdr device) :name) outdevice) (getf (cdr device) :output))) pm-devices)))) (when device-id (setf stream (pm::pm-open-output device-id *portmidi-def-buffer-size* 0))))) (om-lisp::om-print-format "[out] ~D => ~A~A" (list (car item) outdevice (if stream "" ": device not found!")) "MIDI") (push (list (car item) outdevice stream) *portmidi-out-ports-table*) ;;; add this port/stream pair in the table )) ) t)) (defun get-input-stream-from-port (port) (when port (let ((device (find port *portmidi-in-ports-table* :key 'car :test '=))) (values (nth 2 device) (nth 1 device))))) (defun get-output-stream-from-port (port) (when port (let ((device (find port *portmidi-out-ports-table* :key 'car :test '=))) (values (nth 2 device) (nth 1 device))))) (defmethod portmidi-setup (settings) (show-portmidi-dialog settings)) (defclass portmidi-ports-dialog (oa::om-dialog) ((portviews :accessor portviews :initform nil :initarg :portviews) (settings :accessor settings :initform nil :initarg :settings))) (defclass portmidi-ports-view (oa::om-column-layout) ((portlines :accessor portlines :initform nil :initarg :portlines) (direction :accessor direction :initform nil :initarg :direction))) (defmethod set-portmidi-connection-view ((self portmidi-ports-view) dialog) (let ((devices (remove nil (loop for ref in (list-devices) when (nth (if (equal (direction self) :in) 6 8) ref) collect (nth 4 ref)))) (pos-in-settings (if (equal (direction self) :in) 0 1))) (oa::om-with-delayed-update self (apply 'oa::om-remove-subviews (cons self (portlines self))) (when (nth pos-in-settings (settings dialog)) (apply 'oa::om-add-subviews (cons self (append (setf (portlines self) (loop for portsetting in (sort (nth pos-in-settings (settings dialog)) '< :key 'car) collect (oa::om-make-layout 'oa::om-row-layout :subviews (list (oa::om-make-di 'oa::om-simple-text :size (oa::om-make-point 40 24) :text (format nil "~D" (car portsetting)) :font (oa::om-def-font :gui-title)) (oa::om-make-di 'oa::om-button :size (oa::om-make-point 40 24) :text "-" :di-action (let ((n (car portsetting))) #'(lambda (button) (declare (ignore button)) (setf (nth pos-in-settings (settings dialog)) (remove n (nth pos-in-settings (settings dialog)) :key 'car :test '=)) (set-portmidi-connection-view self dialog) ))) (oa::om-make-di 'oa:om-popup-list :size (oa::om-make-point 200 24) :items (cons "[disconnected]" devices) :value (car (cadr portsetting)) ;; device for this port :di-action (let ((p (position (car portsetting) (nth pos-in-settings (settings dialog)) :test '= :key 'car)) (port (car portsetting))) #'(lambda (list) (setf (nth p (nth pos-in-settings (settings dialog))) (list port (if (= 0 (oa::om-get-selected-item-index list)) nil (list (oa::om-get-selected-item list)))))))) nil)))) nil))))))) (defun show-portmidi-dialog (settings) (let ((dd (oa::om-make-window 'portmidi-ports-dialog :window-title "PortMIDI Setup" :size (oa::om-make-point 600 310) :resizable t :settings settings)) (inv (oa::om-make-layout 'portmidi-ports-view :size (oa::om-make-point 300 210) :direction :in)) (outv (oa::om-make-layout 'portmidi-ports-view :size (oa::om-make-point 300 210) :direction :out))) (oa::om-add-subviews inv (oa::om-make-layout 'oa::om-row-layout :ratios '(1 1 1 100) :subviews (list (oa::om-make-di 'oa::om-simple-text :size (oa::om-make-point 40 24) :text "In" :font (oa::om-def-font :gui-title)) (oa::om-make-di 'oa::om-button :size (oa::om-make-point 40 24) :text "+" :di-action #'(lambda (item) (declare (ignore item)) (let ((newport 0)) (loop while (find newport (car (settings dd)) :test '= :key 'car) do (setf newport (1+ newport))) (setf (settings dd) (list (append (car (settings dd)) (list (list newport nil))) (cadr (settings dd)))) (set-portmidi-connection-view inv dd) ))) (oa::om-make-di 'oa::om-simple-text :size (oa::om-make-point 120 24) :text "Input Devices" :font (oa::om-def-font :gui-title)) NIL )) ) (oa::om-add-subviews outv (oa::om-make-layout 'oa::om-row-layout :ratios '(1 1 1 100) :subviews (list (oa::om-make-di 'oa::om-simple-text :size (oa::om-make-point 40 24) :text "Out" :font (oa::om-def-font :gui-title)) (oa::om-make-di 'oa::om-button :size (oa::om-make-point 40 24) :text "+" :di-action #'(lambda (item) (declare (ignore item)) (let ((newport 0)) (loop while (find newport (cadr (settings dd)) :test '= :key 'car) do (setf newport (1+ newport))) (setf (settings dd) (list (car (settings dd)) (append (cadr (settings dd)) (list (list newport nil))) )) (set-portmidi-connection-view outv dd) ))) (oa::om-make-di 'oa::om-simple-text :size (oa::om-make-point 120 24) :text "Output Devices" :font (oa::om-def-font :gui-title)) NIL )) ) (setf (portviews dd) (list inv outv)) (oa::om-add-subviews dd (oa::om-make-layout 'oa:om-column-layout :ratios '(1 nil) :delta 10 :subviews (list (oa::om-make-layout 'oa:om-row-layout :subviews (list inv outv)) (oa::om-make-layout 'oa:om-row-layout :align :bottom :subviews (list (oa::om-make-di 'oa::om-multi-text :size (oa::om-make-point 400 32) :fg-color (oa:om-def-color :dark-gray) :text "This software detects MIDI devices at startup. If some active MIDI devices do not appear in the lists, you might need to restart." :font (oa::om-def-font :gui)) ;(oa::om-make-di 'oa::om-button :position (oa::om-make-point 20 265) :size (oa::om-make-point 130 20) :text "Refresh Devices" ; :di-action #'(lambda (item) ; (portmidi-connect-ports (settings dd)) ; (set-portmidi-connection-view inv dd) ; (set-portmidi-connection-view outv dd) ; )) NIL (oa::om-make-di 'oa::om-button :size (oa::om-make-point 80 24) :text "Cancel" :di-action #'(lambda (item) (declare (ignore item)) (oa::om-return-from-modal-dialog dd nil))) (oa::om-make-di 'oa::om-button :size (oa::om-make-point 80 24) :text "OK" :di-action #'(lambda (item) (declare (ignore item)) (oa::om-return-from-modal-dialog dd (settings dd)))) )) ))) (set-portmidi-connection-view inv dd) (set-portmidi-connection-view outv dd) (oa::om-modal-dialog dd) ))
14,211
Common Lisp
.lisp
237
36.400844
191
0.413221
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
7b1beff005ea1a4a48b852d0f3425e409692070c1117311b7bd97c574f435b7b
790
[ -1 ]
791
portmidi-api.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/portmidi/portmidi-api.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om-midi) (pushnew :portmidi *features*) (defun om-start-portmidi () (when om-midi::*libportmidi* (pm::pm-initialize)) om-midi::*libportmidi*) (defun om-stop-portmidi () (when om-midi::*libportmidi* (pm::pm-terminate))) ;;;======================================== ;;; From H. Taube's CFFI binding ;;;======================================== (defmacro with-pm-error (form) (let ((v (gensym))) `(let ((,v ,form)) (if (not (= ,v pm::pmNoError)) (if (= ,v pm::pmHostError) (error "Host error is: ~a" (pm::pm-get-host-error-text)) (error (pm::pm-get-error-text ,v)) ))))) ;;;======================================== ;;; PortTime ;;;======================================== (defun pm-time-started () (let ((res (pm::pt-started))) (if (= res 0) nil t))) (defun pm-time-start () ;; NB: This has to be called before opening output or input. ;; it seems that if its called 2x we get an error. (unless (pm-time-started) (with-pm-error (pm::pt-start 1 (cffi:null-pointer) (cffi:null-pointer)))) (values)) (defun pm-time-stop () (when (pm-time-started) (with-pm-error (pm::pt-stop))) (values)) ;;;======================================== ;;; Devices ;;;======================================== (defun describe-device (id) (multiple-value-bind (interf name input output opened) (pm::pm-get-device-info id) (list id :interface interf :name name :input input :output output :open opened) )) (defun list-devices () (loop for i below (pm::pm-count-devices) collect (describe-device i))) ; (list-devices) ;;;======================================== ;;; START/STOP: NOT USEFUL AT THE END SINCE MIDI PORTS WILL STAY OPEN ;;;======================================== ;(defvar *midi-out-stream* nil) ; (portmidi-start) #| (defun portmidi-start (&optional (buffersize 1024)) (unless (pm-time-started) (pm-time-start)) ;(unless *midi-out-stream* ; (handler-bind ((error #'(lambda (err) ; (print "PortMidi: Could not open MIDI device!!!") ; (abort)))) ; (setf *midi-out-stream* (pm::pm-open-output 0 buffersize 0)))) (defun portmidi-stop () ;(pm::pm-close *midi-out-stream*) ;(setf *midi-out-stream* nil) (when (pm-time-started) (pm-time-stop)) t) |# ;;; used, e.g. to refresh the list of devices (defun portmidi-restart (&optional (print t)) (portmidi-close-all-midi-ports) (om-stop-portmidi) (pm::pm-initialize) (when print (om-lisp::om-print "initialized" "MIDI") (let ((devices (list-devices))) (if devices (progn (om-lisp::om-print "devices detected:" "MIDI") (loop for device in devices do (om-lisp:om-print-format "~A ~A" (list (cond ((and (nth 6 device) (nth 8 device)) "[in-out]") ((nth 6 device) "[in] ") ((nth 8 device) "[out]") (t "[-]")) (nth 4 device)) "MIDI"))) (om-lisp::om-print "no MIDI devices detected" "MIDI")) ))) ; (portmidi-restart) ;;;======================================== ;;; MESSAGES ;;; FROM CL-PORT-MIDI ;;;======================================== (defun pm-channel (channel) "=> the bitmask for 'channel" (ash 1 channel)) (defun pm-channels (&rest channels) "=> a bitmask for multiple channels" (apply #'+ (mapcar #'channel channels))) (defun make-message (status data1 data2) "=> an integer representing a MIDI message Combines the integers `status`, `data1` and `data2` to a MIDI message." (let ((d2 (boole boole-and (ash data2 16) #xFF0000)) (d1 (boole boole-and (ash data1 8) #xFF00)) (st (boole boole-and status #xFF))) (boole boole-ior d2 (boole boole-ior d1 st)))) (defun message-status (msg) "=> the status byte of the MIDI message `msg` as an integer" (boole boole-and msg #xFF)) (defun message-data1 (msg) "=> the first data byte of the MIDI message `msg` as an integer" (boole boole-and (ash msg -8) #xFF)) (defun message-data2 (msg) "=> the second data byte of the MIDI message `msg` as an integer" (boole boole-and (ash msg -16) #xFF)) (defun make-message* (upper lower data1 data2) ;internal "=> a MIDI message as an integer Works like `make-message` but combines `upper` and `lower` to the status byte." (let ((status (boole boole-ior (boole boole-and (ash upper 4) #xF0) (boole boole-and lower #xF)))) (make-message status data1 data2))) ;; ex. Note-ON on channel ;; (make-message* 9 0 60 100) ;; ex. Note-OFF on channel ;; (make-message* 8 channel note velocity) ;; (message-status 14208) (defun message-type (status) (ash (logand status #xf0) -4)) (defun message-channel (status) (logand status #x0f)) ;;;======================================== ;;; MESSAGES - OUR API ;;;======================================== (defvar *midi-typenum-table* '((:KeyOff #b1000) (:KeyOn #b1001) (:KeyPress #b1010) (:CtrlChange #b1011) (:ProgChange #b1100) (:ChanPress #b1101) (:PitchBend #b1110) ;;; mode messages have same status bytes as CtrlChange (:ResetAllControllers #b1011) (:AllNotesOff #b1011) )) (defvar *midi-meta-types* '(:SeqNum :Textual :Copyright :SeqName :InstrName :Lyric :Marker :CuePoint :ProgName :DeviceName :ChannelPrefix :MidiPortMsg :EndTrack :Tempo :SMPTEOffset :TimeSign :KeySign :Specific)) ; (type-to-midi :KeyOff) (defun type-to-midi (type) (or (cadr (find type *midi-typenum-table* :key 'car :test 'equal)) (and (find type *midi-meta-types*) #xFF) (progn (print (format nil "PORTMIDI API - MESSAGE TYPE NOT SUPPORTED: ~S " type)) nil) )) ; (midi-to-type 9) (defun midi-to-type (num) (or (car (find num *midi-typenum-table* :key 'cadr :test '=)) (progn (print (format nil "PORTMIDI API - UNKNOW MESSAGE NUM: ~S " num)) nil) )) (defun portmidi-make-midi-evt (midi-message &optional port) (make-midi-evt :type (midi-to-type (message-type (message-status midi-message))) :chan (1+ (message-channel (message-status midi-message))) :port port :fields (list (message-data1 midi-message) (message-data2 midi-message)) )) (defun PMEventBufferMap (fn buf end &optional port) (loop for i below end for e = (pm::pm-EventBufferElt buf i) do (funcall fn (portmidi-make-midi-evt (pm::Event.message e) port) (pm::Event.timestamp e))) (values)) (defun 7-msb (14bitval) (logand (ash 14bitval -7) #x7f)) (defun 7-lsb (14bitval) (logand 14bitval #x7f)) (defun make-midi-bytes (type channel vals) (let ((type-ref (type-to-midi type)) (v1 (if (listp vals) (car vals) (7-lsb vals))) (v2 (if (listp vals) (or (cadr vals) 0) (7-msb vals)))) (when type-ref (apply 'make-message* (list type-ref channel v1 v2))))) (defun send-bytes (bytes port) (let ((out (get-output-stream-from-port port))) (if out (and bytes (pm::pm-write-short out 0 bytes)) (print (format nil "PortMIDI ERROR: port ~A is not connected. Check MIDI preferences to connect MIDI devices ?" port)) ))) (defun portmidi-send-bytes (datalist port) (send-bytes (apply 'make-message datalist) port)) (defun portmidi-send-evt (evt) (when (midi-evt-port evt) (let ((bytes (make-midi-bytes (midi-evt-type evt) (1- (midi-evt-chan evt)) (midi-evt-fields evt)))) (when bytes (send-bytes bytes (midi-evt-port evt))) ))) ;;;======================================== ;;; MIDI IN ;;;======================================== ;;;; FROM Taube's CFFI bindings (defun portmidi-Read (stream *evbuf len) (let ((res (pm::pm-read stream *evbuf len))) (if (< res 0) (error (pm::pm-get-error-text res)) res))) ;;; check if there is something in stream (defun portmidi-Poll (stream) (let ((res (pm::pm-poll stream))) (cond ((= res 0) nil) ((= res 1) t) (t (error (pm::pm-get-error-text res)))))) (defstruct midi-in-process (process) (buffer)) (defun midi-in-loop (stream buff size &optional (fun nil) (port nil) (redirect-to-port nil)) (UNWIND-PROTECT (let ((out? (get-output-stream-from-port redirect-to-port))) ;;; flush current buffer (anything received before the loop starts) (loop while (portmidi-poll stream) do (portmidi-read stream buff size)) (loop do (if (portmidi-poll stream) (let ((n (portmidi-read stream buff size))) (unless (= n 0) (when fun (PMEventBufferMap fun buff n port)) (when out? (PMEventBufferMap #'(lambda (message time) (declare (ignore time)) (portmidi-send-evt message)) buff n redirect-to-port)) )) (sleep 0.001)))) (PROGN (pm::pm-EventBufferFree buff) (mp:process-kill mp::*current-process*)) )) ; (get-input-stream-from-port 0) (defun portmidi-in-start (portnum function &optional (buffersize 32) redirect-to-port) (multiple-value-bind (in name) (get-input-stream-from-port portnum) (if (null in) (progn (print (format nil "PortMidi ERROR: INPUT port ~A is not connected" portnum)) nil) (let* ((midibuffer (pm::pm-EventBufferNew buffersize)) (midiprocess (make-midi-in-process :buffer midibuffer :process (mp:process-run-function (format nil "MIDI IN (~s)" name) nil #'midi-in-loop in midibuffer buffersize function portnum redirect-to-port)))) midiprocess)))) (defun portmidi-in-stop (midiprocess) (mp:process-kill (midi-in-process-process midiprocess)) (prog1 (pm::pm-EventBufferFree (midi-in-process-buffer midiprocess)) (mp:process-wait "Wait until MIDI IN process be killed" #'(lambda () (not (mp:process-alive-p (midi-in-process-process midiprocess))))) )) #| (pm::pm-terminate) (pm::pm-initialize) (portmidi-restart) (pm-time-started) (pm-time-start) (list-devices) (pm::pm-get-default-output-device-id) (pm::pm-get-default-input-device-id) ;;; TEST OUT (setf *midi-out* (pm::pm-open-output 2 1024 0)) (pm::pm-write-short *midi-out* 0 (make-midi-bytes :keyoff 0 '(62 100))) (pm:pm-close *midi-out*) ;;; TEST IN (defparameter indev (pm::pm-open-input 0 256)) ; ignore active sensing etc. (pm::pm-set-filter indev pm::filt-realtime) ; check midi in (portmidi-Poll indev) (defparameter midi-buffer (pm::pm-EventBufferNew 32)) (defparameter num (portmidi-Read indev midi-buffer 32)) (PMEventBufferMap (lambda (a b) (print (list "time" b)) (print (list (message-status a) (message-data1 a) (message-data2 a))) (print "=====")) midi-buffer num) (pm:EventBufferFree midi-buffer) (pm::pm-close indev) ;;; recv testing (defparameter pitch 0) (loop while (/= pitch 60) do (let ((n (pm:Read indev buff 1))) (cond ((= n 1) (PMEventBufferMap (lambda (a b) b (pm a) (terpri) (setf pitch (pm:Message.data1 a))) buff n))))) ; fake ; (defparameter *in* (pm::pm-open-input 0 *portmidi-def-buffer-size*)) ; (defun get-input-stream-from-port (n) (values *in* "Oxygen 25")) (defparameter *test-midi-in* (portmidi-in-start 0 (lambda (message time) ;(print (list "time" time)) (print message) ;(portmidi-send-evt message) ) 1)) (portmidi-in-stop *test-midi-in* :wait t) |#
13,110
Common Lisp
.lisp
336
31.883929
124
0.553925
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
21bd0be5112eb68bfcecf7b3aeeb6893582550457da36e14354e34df052b05e8
791
[ -1 ]
792
portmidi.lisp
cac-t-u-s_om-sharp/src/packages/midi/midi-api/portmidi/portmidi.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;; ********************************************************************** ;;; Merging Rick Taube's CFFI-PORTMIDI and PortMedi's CL-PortMIDI code ;;; Copyright (c) 2014 Jean Bresson ;;; ********************************************************************** ;;; CL-PortMIDI from PortMedia ;;; Copyright (C) 2012 Christoph Finkensiep ;;; ********************************************************************** ;;; CFFI-PortMidi binding from PortMIDI distribution ;;; Copyright (C) 2005 Heinrich Taube, <taube (at) uiuc (dot) edu> ;;; ********************************************************************** ;;; ********************************************************************** ;;; This program is free software; you can redistribute it and/or ;;; modify it under the terms of the Lisp Lesser Gnu Public License. ;;; See http://www.cliki.net/LLGPL for the text of this agreement. ;;; ********************************************************************** (in-package :cl-user) (defpackage :portmidi (:use :common-lisp) (:nicknames :pm)) (in-package :pm) ;;;================ ;;; CONSTANTS ;;;================ (defconstant true 1) (defconstant false 0) (defconstant pmNoError 0) (defconstant pmHostError -10000) (defconstant pm-no-device -1) (defconstant pm-default-sysex-buffer-size 1024) (defvar *host-error-text* (make-string 256 :initial-element #\*)) ;;;================ ;;; TYPES ;;;================ (cffi:defctype pm-error :int) (cffi:defctype pm-stream :void) (cffi:defctype pm-time-proc-ptr :pointer) ;;; DEVICES (cffi:defctype pm-device-id :int) (cffi:defcstruct pm-device-info (struct-version :int) (interf :pointer) (name :pointer) (input :int) (output :int) (opened :int)) (defun pm-device-info-interf (ptr) (or (ignore-errors (cffi:foreign-string-to-lisp (cffi:foreign-slot-value ptr 'pm-device-info 'interf))) "Error reading interface name")) (defun pm-device-info-name (ptr) (or (ignore-errors (cffi:foreign-string-to-lisp (cffi:foreign-slot-value ptr 'pm-device-info 'name))) "Error reading device name")) (defun pm-device-info-input (ptr) (not (= (cffi:foreign-slot-value ptr 'pm-device-info 'input) 0))) (defun pm-device-info-output (ptr) (not (= (cffi:foreign-slot-value ptr 'pm-device-info 'output) 0))) (defun pm-device-info-opened (ptr) (not (= (cffi:foreign-slot-value ptr 'pm-device-info 'opened) 0))) ;;; MIDI EVENTS (cffi:defctype pm-message :long) (cffi:defctype pm-timestamp :long) #| (defun Message (status data1 data2) ;; portmidi messages are just unsigneds (logior (logand (ash data2 16) #xFF0000) (logand (ash data1 08) #xFF00) (logand status #xFF))) (defun Message.status (m) (logand m #xFF)) (defun Message.data1 (m) (logand (ash m -08) #xFF)) (defun Message.data2 (m) (logand (ash m -16) #xFF)) |# (cffi:defcstruct pm-event (message pm-message) (timestamp pm-timestamp)) ;;; accessors (defun Event.message (e &optional (v nil vp)) (if vp (progn (setf (cffi:foreign-slot-value e 'pm-event 'message) v) v) (cffi:foreign-slot-value e 'pm-event 'message))) (defun Event.timestamp (e &optional (v nil vp)) (if vp (progn (setf (cffi:foreign-slot-value e 'pm-event 'timestamp) v) v) (cffi:foreign-slot-value e 'pm-event 'timestamp))) ;;; EVENT BUFFERS (defun pm-EventBufferNew (len) (cffi:foreign-alloc 'pm-event :count len)) (defun pm-EventBufferFree (buf) (cffi:foreign-free buf)) (defun pm-EventBufferElt (buf i) ;; buf is POINTER to buf (cffi:mem-aref buf 'pm-event i)) (defun pm-EventBufferSet (buffer index timestamp message) (setf (cffi:foreign-slot-value (cffi:mem-aref buffer 'pm-event index) 'pm-event 'timestamp) timestamp) (setf (cffi:foreign-slot-value (cffi:mem-aref buffer 'pm-event index) 'pm-event 'message) message) (values)) ;;; EX. use buffers ;(let ((buff (pm::pm-EventBufferNew 8))) ; (loop for i below 8 for x = (pm:EventBufferElt buff i) do ; (pm::Event.message x (pm:message #b1001000 (+ 60 i) (+ 100 i))) ; (pm::Event.timestamp x (* 1000 i))) ; (loop for i below 8 for x = (pm:EventBufferElt buff i) ; ;; check buffer contents ; collect (list (pm:Event.timestamp x) ; (pm:Message.data1 (pm:Event.message x)) ; (pm:Message.data2 (pm:Event.message x)))) ; (pm:EventBufferFree buff)) ;;;========================== ;;; PORTTIME ;;;========================== ;;; porttime.h (cffi:defctype pt-error :int) (cffi:defctype pt-timestamp :long) (cffi:defcfun ("Pt_Start" pt-start) pt-error (a :int) (b :pointer) (c :pointer)) (cffi:defcfun ("Pt_Stop" pt-stop) pt-error) (cffi:defcfun ("Pt_Started" pt-started) :int) (cffi:defcfun ("Pt_Time" pt-time) pt-timestamp) ;;;================ ;;; FUNCTIONS ;;;================ ;;; INIT / CLOSE (cffi:defcfun ("Pm_Initialize" pm-initialize) pm-error) (cffi:defcfun ("Pm_Terminate" pm-terminate) pm-error) ; (pm-initialize) ; (pm-terminate) ;;; ERRORS (cffi:defcfun ("Pm_HasHostError" pm-has-host-error) :int (stream :pointer)) (cffi:defcfun ("Pm_GetErrorText" pm-get-error-text-STR) :pointer (errnum pm-error)) (defun pm-get-error-text (errnum) (cffi:foreign-string-to-lisp (pm-get-error-text-STR errnum))) (cffi:defcfun ("Pm_GetHostErrorText" pm-get-host-error-text-STR) :void (msg :pointer) (len :unsigned-int)) (defun pm-get-host-error-text () (cffi:with-foreign-string (host-error *host-error-text*) (pm-get-host-error-text-STR host-error (length *host-error-text*)) (cffi:foreign-string-to-lisp host-error))) ;;; DEVICES (cffi:defcfun ("Pm_CountDevices" pm-count-devices) :int) (cffi:defcfun ("Pm_GetDeviceInfo" pm-get-device-info-PTR) :pointer (id pm-device-id)) ; (cffi:foreign-slot-value ptr 'pm-device-info 'name) (defun pm-get-device-info (device-id) (let* ((ptr (pm-get-device-info-PTR device-id)) (interf (pm-device-info-interf ptr)) (name (pm-device-info-name ptr)) (in (pm-device-info-input ptr)) (out (pm-device-info-output ptr)) (open (pm-device-info-opened ptr))) (values interf name in out open)) ) ;;; this has to do with a preference stored in ;;; /Users/$NAME/Library/Preferences/com.apple.java.util.prefs.plist ;;; -1 = no device (cffi:defcfun ("Pm_GetDefaultOutputDeviceID" pm-get-default-output-device-id) pm-device-id) ;;; -1 = no device (cffi:defcfun ("Pm_GetDefaultInputDeviceID" pm-get-default-input-device-id) pm-device-id) ;;; OPEN/CLOSE PORTS ;;; We could use our lisp timer instead of internal PortTime process (cffi:defcfun ("Pm_OpenOutput" pm-open-output-PTR) pm-error (stream :pointer) (output-device pm-device-id) (output-driver-info :pointer) (buffer-size :long) (time-proc pm-time-proc-ptr) (time-info :pointer) (latency :long)) (cffi:defcfun ("Pm_OpenInput" pm-open-input-PTR) pm-error (stream :pointer) (input-device pm-device-id) (input-driver-info :pointer) (buffer-size :long) (time-proc pm-time-proc-ptr) (time-info :pointer)) ;(setf ptr (cffi::foreign-alloc :pointer)) ;(pm-open-output-PTR ptr 1 (cffi:null-pointer) 512 (cffi:null-pointer) (cffi:null-pointer) 0) ;(pm::pm-open-output 1 512 512) (defun pm-open-output (device buffer-size latency) ;;; (unless (Started) (Start)) (cffi:with-foreign-object (p1 :pointer) (let ((err (pm-open-output-PTR p1 device (cffi:null-pointer) buffer-size (cffi:null-pointer) (cffi:null-pointer) latency))) (if (= err pmNoError) (cffi:mem-ref p1 :pointer) (error (pm-get-error-text err)))))) (defun pm-open-input (device buffer-size) ;; portmidi: timer must be running before opening ;(unless (Started) (Start)) (cffi:with-foreign-object (p1 :pointer) (let ((err (pm-open-input-PTR p1 device (cffi:null-pointer) buffer-size (cffi:null-pointer) (cffi:null-pointer) ))) (if (= err pmNoError) (cffi:mem-ref p1 :pointer) (error (pm-get-error-text err)))))) ;;; synchronizes stream with the clock. (cffi::defcfun ("Pm_Synchronize" pm-synchronize) pm-error (stream :pointer)) (cffi:defcfun ("Pm_Close" pm-close) pm-error (stream :pointer)) ;; Terminates outgoing messages on stream. ;; pm-close should be called immediately after (cffi:defcfun ("Pm_Abort" pm-abort) pm-error (stream :pointer)) ;;; SEND (cffi:defcfun ("Pm_Write" pm-write) pm-error (stream :pointer) (buffer :pointer) (length :long)) (cffi:defcfun ("Pm_WriteShort" pm-write-short) pm-error (stream :pointer) (timetag pm-timestamp) (msg :long)) (cffi:defcfun ("Pm_WriteSysEx" pm-write-sys-ex-PTR) pm-error (stream :pointer) (timetag pm-timestamp) (msg :pointer)) (defun pm-write-sys-ex (stream timetag string) (cffi:with-foreign-string (ptr string) (pm-write-sys-ex-PTR stream timetag ptr))) ;;; RECEIVE (cffi:defcfun ("Pm_Poll" pm-poll) pm-error (stream :pointer)) (cffi:defcfun ("Pm_Read" pm-read) pm-error (stream :pointer) (buffer :pointer) (length :long)) ;;; select MIDI channels (cffi:defcfun ("Pm_SetChannelMask" pm-set-channel-mask) pm-error (stream :pointer) (mask :int)) ;;; filtering MIDI IN IN (cffi:defcfun ("Pm_SetFilter" pm-set-filter) pm-error (stream :pointer) (filters :long)) (defconstant filt-active 1) (defconstant filt-sysex 2) (defconstant filt-clock 4) (defconstant filt-play 8) (defconstant filt-f9 16) (defconstant filt-fd 32) (defconstant filt-reset 64) (defconstant filt-note 128) (defconstant filt-channel-aftertouch 256) (defconstant filt-poly-aftertouch 512) (defconstant filt-program 1024) (defconstant filt-control 2048) (defconstant filt-pitchbend 4096) (defconstant filt-mtc 8192) (defconstant filt-song-position 16384) (defconstant filt-song-select 32768) (defconstant filt-tune 65536) (defconstant filt-tick filt-f9) (defconstant filt-undefined (logior filt-f9 filt-fd)) (defconstant filt-realtime (logior filt-active filt-sysex filt-clock filt-play filt-undefined filt-reset)) (defconstant filt-aftertouch (logior filt-channel-aftertouch filt-poly-aftertouch )) (defconstant filt-systemcommon (logior filt-mtc filt-song-position filt-song-select filt-tune))
11,086
Common Lisp
.lisp
271
37.487085
106
0.638576
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
49e401e01475387e8208bba328dfebaba2248677eaa0ba8bbb2fcdc3af16f8cc
792
[ -1 ]
793
space.lisp
cac-t-u-s_om-sharp/src/packages/space/space.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;(require-om-package "sound") ;;; OpenGL interface (from LispWorks) (load (merge-pathnames "OpenGL/lw-opengl/load" *load-pathname*)) ;;; Mid-level OM-OpenGL interface: (compile&load (om-relative-path '("OpenGL") "gl-user")) (compile&load (om-relative-path '("OpenGL") "om-opengl-view")) (compile&load (om-relative-path '("OpenGL") "om-3d-object")) ;;; Require no OpenGL (compile&load (om-relative-path '("3D") "3dc")) (compile&load (om-relative-path '("3D") "3d-tools")) (compile&load (om-relative-path '("3D") "3d-functions")) (compile&load (om-relative-path '("utils") "background-elements")) (compile&load (om-relative-path '("utils") "osc-manager")) ;;; Require OpenGL interface (compile&load (om-relative-path '("3D") "3d-model")) (compile&load (om-relative-path '("3D") "3dc-editor")) (omNG-make-package "3D" :container-pack *om-package-tree* :classes '(3DC) :functions '(3D-sample 3D-interpol) :subpackages (list (omNG-make-package "3D-model" :classes '(3D-model 3D-cube 3D-sphere 3D-lines) :functions '(get-transformed-data)) (omNG-make-package "Conversions" :functions '(xyz->aed aed->xyz)) (omNG-make-package "Background Elements" :classes '(speaker project-room)))) (omNG-make-package "Conversions" :container-pack (get-subpackage *om-package-tree* "Basic Tools") :functions '(car->pol pol->car xy->ad ad->xy))
2,253
Common Lisp
.lisp
51
39.764706
77
0.576835
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
29fd8d0c78aefa86623df6b3af552d26e210a6cd9b836d047ac7242afd010a19
793
[ -1 ]
794
osc-manager.lisp
cac-t-u-s_om-sharp/src/packages/space/utils/osc-manager.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Garcia ;============================================================================ (in-package :om) (defclass osc-curvce-input-manager () ((editor :accessor editor :initform editor :initarg :editor) (port :accessor port :initform 6666) (active-p :accessor active-p :initform nil) (process :accessor process :initform nil) (window :accessor window :initform nil) (cursor-position :accessor cursor-position :initform '(0 0 0)) (cursor-status :accessor cursor-status :initform nil) (dist-threshold :accessor dist-threshold :initform 0.1) (last-osc-point :accessor last-osc-point :initform nil) (osc-first-time :accessor osc-first-time :initform nil)) ) (defmethod osc-manager-restart ((self osc-curvce-input-manager)) (when (active-p self) (osc-manager-stop-receive self) (osc-manager-start-receive self))) (defmethod osc-manager-start-receive ((self osc-curvce-input-manager)) (osc-manager-stop-receive self) ;; just in case (let ((port (port self))) (if (and port (numberp port)) (progn (print (format nil "3DC-OSC-RECEIVE START on port ~D" port)) (setf (active-p self) t) (setf (process self) (om-start-udp-server port "localhost" #'(lambda (msg) (let* ((message (osc-decode msg))) (osc-manager-process-message self message) ) nil))) (update-to-editor (editor self) self)) (om-beep-msg (format nil "error - bad port number for OSC-RECEIVE: ~A" port)) ))) (defmethod osc-manager-stop-receive ((self osc-curvce-input-manager)) (when (process self) (om-stop-udp-server (process self)) (om-print (format nil "RECEIVE STOP: ~A" (om-process-name (process self))) "UDP")) (setf (process self) nil) (setf (active-p self) nil) (update-to-editor (editor self) self)) (defmethod open-osc-manager ((self osc-curvce-input-manager)) (if (and (window self) (om-window-open-p (window self))) (om-select-window (window self)) (setf (window self) (om-make-window 'om-window :title "3DC Editor - OSC manager" :size (om-make-point 300 nil) :subviews (list (om-make-layout 'om-column-layout :subviews (list (om-make-di 'om-simple-text :size (omp 400 70) :font (om-def-font :gui) :text (format nil "Send OSC Messages to edit 2D/3D objects:~%- /3dc/clear resets the current object.~%- /3dc/move x y z displays the current position.~%- /3dc/add x y z time appends a new point.") ) ;;; (if the distance with the previous one is lesser than the distance treshold) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "OSC port:" :size (omp 150 20) :font (om-def-font :gui) ) (om-make-graphic-object 'numbox :value (port self) :size (omp 40 18) :bg-color (om-def-color :white) :font (om-def-font :normal) :db-click t :min-val 0 :after-fun #'(lambda (numbox) (setf (port self) (value numbox)) (osc-manager-restart self))) nil (om-make-di 'om-check-box :text "Start/Stop OSC" :font (om-def-font :gui) :checked-p (active-p self) :size (omp 150 20) :di-action #'(lambda (item) (if (om-checked-p item) (osc-manager-start-receive self) (osc-manager-stop-receive self) ))) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "Distance treshold:" :font (om-def-font :gui) :size (omp 150 30)) (om-make-graphic-object 'numbox :value (dist-threshold self) :min-val 0.0 :size (omp 40 18) :font (om-def-font :normal) :db-click 1 :bg-color (om-def-color :white) :after-fun #'(lambda (numbox) (setf (dist-threshold self) (value numbox))))) )))) )))) (defmethod close-osc-manager ((self osc-curvce-input-manager)) (osc-manager-stop-receive self) (when (window self) (om-close-window (window self)) (setf (window self) nil))) (defvar *3dc_osc_state* nil) (defmethod osc-manager-clear-callback ((editor t)) nil) (defmethod osc-manager-add-callback ((editor t) point) nil) (defmethod osc-manager-move-callback ((editor t)) nil) (defmethod osc-manager-process-message ((self osc-curvce-input-manager) message) (let ((address (car message)) (content (cdr message))) (cond ((string-equal address "/3dc/clear") (setf (last-osc-point self) nil) (setf (osc-first-time self) nil) (osc-manager-clear-callback (editor self))) ((string-equal address "/3dc/add") (unless *3dc_osc_state* (setf *3dc_osc_state* t)) (setf (cursor-status self) t) (setf (cursor-position self) content) (unless (osc-first-time self) (setf (osc-first-time self) (or (cadddr content) 0))) (let ((point (make-3dpoint :x (car content) :y (cadr content) :z (caddr content) :time (- (cadddr content) (osc-first-time self))))) (when (or (not (last-osc-point self)) (>= (om-points-distance (last-osc-point self) point) (dist-threshold self))) (setf (last-osc-point self) point) (osc-manager-add-callback (editor self) point) ))) ((equal address "/3dc/move") (when *3dc_osc_state* (osc-manager-move-callback (editor self)) (setf *3dc_osc_state* nil)) (setf (cursor-status self) nil) (setf (cursor-position self) content) )) ))
7,658
Common Lisp
.lisp
158
33.531646
222
0.491718
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
52bc8c38387065f6a1148c3c6ed7b3b0232d41ff13f8d74b628806d9d1a9b7d6
794
[ -1 ]
795
background-elements.lisp
cac-t-u-s_om-sharp/src/packages/space/utils/background-elements.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defclass speaker (background-element) ((pos :accessor pos :initarg :pos :initform nil) (size :accessor size :initarg :size :initform 1))) (defmethod initialize-instance :after ((self speaker) &rest args) (let ((pos (slot-value self 'pos))) (when (listp pos) (setf (slot-value self 'pos) (make-3dpoint :x (car pos) :y (cadr pos) :z (or (caddr pos) 0)))) self)) (defun make-bg-speakers (speakers) (let* ((max-xy-extent (loop for spk in speakers minimize (car spk) into minx maximize (car spk) into maxx minimize (cadr spk) into miny maximize (cadr spk) into maxy when (caddr spk) minimize (caddr spk) into minz when (caddr spk) maximize (caddr spk) into maxz finally (return (max (abs (- maxx minx)) (abs (- maxy miny)) (abs (- minz maxz)))))) (speaker-size (* .005 max-xy-extent))) (loop for spk in speakers collect (make-instance 'speaker :pos (make-3dpoint :x (car spk) :y (cadr spk) :z (or (caddr spk) 0)) :size speaker-size)) )) (defmethod draw-background-element ((self speaker) (view bpf-bpc-panel) editor &optional x1 y1 x2 y2) (om-draw-rect (x-to-pix view (- (editor-point-x editor (pos self)) (* (size self) .5))) (y-to-pix view (- (editor-point-y editor (pos self)) (* (size self) .5))) (max (dx-to-dpix view (size self)) 10) (min (dy-to-dpix view (size self)) -10) :color (om-def-color :light-gray) :fill t) (om-draw-rect (x-to-pix view (- (editor-point-x editor (pos self)) (* (size self) .5))) (y-to-pix view (- (editor-point-y editor (pos self)) (* (size self) .5))) (max (dx-to-dpix view (size self)) 10) (min (dy-to-dpix view (size self)) -10) :line 2 :style :dash :color (om-def-color :gray) :fill nil)) (defmethod make-3D-background-element ((self speaker)) (make-instance '3d-cube :size (size self) :center (list (om-point-x (pos self)) (om-point-y (pos self)) (om-point-z (pos self))) :color (om-def-color :gray))) ;;;============================================================= (defclass project-room (background-element) ((center :accessor center :initarg :center :initform (make-3dpoint :x 0 :y 0 :z 0)) (width :accessor width :initarg :width :initform 1) (depth :accessor depth :initarg :depth :initform 1) (height :accessor height :initarg :height :initform 1) (show-floor :accessor show-floor :initarg :show-floor :initform nil))) (defun make-bg-room (width depth height) (let ((room (make-instance 'project-room :width width :depth depth :height height :show-floor t))) (setf (center room) (make-3dpoint :x 0 :y 0 :z (* height 0.5))) room)) (defmethod draw-background-element ((self project-room) (view bpf-bpc-panel) editor &optional x1 y1 x2 y2) (let ((size-point (make-3dpoint :x (width self) :y (depth self) :z (height self)))) (om-draw-rect (x-to-pix view (- (editor-point-x editor (center self)) (* (editor-point-x editor size-point) .5))) (y-to-pix view (- (editor-point-y editor (center self)) (* (editor-point-y editor size-point) .5))) (max (dx-to-dpix view (editor-point-x editor size-point)) 10) (min (dy-to-dpix view (editor-point-y editor size-point)) -10) :line 2 :style :dash :color (om-def-color :dark-red) :fill nil) )) (defmethod make-3D-background-element ((self project-room)) (make-instance '3d-cube :size (list (width self) (depth self) (height self)) :center (list (om-point-x (center self)) (om-point-y (center self)) (om-point-z (center self))) :color (om-def-color :gray) :filled nil))
4,817
Common Lisp
.lisp
83
48.373494
117
0.549194
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
a49121b28c4eae7033f20ab762900b2bcc4748a0eb134a09a8a429b65ea16438
795
[ -1 ]
796
3dc.lisp
cac-t-u-s_om-sharp/src/packages/space/3D/3dc.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defstruct (3dpoint (:include tpoint)) (z 0)) (defun om-make-3dpoint (x y z &optional time type) (make-3Dpoint :x x :y y :z z :time time :internal-time time :type type)) (defmethod om-point-z ((self 3Dpoint)) (3dpoint-z self)) (defmethod om-point-z ((self t)) 0) (defmethod om-point-p ((self 3dpoint)) t) (defmethod om-copy ((self 3dpoint)) (make-3Dpoint :x (3Dpoint-x self) :y (3Dpoint-y self) :z (3Dpoint-z self) :time (3Dpoint-time self) :internal-time (3Dpoint-internal-time self) :type (3Dpoint-type self))) (defmethod omng-save ((self 3dpoint)) `(:3Dpoint ,(om-point-x self) ,(om-point-y self) ,(om-point-z self))) (defmethod om-load-from-id ((id (eql :3Dpoint)) data) (apply 'om-make-3dpoint data)) (defmethod om-point-set ((point 3dpoint) &key x y z time type) (if x (setf (3dpoint-x point) x)) (if y (setf (3dpoint-y point) y)) (if z (setf (3dpoint-z point) z)) (if time (progn (setf (3dpoint-time point) time) (setf (3dpoint-internal-time point) time))) (if type (setf (3dpoint-type point) type)) point) (defmethod om-point-set-values-from-point ((point 3Dpoint) (target 3Dpoint)) (setf (3dpoint-x point) (3dpoint-x target) (3dpoint-y point) (3dpoint-y target) (3dpoint-z point) (3dpoint-z target) (3dpoint-time point) (3dpoint-time target) (3dpoint-internal-time point) (3dpoint-internal-time target) (3dpoint-type point) (3dpoint-type target)) point) (defmethod om-points-equal-p ((point1 3dpoint) (point2 3dpoint)) (and (= (3Dpoint-x point1) (3Dpoint-x point2)) (= (3Dpoint-y point1) (3Dpoint-y point2)) (= (3Dpoint-z point1) (3Dpoint-z point2)) (= (3Dpoint-time point1) (3Dpoint-time point2)))) ;;; not necessarily at the same time ! (defmethod om-points-at-same-position ((p1 3dpoint) (p2 3dpoint)) (and (= (3Dpoint-x p1) (3Dpoint-x p2)) (= (3Dpoint-y p1) (3Dpoint-y p2)) (= (3Dpoint-z p1) (3Dpoint-z p2)))) (defmethod om-add-points ((p1 3dpoint) p2) (make-3dpoint :x (+ (3Dpoint-x p1) (om-point-x p2) :y (+ (3Dpoint-y p1) (om-point-y p2)) :z (+ (3Dpoint-z p1) (om-point-z p2))))) (defmethod om-add-points (p1 (p2 3dpoint)) (make-3dpoint :x (+ (om-point-x p1) (om-point-x p2) :y (+ (om-point-y p1) (om-point-y p2)) :z (+ (om-point-z p1) (om-point-z p2))))) (defmethod om-subtract-points ((p1 3dpoint) p2) (make-3dpoint :x (- (om-point-x p1) (om-point-x p2) :y (- (om-point-y p1) (om-point-y p2)) :z (- (om-point-z p1) (om-point-z p2))))) (defmethod om-subtract-points (p1 (p2 3dpoint)) (make-3dpoint :x (- (om-point-x p1) (om-point-x p2) :y (- (om-point-y p1) (om-point-y p2)) :z (- (om-point-z p1) (om-point-z p2))))) (defmethod om-point-* ((point 3dpoint) fact) (make-3dpoint :x (* (3Dpoint-x point) fact) :y (* (3Dpoint-y point) fact) :z (* (3Dpoint-z point) fact))) (defmethod om-points-distance ((p1 3Dpoint) (p2 3Dpoint)) (sqrt (+ (expt (- (3Dpoint-x p2) (3Dpoint-x p1)) 2) (expt (- (3Dpoint-y p2) (3Dpoint-y p1)) 2) (expt (- (3Dpoint-z p2) (3Dpoint-z p1)) 2)))) (defmethod om-point-mv ((point 3Dpoint) &key x y z time) (if x (setf (3Dpoint-x point) (+ (3Dpoint-x point) x))) (if y (setf (3Dpoint-y point) (+ (3Dpoint-y point) y))) (if z (setf (3Dpoint-z point) (+ (3Dpoint-z point) z))) (if time (progn (setf (tpoint-time point) (+ (tpoint-time point) time)) (setf (tpoint-internal-time point) (tpoint-time point)))) point) (defclass* 3DC (BPC) ((x-points :initform nil :initarg :x-points :documentation "X coordinates (list)") (y-points :initform nil :initarg :y-points :documentation "Y coordinates (list)") (z-points :initform nil :initarg :z-points :documentation "Z coordinates (list)")) (:documentation "3D Curve: a 3D path defined by a list of [x,y,z] coordinates. 3DC objects are constructed from the list of X coordinates (<x-points>), the list of Y coordinates (<y-points>) and the list of Z coordinates (<z-points>). If <x-list>, <y-list> and <z-list> are not of the same length, the last coordinate (for y and z) or the last step (for x) is repeated in the shorter lists. <decimals> specifies the precision of the function (0 = integers, n > 0 = number of decimals) " )) ;;; REDEFS FOR Z (defmethod z-values-from-points ((self 3DC)) (mapcar #'om-point-z (point-list self))) (defmethod z-points ((self 3DC)) (z-values-from-points self)) (defmethod (setf z-points) ((z-points t) (self 3DC)) (set-bpf-points self :z z-points) z-points) (defmethod (setf decimals) ((decimals t) (self 3DC)) (let ((x (x-values-from-points self)) (y (y-values-from-points self)) (z (z-values-from-points self))) (setf (slot-value self 'decimals) decimals) (check-decimals self) (set-bpf-points self :x x :y y :z z) (time-sequence-update-internal-times self) (decimals self))) (defmethod adapt-point ((self 3DC) point) (setf (3Dpoint-x point) (funcall (truncate-function (decimals self)) (3Dpoint-x point)) (3Dpoint-y point) (funcall (truncate-function (decimals self)) (3Dpoint-y point)) (3Dpoint-z point) (funcall (truncate-function (decimals self)) (3Dpoint-z point))) point) (defmethod init-bpf-points ((self 3DC)) (set-bpf-points self :x (slot-value self 'x-points) :y (slot-value self 'y-points) :z (slot-value self 'z-points) :time (slot-value self 'times) :time-types (slot-value self 'time-types)) (time-sequence-update-internal-times self) self) (defmethod set-bpf-points ((self 3DC) &key x y z time time-types) (let ((point-list (make-3D-points-from-lists (or x (x-values-from-points self)) (or y (y-values-from-points self)) (or z (z-values-from-points self)) (decimals self) 'om-make-3dpoint)) (times (or time (time-values-from-points self)))) (when times (if (listp times) (loop for p in point-list for time in times do (setf (3dpoint-time p) time)) (loop for p in point-list do (setf (3dpoint-time p) times)))) (when time-types (loop for p in point-list for type in time-types do (om-point-set p :type type))) (setf (point-list self) point-list) (setf (slot-value self 'x-points) NIL) (setf (slot-value self 'y-points) NIL) (setf (slot-value self 'z-points) NIL) (setf (slot-value self 'times) NIL) (setf (slot-value self 'time-types) NIL))) (defmethod duplicate-coordinates ((p1 3dpoint) (p2 3dpoint)) (and (= (3dpoint-x p1) (3dpoint-x p2)) (= (3dpoint-y p1) (3dpoint-y p2)) (= (3dpoint-z p1) (3dpoint-z p2)) (equal (3dpoint-time p1) (3dpoint-time p2)))) (defmethod make-3D-points-from-lists ((listx list) (listy list) (listz list) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (when (or listx listy listz) (if (and (list-subtypep listx 'number) (list-subtypep listy 'number) (list-subtypep listz 'number)) (let* ((listx (mapcar (truncate-function decimals) (or listx '(0)))) (listy (mapcar (truncate-function decimals) (or listy '(0)))) (listz (mapcar (truncate-function decimals) (or listz '(0)))) (defx (car (last listx))) (defy (car (last listy))) (defz (car (last listz)))) (loop for xpoin = (if listx (pop listx) 0) then (if listx (pop listx) defx) for ypoin = (if listy (pop listy) 0) then (if listy (pop listy) defy) for zpoin = (if listz (pop listz) 0) then (if listz (pop listz) defz) while (or listy listx listz) collect (funcall mkpoint xpoin ypoin zpoin) into rep finally (return (append rep (list (funcall mkpoint xpoin ypoin zpoin))))) ) (om-beep-msg "BUILD 3DC POINTS: input coordinates are not (all) numbers!") ))) ;;; 2 LISTS / 1 CONSTANT (3 POSSIBILITIES) (defmethod make-3D-points-from-lists ((pointx number) (listy list) (listz list) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (and (list-subtypep listy 'number) (list-subtypep listz 'number)) (let* ((pointx (funcall (truncate-function decimals) pointx)) (listy (mapcar (truncate-function decimals) (or listy '(0)))) (listz (mapcar (truncate-function decimals) (or listz '(0)))) (defy (car (last listy))) (defz (car (last listz)))) (loop for ypoin = (if listy (pop listy) 0) then (if listy (pop listy) defy) for zpoin = (if listz (pop listz) 0) then (if listz (pop listz) defz) while (or listy listz) collect (funcall mkpoint pointx ypoin zpoin) into rep finally (return (append rep (list (funcall mkpoint pointx ypoin zpoin)))))) (om-beep-msg "BUILD 3DC POINTS: Y/Z-coordinates are not (all) numbers!") )) (defmethod make-3D-points-from-lists ((listx list) (pointy number) (listz list) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (and (list-subtypep listx 'number) (list-subtypep listz 'number)) (let* ((pointy (funcall (truncate-function decimals) pointy)) (listx (mapcar (truncate-function decimals) (or listx '(0)))) (listz (mapcar (truncate-function decimals) (or listz '(0)))) (defx (car (last listx))) (defz (car (last listz)))) (loop for xpoin = (if listx (pop listx) 0) then (if listx (pop listx) defx) for zpoin = (if listz (pop listz) 0) then (if listz (pop listz) defz) while (or listx listz) collect (funcall mkpoint xpoin pointy zpoin) into rep finally (return (append rep (list (funcall mkpoint xpoin pointy zpoin)))))) (om-beep-msg "BUILD 3DC POINTS: X/Z-coordinates are not (all) numbers!") )) (defmethod make-3D-points-from-lists ((listx list) (listy list) (pointz number) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (and (list-subtypep listx 'number) (list-subtypep listy 'number)) (let* ((pointz (funcall (truncate-function decimals) pointz)) (listx (mapcar (truncate-function decimals) (or listx '(0)))) (listy (mapcar (truncate-function decimals) (or listy '(0)))) (defx (car (last listx))) (defy (car (last listy)))) (loop for xpoin = (if listx (pop listx) 0) then (if listx (pop listx) defx) for ypoin = (if listy (pop listy) 0) then (if listy (pop listy) defy) while (or listx listy) collect (funcall mkpoint xpoin ypoin pointz) into rep finally (return (append rep (list (funcall mkpoint xpoin ypoin pointz)))))) (om-beep-msg "BUILD 3DC POINTS: X/Z-coordinates are not (all) numbers!") )) ;;; 2 CONSTANTS / 1 LIST (3 POSSIBILITIES) (defmethod make-3D-points-from-lists ((listx list) (pointy number) (pointz number) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (list-subtypep listx 'number) (let* ((tf (truncate-function decimals)) (pointy (funcall tf pointy)) (pointz (funcall tf pointz))) (loop for xpoin in listx collect (funcall mkpoint (funcall tf xpoin) pointy pointz))) (om-beep-msg "BUILD 3DC POINTS: X-coordinates are not (all) numbers!") )) (defmethod make-3D-points-from-lists ((pointx number) (listy list) (pointz number) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (list-subtypep listy 'number) (let* ((tf (truncate-function decimals)) (pointx (funcall tf pointx)) (pointz (funcall tf pointz))) (loop for ypoin in listy collect (funcall mkpoint pointx (funcall tf ypoin) pointz))) (om-beep-msg "BUILD 3DC POINTS: Y-coordinates are not (all) numbers!") )) (defmethod make-3D-points-from-lists ((pointx number) (pointy number) (listz list) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (if (list-subtypep listz 'number) (let* ((tf (truncate-function decimals)) (pointx (funcall tf pointx)) (pointy (funcall tf pointy))) (loop for zpoin in listz collect (funcall mkpoint pointx pointy (funcall tf zpoin)))) (om-beep-msg "BUILD 3DC POINTS: Z-coordinates are not (all) numbers!") )) ;;; 3 CONSTANTS (defmethod make-3D-points-from-lists ((pointx number) (pointy number) (pointz number) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (list (funcall mkpoint pointx pointy pointz))) (defmethod make-3D-points-from-lists ((pointx t) (pointy t) (pointz t) &optional (decimals 0) (mkpoint 'om-make-3dpoint)) (print pointx) (print pointy) (print pointz) (om-beep-msg "BUILD 3DC POINTS: Wrong coordinate lists!")) ;;; need to convert the points between the different subtypes of BPF (defmethod objfromobjs ((model bpf) (target bpf)) (let ((rep (call-next-method))) (init-bpf-points rep) rep)) ;;;========================== ;;;redefined timed objects methods ;;;========================== (defmethod make-default-tpoint-at-time ((self 3dc) time) ;this methods create a new point that preserves the motion of the object (if (times self) (let ((pos (or (position time (point-list self) :key 'tpoint-internal-time :test '<= ) (length (point-list self)))) (len (length (time-sequence-get-internal-times self)))) ;if length is 1 or if the point is before the others or after use the same position than the before or after point (if (or (= len 1) (or (= pos 0) (= pos len))) (let ((point (nth (min pos (1- len)) (point-list self)))) (om-make-3dpoint (om-point-x point) (om-point-y point) (3dpoint-z point) time)) ; if several points, preserve the motion (let ((p1 (nth (1- pos) (point-list self))) (p2 (nth pos (point-list self)))) (calc-intermediate-point-at-time p1 p2 time)))) ;if no points, create a points a pos (om-make-3dpoint 0 0 0 time))) (defmethod calc-intermediate-point-at-time ((p1 3dpoint) (p2 3dpoint) time) (let* ((dur (- (tpoint-internal-time p2) (tpoint-internal-time p1))) (factor (/ (- time (tpoint-internal-time p1)) dur)) (x (+ (* (- (tpoint-x p2) (tpoint-x p1)) factor) (tpoint-x p1))) (y (+ (* (- (tpoint-y p2) (tpoint-y p1)) factor) (tpoint-y p1))) (z (+ (* (- (3dpoint-z p2) (3dpoint-z p1)) factor) (3dpoint-z p1)))) (om-make-3Dpoint x y z time))) ;-------------------get the min max points in x and y axis------------------------------ ;;; using reduce 'mix/max is fatser when interpreted but not when compiled (defmethod nice-bpf-range ((self 3dc)) (multiple-value-bind (x1 x2 y1 y2 z1 z2 t1 t2) (loop for x in (x-values-from-points self) for y in (y-values-from-points self) for z in (z-values-from-points self) for time in (time-sequence-get-internal-times self) minimize x into x1 maximize x into x2 minimize y into y1 maximize y into y2 minimize z into z1 maximize z into z2 minimize time into t1 maximize time into t2 finally (return (values x1 x2 y1 y2 z1 z2 t1 t2))) (append (list x1 x2) (list y1 y2) (list z1 z2) (list t1 t2)) ; (if (< (- x2 x1) 10) (list (- x1 5) (+ x2 5)) (list x1 x2)) ; (if (< (- y2 y1) 10) (list (- y1 5) (+ y2 5)) (list y1 y2))) )) ;;; to be redefined by objects if they have a specific miniview for the sequencer (defmethod draw-sequencer-mini-view ((self 3dc) (box t) x y w h &optional time) (let* ((x-col (om-def-color :red)) (y-col (om-def-color :green)) (z-col (om-def-color :blue)) (ranges (nice-bpf-range self)) (times (time-sequence-get-internal-times self)) (x-t-list (mat-trans (list times (x-points self)))) (x-t-ranges (list 0 (nth 7 ranges) (car ranges) (cadr ranges))) (y-t-list (mat-trans (list times (y-points self)))) (y-t-ranges (list 0 (nth 7 ranges) (caddr ranges) (cadddr ranges))) (z-t-list (mat-trans (list times (z-points self)))) (z-t-ranges (list 0 (nth 7 ranges) (nth 5 ranges) (nth 6 ranges)))) ;draw x = f(t) (draw-bpf-points-in-rect x-t-list x-col x-t-ranges ;(+ x 7) (+ y 10) (- w 14) (- h 20) x (+ y 10) w (- h 20) ) ;draw y = f(t) (draw-bpf-points-in-rect y-t-list y-col y-t-ranges ;(+ x 7) (+ y 10) (- w 14) (- h 20) x (+ y 10) w (- h 20) ) ;draw z = f(t) (draw-bpf-points-in-rect z-t-list z-col z-t-ranges ;(+ x 7) (+ y 10) (- w 14) (- h 20) x (+ y 10) w (- h 20) ) t)) ;;;============================ ;;; SPECIALIZATIONS ;;;============================ (defmethod* point-pairs ((self 3dc)) :initvals '(nil) :indoc '("a 3dc") :doc "Retruns the list of points in <self> as a list ((x1 y1 z1 t1) (x2 y2 z2 t2) ...)" (mat-trans (list (x-points self) (y-points self) (z-points self) (time-sequence-get-internal-times self)))) (defmethod timed-point-pairs ((self 3DC)) (let ((times (times self))) (when (position nil times) (setf times (time-sequence-get-internal-times self))) (mat-trans (list (x-points self) (y-points self) (z-points self) times)))) ;;; called (for instance) in save-as-text (defmethod write-data ((self 3DC) out) (loop for x in (x-points self) for y in (y-points self) for z in (z-points self) do (format out "~D ~D ~D~%" x y z))) (defmethod get-first-point ((self 3DC)) (car (timed-point-pairs self))) ;;;============================ ;;; PLAYER ;;;============================ (defmethod arguments-for-action ((fun (eql 'send-xyz-as-osc))) `((:string address "/point/xyz") (:string host ,(get-pref-value :osc :out-host)) (:int port ,(get-pref-value :osc :out-port)) (:int id 1) )) (defun send-xyz-as-osc (point &optional (address "/point/xyz") (host "localhost") (port 3000) (id 1)) (osc-send (list address id (om-point-x point) (om-point-y point) (om-point-z point)) host port)) (defmethod get-def-action-list ((object 3DC)) '(print send-xyz-as-osc))
19,858
Common Lisp
.lisp
373
44.592493
155
0.58548
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
d787e57557715fcddca94b38f65b823363e97cfccb0423b0cd80e8a6ab7810b1
796
[ -1 ]
797
3d-tools.lisp
cac-t-u-s_om-sharp/src/packages/space/3D/3d-tools.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: M. Schumacher ;============================================================================ (in-package :om) ;;; Euclidean-distances (defmethod xy-distance ((x number) (y number)) (sqrt (+ (* x x) (* y y)))) (defmethod xy-distance ((x list) (y list)) (mapcar 'xy-distance x y)) (defmethod xyz-distance ((x number) (y number) (z number)) (sqrt (+ (* x x) (* y y) (* z z)))) (defmethod xyz-distance ((x list) (y list) (z list)) (mapcar 'xyz-distance x y z)) ;;; PHASE-UNWRAP ;;; (ported from Matlab) (defmethod phase-unwrap ((degrees list)) "Output is the shortest polar distance from the last value (in degrees)." (let ((loopres (loop for a in (om- (mapcar #'(lambda (value) (mod value 360)) (om+ (x->dx degrees) 180)) 180) for b in (x->dx degrees) collect (if (and (om= a -180) (om> b 0)) 180 a) ))) (om+ degrees (dx->x 0 (om- loopres (x->dx degrees)))))) ;;; POL->CAR (defmethod* pol->car ((r number) (a number)) :icon :conversion :initvals '(0 0) :indoc '("radius (magnitude)" "angle (phase)") :numouts 2 :outdoc '("x" "y") :doc "Conversion from polar (radius <r>, angle <a>) to cartesian (x, y) coordinates. <r> and <a> can be numbers or lists." (values (* r (cos a)) (* r (sin a)))) (defmethod* pol->car ((r list) (a list)) (let ((tmplist (mat-trans (mapcar #'(lambda (rr aa) (multiple-value-list (pol->car rr aa))) r a)))) (values-list tmplist))) (defmethod* pol->car ((r list) (a number)) (let ((tmplist (mat-trans (mapcar #'(lambda (rr) (multiple-value-list (pol->car rr a))) r)))) (values-list tmplist))) (defmethod* pol->car ((r number) (a list)) (let ((tmplist (mat-trans (mapcar #'(lambda (aa) (multiple-value-list (pol->car r aa))) a)))) (values-list tmplist))) ;;; CAR->POL (defmethod* car->pol ((x number) (y number)) :icon :conversion :initvals '(0 0) :indoc '("x" "y") :numouts 2 :outdoc '("r" "a") :doc "Conversion from cartesian (x, y) to polar (radius, angle) coordinates. <x> and <y> can be numbers or lists." (values (sqrt (+ (* x x) (* y y ))) (atan y x))) (defmethod* car->pol ((x list) (y list)) (let ((tmplist (mat-trans (mapcar #'(lambda (xx yy) (multiple-value-list (car->pol xx yy))) x y)))) (values-list tmplist))) (defmethod* car->pol ((x list) (y number)) (let ((tmplist (mat-trans (mapcar #'(lambda (xx) (multiple-value-list (car->pol xx y))) x)))) (values-list tmplist))) (defmethod* car->pol ((x number) (y list)) (let ((tmplist (mat-trans (mapcar #'(lambda (yy) (multiple-value-list (car->pol x yy))) y)))) (values-list tmplist))) ;;; RAD->DEG (defmethod* rad->deg ((radians number)) :icon :conversion :indoc '("radians") :outdoc '("degrees") :doc "Converts radians to degree. <radians> can be a number or a list." ;(/ (* radians 180) pi) (* radians 57.29577951308232)) (defmethod* rad->deg ((radians list)) (mapcar 'rad->deg radians)) ;;; DEG->RAD (defmethod* deg->rad ((degrees number)) :icon :conversion :indoc '("degrees") :outdoc '("radians") :doc "Donverts degrees to radians. <degrees> can be a number or a list." ;(/ (* degrees pi) 180) (* degrees 0.017453292519943295)) (defmethod* deg->rad ((degrees list)) (mapcar 'deg->rad degrees)) ;;; XY->AD (defmethod* xy->ad ((x number) (y number)) :icon :conversion :initvals '(0 0) :indoc '("x" "y") :numouts 2 :outdoc '("azimuth" "distance") :doc "Converts 2D cartesian coordinates [x,y] to polar coordinates [azimuth, distance]. Navigational coordinate systems (see www.spatdif.org). <x> and <y> can be numbers, lists or bpfs. Returns 2 values (numbers, lists or bpfs) for 'azimuth' and 'distance'." (multiple-value-bind (distance azimuth) (car->pol x y) (values (- 90 (rad->deg azimuth)) distance) )) (defmethod* xy->ad ((x list) (y list)) (let ((result (mat-trans (loop for x1 in x for y1 in y collect (multiple-value-list (xy->ad x1 y1)))))) (values (phase-unwrap (first result)) (second result)))) (defmethod* xy->ad ((x number) (y list)) (xy->ad (make-list (length y) :initial-element x) y)) (defmethod* xy->ad ((x list) (y number)) (xy->ad x (make-list (length x) :initial-element y))) (defmethod* xy->ad ((x bpf) (y bpf)) (multiple-value-bind (a d) (xy->ad (y-points x) (y-points y)) (values (make-instance 'bpf :x-points (x-points x) :y-points a :decimals (decimals x)) (make-instance 'bpf :x-points (x-points y) :y-points d :decimals (decimals x)) ))) (defmethod* xy->ad ((x bpf) (y list)) (multiple-value-bind (a d) (xy->ad (y-points x) y) (values (make-instance 'bpf :x-points (x-points x) :y-points a :decimals (decimals x)) d)) ) (defmethod* xy->ad ((x bpf) (y number)) (multiple-value-bind (a d) (xy->ad (y-points x) y) (values (make-instance 'bpf :x-points (x-points x) :y-points a :decimals (decimals x)) d)) ) (defmethod* xy->ad ((x list) (y bpf)) (multiple-value-bind (a d) (xy->ad x (y-points y)) (values a (make-instance 'bpf :x-points (x-points y) :y-points d :decimals (decimals y)))) ) (defmethod* xy->ad ((x number) (y bpf)) (multiple-value-bind (a d) (xy->ad x (y-points y)) (values a (make-instance 'bpf :x-points (x-points y) :y-points d :decimals (decimals y)) ))) (defmethod* xy->ad ((self bpc) anything) (multiple-value-bind (a d) (xy->ad (x-points self) (y-points self)) (make-instance 'bpf :x-points a :y-points d :decimals (decimals self)) )) ;;; AD -> XY (defmethod* ad->xy ((a number) (d number)) :icon :conversion :initvals '(0 0) :indoc '("azimuth" "distance") :numouts 2 :outdoc '("x" "y") :doc "Converts 2D polar coordinates [azimuth, distance] to 2D cartesian coordinates [x,y]. Navigational coordinate systems (see www.spatdif.org). <a> and <d> can be numbers, lists or bpfs. Returns 2 values (numbers, lists or bpfs) for 'x' and 'y'." (multiple-value-bind (x y) (pol->car d (deg->rad (- 90 a))) (values x y))) (defmethod* ad->xy ((a list) (d list)) (let ((result (mat-trans (loop for a1 in a for d1 in d collect (multiple-value-list (ad->xy a1 d1)))))) (values-list result))) (defmethod* ad->xy ((a bpf) (d bpf)) (multiple-value-bind (x y) (ad->xy (y-points a) (y-points d)) (values (make-instance 'bpf :x-points (x-points a) :y-points x :decimals (decimals a)) (make-instance 'bpf :x-points (x-points d) :y-points y :decimals (decimals d))))) (defmethod* ad->xy ((a bpf) (d list)) (multiple-value-bind (x y) (ad->xy (y-points a) d) (values (make-instance 'bpf :x-points (x-points a) :y-points x :decimals (decimals a)) y)) ) (defmethod* ad->xy ((a bpf) (d number)) (multiple-value-bind (x y) (ad->xy (y-points a) d) (values (make-instance 'bpf :x-points (x-points a) :y-points x :decimals (decimals a)) y)) ) (defmethod* ad->xy ((a list) (d bpf)) (multiple-value-bind (x y) (ad->xy a (y-points d)) (values x (make-instance 'bpf :x-points (x-points d) :y-points y :decimals (decimals d)))) ) (defmethod* ad->xy ((a number) (d bpf)) (multiple-value-bind (x y) (ad->xy a (y-points d)) (values x (make-instance 'bpf :x-points (x-points d) :y-points y :decimals (decimals d)) )) ) (defmethod* ad->xy ((a number) (d list)) (ad->xy (make-list (length d) :initial-element a) d)) (defmethod* ad->xy ((a list) (d number)) (ad->xy a (make-list (length a) :initial-element d))) (defmethod* ad->xy ((self bpc) anything) (multiple-value-bind (x y) (ad->xy (x-points self) (y-points self)) (make-instance 'bpf :x-points x :y-points y :decimals (decimals self))) ) ;;; XYZ->AED (defmethod* xyz->aed ((x number) (y number) (z number)) :icon :conversion :initvals '(0 0 0) :indoc '("x" "y" "z") :numouts 3 :outdoc '("azimuth" "elevation" "distance") :doc "Converts 3D cartesian coordinates [x,y,z] to spherical coordinates [azimuth, elevation, distance]. Navigational coordinate systems (see www.spatdif.org). <x>, <y>, and <z> can be numbers or lists. Returns 3 values (or lists) for 'azimuth', 'elevation' and 'distance'." (multiple-value-bind (dist ang) (car->pol x y) (multiple-value-bind (distz angz) (car->pol dist z) (values (- 90 (rad->deg ang)) (rad->deg angz) distz) ))) (defmethod* xyz->aed ((x number) (y number) (z list)) (xyz->aed (make-list (length z) :initial-element x) (make-list (length z) :initial-element y) z)) (defmethod* xyz->aed ((x number) (y list) (z number)) (xyz->aed (make-list (length y) :initial-element x) y (make-list (length y) :initial-element z))) (defmethod* xyz->aed ((x number) (y list) (z list)) (xyz->aed (make-list (length y) :initial-element x) y z)) (defmethod* xyz->aed ((x list) (y list) (z list)) (let ((result (mat-trans (loop for x1 in x for y1 in y for z1 in z collect (multiple-value-list (xyz->aed x1 y1 z1)))))) (values (phase-unwrap (first result)) (phase-unwrap (second result)) (third result)))) (defmethod* xyz->aed ((x list) (y list) (z number)) (xyz->aed x y (make-list (length x) :initial-element z))) (defmethod* xyz->aed ((x list) (y number) (z list)) (xyz->aed x (make-list (length x) :initial-element y) z)) (defmethod* xyz->aed ((x list) (y number) (z number)) (xyz->aed x (make-list (length x) :initial-element y) (make-list (length x) :initial-element z))) ;;; AED -> XYZ (defmethod* aed->xyz ((a number) (e number) (d number)) :icon :conversion :initvals '(0 0 0) :indoc '("azimuth" "elevation" "distance") :numouts 3 :outdoc '("x" "y" "z") :doc "Converts 3D spherical coordinates [azimuth, elevation, distance] to cartesian coordinates [x,y,z]. Navigational coordinate systems (see www.spatdif.org). <a>, <e>, amd <d> can be numbers or lists. Returns 3 values (or lists) for 'x', 'y' and 'z'." (values (* d (sin (deg->rad (- 90 e))) (sin (deg->rad a))) (* d (sin (deg->rad (- 90 e))) (cos (deg->rad a))) (* d (cos (deg->rad (- 90 e)))))) (defmethod* aed->xyz ((a number) (e number) (d list)) (aed->xyz (make-list (length d) :initial-element a) (make-list (length d) :initial-element e) d)) (defmethod* aed->xyz ((a number) (e list) (d number)) (aed->xyz (make-list (length e) :initial-element a) e (make-list (length a) :initial-element d))) (defmethod* aed->xyz ((a number) (e list) (d list)) (aed->xyz (make-list (length e) :initial-element a) e d)) (defmethod* aed->xyz ((a list) (e list) (d list)) (let ((result (mat-trans (loop for a1 in a for e1 in e for d1 in d collect (multiple-value-list (aed->xyz a1 e1 d1)))))) (values-list result))) (defmethod* aed->xyz ((a list) (e list) (d number)) (aed->xyz a e (make-list (length a) :initial-element d))) (defmethod* aed->xyz ((a list) (e number) (d list)) (aed->xyz a (make-list (length a) :initial-element e) d)) (defmethod* aed->xyz ((a list) (e number) (d number)) (aed->xyz a (make-list (length a) :initial-element e) (make-list (length a) :initial-element d))) ;;; UTIL (defmethod* gen-circles (n r n-points) :initvals '(1 10 200) :numouts 2 (ad->xy (arithm-ser 0 (round (* n 360)) (/ (* n 360) n-points) n-points) r))
12,399
Common Lisp
.lisp
272
40.231618
161
0.591392
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
3cb570cf8f6c84849dc9bea03645ef4fa5b965d13962dea1f685e0e94fd0cd5b
797
[ -1 ]
798
3dc-editor.lisp
cac-t-u-s_om-sharp/src/packages/space/3D/3dc-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson, J. Garcia ;============================================================================ (in-package :om) (defclass 3DC-editor (multi-display-editor-mixin OMEditor multi-view-editor play-editor-mixin undoable-editor-mixin) ((top-bpc-editor :accessor top-bpc-editor :initform nil) (front-bpc-editor :accessor front-bpc-editor :initform nil) (3Dp :accessor 3Dp :initform nil) (timeline-editor :accessor timeline-editor :initform nil) (timeline-enabled :accessor timeline-enabled :initarg :timeline-enabled :initform t) (osc-manager :accessor osc-manager :initform nil) (color-options :accessor color-options :initarg :color-options :initform '(:single :indices :length :speed)) )) (defmethod object-default-edition-params ((self 3DC)) (append (call-next-method) `((:line-width 1) (:3D-bg-color ,(om-def-color :white))))) (defmethod object-has-editor ((self 3dc)) t) (defmethod get-editor-class ((self 3DC)) '3DC-editor) (defmethod init-editor ((self 3dc-editor)) (when (timeline-enabled self) (setf (timeline-editor self) (make-instance 'timeline-editor :object (object self) :container-editor self)) )) (defmethod make-3D-background-element ((self background-element)) nil) ;===== MultiDisplay API (defmethod enable-multi-display ((self 3dc-editor) obj-list) (call-next-method) (enable-multi-display (top-bpc-editor self) obj-list) (enable-multi-display (front-bpc-editor self) obj-list) (set-3D-objects self)) (defmethod disable-multi-display ((self 3dc-editor)) (call-next-method) (disable-multi-display (top-bpc-editor self)) (disable-multi-display (front-bpc-editor self)) (set-3D-objects self)) ;===== ;;; from play-editor-mixin (defmethod get-obj-to-play ((self 3dc-editor)) (object-value self)) (defmethod play-editor-callback ((self 3dc-editor) time) (om-invalidate-view (3dp self)) (when (top-bpc-editor self) (om-invalidate-view (get-g-component (top-bpc-editor self) :main-panel))) (when (front-bpc-editor self) (om-invalidate-view (get-g-component (front-bpc-editor self) :main-panel))) (call-next-method)) (defmethod cursor-panes ((self 3dc-editor)) (when (timeline-editor self) (cursor-panes (timeline-editor self)))) (defmethod set-time-display ((self 3dc-editor) time) (when (timeline-editor self) (set-time-display (timeline-editor self) time)) (call-next-method)) ;;;========================== ;;; SYSTEM CALLBACKS ;;;========================== (defclass 3D-axis-view (om-view) ()) (defmethod om-draw-contents ((self 3d-axis-view)) (call-next-method) (om-with-fg-color (om-make-color 0.8 0.3 0.3) (om-draw-line 10 5 40 5) (om-draw-string 1 7 "x")) (om-with-fg-color (om-make-color 0.3 0.6 0.3) (om-draw-line 10 12 40 12) (om-draw-string 1 14 "y")) (om-with-fg-color (om-make-color 0.3 0.3 0.6) (om-draw-line 10 19 40 19) (om-draw-string 1 21 "z"))) (defmethod make-timeline-left-item ((self 3DC-editor) id) (om-make-view 'om-view :size (omp 0 15))) (defmethod make-editor-window-contents ((editor 3DC-editor)) (let* ((object (or (object-value editor) (make-instance '3DC))) ;;; dummy-object just in case... (decimals (decimals object)) (3dPanel (om-make-view '3dpanel :editor editor :bg-color (editor-get-edit-param editor :3D-bg-color) :g-objects (create-GL-objects editor) )) (top-editor (make-instance 'bpc-editor :object (object editor) :container-editor editor :decimals decimals :x-axis-key :x :y-axis-key :y :make-point-function #'(lambda (x y) (make-3Dpoint :x x :y y)))) (front-editor (make-instance 'bpc-editor :object (object editor) :container-editor editor :decimals decimals :x-axis-key :x :y-axis-key :z :make-point-function #'(lambda (x y) (make-3Dpoint :x x :z y)))) (top-panel (om-make-view 'BPC-panel :direct-draw t :bg-color (om-def-color :white) :scrollbars nil :size (omp 50 100) :scale-fact (expt 10 decimals) :editor top-editor)) (front-panel (om-make-view 'BPC-panel :direct-draw t :bg-color (om-def-color :white) :scrollbars nil :size (omp 50 100) :scale-fact (expt 10 decimals) :editor front-editor)) (top-mousepos-txt (om-make-graphic-object 'om-item-text :size (omp 60 16))) (front-mousepos-txt (om-make-graphic-object 'om-item-text :size (omp 60 16))) (timeline-editor (timeline-editor editor)) (transport-area nil) (bottom-area nil) (top-layout (om-make-layout 'om-grid-layout :dimensions '(2 3) :ratios '((0.01 0.99) (0.01 0.98 0.01)) :subviews (list nil (om-make-layout 'om-row-layout :subviews (list (om-make-graphic-object 'om-item-text :text "Top view" :size (omp 60 18)) top-mousepos-txt)) (setf (y-ruler top-panel) (om-make-view 'y-ruler-view :related-views (list top-panel) :size (omp 30 nil) :bg-color (om-def-color :white) :decimals decimals)) top-panel nil (setf (x-ruler top-panel) (om-make-view 'x-ruler-view :related-views (list top-panel) :size (omp nil 30) :bg-color (om-def-color :white) :decimals decimals))))) (front-layout (om-make-layout 'om-grid-layout :dimensions '(2 3) :ratios '((0.01 0.99) (0.01 0.98 0.01)) :subviews (list nil (om-make-layout 'om-row-layout :subviews (list (om-make-graphic-object 'om-item-text :text "Front view" :size (omp 60 18)) front-mousepos-txt)) (setf (y-ruler front-panel) (om-make-view 'y-ruler-view :related-views (list front-panel) :size (omp 30 nil) :bg-color (om-def-color :white) :decimals decimals)) front-panel nil (setf (x-ruler front-panel) (om-make-view 'x-ruler-view :related-views (list front-panel) :size (omp nil 30) :bg-color (om-def-color :white) :decimals decimals)))))) ;bottom area (setf bottom-area (let ((item-h 18)) (om-make-layout 'om-row-layout :ratios '(.01 1 1) :subviews (list NIL ; small gap (om-make-layout 'om-grid-layout :dimensions '(2 3) :align '(:left :center) :subviews (list (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-check-box :text "axes" :size (omp 46 item-h) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-axes) :di-action #'(lambda (item) (editor-set-edit-param editor :show-axes (om-checked-p item)) (update-3D-view editor))) (om-make-view '3D-axis-view :size (omp 30 24)))) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "draw mode:" :size (omp 80 item-h) :font (om-def-font :gui)) (om-make-di 'om-popup-list :items '(:default :points :lines) :size (omp 80 24) :font (om-def-font :gui) :value (editor-get-edit-param editor :draw-style) :di-action #'(lambda (list) (editor-set-edit-param editor :draw-style (om-get-selected-item list)) )))) (om-make-di 'om-check-box :text "background elements" :size (omp 160 item-h) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-background) :di-action #'(lambda (item) (editor-set-edit-param editor :show-background (om-checked-p item)) (set-3D-objects editor))) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "line size:" :size (omp 80 item-h) :font (om-def-font :gui)) (om-make-view 'om-view :size (om-make-point 28 18) :subviews (list (om-make-graphic-object 'numbox :value (editor-get-edit-param editor :line-width) :bg-color (om-def-color :white) :border t :size (om-make-point 28 18) :font (om-def-font :normal) :min-val 1 :max-val 10 :after-fun #'(lambda (item) (editor-set-edit-param editor :line-width (value item)) (set-3D-objects editor))))))) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "background" :size (omp 80 item-h) :font (om-def-font :gui)) (om-make-view 'color-view :size (om-make-point 35 16) :resizable nil :color (editor-get-edit-param editor :3D-bg-color) :after-fun #'(lambda (item) (editor-set-edit-param editor :3D-bg-color (color item)) (om-set-bg-color (get-g-component editor :main-panel) (color item)) (update-3D-view editor) )))) (when (color-options editor) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "color mapping:" :size (omp 80 item-h) :font (om-def-font :gui)) (om-make-di 'om-popup-list :items (color-options editor) :size (omp 80 24) :font (om-def-font :gui) :value (editor-get-edit-param editor :color-style) :di-action #'(lambda (list) (editor-set-edit-param editor :color-style (om-get-selected-item list)) (update-3d-curve-vertices-colors editor) (update-3D-view editor)))))) )) NIL ;; fill whitespace in the middle (om-make-layout 'om-column-layout :subviews (list (when timeline-editor (om-make-di 'om-check-box :text "show timeline" :size (omp 100 item-h) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-timeline) :di-action #'(lambda (item) (editor-set-edit-param editor :show-timeline (om-checked-p item)) (clear-timeline timeline-editor) (om-invalidate-view (get-g-component timeline-editor :main-panel)) (when (om-checked-p item) (make-timeline-view timeline-editor)) (om-update-layout (main-view editor)))) ) (om-make-di 'om-check-box :text "indices" :size (omp 60 item-h) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-indices) :di-action #'(lambda (item) (editor-set-edit-param editor :show-indices (om-checked-p item)))) (om-make-di 'om-check-box :text "times" :size (omp 60 item-h) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-times) :di-action #'(lambda (item) (editor-set-edit-param editor :show-times (om-checked-p item)))) )) )))) (when (timeline-enabled editor) (setf transport-area (om-make-layout 'om-row-layout ;:align :center :ratios '(0.8 0.5 0.05) :subviews (list nil (make-time-monitor editor :time (if (action object) 0 nil)) (om-make-layout 'om-row-layout ;:size (omp 60 20) :subviews (list (make-play-button editor :enable t) (make-repeat-button editor :enable t) (make-pause-button editor :enable t) (make-stop-button editor :enable t)))) ))) (set-g-component editor :main-panel 3dpanel) (set-g-component top-editor :main-panel top-panel) (set-g-component front-editor :main-panel front-panel) (set-g-component top-editor :mousepos-txt top-mousepos-txt) (set-g-component front-editor :mousepos-txt front-mousepos-txt) (setf (3Dp editor) 3dPanel (top-bpc-editor editor) top-editor (front-bpc-editor editor) front-editor) (update-3d-curve-vertices-colors editor) (when timeline-editor (set-g-component timeline-editor :main-panel (om-make-layout 'om-row-layout)) (when (editor-get-edit-param editor :show-timeline) (make-timeline-view timeline-editor))) (om-make-layout 'om-row-layout :ratios '(9.9 0.1) :subviews (list (om-make-layout 'om-column-layout :subviews (list transport-area (om-make-layout 'om-row-layout :subviews (list 3dpanel :divider (om-make-layout 'om-column-layout :subviews (list top-layout :divider front-layout))) :ratios '(0.6 nil 0.4) ) (when timeline-editor (get-g-component timeline-editor :main-panel)) bottom-area) :delta 2 :ratios '(0.01 1 0.01 0.01)) (call-next-method) )) ;side panel )) (defmethod editor-close ((self 3dc-editor)) (when (osc-manager self) (close-osc-manager self) (setf (osc-manager self) nil)) (call-next-method)) (defmethod editor-invalidate-views ((self 3Dc-editor)) (when (top-bpc-editor self) (editor-invalidate-views (top-bpc-editor self))) (when (front-bpc-editor self) (editor-invalidate-views (front-bpc-editor self))) (when (timeline-editor self) (editor-invalidate-views (timeline-editor self))) (update-editor-3d-object self) (update-3d-view self)) (defmethod editor-window-init-size ((self 3DC-editor)) (om-make-point 800 600)) (defmethod init-editor-window ((editor 3DC-editor)) (call-next-method) (reinit-ranges (top-bpc-editor editor)) (reinit-ranges (front-bpc-editor editor)) (update-editor-3d-object editor) (om-init-3D-view (3Dp editor))) ; when the object is modified (defmethod update-to-editor ((self 3DC-editor) (from t)) (setf (selection self) nil) (when (window self) (set-3d-objects self) (set-decimals-in-editor (top-bpc-editor self) (decimals (object-value self))) (set-decimals-in-editor (front-bpc-editor self) (decimals (object-value self))) (time-sequence-update-internal-times (object-value self)) ; (enable-play-controls self (action (object-value self))) ;;; leave T (update-sub-editors self) (update-default-view self) )) ; when the timeline is edited (defmethod update-to-editor ((self 3DC-editor) (from timeline-editor)) (setf (selection self) (get-indices-from-points (object-value self) (selection from))) (when (window self) (update-editor-3d-object self) (time-sequence-update-internal-times (object-value self)) (update-3d-view self) (update-sub-editors self)) (report-modifications self)) ; when internal editors are edited (defmethod update-to-editor ((self 3DC-editor) (from bpf-editor)) (setf (selection self) (selection from)) (update-sub-editors self) (when (window self) (update-editor-3d-object self) (update-3d-view self)) (report-modifications self)) (defmethod format-3D-points ((self 3DC)) (mat-trans (list (x-points self) (y-points self) (z-points self) (times self)))) (defmethod create-GL-objects ((self 3DC-editor)) (let ((obj-list (if (object-value self) (cons (object-value self) (remove (object-value self) (multi-obj-list self))) (multi-obj-list self)))) (remove nil (append (mapcar #'(lambda (obj) (make-instance '3D-lines :points (format-3d-points obj) :color (color obj) :draw-style :default :line-width (editor-get-edit-param self :line-width)) ) obj-list) (when (editor-get-edit-param self :show-background) (mapcar 'make-3D-background-element (list! (editor-get-edit-param self :background)))) )) )) ;;; will redraw the existing objects (defmethod update-3D-view ((self 3DC-editor)) (when (3DP self) (gl-user::clear-gl-display-list (3Dp self)) (om-invalidate-view (3Dp self)))) ;;; will rebuild the objects then redraw ;;; the gl-objets are drawn in an optimized OpenGL call-list (defmethod set-3D-objects ((self 3dc-editor)) (when (3Dp self) (om-set-gl-objects (3Dp self) (create-GL-objects self)) (update-3d-curve-vertices-colors self) (update-3D-view self))) (defmethod update-editor-3d-object ((self 3dc-editor)) (when (3DP self) (let ((3d-objs (if (multi-obj-list self) (first-n (om-get-gl-objects (3DP self)) (length (multi-obj-list self))) (list (car (om-get-gl-objects (3DP self)))))) (obj (object-value self))) (when obj (setf (selected-points (car 3d-objs)) (selection self)) (loop for 3d-obj in 3d-objs for o in (cons obj (remove obj (multi-obj-list self))) do (setf (draw-style 3d-obj) (editor-get-edit-param self :draw-style)) (om-set-3Dobj-points 3d-obj (format-3d-points o)))) (update-3d-curve-vertices-colors self)))) (defmethod update-sub-editors ((self 3DC-editor)) (when (window self) (when (top-bpc-editor self) (setf (selection (top-bpc-editor self)) (selection self)) (editor-invalidate-views (top-bpc-editor self))) (when (front-bpc-editor self) (setf (selection (front-bpc-editor self)) (selection self)) (editor-invalidate-views (front-bpc-editor self))) (update-timeline-editor self))) ;;; called after undo/redo (defmethod update-after-state-change ((self 3DC-editor)) (update-view-contents (get-g-component self :default-view)) (set-decimals-in-editor (top-bpc-editor self) (decimals (object-value self))) (set-decimals-in-editor (front-bpc-editor self) (decimals (object-value self))) (editor-invalidate-views self) (call-next-method)) ;;;========================== ;;; MENUS ;;;========================== (defmethod om-menu-items ((self 3dc-editor)) (remove nil (list (main-app-menu-item) (om-make-menu "File" (default-file-menu-items self)) (om-make-menu "Edit" (bpf-edit-menu-items self)) (om-make-menu "Windows" (default-windows-menu-items self)) (om-make-menu "Help" (default-help-menu-items self)) ))) (defmethod reverse-points ((self 3dc-editor)) (store-current-state-for-undo self) (with-schedulable-object (object-value self) (time-sequence-reverse (object-value self))) (editor-invalidate-views self) (update-to-editor (timeline-editor self) self) (report-modifications self)) (defmethod cleanup-bpf-points ((self 3dc-editor)) (store-current-state-for-undo self) (with-schedulable-object (object-value self) (cleanup-points (object-value self))) (editor-invalidate-views self) (update-to-editor (timeline-editor self) self) (report-modifications self)) (defmethod select-all-command ((self 3dc-editor)) #'(lambda () (setf (selection self) (list T)) (update-editor-3d-object self) (update-sub-editors self) (update-3d-view self) )) (defmethod open-osc-manager-command ((self 3dc-editor)) #'(lambda () (editor-open-osc-manager self))) ;;;========================== ;;; KEY EVENTS ;;;========================== (defmethod editor-key-action ((editor 3DC-editor) key) (let ((top-editor (top-bpc-editor editor)) (front-editor (front-bpc-editor editor))) (when (and top-editor front-editor) (let ((top-panel (get-g-component top-editor :main-panel)) (front-panel (get-g-component front-editor :main-panel)) (selected-editor (and (selected-view editor) (editor (selected-view editor)))) (3dpanel (3dp editor))) (case key (#\- (zoom-rulers top-panel :dx -0.1 :dy -0.1) (zoom-rulers front-panel :dx -0.1 :dy -0.1) (zoom-view 3dpanel 0.8)) (#\+ (zoom-rulers top-panel :dx 0.1 :dy 0.1) (zoom-rulers front-panel :dx 0.1 :dy 0.1) (zoom-view 3dpanel 1.2)) (:om-key-delete (store-current-state-for-undo editor) (delete-editor-selection editor) (report-modifications top-editor) ;; why ? (update-editor-3d-object editor) (update-sub-editors editor)) (:om-key-esc (set-selection editor nil) (call-next-method) ;;; will also reset the cursor interval (update-editor-3d-object editor) (update-sub-editors editor)) ;;; we use the internal editors to make the moves because they have ruler hints (:om-key-left (let* ((ed (or selected-editor top-editor)) (panel (get-g-component ed :main-panel))) (store-current-state-for-undo editor :action :move-l :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection ed :dx (/ (- (get-units (x-ruler panel) (if (om-shift-key-p) 400 40))) (scale-fact panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications top-editor) )) (:om-key-right (let* ((ed (or selected-editor top-editor)) (panel (get-g-component ed :main-panel))) (store-current-state-for-undo editor :action :move-r :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection ed :dx (/ (get-units (x-ruler panel) (if (om-shift-key-p) 400 40)) (scale-fact panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications top-editor))) (:om-key-up (let* ((ed (or selected-editor top-editor)) (panel (get-g-component ed :main-panel))) (store-current-state-for-undo editor :action :move-u :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection ed :dy (/ (get-units (y-ruler panel) (if (om-shift-key-p) 400 40)) (scale-fact panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications ed))) (:om-key-down (let* ((ed (or selected-editor top-editor)) (panel (get-g-component ed :main-panel))) (store-current-state-for-undo editor :action :move-d :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection ed :dy (/ (- (get-units (y-ruler panel) (if (om-shift-key-p) 400 40))) (scale-fact panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications ed))) (:om-key-pageup (store-current-state-for-undo editor :action :move-pu :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection front-editor :dy (/ (get-units (y-ruler front-panel) (if (om-shift-key-p) 400 40)) (scale-fact front-panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications front-editor)) (:om-key-pagedown (store-current-state-for-undo editor :action :move-pd :item (selection editor)) (with-schedulable-object (object-value editor) (move-editor-selection front-editor :dy (/ (- (get-units (y-ruler front-panel) (if (om-shift-key-p) 400 40))) (scale-fact front-panel))) (time-sequence-update-internal-times (object-value editor))) (report-modifications front-editor)) (#\Space (editor-stop editor) (player-play-object *general-player* (get-obj-to-play editor) editor)) (otherwise (editor-key-action (top-bpc-editor editor) key) (editor-key-action (front-bpc-editor editor) key)) ))))) ;;;========================== ;;; some functions from BPF/BPC-editor ;;;========================== (defmethod delete-editor-selection ((self 3dc-editor)) (when (selection self) (let ((object (object-value self))) (if (find T (selection self)) (setf (point-list (object-value self)) nil) (mapcar #'(lambda (i) (time-sequence-remove-nth-timed-item (object-value self) i)) (sort (selection self) '>) )) (setf (selection self) nil) (time-sequence-update-internal-times object)) (update-sub-editors self))) ;;;========================== ;;; 3D PANEL ;;;========================== (defclass 3DPanel (OMEditorView om-opengl-view) ()) (defmethod om-get-bg-color ((self 3DPanel)) (editor-get-edit-param (editor self) :3d-bg-color)) (defmethod om-get-default-extents ((self 3DPanel)) (values -0.5 0.5 -0.5 0.5 -0.5 0.5)) (defmethod om-draw-contents ((self 3DPanel)) (let ((editor (editor self))) ;(opengl:rendering-on (self) ; (gl-user::polar-rotate (gl-user::icotransform self) :dz -90 :dx 90)) (when (editor-get-edit-param editor :show-axes) (opengl:gl-push-matrix) (draw-3D-axes editor) (opengl:gl-pop-matrix)) (when (and (osc-manager editor) (active-p (osc-manager editor))) (opengl:gl-push-matrix) (draw-3D-cursor-position editor) (opengl:gl-pop-matrix)) (when (equal (player-get-object-state (player editor) (object-value editor)) :play) (opengl:gl-push-matrix) (draw-3D-player-cursor-position editor (player-get-object-time (player editor) (object-value editor))) (opengl:gl-pop-matrix)) ) ) (defmethod draw-3D-axes ((self 3DC-Editor)) (let* ((l 1.0) (arrow-size (/ l 20.0))) ;X axis (opengl:gl-color3-f 0.8 0.3 0.3) ;axis (opengl:gl-begin opengl:*GL-LINES*) (opengl:gl-vertex3-f -0.3 0.0 0.0) (opengl:gl-vertex3-f l 0.0 0.0) (opengl:gl-end) (draw-cone (list l 0.0 0.0) arrow-size 90.0 (list 0.0 1.0 0.0)) ;Y axis (opengl:gl-color3-f 0.3 0.6 0.3) ;axis (opengl:gl-begin opengl:*GL-LINES*) (opengl:gl-vertex3-f 0.0 -0.3 0.0) (opengl:gl-vertex3-f 0.0 l 0.0) (opengl:gl-end) (draw-cone (list 0.0 l 0.0) arrow-size -90.0 (list 1.0 0.0 0.0)) ;Z axis (opengl:gl-color3-f 0.3 0.3 0.6) ;axis (opengl:gl-begin opengl:*GL-LINES*) (opengl:gl-vertex3-f 0.0 0.0 -0.3) (opengl:gl-vertex3-f 0.0 0.0 l) (opengl:gl-end) (draw-cone (list 0.0 0.0 l) arrow-size 0.0 (list 0.0 1.0 0.0)) ) (restore-om-gl-colors-and-attributes)) (defmethod draw-3D-cursor-position ((self 3DC-Editor)) "Draw the OSC cursor" (when (osc-manager self) (if (equal (cursor-status (osc-manager self)) :draw) (opengl:gl-color4-f 1.0 0.1 0.1 1.0) (opengl:gl-color4-f 0.1 1.0 0.1 1.0)) (draw-sphere (cursor-position (osc-manager self)) (* (editor-get-edit-param self :line-width) 0.02)) (restore-om-gl-colors-and-attributes))) (defmethod draw-3D-player-cursor-position ((self 3DC-Editor) time) "Draw the player cursor(s)" (loop for obj in (or (multi-obj-list self) (list (object-value self))) do (let ((point (time-sequence-get-active-timed-item-at obj time))) (when point ; (opengl:gl-color4-f 0.9 0.3 0.1 1.0) (let ((c (or (color obj) (om-make-color .9 .3 .1)))) (opengl:gl-color3-f (coerce (om-color-r c) 'single-float) (coerce (om-color-g c) 'single-float) (coerce (om-color-b c) 'single-float))) (draw-sphere (point-to-list point) (* (editor-get-edit-param self :line-width) 0.03)) ))) (restore-om-gl-colors-and-attributes)) (defmethod point-to-list ((point 3dpoint)) (list (3dpoint-x point) (3dpoint-y point) (3dpoint-z point) (3dpoint-time point))) (defmethod update-3d-curve-vertices-colors ((self 3dc-editor)) (let ((g-objects (om-get-gl-objects (3Dp self))) (om-objects (cons (object-value self) (remove (object-value self) (multi-obj-list self))))) (loop for 3dobj in g-objects for 3dc in om-objects do (setf (vertices-colors-interpol 3dobj) (not (eql (editor-get-edit-param self :color-style) :speed)) (vertices-colors 3dobj) (get-vertices-colors self 3DC))))) (defmethod update-curve-min-max-values ((self 3dc-editor) min max) nil) (defmethod get-vertices-colors ((self 3dc-editor) (obj 3dc)) "create a vector of colors for a 3D-timed-curve depending on the mode selected" (let* ((size (max (length (point-list obj)) 1)) (min_h 0.65) (max_h 0.0) (range_h (- max_h min_h)) (h_step (/ (- max_h min_h) (if (= size 1) 1 (1- size))))) (if (not (point-list obj)) (default-color-vertices self obj) (case (editor-get-edit-param self :color-style) ((equal :indices) (update-curve-min-max-values self 0 (1- size)) (loop for i from 0 to (1- size) collect (let ((h (+ min_h (* i h_step)))) (om-make-color-hsv h 0.8 0.8))) ) ((equal :length) (let* ((profile (give-normalized-cumulative-length-profile obj))) (update-curve-min-max-values self 0 (give-length obj)) (loop for val in profile collect (om-make-color-hsv (+ min_h (* val range_h)) 0.8 0.8))) ) ((equal :speed) (let* ((speeds (give-speed-profile obj)) (max_speed nil) (min_speed nil)) (if (< (length speeds) 2) (progn (setf max_speed (or (car speeds) 0)) (setf min_speed (or (car speeds) 0))) (progn ;removing -1 and replacing by max speed (setf max_speed (reduce 'max speeds)) (setf speeds (loop for speed in speeds collect (if (= speed -1) max_speed speed))) (setf min_speed (reduce 'min speeds)) (setf speeds (normalize-speeds-list speeds min_speed max_speed)))) (setf speeds (cons (car speeds) speeds)) (update-curve-min-max-values self min_speed max_speed) (loop for speed in speeds collect (om-make-color-hsv (+ min_h (* range_h (or speed 0.5))) 0.8 0.8) ))) (otherwise (update-curve-min-max-values self nil nil) (default-color-vertices self obj)))))) (defun normalize-speeds-list (speeds min_speed max_speed) (let ((range_speed (- max_speed min_speed))) (setf range_speed (- max_speed min_speed)) (when (zerop range_speed) (setf range_speed 1)) (setf speeds (om/ (om- speeds min_speed) range_speed)))) (defmethod default-color-vertices ((self 3dc-editor) (obj 3dc)) (make-list (length (point-list obj)) :initial-element (or (color obj) (om-def-color :black)))) (defmethod om-view-key-handler ((self 3DPanel) key) (case key (:om-key-esc (om-init-3D-view self)) (otherwise (call-next-method))) ) ;;;=================== ;;; OSC INPUT ;;;=================== (defun editor-open-osc-manager (editor) (unless (osc-manager editor) (setf (osc-manager editor) (make-instance 'osc-curvce-input-manager :editor editor))) (open-osc-manager (osc-manager editor))) (defmethod osc-manager-add-callback ((editor 3DC-editor) point) (let ((obj (object-value editor))) (time-sequence-insert-timed-item-and-update obj point (length (point-list obj))) (report-modifications editor) (if (= (mod (length (point-list obj)) 10) 9) (editor-invalidate-views editor)) (om-invalidate-view (3Dp editor)))) (defmethod osc-manager-move-callback ((editor 3DC-editor)) (update-sub-editors editor) (om-invalidate-view (3dp editor))) (defmethod osc-manager-clear-callback ((editor 3DC-editor)) (setf (point-list (object-value editor)) nil) (report-modifications editor) (update-sub-editors editor)) #| (defclass color-scale-view (om-view) ()) (defmethod om-draw-contents ((self color-scale-view)) (let* ((size (om-view-size self)) (width (om-point-x size)) (steps 20) (w_step (round (/ width steps))) (height (om-point-y size)) (min_h 0.65) (max_h 0.0) (h_step (/ (- max_h min_h) steps))) (loop for i from 0 to steps do (let ((h (+ min_h (* i h_step)))) (om-draw-rect (* i w_step) 0 (+ (* (+ 1 i) w_step) 1) height :color (om-make-color-hsv h 0.8 0.8) :fill t))))) |#
37,594
Common Lisp
.lisp
752
36.445479
172
0.536905
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
d034ea5190815a1899e035d5ce93d34a609ed8c333002fef3b2495c792e2c6c3
798
[ -1 ]
799
3d-functions.lisp
cac-t-u-s_om-sharp/src/packages/space/3D/3d-functions.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson, M. Schumacher ;============================================================================ (in-package :om) ;;;==================== ;;; FUNCTIONS FOR 3DCs ;;;==================== ;;; INTERPOLATION (defmethod 3D-interpolation ((first 3DC) (second 3DC) (steps number) &optional (curve 0.0) (decimals nil) (mode 'points) color) (cond ((equal mode 'points) (let ((interp-x (interpolation (x-points first) (x-points second) steps curve)) (interp-y (interpolation (y-points first) (y-points second) steps curve)) (interp-z (interpolation (z-points first) (z-points second) steps curve)) (interp-times (interpolation (time-sequence-get-internal-times first) (time-sequence-get-internal-times second) steps curve))) (values (loop for x1 in interp-x for y1 in interp-y for z1 in interp-z for t1 in interp-times collect (make-instance (class-of first) :x-points x1 :y-points y1 :z-points z1 :times t1 :decimals (decimals first) :color (if (equal color 'random) (om-random-color) color) )) interp-x interp-y interp-z interp-times) )) ((equal mode 'sample) (let ((l1 (length (point-list first))) (l2 (length (point-list second)))) (cond ((> l1 l2) (3D-interpolation first (3D-sample second l1) steps curve decimals 'points color)) ((> l2 l1) (3D-interpolation (3d-sample first l2) second steps curve decimals 'points color)) (t (3D-interpolation first second steps curve decimals 'points color))) )) )) (defmethod* 3D-interpol ((first 3DC) (second 3DC) (steps number) &key (curve 0.0) (decimals nil) (mode 'points) (color nil)) :icon 'bpf-interpol :initvals '(nil nil 1 0.0 nil points nil) :indoc '("a 3DC or trajectory" "a 3DC or trajectory" "number of steps" "interpolation curve" "precision" "interpolation mode" "coloring") :outdoc '("list of 3DC" "list of x-points" "list of y-points" "list of z-points" "list of times") :numouts 5 :menuins '((5 (("points to point" points) ("resample curves" sample)))) :doc "Interpolates between two 3D curves or trajectories). <steps> is the number of interpolated curves wanted, including <first> and <second>. 1 means one value between <first> and <seconds>. 2 will return only <first> and <second>. 3 will return <first> and <second> with one more curve in between. etc. <curve> in an exponential factor for the interpolation curve (0 = linear). <decimals> is the precision (number of decimals) in the returned curves (default NIL = precision of <first>). <mode> determines how interpolation is done : - 'points is point-by-point interpolation: the curves must have the same number of points, or the bigger one will be truncated. - 'sample means that the curves are resampled before interpolation. In case of BPfs, x-points will be added if needed so that the interpolated curves all have the same x points. In case of BPCs, the one with fewer points is resampled, then point-by-point interpolation is applied. <color> sets a color for the resulting curves. Use 'random to assign random colors for each interpolated curve. Outputs 1) list of interpolated BPFs/BPCs 2) list of x-points 3) list of y-points 4) list of z-points 5) list of times " (3D-interpolation first second steps curve decimals mode color)) ;;; RESAMPLE (defmethod* 3D-sample ((self 3Dc) (samples number) &optional decimals) :icon 'bpf-sample :initvals '(nil 1000 nil) ; :indoc '("object (3Dc)" "number of samples" "decimals") :numouts 5 :doc "samples a 3Dc" (let ((x (third (multiple-value-list (om-sample (x-points self) samples)))) (y (third (multiple-value-list (om-sample (y-points self) samples)))) (z (third (multiple-value-list (om-sample (z-points self) samples)))) (times (third (multiple-value-list (om-sample (time-sequence-get-internal-times self) samples))))) (values (make-instance (type-of self) :x-points x :y-points y :z-points z :times times :decimals (or decimals (decimals self))) x y z times))) ;;;======================================= ;;; REDEFINITION OF BPC FUNCTIONS FOR 3DCs and 3D-trajectories from OMPrisma ;;; by M.Schumacher, http://sourceforge.net/p/omprisma/ ;;;======================================= ;;; ROTATION ;;; From OMPrisma traj-rotate (defmethod* om-rotate ((self 3dc) &key (yaw 0) (pitch 0) (roll 0)) (let* ((res self)) (when (and yaw (not (zerop yaw))) (setf res (multiple-value-bind (a e d) (xyz->aed (x-points res) (y-points res) (z-points res)) (multiple-value-bind (x y z) (aed->xyz (om+ a yaw) e d) (make-instance (type-of self) :x-points x :y-points y :z-points z :times (times self) :decimals (decimals self)) )))) (when (and pitch (not (zerop pitch))) (setf res (multiple-value-bind (a e d) (xyz->aed (z-points res) (y-points res) (x-points res)) (multiple-value-bind (x y z) (aed->xyz (om+ a pitch) e d) (make-instance (type-of self) :x-points x :y-points y :z-points z :times (times self) :decimals (decimals self)))))) (when (and roll (not (zerop roll))) (setf res (multiple-value-bind (a e d) (xyz->aed (x-points res) (z-points res) (y-points res)) (multiple-value-bind (x y z) (aed->xyz (om+ a roll) e d) (make-instance (type-of self) :x-points x :y-points y :z-points z :times (times self) :decimals (decimals self)))))) (setf (color res) (color self)) res)) ;;; same with a list of (x y z) (defmethod* om-rotate ((self list) &key (yaw 0) (pitch 0) (roll 0)) (let* ((xyzlist (mat-trans self))) (when (and yaw (not (zerop yaw))) (setf xyzlist (multiple-value-bind (a e d) (xyz->aed (nth 0 xyzlist) (nth 1 xyzlist) (nth 2 xyzlist)) (multiple-value-bind (x y z) (aed->xyz (om+ a yaw) e d) (list x y z))))) (when (and pitch (not (zerop pitch))) (setf xyzlist (multiple-value-bind (a e d) (xyz->aed (nth 2 xyzlist) (nth 1 xyzlist) (nth 0 xyzlist)) (multiple-value-bind (x y z) (aed->xyz (om+ a pitch) e d) (list z y x ))))) (when (and roll (not (zerop roll))) (setf xyzlist (multiple-value-bind (a e d) (xyz->aed (nth 0 xyzlist) (nth 2 xyzlist) (nth 1 xyzlist)) (multiple-value-bind (x y z) (aed->xyz (om+ a roll) e d) (list x z y))))) (mat-trans xyzlist))) ;;; TRANSLATION ;;; From OMPrisma traj-translate (defmethod* om-translate ((self 3dc) &key x y z time) (let ((res self) (thex x) (they y) (thez z) (thet time)) (unless (numberp x) (setf thex 0)) (unless (numberp y) (setf they 0)) (unless (numberp z) (setf thez 0)) (unless (numberp time) (setf thet 0)) (setf res (make-instance (type-of self) :x-points (om+ (x-points self) thex) :y-points (om+ (y-points self) they) :z-points (om+ (z-points self) thez) :times (om+ (time-sequence-get-internal-times self) thet) :decimals (decimals self)) ) (setf (color res) (color self)) res)) (defmethod* om-mirror ((self 3DC) &key x y z times) (let ((res (make-instance (type-of self) :x-points (if x (om* -1 (x-points self)) (x-points self)) :y-points (if y (om* -1 (y-points self)) (y-points self)) :z-points (if z (om* -1 (z-points self)) (z-points self)) :times (if times (om* -1 (time-sequence-get-internal-times self)) (time-sequence-get-internal-times self)) :decimals (decimals self)))) (setf (color res) (color self)) res))
9,118
Common Lisp
.lisp
169
43.964497
281
0.563221
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
1da9ed3330f733887a60bdc5032d60ba3ce1364bfe3644f299335e1d724ee359
799
[ -1 ]
800
3d-model.lisp
cac-t-u-s_om-sharp/src/packages/space/3D/3d-model.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (defclass* 3d-model () ((data :initarg :data :accessor data :initform nil :documentation "a list of 3D-object (3D-lines, etc..)") (scaler-x :accessor scaler-x :initform 1 :documentation "a scaler for the viewer's 'x' axis") (scaler-y :accessor scaler-y :initform 1 :documentation "a scaler for the viewer's 'y' axis") (scaler-z :accessor scaler-z :initform 1 :documentation "a scaler for the viewer's 'z' axis") (center :accessor center :initform (list 0.0 0.0 0.0) :documentation "a 3D point used as reference for data transformation and output") (rotation-x :accessor rotation-x :initform 0 :documentation "rotation angles on x axis") (rotation-y :accessor rotation-y :initform 0 :documentation "rotation angles on y axis") (rotation-z :accessor rotation-z :initform 0 :documentation "rotation angles on z axis")) (:documentation "A container for 3D-objects, with associated graphical editor. Construct with a list of 3D objects: 3D-CUBE, 3D-SPHERE, 3D-LINES, and additional visualization parameters: - X, Y, Z scalers. - X, Y, Z-axis rotation angles. - Rotation center. Use 'get-transformed-data' to export the data as transformed by the rotation and scalers. ")) #| (defmethod get-properties-list ((self 3d-model)) '(("" (:scaler-x "x scale factor" :number scaler-x (.001 1000.0 1)) (:scaler-y "y scale factor" :number scaler-y (.001 1000.0 1)) (:scaler-z "z scale factor" :number scaler-z (.001 1000.0 1)) (:rotation-x "x-axis rotation" :number rotation-x (0 360 1)) (:rotation-y "y-axis rotation" :number rotation-y (0 360 1)) (:rotation-z "z-axis rotation" :number rotation-z (0 360 1)) (:center "center of rotation" :list center (0 0 0)) ))) |# (defmethod additional-box-attributes ((self 3d-model)) '((:x-grid "the x-range of the grid displayed in the viewer" nil) (:y-grid "the y-range of the grid displayed in the viewer" nil))) (defmethod additional-class-attributes ((self 3d-model)) '(scaler-x scaler-y scaler-z center rotation-x rotation-y rotation-z)) (defmethod om-init-instance ((self 3d-model) &optional initargs) (let ((c (find-value-in-kv-list initargs :center))) (when c (setf (center self) (copy-list c))) (when (data self) (setf (data self) (format-3D-objects (data self))) (when initargs ;;; we're not copying/reloading the object (multiple-value-bind (xmi xma ymi yma zmi zma) (get-extents (data self)) (let ((scaled-ref 100)) (unless (find-value-in-kv-list initargs :scaler-x) (setf (scaler-x self) (float (/ scaled-ref (- xma xmi))))) (unless (find-value-in-kv-list initargs :scaler-y) (setf (scaler-y self) (float (/ scaled-ref (- yma ymi))))) (unless (find-value-in-kv-list initargs :scaler-z) (setf (scaler-z self) (float (/ scaled-ref (- zma zmi))))) ))) ) self)) (defun format-3D-objects (list) (remove nil (loop for item in list collect (cond ((subtypep (type-of item) 'om-3d-object) item) ((and (consp item) (list-subtypep item 'cons)) (make-instance '3D-lines :points (loop for p in item collect (list (coerce (nth 0 p) 'single-float) (coerce (nth 1 p) 'single-float) (coerce (nth 2 p) 'single-float))) :color (om-random-color))) (t (om-beep-msg "Wrong object for 3D-model: ~A" (type-of item)))) ))) ;;; called from the editor only (defmethod init-state ((3dm 3d-model)) (setf (rotation-x 3dm) 0 (rotation-y 3dm) 0 (rotation-z 3dm) 0)) ;;; destructive ;;; does not modify interal glpoints (defmethod scale-object ((self om-3d-object) &key x y z) (loop for p in (om-3Dobj-points self) do (if x (setf (car p) (* x (car p)))) (if y (setf (cadr p) (* y (cadr p)))) (if z (setf (caddr p) (* z (caddr p))))) self) (defmethod translate-object ((self om-3d-object) &key x y z) (loop for p in (om-3Dobj-points self) do (if x (setf (car p) (+ x (car p)))) (if y (setf (cadr p) (+ y (cadr p)))) (if z (setf (caddr p) (+ z (caddr p))))) self) (defmethod* get-transformed-data ((self 3d-model)) :indoc '("a 3D-MODEL object") :outdoc '("transformed 3D-MODEL") :doc "Returns a new 3D-MODEL object as trasformed by the scalers and rotation values of an initial 3D-MODEL." (loop for obj in (data self) collect (let* ((new-obj (scale-object (translate-object (om-copy obj) :x (- (nth 0 (center self))) :y (- (nth 1 (center self))) :z (- (nth 2 (center self)))) :x (scaler-x self) :y (scaler-y self) :z (scaler-z self)) ) (points-xyz (mat-trans (om-3Dobj-points new-obj))) (xlist (car points-xyz)) (ylist (cadr points-xyz)) (zlist (caddr points-xyz)) (yaw (rotation-z self)) (pitch (rotation-x self)) (roll (rotation-y self))) ;;; !!! the order of the 3 rotations matters !!! ;;; YAW = Z axis (unless nil ;(zerop yaw) (multiple-value-bind (a e d) (xyz->aed xlist ylist zlist) (multiple-value-bind (x y z) (aed->xyz (om- a yaw) e d) (setf xlist x ylist y zlist z)))) ;;; ROLL = Y axis (unless nil ;(zerop roll) (multiple-value-bind (a e d) (xyz->aed xlist zlist ylist) (multiple-value-bind (x y z) (aed->xyz (om+ a roll) e d) (setf xlist x ylist z zlist y)))) ;;; PITCH = X axis (unless nil ;(zerop pitch) (multiple-value-bind (a e d) (xyz->aed zlist ylist xlist) (multiple-value-bind (x y z) (aed->xyz (om+ a pitch) e d) (setf zlist x ylist y xlist z)))) (om-set-3Dobj-points new-obj (mat-trans (list xlist ylist zlist))) (translate-object (scale-object new-obj :x (/ 1 (scaler-x self)) :y (/ 1 (scaler-y self)) :z (/ 1 (scaler-z self))) :x (nth 0 (center self)) :y (nth 1 (center self)) :z (nth 2 (center self)) ) ))) ;;; does not copy the data (defmethod filter-3D-data ((data-list list) &key xmin xmax ymin ymax zmin zmax) (remove-if #'(lambda (line) (find-if #'(lambda (p) (or (and xmin (< (car p) xmin)) (and xmax (> (car p) xmax)) (and ymin (< (cadr p) ymin)) (and ymax (> (cadr p) ymax)) (and zmin (< (caddr p) zmin)) (and zmax (> (caddr p) zmax)))) (om-3Dobj-points line))) data-list)) (defmethod filter-3D-points ((data-list list) &key xmin xmax ymin ymax zmin zmax) (remove-if #'(lambda (line) (null (om-3Dobj-points line))) (loop for line in data-list collect (let ((newline (om-copy line))) (setf (points newline) (remove-if #'(lambda (p) (or (and xmin (< (car p) xmin)) (and xmax (> (car p) xmax)) (and ymin (< (cadr p) ymin)) (and ymax (> (cadr p) ymax)) (and zmin (< (caddr p) zmin)) (and zmax (> (caddr p) zmax)))) (om-3Dobj-points newline))) newline)) )) ;;;======================================= ;;; EDITOR ;;;======================================= (defmethod object-has-editor ((self 3d-model)) t) (defmethod get-editor-class ((self 3d-model)) '3d-model-editor) (defmethod object-default-edition-params ((self 3d-model)) `((:x-grid :auto) (:y-grid :auto) (:shift-x-edit-mode :z) (:shift-y-edit-mode :_) (:alt-x-edit-mode :y) (:alt-y-edit-mode :x) (:show-grid t) (:filter-off-grid nil) (:3D-bg-color ,(om-make-color .1 .2 .2)) )) (defclass 3d-model-editor (OMEditor) ((x-grid :accessor x-grid :initform nil) ;; x-grid and y-grid can be the same as the editor's edit param, or they can be computed automatically (y-grid :accessor y-grid :initform nil))) (defclass 3d-model-view (OMEditorView om-opengl-view) ((viewpoint :accessor viewpoint :initform '(0.0d0 0.0d0 0.0d0) :documentation "x-y-z axis rotation angles"))) (defmethod init-grid ((editor 3d-model-editor)) (multiple-value-bind (xmi xma ymi yma zmi zma) ;; the data is scaled here. the grid must not (if (data (object-value editor)) (get-extents (data (object-value editor))) (values 0 0 0 0 0 0)) (declare (ignore zmi zma)) (set-x-grid editor (if (equal (editor-get-edit-param editor :x-grid) :auto) (list xmi xma) (editor-get-edit-param editor :x-grid))) (set-y-grid editor (if (equal (editor-get-edit-param editor :y-grid) :auto) (list ymi yma) (editor-get-edit-param editor :y-grid)))) ;; in case the def value was :auto, we set it now to the actual value (editor-set-edit-param editor :x-grid (x-grid editor)) (editor-set-edit-param editor :y-grid (y-grid editor))) (defmethod set-x-grid ((editor 3d-model-editor) values) (setf (x-grid editor) values) (when (get-g-component editor :x-grid-min-numbox) (set-value (get-g-component editor :x-grid-min-numbox) (car values))) (when (get-g-component editor :x-grid-max-numbox) (set-value (get-g-component editor :x-grid-max-numbox) (cadr values))) ;(when (get-g-component editor :center-x-numbox) ; (set-min-max (get-g-component editor :center-x-numbox) ; :min (car values) ; :max (cadr values))) (update-lines editor) values) (defmethod set-y-grid ((editor 3d-model-editor) values) (setf (y-grid editor) values) (when (get-g-component editor :y-grid-min-numbox) (set-value (get-g-component editor :y-grid-min-numbox) (car values))) (when (get-g-component editor :y-grid-max-numbox) (set-value (get-g-component editor :y-grid-max-numbox) (cadr values))) ;(when (get-g-component editor :center-y-numbox) ; (set-min-max (get-g-component editor :center-y-numbox) ; :min (car values) ; :max (cadr values))) (update-lines editor) values) (defmethod update-lines ((ed 3d-model-editor)) (let ((3D-view (get-g-component ed :3d-view))) (loop for line in (get-transformed-data (object-value ed)) for 3dobj in (om-get-gl-objects 3d-view) when (slot-exists-p 3dobj 'vertices-colors) do (setf (vertices-colors 3dobj) (loop for p in (om-3Dobj-points line) collect (if (and (editor-get-edit-param ed :filter-off-grid) (x-grid ed) (y-grid ed) (or (< (car p) (car (x-grid ed))) (> (car p) (cadr (x-grid ed))) (< (cadr p) (car (y-grid ed))) (> (cadr p) (cadr (y-grid ed))))) (om-make-color-alpha (om-def-color :gray) 0.1) NIL)))) (gl-user::clear-gl-display-list 3D-view) )) (defmethod update-g-components ((ed 3d-model-editor)) (let ((3DV (object-value ed))) (set-value (get-g-component ed :center-x-numbox) (car (center 3DV))) (set-value (get-g-component ed :center-y-numbox) (cadr (center 3DV))) (set-value (get-g-component ed :rotation-x-numbox) (rotation-x 3DV)) (set-value (get-g-component ed :rotation-y-numbox) (rotation-y 3DV)) (set-value (get-g-component ed :rotation-z-numbox) (rotation-z 3DV)) (om-set-slider-value (get-g-component ed :rotation-x-slider) (round (rotation-x 3DV))) (om-set-slider-value (get-g-component ed :rotation-y-slider) (round (rotation-y 3DV))) (om-set-slider-value (get-g-component ed :rotation-z-slider) (round (rotation-z 3DV))) )) (defmethod set-rotation-param-from-editor ((editor 3d-model-editor) object-slot value) (setf (slot-value (object-value editor) object-slot) value) (update-from-editor (object editor) :reactive nil) (when (editor-get-edit-param editor :filter-off-grid) (update-lines editor))) (defmethod set-3d-model-controls-from-object ((editor 3d-model-editor)) (let ((obj (object-value editor))) (set-value (get-g-component editor :center-x-numbox) (car (center obj))) (set-value (get-g-component editor :center-y-numbox) (cadr (center obj))) (set-value (get-g-component editor :rotation-x-numbox) (rotation-x obj)) (set-value (get-g-component editor :rotation-y-numbox) (rotation-y obj)) (set-value (get-g-component editor :rotation-z-numbox) (rotation-z obj)) (om-set-slider-value (get-g-component editor :rotation-x-slider) (round (rotation-x obj))) (om-set-slider-value (get-g-component editor :rotation-y-slider) (round (rotation-y obj))) (om-set-slider-value (get-g-component editor :rotation-z-slider) (round (rotation-z obj))) )) (defmethod set-bg-color ((editor 3d-model-editor)) (let ((new-color (om-choose-color-dialog :color (editor-get-edit-param editor :3D-bg-color) :owner (window editor)))) (when new-color (editor-set-edit-param editor :3D-bg-color new-color) (om-set-bg-color (get-g-component editor :3d-view) new-color) (om-invalidate-view (get-g-component editor :3d-view)) ))) (defmethod make-editor-window-contents ((editor 3d-model-editor)) (let ((obj (object-value editor))) (set-g-component editor :center-x-numbox (om-make-graphic-object 'numbox :size (om-make-point 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (car (center obj)) ;:min-val (car (x-grid editor)) :max-val (cadr (x-grid editor)) :db-click t :after-fun #'(lambda (item) (setf (car (center obj)) (get-value item)) (set-rotation-param-from-editor editor 'center (center obj)) (om-invalidate-view (get-g-component editor :3d-view)) ))) (set-g-component editor :center-y-numbox (om-make-graphic-object 'numbox :size (om-make-point 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (cadr (center obj)) ;:min-val (car (y-grid editor)) :max-val (cadr (x-grid editor)) :db-click t :after-fun #'(lambda (item) (setf (cadr (center obj)) (get-value item)) (set-rotation-param-from-editor editor 'center (center obj)) (om-invalidate-view (get-g-component editor :3d-view)) ))) (set-g-component editor :rotation-x-numbox (om-make-graphic-object 'numbox :size (om-make-point 40 18) :font (om-def-font :normal) :fg-color (om-def-color :gray) :border nil :enabled nil :value (rotation-x obj) :decimals 0)) (set-g-component editor :rotation-y-numbox (om-make-graphic-object 'numbox :size (om-make-point 40 18) :font (om-def-font :normal) :fg-color (om-def-color :gray) :border nil :enabled nil :value (rotation-y obj) :decimals 0)) (set-g-component editor :rotation-z-numbox (om-make-graphic-object 'numbox :size (om-make-point 40 18) :font (om-def-font :normal) :fg-color (om-def-color :gray) :border nil :enabled nil :value (rotation-z obj) :decimals 0)) (set-g-component editor :rotation-x-slider (om-make-di 'om-slider :range '(0 360) :size (omp 100 24) :value (rotation-x obj) :di-action #'(lambda (item) (set-rotation-param-from-editor editor 'rotation-x (om-slider-value item)) (om-invalidate-view (get-g-component editor :3d-view)) (set-value (get-g-component editor :rotation-x-numbox) (om-slider-value item) )))) (set-g-component editor :rotation-y-slider (om-make-di 'om-slider :range '(0 360) :size (omp 100 24) :value (rotation-y obj) :di-action #'(lambda (item) (set-rotation-param-from-editor editor 'rotation-y (om-slider-value item)) (om-invalidate-view (get-g-component editor :3d-view)) (set-value (get-g-component editor :rotation-y-numbox) (om-slider-value item) )))) (set-g-component editor :rotation-z-slider (om-make-di 'om-slider :range '(0 360) :size (omp 100 24) :value (rotation-z obj) :di-action #'(lambda (item) (set-rotation-param-from-editor editor 'rotation-z (om-slider-value item)) (om-invalidate-view (get-g-component editor :3d-view)) (set-value (get-g-component editor :rotation-z-numbox) (om-slider-value item) )))) (set-g-component editor :x-grid-min-numbox (om-make-graphic-object 'numbox :size (omp 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (car (x-grid editor)) :db-click t :after-fun #'(lambda (item) (set-x-grid editor (list (get-value item) (cadr (x-grid editor)))) (editor-set-edit-param editor :x-grid (x-grid editor)) (om-invalidate-view (get-g-component editor :3d-view)) ))) (set-g-component editor :x-grid-max-numbox (om-make-graphic-object'numbox :size (omp 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (cadr (x-grid editor)) :db-click t :after-fun #'(lambda (item) (set-x-grid editor (list (car (x-grid editor)) (get-value item))) (editor-set-edit-param editor :x-grid (x-grid editor)) (om-invalidate-view (get-g-component editor :3d-view))))) (set-g-component editor :y-grid-min-numbox (om-make-graphic-object 'numbox :size (omp 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (car (y-grid editor)) :db-click t :after-fun #'(lambda (item) (set-y-grid editor (list (get-value item) (cadr (y-grid editor)))) (editor-set-edit-param editor :y-grid (y-grid editor)) (om-invalidate-view (get-g-component editor :3d-view))))) (set-g-component editor :y-grid-max-numbox (om-make-graphic-object 'numbox :size (omp 55 18) :font (om-def-font :normal) :bg-color (om-def-color :white) :border t :decimals 1 :value (cadr (y-grid editor)) :db-click t :after-fun #'(lambda (item) (set-y-grid editor (list (car (y-grid editor)) (get-value item))) (editor-set-edit-param editor :y-grid (y-grid editor)) (om-invalidate-view (get-g-component editor :3d-view))))) (let ((control-view (om-make-layout 'om-row-layout :subviews (list ;;; CONTROLLERS (om-make-layout 'om-column-layout :subviews (list (om-make-di 'om-simple-text :text "Rotation control axes" :size (omp 180 22) :font (om-def-font :gui-b)) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "shift:" :size (omp 40 22) :font (om-def-font :gui)) (om-make-di 'om-popup-list :size (omp 60 24) :font (om-def-font :gui) :items '(:x :y :z :_) :value (editor-get-edit-param editor :shift-x-edit-mode) :di-action #'(lambda (list) (editor-set-edit-param editor :shift-x-edit-mode (om-get-selected-item list)))) (om-make-di 'om-popup-list :size (omp 60 24) :font (om-def-font :gui) :items '(:x :y :z :_) :value (editor-get-edit-param editor :shift-y-edit-mode) :di-action #'(lambda (list) (editor-set-edit-param editor :shift-y-edit-mode (om-get-selected-item list)))) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "alt:" :size (omp 40 20) :font (om-def-font :gui)) (om-make-di 'om-popup-list :size (omp 60 24) :font (om-def-font :gui) :items '(:x :y :z :_) :value (editor-get-edit-param editor :alt-x-edit-mode) :di-action #'(lambda (list) (editor-set-edit-param editor :alt-x-edit-mode (om-get-selected-item list)))) (om-make-di 'om-popup-list :size (omp 60 24) :font (om-def-font :gui) :items '(:x :y :z :_) :value (editor-get-edit-param editor :alt-y-edit-mode) :di-action #'(lambda (list) (editor-set-edit-param editor :alt-y-edit-mode (om-get-selected-item list)))) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "" :size (omp 40 20)) (om-make-di 'om-button :text "reinit rotations" :size (omp 120 24) :font (om-def-font :gui) :di-action #'(lambda (item) (declare (ignore item)) (init-state obj) (update-g-components editor) (when (editor-get-edit-param editor :filter-off-grid) (update-lines editor)) (om-invalidate-view (om-invalidate-view (get-g-component editor :3d-view))))))) )) ;;; ROTATION (om-make-layout 'om-column-layout :subviews (list (om-make-di 'om-simple-text :text "Rotation values" :size (omp 240 21) :font (om-def-font :gui-b)) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "center-x:" :size (omp 55 22) :font (om-def-font :gui)) (get-g-component editor :center-x-numbox) (om-make-di 'om-simple-text :text "center-y:" :size (omp 55 22) :font (om-def-font :gui)) (get-g-component editor :center-y-numbox) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "rotation-x:" :size (omp 60 20) :font (om-def-font :gui)) (get-g-component editor :rotation-x-slider) (get-g-component editor :rotation-x-numbox))) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "rotation-y:" :size (omp 60 20) :font (om-def-font :gui)) (get-g-component editor :rotation-y-slider) (get-g-component editor :rotation-y-numbox))) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "rotation-z:" :size (omp 60 20) :font (om-def-font :gui)) (get-g-component editor :rotation-z-slider) (get-g-component editor :rotation-z-numbox))) )) ;;; GRID (om-make-layout 'om-column-layout :subviews (list (om-make-di 'om-simple-text :text "Grid" :size (omp 200 22) :font (om-def-font :gui-b)) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "x-min:" :size (omp 40 22) :font (om-def-font :gui)) (get-g-component editor :x-grid-min-numbox) (om-make-di 'om-simple-text :text "x-max:" :size (omp 40 22) :font (om-def-font :gui)) (get-g-component editor :x-grid-max-numbox) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-simple-text :text "y-min:" :size (omp 40 22) :font (om-def-font :gui)) (get-g-component editor :y-grid-min-numbox) (om-make-di 'om-simple-text :text "y-max:" :size (omp 40 22) :font (om-def-font :gui)) (get-g-component editor :y-grid-max-numbox) )) (om-make-layout 'om-row-layout :subviews (list (om-make-di 'om-check-box :text "show" :size (omp 100 20) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :show-grid) :di-action #'(lambda (item) (editor-set-edit-param editor :show-grid (print (om-checked-p item))) (om-invalidate-view (get-g-component editor :3d-view)))) (om-make-di 'om-button :text "fit" :size (omp 60 24) :font (om-def-font :gui) :di-action #'(lambda (item) (declare (ignore item)) (editor-set-edit-param editor :x-grid :auto) (editor-set-edit-param editor :y-grid :auto) (init-grid editor) (update-g-components editor) (om-invalidate-view (om-invalidate-view (get-g-component editor :3d-view))))) )) (om-make-di 'om-check-box :text "filter off-grid" :size (omp 100 20) :font (om-def-font :gui) :checked-p (editor-get-edit-param editor :filter-off-grid) :di-action #'(lambda (item) (editor-set-edit-param editor :filter-off-grid (om-checked-p item)) (update-lines editor) (om-invalidate-view (get-g-component editor :3d-view)))) )) )) )) (set-g-component editor :3D-view (om-make-view '3d-model-view :editor editor :bg-color (editor-get-edit-param editor :3D-bg-color))) (om-make-layout 'om-row-layout :ratios '(9.9 0.1) :subviews (list (om-make-layout 'om-column-layout :ratios '(99 1) :subviews (list (get-g-component editor :3d-view) control-view)) (make-default-editor-view editor))) ))) (defmethod update-3D-contents ((editor 3d-model-editor)) (let ((obj (object-value editor)) (3D-view (get-g-component editor :3D-view))) ;;; works better if the objects are set after everything is on-screen (om-set-gl-objects 3D-view (loop for ob in (data obj) collect (let ((view-ob (om-copy ob))) (scale-object view-ob :x (scaler-x obj) :y (scaler-y obj) :z (scaler-z obj)) (om-update-3Dobj view-ob) view-ob) )) ;; apparently this needs to be done earlier (currently in draw-grid) (init-grid editor) )) (defmethod init-editor-window ((editor 3d-model-editor)) (call-next-method) (let ((3D-view (get-g-component editor :3D-view))) (update-3D-contents editor) (om-init-3d-view 3D-view) (om-invalidate-view 3D-view))) (defmethod update-to-editor ((editor 3d-model-editor) (from OMBox)) (when (window editor) (set-3d-model-controls-from-object editor) (let ((3D-view (get-g-component editor :3D-view))) (update-3D-contents editor) (gl-user::clear-gl-display-list 3D-view) (om-invalidate-view 3D-view) ))) (defmethod update-to-editor ((editor 3d-model-editor) (from t)) (when (window editor) (set-3d-model-controls-from-object editor) (let ((3D-view (get-g-component editor :3D-view))) (update-3D-contents editor) (gl-user::clear-gl-display-list 3D-view) (om-invalidate-view 3D-view) ))) ;;;======================== ;;; BOX ;;;======================== (defmethod display-modes-for-object ((self 3d-model)) '(:mini-view :text :hidden)) (defmethod get-cache-display-for-draw ((self 3d-model) box) (declare (ignore box)) (when (data self) (multiple-value-bind (xmi xma ymi yma zmi zma) (get-extents (data self)) (list (list xmi xma ymi yma zmi zma))))) (defmethod draw-mini-view ((self 3d-model) (box t) x y w h &optional time) (when (data self) (let ((ranges (car (get-display-draw box)))) (multiple-value-bind (fx ox) (conversion-factor-and-offset (car ranges) (cadr ranges) w x) (multiple-value-bind (fy oy) ;;; Y ranges are reversed !! (conversion-factor-and-offset (cadddr ranges) (caddr ranges) h y) (let ((font (om-def-font :tiny))) (om-with-font font (om-draw-string (+ x 10) (+ y (- h 4)) (number-to-string (nth 0 ranges))) (om-draw-string (+ x (- w (om-string-size (number-to-string (nth 1 ranges)) font) 4)) (+ y (- h 4)) (number-to-string (/ (nth 1 ranges) (scaler-x self)))) (om-draw-string x (+ y (- h 14)) (number-to-string (nth 2 ranges))) (om-draw-string x (+ y 10) (number-to-string (nth 3 ranges))))) (loop for line in (data self) do (when (points line) (let ((lines (loop for pts on (points line) while (cadr pts) append (let ((p1 (car pts)) (p2 (cadr pts))) (om+ 0.5 (list (+ ox (* fx (car p1))) (+ oy (* fy (cadr p1))) (+ ox (* fx (car p2))) (+ oy (* fy (cadr p2))))) )))) (om-with-fg-color (or (color line) (om-def-color :dark-gray)) (om-draw-lines lines))) )) ))))) ;;;============================ ;;; OPENGL ;;;============================ (defun draw-grid (x1 x2 y1 y2) (let ((xmin (* 2.0 (floor x1 2))) (xmax (* 2.0 (ceiling x2 2))) (ymin (* 2.0 (floor y1 2))) (ymax (* 2.0 (ceiling y2 2)))) (opengl:gl-line-width .5) (opengl:gl-color4-f 0.9 0.9 0.9 0.9) (opengl:gl-begin opengl:*GL-LINES*) (loop for x from xmin to xmax by 2 do (opengl:gl-vertex3-f (float x) ymin 0.0) (opengl:gl-vertex3-f (float x) ymax 0.0)) (loop for y from ymin to ymax by 2 do (opengl:gl-vertex3-f xmin (float y) 0.0) (opengl:gl-vertex3-f xmax (float y) 0.0)) (opengl:gl-end) )) (defmethod om-draw-contents ((self 3d-model-view)) (let* ((ed (editor self)) (3DV (object-value ed))) (gl-user::initialize-transform (gl-user::position-transform (gl-user::camera self))) (gl-user::polar-rotate (gl-user::position-transform (gl-user::camera self)) :dz (car (viewpoint self)) :dx (cadr (viewpoint self))) (when (and (editor-get-edit-param ed :show-grid) (x-grid ed) (y-grid ed)) (draw-grid (* (scaler-x 3DV) (car (x-grid ed))) (* (scaler-x 3DV) (cadr (x-grid ed))) (* (scaler-y 3DV) (car (y-grid ed))) (* (scaler-y 3DV) (cadr (y-grid ed))))) (opengl:gl-color4-f 1.0 1.0 1.0 0.5) (draw-gl-point (float (* (scaler-x 3DV) (nth 0 (center 3DV)))) (float (* (scaler-y 3DV) (nth 1 (center 3DV)))) (float (* (scaler-z 3DV) (nth 2 (center 3DV)))) '(1.0 1.0 1.0) 1.0 10.0) (gl-user::initialize-transform (gl-user::object-transform self)) (gl-user::translate (gl-user::object-transform self) :dx (- (float (* (scaler-x 3DV) (nth 0 (center 3DV))))) :dy (- (float (* (scaler-y 3DV) (nth 1 (center 3DV)))))) (gl-user::polar-rotate (gl-user::object-transform self) :dx (* (rotation-x 3DV) 10) ;;; rotations in gl-user seem to be 0-3600 :dy (* (rotation-y 3DV) 10) :dz (* (rotation-z 3DV) 10)) (gl-user::translate (gl-user::object-transform self) :dx (float (* (scaler-x 3DV) (nth 0 (center 3DV)))) :dy (float (* (scaler-y 3DV) (nth 1 (center 3DV))))) )) (defmethod om-adapt-camera-to-object ((self 3d-model-view)) (when (om-get-gl-objects self) (multiple-value-bind (xmi xma ymi yma zmi zma) (get-extents (om-get-gl-objects self)) (let* ((dist-z (* 2.5d0 (max 3.0d0 (abs xmi) (abs xma) (abs ymi) (abs yma) (abs zmi) (abs zma)))) (far-z (max 20.0d0 (* 5.0d0 dist-z)))) (setf (gl-user::eye (gl-user::camera self)) (gl-user::make-xyz :x (+ xmi (* (- xma xmi) 0.5d0)) :y (+ ymi (* (- yma ymi) 0.5d0)) :z dist-z)) (setf (gl-user::center (gl-user::camera self)) (gl-user::make-xyz :x (+ xmi (* (- xma xmi) 0.5d0)) :y (+ ymi (* (- yma ymi) 0.5d0)) :z 0.0d0)) (setf (gl-user::up (gl-user::camera self)) (gl-user::make-xyz :y 1.0d0)) (setf (gl-user::far (gl-user::projection (gl-user::camera self))) far-z))))) (defmethod om-view-key-handler ((self 3d-model-view) key) (let* ((ed (editor self)) (3DV (object-value ed))) (case key (#\+ (setf (gl-user::xyz-z (gl-user::eye (gl-user::camera self))) (* (gl-user::xyz-z (gl-user::eye (gl-user::camera self))) 0.6)) (om-invalidate-view self)) (#\- (setf (gl-user::xyz-z (gl-user::eye (gl-user::camera self))) (* (gl-user::xyz-z (gl-user::eye (gl-user::camera self))) 1.2)) (om-invalidate-view self)) (:om-key-right (if (om-command-key-p) (call-next-method) ;; will go next in a collection editor (let ((new-x (* (round (* (+ (nth 0 (center 3DV)) (max 0.1 (/ 1 (scaler-x 3DV)))) 10)) 0.1))) (setf (nth 0 (center 3DV)) new-x) (set-rotation-param-from-editor ed 'center (center 3DV)) (set-value (get-g-component ed :center-x-numbox) new-x) (om-invalidate-view self)))) (:om-key-left (if (om-command-key-p) (call-next-method) ;; will go previous in a collection editor (let ((new-x (* (round (* (- (nth 0 (center 3DV)) (max 0.1 (/ 1 (scaler-x 3DV)))) 10)) 0.1))) (setf (nth 0 (center 3DV)) new-x) (set-rotation-param-from-editor ed 'center (center 3DV)) (set-value (get-g-component ed :center-x-numbox) new-x) (om-invalidate-view self)))) (:om-key-up (let ((new-y (* (round (* (+ (nth 1 (center 3DV)) (max 0.1 (/ 1 (scaler-y 3DV)))) 10)) 0.1))) (setf (nth 1 (center 3DV)) new-y) (set-rotation-param-from-editor ed 'center (center 3DV)) (set-value (get-g-component ed :center-y-numbox) new-y) (om-invalidate-view self))) (:om-key-down (let ((new-y (* (round (* (- (nth 1 (center 3DV)) (max 0.1 (/ 1 (scaler-y 3DV)))) 10)) 0.1))) (setf (nth 1 (center 3DV)) new-y) (set-rotation-param-from-editor ed 'center (center 3DV)) (set-value (get-g-component ed :center-y-numbox) new-y) (om-invalidate-view self))) (:om-key-esc (setf (viewpoint self) (list 0.0d0 0.0d0 0.0d0)) (setf (gl-user::lastxy self) nil) (gl-user::initialize-transform (gl-user::position-transform (gl-user::camera self))) (gl-user::polar-rotate (gl-user::position-transform (gl-user::camera self)) :dz (car (viewpoint self)) :dx (cadr (viewpoint self))) (om-invalidate-view self) (om-invalidate-view self) ;;; don't know why this is needed twice... ) (#\o (init-state 3DV) (update-from-editor (object ed) :reactive nil) (update-g-components ed) (when (editor-get-edit-param ed :filter-off-grid) (update-lines ed)) (om-invalidate-view self)) (#\O (setf (center 3DV) (list 0 0 0)) (update-from-editor (object ed) :reactive nil) (update-g-components ed) (when (editor-get-edit-param ed :filter-off-grid) (update-lines ed)) (om-invalidate-view self)) (#\c (set-bg-color ed)) (#\Space (report-modifications ed)) (otherwise (call-next-method))))) (defmethod gl-user::opengl-viewer-motion-click ((self 3d-model-view) x y) (let ((last (gl-user::lastxy self))) (when last (setf (car (viewpoint self)) (mod (+ (car (viewpoint self)) (- x (car last))) 3600)) (setf (cadr (viewpoint self)) (mod (+ (cadr (viewpoint self)) (- y (cdr last))) 3600)) (opengl:rendering-on (self) (gl-user::opengl-redisplay-canvas self)) (setf (gl-user::lastxy self) (cons x y))))) (defmethod gl-user::opengl-viewer-motion-shift-click ((self 3d-model-view) x y) (let* ((last (gl-user::lastxy self)) (ed (editor self)) (3DV (object-value ed)) (dx (* (- x (car last)) .3)) (dy (* (- y (cdr last)) .3))) (when last (case (editor-get-edit-param ed :shift-x-edit-mode) (:x (setf (rotation-x 3DV) (mod (+ (rotation-x 3DV) dx) 360))) (:y (setf (rotation-y 3DV) (mod (+ (rotation-y 3DV) dx) 360))) (:z (setf (rotation-z 3DV) (mod (+ (rotation-z 3DV) dx) 360)))) (case (editor-get-edit-param ed :shift-y-edit-mode) (:x (setf (rotation-x 3DV) (mod (+ (rotation-x 3DV) dy) 360))) (:y (setf (rotation-y 3DV) (mod (+ (rotation-y 3DV) dy) 360))) (:z (setf (rotation-z 3DV) (mod (+ (rotation-z 3DV) dy) 360))))) (update-g-components ed) (when (editor-get-edit-param ed :filter-off-grid) (update-lines ed)) (update-from-editor (object ed) :reactive nil) (opengl:rendering-on (self) (gl-user::opengl-redisplay-canvas self)) (setf (gl-user::lastxy self) (cons x y)))) (defmethod gl-user::opengl-viewer-motion-alt-click ((self 3d-model-view) x y) (let* ((last (gl-user::lastxy self)) (ed (editor self)) (3DV (object-value ed)) (dx (* (- x (car last)) .3)) (dy (* (- y (cdr last)) .3))) (when last (case (editor-get-edit-param ed :alt-x-edit-mode) (:x (setf (rotation-x 3DV) (mod (+ (rotation-x 3DV) dx) 360))) (:y (setf (rotation-y 3DV) (mod (+ (rotation-y 3DV) dx) 360))) (:z (setf (rotation-z 3DV) (mod (+ (rotation-z 3DV) dx) 360)))) (case (editor-get-edit-param ed :alt-y-edit-mode) (:x (setf (rotation-x 3DV) (mod (+ (rotation-x 3DV) dy) 360))) (:y (setf (rotation-y 3DV) (mod (+ (rotation-y 3DV) dy) 360))) (:z (setf (rotation-z 3DV) (mod (+ (rotation-z 3DV) dy) 360))))) (update-g-components ed) (when (editor-get-edit-param ed :filter-off-grid) (update-lines ed)) (update-from-editor (object ed) :reactive nil) (opengl:rendering-on (self) (gl-user::opengl-redisplay-canvas self)) (setf (gl-user::lastxy self) (cons x y))))
45,776
Common Lisp
.lisp
826
38.421308
145
0.4876
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
18fea4631fbeaef115fe2477df885f4246138ab89869cd3d7df49f8907f3fa9b
800
[ -1 ]
801
gl-user.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/gl-user.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;=========================================================================== ; Mid-level interface with LW OpenGL ; Adapted from the OpenGL example in LispWorks distribution ;;=========================================================================== (defpackage :gl-user (:use :common-lisp)) (in-package :gl-user) ;;; ------------------------------------------------------------ ;;; Types and creators. (deftype gl-double () 'double-float) (deftype gl-double-vector (n) `(opengl:gl-vector :double ,n)) (deftype gl-single () 'single-float) (deftype gl-single-vector (n) `(opengl:gl-vector :float ,n)) (defun make-gl-double-vector (size) (opengl:make-gl-vector :double size)) (defun make-gl-single-vector (size) (opengl:make-gl-vector :float size)) (defun gl-float-vector (type contents) (opengl:make-gl-vector type (length contents) :contents contents)) (defun gl-double-vector (&rest contents) (gl-float-vector :double contents)) (defun gl-single-vector (&rest contents) (gl-float-vector :float contents)) ;;; ------------------------------ ;;; Vertex can be pass through to 'C' ;;; vertexes list of gl-vertexes (not passed to 'C') ;;; ------------------------------ (declaim (inline gl-vertex gl-vertexes)) (defun gl-vertex (x y z w) (gl-double-vector x y z w)) (defun gl-vertexes (contents) (mapcar #'(lambda (c) (apply 'gl-double-vector c)) contents)) ;;; ------------------------------ ;;; XYZ coordinate ;;; ------------------------------ (defstruct xyz (x 0.0d0 :type double-float) (y 0.0d0 :type double-float) (z 0.0d0 :type double-float)) ;;; -------------------------------- ;;; Geometry Utilities (defun vector-difference (v1 v2 res) (loop for i fixnum below 3 do (setf (opengl:gl-vector-aref res i) (- (opengl:gl-vector-aref v1 i) (opengl:gl-vector-aref v2 i)))) res) (defun vector-sum (v1 v2 res) (loop for i fixnum below 3 do (setf (opengl:gl-vector-aref res i) (+ (opengl:gl-vector-aref v1 i) (opengl:gl-vector-aref v2 i)))) res) (defun normalize (vector) (let* ((x (opengl:gl-vector-aref vector 0)) (y (opengl:gl-vector-aref vector 1)) (z (opengl:gl-vector-aref vector 2)) (d (sqrt (+ (* x x) (* y y) (* z z))))) (if (zerop d) (error "Can't normalize a zero-length vector! ~s" vector) (setf (opengl:gl-vector-aref vector 0) (/ x d) (opengl:gl-vector-aref vector 1) (/ y d) (opengl:gl-vector-aref vector 2) (/ z d))) vector)) (defun normalized-cross-product (v1 v2 result) (let ((res (or result (make-gl-double-vector (length v1))))) (declare (type (gl-double-vector (*)) res)) (setf (opengl:gl-vector-aref res 0) (- (* (opengl:gl-vector-aref v1 1) (opengl:gl-vector-aref v2 2)) (* (opengl:gl-vector-aref v1 2) (opengl:gl-vector-aref v2 1))) (opengl:gl-vector-aref res 1) (- (* (opengl:gl-vector-aref v1 2) (opengl:gl-vector-aref v2 0)) (* (opengl:gl-vector-aref v1 0) (opengl:gl-vector-aref v2 2))) (opengl:gl-vector-aref res 2) (- (* (opengl:gl-vector-aref v1 0) (opengl:gl-vector-aref v2 1)) (* (opengl:gl-vector-aref v1 1) (opengl:gl-vector-aref v2 0)))) (normalize res) res)) ;;; ------------------------------------------------------------ ;;; TEXT (defun set-up-gl-fonts (pane obj) #+Win32 (when (name obj) (unless (assoc :font (extra-display-lists obj)) (push (list :font (win32::wgl-use-font pane :start 0 :count 256 :outlinep t) 256) (extra-display-lists obj))))) #+Win32 (defmacro with-3d-text-state-saved (&body body) `(opengl:with-matrix-pushed (opengl:gl-push-attrib opengl:*gl-all-attrib-bits*) ,@body (opengl:gl-pop-attrib))) #+Win32 (defun draw-3d-text (obj text) (let* ((base (second (assoc :font (extra-display-lists obj))))) ;; Set up for a string-drawing display list call. (opengl:gl-list-base base) ;; Draw a string using font display lists. (fli:with-foreign-string (ptr elts bytes :external-format win32:*multibyte-code-page-ef* :null-terminated-p nil) text (declare (ignore bytes)) (opengl:gl-call-lists elts opengl:*gl-unsigned-byte* ptr)))) #+Win32 (defun draw-positioned-3d-text (obj text x-pos y-pos z-pos x-rotation y-rotation z-rotation scale) (with-3d-text-state-saved (opengl:gl-translated x-pos y-pos z-pos) (opengl:gl-scaled scale scale scale) (opengl:gl-rotated x-rotation 1.0d0 0.0d0 0.0d0) (opengl:gl-rotated y-rotation 1.0d0 0.0d0 0.0d0) (opengl:gl-rotated z-rotation 0.0d0 0.0d0 1.0d0) ;; Draw the text. (draw-3d-text obj text))) ;;; ------------------------------------------------------------ ;;; TEXTURE ;;; (defvar *texture-color* nil) ;;; Setup code (defun get-texture-color () (unless *texture-color* (setf *texture-color* (gl-single-vector 1.0 1.0 1.0 1.0))) *texture-color*) ;;; Cleanup code (defun cleanup-texture-color () (setf *texture-color* nil)) (defun make-object-colors (npolys &optional style) (case style (:uniform (make-array npolys :initial-element (gl-single-vector (float (random 1.0) 1.0) (float (random 1.0) 1.0) (float (random 1.0) 1.0) 1.0))) (otherwise (coerce (loop for i below npolys collect (gl-single-vector (float (random 1.0) 1.0) (float (random 1.0) 1.0) (float (random 1.0) 1.0) 1.0)) 'vector)))) (defun make-object-vertexes (vertex-list) (coerce (gl-vertexes vertex-list) 'simple-vector)) (defun make-object-indexes (index-list) (let* ((biggest (loop for i in index-list maximize (length i))) (indexes (make-array (list (length index-list) biggest) :element-type 'fixnum :initial-element -1))) (loop for id in index-list for i from 0 do (loop for jd in id for j from 0 do (setf (aref indexes i j) jd))) indexes)) ;;; ------------------------------------------------------------ ;;; Class object ;;; ;;; This superclass just manages display lists for the subclasses. (defclass gl-object () ((name :initarg :name :accessor name :initform nil) (use-display-list :initform nil :initarg :use-display-list :accessor use-display-list) (display-list :initform nil :accessor display-list) (extra-display-lists :initform nil :accessor extra-display-lists) (viewer :accessor viewer))) (defmethod draw :around ((object gl-object)) (if (use-display-list object) (if (display-list object) (progn (opengl:gl-call-list (display-list object)) (let ((draw (sys:cdr-assoc :draw (extra-display-lists object)))) (mapc 'opengl:gl-call-list draw))) (progn (set-up-gl-fonts (viewer object) object) (let ((n (opengl:gl-gen-lists 1))) (if (plusp n) (progn (opengl:gl-new-list n opengl:*gl-compile-and-execute*) (call-next-method) (opengl:gl-end-list) (setf (display-list object) n)) (progn (format t "~%~s:No more display list indexes!" object) (call-next-method)))))) (call-next-method))) (defmethod draw ((object gl-object)) (print (list "gl-user drawing object" object))) (defmethod (setf use-display-list) :after (value (object gl-object)) (unless value (delete-display-list object))) (defmethod delete-display-list ((object gl-object)) (when (display-list object) (opengl:gl-delete-lists (display-list object) 1) (setf (display-list object) nil)) (loop for (nil start length) in (extra-display-lists object) do (opengl:gl-delete-lists start length)) (setf (extra-display-lists object) nil)) ;;====================== ;; INTERFACE (exported functions and classes) ;;====================== ;;; Main OpenGL view superclass (defclass opengl-view (opengl:opengl-pane) ((g-objects :initarg :g-objects :accessor g-objects :initform nil) (icotransform :initform nil :initarg :icotransform :accessor icotransform) (light-transform :initform nil :initarg :light-transform :accessor light-transform) (object-transform :initform nil :initarg :object-transform :accessor object-transform) (double-buffered-p :initform t :initarg :double-buffered-p :accessor double-buffered-p) (lastxy :initform nil :initarg :lastxy :accessor lastxy) (camera :initform (make-camera :color '(0.9 0.9 0.9 1.0)) :initarg :camera :accessor camera)) (:default-initargs :configuration #-linux (list :rgba t :depth t :double-buffered t :depth-buffer 64) ;depth buffer allows using depth in 3D drawing #+linux (list :rgba t :depth nil :double-buffered t) :use-display-list t :display-callback 'opengl-redisplay-canvas :resize-callback 'opengl-resize-canvas :input-model '(((:button-1 :press) opengl-viewer-click) ((:button-1 :shift :press) opengl-viewer-shift-click) ((:button-1 :meta :press) opengl-viewer-alt-click) ((:motion :button-1) opengl-viewer-motion-click) ((:motion :button-1 :shift) opengl-viewer-motion-shift-click) ((:motion :button-1 :meta) opengl-viewer-motion-alt-click) ((:button-1 :second-press) opengl-viewer-double-click) (:gesture-spec opengl-viewer-key-pressed)) )) (defmethod (setf g-objects) :before (new-object-list (viewer opengl-view)) (opengl:rendering-on (viewer) (mapc #'delete-display-list (g-objects viewer)))) (defmethod (setf g-objects) :after (new-object-list (viewer opengl-view)) (when new-object-list (mapc #'(lambda (g-object) (setf (viewer g-object) viewer)) (g-objects viewer))) (opengl-redisplay-canvas viewer)) (defmethod set-gl-object-list ((self opengl-view) globject-list) (setf (g-objects self) globject-list)) (defmethod get-gl-object-list ((self opengl-view)) (g-objects self)) ;;; ------------------------------------------------------------ ;;; Class projection ;;; ;;; A class which defines the fovy, aspect, near and far ;;; values for a call to glu-perspective to define the projection ;;; matrix. (defparameter *fovy* 45.0d0) (defparameter *aspect* 1.0d0) (defparameter *near* 0.2d0) (defparameter *far* 100.0d0) (defclass projection (gl-object) ((fovy :initform *fovy* :initarg :fovy :accessor fovy) (aspect :initform *aspect* :initarg :aspect :accessor aspect) (near :initform *near* :initarg :near :accessor near) (far :initform *far* :initarg :far :accessor far))) (defmethod draw ((projection projection)) (opengl:glu-perspective (fovy projection) (aspect projection) (near projection) (far projection)) ;(opengl:gl-ortho -1000.0D0 1000.0D0 -1000.0D0 1000.0D0 -1000.0D0 1000.0D0) ) (defun make-projection (&key fovy aspect near far) (make-instance 'projection :fovy (or fovy *fovy*) :aspect (or aspect *aspect*) :near (or near *near*) :far (or far *far*))) ;;; ------------------------------------------------------------ ;;; Class camera ;;; ;;; Defines an eye point, a center point and an up vector. ;;; The draw method calls GLU-LOOK-AT to install the camera values. ;;; The up vector is set to y (defparameter *eye* (make-xyz :y 1.0d0)) (defparameter *center* (make-xyz :y 1.0d0)) (defparameter *up* (make-xyz :z 1.0d0)) (defclass camera (gl-object) ((eye :initform (copy-structure *eye*) :initarg :eye :accessor eye :type xyz) (center :initform (copy-structure *center*) :initarg :center :accessor center :type xyz) (up :initform (copy-structure *up*) :initarg :up :accessor up :type xyz) (projection :initform (make-projection) :initarg :projection :accessor projection) (bgcolor :initform nil :initarg :bgcolor :accessor bgcolor) (position-transform :initform nil :initarg :position-transform :accessor position-transform) )) (defmethod draw ((camera camera)) (let ((eye (eye camera)) (center (center camera)) (up (up camera)) (projection (projection camera))) (declare (type xyz up eye center)) (opengl:gl-matrix-mode opengl:*gl-projection*) (opengl:gl-load-identity) (draw projection) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:gl-load-identity) (opengl:glu-look-at (xyz-x eye) (xyz-y eye) (xyz-z eye) (xyz-x center) (xyz-y center) (xyz-z center) (xyz-x up) (xyz-y up) (xyz-z up)) ;;; move the viewpoint (opengl:gl-translated (xyz-x center) (xyz-y center) (xyz-z center)) (opengl:gl-mult-matrixd (position-transform camera)) (opengl:gl-translated (- (xyz-x center)) (- (xyz-y center)) (- (xyz-z center))) ;(opengl:gl-enable opengl:*gl-lighting*) ;; can't get it to work correctly.. (when (bgcolor camera) (opengl:gl-clear-color (car (bgcolor camera)) (cadr (bgcolor camera)) (caddr (bgcolor camera)) (cadddr (bgcolor camera)) )) (opengl:gl-clear opengl:*gl-color-buffer-bit*) (opengl:gl-clear opengl:*gl-depth-buffer-bit*) (opengl:gl-depth-func opengl:*gl-less*) (opengl:gl-enable opengl:*gl-depth-test*))) (defun make-camera (&key eye center up projection color) (make-instance 'camera :eye (copy-structure (or eye *eye*)) :center (copy-structure (or center *center*)) :up (copy-structure (or up *up*)) :projection (or projection (make-projection)) :bgcolor (or color '(0.9 0.9 0.9 1.0))) ) (defun init-camera (camera) (setf (eye camera) (copy-structure *eye*)) (setf (center camera) (copy-structure *center*)) (setf (up camera) (copy-structure *up*)) (setf (projection camera) (make-projection)) (setf (position-transform camera) (make-gl-double-vector 16)) (initialize-transform (position-transform camera)) camera) ;;; ------------------------------------------------------------ ;;; The CAPI Interface ;;; ------------------------------------------------------------ (defun initialize-transform (transform) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:with-matrix-pushed (opengl:gl-load-identity) (opengl:gl-get-doublev opengl:*gl-modelview-matrix* transform))) (defun initialize-viewer (canvas) ;; Initialize the icotransform to unity. (opengl:rendering-on (canvas) (init-camera (camera canvas)) ;; new projeaction, needs to be adjusted to the view ratio (setf (icotransform canvas) (make-gl-double-vector 16)) (setf (light-transform canvas) (make-gl-double-vector 16)) (setf (object-transform canvas) (make-gl-double-vector 16)) (initialize-transform (icotransform canvas)) (initialize-transform (light-transform canvas)) (initialize-transform (object-transform canvas)) (set-lights-and-materials) (multiple-value-bind (w h) (capi::pinboard-pane-size canvas) (opengl-resize-canvas canvas 0 0 w h)))) (defun initialize-icotransform (canvas) (setf (icotransform canvas) (make-gl-double-vector 16)) (initialize-transform (icotransform canvas))) (defparameter *pointer-rotation-gain* 0.1d0) (defun polar-rotate (transform &key dx dy dz) (opengl:with-matrix-pushed (opengl:gl-load-identity) (when dx (opengl:gl-rotated (float (* dx *pointer-rotation-gain*) 1.0d0) 1.0d0 0.0d0 0.0d0)) (when dy (opengl:gl-rotated (float (* dy *pointer-rotation-gain*) 1.0d0) 0.0d0 1.0d0 0.0d0)) (when dz (opengl:gl-rotated (float (* dz *pointer-rotation-gain*) 1.0d0) 0.0d0 0.0d0 1.0d0)) (opengl:gl-mult-matrixd transform) (opengl:gl-get-doublev opengl:*gl-modelview-matrix* transform))) (defun translate (transform &key (dx 0.0d0) (dy 0.0d0) (dz 0.0d0)) (opengl:with-matrix-pushed (opengl:gl-load-identity) (opengl:gl-translated (float dx 1.0d0) (float dy 1.0d0) (float dz 1.0d0)) (opengl:gl-mult-matrixd transform) (opengl:gl-get-doublev opengl:*gl-modelview-matrix* transform))) (defun polar-rotate-light (viewer &key dx dy dz) (polar-rotate (light-transform viewer) :dx dx :dy dy :dz dz)) (defun polar-rotate-icosahedron (viewer &key dx dy dz) (polar-rotate (icotransform viewer) :dx dx :dy dy :dz dz)) (defun translate-icosahedron (viewer dx dy) (let ((factor (/ (xyz-y (eye (camera viewer))) 1500))) (translate (icotransform viewer) :dx (* dx factor) :dz (* dy factor)))) ;;; camera in canvas instead of interface (defun opengl-resize-canvas (canvas x y width height) (when #+Win32 (win32:is-window-visible (win32:pane-hwnd (capi-internals:representation canvas))) #-Win32 T (opengl:rendering-on (canvas) (opengl:gl-viewport 0 0 width height)) (setf (aspect (projection (camera canvas))) (coerce (/ width height) 'double-float)) (opengl-redisplay-canvas canvas))) (defparameter *light-model-ambient* nil) (defparameter *light-position* nil) (defparameter *light-ambient* nil) (defparameter *light-diffuse* nil) (defparameter *light-specular* nil) (defparameter *material-specular* nil) (defparameter *material-shininess* 25.0) (defparameter *material-emission* nil) ;; must be called at runtime because of gl-vector pointers (defun set-lights-and-materials () (setf *light-model-ambient* (gl-single-vector 0.4 0.4 0.4 1.0)) ;; (gl-single-vector 0.0 0.0 0.0 1.0) ;(setf *light-position* (gl-single-vector 10.0 10.0 10.0 1.0)) (setf *light-position* (gl-single-vector 10.0 10.0 10.0 0.0)) (setf *light-ambient* (gl-single-vector 0.1 0.1 0.1 1.0)) (setf *light-diffuse* (gl-single-vector 0.8 0.8 0.8 1.0)) (setf *light-specular* (gl-single-vector 0.8 0.8 0.8 1.0)) (setf *material-specular* (gl-single-vector 0.1 0.1 0.1 1.0)) ;; (gl-single-vector 0.1 0.0 0.0 1.0) (setf *material-shininess* 25.0) ;; 64.0 (setf *material-emission* (gl-single-vector 0.0 0.0 0.0 1.0)) ;; (gl-single-vector 0.0 0.0 0.0 1.0) ) (defun ensure-gl-vector (check) (unless check (set-lights-and-materials))) (defun opengl-redisplay-canvas (canvas &rest ignore) ignore (unless (icotransform canvas) (initialize-viewer canvas)) (opengl:rendering-on (canvas) (if *om-3d-anaglyph* (opengl-redisplay-canvas-anaglyph canvas) (opengl-redisplay-canvas-standard canvas)) ;swap buffers if double buffered (when (double-buffered-p canvas) (opengl:swap-buffers canvas)) )) (defun opengl-redisplay-canvas-standard (canvas) (opengl:gl-draw-buffer opengl:*gl-back*) (opengl:gl-clear opengl:*gl-color-buffer-bit*) (opengl:gl-clear opengl:*gl-depth-buffer-bit*) (opengl:gl-color-mask 1 1 1 1) ;draw the camera (background and view position) (unless (position-transform (camera canvas)) (init-camera (camera canvas))) (draw (camera canvas)) ;apply transform and render canvas light and objects (opengl-redisplay-all canvas) ) (defun opengl-redisplay-all (canvas) (ensure-gl-vector (and *material-specular* *material-emission* *light-model-ambient* *light-position* *light-ambient* *light-diffuse* *light-specular*)) (opengl:with-matrix-pushed (opengl:gl-mult-matrixd (light-transform canvas)) (opengl:gl-light-modelfv opengl:*gl-light-model-ambient* *light-model-ambient*) (opengl:gl-light-modelf opengl:*gl-light-model-local-viewer* 0.0) (opengl:gl-light-modelf opengl:*gl-light-model-two-side* 0.0) (opengl:gl-enable opengl:*gl-light0*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-position* *light-position*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-ambient* *light-ambient*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-diffuse* *light-diffuse*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-specular* *light-specular*) ) (opengl:with-matrix-pushed ;;(opengl:gl-shade-model opengl:*gl-smooth*) ;material stuff (opengl:gl-cull-face opengl:*gl-back*) (opengl:gl-enable opengl:*gl-cull-face*) (opengl:gl-enable opengl:*gl-color-material*) (opengl:gl-color-material opengl:*gl-front* opengl:*gl-ambient-and-diffuse*) (opengl:gl-materialfv opengl:*gl-front* opengl:*gl-specular* *material-specular*) (opengl:gl-materialf opengl:*gl-front* opengl:*gl-shininess* *material-shininess*) (opengl:gl-materialfv opengl:*gl-front* opengl:*gl-emission* *material-emission*) (opengl:gl-mult-matrixd (icotransform canvas)) ;Draw the content of the pane ant the objects (draw-contents canvas) (opengl:with-matrix-pushed (opengl:gl-mult-matrixd (object-transform canvas)) (mapc #'draw (g-objects canvas))) ) ) ;tobe redefined (defmethod draw-contents (canvas) (print (list "draw canvas" canvas))) ;;;=========================== ;;; ANAGLYPH MODE ;;;=========================== (defparameter *om-3d-anaglyph* nil) (defparameter *om-3d-anaglyph-eye-dist* 0.2d0) (defun opengl-anaglyph-p () *om-3d-anaglyph*) (defun opengl-enable-or-disable-anaglyph (t-or-nil) (setf *om-3d-anaglyph* t-or-nil)) (defun opengl-set-anaglyph-eye-dist (dist) (setf *om-3d-anaglyph-eye-dist* (coerce dist 'double-float))) (defun opengl-redisplay-canvas-anaglyph (canvas) (let* ((camera (camera canvas)) (eye (eye camera)) (center (center camera)) (up (up camera)) (projection (projection camera)) (camera-left (make-camera :eye eye :center center :up up :color '(0.95 0.95 0.95 1.0) :projection projection)) (camera-right (make-camera :eye eye :center center :up up :color '(0.95 0.95 0.95 1.0) :projection projection))) (unless (position-transform camera-left) (setf (position-transform camera-left) (make-gl-double-vector 16)) (initialize-transform (position-transform camera-left))) (unless (position-transform camera-right) (setf (position-transform camera-right) (make-gl-double-vector 16)) (initialize-transform (position-transform camera-right))) ;colors ;left = red ;right = blue ;set camera eye offset (setf (xyz-x (eye camera-left)) (- *om-3d-anaglyph-eye-dist*)) (setf (xyz-x (eye camera-right)) *om-3d-anaglyph-eye-dist*) ;clear depth and color buffers for back buffer (opengl:gl-draw-buffer opengl:*gl-back*) (opengl:gl-clear opengl:*gl-color-buffer-bit*) (opengl:gl-clear opengl:*gl-depth-buffer-bit*) ;;;;;;;;RED;;;;;;;;;;;;; ;set the rendering buffer for red (opengl:gl-draw-buffer opengl:*gl-back-left*) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:gl-load-identity) (opengl:gl-color-mask 1 0 0 1) (draw camera-left) ;apply transform and render canvas lights and objects (opengl-redisplay-all canvas) ;;;;CYAN;;;;;;;;;;;; ;set the rendering buffer for cyan (opengl:gl-draw-buffer opengl:*gl-back-right*) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:gl-load-identity) (opengl:gl-color-mask 0 1 1 1) (draw camera-right) ;apply transform and render canvas lights and objects (opengl-redisplay-all canvas) ) ) ;;; USER INTERACTION (defmethod opengl-viewer-click (canvas x y) (setf (lastxy canvas) (cons x y))) (defmethod opengl-viewer-shift-click (canvas x y) (opengl-viewer-click canvas x y)) (defmethod opengl-viewer-alt-click (canvas x y) (opengl-viewer-click canvas x y)) (defmethod opengl-viewer-motion-click (canvas x y) (unless (icotransform canvas) (initialize-viewer canvas)) (let ((last (lastxy canvas))) (when last (opengl:rendering-on (canvas) (polar-rotate-icosahedron canvas :dz (* 2 (- x (car last))) :dx (* 2 (- y (cdr last))))) (opengl-redisplay-canvas canvas)) (setf (lastxy canvas) (cons x y)))) (defmethod opengl-viewer-motion-shift-click (canvas x y) (unless (icotransform canvas) (initialize-viewer canvas)) (let ((last (lastxy canvas))) (when last (let ((eye (eye (camera canvas)))) (setf (xyz-y eye) (min (- (xyz-y eye) (* (/ (- (cdr last) y) 20) (/ (xyz-y eye) 20))) -0.1d0)) ) (opengl-redisplay-canvas canvas)) (setf (lastxy canvas) (cons x y)))) (defmethod opengl-viewer-motion-alt-click (canvas x y) (unless (icotransform canvas) (initialize-viewer canvas)) (let ((last (lastxy canvas))) (when last (opengl:rendering-on (canvas) (translate-icosahedron canvas (- (car last) x) (- y (cdr last)) )) (opengl-redisplay-canvas canvas)) (setf (lastxy canvas) (cons x y)))) (defmethod opengl-viewer-double-click (canvas x y) nil) ;; handles key press using CAPI 'gesture-spec' ;; to be redefined in opengl-view (defmethod opengl-viewer-key-pressed (canvas x y spec) nil) ;(defmethod init-3D-view ((self opengl-view)) ; (init-camera (camera self)) ; (setf (aspect (projection (camera self))) ; (coerce (/ (capi::pane-width self) (capi::pane-height self)) 'double-float)) ; (initialize-viewer self) ; (opengl-redisplay-canvas self))
27,062
Common Lisp
.lisp
593
38.605396
129
0.611518
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
40fb92c9e6bdca576e9f6a632f0bbb1d11d0f67c71fecc842b17b8a2eccbb77b
801
[ -1 ]
802
om-opengl-view.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/om-opengl-view.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;====================== ;;; MIXED VIEW INHERITING FROM OM-VIEW (OM-API) and OPENGL-VIEW (GL-USER) ;;;====================== (in-package :om) (defvar *OM-GL-DEFAULT-LINEWIDTH* 2.0) (defvar *OM-GL-DEFAULT-COLOR* (list 0.0 0.0 0.0 1.0)) (defclass om-opengl-view (gl-user::opengl-view om-view) ()) ;;; called from 3D-lines draw-contenst (?) (defmethod restore-om-gl-colors-and-attributes () (opengl:gl-color4-f (nth 0 *OM-GL-DEFAULT-COLOR*) (nth 1 *OM-GL-DEFAULT-COLOR*) (nth 2 *OM-GL-DEFAULT-COLOR*) (nth 3 *OM-GL-DEFAULT-COLOR*)) (opengl:gl-line-width *OM-GL-DEFAULT-LINEWIDTH*) (opengl:gl-enable opengl:*gl-point-size*) (opengl:gl-enable opengl:*gl-point-smooth*)) (defmethod initialize-instance :after ((self om-opengl-view) &key &allow-other-keys) (mapcar #'(lambda (o) (setf (gl-user::viewer o) self)) (gl-user::g-objects self)) (when (om-get-bg-color self) (setf (gl-user::bgcolor (gl-user::camera self)) (om-color-to-single-float-list (om-get-bg-color self)))) ) (defmethod om-set-bg-color ((self om-opengl-view) color) (call-next-method) (setf (gl-user::bgcolor (gl-user::camera self)) (om-color-to-single-float-list (om-get-bg-color self)))) (defmethod om-color-to-single-float-list (color) (list (coerce (om-color-r color) 'single-float) (coerce (om-color-g color) 'single-float) (coerce (om-color-b color) 'single-float) (coerce (or (om-color-a color) 1.0) 'single-float))) (defmethod oa::om-invalidate-view ((self om-opengl-view)) (gl-user::opengl-redisplay-canvas self)) (defmethod gl-user::clear-gl-display-list ((viewer om-opengl-view)) (opengl:rendering-on (viewer) (mapcar #'gl-user::delete-display-list (gl-user::g-objects viewer)))) (defmethod gl-user::draw-contents ((self om-opengl-view)) (oa::om-draw-contents self)) ; to be redefined by subclasses (defmethod oa::om-draw-contents ((self om-opengl-view)) nil) (defmethod gl-user::opengl-viewer-click ((self om-opengl-view) x y) (call-next-method) (om-view-click-handler self (omp x y))) (defmethod gl-user::opengl-viewer-key-pressed ((self om-opengl-view) x y spec) (oa::om-char-spec-callback self x y spec)) (defmethod gl-user::opengl-viewer-double-click ((self om-opengl-view) x y) (om-init-3d-view self)) (defmethod om-init-3D-view ((self om-opengl-view)) (gl-user::initialize-viewer self) (om-adapt-camera-to-object self) (gl-user::clear-gl-display-list self) (gl-user::opengl-redisplay-canvas self)) (defmethod zoom-view ((self om-opengl-view) factor) (let ((eye (gl-user::eye (gl-user::camera self))) (fact (if (= factor 0) 1 (/ 1 factor)))) (setf (gl-user::xyz-y eye) (min (* (gl-user::xyz-y eye) fact) -0.1d0))) (gl-user::opengl-redisplay-canvas self)) (defmethod om-get-gl-objects ((self om-opengl-view)) (gl-user::get-gl-object-list self)) (defmethod om-set-gl-objects ((self om-opengl-view) (obj gl-user::gl-object)) (gl-user::set-gl-object-list self (list obj))) (defmethod om-set-gl-objects ((self om-opengl-view) (objlist list)) (gl-user::set-gl-object-list self objlist)) (defmethod om-get-default-extents ((self om-opengl-view)) (values -1.0 1.0 -1.0 1.0 -1.0 1.0)) (defmethod om-adapt-camera-to-object ((self om-opengl-view)) (multiple-value-bind (x1 x2 y1 y2 z1 z2) (get-extents (om-get-gl-objects self)) (multiple-value-bind (defx1 defx2 defy1 defy2 defz1 defz2) (om-get-default-extents self) (let ((xmi (or x1 defx1)) (xma (or x2 defx2)) (ymi (or y1 defy1)) (yma (or y2 defy2)) (zmi (or z1 defz1)) (zma (or z2 defz2))) (let* ((dist-z (* 2.5d0 (max 1.0d0 (abs xmi) (abs xma) (abs ymi) (abs yma) (abs zmi) (abs zma)))) (far-z (max 20.0d0 (* 5.0d0 dist-z)))) ; (om-print-dbg "dist: ~A - far: ~A" (list dist-z far-z) "OPENGL") (setf (gl-user::eye (gl-user::camera self)) (gl-user::make-xyz :x 0.0D0 :y (- dist-z) :z 0.0d0)) (setf (gl-user::far (gl-user::projection (gl-user::camera self))) far-z) )) )))
4,829
Common Lisp
.lisp
94
47.202128
142
0.620008
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
b1200af1268b3bd809cbef85736dbdf6ff744f17006cb14d090910a43934ca82
802
[ -1 ]
803
om-3d-object.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/om-3d-object.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;====================== ;;; om-3D-object ;;;====================== (defclass om-3D-object (gl-user::gl-object) ((color :accessor color :initarg :color :initform nil) (points :initarg :points :accessor points :initform nil) (glvertexes :accessor glvertexes :initarg :glvertexes :initform nil)) (:default-initargs :use-display-list nil)) ; for 3D objects we copy only the initargs (as for omobjects) (defmethod condition-for-copy-slot ((from om-3D-object) (to t) slot) (and (call-next-method) (slot-definition-initargs slot))) (defun points2vertex (points) (gl-user::make-object-vertexes (mapcar #'(lambda (p) (list (coerce (car p) 'double-float) (coerce (cadr p) 'double-float) (coerce (caddr p) 'double-float) 1.0d0)) points))) (defmethod initialize-instance :after ((self om-3D-object) &key points &allow-other-keys) (let ((pts (or points (points self)))) (setf (glvertexes self) (points2vertex pts)))) (defmethod gl-user::draw ((self om-3D-object)) (activate-anti-aliasing-parameters) (om-draw-contents self)) ; anti aliasing things. Warning: if depth enable it may not work... (defun activate-anti-aliasing-parameters () (opengl:gl-enable opengl:*gl-blend*) (opengl:gl-enable opengl:*gl-line-smooth*) (opengl:gl-blend-func opengl:*gl-src-alpha* opengl:*gl-one-minus-src-alpha*) (opengl:gl-hint opengl:*gl-line-smooth-hint* opengl:*gl-dont-care*) ) (defmethod om-draw-contents ((self om-3D-object)) nil) (defmethod om-get-gl-points ((self om-3D-object)) (glvertexes self)) (defmethod om-3Dobj-points ((self om-3D-object)) (points self)) (defmethod om-set-3Dobj-points ((self om-3D-object) points) (setf (points self) points) (setf (glvertexes self) (points2vertex points)) self) (defmethod om-update-3Dobj ((self om-3D-object)) (setf (glvertexes self) (points2vertex (points self)))) ; naive implementation (defmethod om-append-3Dobj-point ((self om-3D-object) point) (setf (points self) (append (points self) point)) (setf (glvertexes self) (points2vertex (points self)))) (defmethod om-3Dobj-color ((self om-3D-object)) (color self)) (defmethod get-extents ((self om-3D-object)) (when (om-3Dobj-points self) (let* ((x-y-z (mat-trans (om-3Dobj-points self))) (xpts (nth 0 x-y-z)) (ypts (nth 1 x-y-z)) (zpts (nth 2 x-y-z))) (values (reduce 'min xpts) (reduce 'max xpts) (reduce 'min ypts) (reduce 'max ypts) (reduce 'min zpts) (reduce 'max zpts))))) (defmethod get-extents ((self list)) (let (xmins xmaxs ymins ymaxs zmins zmaxs) (when self (loop for elt in self do (multiple-value-bind (xmin xmax ymin ymax zmin zmax) (get-extents elt) (when xmin (push xmin xmins) (push xmax xmaxs) (push ymin ymins) (push ymax ymaxs) (push zmin zmins) (push zmax zmaxs)))) (when xmins (values (reduce 'min xmins) (reduce 'max xmaxs) (reduce 'min ymins) (reduce 'max ymaxs) (reduce 'min zmins) (reduce 'max zmaxs)))))) ;;;;;;;;;;;;;LIST OF 3D OBJ;;;;;;;;;;;;; #| (defclass om-3D-object-list (gl-user::gl-object) ((objects :accessor objects :initarg :objects :initform nil))) (defmethod gl-user::draw ((self om-3D-object-list)) (mapcar 'om-draw-contents (objects self))) (defmethod om-get-3D-objects ((self om-3D-object-list)) (objects self)) (defmethod om-3Dobj-points ((self om-3D-object-list)) (apply 'append (mapcar 'om-3Dobj-points (objects self)))) (defmethod set-draw-style ((self om-3D-object-list) val) (mapcar #'(lambda (curve) (set-draw-style curve val)) (om-get-3D-objects self))) |# ;;; COMMENT: /* QuadricDrawStyle */ ;;; DEFINE: #define GLU_POINT 100010 (defconstant GLU_POINT 100010) ;;; DEFINE: #define GLU_LINE 100011 (defconstant GLU_LINE 100011) ;;; DEFINE: #define GLU_FILL 100012 (defconstant GLU_FILL 100012) ;;; DEFINE: #define GLU_SILHOUETTE 100013 (defconstant GLU_SILHOUETTE 100013) (defun draw-gl-point (x y z rgb alpha size) (opengl:gl-color4-f (nth 0 rgb) (nth 1 rgb) (nth 2 rgb) alpha) (opengl:gl-point-size size) (opengl:gl-begin opengl:*gl-points*) (opengl:gl-vertex3-f x y z) (opengl:gl-end)) (defun draw-sphere (position radius) (let* ((r (coerce radius 'double-float)) (x (float (car position))) (y (float (cadr position))) (z (float (caddr position))) (glu-quad (opengl:glu-new-quadric))) (opengl:gl-push-matrix) (opengl:gl-translatef x y z) (opengl:glu-quadric-draw-style glu-quad GLU_FILL) (opengl:glu-sphere glu-quad r 20 20) (opengl:gl-pop-matrix) )) (defun draw-cone (position size angle rotation_point) (let* ((hs (coerce (/ size 2) 'double-float)) (x (car position)) (y (cadr position)) (z (caddr position)) (rx (car rotation_point)) (ry (cadr rotation_point)) (rz (caddr rotation_point)) (glu-quad (opengl:glu-new-quadric))) (opengl:gl-push-matrix) (opengl:gl-translatef x y z) (opengl:gl-rotatef angle rx ry rz) (opengl:glu-quadric-draw-style glu-quad GLU_FILL) (opengl:glu-cylinder glu-quad hs 0.0d0 hs 20 20) (opengl:gl-pop-matrix) )) (defun draw-cube (position size faces) (let* ((hs (/ size 2)) (x (car position)) (y (cadr position)) (z (caddr position)) (cube-points (list (list (- x hs) (- y hs) (- z hs)) (list (+ x hs) (- y hs) (- z hs)) (list (+ x hs) (- y hs) (+ z hs)) (list (- x hs) (- y hs) (+ z hs)) (list (- x hs) (+ y hs) (- z hs)) (list (+ x hs) (+ y hs) (- z hs)) (list (+ x hs) (+ y hs) (+ z hs)) (list (- x hs) (+ y hs) (+ z hs))))) (if faces (opengl:gl-begin opengl:*GL-QUADS*) (opengl:gl-begin opengl:*GL-LINE-LOOP*)) (opengl:gl-normal3-i 0 1 0) (opengl:gl-vertex3-f (car (nth 0 cube-points)) (cadr (nth 0 cube-points)) (caddr (nth 0 cube-points))) (opengl:gl-vertex3-f (car (nth 1 cube-points)) (cadr (nth 1 cube-points)) (caddr (nth 1 cube-points))) (opengl:gl-vertex3-f (car (nth 2 cube-points)) (cadr (nth 2 cube-points)) (caddr (nth 2 cube-points))) (opengl:gl-vertex3-f (car (nth 3 cube-points)) (cadr (nth 3 cube-points)) (caddr (nth 3 cube-points))) (opengl:gl-end) (if faces (opengl:gl-begin opengl:*GL-QUADS*) (opengl:gl-begin opengl:*GL-LINE-LOOP*)) (opengl:gl-normal3-i 0 1 0) (opengl:gl-vertex3-f (car (nth 7 cube-points)) (cadr (nth 7 cube-points)) (caddr (nth 7 cube-points))) (opengl:gl-vertex3-f (car (nth 6 cube-points)) (cadr (nth 6 cube-points)) (caddr (nth 6 cube-points))) (opengl:gl-vertex3-f (car (nth 5 cube-points)) (cadr (nth 5 cube-points)) (caddr (nth 5 cube-points))) (opengl:gl-vertex3-f (car (nth 4 cube-points)) (cadr (nth 4 cube-points)) (caddr (nth 4 cube-points))) (opengl:gl-end) (if faces (opengl:gl-begin opengl:*GL-QUADS*) (opengl:gl-begin opengl:*GL-LINES*)) (opengl:gl-vertex3-f (car (nth 3 cube-points)) (cadr (nth 3 cube-points)) (caddr (nth 3 cube-points))) (opengl:gl-vertex3-f (car (nth 7 cube-points)) (cadr (nth 7 cube-points)) (caddr (nth 7 cube-points))) (opengl:gl-vertex3-f (car (nth 4 cube-points)) (cadr (nth 4 cube-points)) (caddr (nth 4 cube-points))) (opengl:gl-vertex3-f (car (nth 0 cube-points)) (cadr (nth 0 cube-points)) (caddr (nth 0 cube-points))) (opengl:gl-vertex3-f (car (nth 5 cube-points)) (cadr (nth 5 cube-points)) (caddr (nth 5 cube-points))) (opengl:gl-vertex3-f (car (nth 1 cube-points)) (cadr (nth 1 cube-points)) (caddr (nth 1 cube-points))) (opengl:gl-vertex3-f (car (nth 0 cube-points)) (cadr (nth 0 cube-points)) (caddr (nth 0 cube-points))) (opengl:gl-vertex3-f (car (nth 4 cube-points)) (cadr (nth 4 cube-points)) (caddr (nth 4 cube-points))) (opengl:gl-vertex3-f (car (nth 6 cube-points)) (cadr (nth 6 cube-points)) (caddr (nth 6 cube-points))) (opengl:gl-vertex3-f (car (nth 2 cube-points)) (cadr (nth 2 cube-points)) (caddr (nth 2 cube-points))) (opengl:gl-vertex3-f (car (nth 1 cube-points)) (cadr (nth 1 cube-points)) (caddr (nth 1 cube-points))) (opengl:gl-vertex3-f (car (nth 5 cube-points)) (cadr (nth 5 cube-points)) (caddr (nth 5 cube-points))) (opengl:gl-vertex3-f (car (nth 2 cube-points)) (cadr (nth 2 cube-points)) (caddr (nth 2 cube-points))) (opengl:gl-vertex3-f (car (nth 6 cube-points)) (cadr (nth 6 cube-points)) (caddr (nth 6 cube-points))) (opengl:gl-vertex3-f (car (nth 7 cube-points)) (cadr (nth 7 cube-points)) (caddr (nth 7 cube-points))) (opengl:gl-vertex3-f (car (nth 3 cube-points)) (cadr (nth 3 cube-points)) (caddr (nth 3 cube-points))) (opengl:gl-end))) ;;;====================== ;;; 3D-cube ;;;====================== (defclass 3D-cube (om-3D-object) ((center :accessor center :initarg :center :initform nil) (size :accessor size :initarg :size :initform nil) (color :accessor color :initarg :color :initform nil) (filled :accessor filled :initarg :filled :initform t ) (faces :accessor faces :initform '((1 2 3 4) (1 4 8 5) (5 8 7 6) (6 7 3 2) (4 3 7 8) (2 1 5 6))) (normals :accessor normals :initform '((0 1 0) (1 0 0) (0 -1 0) (-1 0 0) (0 0 -1) (0 0 1)))) ) (defmethod initialize-instance :after ((self 3D-cube) &rest initargs) (when (and (center self) (size self)) (let* ((hw (* 0.5 (if (listp (size self)) (car (size self)) (size self)))) (hd (* 0.5 (if (listp (size self)) (cadr (size self)) (size self)))) (hh (* 0.5 (if (listp (size self)) (caddr (size self)) (size self)))) (x (car (center self))) (y (cadr (center self))) (z (caddr (center self))) (p1 (list (- x hw) (- y hd) (- z hh))) (p2 (list (+ x hw) (- y hd) (- z hh))) (p3 (list (+ x hw) (- y hd) (+ z hh))) (p4 (list (- x hw) (- y hd) (+ z hh))) (p5 (list (- x hw) (+ y hd) (- z hh))) (p6 (list (+ x hw) (+ y hd) (- z hh))) (p7 (list (+ x hw) (+ y hd) (+ z hh))) (p8 (list (- x hw) (+ y hd) (+ z hh)))) (om-set-3Dobj-points self (list p1 p2 p3 p4 p5 p6 p7 p8)) ))) (defmethod make-cube-face ((self 3D-cube) i &optional (fill t)) ) (defmethod om-draw-contents ((self 3D-cube)) (let* ((vertices (om-get-gl-points self))) (when (om-3Dobj-color self) (let ((col (om-color-to-single-float-list (om-3Dobj-color self)))) (opengl:gl-color4-f (car col) (cadr col) (caddr col) (cadddr col)))) (opengl:gl-shade-model opengl:*gl-flat*) (when (filled self) (loop for f in (faces self) for n in (normals self) do ;for i from 1 do (progn ;(find i '(1) :test '=) (opengl:gl-begin opengl:*GL-QUADS*) (loop for p in f do ;(apply 'opengl:gl-normal3-i n) (opengl:gl-vertex4-dv (aref vertices (1- p))) ;(apply 'opengl:gl-normal3-i n) ) (opengl:gl-end))) ) (opengl:gl-color3-f 0.3 0.3 0.3) (loop for f in (faces self) do (opengl:gl-begin opengl:*GL-LINE-LOOP*) (loop for p in f do (opengl:gl-vertex4-dv (aref vertices (1- p)))) (opengl:gl-end)) )) ;;;====================== ;;; SPHERE ;;;====================== (defclass 3D-sphere (om-3D-object) ((center :accessor center :initarg :center :initform '(0 0 0)) (radius :accessor radius :initarg :radius :initform 1.0) (color :accessor color :initarg :color :initform nil))) (defmethod initialize-instance :after ((self 3D-sphere) &rest initargs) (when (center self) ;; temporary: the poinst are also used for calculating the bounding-box (om-set-3Dobj-points self (list (center self))) )) (defmethod get-extents ((self 3D-sphere)) (when (and (center self) (radius self)) (values (- (nth 0 (center self)) (radius self)) (+ (nth 0 (center self)) (radius self)) (- (nth 1 (center self)) (radius self)) (+ (nth 1 (center self)) (radius self)) (- (nth 2 (center self)) (radius self)) (+ (nth 2 (center self)) (radius self))) )) (defmethod om-draw-contents ((self 3D-sphere)) (if (om-3Dobj-color self) (let ((col (om-color-to-single-float-list (om-3Dobj-color self)))) (opengl:gl-color4-f (car col) (cadr col) (caddr col) (cadddr col)))) (opengl:gl-shade-model opengl:*gl-smooth*) (draw-sphere (center self) (radius self))) ;;;====================== ;;; 3D-curve ;;;====================== (defclass 3d-lines (om-3d-object) (;; visible / initargs: (points :initarg :points :accessor points :initform nil) (color :accessor color :initarg :color :initform nil) (line-width :accessor line-width :initarg :line-width :initform 2.0) (draw-style :accessor draw-style :initarg :draw-style :initform :default) ;; hidden: (selected-points :accessor selected-points :initform nil) (vertices-colors :accessor vertices-colors :initform nil) (vertices-colors-interpol :accessor vertices-colors-interpol :initform nil)) (:default-initargs :use-display-list T)) (defmethod om-draw-contents ((self 3d-lines)) (let* ((vertices (om-get-gl-points self)) (size (- (length vertices) 1)) (selection (selected-points self))) (opengl:gl-enable opengl:*gl-light0*) (opengl:gl-line-width (float (line-width self))) ;draw the lines first (when (and (not (equal (draw-style self) :points)) (> size 0)) (if (vertices-colors-interpol self) (opengl:gl-shade-model opengl:*gl-smooth*) (opengl:gl-shade-model opengl:*gl-flat*)) (opengl:gl-begin opengl:*GL-LINE-STRIP*) (loop for i from 0 to size do (let ((rgb (om-color-to-single-float-list (or (nth i (vertices-colors self)) (om-3Dobj-color self) (om-def-color :white))))) (opengl:gl-color4-f (nth 0 rgb) (nth 1 rgb) (nth 2 rgb) 0.8) (opengl:gl-vertex4-dv (aref vertices i)))) (opengl:gl-end) ) ;draw the sphere and the selection (as bigger opaque sphere) (when (not (equal (draw-style self) :lines)) (loop for i from 0 to size do (let* ((rgb (or (nth i (vertices-colors self)) (om-3Dobj-color self) (om-def-color :white))) (selected (or (equal '(t) selection) (find i selection))) (alpha (if selected 1.0 0.7)) (point (nth i (om-3dobj-points self))) (x (float (car point))) (y (float (cadr point))) (z (float (caddr point)))) (when selected (setf rgb (om-def-color :dark-red))) (setf rgb (om-color-to-single-float-list rgb)) (draw-gl-point x y z rgb alpha (* 3.0 (line-width self))) )))) ;restore gl params (restore-om-gl-colors-and-attributes) ) ;;;====================== ;;; FOR .obj files ;to do... harder than expected to match faces and vertexes. ;;;====================== ;code reusing globjule functions (defclass 3D-fromobjfile (om-3D-object)()) (defmethod om-draw-contents ((self 3D-fromobjfile)) nil) (defmethod load-3Dobj-from-file (path) (let ((obj (make-instance '3d-fromobjfile)) (points nil)) (with-open-file (stream path) (loop while (peek-char nil stream nil nil) do (case (intern (string-upcase (read-string-token stream)) :keyword) (:v (setf points (append (list (read-vec stream)) points)))) )) (setf points (reverse points)) (om-set-3Dobj-points obj points) obj)) (defun read-vec (stream &optional (n 3)) (let ((vec nil)) (dotimes (i n) (setf vec (append (list (read stream)) vec))) vec)) (defun read-string-token (stream) (read-until stream #\Space)) (defun read-token (stream) (read (read-string-token stream))) (defun read-until (stream character) (when (typep stream 'string) (setf stream (make-string-input-stream stream))) (loop with head for c = (read-char stream nil nil) if (or (not c) (char= c character) (char= c #\Newline)) do (return (coerce (reverse head) 'string)) else do (push c head)))
17,926
Common Lisp
.lisp
394
37.972081
106
0.575709
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
374070d362c1335275c3fab9f99d178b824dc0eb98780bcf7a7330ea981791d8
803
[ -1 ]
804
win32.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/win32.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/win32.lisp,v 1.10.1.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "WIN32") ;;; From WINGDI.H ;;; /* pixel types */ (defconstant *PFD-TYPE-RGBA* 0) (defconstant *PFD-TYPE-COLORINDEX* 1) ;;; /* layer types */ (defconstant *PFD-MAIN-PLANE* 0) (defconstant *PFD-OVERLAY-PLANE* 1) (defconstant *PFD-UNDERLAY-PLANE* -1) ;;; /* PIXELFORMATDESCRIPTOR flags */ (defconstant *PFD-DOUBLEBUFFER* #x00000001) (defconstant *PFD-STEREO* #x00000002) (defconstant *PFD-DRAW-TO-WINDOW* #x00000004) (defconstant *PFD-DRAW-TO-BITMAP* #x00000008) (defconstant *PFD-SUPPORT-GDI* #x00000010) (defconstant *PFD-SUPPORT-OPENGL* #x00000020) (defconstant *PFD-GENERIC-FORMAT* #x00000040) (defconstant *PFD-NEED-PALETTE* #x00000080) (defconstant *PFD-NEED-SYSTEM-PALETTE* #x00000100) (defconstant *PFD-SWAP-EXCHANGE* #x00000200) (defconstant *PFD-SWAP-COPY* #x00000400) ;;; /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */ (defconstant *PFD-DOUBLEBUFFER-DONTCARE* #x40000000) (defconstant *PFD-STEREO-DONTCARE* #x80000000) (fli:define-c-struct (tag-pixel-format-descriptor (:foreign-name "tagPIXELFORMATDESCRIPTOR")) (nSize WORD) (nVersion WORD) (dwFlags DWORD) (iPixelType BYTE) (cColorBits BYTE) (cRedBits BYTE) (cRedShift BYTE) (cGreenBits BYTE) (cGreenShift BYTE) (cBlueBits BYTE) (cBlueShift BYTE) (cAlphaBits BYTE) (cAlphaShift BYTE) (cAccumBits BYTE) (cAccumRedBits BYTE) (cAccumGreenBits BYTE) (cAccumBlueBits BYTE) (cAccumAlphaBits BYTE) (cDepthBits BYTE) (cStencilBits BYTE) (cAuxBuffers BYTE) (iLayerType BYTE) (bReserved BYTE) (dwLayerMask DWORD) (dwVisibleMask DWORD) (dwDamageMask DWORD)) (fli:define-c-typedef (pixel-format-descriptor (:foreign-name "PIXELFORMATDESCRIPTOR")) (:struct tag-pixel-format-descriptor)) (fli:define-c-typedef (hglrc (:foreign-name "HGLRC")) HANDLE) (fli:define-foreign-function (get-pixel-format "GetPixelFormat") ((hdc HDC)) :result-type :int :documentation "Obtains the index of the specified device context's currently selected pixel format." :language :ansi-c) (fli:define-foreign-function (choose-pixel-format "ChoosePixelFormat") ((hdc HDC) (pfd (:ptr pixel-format-descriptor))) :result-type :int :documentation "Attempts to find the pixel format supported by a device context that is the best match to a given pixel format specification." :language :ansi-c) (fli:define-foreign-function (set-pixel-format "SetPixelFormat") ((hdc HDC) (iPixelFormat :int) (pfd (:ptr pixel-format-descriptor))) :result-type BOOL :documentation "Sets the specified device context's pixel format to the format specified by the iPixelFormat index" :language :ansi-c) (fli:define-foreign-function (%describe-pixel-format "DescribePixelFormat") ((hdc HDC) (iPixelFormat :int) (nBytes :int) (pfd (:ptr pixel-format-descriptor))) :result-type :int :documentation "Obtains information about the pixel format identified by iPixelFormat of the device associated with hdc. The function sets the members of the PIXELFORMATDESCRIPTOR structure pointed to by ppfd with that pixel format information." :language :ansi-c) (defun describe-pixel-format (hdc ipfd pfd) (%describe-pixel-format hdc ipfd (fli:size-of 'pixel-format-descriptor) pfd)) ;;; ------------------------------------------------------------ ;;; (fli:define-foreign-function (wgl-create-context "wglCreateContext") ((hdc HDC)) :documentation "Creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by hdc. The rendering context has the same pixel format as the device context." :result-type HGLRC :language :ansi-c) (fli:define-foreign-function (wgl-make-current "wglMakeCurrent") ((hdc HDC) (hglrc HGLRC)) :documentation "Makes a specified OpenGL rendering context the calling thread's current rendering context. All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc. You can also use wglMakeCurrent to make the calling thread's current rendering context not current." :result-type BOOL :language :ansi-c) (fli:define-foreign-function (wgl-delete-context "wglDeleteContext") ((hglrc HGLRC)) :result-type BOOL :language :ansi-c) (fli:define-foreign-function (wgl-get-current-context "wglGetCurrentContext") () :result-type HGLRC :language :ansi-c) (fli:define-foreign-function (wgl-get-current-dc "wglGetCurrentDC") () :result-type HDC :language :ansi-c) (fli:define-foreign-function (swap-buffers "SwapBuffers") ((hdc HDC)) :result-type BOOL :language :ansi-c) ;;; ---------------------------------------------------------------------- ;;; Support for text within double buffered OpenGL panes ;;; ---------------------------------------------------------------------- (defconstant TMPF_TRUETYPE #x04) (defconstant *WGL-FONT-LINES* 0) (defconstant *WGL-FONT-POLYGONS* 1) ;;; For extruded 3D fonts (fli:define-c-struct _POINTFLOAT (x :float) (y :float)) (fli:define-c-typedef POINTFLOAT (:struct _POINTFLOAT)) (fli:define-c-struct _GLYPHMETRICSFLOAT (gmfBlackBoxX :float) (gmfBlackBoxY :float) (gmfptGlyphOrigin POINTFLOAT) (gmfCellIncX :float) (gmfCellIncY :float)) (fli:define-c-typedef GLYPHMETRICSFLOAT (:struct _GLYPHMETRICSFLOAT)) (fli:define-foreign-function ( win32::wgl-use-font-outlines "wglUseFontOutlines" :dbcs) ((hdc HDC) (first DWORD) (count DWORD) (list-base DWORD) (deviation :float) (extrusion :float) (format :int) (lpgmf :pointer)) ;;LPGLYPHMETRICSFLOAT :result-type BOOL :language :ansi-c) ;;; Convert a font to a bitmap. (fli:define-foreign-function (win32::wgl-use-font-bitmaps "wglUseFontBitmaps" :dbcs) ((hdc HDC) (first DWORD) (count DWORD) (list-base DWORD)) :result-type BOOL) ;;; (WGL-USE-FONT OPENGL-PANE &key FONT OUTLINEP DEVIATION ;;; EXTRUSION GLYPH-METRIC-POINTER ;;; START COUNT ERRORP LIST-BASE) ;;; Create a display-list for a given font. ;;; Arguments : ;;; OPENGL-PANE : OPENGL-PANE ;;; FONT : capi font specification. If no font is specified then the ;;; font for the OPENGL-PANE will be used. ;;; OUTLINEP : BOOLEAN - When NULL - A display list containing bitmap representation ;;; of each font character will be generated. ;;; Otherwise - A display list containing 3d character representation ;;; for each font character will be generated. (Note that ;;; the font must be TrueType in this case) ;;; DEVIATION : FLOAT - chordal deviation from the original outlines ;;; EXTRUSION : FLOAT - how much the font is extruded in the negative z direction. ;;; GLYPH-METRIC-POINTER : Foreign pointer to an array (length COUNT) of GLYPHMETRICSFLOAT ;;; Structures that recieve the glyph metrics. If NIL is passed in ;;; then no data will be stored. ;;; START : INTEGER - First of the set of glyphs which will form the display-list ;;; COUNT : INTEGER - Number of glyphs to be used in the creation of the display-list. ;;; ERRORP : BOOLEAN - When true, an error will be signaled when a glerror occurs. ;;; Otherwise NIL will be returned from the WGL-USE-FONT ;;; LIST-BASE : INTEGER - Specifies the start of the display-list. ;;; RESULTS : ;;; The list-base used for creating the font (or NIL indicating an error). ;;; Note that once the font list (pointed to by the list-base) is no longer ;;; required then it should be destroyed by calling OPENGL:GL-DELETE-LISTS (defun wgl-use-font (opengl-pane &key (font (gp::get-port-font opengl-pane)) outlinep (deviation 0.0) (extrusion 0.1) glyph-metric-pointer (start 32) (count 224) (errorp t) (list-base (opengl:gl-gen-lists count))) (let ((gpfont (gp:lookup-font opengl-pane font)) (hdc (win32::wgl-get-current-dc))) (unwind-protect (progn (realize-tool gpfont) (when (and outlinep (not (logtest TMPF_TRUETYPE (logical-font-textmetric-pitch gpfont)))) (opengl:gl-delete-lists list-base count) (case errorp (:warn (warn "~s : Outline font must be a TrueType font." 'wgl-use-font)) ((nil) nil) (otherwise (error "~s : Outline font must be a TrueType font." 'wgl-use-font))) (return-from wgl-use-font nil)) (select-object hdc (drawing-tool-handle gpfont)) ;; For some reason - OpenGL on NT sometimes fails to ;; create the font the first time around. Not sure of ;; the reason why. The simple fix is if the creation ;; of the font fails the first time - try calling ;; wglUseFont... again to make sure that there really ;; is some form or error??? (unless (if outlinep (let ((format (if (eq outlinep :lines) *WGL-FONT-LINES* *WGL-FONT-POLYGONS*))) (or (win32::wgl-use-font-outlines hdc start count list-base deviation extrusion format glyph-metric-pointer) (win32::wgl-use-font-outlines hdc start count list-base deviation extrusion format glyph-metric-pointer))) (or (win32::wgl-use-font-bitmaps hdc start count list-base) (win32::wgl-use-font-bitmaps hdc start count list-base))) (unwind-protect (let ((windows-error-message (win32:get-last-error))) (case errorp (:warn (warn "~S failed : (getLastError = ~d) " 'wgl-use-font windows-error-message)) ((nil) nil) (otherwise (error "~S failed : (getLastError = ~d)" 'wgl-use-font windows-error-message)))) (opengl:gl-delete-lists list-base count) (return-from wgl-use-font nil))) list-base) (unrealize-tool gpfont))))
11,341
Common Lisp
.lisp
241
38.917012
151
0.609811
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
af059ca0f04c3c3071634f2d46056786e1a84d4c5dd615e8d451520fa90fac67
804
[ -1 ]
805
types.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/types.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/types.lisp,v 1.5.5.2 2014/06/05 12:08:37 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") (fli:define-c-typedef (glenum (:foreign-name "GLenum")) (:unsigned :int)) (fli:define-c-typedef (glboolean (:foreign-name "GLboolean")) (:unsigned :char)) (fli:define-c-typedef (glbitfield (:foreign-name "GLbitfield")) (:unsigned :int)) (fli:define-c-typedef (glbyte (:foreign-name "GLbyte")) (:signed :char)) (fli:define-c-typedef (glshort (:foreign-name "GLshort")) (:signed :short)) (fli:define-c-typedef (glint (:foreign-name "GLint")) (:signed :int)) (fli:define-c-typedef (glsizei (:foreign-name "GLsizei")) (:signed :int)) (fli:define-c-typedef (glubyte (:foreign-name "GLubyte")) (:unsigned :char)) (fli:define-c-typedef (glushort (:foreign-name "GLushort")) (:unsigned :short)) (fli:define-c-typedef (gluint (:foreign-name "GLuint")) (:unsigned :int)) (fli:define-c-typedef (glfloat (:foreign-name "GLfloat")) :float) (fli:define-c-typedef (glclampf (:foreign-name "GLclampf")) :float) (fli:define-c-typedef (gldouble (:foreign-name "GLdouble")) :double) (fli:define-c-typedef (glclampd (:foreign-name "GLclampd")) :double) (fli:define-c-typedef (glvoid (:foreign-name "GLvoid")) :void) (fli:define-c-typedef (glintptr (:foreign-name "GLintptr")) (:pointer-integer :long)) (fli:define-c-typedef (glsizeiptr (:foreign-name "GLsizeiptr")) (:pointer-integer :long)) (fli:define-c-typedef (glchar (:foreign-name "GLchar")) :char) (fli:define-c-typedef glstring-return #+mswindows (w:lpstr :pass-by :reference) #-mswindows (:reference :ef-mb-string))
1,755
Common Lisp
.lisp
42
39.285714
150
0.707101
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
d84b1fafc3ee2a3976ecb49a0d2667ad3bc571e641fc12409d20b1a2cfa3c8a4
805
[ -1 ]
806
ftgl.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/ftgl.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/ftgl.lisp,v 1.2.1.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. ;; An FTGL interface. (cl:defpackage "FTGL" (:export #:ft-error #:ft-glyph-slot #:ft-encoding #:FTGL_RENDER_FRONT #:FTGL_RENDER_BACK #:FTGL_RENDER_SIDE #:FTGL_RENDER_ALL #:ftgl-double #:ftgl-float #:ftglglyph #:ftgl-create-custom-glyph #:ftgl-destroy-glyph #:ftgl-render-glyph #:ftgl-get-glyph-advance #:ftgl-get-glyph-bbox #:ftgl-get-glyph-error #:ftgl-create-bitmap-glyph #:ftgl-create-extrude-glyph #:ftgl-create-outline-glyph #:ftgl-create-pixmap-glyph #:ftgl-create-polygon-glyph #:ftgl-create-texture-glyph #:ftglfont #:ftgl-create-custom-font #:ftgl-destroy-font #:ftgl-attach-file #:ftgl-attach-data #:ftgl-set-font-char-map #:ftgl-get-font-char-map-count #:ftgl-get-font-char-map-list #:ftgl-set-font-face-size #:ftgl-get-font-face-size #:ftgl-set-font-depth #:ftgl-set-font-outset #:ftgl-set-font-display-list #:ftgl-get-font-ascender #:ftgl-get-font-descender #:ftgl-get-font-line-height #:ftgl-get-font-bbox #:ftgl-get-font-advance #:ftgl-render-font #:ftgl-get-font-error #:ftgl-create-bitmap-font #:ftgl-create-buffer-font #:ftgl-create-extrude-font #:ftgl-create-outline-font #:ftgl-create-pixmap-font #:ftgl-create-polygon-font #:ftgl-create-texture-font #:ftgllayout #:ftgl-destroy-layout #:ftgl-get-layout-bbox #:ftgl-render-layout #:ftgl-get-layout-error #:ftgl-create-simple-layout #:ftgl-set-layout-font #:ftgl-get-layout-font #:ftgl-set-layout-line-length #:ftgl-get-layout-line-length #:ftgl-set-layout-alignment #:ftgl-get-layout-alignement #:ftgl-set-layout-line-spacing #:ftgl-get-layout-line-spacing ) ) (in-package "FTGL") ;; Misc FreeType definitions. (fli:define-c-typedef (ft-error (:foreign-name "FT_Error")) :int) (fli:define-c-struct (ft-glyph-slot-rec- (:foreign-name "FT_GlyphSlotRec_") (:forward-reference t))) (fli:define-c-typedef (ft-glyph-slot (:foreign-name "FT_GlyphSlot")) (:pointer (:struct ft-glyph-slot-rec-))) (fli:define-c-enum (ft-encoding- (:foreign-name "FT_Encoding_")) (ft-encoding-none 0) (ft-encoding-ms-symbol 1937337698) (ft-encoding-unicode 1970170211) (ft-encoding-sjis 1936353651) (ft-encoding-gb2312 1734484000) (ft-encoding-big5 1651074869) (ft-encoding-wansung 2002873971) (ft-encoding-johab 1785686113) (ft-encoding-ms-sjis 1936353651) (ft-encoding-ms-gb2312 1734484000) (ft-encoding-ms-big5 1651074869) (ft-encoding-ms-wansung 2002873971) (ft-encoding-ms-johab 1785686113) (ft-encoding-adobe-standard 1094995778) (ft-encoding-adobe-expert 1094992453) (ft-encoding-adobe-custom 1094992451) (ft-encoding-adobe-latin-1 1818326065) (ft-encoding-old-latin-2 1818326066) (ft-encoding-apple-roman 1634889070)) (fli:define-c-typedef (ft-encoding (:foreign-name "FT_Encoding")) (:enum ft-encoding-)) (fli:define-c-typedef ftgl-string-in (:reference-pass :ef-mb-string)) (defconstant FTGL_RENDER_FRONT #x0001) (defconstant FTGL_RENDER_BACK #x0002) (defconstant FTGL_RENDER_SIDE #x0004) (defconstant FTGL_RENDER_ALL #xffff) (fli:define-c-typedef (ftgl-double (:foreign-name "FTGL_DOUBLE")) :double) (fli:define-c-typedef (ftgl-float (:foreign-name "FTGL_FLOAT")) :float) (fli:define-c-struct (-ftglglyph (:foreign-name "_FTGLGlyph") (:forward-reference t))) (fli:define-c-typedef (ftglglyph (:foreign-name "FTGLglyph")) (:struct -ftglglyph)) (fli:define-foreign-function (ftgl-create-custom-glyph "ftglCreateCustomGlyph" :source) ((base (:pointer ftglglyph)) (data (:pointer :void)) (render-callback (:pointer (:function ((:pointer ftglglyph) (:pointer :void) ftgl-double ftgl-double :int (:pointer ftgl-double) (:pointer ftgl-double)) :void))) (destroy-callback (:pointer (:function ((:pointer ftglglyph) (:pointer :void)) :void)))) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-destroy-glyph "ftglDestroyGlyph" :source) ((glyph (:pointer ftglglyph))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-render-glyph "ftglRenderGlyph" :source) ((glyph (:pointer ftglglyph)) (penx ftgl-double) (peny ftgl-double) (render-mode :int) (advancex (:pointer ftgl-double)) (advancey (:pointer ftgl-double))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-glyph-advance "ftglGetGlyphAdvance" :source) ((glyph (:pointer ftglglyph))) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-get-glyph-bbox "ftglGetGlyphBBox" :source) ((glyph (:pointer ftglglyph)) (bounds (:c-array :float 6))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-glyph-error "ftglGetGlyphError" :source) ((glyph (:pointer ftglglyph))) :result-type ft-error :language :ansi-c) (fli:define-foreign-function (ftgl-create-bitmap-glyph "ftglCreateBitmapGlyph" :source) ((glyph ft-glyph-slot)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-create-extrude-glyph "ftglCreateExtrudeGlyph" :source) ((glyph ft-glyph-slot) (depth :float) (front-outset :float) (back-outset :float) (use-display-list :int)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-create-outline-glyph "ftglCreateOutlineGlyph" :source) ((glyph ft-glyph-slot) (outset :float) (use-display-list :int)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-create-pixmap-glyph "ftglCreatePixmapGlyph" :source) ((glyph ft-glyph-slot)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-create-polygon-glyph "ftglCreatePolygonGlyph" :source) ((glyph ft-glyph-slot) (outset :float) (use-display-list :int)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-foreign-function (ftgl-create-texture-glyph "ftglCreateTextureGlyph" :source) ((glyph ft-glyph-slot) (id :int) (x-offset :int) (y-offset :int) (width :int) (height :int)) :result-type (:pointer ftglglyph) :language :ansi-c) (fli:define-c-struct (-ftglfont (:foreign-name "_FTGLFont") (:forward-reference t))) (fli:define-c-typedef (ftglfont (:foreign-name "FTGLfont")) (:struct -ftglfont)) (fli:define-foreign-function (ftgl-create-custom-font "ftglCreateCustomFont" :source) ((font-file-path ftgl-string-in) (data (:pointer :void)) (makeglyph-callback (:pointer (:function (ft-glyph-slot (:pointer :void)) (:pointer ftglglyph))))) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-destroy-font "ftglDestroyFont" :source) ((font (:pointer ftglfont))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-attach-file "ftglAttachFile" :source) ((font (:pointer ftglfont)) (path ftgl-string-in)) :result-type :int :language :ansi-c) (fli:define-foreign-function (ftgl-attach-data "ftglAttachData" :source) ((font (:pointer ftglfont)) (data (:pointer (:const (:unsigned :char)))) (size :size-t)) :result-type :int :language :ansi-c) (fli:define-foreign-function (ftgl-set-font-char-map "ftglSetFontCharMap" :source) ((font (:pointer ftglfont)) (encoding ft-encoding)) :result-type :int :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-char-map-count "ftglGetFontCharMapCount" :source) ((font (:pointer ftglfont))) :result-type (:unsigned :int) :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-char-map-list "ftglGetFontCharMapList" :source) ((font (:pointer ftglfont))) :result-type (:pointer ft-encoding) :language :ansi-c) (fli:define-foreign-function (ftgl-set-font-face-size "ftglSetFontFaceSize" :source) ((font (:pointer ftglfont)) (size (:unsigned :int)) (res (:unsigned :int))) :result-type :int :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-face-size "ftglGetFontFaceSize" :source) ((font (:pointer ftglfont))) :result-type (:unsigned :int) :language :ansi-c) (fli:define-foreign-function (ftgl-set-font-depth "ftglSetFontDepth" :source) ((font (:pointer ftglfont)) (depth :float)) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-set-font-outset "ftglSetFontOutset" :source) ((font (:pointer ftglfont)) (front :float) (back :float)) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-set-font-display-list "ftglSetFontDisplayList" :source) ((font (:pointer ftglfont)) (use-list :int)) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-ascender "ftglGetFontAscender" :source) ((font (:pointer ftglfont))) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-descender "ftglGetFontDescender" :source) ((font (:pointer ftglfont))) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-line-height "ftglGetFontLineHeight" :source) ((font (:pointer ftglfont))) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-bbox "ftglGetFontBBox" :source) ((font (:pointer ftglfont)) (string ftgl-string-in) (len :int) (bounds (:c-array :float 6))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-advance "ftglGetFontAdvance" :source) ((font (:pointer ftglfont)) (string ftgl-string-in)) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-render-font "ftglRenderFont" :source) ((font (:pointer ftglfont)) (string ftgl-string-in) (mode :int)) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-font-error "ftglGetFontError" :source) ((font (:pointer ftglfont))) :result-type ft-error :language :ansi-c) (fli:define-foreign-function (ftgl-create-bitmap-font "ftglCreateBitmapFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-buffer-font "ftglCreateBufferFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-extrude-font "ftglCreateExtrudeFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-outline-font "ftglCreateOutlineFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-pixmap-font "ftglCreatePixmapFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-polygon-font "ftglCreatePolygonFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-create-texture-font "ftglCreateTextureFont" :source) ((file ftgl-string-in)) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-c-struct (-ftgllayout (:foreign-name "_FTGLlayout") (:forward-reference t))) (fli:define-c-typedef (ftgllayout (:foreign-name "FTGLlayout")) (:struct -ftgllayout)) (fli:define-foreign-function (ftgl-destroy-layout "ftglDestroyLayout" :source) ((layout (:pointer ftgllayout))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-bbox "ftglGetLayoutBBox" :source) ((layout (:pointer ftgllayout)) (string ftgl-string-in) (bounds (:c-array :float 6))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-render-layout "ftglRenderLayout" :source) ((layout (:pointer ftgllayout)) (string ftgl-string-in) (mode :int)) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-error "ftglGetLayoutError" :source) ((layout (:pointer ftgllayout))) :result-type ft-error :language :ansi-c) (fli:define-foreign-function (ftgl-create-simple-layout "ftglCreateSimpleLayout" :source) nil :result-type (:pointer ftgllayout) :language :ansi-c) (fli:define-foreign-function (ftgl-set-layout-font "ftglSetLayoutFont" :source) ((arg-1 (:pointer ftgllayout)) (arg-2 (:pointer ftglfont))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-font "ftglGetLayoutFont" :source) ((arg-1 (:pointer ftgllayout))) :result-type (:pointer ftglfont) :language :ansi-c) (fli:define-foreign-function (ftgl-set-layout-line-length "ftglSetLayoutLineLength" :source) ((arg-1 (:pointer ftgllayout)) (arg-2 (:const :float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-line-length "ftglGetLayoutLineLength" :source) ((arg-1 (:pointer ftgllayout))) :result-type :float :language :ansi-c) (fli:define-foreign-function (ftgl-set-layout-alignment "ftglSetLayoutAlignment" :source) ((arg-1 (:pointer ftgllayout)) (arg-2 (:const :int))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-alignement "ftglGetLayoutAlignement" :source) ((arg-1 (:pointer ftgllayout))) :result-type :int :language :ansi-c) (fli:define-foreign-function (ftgl-set-layout-line-spacing "ftglSetLayoutLineSpacing" :source) ((arg-1 (:pointer ftgllayout)) (arg-2 (:const :float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (ftgl-get-layout-line-spacing "ftglGetLayoutLineSpacing" :source) ((arg-1 (:pointer ftgllayout))) :result-type :float :language :ansi-c) (push :ftgl *features*) (fli:register-module "-lftgl")
25,695
Common Lisp
.lisp
573
21.884817
149
0.390018
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
2d91d61a659bc4abcb3d35bb079773acbb7d27fa194c5e779dc507a2e749d689
806
[ -1 ]
807
compile.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/compile.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/compile.lisp,v 1.8.12.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "CL-USER") (load (current-pathname "defsys")) (compile-system "OPENGL" :load t)
315
Common Lisp
.lisp
5
61
153
0.704918
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
78f2457e8ab51799bccea2448348dde86937b0a05987934cda2be18b47f192dc
807
[ -1 ]
808
msw-lib.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/msw-lib.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/msw-lib.lisp,v 1.11.10.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") (defmethod %make-context ((rep ww::r-output-pane) opengl-configuration) (if (set-win32-pixel-format rep opengl-configuration) (win32::wgl-create-context (ww::r-output-pane-hdc rep)) (error "Can't make wgl context for ~s.~%Pixel-format not set" opengl-configuration))) (defmethod %start-rendering ((rep ww::r-output-pane) context) (or (win32::wgl-make-current (ww::r-output-pane-hdc rep) context) (let ((e (win32:get-last-error))) (format t "~%OpenGL %start-rendering failed! last-error ~d (~x)" e e) nil))) (defmethod %stop-rendering ((rep ww::r-output-pane)) (win32::wgl-make-current (ww::r-output-pane-hdc rep) 0)) (defmethod %swap-buffers ((rep ww::r-output-pane) context) (declare (ignore context)) (win32::SWAP-BUFFERS (ww::r-output-pane-hdc rep))) (defmethod %resize-opengl-context ((rep ww::r-output-pane) context width height) (declare (ignore context width height)) ) (defmethod %free-opengl-resources ((rep ww::r-output-pane) context) (when context (win32::WGL-DELETE-CONTEXT context))) ;;; ------------------------------------------------------------ ;;; (defun device-generic-p (rep) (pfd-dw-flag-p rep win32::*PFD-GENERIC-FORMAT*)) (defun device-native-p (rep) (pfd-dw-flag-p rep win32::*PFD-DRAW-TO-WINDOW*)) (defun device-supports-opengl-p (rep) (pfd-dw-flag-p rep win32::*PFD-SUPPORT-OPENGL*)) (defun device-is-rgba-p (rep) (pfd-slot-test rep 'win32::IPIXELTYPE win32::*PFD-TYPE-RGBA*)) (defun device-is-color-buffer-p (rep) (pfd-slot-test rep 'win32::ILAYERTYPE win32::*PFD-MAIN-PLANE*)) (defun device-color-bits (rep) (pfd-slot-value rep 'win32::CCOLORBITS)) (defun device-palette-needed-p (rep) (pfd-dw-flag-p rep win32::*PFD-NEED-PALETTE* )) (defun pfd-slot-value (rep slot) (let* ((hdc (ww::r-output-pane-hdc rep)) (ipfd (win32::GET-PIXEL-FORMAT hdc))) (fli:with-dynamic-foreign-objects ((pfd win32::pixel-format-descriptor)) (win32::DESCRIBE-PIXEL-FORMAT hdc ipfd pfd) (fli:foreign-slot-value pfd slot)))) (defun pfd-slot-test (rep slot val) (= val (pfd-slot-value rep slot))) (defun pfd-dw-flag-p (rep flag) (let* ((hdc (ww::r-output-pane-hdc rep)) (ipfd (win32::GET-PIXEL-FORMAT hdc))) (fli:with-dynamic-foreign-objects ((pfd win32::pixel-format-descriptor)) (win32::DESCRIBE-PIXEL-FORMAT hdc ipfd pfd) (not (zerop (logand flag (fli:foreign-slot-value pfd 'win32::DWFLAGS))))))) (defun set-win32-pixel-format (rep configuration &key (errorp T)) "Sets the device-context pixel-format-descriptor for rep which supports the requested configuration. Returns T if it succeeds. Configuration is a plist with the following allowed indicators: :double-buffer, :double-buffered, - synonyms, value T or NIL. :buffer-size - color buffer size for indexed colormap visuals :accum - accumulator buffer size (per channel), or NIL. :depth-buffer - value is a depth buffer size or NIL :stencil-size - stencil buffer size or NIL. :aux - aux buffer size or NIL." (let* ((hdc (ww::r-output-pane-hdc rep)) (mode (if (or (getf configuration :rgb) (getf configuration :rgba)) win32::*pfd-type-rgba* win32::*pfd-type-colorindex*)) (depth (or (getf configuration :buffer-size) (win32::R-DEVICE-BITSPIXEL (win32::dc-device (ww::r-output-pane-dc rep))))) (z-buffer (or (getf configuration :depth-buffer) 0)) (accum (or (getf configuration :accum) 0)) (stencil (or (getf configuration :stencil-size) 0)) (aux (or (getf configuration :aux) 0)) (double-buffer (or (getf configuration :double-buffer)(getf configuration :double-buffered))) (flags (logior win32::*pfd-draw-to-window* win32::*pfd-support-opengl* (if double-buffer win32::*PFD-DOUBLEBUFFER* 0)))) (fli:with-dynamic-foreign-objects ((pfd win32::pixel-format-descriptor)) (setf (fli:foreign-slot-value pfd 'win32::nsize) (fli:size-of 'win32::pixel-format-descriptor) (fli:foreign-slot-value pfd 'win32::nversion) 1 (fli:foreign-slot-value pfd 'win32::dwflags) flags (fli:foreign-slot-value pfd 'win32::iPixelType) mode (fli:foreign-slot-value pfd 'win32::cColorBits) depth (fli:foreign-slot-value pfd 'win32::cRedBits) 0 (fli:foreign-slot-value pfd 'win32::cRedShift) 0 (fli:foreign-slot-value pfd 'win32::cGreenBits) 0 (fli:foreign-slot-value pfd 'win32::cGreenShift) 0 (fli:foreign-slot-value pfd 'win32::cBlueBits) 0 (fli:foreign-slot-value pfd 'win32::cBlueShift) 0 (fli:foreign-slot-value pfd 'win32::cAlphaBits) 0 (fli:foreign-slot-value pfd 'win32::cAlphaShift) 0 (fli:foreign-slot-value pfd 'win32::cAccumBits) accum (fli:foreign-slot-value pfd 'win32::cAccumRedBits) 0 (fli:foreign-slot-value pfd 'win32::cAccumGreenBits) 0 (fli:foreign-slot-value pfd 'win32::cAccumBlueBits) 0 (fli:foreign-slot-value pfd 'win32::cAccumAlphaBits) 0 (fli:foreign-slot-value pfd 'win32::cDepthBits) z-buffer (fli:foreign-slot-value pfd 'win32::cStencilBits) stencil (fli:foreign-slot-value pfd 'win32::cAuxBuffers) aux (fli:foreign-slot-value pfd 'win32::iLayerType) win32::*pfd-main-plane* (fli:foreign-slot-value pfd 'win32::breserved) 0 (fli:foreign-slot-value pfd 'win32::dwlayermask) 0 (fli:foreign-slot-value pfd 'win32::dwVisiblemask) 0 (fli:foreign-slot-value pfd 'win32::dwDamagemask) 0) (let ((ipfd (win32::choose-pixel-format hdc pfd))) (if (zerop ipfd) (progn (when errorp (error "Unable to find pixel-format for this opengl configuration: ~s" configuration)) 0) (win32::set-pixel-format hdc ipfd pfd)))))) ;; return a list giving a configuration that corresponds to the pfd (defun get-win32-pixel-format (rep) (let* ((hdc (ww::r-output-pane-hdc rep)) (ipfd (win32::GET-PIXEL-FORMAT hdc))) (fli:with-dynamic-foreign-objects ((pfd win32::pixel-format-descriptor)) (win32::DESCRIBE-PIXEL-FORMAT hdc ipfd pfd) (list ; (fli:foreign-slot-value pfd 'win32::nversion) 1 :double-buffer (not (zerop (logand (fli:foreign-slot-value pfd 'win32::dwflags) win32::*PFD-DOUBLEBUFFER*))) :rgba (eq (fli:foreign-slot-value pfd 'win32::iPixelType) win32::*pfd-type-rgba*) :buffer-size (fli:foreign-slot-value pfd 'win32::cColorBits) ; (fli:foreign-slot-value pfd 'win32::cRedBits) 0 ; (fli:foreign-slot-value pfd 'win32::cRedShift) 0 ; (fli:foreign-slot-value pfd 'win32::cGreenBits) 0 ; (fli:foreign-slot-value pfd 'win32::cGreenShift) 0 ; (fli:foreign-slot-value pfd 'win32::cBlueBits) 0 ; (fli:foreign-slot-value pfd 'win32::cBlueShift) 0 ; (fli:foreign-slot-value pfd 'win32::cAlphaBits) 0 ; (fli:foreign-slot-value pfd 'win32::cAlphaShift) 0 :accum (let ((accum (fli:foreign-slot-value pfd 'win32::cAccumBits))) (unless (zerop accum) accum)) ; (fli:foreign-slot-value pfd 'win32::cAccumRedBits) 0 ; (fli:foreign-slot-value pfd 'win32::cAccumGreenBits) 0 ; (fli:foreign-slot-value pfd 'win32::cAccumBlueBits) 0 ; (fli:foreign-slot-value pfd 'win32::cAccumAlphaBits) 0 :depth-buffer (let ((z-buffer (fli:foreign-slot-value pfd 'win32::cDepthBits))) (unless (zerop z-buffer) z-buffer)) :stencil-size (let ((stencil (fli:foreign-slot-value pfd 'win32::cStencilBits))) (unless (zerop stencil) stencil)) :aux (let ((aux (fli:foreign-slot-value pfd 'win32::cAuxBuffers))) (unless (zerop aux) aux)) ; (fli:foreign-slot-value pfd 'win32::iLayerType) ; (fli:foreign-slot-value pfd 'win32::breserved) ; (fli:foreign-slot-value pfd 'win32::dwlayermask) ; (fli:foreign-slot-value pfd 'win32::dwVisiblemask) ; (fli:foreign-slot-value pfd 'win32::dwDamagemask) )))) (defmethod %describe-configuration ((rep ww::r-output-pane) context &optional (stream *standard-output*) collectp) (declare (ignore context)) (let ((results (get-win32-pixel-format rep))) (if collectp results (format stream "~&Color buffer size : ~d~%Uses ~:[Color Index~;RGBA~]~%Is ~:[single~;double~]-buffered~@[~%Accumulator buffer size (per channel) = ~d bits~]~@[~%Depth buffer size = ~d bits~]~@[~%Stencil buffer size = ~d bits~]~@[~%Has ~d aux buffers~]" (getf results :buffer-size) (getf results :rgba) (getf results :double-buffer) (getf results :accum) (getf results :depth-buffer) (getf results :stencil-size) (getf results :aux)))))
9,378
Common Lisp
.lisp
166
47.692771
252
0.641466
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
069df2412f57e1b0305ce044718c7c38c94fbdc0f4c245dc86597e66dae9bdb3
808
[ -1 ]
809
host.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/host.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/host.lisp,v 1.4.14.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") (setf (logical-pathname-translations "OPENGL") `(("**;*" ,(merge-pathnames "**/*" (pathname-location *load-truename*)))))
368
Common Lisp
.lisp
5
70.4
150
0.670391
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
2c89ff0552bb8b82756fb3dc55408cd82d618a8e32b3e5eb3be855fa6be4b6a0
809
[ -1 ]
810
load.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/load.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/load.lisp,v 1.11.13.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "CL-USER") (load (current-pathname "defsys")) (compile-system "OPENGL" :load t)
314
Common Lisp
.lisp
5
60.6
151
0.70297
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
6cc0603c74260f03b2f05c63706ccc6292c3d6c4e2c1f9f95c5dbee483ea4df5
810
[ -1 ]
811
xm-lib.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/xm-lib.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/xm-lib.lisp,v 1.25.3.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") ;;; capi-motif-library back-end for OpenGL ;;; TBD: proper mechanism for sharing contexts. Currently shared contexts don't ever ;;; get freed. ;;; PJG 9Feb1999 - Fixed code to cope with color::visual-info objects. Previously ;;; it would use XVisualInfo (which could cause memory leaks) (defun find-x11-visual-info (display screen configuration) (if-let (vi (x-utilities::with-x11-foreign-calls-lock-rm-only(call-glx-Choose-Visual display (x-lib:x-screen-number-of-screen screen) configuration))) (fli:copy-pointer vi :type 'x-lib:x-visual-info) (error "Unable to find a suitable visual for OpenGL configuration ~s" configuration))) (defun display-connection-local-maybe (xdisplay) "Heuristic attempt at determining if a display connection is to a server on the same host as the client, which would allow OpenGL direct connections, which are much faster." (let ((host (x-lib::parse-display-name-string (x-lib::x-display-string xdisplay)))) (not (null (member host (list "" "localhost" "unix" (machine-instance)) :test #'string=))))) (defmethod %make-context ((widget xt-lib:widget) opengl-configuration) (let* ((xscreen (xt-lib:xt-screen widget)) (xdisplay (x-lib:x-display-of-screen xscreen)) (visual (xt-lib:xt-get-values widget :visual)) (directp (if (eq (getf opengl-configuration :direct) :force) T (display-connection-local-maybe xdisplay)))) (let ((context (x-utilities::with-x11-foreign-calls-lock-rm-only (call-glx-create-context xdisplay visual (let ((share (getf opengl-configuration :share))) (if (and share (typep share 'glxcontext)) share nil)) directp)))) (unless context (error "Failed to create GLX Context for ~s: ~s ~s" widget xdisplay visual)) context))) (defmethod %start-rendering ((widget xt-lib:widget) context) ;; Returns boolean (success) value returned by glx-make-current (let ((xid (xt-lib:xt-window widget)) (xdisplay (xt-lib:xt-display widget))) (glx-make-current xdisplay xid context))) (defmethod %stop-rendering ((widget xt-lib:widget)) (let ((xdisplay (xt-lib:xt-display widget))) (glx-make-current xdisplay x-lib:none nil))) (defmethod %swap-buffers ((widget xt-lib:widget) context) (declare (ignore context)) (let ((xid (xt-lib:xt-window widget)) (xdisplay (xt-lib:xt-display widget))) (glx-swap-buffers xdisplay xid))) (defmethod %resize-opengl-context ((rep xt-lib:widget) context width height) (declare (ignore context width height)) ) (defmethod %describe-visual-info-configuration ((widget xt-lib:widget) context visual &optional (stream *standard-output*)) (let* ((xscreen (xt-lib:xt-screen widget)) (xdisplay (x-lib:x-display-of-screen xscreen)) (x-visual-info nil)) (unwind-protect (or (x-utilities::with-x11-foreign-calls-lock-rm-only (and (setq x-visual-info (x-visual-info-from-visual xdisplay visual)) (let ((directp (glx-is-direct xdisplay context))) (list* (format nil "Connection to the graphics subsystem is ~:[via the X server.~;direct.~]" directp) (mapcar #'(lambda (attrib) (destructuring-bind (glx-attrib name descr) attrib (multiple-value-bind (error value) (glx-get-config xdisplay x-visual-info glx-attrib 0) (if (zerop error) (format nil "~@?" descr value) (format nil "Failed to get GL context attribute ~a" name))))) *glx-get-config-attributes*))))) (error "Failed to locate x-visual-info for : ~s" visual)) (when x-visual-info (x-lib:x-free x-visual-info))))) ;;; ------------------------------------------------------------ ;;; CAPI-MOTIF-LIBRARY specific (defmethod cm-lib::color-requirements-resources ((pane opengl-pane) (rep cm-lib::output-pane-representation) color-reqs) color-reqs (with-slots (configuration) pane (if configuration (let* ((xdisplay (cm-lib::representation-x-display rep)) (xscreen (cm-lib::representation-x-screen rep)) (x-visual-info (find-x11-visual-info xdisplay xscreen configuration))) (when x-visual-info (let ((color-visual-info (color::set-visual-info-from-x-visual-info x-visual-info))) (prog1 (list :visual (fli:foreign-slot-value x-visual-info 'x-lib:visual) :colormap (color::colormap-for-visual-info xscreen color-visual-info :name :opengl) :depth (fli:foreign-slot-value x-visual-info 'x-lib:depth)) (x-lib:x-free x-visual-info))))) (call-next-method)))) (defmethod %make-context ((rep cm-lib::output-pane-representation) opengl-configuration) (%make-context (cm-lib::representation-work-widget rep) opengl-configuration)) (defmethod %free-opengl-resources ((rep cm-lib::output-pane-representation) context) ;; called by the capi-internals:representation-destroy method. (when context (with-slots (configuration) (cm-lib::representation-capi-object rep) (unless (getf configuration :share) (x-utilities::with-x11-foreign-calls-lock-rm-only ;; Unsatisfactory. We need a way to share information about shared contexts. (let ((xdisplay (cm-lib::representation-x-display rep))) (glx-destroy-context xdisplay context))))))) (defmethod %start-rendering ((rep cm-lib::output-pane-representation) context) (x-utilities::lock-x11-foreign-calls-lock) (let ((res nil)) (unwind-protect (setq res (%start-rendering (cm-lib::representation-work-widget rep) context)) (unless res (x-utilities::unlock-x11-foreign-calls-lock))) res)) (defmethod %stop-rendering ((rep cm-lib::output-pane-representation)) (unwind-protect (%stop-rendering (cm-lib::representation-work-widget rep)) (x-utilities::unlock-x11-foreign-calls-lock))) (defmethod %swap-buffers ((rep cm-lib::output-pane-representation) context) (x-utilities::with-x11-foreign-calls-lock-rm-only (%swap-buffers (cm-lib::representation-work-widget rep) context))) (defmethod %resize-opengl-context ((rep cm-lib::output-pane-representation) context width height) (x-utilities::with-x11-foreign-calls-lock-rm-only (%resize-opengl-context (cm-lib::representation-work-widget rep) context width height))) (defmethod %describe-configuration ((rep cm-lib::output-pane-representation) context &optional (stream *standard-output*) collectp) (let ((results (let* ((widget (cm-lib::representation-work-widget rep)) (visual (xt-lib:xt-get-values widget :visual))) (%describe-visual-info-configuration widget context visual stream)))) (if collectp results (dolist (r results) (format stream "~%~a" r))))) (defmethod %get-debug-entry-hook ((x cm-lib::output-pane-representation)) 'x-utilities::x11-foreign-calls-lock-debug2-hook)
8,065
Common Lisp
.lisp
135
47.251852
152
0.610554
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
077a10487127d53229873002eaf21a0ce13ca6a10679532b42ecfceffab0386f
811
[ -1 ]
812
defsys.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/defsys.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/defsys.lisp,v 1.17.3.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") (pushnew :use-fli-gl-vector sys::*features*) (defsystem "OPENGL" (:optimize ((debug 3) (safety 3))) :members ( "pkg" "constants" "types" "vectors" "fns" ("xfns" :features (or :ffi-x11 :gtk)) ("win32" :features :win32) "ufns" "capi" ("gtk-lib" :features :gtk) ("xm-lib" :features :ffi-x11) ("msw-lib" :features :win32) ("cocoa" :features :cocoa) "loader" ) :rules ((:in-order-to :load :all (:requires (:load :serial))) (:in-order-to :compile :all (:caused-by (:compile :previous)) (:requires (:load :serial)))) )
999
Common Lisp
.lisp
27
26.740741
152
0.514107
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
9cfaa44934d92802dea3d6871c56e0631dc9ba5e1ef785dae2312ffb8ee68104
812
[ -1 ]
813
vectors.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/vectors.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/vectors.lisp,v 1.8.1.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") ;;; ---------------------------------------------------------------------- ;;; OPENGL portable vector handling utilities. ;;; ---------------------------------------------------------------------- ;;; DEFTYPES : ;;; opengl:gl-vector(&optional type length) ;;; ;;; FLI type : ;;; opengl:gl-vector(&optional type length) for lisp-to-foreign conversion only. ;;; ;;; FUNCTIONS: ;;; opengl:make-gl-vector(type length &key contents) ;;; opengl:gl-vector (type &rest contents) ;;; Variation of make-gl-vector. ;;; opengl:free-gl-vector(object) ;;; ;;; gl-vectors allocated by opengl:make-gl-vector and opengl:gl-vector need to ;;; be explicitly released by calling opengl:free-gl-vector (for consistency between ;;; platforms). ;;; ;;; MACROS: ;;; opengl:gl-vector-aref(object subscript) ;;; Accessor for the vector ;;; ;;; opengl:with-gl-vector(bindings ;;; &body body) ;;; Vector is allocated within the scope of the BODY. ;;; bindings is a list of (binding &key type length contents) ;;; ;;; ;;; Common Arguments: ;;; 'TYPE' - element type of the vector ;;; Can be one of ;;; :single, :double ;;; :signed-8, :signed-16, :signed-32 ;;; :unsigned-8, :unsigned-16, :unsigned-32 ;;; 'LENGTH' - length of the vector ;;; Can be a positive integer or '* ;;; 'CONTENTS' a list of values to write into the gl-vector. ;;; ;;; ---------------------------------------------------------------------- ;;; GL deftypes ;;; ---------------------------------------------------------------------- (deftype opengl:gl-vector (&optional type (length '*)) #+:use-fli-gl-vector (declare (ignore type length)) #+:use-fli-gl-vector t #-:use-fli-gl-vector `(simple-array ,(convert-to-lisp-type type) (,length))) ;;; ---------------------------------------------------------------------- ;;; Allocation of float vectors ;;; ---------------------------------------------------------------------- ;;; Foreign type converters - 8 basic types of vectors. ;;; :signed-8 :signed-16 :signed-32 ;;; :unsigned-8 :unsigned-16 :unsigned-32 ;;; :float :double ;;; ---------------------------------------------------------------------- (defun convert-to-fli-type (type-name) (ecase type-name (:signed-8 '(:signed :char)) (:signed-16 '(:signed :short)) (:signed-32 '(:signed :int)) (:unsigned-8 '(:unsigned :char)) (:unsigned-16 '(:unsigned :short)) (:unsigned-32 '(:unsigned :int)) ((:double :double-float) :lisp-double-float) ((:float :single-float) :lisp-single-float))) (defun convert-to-lisp-type (type-name) (case type-name (:signed-8 '(signed-byte 8)) (:signed-16 '(signed-byte 16)) (:signed-32 '(signed-byte 32)) (:unsigned-8 '(unsigned-byte 8)) (:unsigned-16 '(unsigned-byte 16)) (:unsigned-32 '(unsigned-byte 32)) ((:double :double-float) 'double-float) ((:float :single-float) 'single-float))) ;;; ---------------------------------------------------------------------- ;;; Allocation of gl vectors ;;; ---------------------------------------------------------------------- ;;; This current use of auto-gc'ing foreign data is here to mimic the behavior ;;; of lisp foreign arrays. ;;; Using ADD-SPECIAL-FREE-ACTION and FLAG-SPECIAL-FREE-ACTION is not normally ;;; recommended when using the FLI because: ;;; 1. It can slow down the GC by adding overheads to objects to cleanup. ;;; 2. It can have disastrous results if the allocated foreign object is ;;; not cleaned up before an image save - data allocated by ;;; fli:allocate-foreign-object is not persistent across image saves. ;;; Add a count so that we can keep track on how many auto-gc malloc'd objects ;;; are still 'live' #+:use-fli-gl-vector (defvar *gl-vectors-allocated* 0) #+:use-fli-gl-vector (defun free-gl-vector (object) (when (and (fli:pointerp object) (not (fli:null-pointer-p object))) (decf *gl-vectors-allocated*) (fli:free-foreign-object object))) #+:use-fli-gl-vector (add-special-free-action 'free-gl-vector) (defun opengl:make-gl-vector (type length &key (contents nil contentsp)) #+:use-fli-gl-vector (let ((new-vector (fli:allocate-foreign-object :type (convert-to-fli-type type) :nelems length :initial-contents contents))) (incf *gl-vectors-allocated*) (flag-special-free-action new-vector) new-vector) #-:use-fli-gl-vector (sys:in-static-area (apply 'make-array length :element-type (convert-to-lisp-type type) (when contentsp `(:initial-contents ,contents))))) ;;; ------------------------------ ;;; Misc gl vector constructors ;;; ------------------------------ (defun opengl:gl-vector (type &rest contents) (opengl:make-gl-vector type (length contents) :contents contents)) ;;; ---------------------------------------------------------------------- ;;; Element access of gl vectors ;;; ---------------------------------------------------------------------- (defmacro opengl:gl-vector-aref (object subscript) #+:use-fli-gl-vector `(fli:dereference ,object :index ,subscript) #-:use-fli-gl-vector `(aref ,object ,subscript)) ;;; ---------------------------------------------------------------------- ;;; dynamic-extent allocation of gl vectors ;;; ---------------------------------------------------------------------- #-:use-fli-gl-vector (defvar *dynamically-allocated-float-vectors* nil "Holds on to dynamically scoped lisp arrays - prevent the gc from eating them (at least until the end of the scope).") (defun gl-vector-bindings (binding &key (type :single-float) (length 4) (contents nil contentsp)) (values #+:use-fli-gl-vector `(,binding (fli:allocate-dynamic-foreign-object :type ',(convert-to-fli-type type) ,@(when length `(:nelems ,length)) ,@(when contentsp `(:initial-contents ,contents)))) #-:use-fli-gl-vector `(,binding (sys:in-static-area (make-array ,length :element-type ',(convert-to-lisp-type type) ,@(when contentsp `(:initial-contents ,contents))))) binding)) (defmacro opengl:with-gl-vectors ((&rest bindings) &body body) (let (let-bindings binding-names) (dolist (binding bindings) (multiple-value-bind (let-binding binding-name) (apply 'gl-vector-bindings binding) (push let-binding let-bindings) (push binding-name binding-names))) #+:use-fli-gl-vector `(fli:with-dynamic-foreign-objects () (let* ,let-bindings ,@body)) #-:use-fli-gl-vector `(let* (,@let-bindings ,@(when binding-names `((*dynamically-allocated-float-vectors* `(,,@binding-names))))) (declare (dynamic-extent *dynamically-allocated-float-vectors*)) ,@body))) ;;; ---------------------------------------------------------------------- ;;; Foreign type definition ;;; ---------------------------------------------------------------------- (fli:define-foreign-type opengl:gl-vector (&optional (type nil typep) (length '*)) #+:use-fli-gl-vector (if type `(:pointer ,(convert-to-fli-type type)) :pointer) #-:use-fli-gl-vector (if type `(:lisp-array (,(convert-to-lisp-type type) ,length)) :lisp-array))
7,875
Common Lisp
.lisp
177
39.327684
152
0.536544
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
1a9f4d5b6d2f49bd870103b56fcc5c2a849397b66144a8d85e80d6bb63235889
813
[ -1 ]
814
pkg.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/pkg.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/pkg.lisp,v 1.14.3.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") (defpackage "OPENGL" (:add-use-defaults) (:export RENDERING-ON PROCESS-HAS-OPENGL-LOCK-P PROCESS-WITH-OPENGL-LOCK START-RENDERING SWAP-BUFFERS DESCRIBE-CONFIGURATION WITH-MATRIX-PUSHED GLENUM GLBOOLEAN GLBITFIELD GLBYTE GLSHORT GLINT GLSIZEI GLUBYTE GLUSHORT GLUINT GLFLOAT GLCLAMPF GLDOUBLE GLCLAMPD GLVOID GLINTPTR GLSIZEIPTR GLCHAR GL-ACCUM GL-ALPHA-FUNC GL-ARE-TEXTURES-RESIDENT GL-ARRAY-ELEMENT GL-BEGIN GL-BIND-TEXTURE GL-BITMAP GL-BLEND-COLOR GL-BLEND-EQUATION GL-BLEND-EQUATION-SEPARATE GL-BLEND-FUNC GL-CALL-LIST GL-CALL-LISTS GL-CLEAR GL-CLEAR-ACCUM GL-CLEAR-COLOR GL-CLEAR-DEPTH GL-CLEAR-INDEX GL-CLEAR-STENCIL GL-CLIP-PLANE GL-COLOR3-B GL-COLOR3-BV GL-COLOR3-D GL-COLOR3-DV GL-COLOR3-F GL-COLOR3-FV GL-COLOR3-I GL-COLOR3-IV GL-COLOR3-S GL-COLOR3-SV GL-COLOR3-UB GL-COLOR3-UBV GL-COLOR3-UI GL-COLOR3-UIV GL-COLOR3-US GL-COLOR3-USV GL-COLOR4-B GL-COLOR4-BV GL-COLOR4-D GL-COLOR4-DV GL-COLOR4-F GL-COLOR4-FV GL-COLOR4-I GL-COLOR4-IV GL-COLOR4-S GL-COLOR4-SV GL-COLOR4-UB GL-COLOR4-UBV GL-COLOR4-UI GL-COLOR4-UIV GL-COLOR4-US GL-COLOR4-USV GL-COLOR-MASK GL-COLOR-MATERIAL GL-COLOR-POINTER GL-COLOR-SUB-TABLE GL-COLOR-TABLE GL-COLOR-TABLE-PARAMETERFV GL-COLOR-TABLE-PARAMETERIV GL-CONVOLUTION-FILTER1-D GL-CONVOLUTION-FILTER2-D GL-CONVOLUTION-PARAMETERF GL-CONVOLUTION-PARAMETERFV GL-CONVOLUTION-PARAMETERI GL-CONVOLUTION-PARAMETERIV GL-COPY-COLOR-SUB-TABLE GL-COPY-COLOR-TABLE GL-COPY-CONVOLUTION-FILTER1-D GL-COPY-CONVOLUTION-FILTER2-D GL-COPY-PIXELS GL-COPY-TEX-IMAGE1-D GL-COPY-TEX-IMAGE2-D GL-COPY-TEX-SUB-IMAGE1-D GL-COPY-TEX-SUB-IMAGE2-D GL-COPY-TEX-SUB-IMAGE3-D GL-CULL-FACE GL-DELETE-LISTS GL-DELETE-TEXTURES GL-DEPTH-FUNC GL-DEPTH-MASK GL-DEPTH-RANGE GL-DISABLE GL-DISABLE GL-DISABLE-CLIENT-STATE GL-DRAW-ARRAYS GL-DRAW-BUFFER GL-DRAW-ELEMENTS GL-DRAW-PIXELS GL-DRAW-RANGE-ELEMENTS GL-EDGE-FLAG GL-EDGE-FLAG-POINTER GL-EDGE-FLAGV GL-ENABLE GL-ENABLE-CLIENT-STATE GL-END GL-END-LIST GL-EVAL-COORD1-D GL-EVAL-COORD1-DV GL-EVAL-COORD1-F GL-EVAL-COORD1-FV GL-EVAL-COORD2-D GL-EVAL-COORD2-DV GL-EVAL-COORD2-F GL-EVAL-COORD2-FV GL-EVAL-MESH1 GL-EVAL-MESH2 GL-EVAL-POINT1 GL-EVAL-POINT2 GL-FEEDBACK-BUFFER GL-FINISH GL-FLUSH GL-FOGF GL-FOGFV GL-FOGI GL-FOGIV GL-FRONT-FACE GL-FRUSTUM GL-GEN-LISTS GL-GEN-TEXTURES GL-GET-BOOLEANV GL-GET-CLIP-PLANE GL-GET-COLOR-TABLE GL-GET-COLOR-TABLE-PARAMETERFV GL-GET-COLOR-TABLE-PARAMETERIV GL-GET-CONVOLUTION-FILTER GL-GET-CONVOLUTION-PARAMETERFV GL-GET-CONVOLUTION-PARAMETERIV GL-GET-DOUBLEV GL-GET-ERROR GL-GET-FLOATV GL-GET-HISTOGRAM GL-GET-HISTOGRAM-PARAMETERFV GL-GET-HISTOGRAM-PARAMETERIV GL-GET-INTEGERV GL-GET-LIGHTFV GL-GET-LIGHTIV GL-GET-MAPDV GL-GET-MAPFV GL-GET-MAPIV GL-GET-MATERIALFV GL-GET-MATERIALIV GL-GET-MINMAX GL-GET-MINMAX-PARAMETERFV GL-GET-MINMAX-PARAMETERIV GL-GET-PIXEL-MAPFV GL-GET-PIXEL-MAPUIV GL-GET-PIXEL-MAPUSV GL-GET-POINTERV GL-GET-POLYGON-STIPPLE GL-GET-SEPARABLE-FILTER GL-GET-STRING GL-GET-TEX-ENVFV GL-GET-TEX-ENVIV GL-GET-TEX-GENDV GL-GET-TEX-GENFV GL-GET-TEX-GENIV GL-GET-TEX-IMAGE GL-GET-TEX-LEVEL-PARAMETERFV GL-GET-TEX-LEVEL-PARAMETERIV GL-GET-TEX-PARAMETERFV GL-GET-TEX-PARAMETERIV GL-HINT GL-HISTOGRAM GL-INDEX-MASK GL-INDEX-POINTER GL-INDEXD GL-INDEXDV GL-INDEXF GL-INDEXFV GL-INDEXI GL-INDEXIV GL-INDEXS GL-INDEXSV GL-INDEXUB GL-INDEXUBV GL-INIT-NAMES GL-INTERLEAVED-ARRAYS GL-IS-ENABLED GL-IS-LIST GL-IS-TEXTURE GL-LIGHT-MODELF GL-LIGHT-MODELFV GL-LIGHT-MODELI GL-LIGHT-MODELIV GL-LIGHTF GL-LIGHTFV GL-LIGHTI GL-LIGHTIV GL-LINE-STIPPLE GL-LINE-WIDTH GL-LIST-BASE GL-LOAD-IDENTITY GL-LOAD-MATRIXD GL-LOAD-MATRIXF GL-LOAD-NAME GL-LOGIC-OP GL-MAP1-D GL-MAP1-F GL-MAP2-D GL-MAP2-F GL-MAP-GRID1-D GL-MAP-GRID1-F GL-MAP-GRID2-D GL-MAP-GRID2-F GL-MATERIALF GL-MATERIALFV GL-MATERIALI GL-MATERIALIV GL-MATRIX-MODE GL-MINMAX GL-MULT-MATRIXD GL-MULT-MATRIXF GL-NEW-LIST GL-NORMAL3-B GL-NORMAL3-BV GL-NORMAL3-D GL-NORMAL3-DV GL-NORMAL3-F GL-NORMAL3-FV GL-NORMAL3-I GL-NORMAL3-IV GL-NORMAL3-S GL-NORMAL3-SV GL-NORMAL-POINTER GL-ORTHO GL-PASS-THROUGH GL-PIXEL-MAPFV GL-PIXEL-MAPUIV GL-PIXEL-MAPUSV GL-PIXEL-STOREF GL-PIXEL-STOREI GL-PIXEL-TRANSFERF GL-PIXEL-TRANSFERI GL-PIXEL-ZOOM GL-POINT-SIZE GL-POLYGON-MODE GL-POLYGON-OFFSET GL-POLYGON-STIPPLE GL-POP-ATTRIB GL-POP-CLIENT-ATTRIB GL-POP-MATRIX GL-POP-NAME GL-PRIORITIZE-TEXTURES GL-PUSH-ATTRIB GL-PUSH-CLIENT-ATTRIB GL-PUSH-MATRIX GL-PUSH-NAME GL-RASTER-POS2-D GL-RASTER-POS2-DV GL-RASTER-POS2-F GL-RASTER-POS2-FV GL-RASTER-POS2-I GL-RASTER-POS2-IV GL-RASTER-POS2-S GL-RASTER-POS2-SV GL-RASTER-POS3-D GL-RASTER-POS3-DV GL-RASTER-POS3-F GL-RASTER-POS3-FV GL-RASTER-POS3-I GL-RASTER-POS3-IV GL-RASTER-POS3-S GL-RASTER-POS3-SV GL-RASTER-POS4-D GL-RASTER-POS4-DV GL-RASTER-POS4-F GL-RASTER-POS4-FV GL-RASTER-POS4-I GL-RASTER-POS4-IV GL-RASTER-POS4-S GL-RASTER-POS4-SV GL-READ-BUFFER GL-READ-PIXELS GL-RECTD GL-RECTDV GL-RECTF GL-RECTFV GL-RECTI GL-RECTIV GL-RECTS GL-RECTSV GL-RENDER-MODE GL-RESET-HISTOGRAM GL-RESET-MINMAX GL-ROTATED GL-ROTATEF GL-SCALED GL-SCALEF GL-SCISSOR GL-SELECT-BUFFER GL-SEPARABLE-FILTER2-D GL-SHADE-MODEL GL-STENCIL-FUNC GL-STENCIL-MASK GL-STENCIL-OP GL-TEX-COORD1-D GL-TEX-COORD1-DV GL-TEX-COORD1-F GL-TEX-COORD1-FV GL-TEX-COORD1-I GL-TEX-COORD1-IV GL-TEX-COORD1-S GL-TEX-COORD1-SV GL-TEX-COORD2-D GL-TEX-COORD2-DV GL-TEX-COORD2-F GL-TEX-COORD2-FV GL-TEX-COORD2-I GL-TEX-COORD2-IV GL-TEX-COORD2-S GL-TEX-COORD2-SV GL-TEX-COORD3-D GL-TEX-COORD3-DV GL-TEX-COORD3-F GL-TEX-COORD3-FV GL-TEX-COORD3-I GL-TEX-COORD3-IV GL-TEX-COORD3-S GL-TEX-COORD3-SV GL-TEX-COORD4-D GL-TEX-COORD4-DV GL-TEX-COORD4-F GL-TEX-COORD4-FV GL-TEX-COORD4-I GL-TEX-COORD4-IV GL-TEX-COORD4-S GL-TEX-COORD4-SV GL-TEX-COORD-POINTER GL-TEX-ENVF GL-TEX-ENVFV GL-TEX-ENVI GL-TEX-ENVIV GL-TEX-GEND GL-TEX-GENDV GL-TEX-GENF GL-TEX-GENFV GL-TEX-GENI GL-TEX-GENIV GL-TEX-IMAGE1-D GL-TEX-IMAGE2-D GL-TEX-IMAGE3-D GL-TEX-PARAMETERF GL-TEX-PARAMETERFV GL-TEX-PARAMETERI GL-TEX-PARAMETERIV GL-TEX-SUB-IMAGE1-D GL-TEX-SUB-IMAGE2-D GL-TEX-SUB-IMAGE3-D GL-TRANSLATED GL-TRANSLATEF GL-VERTEX2-D GL-VERTEX2-DV GL-VERTEX2-F GL-VERTEX2-FV GL-VERTEX2-I GL-VERTEX2-IV GL-VERTEX2-S GL-VERTEX2-SV GL-VERTEX3-D GL-VERTEX3-DV GL-VERTEX3-F GL-VERTEX3-FV GL-VERTEX3-I GL-VERTEX3-IV GL-VERTEX3-S GL-VERTEX3-SV GL-VERTEX4-D GL-VERTEX4-DV GL-VERTEX4-F GL-VERTEX4-FV GL-VERTEX4-I GL-VERTEX4-IV GL-VERTEX4-S GL-VERTEX4-SV GL-VERTEX-POINTER GL-VIEWPORT GL-SAMPLE-COVERAGE GL-SAMPLE-PASS GL-LOAD-TRANSPOSE-MATRIXF GL-LOAD-TRANSPOSE-MATRIXD GL-MULT-TRANSPOSE-MATRIXF GL-MULT-TRANSPOSE-MATRIXD GL-COMPRESSED-TEX-IMAGE3-D GL-COMPRESSED-TEX-IMAGE2-D GL-COMPRESSED-TEX-IMAGE1-D GL-COMPRESSED-TEX-SUB-IMAGE3-D GL-COMPRESSED-TEX-SUB-IMAGE2-D GL-COMPRESSED-TEX-SUB-IMAGE1-D GL-GET-COMPRESSED-TEX-IMAGE GL-ACTIVE-TEXTURE GL-CLIENT-ACTIVE-TEXTURE GL-MULTI-TEX-COORD1-D GL-MULTI-TEX-COORD1-DV GL-MULTI-TEX-COORD1-F GL-MULTI-TEX-COORD1-FV GL-MULTI-TEX-COORD1-I GL-MULTI-TEX-COORD1-IV GL-MULTI-TEX-COORD1-S GL-MULTI-TEX-COORD1-SV GL-MULTI-TEX-COORD2-D GL-MULTI-TEX-COORD2-DV GL-MULTI-TEX-COORD2-F GL-MULTI-TEX-COORD2-FV GL-MULTI-TEX-COORD2-I GL-MULTI-TEX-COORD2-IV GL-MULTI-TEX-COORD2-S GL-MULTI-TEX-COORD2-SV GL-MULTI-TEX-COORD3-D GL-MULTI-TEX-COORD3-DV GL-MULTI-TEX-COORD3-F GL-MULTI-TEX-COORD3-FV GL-MULTI-TEX-COORD3-I GL-MULTI-TEX-COORD3-IV GL-MULTI-TEX-COORD3-S GL-MULTI-TEX-COORD3-SV GL-MULTI-TEX-COORD4-D GL-MULTI-TEX-COORD4-DV GL-MULTI-TEX-COORD4-F GL-MULTI-TEX-COORD4-FV GL-MULTI-TEX-COORD4-I GL-MULTI-TEX-COORD4-IV GL-MULTI-TEX-COORD4-S GL-MULTI-TEX-COORD4-SV GL-FOG-COORDF GL-FOG-COORDFV GL-FOG-COORDD GL-FOG-COORDDV GL-FOG-COORD-POINTER GL-SECONDARY-COLOR3-B GL-SECONDARY-COLOR3-BV GL-SECONDARY-COLOR3-D GL-SECONDARY-COLOR3-DV GL-SECONDARY-COLOR3-F GL-SECONDARY-COLOR3-FV GL-SECONDARY-COLOR3-I GL-SECONDARY-COLOR3-IV GL-SECONDARY-COLOR3-S GL-SECONDARY-COLOR3-SV GL-SECONDARY-COLOR3-UB GL-SECONDARY-COLOR3-UBV GL-SECONDARY-COLOR3-UI GL-SECONDARY-COLOR3-UIV GL-SECONDARY-COLOR3-US GL-SECONDARY-COLOR3-USV GL-SECONDARY-COLOR-POINTER GL-POINT-PARAMETERF GL-POINT-PARAMETERFV GL-POINT-PARAMETERI GL-POINT-PARAMETERIV GL-BLEND-FUNC-SEPARATE GL-MULTI-DRAW-ARRAYS GL-MULTI-DRAW-ELEMENTS GL-WINDOW-POS2-D GL-WINDOW-POS2-DV GL-WINDOW-POS2-F GL-WINDOW-POS2-FV GL-WINDOW-POS2-I GL-WINDOW-POS2-IV GL-WINDOW-POS2-S GL-WINDOW-POS2-SV GL-WINDOW-POS3-D GL-WINDOW-POS3-DV GL-WINDOW-POS3-F GL-WINDOW-POS3-FV GL-WINDOW-POS3-I GL-WINDOW-POS3-IV GL-WINDOW-POS3-S GL-WINDOW-POS3-SV GL-GEN-QUERIES GL-DELETE-QUERIES GL-IS-QUERY GL-BEGIN-QUERY GL-END-QUERY GL-GET-QUERYIV GL-GET-QUERY-OBJECTIV GL-GET-QUERY-OBJECTUIV GL-BIND-BUFFER GL-DELETE-BUFFERS GL-GEN-BUFFERS GL-GEN-BUFFERS GL-IS-BUFFER GL-BUFFER-DATA GL-BUFFER-SUB-DATA GL-GET-BUFFER-SUB-DATA GL-MAP-BUFFER GL-UNMAP-BUFFER GL-GET-BUFFER-PARAMETERIV GL-GET-BUFFER-POINTERV GL-DRAW-BUFFERS GL-VERTEX-ATTRIB1-D GL-VERTEX-ATTRIB1-DV GL-VERTEX-ATTRIB1-F GL-VERTEX-ATTRIB1-FV GL-VERTEX-ATTRIB1-S GL-VERTEX-ATTRIB1-SV GL-VERTEX-ATTRIB2-D GL-VERTEX-ATTRIB2-DV GL-VERTEX-ATTRIB2-F GL-VERTEX-ATTRIB2-FV GL-VERTEX-ATTRIB2-S GL-VERTEX-ATTRIB2-SV GL-VERTEX-ATTRIB3-D GL-VERTEX-ATTRIB3-DV GL-VERTEX-ATTRIB3-F GL-VERTEX-ATTRIB3-FV GL-VERTEX-ATTRIB3-S GL-VERTEX-ATTRIB3-SV GL-VERTEX-ATTRIB4-NBV GL-VERTEX-ATTRIB4-NIV GL-VERTEX-ATTRIB4-NSV GL-VERTEX-ATTRIB4-NUB GL-VERTEX-ATTRIB4-NUBV GL-VERTEX-ATTRIB4-NUIV GL-VERTEX-ATTRIB4-NUSV GL-VERTEX-ATTRIB4-BV GL-VERTEX-ATTRIB4-D GL-VERTEX-ATTRIB4-DV GL-VERTEX-ATTRIB4-F GL-VERTEX-ATTRIB4-FV GL-VERTEX-ATTRIB4-IV GL-VERTEX-ATTRIB4-S GL-VERTEX-ATTRIB4-SV GL-VERTEX-ATTRIB4-UBV GL-VERTEX-ATTRIB4-UIV GL-VERTEX-ATTRIB4-USV GL-VERTEX-ATTRIB-POINTER GL-ENABLE-VERTEX-ATTRIB-ARRAY GL-DISABLE-VERTEX-ATTRIB-ARRAY GL-GET-VERTEX-ATTRIBDV GL-GET-VERTEX-ATTRIBFV GL-GET-VERTEX-ATTRIBIV GL-GET-VERTEX-ATTRIB-POINTERV GL-DELETE-SHADER GL-DETACH-SHADER GL-CREATE-SHADER GL-SHADER-SOURCE GL-COMPILE-SHADER GL-CREATE-PROGRAM GL-ATTACH-SHADER GL-LINK-PROGRAM GL-USE-PROGRAM GL-DELETE-PROGRAM GL-VALIDATE-PROGRAM GL-UNIFORM1-F GL-UNIFORM2-F GL-UNIFORM3-F GL-UNIFORM4-F GL-UNIFORM1-I GL-UNIFORM2-I GL-UNIFORM3-I GL-UNIFORM4-I GL-UNIFORM1-FV GL-UNIFORM2-FV GL-UNIFORM3-FV GL-UNIFORM4-FV GL-UNIFORM1-IV GL-UNIFORM2-IV GL-UNIFORM3-IV GL-UNIFORM4-IV GL-UNIFORM-MATRIX2-FV GL-UNIFORM-MATRIX3-FV GL-UNIFORM-MATRIX4-FV GL-IS-SHADER GL-IS-PROGRAM GL-GET-SHADERIV GL-GET-PROGRAMIV GL-GET-ATTACHED-SHADERS GL-GET-SHADER-INFO-LOG GL-GET-PROGRAM-INFO-LOG GL-GET-UNIFORM-LOCATION GL-GET-ACTIVE-UNIFORM GL-GET-UNIFORMFV GL-GET-UNIFORMIV GL-GET-SHADER-SOURCE GL-BIND-ATTRIB-LOCATION GL-GET-ACTIVE-ATTRIB GL-GET-ATTRIB-LOCATION GL-STENCIL-FUNC-SEPARATE GL-STENCIL-OP-SEPARATE GL-STENCIL-MASK-SEPARATE GL-UNIFORM-MATRIX2X3-FV GL-UNIFORM-MATRIX3X2-FV GL-UNIFORM-MATRIX2X4-FV GL-UNIFORM-MATRIX4X2-FV GL-UNIFORM-MATRIX3X4-FV GL-UNIFORM-MATRIX4X3-FV *GL-ACCUM* *GL-LOAD* *GL-RETURN* *GL-MULT* *GL-ADD* *GL-NEVER* *GL-LESS* *GL-EQUAL* *GL-LEQUAL* *GL-GREATER* *GL-NOTEQUAL* *GL-GEQUAL* *GL-ALWAYS* *GL-CURRENT-BIT* *GL-POINT-BIT* *GL-LINE-BIT* *GL-POLYGON-BIT* *GL-POLYGON-STIPPLE-BIT* *GL-PIXEL-MODE-BIT* *GL-LIGHTING-BIT* *GL-FOG-BIT* *GL-DEPTH-BUFFER-BIT* *GL-ACCUM-BUFFER-BIT* *GL-STENCIL-BUFFER-BIT* *GL-VIEWPORT-BIT* *GL-TRANSFORM-BIT* *GL-ENABLE-BIT* *GL-COLOR-BUFFER-BIT* *GL-HINT-BIT* *GL-EVAL-BIT* *GL-LIST-BIT* *GL-TEXTURE-BIT* *GL-SCISSOR-BIT* *GL-ALL-ATTRIB-BITS* *GL-POINTS* *GL-LINES* *GL-LINE-LOOP* *GL-LINE-STRIP* *GL-TRIANGLES* *GL-TRIANGLE-STRIP* *GL-TRIANGLE-FAN* *GL-QUADS* *GL-QUAD-STRIP* *GL-POLYGON* *GL-ZERO* *GL-ONE* *GL-SRC-COLOR* *GL-ONE-MINUS-SRC-COLOR* *GL-SRC-ALPHA* *GL-ONE-MINUS-SRC-ALPHA* *GL-DST-ALPHA* *GL-ONE-MINUS-DST-ALPHA* *GL-DST-COLOR* *GL-ONE-MINUS-DST-COLOR* *GL-SRC-ALPHA-SATURATE* *GL-TRUE* *GL-FALSE* *GL-CLIP-PLANE0* *GL-CLIP-PLANE1* *GL-CLIP-PLANE2* *GL-CLIP-PLANE3* *GL-CLIP-PLANE4* *GL-CLIP-PLANE5* *GL-BYTE* *GL-UNSIGNED-BYTE* *GL-SHORT* *GL-UNSIGNED-SHORT* *GL-INT* *GL-UNSIGNED-INT* *GL-FLOAT* *GL-2-BYTES* *GL-3-BYTES* *GL-4-BYTES* *GL-DOUBLE* *GL-NONE* *GL-FRONT-LEFT* *GL-FRONT-RIGHT* *GL-BACK-LEFT* *GL-BACK-RIGHT* *GL-FRONT* *GL-BACK* *GL-LEFT* *GL-RIGHT* *GL-FRONT-AND-BACK* *GL-AUX0* *GL-AUX1* *GL-AUX2* *GL-AUX3* *GL-NO-ERROR* *GL-INVALID-ENUM* *GL-INVALID-VALUE* *GL-INVALID-OPERATION* *GL-STACK-OVERFLOW* *GL-STACK-UNDERFLOW* *GL-OUT-OF-MEMORY* *GL-2D* *GL-3D* *GL-3D-COLOR* *GL-3D-COLOR-TEXTURE* *GL-4D-COLOR-TEXTURE* *GL-PASS-THROUGH-TOKEN* *GL-POINT-TOKEN* *GL-LINE-TOKEN* *GL-POLYGON-TOKEN* *GL-BITMAP-TOKEN* *GL-DRAW-PIXEL-TOKEN* *GL-COPY-PIXEL-TOKEN* *GL-LINE-RESET-TOKEN* *GL-EXP* *GL-EXP2* *GL-CW* *GL-CCW* *GL-COEFF* *GL-ORDER* *GL-DOMAIN* *GL-CURRENT-COLOR* *GL-CURRENT-INDEX* *GL-CURRENT-NORMAL* *GL-CURRENT-TEXTURE-COORDS* *GL-CURRENT-RASTER-COLOR* *GL-CURRENT-RASTER-INDEX* *GL-CURRENT-RASTER-TEXTURE-COORDS* *GL-CURRENT-RASTER-POSITION* *GL-CURRENT-RASTER-POSITION-VALID* *GL-CURRENT-RASTER-DISTANCE* *GL-POINT-SMOOTH* *GL-POINT-SIZE* *GL-POINT-SIZE-RANGE* *GL-POINT-SIZE-GRANULARITY* *GL-LINE-SMOOTH* *GL-LINE-WIDTH* *GL-LINE-WIDTH-RANGE* *GL-LINE-WIDTH-GRANULARITY* *GL-LINE-STIPPLE* *GL-LINE-STIPPLE-PATTERN* *GL-LINE-STIPPLE-REPEAT* *GL-LIST-MODE* *GL-MAX-LIST-NESTING* *GL-LIST-BASE* *GL-LIST-INDEX* *GL-POLYGON-MODE* *GL-POLYGON-SMOOTH* *GL-POLYGON-STIPPLE* *GL-EDGE-FLAG* *GL-CULL-FACE* *GL-CULL-FACE-MODE* *GL-FRONT-FACE* *GL-LIGHTING* *GL-LIGHT-MODEL-LOCAL-VIEWER* *GL-LIGHT-MODEL-TWO-SIDE* *GL-LIGHT-MODEL-AMBIENT* *GL-SHADE-MODEL* *GL-COLOR-MATERIAL-FACE* *GL-COLOR-MATERIAL-PARAMETER* *GL-COLOR-MATERIAL* *GL-FOG* *GL-FOG-INDEX* *GL-FOG-DENSITY* *GL-FOG-START* *GL-FOG-END* *GL-FOG-MODE* *GL-FOG-COLOR* *GL-DEPTH-RANGE* *GL-DEPTH-TEST* *GL-DEPTH-WRITEMASK* *GL-DEPTH-CLEAR-VALUE* *GL-DEPTH-FUNC* *GL-ACCUM-CLEAR-VALUE* *GL-STENCIL-TEST* *GL-STENCIL-CLEAR-VALUE* *GL-STENCIL-FUNC* *GL-STENCIL-VALUE-MASK* *GL-STENCIL-FAIL* *GL-STENCIL-PASS-DEPTH-FAIL* *GL-STENCIL-PASS-DEPTH-PASS* *GL-STENCIL-REF* *GL-STENCIL-WRITEMASK* *GL-MATRIX-MODE* *GL-NORMALIZE* *GL-VIEWPORT* *GL-MODELVIEW-STACK-DEPTH* *GL-PROJECTION-STACK-DEPTH* *GL-TEXTURE-STACK-DEPTH* *GL-MODELVIEW-MATRIX* *GL-PROJECTION-MATRIX* *GL-TEXTURE-MATRIX* *GL-ATTRIB-STACK-DEPTH* *GL-CLIENT-ATTRIB-STACK-DEPTH* *GL-ALPHA-TEST* *GL-ALPHA-TEST-FUNC* *GL-ALPHA-TEST-REF* *GL-DITHER* *GL-BLEND-DST* *GL-BLEND-SRC* *GL-BLEND* *GL-LOGIC-OP-MODE* *GL-INDEX-LOGIC-OP* *GL-COLOR-LOGIC-OP* *GL-AUX-BUFFERS* *GL-DRAW-BUFFER* *GL-READ-BUFFER* *GL-SCISSOR-BOX* *GL-SCISSOR-TEST* *GL-INDEX-CLEAR-VALUE* *GL-INDEX-WRITEMASK* *GL-COLOR-CLEAR-VALUE* *GL-COLOR-WRITEMASK* *GL-INDEX-MODE* *GL-RGBA-MODE* *GL-DOUBLEBUFFER* *GL-STEREO* *GL-RENDER-MODE* *GL-PERSPECTIVE-CORRECTION-HINT* *GL-POINT-SMOOTH-HINT* *GL-LINE-SMOOTH-HINT* *GL-POLYGON-SMOOTH-HINT* *GL-FOG-HINT* *GL-TEXTURE-GEN-S* *GL-TEXTURE-GEN-T* *GL-TEXTURE-GEN-R* *GL-TEXTURE-GEN-Q* *GL-PIXEL-MAP-I-TO-I* *GL-PIXEL-MAP-S-TO-S* *GL-PIXEL-MAP-I-TO-R* *GL-PIXEL-MAP-I-TO-G* *GL-PIXEL-MAP-I-TO-B* *GL-PIXEL-MAP-I-TO-A* *GL-PIXEL-MAP-R-TO-R* *GL-PIXEL-MAP-G-TO-G* *GL-PIXEL-MAP-B-TO-B* *GL-PIXEL-MAP-A-TO-A* *GL-PIXEL-MAP-I-TO-I-SIZE* *GL-PIXEL-MAP-S-TO-S-SIZE* *GL-PIXEL-MAP-I-TO-R-SIZE* *GL-PIXEL-MAP-I-TO-G-SIZE* *GL-PIXEL-MAP-I-TO-B-SIZE* *GL-PIXEL-MAP-I-TO-A-SIZE* *GL-PIXEL-MAP-R-TO-R-SIZE* *GL-PIXEL-MAP-G-TO-G-SIZE* *GL-PIXEL-MAP-B-TO-B-SIZE* *GL-PIXEL-MAP-A-TO-A-SIZE* *GL-UNPACK-SWAP-BYTES* *GL-UNPACK-LSB-FIRST* *GL-UNPACK-ROW-LENGTH* *GL-UNPACK-SKIP-ROWS* *GL-UNPACK-SKIP-PIXELS* *GL-UNPACK-ALIGNMENT* *GL-PACK-SWAP-BYTES* *GL-PACK-LSB-FIRST* *GL-PACK-ROW-LENGTH* *GL-PACK-SKIP-ROWS* *GL-PACK-SKIP-PIXELS* *GL-PACK-ALIGNMENT* *GL-MAP-COLOR* *GL-MAP-STENCIL* *GL-INDEX-SHIFT* *GL-INDEX-OFFSET* *GL-RED-SCALE* *GL-RED-BIAS* *GL-ZOOM-X* *GL-ZOOM-Y* *GL-GREEN-SCALE* *GL-GREEN-BIAS* *GL-BLUE-SCALE* *GL-BLUE-BIAS* *GL-ALPHA-SCALE* *GL-ALPHA-BIAS* *GL-DEPTH-SCALE* *GL-DEPTH-BIAS* *GL-MAX-EVAL-ORDER* *GL-MAX-LIGHTS* *GL-MAX-CLIP-PLANES* *GL-MAX-TEXTURE-SIZE* *GL-MAX-PIXEL-MAP-TABLE* *GL-MAX-ATTRIB-STACK-DEPTH* *GL-MAX-MODELVIEW-STACK-DEPTH* *GL-MAX-NAME-STACK-DEPTH* *GL-MAX-PROJECTION-STACK-DEPTH* *GL-MAX-TEXTURE-STACK-DEPTH* *GL-MAX-VIEWPORT-DIMS* *GL-MAX-CLIENT-ATTRIB-STACK-DEPTH* *GL-SUBPIXEL-BITS* *GL-INDEX-BITS* *GL-RED-BITS* *GL-GREEN-BITS* *GL-BLUE-BITS* *GL-ALPHA-BITS* *GL-DEPTH-BITS* *GL-STENCIL-BITS* *GL-ACCUM-RED-BITS* *GL-ACCUM-GREEN-BITS* *GL-ACCUM-BLUE-BITS* *GL-ACCUM-ALPHA-BITS* *GL-NAME-STACK-DEPTH* *GL-AUTO-NORMAL* *GL-MAP1-COLOR-4* *GL-MAP1-INDEX* *GL-MAP1-NORMAL* *GL-MAP1-TEXTURE-COORD-1* *GL-MAP1-TEXTURE-COORD-2* *GL-MAP1-TEXTURE-COORD-3* *GL-MAP1-TEXTURE-COORD-4* *GL-MAP1-VERTEX-3* *GL-MAP1-VERTEX-4* *GL-MAP2-COLOR-4* *GL-MAP2-INDEX* *GL-MAP2-NORMAL* *GL-MAP2-TEXTURE-COORD-1* *GL-MAP2-TEXTURE-COORD-2* *GL-MAP2-TEXTURE-COORD-3* *GL-MAP2-TEXTURE-COORD-4* *GL-MAP2-VERTEX-3* *GL-MAP2-VERTEX-4* *GL-MAP1-GRID-DOMAIN* *GL-MAP1-GRID-SEGMENTS* *GL-MAP2-GRID-DOMAIN* *GL-MAP2-GRID-SEGMENTS* *GL-TEXTURE-1D* *GL-TEXTURE-2D* *GL-FEEDBACK-BUFFER-POINTER* *GL-FEEDBACK-BUFFER-SIZE* *GL-FEEDBACK-BUFFER-TYPE* *GL-SELECTION-BUFFER-POINTER* *GL-SELECTION-BUFFER-SIZE* *GL-TEXTURE-WIDTH* *GL-TEXTURE-HEIGHT* *GL-TEXTURE-INTERNAL-FORMAT* *GL-TEXTURE-BORDER-COLOR* *GL-TEXTURE-BORDER* *GL-DONT-CARE* *GL-FASTEST* *GL-NICEST* *GL-LIGHT0* *GL-LIGHT1* *GL-LIGHT2* *GL-LIGHT3* *GL-LIGHT4* *GL-LIGHT5* *GL-LIGHT6* *GL-LIGHT7* *GL-AMBIENT* *GL-DIFFUSE* *GL-SPECULAR* *GL-POSITION* *GL-SPOT-DIRECTION* *GL-SPOT-EXPONENT* *GL-SPOT-CUTOFF* *GL-CONSTANT-ATTENUATION* *GL-LINEAR-ATTENUATION* *GL-QUADRATIC-ATTENUATION* *GL-COMPILE* *GL-COMPILE-AND-EXECUTE* *GL-CLEAR* *GL-AND* *GL-AND-REVERSE* *GL-COPY* *GL-AND-INVERTED* *GL-NOOP* *GL-XOR* *GL-OR* *GL-NOR* *GL-EQUIV* *GL-INVERT* *GL-OR-REVERSE* *GL-COPY-INVERTED* *GL-OR-INVERTED* *GL-NAND* *GL-SET* *GL-EMISSION* *GL-SHININESS* *GL-AMBIENT-AND-DIFFUSE* *GL-COLOR-INDEXES* *GL-MODELVIEW* *GL-PROJECTION* *GL-TEXTURE* *GL-COLOR* *GL-DEPTH* *GL-STENCIL* *GL-COLOR-INDEX* *GL-STENCIL-INDEX* *GL-DEPTH-COMPONENT* *GL-RED* *GL-GREEN* *GL-BLUE* *GL-ALPHA* *GL-RGB* *GL-RGBA* *GL-LUMINANCE* *GL-LUMINANCE-ALPHA* *GL-BITMAP* *GL-POINT* *GL-LINE* *GL-FILL* *GL-RENDER* *GL-FEEDBACK* *GL-SELECT* *GL-FLAT* *GL-SMOOTH* *GL-KEEP* *GL-REPLACE* *GL-INCR* *GL-DECR* *GL-VENDOR* *GL-RENDERER* *GL-VERSION* *GL-EXTENSIONS* *GL-S* *GL-T* *GL-R* *GL-Q* *GL-MODULATE* *GL-DECAL* *GL-TEXTURE-ENV-MODE* *GL-TEXTURE-ENV-COLOR* *GL-TEXTURE-ENV* *GL-EYE-LINEAR* *GL-OBJECT-LINEAR* *GL-SPHERE-MAP* *GL-TEXTURE-GEN-MODE* *GL-OBJECT-PLANE* *GL-EYE-PLANE* *GL-NEAREST* *GL-LINEAR* *GL-NEAREST-MIPMAP-NEAREST* *GL-LINEAR-MIPMAP-NEAREST* *GL-NEAREST-MIPMAP-LINEAR* *GL-LINEAR-MIPMAP-LINEAR* *GL-TEXTURE-MAG-FILTER* *GL-TEXTURE-MIN-FILTER* *GL-TEXTURE-WRAP-S* *GL-TEXTURE-WRAP-T* *GL-CLAMP* *GL-REPEAT* *GL-CLIENT-PIXEL-STORE-BIT* *GL-CLIENT-VERTEX-ARRAY-BIT* *GL-CLIENT-ALL-ATTRIB-BITS* *GL-POLYGON-OFFSET-FACTOR* *GL-POLYGON-OFFSET-UNITS* *GL-POLYGON-OFFSET-POINT* *GL-POLYGON-OFFSET-LINE* *GL-POLYGON-OFFSET-FILL* *GL-ALPHA4* *GL-ALPHA8* *GL-ALPHA12* *GL-ALPHA16* *GL-LUMINANCE4* *GL-LUMINANCE8* *GL-LUMINANCE12* *GL-LUMINANCE16* *GL-LUMINANCE4-ALPHA4* *GL-LUMINANCE6-ALPHA2* *GL-LUMINANCE8-ALPHA8* *GL-LUMINANCE12-ALPHA4* *GL-LUMINANCE12-ALPHA12* *GL-LUMINANCE16-ALPHA16* *GL-INTENSITY* *GL-INTENSITY4* *GL-INTENSITY8* *GL-INTENSITY12* *GL-INTENSITY16* *GL-R3-G3-B2* *GL-RGB4* *GL-RGB5* *GL-RGB8* *GL-RGB10* *GL-RGB12* *GL-RGB16* *GL-RGBA2* *GL-RGBA4* *GL-RGB5-A1* *GL-RGBA8* *GL-RGB10-A2* *GL-RGBA12* *GL-RGBA16* *GL-TEXTURE-RED-SIZE* *GL-TEXTURE-GREEN-SIZE* *GL-TEXTURE-BLUE-SIZE* *GL-TEXTURE-ALPHA-SIZE* *GL-TEXTURE-LUMINANCE-SIZE* *GL-TEXTURE-INTENSITY-SIZE* *GL-PROXY-TEXTURE-1D* *GL-PROXY-TEXTURE-2D* *GL-TEXTURE-PRIORITY* *GL-TEXTURE-RESIDENT* *GL-TEXTURE-BINDING-1D* *GL-TEXTURE-BINDING-2D* *GL-TEXTURE-BINDING-3D* *GL-VERTEX-ARRAY* *GL-NORMAL-ARRAY* *GL-COLOR-ARRAY* *GL-INDEX-ARRAY* *GL-TEXTURE-COORD-ARRAY* *GL-EDGE-FLAG-ARRAY* *GL-VERTEX-ARRAY-SIZE* *GL-VERTEX-ARRAY-TYPE* *GL-VERTEX-ARRAY-STRIDE* *GL-NORMAL-ARRAY-TYPE* *GL-NORMAL-ARRAY-STRIDE* *GL-COLOR-ARRAY-SIZE* *GL-COLOR-ARRAY-TYPE* *GL-COLOR-ARRAY-STRIDE* *GL-INDEX-ARRAY-TYPE* *GL-INDEX-ARRAY-STRIDE* *GL-TEXTURE-COORD-ARRAY-SIZE* *GL-TEXTURE-COORD-ARRAY-TYPE* *GL-TEXTURE-COORD-ARRAY-STRIDE* *GL-EDGE-FLAG-ARRAY-STRIDE* *GL-VERTEX-ARRAY-POINTER* *GL-NORMAL-ARRAY-POINTER* *GL-COLOR-ARRAY-POINTER* *GL-INDEX-ARRAY-POINTER* *GL-TEXTURE-COORD-ARRAY-POINTER* *GL-EDGE-FLAG-ARRAY-POINTER* *GL-V2F* *GL-V3F* *GL-C4UB-V2F* *GL-C4UB-V3F* *GL-C3F-V3F* *GL-N3F-V3F* *GL-C4F-N3F-V3F* *GL-T2F-V3F* *GL-T4F-V4F* *GL-T2F-C4UB-V3F* *GL-T2F-C3F-V3F* *GL-T2F-N3F-V3F* *GL-T2F-C4F-N3F-V3F* *GL-T4F-C4F-N3F-V4F* *GL-BGR* *GL-BGRA* *GL-CONSTANT-COLOR* *GL-ONE-MINUS-CONSTANT-COLOR* *GL-CONSTANT-ALPHA* *GL-ONE-MINUS-CONSTANT-ALPHA* *GL-BLEND-COLOR* *GL-FUNC-ADD* *GL-MIN* *GL-MAX* *GL-BLEND-EQUATION* *GL-BLEND-EQUATION-RGB* *GL-BLEND-EQUATION-ALPHA* *GL-FUNC-SUBTRACT* *GL-FUNC-REVERSE-SUBTRACT* *GL-COLOR-MATRIX* *GL-COLOR-MATRIX-STACK-DEPTH* *GL-MAX-COLOR-MATRIX-STACK-DEPTH* *GL-POST-COLOR-MATRIX-RED-SCALE* *GL-POST-COLOR-MATRIX-GREEN-SCALE* *GL-POST-COLOR-MATRIX-BLUE-SCALE* *GL-POST-COLOR-MATRIX-ALPHA-SCALE* *GL-POST-COLOR-MATRIX-RED-BIAS* *GL-POST-COLOR-MATRIX-GREEN-BIAS* *GL-POST-COLOR-MATRIX-BLUE-BIAS* *GL-POST-COLOR-MATRIX-ALPHA-BIAS* *GL-COLOR-TABLE* *GL-POST-CONVOLUTION-COLOR-TABLE* *GL-POST-COLOR-MATRIX-COLOR-TABLE* *GL-PROXY-COLOR-TABLE* *GL-PROXY-POST-CONVOLUTION-COLOR-TABLE* *GL-PROXY-POST-COLOR-MATRIX-COLOR-TABLE* *GL-COLOR-TABLE-SCALE* *GL-COLOR-TABLE-BIAS* *GL-COLOR-TABLE-FORMAT* *GL-COLOR-TABLE-WIDTH* *GL-COLOR-TABLE-RED-SIZE* *GL-COLOR-TABLE-GREEN-SIZE* *GL-COLOR-TABLE-BLUE-SIZE* *GL-COLOR-TABLE-ALPHA-SIZE* *GL-COLOR-TABLE-LUMINANCE-SIZE* *GL-COLOR-TABLE-INTENSITY-SIZE* *GL-CONVOLUTION-1D* *GL-CONVOLUTION-2D* *GL-SEPARABLE-2D* *GL-CONVOLUTION-BORDER-MODE* *GL-CONVOLUTION-FILTER-SCALE* *GL-CONVOLUTION-FILTER-BIAS* *GL-REDUCE* *GL-CONVOLUTION-FORMAT* *GL-CONVOLUTION-WIDTH* *GL-CONVOLUTION-HEIGHT* *GL-MAX-CONVOLUTION-WIDTH* *GL-MAX-CONVOLUTION-HEIGHT* *GL-POST-CONVOLUTION-RED-SCALE* *GL-POST-CONVOLUTION-GREEN-SCALE* *GL-POST-CONVOLUTION-BLUE-SCALE* *GL-POST-CONVOLUTION-ALPHA-SCALE* *GL-POST-CONVOLUTION-RED-BIAS* *GL-POST-CONVOLUTION-GREEN-BIAS* *GL-POST-CONVOLUTION-BLUE-BIAS* *GL-POST-CONVOLUTION-ALPHA-BIAS* *GL-CONSTANT-BORDER* *GL-REPLICATE-BORDER* *GL-CONVOLUTION-BORDER-COLOR* *GL-MAX-ELEMENTS-VERTICES* *GL-MAX-ELEMENTS-INDICES* *GL-HISTOGRAM* *GL-PROXY-HISTOGRAM* *GL-HISTOGRAM-WIDTH* *GL-HISTOGRAM-FORMAT* *GL-HISTOGRAM-RED-SIZE* *GL-HISTOGRAM-GREEN-SIZE* *GL-HISTOGRAM-BLUE-SIZE* *GL-HISTOGRAM-ALPHA-SIZE* *GL-HISTOGRAM-LUMINANCE-SIZE* *GL-HISTOGRAM-SINK* *GL-MINMAX* *GL-MINMAX-FORMAT* *GL-MINMAX-SINK* *GL-TABLE-TOO-LARGE* *GL-UNSIGNED-BYTE-3-3-2* *GL-UNSIGNED-SHORT-4-4-4-4* *GL-UNSIGNED-SHORT-5-5-5-1* *GL-UNSIGNED-INT-8-8-8-8* *GL-UNSIGNED-INT-10-10-10-2* *GL-UNSIGNED-BYTE-2-3-3-REV* *GL-UNSIGNED-SHORT-5-6-5* *GL-UNSIGNED-SHORT-5-6-5-REV* *GL-UNSIGNED-SHORT-4-4-4-4-REV* *GL-UNSIGNED-SHORT-1-5-5-5-REV* *GL-UNSIGNED-INT-8-8-8-8-REV* *GL-UNSIGNED-INT-2-10-10-10-REV* *GL-RESCALE-NORMAL* *GL-LIGHT-MODEL-COLOR-CONTROL* *GL-SINGLE-COLOR* *GL-SEPARATE-SPECULAR-COLOR* *GL-PACK-SKIP-IMAGES* *GL-PACK-IMAGE-HEIGHT* *GL-UNPACK-SKIP-IMAGES* *GL-UNPACK-IMAGE-HEIGHT* *GL-TEXTURE-3D* *GL-PROXY-TEXTURE-3D* *GL-TEXTURE-DEPTH* *GL-TEXTURE-WRAP-R* *GL-MAX-3D-TEXTURE-SIZE* *GL-CLAMP-TO-EDGE* *GL-CLAMP-TO-BORDER* *GL-TEXTURE-MIN-LOD* *GL-TEXTURE-MAX-LOD* *GL-TEXTURE-BASE-LEVEL* *GL-TEXTURE-MAX-LEVEL* *GL-SMOOTH-POINT-SIZE-RANGE* *GL-SMOOTH-POINT-SIZE-GRANULARITY* *GL-SMOOTH-LINE-WIDTH-RANGE* *GL-SMOOTH-LINE-WIDTH-GRANULARITY* *GL-ALIASED-POINT-SIZE-RANGE* *GL-ALIASED-LINE-WIDTH-RANGE* *GL-TEXTURE0* *GL-TEXTURE1* *GL-TEXTURE2* *GL-TEXTURE3* *GL-TEXTURE4* *GL-TEXTURE5* *GL-TEXTURE6* *GL-TEXTURE7* *GL-TEXTURE8* *GL-TEXTURE9* *GL-TEXTURE10* *GL-TEXTURE11* *GL-TEXTURE12* *GL-TEXTURE13* *GL-TEXTURE14* *GL-TEXTURE15* *GL-TEXTURE16* *GL-TEXTURE17* *GL-TEXTURE18* *GL-TEXTURE19* *GL-TEXTURE20* *GL-TEXTURE21* *GL-TEXTURE22* *GL-TEXTURE23* *GL-TEXTURE24* *GL-TEXTURE25* *GL-TEXTURE26* *GL-TEXTURE27* *GL-TEXTURE28* *GL-TEXTURE29* *GL-TEXTURE30* *GL-TEXTURE31* *GL-ACTIVE-TEXTURE* *GL-CLIENT-ACTIVE-TEXTURE* *GL-MAX-TEXTURE-UNITS* *GL-COMBINE* *GL-COMBINE-RGB* *GL-COMBINE-ALPHA* *GL-RGB-SCALE* *GL-ADD-SIGNED* *GL-INTERPOLATE* *GL-CONSTANT* *GL-PRIMARY-COLOR* *GL-PREVIOUS* *GL-SUBTRACT* *GL-SRC0-RGB* *GL-SRC1-RGB* *GL-SRC2-RGB* *GL-SRC3-RGB* *GL-SRC4-RGB* *GL-SRC5-RGB* *GL-SRC6-RGB* *GL-SRC7-RGB* *GL-SRC0-ALPHA* *GL-SRC1-ALPHA* *GL-SRC2-ALPHA* *GL-SRC3-ALPHA* *GL-SRC4-ALPHA* *GL-SRC5-ALPHA* *GL-SRC6-ALPHA* *GL-SRC7-ALPHA* *GL-SOURCE0-RGB* *GL-SOURCE1-RGB* *GL-SOURCE2-RGB* *GL-SOURCE3-RGB* *GL-SOURCE4-RGB* *GL-SOURCE5-RGB* *GL-SOURCE6-RGB* *GL-SOURCE7-RGB* *GL-SOURCE0-ALPHA* *GL-SOURCE1-ALPHA* *GL-SOURCE2-ALPHA* *GL-SOURCE3-ALPHA* *GL-SOURCE4-ALPHA* *GL-SOURCE5-ALPHA* *GL-SOURCE6-ALPHA* *GL-SOURCE7-ALPHA* *GL-OPERAND0-RGB* *GL-OPERAND1-RGB* *GL-OPERAND2-RGB* *GL-OPERAND3-RGB* *GL-OPERAND4-RGB* *GL-OPERAND5-RGB* *GL-OPERAND6-RGB* *GL-OPERAND7-RGB* *GL-OPERAND0-ALPHA* *GL-OPERAND1-ALPHA* *GL-OPERAND2-ALPHA* *GL-OPERAND3-ALPHA* *GL-OPERAND4-ALPHA* *GL-OPERAND5-ALPHA* *GL-OPERAND6-ALPHA* *GL-OPERAND7-ALPHA* *GL-DOT3-RGB* *GL-DOT3-RGBA* *GL-TRANSPOSE-MODELVIEW-MATRIX* *GL-TRANSPOSE-PROJECTION-MATRIX* *GL-TRANSPOSE-TEXTURE-MATRIX* *GL-TRANSPOSE-COLOR-MATRIX* *GL-NORMAL-MAP* *GL-REFLECTION-MAP* *GL-TEXTURE-CUBE-MAP* *GL-TEXTURE-BINDING-CUBE-MAP* *GL-TEXTURE-CUBE-MAP-POSITIVE-X* *GL-TEXTURE-CUBE-MAP-NEGATIVE-X* *GL-TEXTURE-CUBE-MAP-POSITIVE-Y* *GL-TEXTURE-CUBE-MAP-NEGATIVE-Y* *GL-TEXTURE-CUBE-MAP-POSITIVE-Z* *GL-TEXTURE-CUBE-MAP-NEGATIVE-Z* *GL-PROXY-TEXTURE-CUBE-MAP* *GL-MAX-CUBE-MAP-TEXTURE-SIZE* *GL-COMPRESSED-ALPHA* *GL-COMPRESSED-LUMINANCE* *GL-COMPRESSED-LUMINANCE-ALPHA* *GL-COMPRESSED-INTENSITY* *GL-COMPRESSED-RGB* *GL-COMPRESSED-RGBA* *GL-TEXTURE-COMPRESSION-HINT* *GL-TEXTURE-COMPRESSED-IMAGE-SIZE* *GL-TEXTURE-COMPRESSED* *GL-NUM-COMPRESSED-TEXTURE-FORMATS* *GL-COMPRESSED-TEXTURE-FORMATS* *GL-MULTISAMPLE* *GL-SAMPLE-ALPHA-TO-COVERAGE* *GL-SAMPLE-ALPHA-TO-ONE* *GL-SAMPLE-COVERAGE* *GL-SAMPLE-BUFFERS* *GL-SAMPLES* *GL-SAMPLE-COVERAGE-VALUE* *GL-SAMPLE-COVERAGE-INVERT* *GL-MULTISAMPLE-BIT* *GL-DEPTH-COMPONENT16* *GL-DEPTH-COMPONENT24* *GL-DEPTH-COMPONENT32* *GL-TEXTURE-DEPTH-SIZE* *GL-DEPTH-TEXTURE-MODE* *GL-TEXTURE-COMPARE-MODE* *GL-TEXTURE-COMPARE-FUNC* *GL-COMPARE-R-TO-TEXTURE* *GL-QUERY-COUNTER-BITS* *GL-CURRENT-QUERY* *GL-QUERY-RESULT* *GL-QUERY-RESULT-AVAILABLE* *GL-SAMPLES-PASSED* *GL-FOG-COORD-SRC* *GL-FOG-COORD* *GL-FRAGMENT-DEPTH* *GL-CURRENT-FOG-COORD* *GL-FOG-COORD-ARRAY-TYPE* *GL-FOG-COORD-ARRAY-STRIDE* *GL-FOG-COORD-ARRAY-POINTER* *GL-FOG-COORD-ARRAY* *GL-FOG-COORDINATE-SOURCE* *GL-FOG-COORDINATE* *GL-CURRENT-FOG-COORDINATE* *GL-FOG-COORDINATE-ARRAY-TYPE* *GL-FOG-COORDINATE-ARRAY-STRIDE* *GL-FOG-COORDINATE-ARRAY-POINTER* *GL-FOG-COORDINATE-ARRAY* *GL-COLOR-SUM* *GL-CURRENT-SECONDARY-COLOR* *GL-SECONDARY-COLOR-ARRAY-SIZE* *GL-SECONDARY-COLOR-ARRAY-TYPE* *GL-SECONDARY-COLOR-ARRAY-STRIDE* *GL-SECONDARY-COLOR-ARRAY-POINTER* *GL-SECONDARY-COLOR-ARRAY* *GL-POINT-SIZE-MIN* *GL-POINT-SIZE-MAX* *GL-POINT-FADE-THRESHOLD-SIZE* *GL-POINT-DISTANCE-ATTENUATION* *GL-BLEND-DST-RGB* *GL-BLEND-SRC-RGB* *GL-BLEND-DST-ALPHA* *GL-BLEND-SRC-ALPHA* *GL-GENERATE-MIPMAP* *GL-GENERATE-MIPMAP-HINT* *GL-INCR-WRAP* *GL-DECR-WRAP* *GL-MIRRORED-REPEAT* *GL-MAX-TEXTURE-LOD-BIAS* *GL-TEXTURE-FILTER-CONTROL* *GL-TEXTURE-LOD-BIAS* *GL-ARRAY-BUFFER* *GL-ELEMENT-ARRAY-BUFFER* *GL-ARRAY-BUFFER-BINDING* *GL-ELEMENT-ARRAY-BUFFER-BINDING* *GL-VERTEX-ARRAY-BUFFER-BINDING* *GL-NORMAL-ARRAY-BUFFER-BINDING* *GL-COLOR-ARRAY-BUFFER-BINDING* *GL-INDEX-ARRAY-BUFFER-BINDING* *GL-TEXTURE-COORD-ARRAY-BUFFER-BINDING* *GL-EDGE-FLAG-ARRAY-BUFFER-BINDING* *GL-SECONDARY-COLOR-ARRAY-BUFFER-BINDING* *GL-FOG-COORD-ARRAY-BUFFER-BINDING* *GL-WEIGHT-ARRAY-BUFFER-BINDING* *GL-VERTEX-ATTRIB-ARRAY-BUFFER-BINDING* *GL-STREAM-DRAW* *GL-STREAM-READ* *GL-STREAM-COPY* *GL-STATIC-DRAW* *GL-STATIC-READ* *GL-STATIC-COPY* *GL-DYNAMIC-DRAW* *GL-DYNAMIC-READ* *GL-DYNAMIC-COPY* *GL-READ-ONLY* *GL-WRITE-ONLY* *GL-READ-WRITE* *GL-BUFFER-SIZE* *GL-BUFFER-USAGE* *GL-BUFFER-ACCESS* *GL-BUFFER-MAPPED* *GL-BUFFER-MAP-POINTER* *GL-FOG-COORDINATE-ARRAY-BUFFER-BINDING* *GL-CURRENT-PROGRAM* *GL-SHADER-TYPE* *GL-DELETE-STATUS* *GL-COMPILE-STATUS* *GL-LINK-STATUS* *GL-VALIDATE-STATUS* *GL-INFO-LOG-LENGTH* *GL-ATTACHED-SHADERS* *GL-ACTIVE-UNIFORMS* *GL-ACTIVE-UNIFORM-MAX-LENGTH* *GL-SHADER-SOURCE-LENGTH* *GL-FLOAT-VEC2* *GL-FLOAT-VEC3* *GL-FLOAT-VEC4* *GL-INT-VEC2* *GL-INT-VEC3* *GL-INT-VEC4* *GL-BOOL* *GL-BOOL-VEC2* *GL-BOOL-VEC3* *GL-BOOL-VEC4* *GL-FLOAT-MAT2* *GL-FLOAT-MAT3* *GL-FLOAT-MAT4* *GL-SAMPLER-1D* *GL-SAMPLER-2D* *GL-SAMPLER-3D* *GL-SAMPLER-CUBE* *GL-SAMPLER-1D-SHADOW* *GL-SAMPLER-2D-SHADOW* *GL-SHADING-LANGUAGE-VERSION* *GL-VERTEX-SHADER* *GL-MAX-VERTEX-UNIFORM-COMPONENTS* *GL-MAX-VARYING-FLOATS* *GL-MAX-VERTEX-TEXTURE-IMAGE-UNITS* *GL-MAX-COMBINED-TEXTURE-IMAGE-UNITS* *GL-ACTIVE-ATTRIBUTES* *GL-ACTIVE-ATTRIBUTE-MAX-LENGTH* *GL-FRAGMENT-SHADER* *GL-MAX-FRAGMENT-UNIFORM-COMPONENTS* *GL-FRAGMENT-SHADER-DERIVATIVE-HINT* *GL-MAX-VERTEX-ATTRIBS* *GL-VERTEX-ATTRIB-ARRAY-ENABLED* *GL-VERTEX-ATTRIB-ARRAY-SIZE* *GL-VERTEX-ATTRIB-ARRAY-STRIDE* *GL-VERTEX-ATTRIB-ARRAY-TYPE* *GL-VERTEX-ATTRIB-ARRAY-NORMALIZED* *GL-CURRENT-VERTEX-ATTRIB* *GL-VERTEX-ATTRIB-ARRAY-POINTER* *GL-VERTEX-PROGRAM-POINT-SIZE* *GL-VERTEX-PROGRAM-TWO-SIDE* *GL-MAX-TEXTURE-COORDS* *GL-MAX-TEXTURE-IMAGE-UNITS* *GL-MAX-DRAW-BUFFERS* *GL-DRAW-BUFFER0* *GL-DRAW-BUFFER1* *GL-DRAW-BUFFER2* *GL-DRAW-BUFFER3* *GL-DRAW-BUFFER4* *GL-DRAW-BUFFER5* *GL-DRAW-BUFFER6* *GL-DRAW-BUFFER7* *GL-DRAW-BUFFER8* *GL-DRAW-BUFFER9* *GL-DRAW-BUFFER10* *GL-DRAW-BUFFER11* *GL-DRAW-BUFFER12* *GL-DRAW-BUFFER13* *GL-DRAW-BUFFER14* *GL-DRAW-BUFFER15* *GL-POINT-SPRITE* *GL-COORD-REPLACE* *GL-POINT-SPRITE-COORD-ORIGIN* *GL-LOWER-LEFT* *GL-UPPER-LEFT* *GL-STENCIL-BACK-FUNC* *GL-STENCIL-BACK-VALUE-MASK* *GL-STENCIL-BACK-REF* *GL-STENCIL-BACK-FAIL* *GL-STENCIL-BACK-PASS-DEPTH-FAIL* *GL-STENCIL-BACK-PASS-DEPTH-PASS* *GL-STENCIL-BACK-WRITEMASK* *GL-CURRENT-RASTER-SECONDARY-COLOR* *GL-PIXEL-PACK-BUFFER* *GL-PIXEL-UNPACK-BUFFER* *GL-PIXEL-PACK-BUFFER-BINDING* *GL-PIXEL-UNPACK-BUFFER-BINDING* *GL-FLOAT-MAT2x3* *GL-FLOAT-MAT2x4* *GL-FLOAT-MAT3x2* *GL-FLOAT-MAT3x4* *GL-FLOAT-MAT4x2* *GL-FLOAT-MAT4x3* *GL-SRGB* *GL-SRGB8* *GL-SRGB-ALPHA* *GL-SRGB8-ALPHA8* *GL-SLUMINANCE-ALPHA* *GL-SLUMINANCE8-ALPHA8* *GL-SLUMINANCE* *GL-SLUMINANCE8* *GL-COMPRESSED-SRGB* *GL-COMPRESSED-SRGB-ALPHA* *GL-COMPRESSED-SLUMINANCE* *GL-COMPRESSED-SLUMINANCE-ALPHA* *GL-LOGIC-OP* *GL-TEXTURE-COMPONENTS* *GLX-USE-GL* *GLX-BUFFER-SIZE* *GLX-LEVEL* *GLX-RGBA* *GLX-DOUBLEBUFFER* *GLX-STEREO* *GLX-AUX-BUFFERS* *GLX-RED-SIZE* *GLX-GREEN-SIZE* *GLX-BLUE-SIZE* *GLX-ALPHA-SIZE* *GLX-DEPTH-SIZE* *GLX-STENCIL-SIZE* *GLX-ACCUM-RED-SIZE* *GLX-ACCUM-GREEN-SIZE* *GLX-ACCUM-BLUE-SIZE* *GLX-ACCUM-ALPHA-SIZE* *GLX-BAD-SCREEN* *GLX-BAD-ATTRIBUTE* *GLX-NO-EXTENSION* *GLX-BAD-VISUAL* *StaticGray* *GrayScale* *StaticColor* *PseudoColor* *TrueColor* *DirectColor* GLU-ERROR-STRING GLU-GET-STRING GLU-ORTHO2-D GLU-PERSPECTIVE GLU-PICK-MATRIX GLU-LOOK-AT GLU-PROJECT GLU-UN-PROJECT GLU-SCALE-IMAGE GLU-BUILD1-DMIPMAPS GLU-BUILD2-DMIPMAPS GLUQUADRIC-OBJ GLU-NEW-QUADRIC GLU-DELETE-QUADRIC GLU-QUADRIC-NORMALS GLU-QUADRIC-TEXTURE GLU-QUADRIC-ORIENTATION GLU-QUADRIC-DRAW-STYLE GLU-CYLINDER GLU-DISK GLU-PARTIAL-DISK GLU-SPHERE GLU-QUADRIC-CALLBACK GLUTRIANGULATOR-OBJ GLU-NEW-TESS GLU-TESS-CALLBACK GLU-DELETE-TESS GLU-BEGIN-POLYGON GLU-END-POLYGON GLU-NEXT-CONTOUR GLU-TESS-VERTEX GLUNURBS-OBJ GLU-NEW-NURBS-RENDERER GLU-DELETE-NURBS-RENDERER GLU-BEGIN-SURFACE GLU-BEGIN-CURVE GLU-END-CURVE GLU-END-SURFACE GLU-BEGIN-TRIM GLU-END-TRIM GLU-PWL-CURVE GLU-NURBS-CURVE GLU-NURBS-SURFACE GLU-LOAD-SAMPLING-MATRICES GLU-NURBS-PROPERTY GLU-GET-NURBS-PROPERTY GLU-NURBS-CALLBACK GLX-CHOOSE-VISUAL GLX-COPY-CONTEXT GLX-CREATE-CONTEXT GLX-CREATE-GLXPIXMAP GLX-DESTROY-CONTEXT GLX-DESTROY-GLXPIXMAP GLX-GET-CONFIG GLX-GET-CURRENT-CONTEXT GLX-GET-CURRENT-DRAWABLE GLX-IS-DIRECT GLX-MAKE-CURRENT GLX-QUERY-EXTENSION GLX-QUERY-VERSION GLX-SWAP-BUFFERS GLX-USE-XFONT GLX-WAIT-GL GLX-WAIT-X GLX-QUERY-EXTENSIONS-STRING GLX-GET-CLIENT-STRING GLX-QUERY-SERVER-STRING GLX-GET-VIDEO-SYNC-SGI GLX-WAIT-VIDEO-SYNC-SGI GLX-SWAP-INTERVAL-SGI GLX-SWAP-MODE-SGI ) (:export GL-VECTOR MAKE-GL-VECTOR GL-VECTOR-AREF WITH-GL-VECTORS ) (:export "OPENGL-PANE" ) ) #+(and pthreads ffi-x11) (fli::mark-package-foreign-callers-keep-lock "OPENGL" :non-concurrent)
37,493
Common Lisp
.lisp
1,694
18.075561
149
0.685358
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
71b9aa675285700bb1c89d79d307c982fbd43a9a70535deb7fc0975ab371cd51
814
[ -1 ]
815
xfns.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/xfns.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/xfns.lisp,v 1.6.3.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") ;; Names for attributes to glXGetConfig. (defconstant *GLX-USE-GL* 1) ;; support GLX rendering */ (defconstant *GLX-BUFFER-SIZE* 2) ;; depth of the color buffer */ (defconstant *GLX-LEVEL* 3) ;; level in plane stacking */ (defconstant *GLX-RGBA* 4) ;; true if RGBA mode */ (defconstant *GLX-DOUBLEBUFFER* 5) ;; double buffering supported */ (defconstant *GLX-STEREO* 6) ;; stereo buffering supported */ (defconstant *GLX-AUX-BUFFERS* 7) ;; number of aux buffers */ (defconstant *GLX-RED-SIZE* 8) ;; number of red component bits */ (defconstant *GLX-GREEN-SIZE* 9) ;; number of green component bits */ (defconstant *GLX-BLUE-SIZE* 10) ;; number of blue component bits */ (defconstant *GLX-ALPHA-SIZE* 11) ;; number of alpha component bits */ (defconstant *GLX-DEPTH-SIZE* 12) ;; number of depth bits */ (defconstant *GLX-STENCIL-SIZE* 13) ;; number of stencil bits */ (defconstant *GLX-ACCUM-RED-SIZE* 14) ;; number of red accum bits */ (defconstant *GLX-ACCUM-GREEN-SIZE* 15) ;; number of green accum bits */ (defconstant *GLX-ACCUM-BLUE-SIZE* 16) ;; number of blue accum bits */ (defconstant *GLX-ACCUM-ALPHA-SIZE* 17) ;; number of alpha accum bits */ (defconstant *glx-get-config-attributes* `((,*GLX-USE-GL* *GLX-USE-GL* "~[Does NOT support~;Supports~] OpenGL rendering") (,*GLX-BUFFER-SIZE* *GLX-BUFFER-SIZE* "Color buffer size : ~d") (,*GLX-LEVEL* *GLX-LEVEL* "Frame buffer level : ~d") (,*GLX-RGBA* *GLX-RGBA* "Uses ~[Color Index~;RGBA~] mode") (,*GLX-DOUBLEBUFFER* *GLX-DOUBLEBUFFER* "Is ~[single~;double~]-buffered") (,*GLX-STEREO* *GLX-STEREO* "~[Does not support~;Supports~] stereo buffers") (,*GLX-AUX-BUFFERS* *GLX-AUX-BUFFERS* "Has ~d aux buffers") (,*GLX-RED-SIZE* *GLX-RED-SIZE* "Has ~d bits in the red component") (,*GLX-GREEN-SIZE* *GLX-GREEN-SIZE* "Has ~d bits in the green component") (,*GLX-BLUE-SIZE* *GLX-BLUE-SIZE* "Has ~d bits in the blue component") (,*GLX-ALPHA-SIZE* *GLX-ALPHA-SIZE* "Has ~d bits in the alpha component") (,*GLX-DEPTH-SIZE* *GLX-DEPTH-SIZE* "Depth buffer size = ~d bits") (,*GLX-STENCIL-SIZE* *GLX-STENCIL-SIZE* "Has ~d stencil bits") (,*GLX-ACCUM-RED-SIZE* *GLX-ACCUM-RED-SIZE* "Accumulation buffer red channel is ~d bits") (,*GLX-ACCUM-GREEN-SIZE* *GLX-ACCUM-GREEN-SIZE* "Accumulation buffer green channel is ~d bits") (,*GLX-ACCUM-BLUE-SIZE* *GLX-ACCUM-BLUE-SIZE* "Accumulation buffer blue channel is ~d bits") (,*GLX-ACCUM-ALPHA-SIZE* *GLX-ACCUM-ALPHA-SIZE* "Accumulation buffer alpha channel is ~d bits"))) ;; ;; Error return values from glXGetConfig. Success is indicated by ;; a value of 0. (defconstant *GLX-BAD-SCREEN* 1) ;; screen # is bad */ (defconstant *GLX-BAD-ATTRIBUTE* 2) ;; attribute to get is bad */ (defconstant *GLX-NO-EXTENSION* 3) ;; no glx extension on server */ (defconstant *GLX-BAD-VISUAL* 4) ;; visual # not known by GLX */ (fli:define-c-typedef (xid (:foreign-name "XID")) (:unsigned :long)) (fli:define-c-typedef (visual (:foreign-name "Visual")) (:struct (ext-data :pointer) (visualid xid) (class :int) (red-mask (:unsigned :long)) (green-mask (:unsigned :long)) (blue-mask (:unsigned :long)) (bits-per-rgb :int) (map-entries :int))) (fli:define-c-typedef (x-visual-info (:foreign-name "XVisualInfo")) (:struct (visual (:pointer visual)) (visualid xid) (screen-number :int) (depth :int) (class :int) (red-mask (:unsigned :long)) (green-mask (:unsigned :long)) (blue-mask (:unsigned :long)) (colormap-size :int) (bits-per-rgb :int))) ;;; because this file is used for xm-lib and gtk-lib, the actual type of ;;; the pointer ae are going to get is different. So we use this ;;; definitions to accept any pointer, (fli:define-foreign-type x-display-pointer () :pointer) (fli:define-foreign-type x-visual-info-pointer () '(:pointer x-visual-info)) (fli:define-foreign-type x-font-pointer () :pointer) (fli:define-c-typedef (glxcontext-id (:foreign-name "GLXContextID")) xid) (fli:define-c-typedef (glxpixmap (:foreign-name "GLXPixmap")) xid) (fli:define-c-typedef (glxdrawable (:foreign-name "GLXDrawable")) xid) (fli:define-c-typedef (glxcontext (:foreign-name "GLXContext")) (:pointer (:struct --glxcontext-rec))) (fli:define-foreign-function (glx-choose-visual "glXChooseVisual" :source) ((dpy x-display-pointer) (screen-number :int) (attrib-list (gl-vector :signed-32))) :result-type x-visual-info-pointer :language :ansi-c) (fli:define-foreign-function (glx-copy-context "glXCopyContext" :source) ((dpy x-display-pointer) (src glxcontext) (dst glxcontext) (mask gluint)) :language :ansi-c) (fli:define-foreign-function (glx-create-context "glXCreateContext" :source) ((dpy x-display-pointer) (vis x-visual-info-pointer) (share-list glxcontext) (direct :boolean)) :result-type (:wrapper glxcontext :foreign-to-lisp (lambda (x) (if (fli:null-pointer-p x) nil x))) :language :ansi-c) (fli:define-foreign-function (glx-create-glxpixmap "glXCreateGLXPixmap" :source) ((dpy x-display-pointer) (vis x-visual-info-pointer) (pixmap xid)) :result-type glxpixmap :language :ansi-c) (fli:define-foreign-function (glx-destroy-context "glXDestroyContext" :source) ((dpy x-display-pointer) (ctx glxcontext)) :language :ansi-c) (fli:define-foreign-function (glx-destroy-glxpixmap "glXDestroyGLXPixmap" :source) ((dpy x-display-pointer) (pix glxpixmap)) :language :ansi-c) (fli:define-foreign-function (glx-get-config "glXGetConfig" :source) ((dpy x-display-pointer) (visual-info x-visual-info-pointer) (attribute (:signed :int)) (value (:reference-return (:signed :int)))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glx-get-current-context "glXGetCurrentContext" :source) () :result-type glxcontext :language :ansi-c) (fli:define-foreign-function (glx-get-current-drawable "glXGetCurrentDrawable" :source) () :result-type glxdrawable :language :ansi-c) (fli:define-foreign-function (glx-is-direct "glXIsDirect" :source) ((dpy x-display-pointer) (ctx glxcontext)) :result-type :boolean :language :ansi-c) (fli:define-foreign-function (glx-make-current "glXMakeCurrent" :source) ((dpy x-display-pointer) (drawable glxdrawable) (ctx glxcontext)) :result-type :boolean :language :ansi-c) (fli:define-foreign-function (glx-query-extension "glXQueryExtension" :source) ((dpy x-display-pointer) (error-base (:pointer (:signed :int))) (event-base (:pointer (:signed :int)))) :result-type :boolean :language :ansi-c) (fli:define-foreign-function (glx-query-version "glXQueryVersion" :source) ((dpy x-display-pointer) (major (:pointer (:signed :int))) (minor (:pointer (:signed :int)))) :result-type :boolean :language :ansi-c) (fli:define-foreign-function (glx-swap-buffers "glXSwapBuffers" :source) ((dpy x-display-pointer) (drawable glxdrawable)) :language :ansi-c) (fli:define-foreign-function (glx-use-xfont "glXUseXFont" :source) ((font x-font-pointer) (first (:signed :int)) (count (:signed :int)) (list-base (:signed :int))) :language :ansi-c) (fli:define-foreign-function (glx-wait-gl "glXWaitGL" :source) () :language :ansi-c) (fli:define-foreign-function (glx-wait-x "glXWaitX" :source) () :language :ansi-c) (fli:define-foreign-function (glx-query-extensions-string "glXQueryExtensionsString" :source) ((dpy x-display-pointer) (screen :int)) :result-type (:pointer (:const :char)) :language :ansi-c) (fli:define-foreign-function (glx-get-client-string "glXGetClientString" :source) ((dpy x-display-pointer) (name (:signed :int))) :result-type (:pointer (:const :char)) :language :ansi-c) (fli:define-foreign-function (glx-query-server-string "glXQueryServerString" :source) ((dpy x-display-pointer) (screen :int) (name (:signed :int))) :result-type (:pointer (:const :char)) :language :ansi-c) (fli:define-foreign-function (glx-get-video-sync-sgi "glXGetVideoSyncSGI" :source) ((count (:pointer (:unsigned :int)))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glx-wait-video-sync-sgi "glXWaitVideoSyncSGI" :source) ((divisor (:signed :int)) (remainder (:signed :int)) (count (:pointer (:unsigned :int)))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glx-swap-interval-sgi "glXSwapIntervalSGI" :source) ((interval (:signed :int))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glx-swap-mode-sgi "glXSwapModeSGI" :source) ((mode (:signed :int)) (params (:pointer (:signed :int)))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (x-free "XFree" :source) ((data :pointer)) :language :c) (fli:define-foreign-function (%x-get-visual-info "XGetVisualInfo" :source) ((display x-display-pointer) (vinfo-mask :long) (vinfo-template x-visual-info-pointer) (:ignore (:reference-return :int))) ;nitems-return :result-type x-visual-info-pointer :language :c) ;;; Caller needs to x-free the result (if non-nil) (defun x-visual-info-from-visual (display visual) (fli:with-coerced-pointer (visual-poi :type 'visual) visual (let ((id (fli:foreign-slot-value visual-poi 'visualid))) (multiple-value-bind (x-info num) (fli:with-dynamic-foreign-objects ((visual-info-template x-visual-info)) (setf (fli:foreign-slot-value visual-info-template 'visualid) id) (%x-get-visual-info display 1 ;;;; VisualIDMask visual-info-template)) (if (= num 1) x-info nil))))) (defun call-glx-create-context (xdisplay visual share directp) (when-let (xvi (x-visual-info-from-visual xdisplay visual)) (prog1 (glx-create-context xdisplay xvi share directp) (x-free xvi)))) (defun indexed-colormap-p (configuration) (not (or (getf configuration :rgb) (getf configuration :rgba)))) ;;; Note: This is called inside the library lock. (defun call-glx-Choose-Visual (display screen-number configuration) "Return a visual info structure which supports the requested configuration. Configuration is a plist with the following allowed indicators: :double-buffer, :double-buffered, - synonyms, value T or NIL. :buffer-size - color buffer size for indexed colormap visuals :red-size, :green-size, :blue-size, :alpha-size - sizes of color buffer channels for RGB visuals. :accum - accumulator buffer size (per channel), or NIL. :accum-red-size, accum-green-size, accum-blue-size, accum-alpha-size - sizes of accumulator buffer channels, which default to the :accum value. :depth-buffer - value is a depth buffer size or NIL :stencil-size - stencil buffer size or NIL. :aux - aux buffer size or NIL." (let ((params (append (when (or (getf configuration :double-buffer) (getf configuration :double-buffered)) (list *GLX-DOUBLEBUFFER*)) (if (indexed-colormap-p configuration) (list *GLX-BUFFER-SIZE* (getf configuration :buffer-size 1)) (append (list *GLX-RGBA* *GLX-RED-SIZE* (getf configuration :red-size 1) *GLX-GREEN-SIZE* (getf configuration :green-size 1) *GLX-BLUE-SIZE* (getf configuration :blue-size 1)) (when (getf configuration :alpha-size) (list *GLX-ALPHA-SIZE* (getf configuration :alpha-size))) (let ((accum (getf configuration :accum))) (when accum (list *GLX-ACCUM-RED-SIZE* (getf configuration :accum-red-size accum) *GLX-ACCUM-GREEN-SIZE* (getf configuration :accum-green-size accum) *GLX-ACCUM-BLUE-SIZE* (getf configuration :accum-blue-size accum) *GLX-ACCUM-ALPHA-SIZE* (getf configuration :accum-alpha-size accum)))))) (let ((depth (getf configuration :depth-buffer))) (when depth (list *GLX-DEPTH-SIZE* depth))) (let ((stencil (getf configuration :stencil-size))) (when stencil (list *GLX-STENCIL-SIZE* stencil))) (let ((aux (getf configuration :aux 0))) (list *GLX-AUX-BUFFERS* aux)) (list 0)))) (fli:with-dynamic-foreign-objects () (let* ((vparams #+:use-fli-gl-vector (fli:allocate-dynamic-foreign-object :type '(:signed :int) :initial-contents params) #-:use-fli-gl-vector (sys:in-static-area (make-array (length params) :element-type '(signed-byte 32) :initial-contents params))) (visual-info (glx-Choose-Visual display screen-number vparams))) (if (fli:null-pointer-p visual-info) nil visual-info)) )))
14,036
Common Lisp
.lisp
289
40.882353
149
0.638265
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
46c82d3309099d480444a55ce03c2e79bf6bc1fa677f79367beedb67910af87b
815
[ -1 ]
816
loader.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/loader.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/loader.lisp,v 1.7.1.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "CL-USER") ;; Ensure a connection to the foreign OpenGL libraries. (eval-when (load eval) #+mswindows (progn (fli:register-module "OPENGL32" :connection-style :immediate) (fli:register-module "GLU32" :connection-style :immediate) ) #+Linux (progn ;; Ideally libGL.so and libGLU.so would be loaded directly, but ;; there might be problems most likely caused by libGLU.so not having ;; an SO_NEEDED dependency on libGL.so. As a workaround, create a ;; combined file beforehand as follows: ;; ;; $ cd /tmp; ld -shared -o gl.so -L/usr/X11R6/lib -lGLU -lGL -lm ;; or ;; $ cd /tmp; ld -shared -o gl64.so -L/usr/X11R6/lib64 -lGLU -lGL -lm ;; ;; (fli:register-module #-lispworks-64bit "/tmp/gl.so" ;; #+lispworks-64bit "/tmp/gl64.so" ;; :connection-style :immediate) (dolist (name '("-lGL" "-lGLU")) (fli:register-module name)) ) #+Darwin (cond ((member :cocoa *features*) (let ((root "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/")) (fli:register-module (merge-pathnames "libGL.dylib" root)) (fli:register-module (merge-pathnames "libGLU.dylib" root)))) ((member :ffi-x11 *features*) (let ((root "/usr/X11R6/lib/")) (fli:register-module (merge-pathnames "libGL.dylib" root)) (fli:register-module (merge-pathnames "libGLU.dylib" root))))) #+FreeBSD (dolist (name '("-lGL" "-lGLU")) (fli:register-module name)) #+Solaris2 (dolist (name '("-lGL" "-lGLU")) (fli:register-module name)) #+AIX (dolist (name '("-lGL" "-lGLU" "-lXext" "-lX11" "-lIM" ; Not obvious that these are needed )) (fli:register-module name)) #+HP-UX (link-load:read-foreign-modules "-L/opt/graphics/OpenGL/lib" "-lGL" "-lGLU") #+IRIX (link-load:read-foreign-modules "-lGLcore" "-lGL" "-lGLU" "-lX11") )
2,263
Common Lisp
.lisp
53
35.924528
151
0.607339
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
e0fc1995ec7fe80a4bcb20951f232fade470d577354424c4cc65080f258d8e5c
816
[ -1 ]
817
constants.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/constants.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/constants.lisp,v 1.6.1.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") ;; AccumOp (defconstant *GL-ACCUM* #x0100) (defconstant *GL-LOAD* #x0101) (defconstant *GL-RETURN* #x0102) (defconstant *GL-MULT* #x0103) (defconstant *GL-ADD* #x0104) ;; AlphaFunction (defconstant *GL-NEVER* #x0200) (defconstant *GL-LESS* #x0201) (defconstant *GL-EQUAL* #x0202) (defconstant *GL-LEQUAL* #x0203) (defconstant *GL-GREATER* #x0204) (defconstant *GL-NOTEQUAL* #x0205) (defconstant *GL-GEQUAL* #x0206) (defconstant *GL-ALWAYS* #x0207) ;; AttribMask (defconstant *GL-CURRENT-BIT* #x00000001) (defconstant *GL-POINT-BIT* #x00000002) (defconstant *GL-LINE-BIT* #x00000004) (defconstant *GL-POLYGON-BIT* #x00000008) (defconstant *GL-POLYGON-STIPPLE-BIT* #x00000010) (defconstant *GL-PIXEL-MODE-BIT* #x00000020) (defconstant *GL-LIGHTING-BIT* #x00000040) (defconstant *GL-FOG-BIT* #x00000080) (defconstant *GL-DEPTH-BUFFER-BIT* #x00000100) (defconstant *GL-ACCUM-BUFFER-BIT* #x00000200) (defconstant *GL-STENCIL-BUFFER-BIT* #x00000400) (defconstant *GL-VIEWPORT-BIT* #x00000800) (defconstant *GL-TRANSFORM-BIT* #x00001000) (defconstant *GL-ENABLE-BIT* #x00002000) (defconstant *GL-COLOR-BUFFER-BIT* #x00004000) (defconstant *GL-HINT-BIT* #x00008000) (defconstant *GL-EVAL-BIT* #x00010000) (defconstant *GL-LIST-BIT* #x00020000) (defconstant *GL-TEXTURE-BIT* #x00040000) (defconstant *GL-SCISSOR-BIT* #x00080000) (defconstant *GL-ALL-ATTRIB-BITS* #x000fffff) ;; BeginMode (defconstant *GL-POINTS* #x0000) (defconstant *GL-LINES* #x0001) (defconstant *GL-LINE-LOOP* #x0002) (defconstant *GL-LINE-STRIP* #x0003) (defconstant *GL-TRIANGLES* #x0004) (defconstant *GL-TRIANGLE-STRIP* #x0005) (defconstant *GL-TRIANGLE-FAN* #x0006) (defconstant *GL-QUADS* #x0007) (defconstant *GL-QUAD-STRIP* #x0008) (defconstant *GL-POLYGON* #x0009) ;; BlendEquationMode ;; GL-LOGIC-OP ;; GL-FUNC-ADD ;; GL-MIN ;; GL-MAX ;; GL-FUNC-SUBTRACT ;; GL-FUNC-REVERSE-SUBTRACT ;; BlendingFactorDest (defconstant *GL-ZERO* #x0) (defconstant *GL-ONE* #x1) (defconstant *GL-SRC-COLOR* #x0300) (defconstant *GL-ONE-MINUS-SRC-COLOR* #x0301) (defconstant *GL-SRC-ALPHA* #x0302) (defconstant *GL-ONE-MINUS-SRC-ALPHA* #x0303) (defconstant *GL-DST-ALPHA* #x0304) (defconstant *GL-ONE-MINUS-DST-ALPHA* #x0305) ;; GL-CONSTANT-COLOR ;; GL-ONE-MINUS-CONSTANT-COLOR ;; GL-CONSTANT-ALPHA ;; GL-ONE-MINUS-CONSTANT-ALPHA ;; BlendingFactorSrc ;; GL-ZERO ;; GL-ONE (defconstant *GL-DST-COLOR* #x0306) (defconstant *GL-ONE-MINUS-DST-COLOR* #x0307) (defconstant *GL-SRC-ALPHA-SATURATE* #x0308) ;; GL-SRC-ALPHA ;; GL-ONE-MINUS-SRC-ALPHA ;; GL-DST-ALPHA ;; GL-ONE-MINUS-DST-ALPHA ;; GL-CONSTANT-COLOR ;; GL-ONE-MINUS-CONSTANT-COLOR ;; GL-CONSTANT-ALPHA ;; GL-ONE-MINUS-CONSTANT-ALPHA ;; Boolean (defconstant *GL-TRUE* #x1) (defconstant *GL-FALSE* #x0) ;; ClearBufferMask ;; GL-COLOR-BUFFER-BIT ;; GL-ACCUM-BUFFER-BIT ;; GL-STENCIL-BUFFER-BIT ;; GL-DEPTH-BUFFER-BIT ;; ClientArrayType ;; GL-VERTEX-ARRAY ;; GL-NORMAL-ARRAY ;; GL-COLOR-ARRAY ;; GL-INDEX-ARRAY ;; GL-TEXTURE-COORD-ARRAY ;; GL-EDGE-FLAG-ARRAY ;; ClipPlaneName (defconstant *GL-CLIP-PLANE0* #x3000) (defconstant *GL-CLIP-PLANE1* #x3001) (defconstant *GL-CLIP-PLANE2* #x3002) (defconstant *GL-CLIP-PLANE3* #x3003) (defconstant *GL-CLIP-PLANE4* #x3004) (defconstant *GL-CLIP-PLANE5* #x3005) ;; ColorMaterialFace ;; GL-FRONT ;; GL-BACK ;; GL-FRONT-AND-BACK ;; ColorMaterialParameter ;; GL-AMBIENT ;; GL-DIFFUSE ;; GL-SPECULAR ;; GL-EMISSION ;; GL-AMBIENT-AND-DIFFUSE ;; ColorPointerType ;; GL-BYTE ;; GL-UNSIGNED-BYTE ;; GL-SHORT ;; GL-UNSIGNED-SHORT ;; GL-INT ;; GL-UNSIGNED-INT ;; GL-FLOAT ;; GL-DOUBLE ;; ColorTableParameterPName ;; GL-COLOR-TABLE-SCALE ;; GL-COLOR-TABLE-BIAS ;; ColorTableTarget ;; GL-COLOR-TABLE ;; GL-POST-CONVOLUTION-COLOR-TABLE ;; GL-POST-COLOR-MATRIX-COLOR-TABLE ;; GL-PROXY-COLOR-TABLE ;; GL-PROXY-POST-CONVOLUTION-COLOR-TABLE ;; GL-PROXY-POST-COLOR-MATRIX-COLOR-TABLE ;; ConvolutionBorderMode ;; GL-REDUCE ;; GL-IGNORE-BORDER ;; GL-CONSTANT-BORDER ;; ConvolutionParameter ;; GL-CONVOLUTION-BORDER-MODE ;; GL-CONVOLUTION-FILTER-SCALE ;; GL-CONVOLUTION-FILTER-BIAS ;; ConvolutionTarget ;; GL-CONVOLUTION-1D ;; GL-CONVOLUTION-2D ;; CullFaceMode ;; GL-FRONT ;; GL-BACK ;; GL-FRONT-AND-BACK ;; DataType (defconstant *GL-BYTE* #x1400) (defconstant *GL-UNSIGNED-BYTE* #x1401) (defconstant *GL-SHORT* #x1402) (defconstant *GL-UNSIGNED-SHORT* #x1403) (defconstant *GL-INT* #x1404) (defconstant *GL-UNSIGNED-INT* #x1405) (defconstant *GL-FLOAT* #x1406) (defconstant *GL-2-BYTES* #x1407) (defconstant *GL-3-BYTES* #x1408) (defconstant *GL-4-BYTES* #x1409) (defconstant *GL-DOUBLE* #x140A) ;; DepthFunction (same as AlphaFunction) ;; GL-NEVER ;; GL-LESS ;; GL-EQUAL ;; GL-LEQUAL ;; GL-GREATER ;; GL-NOTEQUAL ;; GL-GEQUAL ;; GL-ALWAYS ;; DrawBufferMode (defconstant *GL-NONE* #x0) (defconstant *GL-FRONT-LEFT* #x0400) (defconstant *GL-FRONT-RIGHT* #x0401) (defconstant *GL-BACK-LEFT* #x0402) (defconstant *GL-BACK-RIGHT* #x0403) (defconstant *GL-FRONT* #x0404) (defconstant *GL-BACK* #x0405) (defconstant *GL-LEFT* #x0406) (defconstant *GL-RIGHT* #x0407) (defconstant *GL-FRONT-AND-BACK* #x0408) (defconstant *GL-AUX0* #x0409) (defconstant *GL-AUX1* #x040A) (defconstant *GL-AUX2* #x040B) (defconstant *GL-AUX3* #x040C) ;; Enable ;; GL-FOG ;; GL-LIGHTING ;; GL-TEXTURE-1D ;; GL-TEXTURE-2D ;; GL-LINE-STIPPLE ;; GL-POLYGON-STIPPLE ;; GL-CULL-FACE ;; GL-ALPHA-TEST ;; GL-BLEND ;; GL-INDEX-LOGIC-OP ;; GL-COLOR-LOGIC-OP ;; GL-DITHER ;; GL-STENCIL-TEST ;; GL-DEPTH-TEST ;; GL-CLIP-PLANE0 ;; GL-CLIP-PLANE1 ;; GL-CLIP-PLANE2 ;; GL-CLIP-PLANE3 ;; GL-CLIP-PLANE4 ;; GL-CLIP-PLANE5 ;; GL-LIGHT0 ;; GL-LIGHT1 ;; GL-LIGHT2 ;; GL-LIGHT3 ;; GL-LIGHT4 ;; GL-LIGHT5 ;; GL-LIGHT6 ;; GL-LIGHT7 ;; GL-TEXTURE-GEN-S ;; GL-TEXTURE-GEN-T ;; GL-TEXTURE-GEN-R ;; GL-TEXTURE-GEN-Q ;; GL-MAP1-VERTEX-3 ;; GL-MAP1-VERTEX-4 ;; GL-MAP1-COLOR-4 ;; GL-MAP1-INDEX ;; GL-MAP1-NORMAL ;; GL-MAP1-TEXTURE-COORD-1 ;; GL-MAP1-TEXTURE-COORD-2 ;; GL-MAP1-TEXTURE-COORD-3 ;; GL-MAP1-TEXTURE-COORD-4 ;; GL-MAP2-VERTEX-3 ;; GL-MAP2-VERTEX-4 ;; GL-MAP2-COLOR-4 ;; GL-MAP2-INDEX ;; GL-MAP2-NORMAL ;; GL-MAP2-TEXTURE-COORD-1 ;; GL-MAP2-TEXTURE-COORD-2 ;; GL-MAP2-TEXTURE-COORD-3 ;; GL-MAP2-TEXTURE-COORD-4 ;; GL-POINT-SMOOTH ;; GL-LINE-SMOOTH ;; GL-POLYGON-SMOOTH ;; GL-SCISSOR-TEST ;; GL-COLOR-MATERIAL ;; GL-NORMALIZE ;; GL-AUTO-NORMAL ;; GL-VERTEX-ARRAY ;; GL-NORMAL-ARRAY ;; GL-COLOR-ARRAY ;; GL-INDEX-ARRAY ;; GL-TEXTURE-COORD-ARRAY ;; GL-EDGE-FLAG-ARRAY ;; GL-POLYGON-OFFSET-POINT ;; GL-POLYGON-OFFSET-LINE ;; GL-POLYGON-OFFSET-FILL ;; GL-COLOR-TABLE ;; GL-POST-CONVOLUTION-COLOR-TABLE ;; GL-POST-COLOR-MATRIX-COLOR-TABLE ;; GL-CONVOLUTION-1D ;; GL-CONVOLUTION-2D ;; GL-SEPARABLE-2D ;; GL-HISTOGRAM ;; GL-MINMAX ;; GL-RESCALE-NORMAL ;; GL-TEXTURE-3D ;; ErrorCode (defconstant *GL-NO-ERROR* #x0) (defconstant *GL-INVALID-ENUM* #x0500) (defconstant *GL-INVALID-VALUE* #x0501) (defconstant *GL-INVALID-OPERATION* #x0502) (defconstant *GL-STACK-OVERFLOW* #x0503) (defconstant *GL-STACK-UNDERFLOW* #x0504) (defconstant *GL-OUT-OF-MEMORY* #x0505) ;; GL-TABLE-TOO-LARGE ;; FeedBackMode (defconstant *GL-2D* #x0600) (defconstant *GL-3D* #x0601) (defconstant *GL-3D-COLOR* #x0602) (defconstant *GL-3D-COLOR-TEXTURE* #x0603) (defconstant *GL-4D-COLOR-TEXTURE* #x0604) ;; FeedBackToken (defconstant *GL-PASS-THROUGH-TOKEN* #x0700) (defconstant *GL-POINT-TOKEN* #x0701) (defconstant *GL-LINE-TOKEN* #x0702) (defconstant *GL-POLYGON-TOKEN* #x0703) (defconstant *GL-BITMAP-TOKEN* #x0704) (defconstant *GL-DRAW-PIXEL-TOKEN* #x0705) (defconstant *GL-COPY-PIXEL-TOKEN* #x0706) (defconstant *GL-LINE-RESET-TOKEN* #x0707) ;; FogMode ;; GL-LINEAR (defconstant *GL-EXP* #x0800) (defconstant *GL-EXP2* #x0801) ;; FogParameter ;; GL-FOG-COLOR ;; GL-FOG-DENSITY ;; GL-FOG-END ;; GL-FOG-INDEX ;; GL-FOG-MODE ;; GL-FOG-START ;; FrontFaceDirection (defconstant *GL-CW* #x0900) (defconstant *GL-CCW* #x0901) ;; GetColorTableParameterPName ;; GL-COLOR-TABLE-SCALE ;; GL-COLOR-TABLE-BIAS ;; GL-COLOR-TABLE-FORMAT ;; GL-COLOR-TABLE-WIDTH ;; GL-COLOR-TABLE-RED-SIZE ;; GL-COLOR-TABLE-GREEN-SIZE ;; GL-COLOR-TABLE-BLUE-SIZE ;; GL-COLOR-TABLE-ALPHA-SIZE ;; GL-COLOR-TABLE-LUMINANCE-SIZE ;; GL-COLOR-TABLE-INTENSITY-SIZE ;; GetConvolutionParameterPName ;; GL-CONVOLUTION-BORDER-COLOR ;; GL-CONVOLUTION-BORDER-MODE ;; GL-CONVOLUTION-FILTER-SCALE ;; GL-CONVOLUTION-FILTER-BIAS ;; GL-CONVOLUTION-FORMAT ;; GL-CONVOLUTION-WIDTH ;; GL-CONVOLUTION-HEIGHT ;; GL-MAX-CONVOLUTION-WIDTH ;; GL-MAX-CONVOLUTION-HEIGHT ;; GetHistogramParameterPName ;; GL-HISTOGRAM-WIDTH ;; GL-HISTOGRAM-FORMAT ;; GL-HISTOGRAM-RED-SIZE ;; GL-HISTOGRAM-GREEN-SIZE ;; GL-HISTOGRAM-BLUE-SIZE ;; GL-HISTOGRAM-ALPHA-SIZE ;; GL-HISTOGRAM-LUMINANCE-SIZE ;; GL-HISTOGRAM-SINK ;; GetMapTarget (defconstant *GL-COEFF* #x0A00) (defconstant *GL-ORDER* #x0A01) (defconstant *GL-DOMAIN* #x0A02) ;; GetMinmaxParameterPName ;; GL-MINMAX-FORMAT ;; GL-MINMAX-SINK ;; GetPixelMap ;; GL-PIXEL-MAP-I-TO-I ;; GL-PIXEL-MAP-S-TO-S ;; GL-PIXEL-MAP-I-TO-R ;; GL-PIXEL-MAP-I-TO-G ;; GL-PIXEL-MAP-I-TO-B ;; GL-PIXEL-MAP-I-TO-A ;; GL-PIXEL-MAP-R-TO-R ;; GL-PIXEL-MAP-G-TO-G ;; GL-PIXEL-MAP-B-TO-B ;; GL-PIXEL-MAP-A-TO-A ;; GetPointerTarget ;; GL-VERTEX-ARRAY-POINTER ;; GL-NORMAL-ARRAY-POINTER ;; GL-COLOR-ARRAY-POINTER ;; GL-INDEX-ARRAY-POINTER ;; GL-TEXTURE-COORD-ARRAY-POINTER ;; GL-EDGE-FLAG-ARRAY-POINTER ;; GetTarget (defconstant *GL-CURRENT-COLOR* #x0B00) (defconstant *GL-CURRENT-INDEX* #x0B01) (defconstant *GL-CURRENT-NORMAL* #x0B02) (defconstant *GL-CURRENT-TEXTURE-COORDS* #x0B03) (defconstant *GL-CURRENT-RASTER-COLOR* #x0B04) (defconstant *GL-CURRENT-RASTER-INDEX* #x0B05) (defconstant *GL-CURRENT-RASTER-TEXTURE-COORDS* #x0B06) (defconstant *GL-CURRENT-RASTER-POSITION* #x0B07) (defconstant *GL-CURRENT-RASTER-POSITION-VALID* #x0B08) (defconstant *GL-CURRENT-RASTER-DISTANCE* #x0B09) (defconstant *GL-POINT-SMOOTH* #x0B10) (defconstant *GL-POINT-SIZE* #x0B11) (defconstant *GL-POINT-SIZE-RANGE* #x0B12) (defconstant *GL-POINT-SIZE-GRANULARITY* #x0B13) (defconstant *GL-LINE-SMOOTH* #x0B20) (defconstant *GL-LINE-WIDTH* #x0B21) (defconstant *GL-LINE-WIDTH-RANGE* #x0B22) (defconstant *GL-LINE-WIDTH-GRANULARITY* #x0B23) (defconstant *GL-LINE-STIPPLE* #x0B24) (defconstant *GL-LINE-STIPPLE-PATTERN* #x0B25) (defconstant *GL-LINE-STIPPLE-REPEAT* #x0B26) ;; GL-SMOOTH-POINT-SIZE-RANGE ;; GL-SMOOTH-POINT-SIZE-GRANULARITY ;; GL-SMOOTH-LINE-WIDTH-RANGE ;; GL-SMOOTH-LINE-WIDTH-GRANULARITY ;; GL-ALIASED-POINT-SIZE-RANGE ;; GL-ALIASED-LINE-WIDTH-RANGE (defconstant *GL-LIST-MODE* #x0B30) (defconstant *GL-MAX-LIST-NESTING* #x0B31) (defconstant *GL-LIST-BASE* #x0B32) (defconstant *GL-LIST-INDEX* #x0B33) (defconstant *GL-POLYGON-MODE* #x0B40) (defconstant *GL-POLYGON-SMOOTH* #x0B41) (defconstant *GL-POLYGON-STIPPLE* #x0B42) (defconstant *GL-EDGE-FLAG* #x0B43) (defconstant *GL-CULL-FACE* #x0B44) (defconstant *GL-CULL-FACE-MODE* #x0B45) (defconstant *GL-FRONT-FACE* #x0B46) (defconstant *GL-LIGHTING* #x0B50) (defconstant *GL-LIGHT-MODEL-LOCAL-VIEWER* #x0B51) (defconstant *GL-LIGHT-MODEL-TWO-SIDE* #x0B52) (defconstant *GL-LIGHT-MODEL-AMBIENT* #x0B53) (defconstant *GL-SHADE-MODEL* #x0B54) (defconstant *GL-COLOR-MATERIAL-FACE* #x0B55) (defconstant *GL-COLOR-MATERIAL-PARAMETER* #x0B56) (defconstant *GL-COLOR-MATERIAL* #x0B57) (defconstant *GL-FOG* #x0B60) (defconstant *GL-FOG-INDEX* #x0B61) (defconstant *GL-FOG-DENSITY* #x0B62) (defconstant *GL-FOG-START* #x0B63) (defconstant *GL-FOG-END* #x0B64) (defconstant *GL-FOG-MODE* #x0B65) (defconstant *GL-FOG-COLOR* #x0B66) (defconstant *GL-DEPTH-RANGE* #x0B70) (defconstant *GL-DEPTH-TEST* #x0B71) (defconstant *GL-DEPTH-WRITEMASK* #x0B72) (defconstant *GL-DEPTH-CLEAR-VALUE* #x0B73) (defconstant *GL-DEPTH-FUNC* #x0B74) (defconstant *GL-ACCUM-CLEAR-VALUE* #x0B80) (defconstant *GL-STENCIL-TEST* #x0B90) (defconstant *GL-STENCIL-CLEAR-VALUE* #x0B91) (defconstant *GL-STENCIL-FUNC* #x0B92) (defconstant *GL-STENCIL-VALUE-MASK* #x0B93) (defconstant *GL-STENCIL-FAIL* #x0B94) (defconstant *GL-STENCIL-PASS-DEPTH-FAIL* #x0B95) (defconstant *GL-STENCIL-PASS-DEPTH-PASS* #x0B96) (defconstant *GL-STENCIL-REF* #x0B97) (defconstant *GL-STENCIL-WRITEMASK* #x0B98) (defconstant *GL-MATRIX-MODE* #x0BA0) (defconstant *GL-NORMALIZE* #x0BA1) (defconstant *GL-VIEWPORT* #x0BA2) (defconstant *GL-MODELVIEW-STACK-DEPTH* #x0BA3) (defconstant *GL-PROJECTION-STACK-DEPTH* #x0BA4) (defconstant *GL-TEXTURE-STACK-DEPTH* #x0BA5) (defconstant *GL-MODELVIEW-MATRIX* #x0BA6) (defconstant *GL-PROJECTION-MATRIX* #x0BA7) (defconstant *GL-TEXTURE-MATRIX* #x0BA8) (defconstant *GL-ATTRIB-STACK-DEPTH* #x0BB0) (defconstant *GL-CLIENT-ATTRIB-STACK-DEPTH* #x0BB1) (defconstant *GL-ALPHA-TEST* #x0BC0) (defconstant *GL-ALPHA-TEST-FUNC* #x0BC1) (defconstant *GL-ALPHA-TEST-REF* #x0BC2) (defconstant *GL-DITHER* #x0BD0) (defconstant *GL-BLEND-DST* #x0BE0) (defconstant *GL-BLEND-SRC* #x0BE1) (defconstant *GL-BLEND* #x0BE2) (defconstant *GL-LOGIC-OP-MODE* #x0BF0) (defconstant *GL-INDEX-LOGIC-OP* #x0BF1) (defconstant *GL-COLOR-LOGIC-OP* #x0BF2) (defconstant *GL-AUX-BUFFERS* #x0C00) (defconstant *GL-DRAW-BUFFER* #x0C01) (defconstant *GL-READ-BUFFER* #x0C02) (defconstant *GL-SCISSOR-BOX* #x0C10) (defconstant *GL-SCISSOR-TEST* #x0C11) (defconstant *GL-INDEX-CLEAR-VALUE* #x0C20) (defconstant *GL-INDEX-WRITEMASK* #x0C21) (defconstant *GL-COLOR-CLEAR-VALUE* #x0C22) (defconstant *GL-COLOR-WRITEMASK* #x0C23) (defconstant *GL-INDEX-MODE* #x0C30) (defconstant *GL-RGBA-MODE* #x0C31) (defconstant *GL-DOUBLEBUFFER* #x0C32) (defconstant *GL-STEREO* #x0C33) (defconstant *GL-RENDER-MODE* #x0C40) (defconstant *GL-PERSPECTIVE-CORRECTION-HINT* #x0C50) (defconstant *GL-POINT-SMOOTH-HINT* #x0C51) (defconstant *GL-LINE-SMOOTH-HINT* #x0C52) (defconstant *GL-POLYGON-SMOOTH-HINT* #x0C53) (defconstant *GL-FOG-HINT* #x0C54) (defconstant *GL-TEXTURE-GEN-S* #x0C60) (defconstant *GL-TEXTURE-GEN-T* #x0C61) (defconstant *GL-TEXTURE-GEN-R* #x0C62) (defconstant *GL-TEXTURE-GEN-Q* #x0C63) (defconstant *GL-PIXEL-MAP-I-TO-I* #x0C70) (defconstant *GL-PIXEL-MAP-S-TO-S* #x0C71) (defconstant *GL-PIXEL-MAP-I-TO-R* #x0C72) (defconstant *GL-PIXEL-MAP-I-TO-G* #x0C73) (defconstant *GL-PIXEL-MAP-I-TO-B* #x0C74) (defconstant *GL-PIXEL-MAP-I-TO-A* #x0C75) (defconstant *GL-PIXEL-MAP-R-TO-R* #x0C76) (defconstant *GL-PIXEL-MAP-G-TO-G* #x0C77) (defconstant *GL-PIXEL-MAP-B-TO-B* #x0C78) (defconstant *GL-PIXEL-MAP-A-TO-A* #x0C79) (defconstant *GL-PIXEL-MAP-I-TO-I-SIZE* #x0CB0) (defconstant *GL-PIXEL-MAP-S-TO-S-SIZE* #x0CB1) (defconstant *GL-PIXEL-MAP-I-TO-R-SIZE* #x0CB2) (defconstant *GL-PIXEL-MAP-I-TO-G-SIZE* #x0CB3) (defconstant *GL-PIXEL-MAP-I-TO-B-SIZE* #x0CB4) (defconstant *GL-PIXEL-MAP-I-TO-A-SIZE* #x0CB5) (defconstant *GL-PIXEL-MAP-R-TO-R-SIZE* #x0CB6) (defconstant *GL-PIXEL-MAP-G-TO-G-SIZE* #x0CB7) (defconstant *GL-PIXEL-MAP-B-TO-B-SIZE* #x0CB8) (defconstant *GL-PIXEL-MAP-A-TO-A-SIZE* #x0CB9) (defconstant *GL-UNPACK-SWAP-BYTES* #x0CF0) (defconstant *GL-UNPACK-LSB-FIRST* #x0CF1) (defconstant *GL-UNPACK-ROW-LENGTH* #x0CF2) (defconstant *GL-UNPACK-SKIP-ROWS* #x0CF3) (defconstant *GL-UNPACK-SKIP-PIXELS* #x0CF4) (defconstant *GL-UNPACK-ALIGNMENT* #x0CF5) (defconstant *GL-PACK-SWAP-BYTES* #x0D00) (defconstant *GL-PACK-LSB-FIRST* #x0D01) (defconstant *GL-PACK-ROW-LENGTH* #x0D02) (defconstant *GL-PACK-SKIP-ROWS* #x0D03) (defconstant *GL-PACK-SKIP-PIXELS* #x0D04) (defconstant *GL-PACK-ALIGNMENT* #x0D05) (defconstant *GL-MAP-COLOR* #x0D10) (defconstant *GL-MAP-STENCIL* #x0D11) (defconstant *GL-INDEX-SHIFT* #x0D12) (defconstant *GL-INDEX-OFFSET* #x0D13) (defconstant *GL-RED-SCALE* #x0D14) (defconstant *GL-RED-BIAS* #x0D15) (defconstant *GL-ZOOM-X* #x0D16) (defconstant *GL-ZOOM-Y* #x0D17) (defconstant *GL-GREEN-SCALE* #x0D18) (defconstant *GL-GREEN-BIAS* #x0D19) (defconstant *GL-BLUE-SCALE* #x0D1A) (defconstant *GL-BLUE-BIAS* #x0D1B) (defconstant *GL-ALPHA-SCALE* #x0D1C) (defconstant *GL-ALPHA-BIAS* #x0D1D) (defconstant *GL-DEPTH-SCALE* #x0D1E) (defconstant *GL-DEPTH-BIAS* #x0D1F) (defconstant *GL-MAX-EVAL-ORDER* #x0D30) (defconstant *GL-MAX-LIGHTS* #x0D31) (defconstant *GL-MAX-CLIP-PLANES* #x0D32) (defconstant *GL-MAX-TEXTURE-SIZE* #x0D33) (defconstant *GL-MAX-PIXEL-MAP-TABLE* #x0D34) (defconstant *GL-MAX-ATTRIB-STACK-DEPTH* #x0D35) (defconstant *GL-MAX-MODELVIEW-STACK-DEPTH* #x0D36) (defconstant *GL-MAX-NAME-STACK-DEPTH* #x0D37) (defconstant *GL-MAX-PROJECTION-STACK-DEPTH* #x0D38) (defconstant *GL-MAX-TEXTURE-STACK-DEPTH* #x0D39) (defconstant *GL-MAX-VIEWPORT-DIMS* #x0D3A) (defconstant *GL-MAX-CLIENT-ATTRIB-STACK-DEPTH* #x0D3B) (defconstant *GL-SUBPIXEL-BITS* #x0D50) (defconstant *GL-INDEX-BITS* #x0D51) (defconstant *GL-RED-BITS* #x0D52) (defconstant *GL-GREEN-BITS* #x0D53) (defconstant *GL-BLUE-BITS* #x0D54) (defconstant *GL-ALPHA-BITS* #x0D55) (defconstant *GL-DEPTH-BITS* #x0D56) (defconstant *GL-STENCIL-BITS* #x0D57) (defconstant *GL-ACCUM-RED-BITS* #x0D58) (defconstant *GL-ACCUM-GREEN-BITS* #x0D59) (defconstant *GL-ACCUM-BLUE-BITS* #x0D5A) (defconstant *GL-ACCUM-ALPHA-BITS* #x0D5B) (defconstant *GL-NAME-STACK-DEPTH* #x0D70) (defconstant *GL-AUTO-NORMAL* #x0D80) (defconstant *GL-MAP1-COLOR-4* #x0D90) (defconstant *GL-MAP1-INDEX* #x0D91) (defconstant *GL-MAP1-NORMAL* #x0D92) (defconstant *GL-MAP1-TEXTURE-COORD-1* #x0D93) (defconstant *GL-MAP1-TEXTURE-COORD-2* #x0D94) (defconstant *GL-MAP1-TEXTURE-COORD-3* #x0D95) (defconstant *GL-MAP1-TEXTURE-COORD-4* #x0D96) (defconstant *GL-MAP1-VERTEX-3* #x0D97) (defconstant *GL-MAP1-VERTEX-4* #x0D98) (defconstant *GL-MAP2-COLOR-4* #x0DB0) (defconstant *GL-MAP2-INDEX* #x0DB1) (defconstant *GL-MAP2-NORMAL* #x0DB2) (defconstant *GL-MAP2-TEXTURE-COORD-1* #x0DB3) (defconstant *GL-MAP2-TEXTURE-COORD-2* #x0DB4) (defconstant *GL-MAP2-TEXTURE-COORD-3* #x0DB5) (defconstant *GL-MAP2-TEXTURE-COORD-4* #x0DB6) (defconstant *GL-MAP2-VERTEX-3* #x0DB7) (defconstant *GL-MAP2-VERTEX-4* #x0DB8) (defconstant *GL-MAP1-GRID-DOMAIN* #x0DD0) (defconstant *GL-MAP1-GRID-SEGMENTS* #x0DD1) (defconstant *GL-MAP2-GRID-DOMAIN* #x0DD2) (defconstant *GL-MAP2-GRID-SEGMENTS* #x0DD3) (defconstant *GL-TEXTURE-1D* #x0DE0) (defconstant *GL-TEXTURE-2D* #x0DE1) (defconstant *GL-FEEDBACK-BUFFER-POINTER* #x0DF0) (defconstant *GL-FEEDBACK-BUFFER-SIZE* #x0DF1) (defconstant *GL-FEEDBACK-BUFFER-TYPE* #x0DF2) (defconstant *GL-SELECTION-BUFFER-POINTER* #x0DF3) (defconstant *GL-SELECTION-BUFFER-SIZE* #x0DF4) ;; GL-TEXTURE-BINDING-1D ;; GL-TEXTURE-BINDING-2D ;; GL-TEXTURE-BINDING-3D ;; GL-VERTEX-ARRAY ;; GL-NORMAL-ARRAY ;; GL-COLOR-ARRAY ;; GL-INDEX-ARRAY ;; GL-TEXTURE-COORD-ARRAY ;; GL-EDGE-FLAG-ARRAY ;; GL-VERTEX-ARRAY-SIZE ;; GL-VERTEX-ARRAY-TYPE ;; GL-VERTEX-ARRAY-STRIDE ;; GL-NORMAL-ARRAY-TYPE ;; GL-NORMAL-ARRAY-STRIDE ;; GL-COLOR-ARRAY-SIZE ;; GL-COLOR-ARRAY-TYPE ;; GL-COLOR-ARRAY-STRIDE ;; GL-INDEX-ARRAY-TYPE ;; GL-INDEX-ARRAY-STRIDE ;; GL-TEXTURE-COORD-ARRAY-SIZE ;; GL-TEXTURE-COORD-ARRAY-TYPE ;; GL-TEXTURE-COORD-ARRAY-STRIDE ;; GL-EDGE-FLAG-ARRAY-STRIDE ;; GL-POLYGON-OFFSET-FACTOR ;; GL-POLYGON-OFFSET-UNITS ;; GL-COLOR-TABLE ;; GL-POST-CONVOLUTION-COLOR-TABLE ;; GL-POST-COLOR-MATRIX-COLOR-TABLE ;; GL-CONVOLUTION-1D ;; GL-CONVOLUTION-2D ;; GL-SEPARABLE-2D ;; GL-POST-CONVOLUTION-RED-SCALE ;; GL-POST-CONVOLUTION-GREEN-SCALE ;; GL-POST-CONVOLUTION-BLUE-SCALE ;; GL-POST-CONVOLUTION-ALPHA-SCALE ;; GL-POST-CONVOLUTION-RED-BIAS ;; GL-POST-CONVOLUTION-GREEN-BIAS ;; GL-POST-CONVOLUTION-BLUE-BIAS ;; GL-POST-CONVOLUTION-ALPHA-BIAS ;; GL-COLOR-MATRIX ;; GL-COLOR-MATRIX-STACK-DEPTH ;; GL-MAX-COLOR-MATRIX-STACK-DEPTH ;; GL-POST-COLOR-MATRIX-RED-SCALE ;; GL-POST-COLOR-MATRIX-GREEN-SCALE ;; GL-POST-COLOR-MATRIX-BLUE-SCALE ;; GL-POST-COLOR-MATRIX-ALPHA-SCALE ;; GL-POST-COLOR-MATRIX-RED-BIAS ;; GL-POST-COLOR-MATRIX-GREEN-BIAS ;; GL-POST-COLOR-MATRIX-BLUE-BIAS ;; GL-POST-COLOR-MATRIX-ALPHA-BIAS ;; GL-HISTOGRAM ;; GL-MINMAX ;; GL-MAX-ELEMENTS-VERTICES ;; GL-MAX-ELEMENTS-INDICES ;; GL-RESCALE-NORMAL ;; GL-LIGHT-MODEL-COLOR-CONTROL ;; GL-PACK-SKIP-IMAGES ;; GL-PACK-IMAGE-HEIGHT ;; GL-UNPACK-SKIP-IMAGES ;; GL-UNPACK-IMAGE-HEIGHT ;; GL-TEXTURE-3D ;; GL-MAX-3D-TEXTURE-SIZE ;; GL-BLEND-COLOR ;; GL-BLEND-EQUATION ;; GetTextureParameter ;; GL-TEXTURE-MAG-FILTER ;; GL-TEXTURE-MIN-FILTER ;; GL-TEXTURE-WRAP-S ;; GL-TEXTURE-WRAP-T (defconstant *GL-TEXTURE-WIDTH* #x1000) (defconstant *GL-TEXTURE-HEIGHT* #x1001) (defconstant *GL-TEXTURE-INTERNAL-FORMAT* #x1003) (defconstant *GL-TEXTURE-BORDER-COLOR* #x1004) (defconstant *GL-TEXTURE-BORDER* #x1005) ;; GL-TEXTURE-RED-SIZE ;; GL-TEXTURE-GREEN-SIZE ;; GL-TEXTURE-BLUE-SIZE ;; GL-TEXTURE-ALPHA-SIZE ;; GL-TEXTURE-LUMINANCE-SIZE ;; GL-TEXTURE-INTENSITY-SIZE ;; GL-TEXTURE-PRIORITY ;; GL-TEXTURE-RESIDENT ;; GL-TEXTURE-DEPTH ;; GL-TEXTURE-WRAP-R ;; GL-TEXTURE-MIN-LOD ;; GL-TEXTURE-MAX-LOD ;; GL-TEXTURE-BASE-LEVEL ;; GL-TEXTURE-MAX-LEVEL ;; HintMode (defconstant *GL-DONT-CARE* #x1100) (defconstant *GL-FASTEST* #x1101) (defconstant *GL-NICEST* #x1102) ;; HintTarget ;; GL-PERSPECTIVE-CORRECTION-HINT ;; GL-POINT-SMOOTH-HINT ;; GL-LINE-SMOOTH-HINT ;; GL-POLYGON-SMOOTH-HINT ;; GL-FOG-HINT ;; HistogramTarget ;; GL-HISTOGRAM ;; GL-PROXY-HISTOGRAM ;; IndexPointerType ;; GL-SHORT ;; GL-INT ;; GL-FLOAT ;; GL-DOUBLE ;; LightModelColorControl ;; GL-SINGLE-COLOR ;; GL-SEPARATE-SPECULAR-COLOR ;; LightModelParameter ;; GL-LIGHT-MODEL-AMBIENT ;; GL-LIGHT-MODEL-LOCAL-VIEWER ;; GL-LIGHT-MODEL-TWO-SIDE ;; GL-LIGHT-MODEL-COLOR-CONTROL ;; LightName (defconstant *GL-LIGHT0* #x4000) (defconstant *GL-LIGHT1* #x4001) (defconstant *GL-LIGHT2* #x4002) (defconstant *GL-LIGHT3* #x4003) (defconstant *GL-LIGHT4* #x4004) (defconstant *GL-LIGHT5* #x4005) (defconstant *GL-LIGHT6* #x4006) (defconstant *GL-LIGHT7* #x4007) ;; LightParameter (defconstant *GL-AMBIENT* #x1200) (defconstant *GL-DIFFUSE* #x1201) (defconstant *GL-SPECULAR* #x1202) (defconstant *GL-POSITION* #x1203) (defconstant *GL-SPOT-DIRECTION* #x1204) (defconstant *GL-SPOT-EXPONENT* #x1205) (defconstant *GL-SPOT-CUTOFF* #x1206) (defconstant *GL-CONSTANT-ATTENUATION* #x1207) (defconstant *GL-LINEAR-ATTENUATION* #x1208) (defconstant *GL-QUADRATIC-ATTENUATION* #x1209) ;; InterleavedArrays ;; GL-V2F ;; GL-V3F ;; GL-C4UB-V2F ;; GL-C4UB-V3F ;; GL-C3F-V3F ;; GL-N3F-V3F ;; GL-C4F-N3F-V3F ;; GL-T2F-V3F ;; GL-T4F-V4F ;; GL-T2F-C4UB-V3F ;; GL-T2F-C3F-V3F ;; GL-T2F-N3F-V3F ;; GL-T2F-C4F-N3F-V3F ;; GL-T4F-C4F-N3F-V4F ;; ListMode (defconstant *GL-COMPILE* #x1300) (defconstant *GL-COMPILE-AND-EXECUTE* #x1301) ;; ListNameType ;; GL-BYTE ;; GL-UNSIGNED-BYTE ;; GL-SHORT ;; GL-UNSIGNED-SHORT ;; GL-INT ;; GL-UNSIGNED-INT ;; GL-FLOAT ;; GL-2-BYTES ;; GL-3-BYTES ;; GL-4-BYTES ;; LogicOp (defconstant *GL-CLEAR* #x1500) (defconstant *GL-AND* #x1501) (defconstant *GL-AND-REVERSE* #x1502) (defconstant *GL-COPY* #x1503) (defconstant *GL-AND-INVERTED* #x1504) (defconstant *GL-NOOP* #x1505) (defconstant *GL-XOR* #x1506) (defconstant *GL-OR* #x1507) (defconstant *GL-NOR* #x1508) (defconstant *GL-EQUIV* #x1509) (defconstant *GL-INVERT* #x150A) (defconstant *GL-OR-REVERSE* #x150B) (defconstant *GL-COPY-INVERTED* #x150C) (defconstant *GL-OR-INVERTED* #x150D) (defconstant *GL-NAND* #x150E) (defconstant *GL-SET* #x150F) ;; MapTarget ;; GL-MAP1-COLOR-4 ;; GL-MAP1-INDEX ;; GL-MAP1-NORMAL ;; GL-MAP1-TEXTURE-COORD-1 ;; GL-MAP1-TEXTURE-COORD-2 ;; GL-MAP1-TEXTURE-COORD-3 ;; GL-MAP1-TEXTURE-COORD-4 ;; GL-MAP1-VERTEX-3 ;; GL-MAP1-VERTEX-4 ;; GL-MAP2-COLOR-4 ;; GL-MAP2-INDEX ;; GL-MAP2-NORMAL ;; GL-MAP2-TEXTURE-COORD-1 ;; GL-MAP2-TEXTURE-COORD-2 ;; GL-MAP2-TEXTURE-COORD-3 ;; GL-MAP2-TEXTURE-COORD-4 ;; GL-MAP2-VERTEX-3 ;; GL-MAP2-VERTEX-4 ;; MaterialFace ;; GL-FRONT ;; GL-BACK ;; GL-FRONT-AND-BACK ;; MaterialParameter (defconstant *GL-EMISSION* #x1600) (defconstant *GL-SHININESS* #x1601) (defconstant *GL-AMBIENT-AND-DIFFUSE* #x1602) (defconstant *GL-COLOR-INDEXES* #x1603) ;; GL-AMBIENT ;; GL-DIFFUSE ;; GL-SPECULAR ;; MatrixMode (defconstant *GL-MODELVIEW* #x1700) (defconstant *GL-PROJECTION* #x1701) (defconstant *GL-TEXTURE* #x1702) ;; MeshMode1 ;; GL-POINT ;; GL-LINE ;; MeshMode2 ;; GL-POINT ;; GL-LINE ;; GL-FILL ;; MinmaxTarget ;; GL-MINMAX ;; NormalPointerType ;; GL-BYTE ;; GL-SHORT ;; GL-INT ;; GL-FLOAT ;; GL-DOUBLE ;; PixelCopyType (defconstant *GL-COLOR* #x1800) (defconstant *GL-DEPTH* #x1801) (defconstant *GL-STENCIL* #x1802) ;; PixelFormat (defconstant *GL-COLOR-INDEX* #x1900) (defconstant *GL-STENCIL-INDEX* #x1901) (defconstant *GL-DEPTH-COMPONENT* #x1902) (defconstant *GL-RED* #x1903) (defconstant *GL-GREEN* #x1904) (defconstant *GL-BLUE* #x1905) (defconstant *GL-ALPHA* #x1906) (defconstant *GL-RGB* #x1907) (defconstant *GL-RGBA* #x1908) (defconstant *GL-LUMINANCE* #x1909) (defconstant *GL-LUMINANCE-ALPHA* #x190A) ;; GL-ABGR ;; PixelInternalFormat ;; GL-ALPHA4 ;; GL-ALPHA8 ;; GL-ALPHA12 ;; GL-ALPHA16 ;; GL-LUMINANCE4 ;; GL-LUMINANCE8 ;; GL-LUMINANCE12 ;; GL-LUMINANCE16 ;; GL-LUMINANCE4-ALPHA4 ;; GL-LUMINANCE6-ALPHA2 ;; GL-LUMINANCE8-ALPHA8 ;; GL-LUMINANCE12-ALPHA4 ;; GL-LUMINANCE12-ALPHA12 ;; GL-LUMINANCE16-ALPHA16 ;; GL-INTENSITY ;; GL-INTENSITY4 ;; GL-INTENSITY8 ;; GL-INTENSITY12 ;; GL-INTENSITY16 ;; GL-R3-G3-B2 ;; GL-RGB4 ;; GL-RGB5 ;; GL-RGB8 ;; GL-RGB10 ;; GL-RGB12 ;; GL-RGB16 ;; GL-RGBA2 ;; GL-RGBA4 ;; GL-RGB5-A1 ;; GL-RGBA8 ;; GL-RGB10-A2 ;; GL-RGBA12 ;; GL-RGBA16 ;; PixelMap ;; GL-PIXEL-MAP-I-TO-I ;; GL-PIXEL-MAP-S-TO-S ;; GL-PIXEL-MAP-I-TO-R ;; GL-PIXEL-MAP-I-TO-G ;; GL-PIXEL-MAP-I-TO-B ;; GL-PIXEL-MAP-I-TO-A ;; GL-PIXEL-MAP-R-TO-R ;; GL-PIXEL-MAP-G-TO-G ;; GL-PIXEL-MAP-B-TO-B ;; GL-PIXEL-MAP-A-TO-A ;; PixelStore ;; GL-UNPACK-SWAP-BYTES ;; GL-UNPACK-LSB-FIRST ;; GL-UNPACK-ROW-LENGTH ;; GL-UNPACK-SKIP-ROWS ;; GL-UNPACK-SKIP-PIXELS ;; GL-UNPACK-ALIGNMENT ;; GL-PACK-SWAP-BYTES ;; GL-PACK-LSB-FIRST ;; GL-PACK-ROW-LENGTH ;; GL-PACK-SKIP-ROWS ;; GL-PACK-SKIP-PIXELS ;; GL-PACK-ALIGNMENT ;; GL-PACK-SKIP-IMAGES ;; GL-PACK-IMAGE-HEIGHT ;; GL-UNPACK-SKIP-IMAGES ;; GL-UNPACK-IMAGE-HEIGHT ;; PixelTransfer ;; GL-MAP-COLOR ;; GL-MAP-STENCIL ;; GL-INDEX-SHIFT ;; GL-INDEX-OFFSET ;; GL-RED-SCALE ;; GL-RED-BIAS ;; GL-GREEN-SCALE ;; GL-GREEN-BIAS ;; GL-BLUE-SCALE ;; GL-BLUE-BIAS ;; GL-ALPHA-SCALE ;; GL-ALPHA-BIAS ;; GL-DEPTH-SCALE ;; GL-DEPTH-BIAS ;; GL-POST-CONVOLUTION-RED-SCALE ;; GL-POST-CONVOLUTION-GREEN-SCALE ;; GL-POST-CONVOLUTION-BLUE-SCALE ;; GL-POST-CONVOLUTION-ALPHA-SCALE ;; GL-POST-CONVOLUTION-RED-BIAS ;; GL-POST-CONVOLUTION-GREEN-BIAS ;; GL-POST-CONVOLUTION-BLUE-BIAS ;; GL-POST-CONVOLUTION-ALPHA-BIAS ;; GL-POST-COLOR-MATRIX-RED-SCALE ;; GL-POST-COLOR-MATRIX-GREEN-SCALE ;; GL-POST-COLOR-MATRIX-BLUE-SCALE ;; GL-POST-COLOR-MATRIX-ALPHA-SCALE ;; GL-POST-COLOR-MATRIX-RED-BIAS ;; GL-POST-COLOR-MATRIX-GREEN-BIAS ;; GL-POST-COLOR-MATRIX-BLUE-BIAS ;; GL-POST-COLOR-MATRIX-ALPHA-BIAS ;; PixelType (defconstant *GL-BITMAP* #x1A00) ;; GL-BYTE ;; GL-UNSIGNED-BYTE ;; GL-SHORT ;; GL-UNSIGNED-SHORT ;; GL-INT ;; GL-UNSIGNED-INT ;; GL-FLOAT ;; GL-BGR ;; GL-BGRA ;; GL-UNSIGNED-BYTE-3-3-2 ;; GL-UNSIGNED-SHORT-4-4-4-4 ;; GL-UNSIGNED-SHORT-5-5-5-1 ;; GL-UNSIGNED-INT-8-8-8-8 ;; GL-UNSIGNED-INT-10-10-10-2 ;; GL-UNSIGNED-SHORT-5-6-5 ;; GL-UNSIGNED-BYTE-2-3-3-REV ;; GL-UNSIGNED-SHORT-5-6-5-REV ;; GL-UNSIGNED-SHORT-4-4-4-4-REV ;; GL-UNSIGNED-SHORT-1-5-5-5-REV ;; GL-UNSIGNED-INT-8-8-8-8-REV ;; GL-UNSIGNED-INT-2-10-10-10-REV ;; PolygonMode (defconstant *GL-POINT* #x1B00) (defconstant *GL-LINE* #x1B01) (defconstant *GL-FILL* #x1B02) ;; ReadBufferMode ;; GL-FRONT-LEFT ;; GL-FRONT-RIGHT ;; GL-BACK-LEFT ;; GL-BACK-RIGHT ;; GL-FRONT ;; GL-BACK ;; GL-LEFT ;; GL-RIGHT ;; GL-AUX0 ;; GL-AUX1 ;; GL-AUX2 ;; GL-AUX3 ;; RenderingMode (defconstant *GL-RENDER* #x1C00) (defconstant *GL-FEEDBACK* #x1C01) (defconstant *GL-SELECT* #x1C02) ;; SeparableTarget ;; GL-SEPARABLE-2D ;; ShadingModel (defconstant *GL-FLAT* #x1D00) (defconstant *GL-SMOOTH* #x1D01) ;; StencilFunction (same as AlphaFunction) ;; GL-NEVER ;; GL-LESS ;; GL-EQUAL ;; GL-LEQUAL ;; GL-GREATER ;; GL-NOTEQUAL ;; GL-GEQUAL ;; GL-ALWAYS ;; StencilOp ;; GL-ZERO (defconstant *GL-KEEP* #x1E00) (defconstant *GL-REPLACE* #x1E01) (defconstant *GL-INCR* #x1E02) (defconstant *GL-DECR* #x1E03) ;; GL-INVERT ;; StringName (defconstant *GL-VENDOR* #x1F00) (defconstant *GL-RENDERER* #x1F01) (defconstant *GL-VERSION* #x1F02) (defconstant *GL-EXTENSIONS* #x1F03) ;; TextureCoordName (defconstant *GL-S* #x2000) (defconstant *GL-T* #x2001) (defconstant *GL-R* #x2002) (defconstant *GL-Q* #x2003) ;; TexCoordPointerType ;; GL-SHORT ;; GL-INT ;; GL-FLOAT ;; GL-DOUBLE ;; TextureEnvMode (defconstant *GL-MODULATE* #x2100) (defconstant *GL-DECAL* #x2101) ;; GL-BLEND ;; GL-REPLACE ;; TextureEnvParameter (defconstant *GL-TEXTURE-ENV-MODE* #x2200) (defconstant *GL-TEXTURE-ENV-COLOR* #x2201) ;; TextureEnvTarget (defconstant *GL-TEXTURE-ENV* #x2300) ;; TextureGenMode (defconstant *GL-EYE-LINEAR* #x2400) (defconstant *GL-OBJECT-LINEAR* #x2401) (defconstant *GL-SPHERE-MAP* #x2402) ;; TextureGenParameter (defconstant *GL-TEXTURE-GEN-MODE* #x2500) (defconstant *GL-OBJECT-PLANE* #x2501) (defconstant *GL-EYE-PLANE* #x2502) ;; TextureMagFilter (defconstant *GL-NEAREST* #x2600) (defconstant *GL-LINEAR* #x2601) ;; TextureMinFilter ;; GL-NEAREST ;; GL-LINEAR (defconstant *GL-NEAREST-MIPMAP-NEAREST* #x2700) (defconstant *GL-LINEAR-MIPMAP-NEAREST* #x2701) (defconstant *GL-NEAREST-MIPMAP-LINEAR* #x2702) (defconstant *GL-LINEAR-MIPMAP-LINEAR* #x2703) ;; TextureParameterName (defconstant *GL-TEXTURE-MAG-FILTER* #x2800) (defconstant *GL-TEXTURE-MIN-FILTER* #x2801) (defconstant *GL-TEXTURE-WRAP-S* #x2802) (defconstant *GL-TEXTURE-WRAP-T* #x2803) ;; GL-TEXTURE-BORDER-COLOR ;; GL-TEXTURE-PRIORITY ;; GL-TEXTURE-WRAP-R ;; GL-TEXTURE-MIN-LOD ;; GL-TEXTURE-MAX-LOD ;; GL-TEXTURE-BASE-LEVEL ;; GL-TEXTURE-MAX-LEVEL ;; TextureTarget ;; GL-TEXTURE-1D ;; GL-TEXTURE-2D ;; GL-PROXY-TEXTURE-1D ;; GL-PROXY-TEXTURE-2D ;; GL-TEXTURE-3D ;; GL-PROXY-TEXTURE-3D ;; TextureWrapMode (defconstant *GL-CLAMP* #x2900) (defconstant *GL-REPEAT* #x2901) ;; GL-CLAMP-TO-EDGE ;; VertexPointerType ;; GL-SHORT ;; GL-INT ;; GL-FLOAT ;; GL-DOUBLE ;; ClientAttribMask (defconstant *GL-CLIENT-PIXEL-STORE-BIT* #x00000001) (defconstant *GL-CLIENT-VERTEX-ARRAY-BIT* #x00000002) (defconstant *GL-CLIENT-ALL-ATTRIB-BITS* #xffffffff) ;; polygon-offset (defconstant *GL-POLYGON-OFFSET-FACTOR* #x8038) (defconstant *GL-POLYGON-OFFSET-UNITS* #x2A00) (defconstant *GL-POLYGON-OFFSET-POINT* #x2A01) (defconstant *GL-POLYGON-OFFSET-LINE* #x2A02) (defconstant *GL-POLYGON-OFFSET-FILL* #x8037) ;; texture (defconstant *GL-ALPHA4* #x803B) (defconstant *GL-ALPHA8* #x803C) (defconstant *GL-ALPHA12* #x803D) (defconstant *GL-ALPHA16* #x803E) (defconstant *GL-LUMINANCE4* #x803F) (defconstant *GL-LUMINANCE8* #x8040) (defconstant *GL-LUMINANCE12* #x8041) (defconstant *GL-LUMINANCE16* #x8042) (defconstant *GL-LUMINANCE4-ALPHA4* #x8043) (defconstant *GL-LUMINANCE6-ALPHA2* #x8044) (defconstant *GL-LUMINANCE8-ALPHA8* #x8045) (defconstant *GL-LUMINANCE12-ALPHA4* #x8046) (defconstant *GL-LUMINANCE12-ALPHA12* #x8047) (defconstant *GL-LUMINANCE16-ALPHA16* #x8048) (defconstant *GL-INTENSITY* #x8049) (defconstant *GL-INTENSITY4* #x804A) (defconstant *GL-INTENSITY8* #x804B) (defconstant *GL-INTENSITY12* #x804C) (defconstant *GL-INTENSITY16* #x804D) (defconstant *GL-R3-G3-B2* #x2A10) (defconstant *GL-RGB4* #x804F) (defconstant *GL-RGB5* #x8050) (defconstant *GL-RGB8* #x8051) (defconstant *GL-RGB10* #x8052) (defconstant *GL-RGB12* #x8053) (defconstant *GL-RGB16* #x8054) (defconstant *GL-RGBA2* #x8055) (defconstant *GL-RGBA4* #x8056) (defconstant *GL-RGB5-A1* #x8057) (defconstant *GL-RGBA8* #x8058) (defconstant *GL-RGB10-A2* #x8059) (defconstant *GL-RGBA12* #x805A) (defconstant *GL-RGBA16* #x805B) (defconstant *GL-TEXTURE-RED-SIZE* #x805C) (defconstant *GL-TEXTURE-GREEN-SIZE* #x805D) (defconstant *GL-TEXTURE-BLUE-SIZE* #x805E) (defconstant *GL-TEXTURE-ALPHA-SIZE* #x805F) (defconstant *GL-TEXTURE-LUMINANCE-SIZE* #x8060) (defconstant *GL-TEXTURE-INTENSITY-SIZE* #x8061) (defconstant *GL-PROXY-TEXTURE-1D* #x8063) (defconstant *GL-PROXY-TEXTURE-2D* #x8064) ;; texture-object (defconstant *GL-TEXTURE-PRIORITY* #x8066) (defconstant *GL-TEXTURE-RESIDENT* #x8067) (defconstant *GL-TEXTURE-BINDING-1D* #x8068) (defconstant *GL-TEXTURE-BINDING-2D* #x8069) (defconstant *GL-TEXTURE-BINDING-3D* #x806A) ;; vertex-array (defconstant *GL-VERTEX-ARRAY* #x8074) (defconstant *GL-NORMAL-ARRAY* #x8075) (defconstant *GL-COLOR-ARRAY* #x8076) (defconstant *GL-INDEX-ARRAY* #x8077) (defconstant *GL-TEXTURE-COORD-ARRAY* #x8078) (defconstant *GL-EDGE-FLAG-ARRAY* #x8079) (defconstant *GL-VERTEX-ARRAY-SIZE* #x807A) (defconstant *GL-VERTEX-ARRAY-TYPE* #x807B) (defconstant *GL-VERTEX-ARRAY-STRIDE* #x807C) (defconstant *GL-NORMAL-ARRAY-TYPE* #x807E) (defconstant *GL-NORMAL-ARRAY-STRIDE* #x807F) (defconstant *GL-COLOR-ARRAY-SIZE* #x8081) (defconstant *GL-COLOR-ARRAY-TYPE* #x8082) (defconstant *GL-COLOR-ARRAY-STRIDE* #x8083) (defconstant *GL-INDEX-ARRAY-TYPE* #x8085) (defconstant *GL-INDEX-ARRAY-STRIDE* #x8086) (defconstant *GL-TEXTURE-COORD-ARRAY-SIZE* #x8088) (defconstant *GL-TEXTURE-COORD-ARRAY-TYPE* #x8089) (defconstant *GL-TEXTURE-COORD-ARRAY-STRIDE* #x808A) (defconstant *GL-EDGE-FLAG-ARRAY-STRIDE* #x808C) (defconstant *GL-VERTEX-ARRAY-POINTER* #x808E) (defconstant *GL-NORMAL-ARRAY-POINTER* #x808F) (defconstant *GL-COLOR-ARRAY-POINTER* #x8090) (defconstant *GL-INDEX-ARRAY-POINTER* #x8091) (defconstant *GL-TEXTURE-COORD-ARRAY-POINTER* #x8092) (defconstant *GL-EDGE-FLAG-ARRAY-POINTER* #x8093) (defconstant *GL-V2F* #x2A20) (defconstant *GL-V3F* #x2A21) (defconstant *GL-C4UB-V2F* #x2A22) (defconstant *GL-C4UB-V3F* #x2A23) (defconstant *GL-C3F-V3F* #x2A24) (defconstant *GL-N3F-V3F* #x2A25) (defconstant *GL-C4F-N3F-V3F* #x2A26) (defconstant *GL-T2F-V3F* #x2A27) (defconstant *GL-T4F-V4F* #x2A28) (defconstant *GL-T2F-C4UB-V3F* #x2A29) (defconstant *GL-T2F-C3F-V3F* #x2A2A) (defconstant *GL-T2F-N3F-V3F* #x2A2B) (defconstant *GL-T2F-C4F-N3F-V3F* #x2A2C) (defconstant *GL-T4F-C4F-N3F-V4F* #x2A2D) ;; bgra (defconstant *GL-BGR* #x80E0) (defconstant *GL-BGRA* #x80E1) ;; blend-color (defconstant *GL-CONSTANT-COLOR* #x8001) (defconstant *GL-ONE-MINUS-CONSTANT-COLOR* #x8002) (defconstant *GL-CONSTANT-ALPHA* #x8003) (defconstant *GL-ONE-MINUS-CONSTANT-ALPHA* #x8004) (defconstant *GL-BLEND-COLOR* #x8005) ;; blend-minmax (defconstant *GL-FUNC-ADD* #x8006) (defconstant *GL-MIN* #x8007) (defconstant *GL-MAX* #x8008) (defconstant *GL-BLEND-EQUATION* #x8009) ;; blend-equation-separate (defconstant *GL-BLEND-EQUATION-RGB* #x8009) (defconstant *GL-BLEND-EQUATION-ALPHA* #x883D) ;; blend-subtract (defconstant *GL-FUNC-SUBTRACT* #x800A) (defconstant *GL-FUNC-REVERSE-SUBTRACT* #x800B) ;; color-matrix (defconstant *GL-COLOR-MATRIX* #x80B1) (defconstant *GL-COLOR-MATRIX-STACK-DEPTH* #x80B2) (defconstant *GL-MAX-COLOR-MATRIX-STACK-DEPTH* #x80B3) (defconstant *GL-POST-COLOR-MATRIX-RED-SCALE* #x80B4) (defconstant *GL-POST-COLOR-MATRIX-GREEN-SCALE* #x80B5) (defconstant *GL-POST-COLOR-MATRIX-BLUE-SCALE* #x80B6) (defconstant *GL-POST-COLOR-MATRIX-ALPHA-SCALE* #x80B7) (defconstant *GL-POST-COLOR-MATRIX-RED-BIAS* #x80B8) (defconstant *GL-POST-COLOR-MATRIX-GREEN-BIAS* #x80B9) (defconstant *GL-POST-COLOR-MATRIX-BLUE-BIAS* #x80BA) (defconstant *GL-POST-COLOR-MATRIX-ALPHA-BIAS* #x80BB) ;; color-table (defconstant *GL-COLOR-TABLE* #x80D0) (defconstant *GL-POST-CONVOLUTION-COLOR-TABLE* #x80D1) (defconstant *GL-POST-COLOR-MATRIX-COLOR-TABLE* #x80D2) (defconstant *GL-PROXY-COLOR-TABLE* #x80D3) (defconstant *GL-PROXY-POST-CONVOLUTION-COLOR-TABLE* #x80D4) (defconstant *GL-PROXY-POST-COLOR-MATRIX-COLOR-TABLE* #x80D5) (defconstant *GL-COLOR-TABLE-SCALE* #x80D6) (defconstant *GL-COLOR-TABLE-BIAS* #x80D7) (defconstant *GL-COLOR-TABLE-FORMAT* #x80D8) (defconstant *GL-COLOR-TABLE-WIDTH* #x80D9) (defconstant *GL-COLOR-TABLE-RED-SIZE* #x80DA) (defconstant *GL-COLOR-TABLE-GREEN-SIZE* #x80DB) (defconstant *GL-COLOR-TABLE-BLUE-SIZE* #x80DC) (defconstant *GL-COLOR-TABLE-ALPHA-SIZE* #x80DD) (defconstant *GL-COLOR-TABLE-LUMINANCE-SIZE* #x80DE) (defconstant *GL-COLOR-TABLE-INTENSITY-SIZE* #x80DF) ;; convolution (defconstant *GL-CONVOLUTION-1D* #x8010) (defconstant *GL-CONVOLUTION-2D* #x8011) (defconstant *GL-SEPARABLE-2D* #x8012) (defconstant *GL-CONVOLUTION-BORDER-MODE* #x8013) (defconstant *GL-CONVOLUTION-FILTER-SCALE* #x8014) (defconstant *GL-CONVOLUTION-FILTER-BIAS* #x8015) (defconstant *GL-REDUCE* #x8016) (defconstant *GL-CONVOLUTION-FORMAT* #x8017) (defconstant *GL-CONVOLUTION-WIDTH* #x8018) (defconstant *GL-CONVOLUTION-HEIGHT* #x8019) (defconstant *GL-MAX-CONVOLUTION-WIDTH* #x801A) (defconstant *GL-MAX-CONVOLUTION-HEIGHT* #x801B) (defconstant *GL-POST-CONVOLUTION-RED-SCALE* #x801C) (defconstant *GL-POST-CONVOLUTION-GREEN-SCALE* #x801D) (defconstant *GL-POST-CONVOLUTION-BLUE-SCALE* #x801E) (defconstant *GL-POST-CONVOLUTION-ALPHA-SCALE* #x801F) (defconstant *GL-POST-CONVOLUTION-RED-BIAS* #x8020) (defconstant *GL-POST-CONVOLUTION-GREEN-BIAS* #x8021) (defconstant *GL-POST-CONVOLUTION-BLUE-BIAS* #x8022) (defconstant *GL-POST-CONVOLUTION-ALPHA-BIAS* #x8023) (defconstant *GL-CONSTANT-BORDER* #x8151) (defconstant *GL-REPLICATE-BORDER* #x8153) (defconstant *GL-CONVOLUTION-BORDER-COLOR* #x8154) ;; draw-range-elements (defconstant *GL-MAX-ELEMENTS-VERTICES* #x80E8) (defconstant *GL-MAX-ELEMENTS-INDICES* #x80E9) ;; histogram (defconstant *GL-HISTOGRAM* #x8024) (defconstant *GL-PROXY-HISTOGRAM* #x8025) (defconstant *GL-HISTOGRAM-WIDTH* #x8026) (defconstant *GL-HISTOGRAM-FORMAT* #x8027) (defconstant *GL-HISTOGRAM-RED-SIZE* #x8028) (defconstant *GL-HISTOGRAM-GREEN-SIZE* #x8029) (defconstant *GL-HISTOGRAM-BLUE-SIZE* #x802A) (defconstant *GL-HISTOGRAM-ALPHA-SIZE* #x802B) (defconstant *GL-HISTOGRAM-LUMINANCE-SIZE* #x802C) (defconstant *GL-HISTOGRAM-SINK* #x802D) (defconstant *GL-MINMAX* #x802E) (defconstant *GL-MINMAX-FORMAT* #x802F) (defconstant *GL-MINMAX-SINK* #x8030) (defconstant *GL-TABLE-TOO-LARGE* #x8031) ;; packed-pixels (defconstant *GL-UNSIGNED-BYTE-3-3-2* #x8032) (defconstant *GL-UNSIGNED-SHORT-4-4-4-4* #x8033) (defconstant *GL-UNSIGNED-SHORT-5-5-5-1* #x8034) (defconstant *GL-UNSIGNED-INT-8-8-8-8* #x8035) (defconstant *GL-UNSIGNED-INT-10-10-10-2* #x8036) (defconstant *GL-UNSIGNED-BYTE-2-3-3-REV* #x8362) (defconstant *GL-UNSIGNED-SHORT-5-6-5* #x8363) (defconstant *GL-UNSIGNED-SHORT-5-6-5-REV* #x8364) (defconstant *GL-UNSIGNED-SHORT-4-4-4-4-REV* #x8365) (defconstant *GL-UNSIGNED-SHORT-1-5-5-5-REV* #x8366) (defconstant *GL-UNSIGNED-INT-8-8-8-8-REV* #x8367) (defconstant *GL-UNSIGNED-INT-2-10-10-10-REV* #x8368) ;; rescale-normal (defconstant *GL-RESCALE-NORMAL* #x803A) ;; separate-specular-color (defconstant *GL-LIGHT-MODEL-COLOR-CONTROL* #x81F8) (defconstant *GL-SINGLE-COLOR* #x81F9) (defconstant *GL-SEPARATE-SPECULAR-COLOR* #x81FA) ;; texture3D (defconstant *GL-PACK-SKIP-IMAGES* #x806B) (defconstant *GL-PACK-IMAGE-HEIGHT* #x806C) (defconstant *GL-UNPACK-SKIP-IMAGES* #x806D) (defconstant *GL-UNPACK-IMAGE-HEIGHT* #x806E) (defconstant *GL-TEXTURE-3D* #x806F) (defconstant *GL-PROXY-TEXTURE-3D* #x8070) (defconstant *GL-TEXTURE-DEPTH* #x8071) (defconstant *GL-TEXTURE-WRAP-R* #x8072) (defconstant *GL-MAX-3D-TEXTURE-SIZE* #x8073) ;; texture-edge-clamp (defconstant *GL-CLAMP-TO-EDGE* #x812F) (defconstant *GL-CLAMP-TO-BORDER* #x812D) ;; texture-lod (defconstant *GL-TEXTURE-MIN-LOD* #x813A) (defconstant *GL-TEXTURE-MAX-LOD* #x813B) (defconstant *GL-TEXTURE-BASE-LEVEL* #x813C) (defconstant *GL-TEXTURE-MAX-LEVEL* #x813D) ;; GetTarget1-2 (defconstant *GL-SMOOTH-POINT-SIZE-RANGE* #x0B12) (defconstant *GL-SMOOTH-POINT-SIZE-GRANULARITY* #x0B13) (defconstant *GL-SMOOTH-LINE-WIDTH-RANGE* #x0B22) (defconstant *GL-SMOOTH-LINE-WIDTH-GRANULARITY* #x0B23) (defconstant *GL-ALIASED-POINT-SIZE-RANGE* #x846D) (defconstant *GL-ALIASED-LINE-WIDTH-RANGE* #x846E) (defconstant *GL-TEXTURE0* #x84C0) (defconstant *GL-TEXTURE1* #x84C1) (defconstant *GL-TEXTURE2* #x84C2) (defconstant *GL-TEXTURE3* #x84C3) (defconstant *GL-TEXTURE4* #x84C4) (defconstant *GL-TEXTURE5* #x84C5) (defconstant *GL-TEXTURE6* #x84C6) (defconstant *GL-TEXTURE7* #x84C7) (defconstant *GL-TEXTURE8* #x84C8) (defconstant *GL-TEXTURE9* #x84C9) (defconstant *GL-TEXTURE10* #x84CA) (defconstant *GL-TEXTURE11* #x84CB) (defconstant *GL-TEXTURE12* #x84CC) (defconstant *GL-TEXTURE13* #x84CD) (defconstant *GL-TEXTURE14* #x84CE) (defconstant *GL-TEXTURE15* #x84CF) (defconstant *GL-TEXTURE16* #x84D0) (defconstant *GL-TEXTURE17* #x84D1) (defconstant *GL-TEXTURE18* #x84D2) (defconstant *GL-TEXTURE19* #x84D3) (defconstant *GL-TEXTURE20* #x84D4) (defconstant *GL-TEXTURE21* #x84D5) (defconstant *GL-TEXTURE22* #x84D6) (defconstant *GL-TEXTURE23* #x84D7) (defconstant *GL-TEXTURE24* #x84D8) (defconstant *GL-TEXTURE25* #x84D9) (defconstant *GL-TEXTURE26* #x84DA) (defconstant *GL-TEXTURE27* #x84DB) (defconstant *GL-TEXTURE28* #x84DC) (defconstant *GL-TEXTURE29* #x84DD) (defconstant *GL-TEXTURE30* #x84DE) (defconstant *GL-TEXTURE31* #x84DF) (defconstant *GL-ACTIVE-TEXTURE* #x84E0) (defconstant *GL-CLIENT-ACTIVE-TEXTURE* #x84E1) (defconstant *GL-MAX-TEXTURE-UNITS* #x84E2) (defconstant *GL-COMBINE* #x8570) (defconstant *GL-COMBINE-RGB* #x8571) (defconstant *GL-COMBINE-ALPHA* #x8572) (defconstant *GL-RGB-SCALE* #x8573) (defconstant *GL-ADD-SIGNED* #x8574) (defconstant *GL-INTERPOLATE* #x8575) (defconstant *GL-CONSTANT* #x8576) (defconstant *GL-PRIMARY-COLOR* #x8577) (defconstant *GL-PREVIOUS* #x8578) (defconstant *GL-SUBTRACT* #x84E7) (defconstant *GL-SRC0-RGB* #x8580) (defconstant *GL-SRC1-RGB* #x8581) (defconstant *GL-SRC2-RGB* #x8582) (defconstant *GL-SRC3-RGB* #x8583) (defconstant *GL-SRC4-RGB* #x8584) (defconstant *GL-SRC5-RGB* #x8585) (defconstant *GL-SRC6-RGB* #x8586) (defconstant *GL-SRC7-RGB* #x8587) (defconstant *GL-SRC0-ALPHA* #x8588) (defconstant *GL-SRC1-ALPHA* #x8589) (defconstant *GL-SRC2-ALPHA* #x858A) (defconstant *GL-SRC3-ALPHA* #x858B) (defconstant *GL-SRC4-ALPHA* #x858C) (defconstant *GL-SRC5-ALPHA* #x858D) (defconstant *GL-SRC6-ALPHA* #x858E) (defconstant *GL-SRC7-ALPHA* #x858F) ;; Obsolete (defconstant *GL-SOURCE0-RGB* #x8580) (defconstant *GL-SOURCE1-RGB* #x8581) (defconstant *GL-SOURCE2-RGB* #x8582) (defconstant *GL-SOURCE3-RGB* #x8583) (defconstant *GL-SOURCE4-RGB* #x8584) (defconstant *GL-SOURCE5-RGB* #x8585) (defconstant *GL-SOURCE6-RGB* #x8586) (defconstant *GL-SOURCE7-RGB* #x8587) (defconstant *GL-SOURCE0-ALPHA* #x8588) (defconstant *GL-SOURCE1-ALPHA* #x8589) (defconstant *GL-SOURCE2-ALPHA* #x858A) (defconstant *GL-SOURCE3-ALPHA* #x858B) (defconstant *GL-SOURCE4-ALPHA* #x858C) (defconstant *GL-SOURCE5-ALPHA* #x858D) (defconstant *GL-SOURCE6-ALPHA* #x858E) (defconstant *GL-SOURCE7-ALPHA* #x858F) (defconstant *GL-OPERAND0-RGB* #x8590) (defconstant *GL-OPERAND1-RGB* #x8591) (defconstant *GL-OPERAND2-RGB* #x8592) (defconstant *GL-OPERAND3-RGB* #x8593) (defconstant *GL-OPERAND4-RGB* #x8594) (defconstant *GL-OPERAND5-RGB* #x8595) (defconstant *GL-OPERAND6-RGB* #x8596) (defconstant *GL-OPERAND7-RGB* #x8597) (defconstant *GL-OPERAND0-ALPHA* #x8598) (defconstant *GL-OPERAND1-ALPHA* #x8599) (defconstant *GL-OPERAND2-ALPHA* #x859A) (defconstant *GL-OPERAND3-ALPHA* #x859B) (defconstant *GL-OPERAND4-ALPHA* #x859C) (defconstant *GL-OPERAND5-ALPHA* #x859D) (defconstant *GL-OPERAND6-ALPHA* #x859E) (defconstant *GL-OPERAND7-ALPHA* #x859F) (defconstant *GL-DOT3-RGB* #x86AE) (defconstant *GL-DOT3-RGBA* #x86AF) (defconstant *GL-TRANSPOSE-MODELVIEW-MATRIX* #x84E3) (defconstant *GL-TRANSPOSE-PROJECTION-MATRIX* #x84E4) (defconstant *GL-TRANSPOSE-TEXTURE-MATRIX* #x84E5) (defconstant *GL-TRANSPOSE-COLOR-MATRIX* #x84E6) (defconstant *GL-NORMAL-MAP* #x8511) (defconstant *GL-REFLECTION-MAP* #x8512) (defconstant *GL-TEXTURE-CUBE-MAP* #x8513) (defconstant *GL-TEXTURE-BINDING-CUBE-MAP* #x8514) (defconstant *GL-TEXTURE-CUBE-MAP-POSITIVE-X* #x8515) (defconstant *GL-TEXTURE-CUBE-MAP-NEGATIVE-X* #x8516) (defconstant *GL-TEXTURE-CUBE-MAP-POSITIVE-Y* #x8517) (defconstant *GL-TEXTURE-CUBE-MAP-NEGATIVE-Y* #x8518) (defconstant *GL-TEXTURE-CUBE-MAP-POSITIVE-Z* #x8519) (defconstant *GL-TEXTURE-CUBE-MAP-NEGATIVE-Z* #x851A) (defconstant *GL-PROXY-TEXTURE-CUBE-MAP* #x851B) (defconstant *GL-MAX-CUBE-MAP-TEXTURE-SIZE* #x851C) (defconstant *GL-COMPRESSED-ALPHA* #x84E9) (defconstant *GL-COMPRESSED-LUMINANCE* #x84EA) (defconstant *GL-COMPRESSED-LUMINANCE-ALPHA* #x84EB) (defconstant *GL-COMPRESSED-INTENSITY* #x84EC) (defconstant *GL-COMPRESSED-RGB* #x84ED) (defconstant *GL-COMPRESSED-RGBA* #x84EE) (defconstant *GL-TEXTURE-COMPRESSION-HINT* #x84EF) (defconstant *GL-TEXTURE-COMPRESSED-IMAGE-SIZE* #x86A0) (defconstant *GL-TEXTURE-COMPRESSED* #x86A1) (defconstant *GL-NUM-COMPRESSED-TEXTURE-FORMATS* #x86A2) (defconstant *GL-COMPRESSED-TEXTURE-FORMATS* #x86A3) (defconstant *GL-MULTISAMPLE* #x809D) (defconstant *GL-SAMPLE-ALPHA-TO-COVERAGE* #x809E) (defconstant *GL-SAMPLE-ALPHA-TO-ONE* #x809F) (defconstant *GL-SAMPLE-COVERAGE* #x80A0) (defconstant *GL-SAMPLE-BUFFERS* #x80A8) (defconstant *GL-SAMPLES* #x80A9) (defconstant *GL-SAMPLE-COVERAGE-VALUE* #x80AA) (defconstant *GL-SAMPLE-COVERAGE-INVERT* #x80AB) (defconstant *GL-MULTISAMPLE-BIT* #x20000000) (defconstant *GL-DEPTH-COMPONENT16* #x81A5) (defconstant *GL-DEPTH-COMPONENT24* #x81A6) (defconstant *GL-DEPTH-COMPONENT32* #x81A7) (defconstant *GL-TEXTURE-DEPTH-SIZE* #x884A) (defconstant *GL-DEPTH-TEXTURE-MODE* #x884B) (defconstant *GL-TEXTURE-COMPARE-MODE* #x884C) (defconstant *GL-TEXTURE-COMPARE-FUNC* #x884D) (defconstant *GL-COMPARE-R-TO-TEXTURE* #x884E) ;; occlusion-query (defconstant *GL-QUERY-COUNTER-BITS* #x8864) (defconstant *GL-CURRENT-QUERY* #x8865) (defconstant *GL-QUERY-RESULT* #x8866) (defconstant *GL-QUERY-RESULT-AVAILABLE* #x8867) (defconstant *GL-SAMPLES-PASSED* #x8914) (defconstant *GL-FOG-COORD-SRC* #x8450) (defconstant *GL-FOG-COORD* #x8451) (defconstant *GL-FRAGMENT-DEPTH* #x8452) (defconstant *GL-CURRENT-FOG-COORD* #x8453) (defconstant *GL-FOG-COORD-ARRAY-TYPE* #x8454) (defconstant *GL-FOG-COORD-ARRAY-STRIDE* #x8455) (defconstant *GL-FOG-COORD-ARRAY-POINTER* #x8456) (defconstant *GL-FOG-COORD-ARRAY* #x8457) ;; Obsolete (defconstant *GL-FOG-COORDINATE-SOURCE* #x8450) (defconstant *GL-FOG-COORDINATE* #x8451) (defconstant *GL-CURRENT-FOG-COORDINATE* #x8453) (defconstant *GL-FOG-COORDINATE-ARRAY-TYPE* #x8454) (defconstant *GL-FOG-COORDINATE-ARRAY-STRIDE* #x8455) (defconstant *GL-FOG-COORDINATE-ARRAY-POINTER* #x8456) (defconstant *GL-FOG-COORDINATE-ARRAY* #x8457) (defconstant *GL-COLOR-SUM* #x8458) (defconstant *GL-CURRENT-SECONDARY-COLOR* #x8459) (defconstant *GL-SECONDARY-COLOR-ARRAY-SIZE* #x845A) (defconstant *GL-SECONDARY-COLOR-ARRAY-TYPE* #x845B) (defconstant *GL-SECONDARY-COLOR-ARRAY-STRIDE* #x845C) (defconstant *GL-SECONDARY-COLOR-ARRAY-POINTER* #x845D) (defconstant *GL-SECONDARY-COLOR-ARRAY* #x845E) (defconstant *GL-POINT-SIZE-MIN* #x8126) (defconstant *GL-POINT-SIZE-MAX* #x8127) (defconstant *GL-POINT-FADE-THRESHOLD-SIZE* #x8128) (defconstant *GL-POINT-DISTANCE-ATTENUATION* #x8129) (defconstant *GL-BLEND-DST-RGB* #x80C8) (defconstant *GL-BLEND-SRC-RGB* #x80C9) (defconstant *GL-BLEND-DST-ALPHA* #x80CA) (defconstant *GL-BLEND-SRC-ALPHA* #x80CB) (defconstant *GL-GENERATE-MIPMAP* #x8191) (defconstant *GL-GENERATE-MIPMAP-HINT* #x8192) (defconstant *GL-INCR-WRAP* #x8507) (defconstant *GL-DECR-WRAP* #x8508) (defconstant *GL-MIRRORED-REPEAT* #x8370) (defconstant *GL-MAX-TEXTURE-LOD-BIAS* #x84FD) (defconstant *GL-TEXTURE-FILTER-CONTROL* #x8500) (defconstant *GL-TEXTURE-LOD-BIAS* #x8501) ;; vertex-buffer-object (defconstant *GL-ARRAY-BUFFER* #x8892) (defconstant *GL-ELEMENT-ARRAY-BUFFER* #x8893) (defconstant *GL-ARRAY-BUFFER-BINDING* #x8894) (defconstant *GL-ELEMENT-ARRAY-BUFFER-BINDING* #x8895) (defconstant *GL-VERTEX-ARRAY-BUFFER-BINDING* #x8896) (defconstant *GL-NORMAL-ARRAY-BUFFER-BINDING* #x8897) (defconstant *GL-COLOR-ARRAY-BUFFER-BINDING* #x8898) (defconstant *GL-INDEX-ARRAY-BUFFER-BINDING* #x8899) (defconstant *GL-TEXTURE-COORD-ARRAY-BUFFER-BINDING* #x889A) (defconstant *GL-EDGE-FLAG-ARRAY-BUFFER-BINDING* #x889B) (defconstant *GL-SECONDARY-COLOR-ARRAY-BUFFER-BINDING* #x889C) (defconstant *GL-FOG-COORD-ARRAY-BUFFER-BINDING* #x889D) (defconstant *GL-WEIGHT-ARRAY-BUFFER-BINDING* #x889E) (defconstant *GL-VERTEX-ATTRIB-ARRAY-BUFFER-BINDING* #x889F) (defconstant *GL-STREAM-DRAW* #x88E0) (defconstant *GL-STREAM-READ* #x88E1) (defconstant *GL-STREAM-COPY* #x88E2) (defconstant *GL-STATIC-DRAW* #x88E4) (defconstant *GL-STATIC-READ* #x88E5) (defconstant *GL-STATIC-COPY* #x88E6) (defconstant *GL-DYNAMIC-DRAW* #x88E8) (defconstant *GL-DYNAMIC-READ* #x88E9) (defconstant *GL-DYNAMIC-COPY* #x88EA) (defconstant *GL-READ-ONLY* #x88B8) (defconstant *GL-WRITE-ONLY* #x88B9) (defconstant *GL-READ-WRITE* #x88BA) (defconstant *GL-BUFFER-SIZE* #x8764) (defconstant *GL-BUFFER-USAGE* #x8765) (defconstant *GL-BUFFER-ACCESS* #x88BB) (defconstant *GL-BUFFER-MAPPED* #x88BC) (defconstant *GL-BUFFER-MAP-POINTER* #x88BD) ;; Obsolete (defconstant *GL-FOG-COORDINATE-ARRAY-BUFFER-BINDING* #x889D) ;; OpenGL 2.0 (defconstant *GL-CURRENT-PROGRAM* #x8B8D) (defconstant *GL-SHADER-TYPE* #x8B4F) (defconstant *GL-DELETE-STATUS* #x8B80) (defconstant *GL-COMPILE-STATUS* #x8B81) (defconstant *GL-LINK-STATUS* #x8B82) (defconstant *GL-VALIDATE-STATUS* #x8B83) (defconstant *GL-INFO-LOG-LENGTH* #x8B84) (defconstant *GL-ATTACHED-SHADERS* #x8B85) (defconstant *GL-ACTIVE-UNIFORMS* #x8B86) (defconstant *GL-ACTIVE-UNIFORM-MAX-LENGTH* #x8B87) (defconstant *GL-SHADER-SOURCE-LENGTH* #x8B88) (defconstant *GL-FLOAT-VEC2* #x8B50) (defconstant *GL-FLOAT-VEC3* #x8B51) (defconstant *GL-FLOAT-VEC4* #x8B52) (defconstant *GL-INT-VEC2* #x8B53) (defconstant *GL-INT-VEC3* #x8B54) (defconstant *GL-INT-VEC4* #x8B55) (defconstant *GL-BOOL* #x8B56) (defconstant *GL-BOOL-VEC2* #x8B57) (defconstant *GL-BOOL-VEC3* #x8B58) (defconstant *GL-BOOL-VEC4* #x8B59) (defconstant *GL-FLOAT-MAT2* #x8B5A) (defconstant *GL-FLOAT-MAT3* #x8B5B) (defconstant *GL-FLOAT-MAT4* #x8B5C) (defconstant *GL-SAMPLER-1D* #x8B5D) (defconstant *GL-SAMPLER-2D* #x8B5E) (defconstant *GL-SAMPLER-3D* #x8B5F) (defconstant *GL-SAMPLER-CUBE* #x8B60) (defconstant *GL-SAMPLER-1D-SHADOW* #x8B61) (defconstant *GL-SAMPLER-2D-SHADOW* #x8B62) (defconstant *GL-SHADING-LANGUAGE-VERSION* #x8B8C) (defconstant *GL-VERTEX-SHADER* #x8B31) (defconstant *GL-MAX-VERTEX-UNIFORM-COMPONENTS* #x8B4A) (defconstant *GL-MAX-VARYING-FLOATS* #x8B4B) (defconstant *GL-MAX-VERTEX-TEXTURE-IMAGE-UNITS* #x8B4C) (defconstant *GL-MAX-COMBINED-TEXTURE-IMAGE-UNITS* #x8B4D) (defconstant *GL-ACTIVE-ATTRIBUTES* #x8B89) (defconstant *GL-ACTIVE-ATTRIBUTE-MAX-LENGTH* #x8B8A) (defconstant *GL-FRAGMENT-SHADER* #x8B30) (defconstant *GL-MAX-FRAGMENT-UNIFORM-COMPONENTS* #x8B49) (defconstant *GL-FRAGMENT-SHADER-DERIVATIVE-HINT* #x8B8B) (defconstant *GL-MAX-VERTEX-ATTRIBS* #x8869) (defconstant *GL-VERTEX-ATTRIB-ARRAY-ENABLED* #x8622) (defconstant *GL-VERTEX-ATTRIB-ARRAY-SIZE* #x8623) (defconstant *GL-VERTEX-ATTRIB-ARRAY-STRIDE* #x8624) (defconstant *GL-VERTEX-ATTRIB-ARRAY-TYPE* #x8625) (defconstant *GL-VERTEX-ATTRIB-ARRAY-NORMALIZED* #x886A) (defconstant *GL-CURRENT-VERTEX-ATTRIB* #x8626) (defconstant *GL-VERTEX-ATTRIB-ARRAY-POINTER* #x8645) (defconstant *GL-VERTEX-PROGRAM-POINT-SIZE* #x8642) (defconstant *GL-VERTEX-PROGRAM-TWO-SIDE* #x8643) (defconstant *GL-MAX-TEXTURE-COORDS* #x8871) (defconstant *GL-MAX-TEXTURE-IMAGE-UNITS* #x8872) (defconstant *GL-MAX-DRAW-BUFFERS* #x8824) (defconstant *GL-DRAW-BUFFER0* #x8825) (defconstant *GL-DRAW-BUFFER1* #x8826) (defconstant *GL-DRAW-BUFFER2* #x8827) (defconstant *GL-DRAW-BUFFER3* #x8828) (defconstant *GL-DRAW-BUFFER4* #x8829) (defconstant *GL-DRAW-BUFFER5* #x882A) (defconstant *GL-DRAW-BUFFER6* #x882B) (defconstant *GL-DRAW-BUFFER7* #x882C) (defconstant *GL-DRAW-BUFFER8* #x882D) (defconstant *GL-DRAW-BUFFER9* #x882E) (defconstant *GL-DRAW-BUFFER10* #x882F) (defconstant *GL-DRAW-BUFFER11* #x8830) (defconstant *GL-DRAW-BUFFER12* #x8831) (defconstant *GL-DRAW-BUFFER13* #x8832) (defconstant *GL-DRAW-BUFFER14* #x8833) (defconstant *GL-DRAW-BUFFER15* #x8834) (defconstant *GL-POINT-SPRITE* #x8861) (defconstant *GL-COORD-REPLACE* #x8862) (defconstant *GL-POINT-SPRITE-COORD-ORIGIN* #x8CA0) (defconstant *GL-LOWER-LEFT* #x8CA1) (defconstant *GL-UPPER-LEFT* #x8CA2) (defconstant *GL-STENCIL-BACK-FUNC* #x8800) (defconstant *GL-STENCIL-BACK-VALUE-MASK* #x8CA4) (defconstant *GL-STENCIL-BACK-REF* #x8CA3) (defconstant *GL-STENCIL-BACK-FAIL* #x8801) (defconstant *GL-STENCIL-BACK-PASS-DEPTH-FAIL* #x8802) (defconstant *GL-STENCIL-BACK-PASS-DEPTH-PASS* #x8803) (defconstant *GL-STENCIL-BACK-WRITEMASK* #x8CA5) ;; OpenGL 2.1 (defconstant *GL-CURRENT-RASTER-SECONDARY-COLOR* #x845F) (defconstant *GL-PIXEL-PACK-BUFFER* #x88EB) (defconstant *GL-PIXEL-UNPACK-BUFFER* #x88EC) (defconstant *GL-PIXEL-PACK-BUFFER-BINDING* #x88ED) (defconstant *GL-PIXEL-UNPACK-BUFFER-BINDING* #x88EF) (defconstant *GL-FLOAT-MAT2x3* #x8B65) (defconstant *GL-FLOAT-MAT2x4* #x8B66) (defconstant *GL-FLOAT-MAT3x2* #x8B67) (defconstant *GL-FLOAT-MAT3x4* #x8B68) (defconstant *GL-FLOAT-MAT4x2* #x8B69) (defconstant *GL-FLOAT-MAT4x3* #x8B6A) (defconstant *GL-SRGB* #x8C40) (defconstant *GL-SRGB8* #x8C41) (defconstant *GL-SRGB-ALPHA* #x8C42) (defconstant *GL-SRGB8-ALPHA8* #x8C43) (defconstant *GL-SLUMINANCE-ALPHA* #x8C44) (defconstant *GL-SLUMINANCE8-ALPHA8* #x8C45) (defconstant *GL-SLUMINANCE* #x8C46) (defconstant *GL-SLUMINANCE8* #x8C47) (defconstant *GL-COMPRESSED-SRGB* #x8C48) (defconstant *GL-COMPRESSED-SRGB-ALPHA* #x8C49) (defconstant *GL-COMPRESSED-SLUMINANCE* #x8C4A) (defconstant *GL-COMPRESSED-SLUMINANCE-ALPHA* #x8C4B) ;; For compatibility with OpenGL v1.0 (defconstant *GL-LOGIC-OP* *GL-INDEX-LOGIC-OP*) (defconstant *GL-TEXTURE-COMPONENTS* *GL-TEXTURE-INTERNAL-FORMAT*) (defconstant *GrayScale* 1) (defconstant *StaticColor* 2) (defconstant *PseudoColor* 3) (defconstant *TrueColor* 4) (defconstant *DirectColor* 5)
74,198
Common Lisp
.lisp
1,617
44.398887
154
0.544661
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
20b08fca1d0bcbde938ef04bc491a04888e1d30b9a341264afb67c3bba51602e
817
[ -1 ]
818
gtk-lib.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/gtk-lib.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/gtk-lib.lisp,v 1.5.3.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") (defun gtk-representation-x-display (rep) (let* ((screen-rep (cg-lib::representation-screen-representation rep)) (display-rep (cg-lib::screen-representation-display screen-rep))) (fli:make-pointer :address (lwgtk:gdk-x11-display-get-display-address (cg-lib::display-representation-display display-rep))))) (defmethod %make-context ((representation cg-lib::widget-representation) opengl-configuration) (when-let (SETUP-GLX-COLOR-MAP-error (capi:capi-object-property (cg-lib::representation-element representation) 'SETUP-GLX-COLOR-MAP-error)) (error "%MAKE-CONTEXT failed for ~s because SETUP-GLX-COLOR-MAP failed : ~a" representation SETUP-GLX-COLOR-MAP-error)) (when-let (drawable (gp::gdk-port-gdkdrawable representation)) (let* ((screen-rep (cg-lib::representation-screen-representation representation)) (display-rep (cg-lib::screen-representation-display screen-rep)) (directp (if (eq (getf opengl-configuration :direct) :force) T (let ((host (cg-lib::display-representation-host display-rep))) (or (not host) (string= host "localhost") (string= host "unix") (string= host "") (string= host (machine-instance))))))) (let ((context (lwgtk:with-gdk-locked () (let ((xdisplay (fli:make-pointer :address (lwgtk:gdk-x11-display-get-display-address (cg-lib::display-representation-display display-rep)))) (visual (lwgtk:gdk-x11-visual-get-xvisual (lwgtk:gdk-drawable-get-visual drawable)))) (call-glx-create-context xdisplay visual (let ((share (getf opengl-configuration :share))) (if (and share (typep share 'glxcontext)) share nil)) directp))))) (unless context (error "Failed to create GLX Context for ~s" representation)) context)))) (defmethod %free-opengl-resources ((rep cg-lib::output-pane-representation) context) ;; called by the capi-internals:representation-destroy method. (when context (with-slots (configuration) (cg-lib::representation-element rep) (unless (getf configuration :share) (lwgtk:with-gdk-locked() ;; Unsatisfactory. We need a way to share information about shared contexts. (let ((xdisplay (gtk-representation-x-display rep))) (glx-destroy-context xdisplay context))))))) (defmethod %start-rendering ((rep cg-lib::output-pane-representation) context) (when (gp::gdk-port-gdkdrawable rep) (lwgtk:lock-gdk-lock) (let ((xid (lwgtk:gdk-x11-drawable-get-xid (gp::gdk-port-gdkdrawable rep))) (xdisplay (gtk-representation-x-display rep))) (let ((cg-lib::*last-x-error-string* nil)) (values (glx-make-current xdisplay xid context) cg-lib::*last-x-error-string*))))) (defmethod %stop-rendering ((rep cg-lib::output-pane-representation)) (unwind-protect (let ((xdisplay (gtk-representation-x-display rep))) (glx-make-current xdisplay 0 nil)) ;; 0 is none (lwgtk:unlock-gdk-lock))) (defmethod %swap-buffers ((rep cg-lib::output-pane-representation) context) (declare (ignore context)) (lwgtk:with-gdk-locked () (let ((xid (lwgtk:gdk-x11-drawable-get-xid (gp::gdk-port-gdkdrawable rep))) (xdisplay (gtk-representation-x-display rep))) (glx-swap-buffers xdisplay xid)))) (defmethod %resize-opengl-context ((rep cg-lib::output-pane-representation) context width height) #+do-nothing (lwgtk:with-gdk-locked())) (defmethod %describe-configuration ((rep cg-lib::widget-representation) context &optional (stream *standard-output*) collectp) (let ((results (lwgtk:with-gdk-locked () (let* ((screen-rep (cg-lib::representation-screen-representation rep)) (display-rep (cg-lib::screen-representation-display screen-rep)) (xdisplay (fli:make-pointer :address (lwgtk:gdk-x11-display-get-display-address (cg-lib::display-representation-display display-rep)))) (visual (lwgtk:gdk-x11-visual-get-xvisual (lwgtk:gdk-drawable-get-visual (gp::gdk-port-gdkdrawable rep)))) (x-visual-info (x-visual-info-from-visual xdisplay visual))) (prog1 (let ((directp (glx-is-direct xdisplay context))) (list* (format nil "Connection to the graphics subsystem is ~:[via the X server.~;direct.~]" directp) (mapcar #'(lambda (attrib) (destructuring-bind (glx-attrib name descr) attrib (multiple-value-bind (error value) (glx-get-config xdisplay x-visual-info glx-attrib 0) (if (zerop error) (format nil "~@?" descr value) (format nil "Failed to get GL context attribute ~a" name))))) *glx-get-config-attributes*))) (x-free x-visual-info)))))) (if collectp results (dolist (r results) (format stream "~%~a" r))))) (defmethod %get-debug-entry-hook ((x cg-lib::output-pane-representation)) 'lwgtk:gdk-lock-debug2-hook) ;;; Returns an error-string if failed rather than error, so can ;; be used inside lock. (defun setup-glx-color-map (rep pane widget) (let* ((screen-rep (cg-lib::representation-screen-representation rep)) (display-rep (cg-lib::screen-representation-display screen-rep)) (xdisplay (fli:make-pointer :address (lwgtk:gdk-x11-display-get-display-address (cg-lib::display-representation-display display-rep)))) (gdk-screen (cg-lib::screen-representation-screen screen-rep)) (screen-number (lwgtk:gdk-screen-get-number gdk-screen)) (configuration (slot-value pane 'configuration)) ) (when-let (error (if-let (xvi (call-glx-choose-visual xdisplay screen-number configuration)) (prog1 (if-let (gdk-visual (lwgtk:gdk-x11-screen-lookup-visual gdk-screen (fli::foreign-slot-value xvi 'visualid))) (let ((color-map (lwgtk:gdk-colormap-new gdk-visual nil))) (lwgtk:gtk-widget-set-colormap widget color-map) (lwgtk:g-object-unref color-map) nil) ;;; no error "failed to lookup visual") (x-free xvi)) "glXChooseVisual failed")) (format nil "~a for display ~a.~d with configuration ~s" error (cg-lib::display-representation-display-spec display-rep) screen-number configuration)))) (defmethod cg-lib::create-main-widget :around ((rep cg-lib::output-pane-representation) (pane opengl-pane) parent-widget) (let ((widget (call-next-method))) (when-let (err-string (setup-glx-color-map rep pane widget)) (setf (capi:capi-object-property pane 'SETUP-GLX-COLOR-MAP-error) err-string) ;; block %make-context (cg-lib::gtk-error err-string)) widget))
8,618
Common Lisp
.lisp
143
42.160839
152
0.547919
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
e43895b1bebfe4750705820d45bfd8a928bd8c1820d94d751e3a0cd3eaa040ef
818
[ -1 ]
819
cocoa.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/cocoa.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/cocoa.lisp,v 1.7.1.1 2014/05/27 20:56:56 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. ;; Support for OpenGL with CAPI/Cocoa. ;; Symbols in the CAPI-COCOA-LIB package are not part of a supported API. (in-package "OPENGL") (defun opengl-pane-representation-view (rep) (capi-cocoa-lib::representation-main-view rep)) (defstruct cocoa-context context pixel-format set-view) (defmethod %make-context ((rep capi-cocoa-lib::output-pane-representation) opengl-configuration) (let* ((view (opengl-pane-representation-view rep)) (pixel-format (choose-cocoa-pixel-format view opengl-configuration))) (if pixel-format (let ((nscontext (objc:invoke (objc:invoke "NSOpenGLContext" "alloc") "initWithFormat:shareContext:" pixel-format nil))) ;; Invoking setView here does not work for some reason so do it in ;; %start-rendering using the set-view slot instead. #+comment (objc:invoke nscontext "setView:" view) (make-cocoa-context :context nscontext :pixel-format pixel-format :set-view view)) (error "Can't make context for ~s.~%Pixel-format not set" opengl-configuration)))) (defmethod %start-rendering ((rep capi-cocoa-lib::output-pane-representation) context) (let ((nscontext (cocoa-context-context context))) (when (objc:null-objc-pointer-p (objc:invoke nscontext "view")) (objc:invoke nscontext "setView:" (cocoa-context-set-view context))) (objc:invoke nscontext "makeCurrentContext") t)) (defmethod %stop-rendering ((rep capi-cocoa-lib::output-pane-representation)) (objc:invoke "NSOpenGLContext" "clearCurrentContext") t) (defmethod %swap-buffers ((rep capi-cocoa-lib::output-pane-representation) context) (let ((nscontext (cocoa-context-context context))) (objc:invoke nscontext "flushBuffer") t)) (defmethod %free-opengl-resources ((rep capi-cocoa-lib::output-pane-representation) context) (when context (let ((nscontext (cocoa-context-context context))) (objc:invoke nscontext "clearDrawable") (objc:release nscontext) (objc:release (cocoa-context-pixel-format context)))) t) (defmethod %resize-opengl-context ((rep capi-cocoa-lib::output-pane-representation) context width height) (declare (ignore width height)) (when context (let ((nscontext (cocoa-context-context context))) (objc:invoke nscontext "update")))) (defmethod %describe-configuration ((rep capi-cocoa-lib::output-pane-representation) context &optional (stream *standard-output*) collectp) (let ((results (descibe-cocoa-pixel-format (cocoa-context-pixel-format context)))) (if collectp results (format stream "~&Color buffer size : ~d~%Uses ~:[Color Index~;RGBA~]~%Is ~:[single~;double~]-buffered~@[~%Accumulator buffer size (per channel) = ~d bits~]~@[~%Depth buffer size = ~d bits~]~@[~%Stencil buffer size = ~d bits~]~@[~%Has ~d aux buffers~]" (getf results :buffer-size) (getf results :rgba) (getf results :double-buffer) (getf results :accum) (getf results :depth-buffer) (getf results :stencil-size) (getf results :aux))))) ;; NSOpenGLPixelFormatAttribute (defconstant ns-open-gl-pfa-all-renderers 1) (defconstant ns-open-gl-pfa-double-buffer 5) (defconstant ns-open-gl-pfa-stereo 6) (defconstant ns-open-gl-pfa-aux-buffers 7) (defconstant ns-open-gl-pfa-color-size 8) (defconstant ns-open-gl-pfa-alpha-size 11) (defconstant ns-open-gl-pfa-depth-size 12) (defconstant ns-open-gl-pfa-stencil-size 13) (defconstant ns-open-gl-pfa-accum-size 14) (defconstant ns-open-gl-pfa-minimum-policy 51) (defconstant ns-open-gl-pfa-maximum-policy 52) (defconstant ns-open-gl-pfa-off-screen 53) (defconstant ns-open-gl-pfa-full-screen 54) (defconstant ns-open-gl-pfa-sample-buffers 55) (defconstant ns-open-gl-pfa-samples 56) (defconstant ns-open-gl-pfa-aux-depth-stencil 57) (defconstant ns-open-gl-pfa-color-float 58) ; >= 10.4 (defconstant ns-open-gl-pfa-multisample 59) ; >= 10.4 (defconstant ns-open-gl-pfa-supersample 60) ; >= 10.4 (defconstant ns-open-gl-pfa-sample-alpha 61) ; >= 10.4 (defconstant ns-open-gl-pfa-renderer-id 70) (defconstant ns-open-gl-pfa-single-renderer 71) (defconstant ns-open-gl-pfa-no-recovery 72) (defconstant ns-open-gl-pfa-accelerated 73) (defconstant ns-open-gl-pfa-closest-policy 74) (defconstant ns-open-gl-pfa-robust 75) (defconstant ns-open-gl-pfa-backing-store 76) (defconstant ns-open-gl-pfa-mp-safe 78) (defconstant ns-open-gl-pfa-window 80) (defconstant ns-open-gl-pfa-multi-screen 81) (defconstant ns-open-gl-pfa-compliant 83) (defconstant ns-open-gl-pfa-screen-mask 84) (defconstant ns-open-gl-pfa-pixel-buffer 90) ; >= 10.3 (defconstant ns-open-gl-pfa-remote-pixel-buffer 91) ; >= 10.6 (defconstant ns-open-gl-pfa-allow-offline-renderers 96) ; >= 10.5 (defconstant ns-open-gl-pfa-accelerated-compute 97) ; >= 10.6 (defconstant ns-open-gl-pfa-virtual-screen-count 128) (defun ns-open-gl-pixel-format-attribute-type () (if (> (floor (cocoa:ns-app-kit-version-number)) cocoa:ns-app-kit-version-number-10_4) '(:unsigned :int) ':int)) (defun choose-cocoa-pixel-format (view configuration) "Returns the NSOpenGLPixelFormat for rep which supports the requested configuration. Returns NIL if it fails. Configuration is a plist with the following allowed indicators: :double-buffer, :double-buffered, - synonyms, value T or NIL." (fli:with-dynamic-foreign-objects () (let* ((attributes-list (nconc (and (or (getf configuration :double-buffer) (getf configuration :double-buffered)) (list ns-open-gl-pfa-double-buffer)) (let ((depth-buffer (getf configuration :depth-buffer))) (and depth-buffer (list ns-open-gl-pfa-depth-size depth-buffer))) (list 0))) (attributes (fli:allocate-dynamic-foreign-object :type (ns-open-gl-pixel-format-attribute-type) :initial-contents attributes-list))) (let ((format (objc:invoke (objc:invoke "NSOpenGLPixelFormat" "alloc") "initWithAttributes:" attributes))) (if (objc:null-objc-pointer-p format) nil format))))) (defun pixel-format-attribute-value (pixel-format attribute &optional screen) (fli:with-dynamic-foreign-objects () (let ((value (fli:allocate-dynamic-foreign-object :type :int))) (objc:invoke pixel-format "getValues:forAttribute:forVirtualScreen:" value ; this is an out parameter attribute (or screen 0)) (fli:dereference value)))) (defun descibe-cocoa-pixel-format (pixel-format) (list :double-buffer (not (zerop (pixel-format-attribute-value pixel-format ns-open-gl-pfa-double-buffer))) :depth-buffer (pixel-format-attribute-value pixel-format ns-open-gl-pfa-depth-size) ))
8,122
Common Lisp
.lisp
161
40.391304
252
0.61707
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
f1a097d7754b06faaaf895a3146f95d78857fa5c44b8c4817eb0c35f1d93cd02
819
[ -1 ]
820
fns.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/fns.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/fns.lisp,v 1.11.9.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") (fli:define-foreign-function (gl-accum "glAccum" :source) ((op glenum) (value glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-alpha-func "glAlphaFunc" :source) ((func glenum) (ref glclampf)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-are-textures-resident "glAreTexturesResident" :source) ((n glsizei) (textures (gl-vector :unsigned-32)) (residences (gl-vector :unsigned-8))) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-array-element "glArrayElement" :source) ((i glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-begin "glBegin" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-bind-texture "glBindTexture" :source) ((target glenum) (texture gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-bitmap "glBitmap" :source) ((width glsizei) (height glsizei) (xorig glfloat) (yorig glfloat) (xmove glfloat) (ymove glfloat) (bitmap (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-blend-color "glBlendColor" :source) ((red glclampf) (green glclampf) (blue glclampf) (alpha glclampf)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-blend-equation "glBlendEquation" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-blend-equation-separate "glBlendEquationSeparate" :source) ((mode-rgb glenum) (mode-alpha glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-blend-func "glBlendFunc" :source) ((sfactor glenum) (dfactor glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-call-list "glCallList" :source) ((list gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-call-lists "glCallLists" :source) ((n glsizei) (type glenum) (lists gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear "glClear" :source) ((mask glbitfield)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear-accum "glClearAccum" :source) ((red glfloat) (green glfloat) (blue glfloat) (alpha glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear-color "glClearColor" :source) ((red glclampf) (green glclampf) (blue glclampf) (alpha glclampf)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear-depth "glClearDepth" :source) ((depth glclampd)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear-index "glClearIndex" :source) ((c glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clear-stencil "glClearStencil" :source) ((s glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-clip-plane "glClipPlane" :source) ((plane glenum) (equation (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-b "glColor3b" :source) ((red glbyte) (green glbyte) (blue glbyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-bv "glColor3bv" :source) ((v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-d "glColor3d" :source) ((red gldouble) (green gldouble) (blue gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-dv "glColor3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-f "glColor3f" :source) ((red glfloat) (green glfloat) (blue glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-fv "glColor3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-i "glColor3i" :source) ((red glint) (green glint) (blue glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-iv "glColor3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-s "glColor3s" :source) ((red glshort) (green glshort) (blue glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-sv "glColor3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-ub "glColor3ub" :source) ((red glubyte) (green glubyte) (blue glubyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-ubv "glColor3ubv" :source) ((v (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-ui "glColor3ui" :source) ((red gluint) (green gluint) (blue gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-uiv "glColor3uiv" :source) ((v (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-us "glColor3us" :source) ((red glushort) (green glushort) (blue glushort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color3-usv "glColor3usv" :source) ((v (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-b "glColor4b" :source) ((red glbyte) (green glbyte) (blue glbyte) (alpha glbyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-bv "glColor4bv" :source) ((v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-d "glColor4d" :source) ((red gldouble) (green gldouble) (blue gldouble) (alpha gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-dv "glColor4dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-f "glColor4f" :source) ((red glfloat) (green glfloat) (blue glfloat) (alpha glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-fv "glColor4fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-i "glColor4i" :source) ((red glint) (green glint) (blue glint) (alpha glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-iv "glColor4iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-s "glColor4s" :source) ((red glshort) (green glshort) (blue glshort) (alpha glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-sv "glColor4sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-ub "glColor4ub" :source) ((red glubyte) (green glubyte) (blue glubyte) (alpha glubyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-ubv "glColor4ubv" :source) ((v (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-ui "glColor4ui" :source) ((red gluint) (green gluint) (blue gluint) (alpha gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-uiv "glColor4uiv" :source) ((v (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-us "glColor4us" :source) ((red glushort) (green glushort) (blue glushort) (alpha glushort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color4-usv "glColor4usv" :source) ((v (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-mask "glColorMask" :source) ((red glboolean) (green glboolean) (blue glboolean) (alpha glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-material "glColorMaterial" :source) ((face glenum) (mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-pointer "glColorPointer" :source) ((size glint) (type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-sub-table "glColorSubTable" :source) ((target glenum) (start glsizei) (count glsizei) (format glenum) (type glenum) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-table "glColorTable" :source) ((target glenum) (internalformat glenum) (width glsizei) (format glenum) (type glenum) (table gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-table-parameterfv "glColorTableParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-color-table-parameteriv "glColorTableParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-filter1-d "glConvolutionFilter1D" :source) ((target glenum) (internalformat glenum) (width glsizei) (format glenum) (type glenum) (image gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-filter2-d "glConvolutionFilter2D" :source) ((target glenum) (internalformat glenum) (width glsizei) (height glsizei) (format glenum) (type glenum) (image gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-parameterf "glConvolutionParameterf" :source) ((target glenum) (pname glenum) (params glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-parameterfv "glConvolutionParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-parameteri "glConvolutionParameteri" :source) ((target glenum) (pname glenum) (params glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-convolution-parameteriv "glConvolutionParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-color-sub-table "glCopyColorSubTable" :source) ((target glenum) (start glsizei) (x glint) (y glint) (width glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-color-table "glCopyColorTable" :source) ((target glenum) (internalformat glenum) (x glint) (y glint) (width glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-convolution-filter1-d "glCopyConvolutionFilter1D" :source) ((target glenum) (internalformat glenum) (x glint) (y glint) (width glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-convolution-filter2-d "glCopyConvolutionFilter2D" :source) ((target glenum) (internalformat glenum) (x glint) (y glint) (width glsizei) (height glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-pixels "glCopyPixels" :source) ((x glint) (y glint) (width glsizei) (height glsizei) (type glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-tex-image1-d "glCopyTexImage1D" :source) ((target glenum) (level glint) (internalformat glenum) (x glint) (y glint) (width glsizei) (border glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-tex-image2-d "glCopyTexImage2D" :source) ((target glenum) (level glint) (internalformat glenum) (x glint) (y glint) (width glsizei) (height glsizei) (border glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-tex-sub-image1-d "glCopyTexSubImage1D" :source) ((target glenum) (level glint) (xoffset glint) (x glint) (y glint) (width glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-tex-sub-image2-d "glCopyTexSubImage2D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (x glint) (y glint) (width glsizei) (height glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-copy-tex-sub-image3-d "glCopyTexSubImage3D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (zoffset glint) (x glint) (y glint) (width glsizei) (height glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-cull-face "glCullFace" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-lists "glDeleteLists" :source) ((list gluint) (range glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-textures "glDeleteTextures" :source) ((n glsizei) (textures (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-depth-func "glDepthFunc" :source) ((func glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-depth-mask "glDepthMask" :source) ((flag glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-depth-range "glDepthRange" :source) ((z-near glclampd) (z-far glclampd)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-disable "glDisable" :source) ((cap glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-disable-client-state "glDisableClientState" :source) ((array glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-arrays "glDrawArrays" :source) ((mode glenum) (first glint) (count glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-buffer "glDrawBuffer" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-elements "glDrawElements" :source) ((mode glenum) (count glsizei) (type glenum) (indices gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-pixels "glDrawPixels" :source) ((width glsizei) (height glsizei) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-range-elements "glDrawRangeElements" :source) ((mode glenum) (start gluint) (end gluint) (count glsizei) (type glenum) (indices gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-edge-flag "glEdgeFlag" :source) ((flag glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-edge-flag-pointer "glEdgeFlagPointer" :source) ((stride GLsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-edge-flagv "glEdgeFlagv" :source) ((flag (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-enable "glEnable" :source) ((cap glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-enable-client-state "glEnableClientState" :source) ((array glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-end "glEnd" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-end-list "glEndList" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord1-d "glEvalCoord1d" :source) ((u gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord1-dv "glEvalCoord1dv" :source) ((u (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord1-f "glEvalCoord1f" :source) ((u glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord1-fv "glEvalCoord1fv" :source) ((u (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord2-d "glEvalCoord2d" :source) ((u gldouble) (v gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord2-dv "glEvalCoord2dv" :source) ((u (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord2-f "glEvalCoord2f" :source) ((u glfloat) (v glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-coord2-fv "glEvalCoord2fv" :source) ((u (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-mesh1 "glEvalMesh1" :source) ((mode glenum) (i1 glint) (i2 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-mesh2 "glEvalMesh2" :source) ((mode glenum) (i1 glint) (i2 glint) (j1 glint) (j2 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-point1 "glEvalPoint1" :source) ((i glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-eval-point2 "glEvalPoint2" :source) ((i glint) (j glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-feedback-buffer "glFeedbackBuffer" :source) ((size glsizei) (type glenum) (buffer (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-finish "glFinish" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-flush "glFlush" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fogf "glFogf" :source) ((pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fogfv "glFogfv" :source) ((pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fogi "glFogi" :source) ((pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fogiv "glFogiv" :source) ((pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-front-face "glFrontFace" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-frustum "glFrustum" :source) ((left gldouble) (right gldouble) (bottom gldouble) (top gldouble) (z-near gldouble) (z-far gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-gen-lists "glGenLists" :source) ((range glsizei)) :result-type gluint :language :ansi-c) (fli:define-foreign-function (gl-gen-textures "glGenTextures" :source) ((n glsizei) (textures (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-booleanv "glGetBooleanv" :source) ((pname glenum) (params (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-clip-plane "glGetClipPlane" :source) ((plane glenum) (equation (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-color-table "glGetColorTable" :source) ((target glenum) (format glenum) (type glenum) (table gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-color-table-parameterfv "glGetColorTableParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-color-table-parameteriv "glGetColorTableParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-convolution-filter "glGetConvolutionFilter" :source) ((target glenum) (format glenum) (type glenum) (image gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-convolution-parameterfv "glGetConvolutionParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-convolution-parameteriv "glGetConvolutionParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-doublev "glGetDoublev" :source) ((pname glenum) (params (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-error "glGetError" :source) nil :result-type glenum :language :ansi-c) (fli:define-foreign-function (gl-get-floatv "glGetFloatv" :source) ((pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-histogram "glGetHistogram" :source) ((target glenum) (reset glboolean) (format glenum) (type glenum) (values gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-histogram-parameterfv "glGetHistogramParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-histogram-parameteriv "glGetHistogramParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-integerv "glGetIntegerv" :source) ((pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-lightfv "glGetLightfv" :source) ((light glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-lightiv "glGetLightiv" :source) ((light glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-mapdv "glGetMapdv" :source) ((target glenum) (query glenum) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-mapfv "glGetMapfv" :source) ((target glenum) (query glenum) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-mapiv "glGetMapiv" :source) ((target glenum) (query glenum) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-materialfv "glGetMaterialfv" :source) ((face glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-materialiv "glGetMaterialiv" :source) ((face glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-minmax "glGetMinmax" :source) ((target glenum) (reset glboolean) (format glenum) (type glenum) (values gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-minmax-parameterfv "glGetMinmaxParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-minmax-parameteriv "glGetMinmaxParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-pixel-mapfv "glGetPixelMapfv" :source) ((map glenum) (values (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-pixel-mapuiv "glGetPixelMapuiv" :source) ((map glenum) (values (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-pixel-mapusv "glGetPixelMapusv" :source) ((map glenum) (values (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-pointerv "glGetPointerv" :source) ((pname glenum) (:ignore #|params|# (:reference-return (:pointer GLvoid)))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-polygon-stipple "glGetPolygonStipple" :source) ((mask (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-separable-filter "glGetSeparableFilter" :source) ((target glenum) (format glenum) (type glenum) (row gl-vector) (column gl-vector) (span gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-string "glGetString" :source) ((name glenum)) :result-type glstring-return :language :ansi-c) (fli:define-foreign-function (gl-get-tex-envfv "glGetTexEnvfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-enviv "glGetTexEnviv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-gendv "glGetTexGendv" :source) ((coord glenum) (pname glenum) (params (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-genfv "glGetTexGenfv" :source) ((coord glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-geniv "glGetTexGeniv" :source) ((coord glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-image "glGetTexImage" :source) ((target glenum) (level glint) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-level-parameterfv "glGetTexLevelParameterfv" :source) ((target glenum) (level glint) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-level-parameteriv "glGetTexLevelParameteriv" :source) ((target glenum) (level glint) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-parameterfv "glGetTexParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-tex-parameteriv "glGetTexParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-hint "glHint" :source) ((target glenum) (mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-histogram "glHistogram" :source) ((target glenum) (width glsizei) (internalformat glenum) (sink glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-index-mask "glIndexMask" :source) ((mask gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-index-pointer "glIndexPointer" :source) ((type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexd "glIndexd" :source) ((c gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexdv "glIndexdv" :source) ((c (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexf "glIndexf" :source) ((c glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexfv "glIndexfv" :source) ((c (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexi "glIndexi" :source) ((c glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexiv "glIndexiv" :source) ((c (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexs "glIndexs" :source) ((c glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexsv "glIndexsv" :source) ((c (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexub "glIndexub" :source) ((c glubyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-indexubv "glIndexubv" :source) ((c (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-init-names "glInitNames" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-interleaved-arrays "glInterleavedArrays" :source) ((format glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-is-enabled "glIsEnabled" :source) ((cap glenum)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-is-list "glIsList" :source) ((list gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-is-texture "glIsTexture" :source) ((texture gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-light-modelf "glLightModelf" :source) ((pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-light-modelfv "glLightModelfv" :source) ((pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-light-modeli "glLightModeli" :source) ((pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-light-modeliv "glLightModeliv" :source) ((pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-lightf "glLightf" :source) ((light glenum) (pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-lightfv "glLightfv" :source) ((light glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-lighti "glLighti" :source) ((light glenum) (pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-lightiv "glLightiv" :source) ((light glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-line-stipple "glLineStipple" :source) ((factor glint) (pattern glushort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-line-width "glLineWidth" :source) ((width glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-list-base "glListBase" :source) ((base gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-identity "glLoadIdentity" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-matrixd "glLoadMatrixd" :source) ((m (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-matrixf "glLoadMatrixf" :source) ((m (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-name "glLoadName" :source) ((name gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-logic-op "glLogicOp" :source) ((opcode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map1-d "glMap1d" :source) ((target glenum) (u1 gldouble) (u2 gldouble) (stride glint) (order glint) (points (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map1-f "glMap1f" :source) ((target glenum) (u1 glfloat) (u2 glfloat) (stride glint) (order glint) (points (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map2-d "glMap2d" :source) ((target glenum) (u1 gldouble) (u2 gldouble) (ustride glint) (uorder glint) (v1 gldouble) (v2 gldouble) (vstride glint) (vorder glint) (points (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map2-f "glMap2f" :source) ((target glenum) (u1 glfloat) (u2 glfloat) (ustride glint) (uorder glint) (v1 glfloat) (v2 glfloat) (vstride glint) (vorder glint) (points (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map-grid1-d "glMapGrid1d" :source) ((un glint) (u1 gldouble) (u2 gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map-grid1-f "glMapGrid1f" :source) ((un glint) (u1 glfloat) (u2 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map-grid2-d "glMapGrid2d" :source) ((un glint) (u1 gldouble) (u2 gldouble) (vn glint) (v1 gldouble) (v2 gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map-grid2-f "glMapGrid2f" :source) ((un glint) (u1 glfloat) (u2 glfloat) (vn glint) (v1 glfloat) (v2 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-materialf "glMaterialf" :source) ((face glenum) (pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-materialfv "glMaterialfv" :source) ((face glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-materiali "glMateriali" :source) ((face glenum) (pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-materialiv "glMaterialiv" :source) ((face glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-matrix-mode "glMatrixMode" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-minmax "glMinmax" :source) ((target glenum) (internalformat glenum) (sink glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-mult-matrixd "glMultMatrixd" :source) ((m (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-mult-matrixf "glMultMatrixf" :source) ((m (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-new-list "glNewList" :source) ((list gluint) (mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-b "glNormal3b" :source) ((nx glbyte) (ny glbyte) (nz glbyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-bv "glNormal3bv" :source) ((v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-d "glNormal3d" :source) ((nx gldouble) (ny gldouble) (nz gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-dv "glNormal3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-f "glNormal3f" :source) ((nx glfloat) (ny glfloat) (nz glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-fv "glNormal3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-i "glNormal3i" :source) ((nx glint) (ny glint) (nz glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-iv "glNormal3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-s "glNormal3s" :source) ((nx glshort) (ny glshort) (nz glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal3-sv "glNormal3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-normal-pointer "glNormalPointer" :source) ((type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-ortho "glOrtho" :source) ((left gldouble) (right gldouble) (bottom gldouble) (top gldouble) (z-near gldouble) (z-far gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pass-through "glPassThrough" :source) ((token glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-mapfv "glPixelMapfv" :source) ((map glenum) (mapsize glint) (values (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-mapuiv "glPixelMapuiv" :source) ((map glenum) (mapsize glint) (values (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-mapusv "glPixelMapusv" :source) ((map glenum) (mapsize glint) (values (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-storef "glPixelStoref" :source) ((pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-storei "glPixelStorei" :source) ((pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-transferf "glPixelTransferf" :source) ((pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-transferi "glPixelTransferi" :source) ((pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pixel-zoom "glPixelZoom" :source) ((xfactor glfloat) (yfactor glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-point-size "glPointSize" :source) ((size glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-polygon-mode "glPolygonMode" :source) ((face glenum) (mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-polygon-offset "glPolygonOffset" :source) ((factor glfloat) (units glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-polygon-stipple "glPolygonStipple" :source) ((mask (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pop-attrib "glPopAttrib" :source) () :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pop-client-attrib "glPopClientAttrib" :source) () :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pop-matrix "glPopMatrix" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-pop-name "glPopName" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-prioritize-textures "glPrioritizeTextures" :source) ((n GLsizei) (textures (gl-vector :unsigned-32)) (priorities (gl-vector :single-float)) ; glclampf ) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-push-attrib "glPushAttrib" :source) ((mask glbitfield)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-push-client-attrib "glPushClientAttrib" :source) ((mask glbitfield)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-push-matrix "glPushMatrix" :source) nil :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-push-name "glPushName" :source) ((name gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-d "glRasterPos2d" :source) ((x gldouble) (y gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-dv "glRasterPos2dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-f "glRasterPos2f" :source) ((x glfloat) (y glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-fv "glRasterPos2fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-i "glRasterPos2i" :source) ((x glint) (y glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-iv "glRasterPos2iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-s "glRasterPos2s" :source) ((x glshort) (y glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos2-sv "glRasterPos2sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-d "glRasterPos3d" :source) ((x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-dv "glRasterPos3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-f "glRasterPos3f" :source) ((x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-fv "glRasterPos3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-i "glRasterPos3i" :source) ((x glint) (y glint) (z glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-iv "glRasterPos3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-s "glRasterPos3s" :source) ((x glshort) (y glshort) (z glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos3-sv "glRasterPos3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-d "glRasterPos4d" :source) ((x gldouble) (y gldouble) (z gldouble) (w gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-dv "glRasterPos4dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-f "glRasterPos4f" :source) ((x glfloat) (y glfloat) (z glfloat) (w glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-fv "glRasterPos4fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-i "glRasterPos4i" :source) ((x glint) (y glint) (z glint) (w glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-iv "glRasterPos4iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-s "glRasterPos4s" :source) ((x glshort) (y glshort) (z glshort) (w glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-raster-pos4-sv "glRasterPos4sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-read-buffer "glReadBuffer" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-read-pixels "glReadPixels" :source) ((x glint) (y glint) (width glsizei) (height glsizei) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectd "glRectd" :source) ((x1 gldouble) (y1 gldouble) (x2 gldouble) (y2 gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectdv "glRectdv" :source) ((v1 (gl-vector :double-float)) (v2 (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectf "glRectf" :source) ((x1 glfloat) (y1 glfloat) (x2 glfloat) (y2 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectfv "glRectfv" :source) ((v1 (gl-vector :single-float)) (v2 (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-recti "glRecti" :source) ((x1 glint) (y1 glint) (x2 glint) (y2 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectiv "glRectiv" :source) ((v1 (gl-vector :signed-32)) (v2 (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rects "glRects" :source) ((x1 glshort) (y1 glshort) (x2 glshort) (y2 glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rectsv "glRectsv" :source) ((v1 (gl-vector :signed-16)) (v2 (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-render-mode "glRenderMode" :source) ((mode glenum)) :result-type glint :language :ansi-c) (fli:define-foreign-function (gl-reset-histogram "glResetHistogram" :source) ((target glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-reset-minmax "glResetMinmax" :source) ((target glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rotated "glRotated" :source) ((angle gldouble) (x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-rotatef "glRotatef" :source) ((angle glfloat) (x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-scaled "glScaled" :source) ((x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-scalef "glScalef" :source) ((x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-scissor "glScissor" :source) ((x glint) (y glint) (width glsizei) (height glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-select-buffer "glSelectBuffer" :source) ((size glsizei) (buffer (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-separable-filter2-d "glSeparableFilter2D" :source) ((target glenum) (internalformat glenum) (width glsizei) (height glsizei) (format glenum) (type glenum) (row gl-vector) (column gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-shade-model "glShadeModel" :source) ((mode glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-stencil-func "glStencilFunc" :source) ((func glenum) (ref glint) (mask gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-stencil-mask "glStencilMask" :source) ((mask gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-stencil-op "glStencilOp" :source) ((fail glenum) (zfail glenum) (zpass glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-d "glTexCoord1d" :source) ((s gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-dv "glTexCoord1dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-f "glTexCoord1f" :source) ((s glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-fv "glTexCoord1fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-i "glTexCoord1i" :source) ((s glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-iv "glTexCoord1iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-s "glTexCoord1s" :source) ((s glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord1-sv "glTexCoord1sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-d "glTexCoord2d" :source) ((s gldouble) (arg-t gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-dv "glTexCoord2dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-f "glTexCoord2f" :source) ((s glfloat) (arg-t glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-fv "glTexCoord2fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-i "glTexCoord2i" :source) ((s glint) (arg-t glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-iv "glTexCoord2iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-s "glTexCoord2s" :source) ((s glshort) (arg-t glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord2-sv "glTexCoord2sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-d "glTexCoord3d" :source) ((s gldouble) (arg-t gldouble) (r gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-dv "glTexCoord3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-f "glTexCoord3f" :source) ((s glfloat) (arg-t glfloat) (r glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-fv "glTexCoord3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-i "glTexCoord3i" :source) ((s glint) (arg-t glint) (r glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-iv "glTexCoord3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-s "glTexCoord3s" :source) ((s glshort) (arg-t glshort) (r glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord3-sv "glTexCoord3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-d "glTexCoord4d" :source) ((s gldouble) (arg-t gldouble) (r gldouble) (q gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-dv "glTexCoord4dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-f "glTexCoord4f" :source) ((s glfloat) (arg-t glfloat) (r glfloat) (q glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-fv "glTexCoord4fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-i "glTexCoord4i" :source) ((s glint) (arg-t glint) (r glint) (q glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-iv "glTexCoord4iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-s "glTexCoord4s" :source) ((s glshort) (arg-t glshort) (r glshort) (q glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord4-sv "glTexCoord4sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-coord-pointer "glTexCoordPointer" :source) ((size glint) (type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-envf "glTexEnvf" :source) ((target glenum) (pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-envfv "glTexEnvfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-envi "glTexEnvi" :source) ((target glenum) (pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-enviv "glTexEnviv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-gend "glTexGend" :source) ((coord glenum) (pname glenum) (param gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-gendv "glTexGendv" :source) ((coord glenum) (pname glenum) (params (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-genf "glTexGenf" :source) ((coord glenum) (pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-genfv "glTexGenfv" :source) ((coord glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-geni "glTexGeni" :source) ((coord glenum) (pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-geniv "glTexGeniv" :source) ((coord glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-image1-d "glTexImage1D" :source) ((target glenum) (level glint) (internalformat glint) (width glsizei) (border glint) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-image2-d "glTexImage2D" :source) ((target glenum) (level glint) (internalformat glint) (width glsizei) (height glsizei) (border glint) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-image3-d "glTexImage3D" :source) ((target glenum) (level glint) (internalformat glint) (width glsizei) (height glsizei) (depth glsizei) (border glint) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-parameterf "glTexParameterf" :source) ((target glenum) (pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-parameterfv "glTexParameterfv" :source) ((target glenum) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-parameteri "glTexParameteri" :source) ((target glenum) (pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-parameteriv "glTexParameteriv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-sub-image1-d "glTexSubImage1D" :source) ((target glenum) (level glint) (xoffset glint) (width glsizei) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-sub-image2-d "glTexSubImage2D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (width glsizei) (height glsizei) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-tex-sub-image3-d "glTexSubImage3D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (zoffset glint) (width glsizei) (height glsizei) (depth glsizei) (format glenum) (type glenum) (pixels gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-translated "glTranslated" :source) ((x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-translatef "glTranslatef" :source) ((x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-d "glVertex2d" :source) ((x gldouble) (y gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-dv "glVertex2dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-f "glVertex2f" :source) ((x glfloat) (y glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-fv "glVertex2fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-i "glVertex2i" :source) ((x glint) (y glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-iv "glVertex2iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-s "glVertex2s" :source) ((x glshort) (y glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex2-sv "glVertex2sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-d "glVertex3d" :source) ((x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-dv "glVertex3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-f "glVertex3f" :source) ((x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-fv "glVertex3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-i "glVertex3i" :source) ((x glint) (y glint) (z glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-iv "glVertex3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-s "glVertex3s" :source) ((x glshort) (y glshort) (z glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex3-sv "glVertex3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-d "glVertex4d" :source) ((x gldouble) (y gldouble) (z gldouble) (w gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-dv "glVertex4dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-f "glVertex4f" :source) ((x glfloat) (y glfloat) (z glfloat) (w glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-fv "glVertex4fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-i "glVertex4i" :source) ((x glint) (y glint) (z glint) (w glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-iv "glVertex4iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-s "glVertex4s" :source) ((x glshort) (y glshort) (z glshort) (w glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex4-sv "glVertex4sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-pointer "glVertexPointer" :source) ((size glint) (type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-viewport "glViewport" :source) ((x glint) (y glint) (width glsizei) (height glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-sample-coverage "glSampleCoverage" :source) ((value glclampf) (invert glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-transpose-matrixf "glLoadTransposeMatrixf" :source) ((m (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-load-transpose-matrixd "glLoadTransposeMatrixd" :source) ((m (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-mult-transpose-matrixf "glMultTransposeMatrixf" :source) ((m (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-mult-transpose-matrixd "glMultTransposeMatrixd" :source) ((m (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-image3-d "glCompressedTexImage3D" :source) ((target glenum) (level glint) (internalformat glenum) (width glsizei) (height glsizei) (depth glsizei) (border glint) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-image2-d "glCompressedTexImage2D" :source) ((target glenum) (level glint) (internalformat glenum) (width glsizei) (height glsizei) (border glint) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-image1-d "glCompressedTexImage1D" :source) ((target glenum) (level glint) (internalformat glenum) (width glsizei) (border glint) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-sub-image3-d "glCompressedTexSubImage3D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (zoffset glint) (width glsizei) (height glsizei) (depth glsizei) (format glenum) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-sub-image2-d "glCompressedTexSubImage2D" :source) ((target glenum) (level glint) (xoffset glint) (yoffset glint) (width glsizei) (height glsizei) (format glenum) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compressed-tex-sub-image1-d "glCompressedTexSubImage1D" :source) ((target glenum) (level glint) (xoffset glint) (width glsizei) (format glenum) (image-size glsizei) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-compressed-tex-image "glGetCompressedTexImage" :source) ((target glenum) (lod glint) (img gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-active-texture "glActiveTexture" :source) ((texture glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-client-active-texture "glClientActiveTexture" :source) ((texture glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-d "glMultiTexCoord1d" :source) ((target glenum) (s gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-dv "glMultiTexCoord1dv" :source) ((target glenum) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-f "glMultiTexCoord1f" :source) ((target glenum) (s glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-fv "glMultiTexCoord1fv" :source) ((target glenum) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-i "glMultiTexCoord1i" :source) ((target glenum) (s glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-iv "glMultiTexCoord1iv" :source) ((target glenum) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-s "glMultiTexCoord1s" :source) ((target glenum) (s glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord1-sv "glMultiTexCoord1sv" :source) ((target glenum) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-d "glMultiTexCoord2d" :source) ((target glenum) (s gldouble) (arg-t gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-dv "glMultiTexCoord2dv" :source) ((target glenum) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-f "glMultiTexCoord2f" :source) ((target glenum) (s glfloat) (arg-t glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-fv "glMultiTexCoord2fv" :source) ((target glenum) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-i "glMultiTexCoord2i" :source) ((target glenum) (s glint) (arg-t glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-iv "glMultiTexCoord2iv" :source) ((target glenum) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-s "glMultiTexCoord2s" :source) ((target glenum) (s glshort) (arg-t glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord2-sv "glMultiTexCoord2sv" :source) ((target glenum) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-d "glMultiTexCoord3d" :source) ((target glenum) (s gldouble) (arg-t gldouble) (r gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-dv "glMultiTexCoord3dv" :source) ((target glenum) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-f "glMultiTexCoord3f" :source) ((target glenum) (s glfloat) (arg-t glfloat) (r glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-fv "glMultiTexCoord3fv" :source) ((target glenum) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-i "glMultiTexCoord3i" :source) ((target glenum) (s glint) (arg-t glint) (r glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-iv "glMultiTexCoord3iv" :source) ((target glenum) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-s "glMultiTexCoord3s" :source) ((target glenum) (s glshort) (arg-t glshort) (r glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord3-sv "glMultiTexCoord3sv" :source) ((target glenum) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-d "glMultiTexCoord4d" :source) ((target glenum) (s gldouble) (arg-t gldouble) (r gldouble) (q gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-dv "glMultiTexCoord4dv" :source) ((target glenum) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-f "glMultiTexCoord4f" :source) ((target glenum) (s glfloat) (arg-t glfloat) (r glfloat) (q glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-fv "glMultiTexCoord4fv" :source) ((target glenum) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-i "glMultiTexCoord4i" :source) ((target glenum) (s glint) (arg-t glint) (r glint) (q glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-iv "glMultiTexCoord4iv" :source) ((target glenum) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-s "glMultiTexCoord4s" :source) ((target glenum) (s glshort) (arg-t glshort) (r glshort) (q glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-tex-coord4-sv "glMultiTexCoord4sv" :source) ((target glenum) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fog-coordf "glFogCoordf" :source) ((coord glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fog-coordfv "glFogCoordfv" :source) ((coord (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fog-coordd "glFogCoordd" :source) ((coord gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fog-coorddv "glFogCoorddv" :source) ((coord (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-fog-coord-pointer "glFogCoordPointer" :source) ((type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-b "glSecondaryColor3b" :source) ((red glbyte) (green glbyte) (blue glbyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-bv "glSecondaryColor3bv" :source) ((v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-d "glSecondaryColor3d" :source) ((red gldouble) (green gldouble) (blue gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-dv "glSecondaryColor3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-f "glSecondaryColor3f" :source) ((red glfloat) (green glfloat) (blue glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-fv "glSecondaryColor3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-i "glSecondaryColor3i" :source) ((red glint) (green glint) (blue glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-iv "glSecondaryColor3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-s "glSecondaryColor3s" :source) ((red glshort) (green glshort) (blue glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-sv "glSecondaryColor3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-ub "glSecondaryColor3ub" :source) ((red glubyte) (green glubyte) (blue glubyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-ubv "glSecondaryColor3ubv" :source) ((v (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-ui "glSecondaryColor3ui" :source) ((red gluint) (green gluint) (blue gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-uiv "glSecondaryColor3uiv" :source) ((v (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-us "glSecondaryColor3us" :source) ((red glushort) (green glushort) (blue glushort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color3-usv "glSecondaryColor3usv" :source) ((v (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-secondary-color-pointer "glSecondaryColorPointer" :source) ((size glint) (type glenum) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-point-parameterf "glPointParameterf" :source) ((pname glenum) (param glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-point-parameterfv "glPointParameterfv" :source) ((pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-point-parameteri "glPointParameteri" :source) ((pname glenum) (param glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-point-parameteriv "glPointParameteriv" :source) ((pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-blend-func-separate "glBlendFuncSeparate" :source) ((src-rgb glenum) (dst-rgb glenum) (src-alpha glenum) (dst-alpha glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-draw-arrays "glMultiDrawArrays" :source) ((mode GLenum) (first (gl-vector :signed-32)) (count (gl-vector :signed-32)) ; glsizei (primcount glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-multi-draw-elements "glMultiDrawElements" :source) ((mode GLenum) (count (gl-vector :signed-32)) ; glsizei (type glenum) (indices gl-vector) (primcount glsizei)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-d "glWindowPos2d" :source) ((x gldouble) (y gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-dv "glWindowPos2dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-f "glWindowPos2f" :source) ((x glfloat) (y glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-fv "glWindowPos2fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-i "glWindowPos2i" :source) ((x glint) (y glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-iv "glWindowPos2iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-s "glWindowPos2s" :source) ((x glshort) (y glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos2-sv "glWindowPos2sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-d "glWindowPos3d" :source) ((x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-dv "glWindowPos3dv" :source) ((v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-f "glWindowPos3f" :source) ((x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-fv "glWindowPos3fv" :source) ((v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-i "glWindowPos3i" :source) ((x glint) (y glint) (z glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-iv "glWindowPos3iv" :source) ((v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-s "glWindowPos3s" :source) ((x glshort) (y glshort) (z glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-window-pos3-sv "glWindowPos3sv" :source) ((v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-gen-queries "glGenQueries" :source) ((n GLsizei) (ids (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-queries "glDeleteQueries" :source) ((n GLsizei) (ids (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-is-query "glIsQuery" :source) ((id gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-begin-query "glBeginQuery" :source) ((target glenum) (id gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-end-query "glEndQuery" :source) ((target glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-queryiv "glGetQueryiv" :source) ((target glenum) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-query-objectiv "glGetQueryObjectiv" :source) ((id gluint) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-query-objectuiv "glGetQueryObjectuiv" :source) ((id gluint) (pname glenum) (params (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-bind-buffer "glBindBuffer" :source) ((target glenum) (buffer gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-buffers "glDeleteBuffers" :source) ((n glsizei) (buffers (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-gen-buffers "glGenBuffers" :source) ((n glsizei) (buffers (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-is-buffer "glIsBuffer" :source) ((id gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-buffer-data "glBufferData" :source) ((target glenum) (size glsizeiptr) (data gl-vector) (usage glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-buffer-sub-data "glBufferSubData" :source) ((target glenum) (offset glintptr) (size glsizeiptr) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-buffer-sub-data "glGetBufferSubData" :source) ((target glenum) (offset glintptr) (size glsizeiptr) (data gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-map-buffer "glMapBuffer" :source) ((target glenum) (access glenum)) :result-type (:pointer glvoid) :language :ansi-c) (fli:define-foreign-function (gl-unmap-buffer "glUnmapBuffer" :source) ((target glenum)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-get-buffer-parameteriv "glGetBufferParameteriv" :source) ((target glenum) (pname GLenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-buffer-pointerv "glGetBufferPointerv" :source) ((target glenum) (pname GLenum) (:ignore #|params|# (:reference-return (:pointer glvoid)))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-draw-buffers "glDrawBuffers" :source) ((n glsizei) (bufs gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-d "glVertexAttrib1d" :source) ((index gluint) (x gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-dv "glVertexAttrib1dv" :source) ((index gluint) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-f "glVertexAttrib1f" :source) ((index gluint) (x glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-fv "glVertexAttrib1fv" :source) ((index gluint) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-s "glVertexAttrib1s" :source) ((index gluint) (x glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib1-sv "glVertexAttrib1sv" :source) ((index gluint) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-d "glVertexAttrib2d" :source) ((index gluint) (x gldouble) (y gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-dv "glVertexAttrib2dv" :source) ((index gluint) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-f "glVertexAttrib2f" :source) ((index gluint) (x glfloat) (y glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-fv "glVertexAttrib2fv" :source) ((index gluint) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-s "glVertexAttrib2s" :source) ((index gluint) (x glshort) (y glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib2-sv "glVertexAttrib2sv" :source) ((index gluint) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-d "glVertexAttrib3d" :source) ((index gluint) (x gldouble) (y gldouble) (z gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-dv "glVertexAttrib3dv" :source) ((index gluint) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-f "glVertexAttrib3f" :source) ((index gluint) (x glfloat) (y glfloat) (z glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-fv "glVertexAttrib3fv" :source) ((index gluint) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-s "glVertexAttrib3s" :source) ((index gluint) (x glshort) (y glshort) (z glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib3-sv "glVertexAttrib3sv" :source) ((index gluint) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nbv "glVertexAttrib4Nbv" :source) ((index gluint) (v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-niv "glVertexAttrib4Niv" :source) ((index gluint) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nsv "glVertexAttrib4Nsv" :source) ((index gluint) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nub "glVertexAttrib4Nub" :source) ((index gluint) (x glubyte) (y glubyte) (z glubyte) (w glubyte)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nubv "glVertexAttrib4Nubv" :source) ((index gluint) (v (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nuiv "glVertexAttrib4Nuiv" :source) ((index gluint) (v (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-nusv "glVertexAttrib4Nusv" :source) ((index gluint) (v (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-bv "glVertexAttrib4bv" :source) ((index gluint) (v (gl-vector :signed-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-d "glVertexAttrib4d" :source) ((index gluint) (x gldouble) (y gldouble) (z gldouble) (w gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-dv "glVertexAttrib4dv" :source) ((index gluint) (v (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-f "glVertexAttrib4f" :source) ((index gluint) (x glfloat) (y glfloat) (z glfloat) (w glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-fv "glVertexAttrib4fv" :source) ((index gluint) (v (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-iv "glVertexAttrib4iv" :source) ((index gluint) (v (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-s "glVertexAttrib4s" :source) ((index gluint) (x glshort) (y glshort) (z glshort) (w glshort)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-sv "glVertexAttrib4sv" :source) ((index gluint) (v (gl-vector :signed-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-ubv "glVertexAttrib4ubv" :source) ((index gluint) (v (gl-vector :unsigned-8))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-uiv "glVertexAttrib4uiv" :source) ((index gluint) (v (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib4-usv "glVertexAttrib4usv" :source) ((index gluint) (v (gl-vector :unsigned-16))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-vertex-attrib-pointer "glVertexAttribPointer" :source) ((index gluint) (size glint) (type glenum) (normalized glboolean) (stride glsizei) (pointer gl-vector)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-enable-vertex-attrib-array "glEnableVertexAttribArray" :source) ((index gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-disable-vertex-attrib-array "glDisableVertexAttribArray" :source) ((index gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-vertex-attribdv "glGetVertexAttribdv" :source) ((index gluint) (pname glenum) (params (gl-vector :double-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-vertex-attribfv "glGetVertexAttribfv" :source) ((index gluint) (pname glenum) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-vertex-attribiv "glGetVertexAttribiv" :source) ((index gluint) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-vertex-attrib-pointerv "glGetVertexAttribPointerv" :source) ((index gluint) (pname glenum) (:ignore #|pointer|# (:reference-return (:pointer glvoid)))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-shader "glDeleteShader" :source) ((shader gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-detach-shader "glDetachShader" :source) ((program gluint) (shader gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-create-shader "glCreateShader" :source) ((type glenum)) :result-type gluint :language :ansi-c) (fli:define-foreign-function (gl-shader-source "glShaderSource" :source) ((shader gluint) (count GLsizei) (string gl-vector) (length (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-compile-shader "glCompileShader" :source) ((shader gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-create-program "glCreateProgram" :source) () :result-type gluint :language :ansi-c) (fli:define-foreign-function (gl-attach-shader "glAttachShader" :source) ((program gluint) (shader gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-link-program "glLinkProgram" :source) ((program gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-use-program "glUseProgram" :source) ((program gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-delete-program "glDeleteProgram" :source) ((program gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-validate-program "glValidateProgram" :source) ((program gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform1-f "glUniform1f" :source) ((location glint) (v0 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform2-f "glUniform2f" :source) ((location glint) (v0 glfloat) (v1 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform3-f "glUniform3f" :source) ((location glint) (v0 glfloat) (v1 glfloat) (v2 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform4-f "glUniform4f" :source) ((location glint) (v0 glfloat) (v1 glfloat) (v2 glfloat) (v3 glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform1-i "glUniform1i" :source) ((location glint) (v0 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform2-i "glUniform2i" :source) ((location glint) (v0 glint) (v1 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform3-i "glUniform3i" :source) ((location glint) (v0 glint) (v1 glint) (v2 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform4-i "glUniform4i" :source) ((location glint) (v0 glint) (v1 glint) (v2 glint) (v3 glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform1-fv "glUniform1fv" :source) ((location glint) (count glsizei) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform2-fv "glUniform2fv" :source) ((location glint) (count glsizei) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform3-fv "glUniform3fv" :source) ((location glint) (count glsizei) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform4-fv "glUniform4fv" :source) ((location glint) (count glsizei) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform1-iv "glUniform1iv" :source) ((location glint) (count glsizei) (value (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform2-iv "glUniform2iv" :source) ((location glint) (count glsizei) (value (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform3-iv "glUniform3iv" :source) ((location glint) (count glsizei) (value (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform4-iv "glUniform4iv" :source) ((location glint) (count glsizei) (value (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix2-fv "glUniformMatrix2fv" :source) ((location glint) (count glsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix3-fv "glUniformMatrix3fv" :source) ((location glint) (count glsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix4-fv "glUniformMatrix4fv" :source) ((location glint) (count glsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-is-shader "glIsShader" :source) ((shader gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-is-program "glIsProgram" :source) ((program gluint)) :result-type glboolean :language :ansi-c) (fli:define-foreign-function (gl-get-shaderiv "glGetShaderiv" :source) ((shader gluint) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-programiv "glGetProgramiv" :source) ((program gluint) (pname glenum) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-attached-shaders "glGetAttachedShaders" :source) ((program gluint) (max-count glsizei) (:ignore (:reference-return glsizei)) ; count (shaders (gl-vector :unsigned-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-shader-info-log "glGetShaderInfoLog" :source) ((shader gluint) (buf-size glsizei) (:ignore (:reference-return glsizei)) ; length (info-log (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-program-info-log "glGetProgramInfoLog" :source) ((program gluint) (buf-size glsizei) (:ignore (:reference-return glsizei)) ; length (info-log (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-uniform-location "glGetUniformLocation" :source) ((program gluint) (name (:pointer glchar))) :result-type glint :language :ansi-c) (fli:define-foreign-function (gl-get-active-uniform "glGetActiveUniform" :source) ((program gluint) (index gluint) (buf-size glsizei) (:ignore (:reference-return glsizei)) ; length (:ignore (:reference-return glsizei)) ; size (:ignore (:reference-return glenum)) ; type (name (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-uniformfv "glGetUniformfv" :source) ((program gluint) (location glint) (params (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-uniformiv "glGetUniformiv" :source) ((program gluint) (location glint) (params (gl-vector :signed-32))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-shader-source "glGetShaderSource" :source) ((shader gluint) (buf-size glsizei) (:ignore (:reference-return glsizei)) ; length (source (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-bind-attrib-location "glBindAttribLocation" :source) ((program gluint) (index gluint) (name (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-active-attrib "glGetActiveAttrib" :source) ((program gluint) (index gluint) (buf-size glsizei) (:ignore (:reference-return glsizei)) ; length (:ignore (:reference-return glsizei)) ; size (:ignore (:reference-return glenum)) ; type (name (:pointer glchar))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-get-attrib-location "glGetAttribLocation" :source) ((program gluint) (name (:pointer glchar))) :result-type glint :language :ansi-c) (fli:define-foreign-function (gl-stencil-func-separate "glStencilFuncSeparate" :source) ((face glenum) (func glenum) (ref glint) (mask gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-stencil-op-separate "glStencilOpSeparate" :source) ((face glenum) (fail glenum) (zfail glenum) (zpass glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-stencil-mask-separate "glStencilMaskSeparate" :source) ((face glenum) (mask gluint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix2x3-fv "glUniformMatrix2x3fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix3x2-fv "glUniformMatrix3x2fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix2x4-fv "glUniformMatrix2x4fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix4x2-fv "glUniformMatrix4x2fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix3x4-fv "glUniformMatrix3x4fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-uniform-matrix4x3-fv "glUniformMatrix4x3fv" :source) ((location glint) (count GLsizei) (transpose glboolean) (value (gl-vector :single-float))) :result-type :void :language :ansi-c)
106,387
Common Lisp
.lisp
3,201
28.25617
149
0.673493
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
414c0eb8b4ba5685e99bed0450b8abd12e86c5677cf8a2b040a796e3bee97132
820
[ -1 ]
821
ufns.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/ufns.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/ufns.lisp,v 1.9.1.2 2014/06/05 12:08:37 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") #| DATE : 9Oct95 | USER : ken | PROCESSED FILE : /u/ken/OpenGL/opengl/glu.h |# (fli:define-foreign-function (glu-error-string "gluErrorString" :source) ((error-code glenum)) :result-type #+mswindows (w:LPSTR :pass-by :reference) #-mswindows (:reference :lisp-string-array) :language :ansi-c) ;;; glu-error-string - Win32 implmentation includes gluErrorUnicodeStringEXT which returns ;;; a UNICODE error string. Only access this when running on NT - use glu-error-string-win ;;; to dispatch to the correct OS function. #+mswindows (fli:define-foreign-function (glu-error-unicode-string "gluErrorUnicodeStringEXT" :source) ((error-code glenum)) :result-type (w:LPWSTR :pass-by :reference)) #+mswindows (defun glu-error-string-win (glenum) (if (string= (software-type) "Windows NT") (glu-error-unicode-string glenum) (glu-error-string glenum))) (fli:define-foreign-function (glu-get-string "gluGetString" :source) ((name glenum)) :result-type #+mswindows (w:LPSTR :pass-by :reference) #-mswindows (:reference :lisp-string-array) :language :ansi-c) (fli:define-foreign-function (glu-ortho2-d "gluOrtho2D" :source) ((left gldouble) (right gldouble) (bottom gldouble) (top gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (gl-ortho "glOrtho" :source) ((left gldouble) (right gldouble) (bottom gldouble) (top gldouble) (near gldouble) (far gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-perspective "gluPerspective" :source) ((fovy gldouble) (aspect gldouble) (z-near gldouble) (z-far gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-pick-matrix "gluPickMatrix" :source) ((x gldouble) (y gldouble) (width gldouble) (height gldouble) (viewport (gl-vector :signed-32 4))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-look-at "gluLookAt" :source) ((eyex gldouble) (eyey gldouble) (eyez gldouble) (centerx gldouble) (centery gldouble) (centerz gldouble) (upx gldouble) (upy gldouble) (upz gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-project "gluProject" :source) ((objx gldouble) (objy gldouble) (objz gldouble) (model-matrix (gl-vector :double-float 16)) (proj-matrix (gl-vector :double-float 16)) (viewport (gl-vector :signed-32 4)) (:ignore #|winx|# (:reference-return gldouble)) (:ignore #|winy|# (:reference-return gldouble)) (:ignore #|winz|# (:reference-return gldouble))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glu-un-project "gluUnProject" :source) ((winx gldouble) (winy gldouble) (winz gldouble) (model-matrix (gl-vector :double-float 16)) (proj-matrix (gl-vector :double-float 16)) (viewport (gl-vector :signed-32 4)) (:ignore #|objx|# (:reference-return gldouble)) (:ignore #|objt|# (:reference-return gldouble)) (:ignore #|objz|# (:reference-return gldouble))) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glu-scale-image "gluScaleImage" :source) ((format glenum) (widthin glint) (heightin glint) (typein glenum) (datain gl-vector) (widthout glint) (heightout glint) (typeout glenum) (dataout gl-vector)) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glu-build1-dmipmaps "gluBuild1DMipmaps" :source) ((target glenum) (components glint) (width glint) (format glenum) (type glenum) (data gl-vector)) :result-type (:signed :int) :language :ansi-c) (fli:define-foreign-function (glu-build2-dmipmaps "gluBuild2DMipmaps" :source) ((target glenum) (components glint) (width glint) (height glint) (format glenum) (type glenum) (data gl-vector)) :result-type (:signed :int) :language :ansi-c) (fli:define-c-struct (gluquadric (:foreign-name "GLUquadric") (:forward-reference-p t))) (fli:define-c-typedef (gluquadric-obj (:foreign-name "GLUquadricObj")) (:struct gluquadric)) (fli:define-foreign-function (glu-new-quadric "gluNewQuadric" :source) nil :result-type (:pointer gluquadric-obj) :language :ansi-c) (fli:define-foreign-function (glu-delete-quadric "gluDeleteQuadric" :source) ((state (:pointer gluquadric-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-quadric-normals "gluQuadricNormals" :source) ((quad-object (:pointer gluquadric-obj)) (normals glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-quadric-texture "gluQuadricTexture" :source) ((quad-object (:pointer gluquadric-obj)) (texture-coords glboolean)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-quadric-orientation "gluQuadricOrientation" :source) ((quad-object (:pointer gluquadric-obj)) (orientation glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-quadric-draw-style "gluQuadricDrawStyle" :source) ((quad-object (:pointer gluquadric-obj)) (draw-style glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-cylinder "gluCylinder" :source) ((qobj (:pointer gluquadric-obj)) (base-radius gldouble) (top-radius gldouble) (height gldouble) (slices glint) (stacks glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-disk "gluDisk" :source) ((qobj (:pointer gluquadric-obj)) (inner-radius gldouble) (outer-radius gldouble) (slices glint) (loops glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-partial-disk "gluPartialDisk" :source) ((qobj (:pointer gluquadric-obj)) (inner-radius gldouble) (outer-radius gldouble) (slices glint) (loops glint) (start-angle gldouble) (sweep-angle gldouble)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-sphere "gluSphere" :source) ((qobj (:pointer gluquadric-obj)) (radius gldouble) (slices glint) (stacks glint)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-quadric-callback "gluQuadricCallback" :source) ((qobj (:pointer gluquadric-obj)) (which glenum) (fn (:pointer (:function nil :void)))) :result-type :void :language :ansi-c) (fli:define-c-struct (GLUtesselator (:foreign-name "GLUtesselator") (:forward-reference-p t))) (fli:define-c-typedef (glutriangulator-obj (:foreign-name "GLUtriangulatorObj")) (:struct GLUtesselator)) (fli:define-foreign-function (glu-new-tess "gluNewTess" :source) nil :result-type (:pointer glutriangulator-obj) :language :ansi-c) (fli:define-foreign-function (glu-tess-callback "gluTessCallback" :source) ((tobj (:pointer glutriangulator-obj)) (which glenum) (fn (:pointer (:function nil :void)))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-delete-tess "gluDeleteTess" :source) ((tobj (:pointer glutriangulator-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-begin-polygon "gluBeginPolygon" :source) ((tobj (:pointer glutriangulator-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-end-polygon "gluEndPolygon" :source) ((tobj (:pointer glutriangulator-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-next-contour "gluNextContour" :source) ((tobj (:pointer glutriangulator-obj)) (type glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-tess-vertex "gluTessVertex" :source) ((tobj (:pointer glutriangulator-obj)) (v (:c-array gldouble 3)) (data (:pointer :void))) :result-type :void :language :ansi-c) (fli:define-c-struct (glunurbs (:foreign-name "GLUnurbs") (:forward-reference-p t))) (fli:define-c-typedef (glunurbs-obj (:foreign-name "GLUnurbsObj")) (:struct glunurbs)) (fli:define-foreign-function (glu-new-nurbs-renderer "gluNewNurbsRenderer" :source) nil :result-type (:pointer glunurbs-obj) :language :ansi-c) (fli:define-foreign-function (glu-delete-nurbs-renderer "gluDeleteNurbsRenderer" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-begin-surface "gluBeginSurface" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-begin-curve "gluBeginCurve" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-end-curve "gluEndCurve" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-end-surface "gluEndSurface" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-begin-trim "gluBeginTrim" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-end-trim "gluEndTrim" :source) ((nobj (:pointer glunurbs-obj))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-pwl-curve "gluPwlCurve" :source) ((nobj (:pointer glunurbs-obj)) (count glint) (array (gl-vector :single-float)) (stride glint) (type glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-nurbs-curve "gluNurbsCurve" :source) ((nobj (:pointer glunurbs-obj)) (nknots glint) (knot (gl-vector :single-float)) (stride glint) (ctlarray (gl-vector :single-float)) (order glint) (type glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-nurbs-surface "gluNurbsSurface" :source) ((nobj (:pointer glunurbs-obj)) (sknot-count glint) (sknot (gl-vector :single-float)) (tknot-count glint) (tknot (gl-vector :single-float)) (s-stride glint) (t-stride glint) (ctlarray (gl-vector :single-float)) (sorder glint) (torder glint) (type glenum)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-load-sampling-matrices "gluLoadSamplingMatrices" :source) ((nobj (:pointer glunurbs-obj)) (model-matrix (gl-vector :single-float 16)) (proj-matrix (gl-vector :single-float 16)) (viewport (gl-vector :signed-32 4))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-nurbs-property "gluNurbsProperty" :source) ((nobj (:pointer glunurbs-obj)) (property glenum) (value glfloat)) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-get-nurbs-property "gluGetNurbsProperty" :source) ((nobj (:pointer glunurbs-obj)) (property glenum) (value (:pointer glfloat))) :result-type :void :language :ansi-c) (fli:define-foreign-function (glu-nurbs-callback "gluNurbsCallback" :source) ((nobj (:pointer glunurbs-obj)) (which glenum) (fn (:pointer (:function nil :void)))) :result-type :void :language :ansi-c)
12,156
Common Lisp
.lisp
342
30.032164
149
0.668085
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
c0b1cef300f4b18c91c24ba2762ac230770c3a24422901da0347e4728ba7e773
821
[ -1 ]
822
capi.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/capi.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/61/LISPopengl/RCS/capi.lisp,v 1.29.1.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "OPENGL") (defparameter *open-gl-debug* nil) (defun debug-print (format-string &rest args) (when *open-gl-debug* (format *terminal-io* "~?" format-string args))) (defvar *default-opengl-pane-configuration* (list :rgba t)) (defclass opengl-pane (capi:output-pane) ((configuration :initform *default-opengl-pane-configuration* :initarg :configuration :reader configuration) (context :initform nil :initarg :context :accessor context) (render-state :initform nil :accessor opengl-pane-render-state))) (defun ensure-context (opengl-pane) (or (context opengl-pane) (setf (context opengl-pane) (%make-context (capi-internals:representation opengl-pane) (configuration opengl-pane))))) (defmethod swap-buffers ((opengl-pane opengl-pane)) (%swap-buffers (capi-internals:representation opengl-pane) (context opengl-pane))) (defmethod describe-configuration ((opengl-pane opengl-pane) &optional (stream *standard-output*) collectp) (%describe-configuration (capi-internals:representation opengl-pane) (context opengl-pane) stream collectp)) ;;; ------------------------------------------------------------ ;;; Locking ;;; Only one GL context can be current at any time, so we need a ;;; locking mechanism to stop threads interfering with each other. (defvar *current-opengl-window* nil) (defvar *opengl-window-lock* (mp:make-lock :name "OpenGL")) (defun current-process-has-openGL-lock-p () (mp:lock-owned-by-current-process-p *opengl-window-lock*)) (defun process-has-openGL-lock-p (&optional (process nil p-p)) (if p-p (eq process (process-with-openGL-lock)) (current-process-has-openGL-lock-p))) (defun process-with-openGL-lock () (mp:lock-owner *opengl-window-lock*)) (defvar *rendering-on-debug-level* 0) (defmethod start-rendering ((opengl-pane opengl-pane)) "Cause future OpenGL rendering calls to go to this window. This function takes care of MP locking." (when-let (rep (capi-internals:representation opengl-pane)) (unless (eq (opengl-pane-render-state opengl-pane) :error) (when-let (context (ensure-context opengl-pane)) ;; If the process already has the lock, it may be a recursive call or a reentrant call. ;; Recursive calls are okay. Reentrant call arise only when the previous call failed to ;; set the *current-opengl-window* which means an error occurred, so just return. (if (current-process-has-openGL-lock-p) (cond ((null *current-opengl-window*) (debug-print "OpenGL error: Reentrant call to start-rendering in process: ~s" rep) (return-from start-rendering (values nil))) ((not (eq *current-opengl-window* rep)) (debug-print "OpenGL error: Nested call to start-rendering on different window: current : ~s, requested ~s" *current-opengl-window* rep) (return-from start-rendering (values nil))) ((/= *rendering-on-debug-level* (dbg:get-debug-level)) ;;; entered the debugger while rendering, do't try to ;;; render. nil) (t t)) (let ((res nil) error (%start-rendering-returned nil)) (mp:process-lock *opengl-window-lock*) (unwind-protect-blocking-interrupts-in-cleanups (progn (multiple-value-setq (res error) (%start-rendering rep context)) (setq %start-rendering-returned t) (when res (setf (opengl-pane-render-state opengl-pane) t) (setq res :lock *current-opengl-window* rep))) (unless res (%stop-rendering rep) (when error (setf (opengl-pane-render-state opengl-pane) :error)) (unless %start-rendering-returned (setf (context opengl-pane) nil)) (mp:process-unlock *opengl-window-lock*))) (unless res (if error (error "Error when trying to render OPENGL: ~s" error) (debug-print "openGL error: Failed to set current OpenGL context for ~s" rep))) res)))))) (defmethod stop-rendering ((opengl-pane opengl-pane)) (%stop-rendering (capi-internals:representation opengl-pane)) (setf *current-opengl-window* nil) (mp:process-unlock *opengl-window-lock*)) ;;; The hook takes one argument, the condition. (defmethod %get-debug-entry-hook ((x t)) 'identity) (defun get-debug-entry-hook (pane) (%get-debug-entry-hook (capi-internals:representation pane))) (eval-when (:compile-toplevel :load-toplevel :execute) (defmacro rendering-on ((opengl-pane) &body body) (let ((lock (gensym))) (rebinding (opengl-pane) `(let (,lock) (unwind-protect-blocking-interrupts-in-cleanups (progn (setf ,lock (start-rendering ,opengl-pane)) (when ,lock ; lock is :lock or T. T when nested rendering on same window (let ((*rendering-on-debug-level* (dbg:get-debug-level))) (dbg:with-added-debugger-entry-hook (get-debug-entry-hook ,opengl-pane) ,@body)))) (when (eq ,lock :lock) ; when start-rendering returned the lock, unlock. (stop-rendering ,opengl-pane)))))))) (defun release-opengl-pane-context (opengl-pane) (when-let (rep (capi-internals:representation opengl-pane)) (%free-opengl-resources rep (shiftf (context opengl-pane) nil)))) ;; This is a primary method to come after the output-pane-destroy-callback. (defmethod capi-internals:representation-destroy ((opengl-pane opengl-pane)) (release-opengl-pane-context opengl-pane) (setf (opengl-pane-render-state opengl-pane) nil) (call-next-method)) (defmethod capi::output-pane-resize :before ((opengl-pane opengl-pane) x y width height) (%resize-opengl-context (capi-internals:representation opengl-pane) (context opengl-pane) width height)) (defmacro with-matrix-pushed (&body body) `(unwind-protect (progn (gl-push-matrix) ,@body) (gl-pop-matrix))) #|| Example of basic interface: (capi:define-interface opengl-interface () () (:panes (opengl opengl-pane :configuration (list :rgba t))) (:layouts (main capi:column-layout '(opengl) :default t))) ||#
7,084
Common Lisp
.lisp
140
40.071429
150
0.611973
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
19cee7542dae02fb3a63fece96721617ad8e1ebaf6c373d71a6e0ff9542fac20
822
[ -1 ]
823
icosahedron.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/icosahedron.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/icosahedron.lisp,v 1.20.3.3 2014/11/19 16:14:40 martin Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") ;;; This file contains a demonstration of the LispWorks FLI for ;;; OpenGL. To see the demonstration, compile and load the system ;;; OPENGL-EXAMPLES by ;;; ;;; (load "<opengl-directory>/host") ;;; (load "OPENGL:EXAMPLES;load") ;;; ;;; then evaluate ;;; ;;; (setf v (capi:display (make-instance 'icosahedron-viewer))) ;;; ;;; An icosahedron is drawn with faces colored randomly and ;;; illuminated by a single light source. The faces can be subdivided ;;; to approximate a sphere. The following keys and mouse gestures ;;; control it: ;;; ;;; < and > decrease and increase the number of triangles. ;;; ;;; Left mouse button rotates the sphere. ;;; ;;; Middle mouse button rotates the light position. ;;; ;;; Home resets the rotation state. ;;; ;;; o toggles smooth shading. ;;; ;;; p and P increase and decrease material shininess. ;;; ;;; s and S increase and decrease material specular reflection component. ;;; ;;; e and E increase and decrease material emission component. ;;; ;;; a and A increase and decrease light source ambient component. ;;; ;;; t toggles a texture map applied to the icosahedron ;;; ;;; Insert resets the light and material parameters. ;;; ;;; Escape quits the interface. ;;; ;;; ;;; The material ambient and diffuse components are not controllable. ;;; Note that light source ambient, material emission and material ;;; specular reflection can all have negative values, resulting in ;;; some strange effects, such as negative light specular reflections. ;;; ;;; ------------------------------------------------------------ ;;; Programmming notes: ;;; ;;; - Vectors and arrays are converted to gl-vectors which is a ;;; platform independent mechanism for passing through arrays. ;;; gl-vectors behave in much the same way as normal vectors ;;; except that: ;;; 1. They are allocated statically - the memory location of vector ;;; contents will not be moved by the Lisp garbage collector. ;;; (Note that the garbage collector will still reclaim the data if ;;; no longer referenced by Lisp.) ;;; 2. gl-vectors are not guaranteed to survive image-saving. The ;;; implementation of gl-vectors can be found in "OPENGL:vectors.lisp" ;;; ;;; - The drawing of a heavily subdivided icosahedron is quite slow. ;;; That code is not optimized. However, a display list is used, ;;; which means that its redisplay is very fast. ;;; ;;; - The OpenGL window is by default double-buffered, so you do not ;;; see the drawing in progress. If you want to see the drawing ;;; process, use the call ;;; ;;; (setf v (capi:display (make-instance 'icosahedron-viewer ;;; :double-buffered-p nil))) ;;; ;;; - This demo works on 8-bit screens only when double-buffering is ;;; turned off. ;;; ------------------------------------------------------------ ;;; Types and creators. (deftype gl-double () 'double-float) (deftype gl-double-vector (n) `(opengl:gl-vector :double ,n)) (deftype gl-single () 'single-float) (deftype gl-single-vector (n) `(opengl:gl-vector :float ,n)) (defun gl-float-vector (type contents) (opengl:make-gl-vector type (length contents) :contents contents)) (defun gl-double-vector (&rest contents) (gl-float-vector :double contents)) (defun gl-single-vector (&rest contents) (gl-float-vector :float contents)) (defun make-gl-double-vector (size) (opengl:make-gl-vector :double size)) (defun make-gl-single-vector (size) (opengl:make-gl-vector :float size)) ;;; ------------------------------ ;;; Vertex can be pass through to 'C' ;;; vertexes list of gl-vertexes (not passed to 'C' ;;; ------------------------------ (declaim (inline gl-vertex gl-vertexes)) (defun gl-vertex (x y z w) (gl-double-vector x y z w)) (defun gl-vertexes (contents) (mapcar #'(lambda (c) (apply 'gl-double-vector c)) contents)) ;;; ------------------------------ ;;; XYZ coordinate ;;; ------------------------------ (defstruct xyz (x 0.0d0 :type double-float) (y 0.0d0 :type double-float) (z 0.0d0 :type double-float)) ;;; ------------------------------------------------------------ ;;; Class object ;;; ;;; This superclass just manages display lists for the subclasses. (defclass object () ((use-display-list :initform nil :initarg :use-display-list :accessor use-display-list) (display-list :initform nil :initarg :display-list :accessor display-list) (extra-display-lists :initform nil :accessor extra-display-lists) (viewer :accessor viewer))) (defmethod draw :around ((object object)) (if (use-display-list object) (if (display-list object) (progn (opengl:gl-call-list (display-list object)) (let ((draw (sys:cdr-assoc :draw (extra-display-lists object)))) (mapc 'opengl:gl-call-list draw))) (progn (set-up-gl-fonts (canvas (viewer object)) object) (let ((n (opengl:gl-gen-lists 1))) (if (plusp n) (progn (opengl:gl-new-list n opengl:*gl-compile-and-execute*) (call-next-method) (opengl:gl-end-list) (setf (display-list object) n)) (progn (format t "~%~s:No more display list indexes!" object) (call-next-method)))))) (call-next-method))) (defmethod (setf use-display-list) :after (value (object object)) (unless value (opengl:rendering-on ((canvas (viewer object))) (delete-display-list object)))) (defmethod delete-display-list ((object object)) (when (display-list object) (opengl:gl-delete-lists (display-list object) 1) (setf (display-list object) nil)) (loop for (nil start length) in (extra-display-lists object) do (opengl:gl-delete-lists start length)) (setf (extra-display-lists object) nil)) ;;; ------------------------------------------------------------ ;;; Class projection ;;; ;;; A class which defines the fovy, aspect, near and far ;;; values for a call to glu-perspective to define the projection ;;; matrix. (defparameter *fovy* 45.0d0) (defparameter *aspect* 1.0d0) (defparameter *near* 1.0d0) (defparameter *far* 100.0d0) (defclass projection (object) ((fovy :initform *fovy* :initarg :fovy :accessor fovy) (aspect :initform *aspect* :initarg :aspect :accessor aspect) (near :initform *near* :initarg :near :accessor near) (far :initform *far* :initarg :far :accessor far))) (defmethod draw ((projection projection)) (opengl:glu-perspective (fovy projection) (aspect projection) (near projection) (far projection))) (defun make-projection (&key fovy aspect near far) (make-instance 'projection :fovy (or fovy *fovy*) :aspect (or aspect *aspect*) :near (or near *near*) :far (or far *far*))) ;;; ------------------------------------------------------------ ;;; Class camera ;;; ;;; Defines an eye point, a center point and an up vector. ;;; The draw method calls GLU-LOOK-AT to install the camera values. (defparameter *eye* (make-xyz :y 5.0d0)) (defparameter *center* (make-xyz)) (defparameter *up* (make-xyz :z 1.0d0)) (defclass camera (object) ((eye :initform (copy-structure *eye*) :initarg :eye :accessor eye :type xyz) (center :initform (copy-structure *center*) :initarg :center :accessor center :type xyz) (up :initform (copy-structure *up*) :initarg :up :accessor up :type xyz) (projection :initform (make-projection) :initarg :projection :accessor projection))) (defmethod draw ((camera camera)) (let ((eye (eye camera)) (center (center camera)) (up (up camera)) (projection (projection camera))) (declare (type xyz up eye center)) (opengl:gl-matrix-mode opengl:*gl-projection*) (opengl:gl-load-identity) (draw projection) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:gl-load-identity) (opengl:glu-look-at (xyz-x eye) (xyz-y eye) (xyz-z eye) (xyz-x center) (xyz-y center) (xyz-z center) (xyz-x up) (xyz-y up) (xyz-z up)) (opengl:gl-enable opengl:*gl-lighting*) (opengl:gl-clear-color 0.0 0.0 0.3 1.0) (opengl:gl-clear opengl:*gl-color-buffer-bit*) (opengl:gl-clear opengl:*gl-depth-buffer-bit*) (opengl:gl-depth-func opengl:*gl-less*) (opengl:gl-enable opengl:*gl-depth-test*))) (defun make-camera (&key eye center up projection) (make-instance 'camera :eye (copy-structure (or eye *eye*)) :center (copy-structure (or center *center*)) :up (copy-structure (or up *up*)) :projection (or projection (make-projection)))) ;;; ------------------------------------------------------------ ;;; Geometric objects (defvar *texture-color* nil) ;;; Setup code (defun get-texture-color () (unless *texture-color* (setf *texture-color* (gl-single-vector 1.0 1.0 1.0 1.0))) *texture-color*) ;;; Cleanup code (defun cleanup-texture-color () (setf *texture-color* nil)) (defun make-object-colors (npolys &optional style) (case style (:uniform (make-array npolys :initial-element (gl-single-vector (float (random 1.0) 1.0) (float (random 1.0) 1.0) (float (random 1.0) 1.0) 1.0))) (otherwise (coerce (loop for i below npolys collect (gl-single-vector (float (random 1.0) 1.0) (float (random 1.0) 1.0) (float (random 1.0) 1.0) 1.0)) 'vector)))) (defun make-object-vertexes (vertex-list) (coerce (gl-vertexes vertex-list) 'simple-vector)) (defun make-object-indexes (index-list) (let* ((biggest (loop for i in index-list maximize (length i))) (indexes (make-array (list (length index-list) biggest) :element-type 'fixnum :initial-element -1))) (loop for id in index-list for i from 0 do (loop for jd in id for j from 0 do (setf (aref indexes i j) jd))) indexes)) (defclass geom-object (object) ((colors :initform nil :initarg :colors :accessor colors :initarg :color) (vertexes :initform nil :initarg :vertexes :accessor vertexes) (indexes :initform nil :initarg :indexes :accessor indexes) (smoothp :initform nil :initarg :smoothp :initarg smooth :accessor smoothp) (texturep :initform nil :initarg :texturep :accessor texturep) (subdivision :initform 0 :initarg :subdivision :accessor subdivision) (name :initform nil :initarg :name :accessor name)) (:default-initargs :use-display-list T)) (defmethod initialize-instance :after ((geom-object geom-object) &key colors indexes vertexes &allow-other-keys) (setf (colors geom-object) (make-object-colors (length indexes) colors)) (setf (vertexes geom-object) (make-object-vertexes vertexes)) (setf (indexes geom-object) (make-object-indexes indexes))) (defmethod draw ((obj geom-object)) (let* ((indexes (indexes obj)) (vertexes (vertexes obj)) (colors (colors obj)) (n (array-dimension indexes 1)) (m (array-dimension indexes 0)) (smoothp (smoothp obj)) (texturep (texturep obj))) (labels ((texgen (param x y z w) (opengl:with-gl-vectors ((v :type :float :length 4)) (setf (opengl:gl-vector-aref v 0) x (opengl:gl-vector-aref v 1) y (opengl:gl-vector-aref v 2) z (opengl:gl-vector-aref v 3) w) (opengl:gl-tex-geni param opengl:*gl-texture-gen-mode* opengl:*gl-object-linear*) (opengl:gl-tex-genfv param opengl:*gl-object-plane* v)))) (when texturep (opengl:gl-enable opengl:*gl-texture-gen-s*) (opengl:gl-enable opengl:*gl-texture-gen-t*) (texgen opengl:*gl-s* 1.0 0.0 0.0 1.0) (texgen opengl:*gl-t* 0.0 1.0 0.0 1.0) (opengl:gl-color4-fv (get-texture-color))) (if smoothp (progn (opengl:gl-shade-model opengl:*gl-smooth*) (loop for ii below m do (unless texturep (opengl:gl-color4-fv (aref colors ii))) (opengl:gl-begin opengl:*gl-polygon*) (loop for i below n as index = (aref indexes ii i) unless (minusp index) do (let ((v (aref vertexes index))) (opengl:gl-normal3-dv v) (opengl:gl-vertex4-dv v))) (opengl:gl-end))) (opengl:with-gl-vectors ((n1 :type :double :length 3) (n2 :type :double :length 3) (n3 :type :double :length 3)) (opengl:gl-shade-model opengl:*gl-flat*) (loop for ii below m do (let ((v1 (aref vertexes (aref indexes ii 0))) (v2 (aref vertexes (aref indexes ii 1))) (v3 (aref vertexes (aref indexes ii 2)))) (unless texturep (opengl:gl-color4-fv (aref colors ii))) (opengl:gl-begin opengl:*gl-polygon*) (vector-difference v1 v2 n1) (vector-difference v2 v3 n2) (normalized-cross-product n1 n2 n3) (opengl:gl-normal3-dv n3) (loop for i below n as index = (aref indexes ii i) unless (minusp index) do (opengl:gl-vertex4-dv (aref vertexes index))) (opengl:gl-end))))) (when texturep (opengl:gl-disable opengl:*gl-texture-gen-s*) (opengl:gl-disable opengl:*gl-texture-gen-t*))))) (defmethod (setf smoothp) :before (value (obj geom-object)) (delete-display-list obj)) (defmethod (setf subdivision) :before (value (obj geom-object)) (delete-display-list obj)) (defmethod (setf texturep) :before (value (obj geom-object)) (delete-display-list obj)) ;;; ------------------------------------------------------------ ;;; Icosahedron (defvar *icosahedron-vertexes* (let ((x 0.525731112119133606d0) (z 0.850650808352039932d0)) (list (list (- x) 0.0d0 z 1.0d0) (list x 0.0d0 z 1.0d0) (list (- x) 0.0d0 (- z) 1.0d0) (list x 0.0d0 (- z) 1.0d0) (list 0.0d0 z x 1.0d0) (list 0.0d0 z (- x) 1.0d0) (list 0.0d0 (- z) x 1.0d0) (list 0.0d0 (- z) (- x) 1.0d0) (list z x 0.0d0 1.0d0) (list (- z) x 0.0d0 1.0d0) (list z (- x) 0.0d0 1.0d0) (list (- z) (- x) 0.0d0 1.0d0)))) (defconstant *icosahedron-cw-indexes* '((0 4 1) (0 9 4) (9 5 4) (4 5 8) (4 8 1) (8 10 1) (8 3 10) (5 3 8) (5 2 3) (2 7 3) (7 10 3) (7 6 10) (7 11 6) (11 0 6) (0 1 6) (6 1 10) (9 0 11) (9 11 2) (9 2 5) (7 2 11))) (defconstant *icosahedron-indexes* '((1 4 0) (4 9 0) (4 5 9) (8 5 4) (1 8 4) (1 10 8) (10 3 8) (8 3 5) (3 2 5) (3 7 2) (3 10 7) (10 6 7) (6 11 7) (6 0 11) (6 1 0) (10 1 6) (11 0 9) (2 11 9) (5 2 9) (11 2 7))) (defun make-icosahedron-vertexes () (make-object-vertexes *icosahedron-vertexes*)) (defun make-icosahedron-indexes () (make-object-indexes *icosahedron-indexes*)) (defclass icosahedron (geom-object) () (:default-initargs :vertexes *icosahedron-vertexes* :indexes *icosahedron-indexes* :name "Icosahedron" )) (defun spherical-texture-coords (v va vb) (let ((x (opengl:gl-vector-aref v 0)) (y (opengl:gl-vector-aref v 1)) (z (opengl:gl-vector-aref v 2))) (if (and (zerop x) (zerop y)) ;; vertex is at pole, so choose s coord based on other two vertexes. (let* ((ts1 (spherical-texture-coords va v vb)) (ts2 (spherical-texture-coords vb v va)) (tss (cond ((zerop ts1) (if (>= ts2 0.5) (* 0.5 (+ 1.0 ts2)) (* 0.5 ts2))) ((= 1.0 ts1) (if (< ts2 0.5) (* 0.5 ts2) (* 0.5 (+ 1.0 ts2)))) ((zerop ts2) (if (>= ts1 0.5) (* 0.5 (+ 1.0 ts1)) (* 0.5 ts1))) ((= 1.0 ts2) (if (< ts1 0.5) (* 0.5 ts1) (* 0.5 (+ 1.0 ts1)))) (t (* 0.5 (+ ts1 ts2)))))) (if (plusp z) (values tss 1.0) (values tss 0.0))) (let* ((theta (atan y x)) (d (sqrt (+ (* x x) (* y y)))) (phi (atan z d)) (ts (float (/ (+ theta pi) (* 2.0 pi)) 1.0)) (tt (float (/ (+ phi (* pi 0.5)) pi) 1.0))) (values ts tt))))) (defun tri-texture-coords (v1 v2 v3) ;; Compute the texture coordinates for each of 3 vertexes of a triangle. ;; Each value in each pair is in the inclusive range 0 -> 1. ;; The S coordinate values wrap around the object, so the choice of ;; 0 or 1 for each vertex in the boundary needs to be made according ;; to the S coordinate values of the other vertexes. (multiple-value-bind (ts1 tt1) (spherical-texture-coords v1 v2 v3) (multiple-value-bind (ts2 tt2) (spherical-texture-coords v2 v1 v3) (multiple-value-bind (ts3 tt3) (spherical-texture-coords v3 v1 v2) (if (or (>= (abs (- ts1 ts2)) 0.5) (>= (abs (- ts1 ts3)) 0.5)) (let ((ss (list ts1 ts2 ts3))) (declare (dynamic-extent ss)) (labels ((unitp (x) (or (zerop x) (= 1.0 x))) (find-base (s) (let ((y (find-if-not #'unitp s))) (cond ((< y 0.5) 0.0) ((> y 0.5) 1.0) ((= y 0.5) (let ((y (find-if #'(lambda (x) (and (not (unitp x)) (/= 0.5 x))) s))) (if (or (null y) (< y 0.5)) 0.0 1.0))))))) (let ((u (find-base ss))) (mapl #'(lambda (x) (when (unitp (car x)) (setf (car x) u))) ss) (values (first ss) tt1 (second ss) tt2 (third ss) tt3)))) (values ts1 tt1 ts2 tt2 ts3 tt3)))))) (defmethod draw ((icosahedron icosahedron)) (let* ((colors (colors icosahedron)) (vertexes (vertexes icosahedron)) (indexes (indexes icosahedron)) (n1 (make-gl-double-vector 3)) (n2 (make-gl-double-vector 3)) (n3 (make-gl-double-vector 3)) (texturep (texturep icosahedron))) (when texturep (setf colors nil) (opengl:gl-color4-fv (get-texture-color))) (labels ((tri-simple (v1 v2 v3 normalp) ;; Draw a basic textured triangle (multiple-value-bind (ts1 tt1 ts2 tt2 ts3 tt3) (tri-texture-coords v1 v2 v3) (labels ((v-simple (ts tt v) (opengl:gl-tex-coord2-f (float ts 1.0) (float tt 1.0)) (when normalp (opengl:gl-normal3-dv v)) (opengl:gl-vertex4-dv v))) (opengl:gl-begin opengl:*gl-polygon*) (v-simple ts1 tt1 v1) (v-simple ts2 tt2 v2) (v-simple ts3 tt3 v3) (opengl:gl-end)))) ;; Test if 3 vertexes cross the XZ plane and if they do draw two textured ;; triangles which don't. (tri-XZ-cross (v1 v2 v3 normalp) (labels ((XZ-cross (v1 v2) (flet ((lindiv (a b i) (* 0.5d0 (+ (opengl:gl-vector-aref a i) (opengl:gl-vector-aref b i))))) (let* ((s1 (signum (opengl:gl-vector-aref v1 1))) (s2 (signum (opengl:gl-vector-aref v2 1)))) (when (minusp (* s1 s2)) ; return the new interpolated vertex (gl-vertex (lindiv v1 v2 0) (lindiv v1 v2 1) (lindiv v1 v2 2) 1.0d0))))) (triv (va vb vc) (let ((vv (XZ-cross va vb))) (when vv (tri-simple va vv vc normalp) (tri-simple vb vc vv normalp) T)))) (or (triv v1 v2 v3) (triv v2 v3 v1) (triv v3 v1 v2)))) ;; Draw a textured triangle, breaking it into two triangles when it intersects the XZ plane ;; in order to get the texture coords right. (texture-tri (v1 v2 v3 normalp) (or (tri-XZ-cross v1 v2 v3 normalp) (tri-simple v1 v2 v3 normalp))) ;; Draw a single triangle, maybe with texture, include per-vertex normals if normalp (vertex3 (v1 v2 v3 normalp) (if texturep (texture-tri v1 v2 v3 normalp) (progn (opengl:gl-begin opengl:*gl-polygon*) (when normalp (opengl:gl-normal3-dv v1)) (opengl:gl-vertex4-dv v1) (when normalp (opengl:gl-normal3-dv v2)) (opengl:gl-vertex4-dv v2) (when normalp (opengl:gl-normal3-dv v3)) (opengl:gl-vertex4-dv v3) (opengl:gl-end)))) ;; Draw a single triangle, either with each vertex having its own normal (smoothp) ;; or with a single shared normal. (draw-tri (v1 v2 v3 color smoothp) (if smoothp (progn (when color (opengl:gl-color4-fv color)) (vertex3 v1 v2 v3 T)) (progn (vector-difference v1 v2 n1) (vector-difference v2 v3 n2) (normalized-cross-product n1 n2 n3) (when color (opengl:gl-color4-fv color)) (opengl:gl-normal3-dv n3) (vertex3 v1 v2 v3 nil))))) (if (smoothp icosahedron) (opengl:gl-shade-model opengl:*gl-smooth*) (opengl:gl-shade-model opengl:*gl-flat*)) ;; The following draws an icosahedron, each triangle of which may be subdivided n times. (if (subdivision icosahedron) (labels ((subdivide (a b c depth i) (if (zerop depth) (draw-tri a b c (when colors (aref colors i)) (smoothp icosahedron)) (opengl:with-gl-vectors ((ab :type :double :length 4 :contents '(0.0d0 0.0d0 0.0d0 1.0d0)) (bc :type :double :length 4 :contents '(0.0d0 0.0d0 0.0d0 1.0d0)) (ca :type :double :length 4 :contents '(0.0d0 0.0d0 0.0d0 1.0d0))) (let ((d (1- depth))) (vector-sum a b ab) (normalize ab) (vector-sum b c bc) (normalize bc) (vector-sum c a ca) (normalize ca) (subdivide a ab ca d i) (subdivide b bc ab d i) (subdivide c ca bc d i) (subdivide ab bc ca d i)))))) (loop for i below 20 do (subdivide (aref vertexes (aref indexes i 0)) (aref vertexes (aref indexes i 1)) (aref vertexes (aref indexes i 2)) (subdivision icosahedron) i))) (loop for i below 20 do (draw-tri (aref vertexes (aref indexes i 0)) (aref vertexes (aref indexes i 1)) (aref vertexes (aref indexes i 2)) (when colors (aref colors i)) (smoothp icosahedron)) ))))) ;;; ------------------------------------------------------------ ;;; Geometry Utilities (defun vector-difference (v1 v2 res) (loop for i fixnum below 3 do (setf (opengl:gl-vector-aref res i) (- (opengl:gl-vector-aref v1 i) (opengl:gl-vector-aref v2 i)))) res) (defun vector-sum (v1 v2 res) (loop for i fixnum below 3 do (setf (opengl:gl-vector-aref res i) (+ (opengl:gl-vector-aref v1 i) (opengl:gl-vector-aref v2 i)))) res) (defun normalize (vector) (let* ((x (opengl:gl-vector-aref vector 0)) (y (opengl:gl-vector-aref vector 1)) (z (opengl:gl-vector-aref vector 2)) (d (sqrt (+ (* x x) (* y y) (* z z))))) (if (zerop d) (error "Can't normalize a zero-length vector! ~s" vector) (setf (opengl:gl-vector-aref vector 0) (/ x d) (opengl:gl-vector-aref vector 1) (/ y d) (opengl:gl-vector-aref vector 2) (/ z d))) vector)) (defun normalized-cross-product (v1 v2 result) (let ((res (or result (make-gl-double-vector (length v1))))) (declare (type (gl-double-vector (*)) res)) (setf (opengl:gl-vector-aref res 0) (- (* (opengl:gl-vector-aref v1 1) (opengl:gl-vector-aref v2 2)) (* (opengl:gl-vector-aref v1 2) (opengl:gl-vector-aref v2 1))) (opengl:gl-vector-aref res 1) (- (* (opengl:gl-vector-aref v1 2) (opengl:gl-vector-aref v2 0)) (* (opengl:gl-vector-aref v1 0) (opengl:gl-vector-aref v2 2))) (opengl:gl-vector-aref res 2) (- (* (opengl:gl-vector-aref v1 0) (opengl:gl-vector-aref v2 1)) (* (opengl:gl-vector-aref v1 1) (opengl:gl-vector-aref v2 0)))) (normalize res) res)) ;;; ------------------------------------------------------------ ;;; The CAPI Interface (defun make-default-background () (gl-single-vector 0.5 0.5 0.5 1.0)) (eval-when (:load-toplevel :execute) (gp:register-image-translation :up *up-arrow*) (gp:register-image-translation :down *down-arrow*) (gp:register-image-translation :up-disabled *up-disabled*) (gp:register-image-translation :down-disabled *down-disabled*)) (defun make-ico-button-panel (items title &key (images (list :up :down)) (disabled-images (list :up-disabled :down-disabled)) (interaction :no-selection)) (make-instance 'capi:button-panel :title title :interaction interaction :callback-type :interface-data :selection-callback 'process-character :layout-class 'capi:column-layout :items items :images images :disabled-images disabled-images)) (capi:define-interface icosahedron-viewer (capi:interface) ((double-buffered-p :initform t :initarg :double-buffered-p :accessor double-buffered-p) (background :initform (make-default-background) :initarg :background :accessor background) (camera :initform (make-camera) :initarg :camera :accessor camera) (lastxy :initform nil :initarg :lastxy :accessor lastxy) (icotransform :initform nil :initarg :icotransform :accessor icotransform) (light-transform :initform nil :initarg :light-transform :accessor light-transform) (geom-object :initform (make-instance 'icosahedron :use-display-list t) :initarg :icosahedron :initarg :object :accessor icosahedron :accessor object) (texture-image :initform (get-icosahedron-texture-data) :initarg :texture-image :accessor texture-image) (texture-filter :initform opengl:*gl-nearest* :initarg :texture-filter :accessor texture-filter) (texturep :initform nil :initarg :texturep :accessor texturep) (smoothp :initform nil :initarg :smoothp :accessor smoothp) (subdivision-buttons :initform (make-ico-button-panel (list #\> #\<) "Subdiv.")) (specular-buttons :initform (make-ico-button-panel (list #\s #\S) "Spec.")) (emission-buttons :initform (make-ico-button-panel (list #\e #\E) "Em.")) (ambient-buttons :initform (make-ico-button-panel (list #\a #\A) "Ambient")) (shine-buttons :initform (make-ico-button-panel (list #\p #\P) "Shine."))) (:panes (canvas opengl:opengl-pane :configuration (list :rgba t :depth nil :double-buffered double-buffered-p) :min-width 400 :min-height 400 :message "Mouse-L spins the object, Mouse-R moves the light, Shift Mouse-L moves your view." :display-callback 'redisplay-canvas :resize-callback 'resize-canvas :input-model '(((:button-1 :press) viewer-button-1) ((:button-2 :press) viewer-button-2) ((:button-3 :press) viewer-button-2) ((:button-1 :shift :press) viewer-button-1-shift) ((:motion :button-1) viewer-motion-button-1) ((:motion :button-2) viewer-motion-button-2) ((:motion :button-3) viewer-motion-button-2) ((:motion :button-1 :shift) viewer-motion-button-1-shift)) :reader canvas :font (gp:make-font-description :family "Arial")) (shade-buttons capi:check-button-panel :callback-type :interface-data :selection-callback 'process-character :retract-callback 'process-character :layout-class 'capi:column-layout :title "Shading" :title-position :frame :items (list #\o) :print-function #'(lambda (x) (getf '(#\o "Smooth") x))) (texture-buttons capi:check-button-panel :callback-type :interface-data :selection-callback 'process-character :retract-callback 'process-character :layout-class 'capi:row-layout :title "Texture" :title-position :frame :items (list #\t #\n) :print-function #'(lambda (x) (getf '(#\t "On" #\n "Nice") x))) (reset-buttons capi:button-panel :interaction :no-selection :title "Reset" :title-position :frame :callback-type :interface-data :selection-callback 'process-character :layout-class 'capi:row-layout :items (list :home :insert) :print-function #'(lambda (x) (getf '(:home "View" :insert "Material") x))) (quit-button capi:button-panel :interaction :no-selection :callback-type :interface-data :selection-callback 'process-character :layout-class 'capi:column-layout :items (list #\escape) :print-function #'(lambda (x) x "Quit"))) (:layouts (main capi:column-layout '(top bottom canvas)) (top capi:row-layout '(reset-buttons shade-buttons texture-buttons) :x-adjust :right :y-adjust :center :max-width T) (object capi:row-layout '(subdivision-buttons) :title "Object" :title-position :frame) (material capi:row-layout '(specular-buttons emission-buttons shine-buttons) :title "Material" :title-position :frame) (light capi:row-layout '(ambient-buttons) :title "Light" :title-position :frame) (buttons capi:row-layout '(object light material)) (bottom capi:row-layout '(buttons quit-button))) (:default-initargs :auto-menus NIL :title "OpenGL Viewer")) (defmethod initialize-instance :after ((self icosahedron-viewer) &key &allow-other-keys) (setf (viewer (object self)) self)) (defun initialize-viewer (icosahedron-viewer) ;; Initialize the icotransform to unity. (opengl:rendering-on ((canvas icosahedron-viewer)) (setf (icotransform icosahedron-viewer) (make-gl-double-vector 16)) (setf (light-transform icosahedron-viewer) (make-gl-double-vector 16)) (initialize-transform (icotransform icosahedron-viewer)) (initialize-transform (light-transform icosahedron-viewer)) (reset-lights-and-materials))) (defun initialize-transform (transform) (opengl:gl-matrix-mode opengl:*gl-modelview*) (opengl:with-matrix-pushed (opengl:gl-load-identity) (opengl:gl-get-doublev opengl:*gl-modelview-matrix* transform))) (defun viewer-button-1 (canvas x y) (with-slots ((viewer capi:interface)) canvas (setf (lastxy viewer) (cons x y)))) (defun viewer-button-2 (canvas x y) (with-slots ((viewer capi:interface)) canvas (setf (lastxy viewer) (cons x y)))) (defun viewer-motion-button-1 (canvas x y) (with-slots ((viewer capi:interface)) canvas (let ((last (lastxy viewer))) (when last (opengl:rendering-on (canvas) (polar-rotate-icosahedron viewer (- x (car last)) (- y (cdr last)))) (redisplay-canvas canvas)) (setf (lastxy viewer) (cons x y))))) (defun viewer-motion-button-2 (canvas x y) (with-slots ((viewer capi:interface)) canvas (let ((last (lastxy viewer))) (when last (opengl:rendering-on (canvas) (polar-rotate-light viewer (- x (car last)) (- y (cdr last)))) (redisplay-canvas canvas)) (setf (lastxy viewer) (cons x y))))) (defun viewer-button-1-shift (canvas x y) (with-slots ((viewer capi:interface)) canvas (setf (lastxy viewer) (cons x y)))) (defun viewer-motion-button-1-shift (canvas x y) (with-slots ((viewer capi:interface)) canvas (let ((last (lastxy viewer))) (when last (let ((eye (eye (camera viewer)))) (setf (xyz-y eye) (max (+ (xyz-y eye) (/ (- (car last) x) 20)) 2d0))) (redisplay-canvas canvas)) (setf (lastxy viewer) (cons x y))))) (defparameter *pointer-rotation-gain* 0.4d0) (defun polar-rotate (transform dx dy) (opengl:with-matrix-pushed (opengl:gl-load-identity) (opengl:gl-rotated (float (* dx *pointer-rotation-gain*) 1.0d0) 0.0d0 0.0d0 1.0d0) (opengl:gl-rotated (float (* (- dy) *pointer-rotation-gain*) 1.0d0) 1.0d0 0.0d0 0.0d0) (opengl:gl-mult-matrixd transform) (opengl:gl-get-doublev opengl:*gl-modelview-matrix* transform))) (defun polar-rotate-light (viewer dx dy) (polar-rotate (light-transform viewer) dx dy)) (defun polar-rotate-icosahedron (viewer dx dy) (polar-rotate (icotransform viewer) dx dy)) (defparameter *light-model-ambient* nil) (defparameter *light-position* nil) (defparameter *light-ambient* nil) (defparameter *light-diffuse* nil) (defparameter *light-specular* nil) (defparameter *material-specular* nil) (defparameter *material-shininess* 0.0) (defparameter *material-emission* nil) (defun reset-lights-and-materials () (setf *light-model-ambient* (gl-single-vector 0.0 0.0 0.0 1.0)) (setf *light-position* (gl-single-vector 1.0 2.0 3.0 1.0)) (setf *light-ambient* (gl-single-vector 0.1 0.1 0.1 1.0)) (setf *light-diffuse* (gl-single-vector 0.8 0.8 0.8 1.0)) (setf *light-specular* (gl-single-vector 0.8 0.8 0.8 1.0)) (setf *material-specular* (gl-single-vector 0.1 0.0 0.0 1.0)) (setf *material-shininess* 64.0) (setf *material-emission* (gl-single-vector 0.0 0.0 0.0 1.0))) (defun change-material-property (property inc) (let ((val (max -1.0 (min 1.0 (float (+ (opengl:gl-vector-aref (symbol-value property) 0) inc) 1.0))))) (setf (symbol-value property) (gl-single-vector val val val 1.0)))) (defun viewer-character-callback (canvas x y character) x y (with-slots ((viewer capi:interface)) canvas (process-character viewer character))) (defun nice-texture-on (viewer) (setf (texture-filter viewer) opengl:*gl-linear*)) (defun nice-texture-off (viewer) (setf (texture-filter viewer) opengl:*gl-nearest*)) (defun nice-texture-p (viewer) (eq (texture-filter viewer) opengl:*gl-linear*)) (defun turn-off-texture (viewer) (opengl:rendering-on ((canvas viewer)) (setf (texturep (icosahedron viewer)) nil) (setf (texturep viewer) nil) (opengl:gl-disable opengl:*gl-texture-2d*))) (defun turn-on-texture (viewer) (opengl:rendering-on ((canvas viewer)) (setf (texturep (object viewer)) t) (setf (texturep viewer) t) (opengl:gl-pixel-storei opengl:*gl-unpack-alignment* 1) (opengl:gl-tex-image2-d opengl:*gl-texture-2d* 0 3 64 64 0 opengl:*gl-rgba* opengl:*gl-unsigned-byte* (texture-image viewer)) (opengl:gl-tex-parameteri opengl:*gl-texture-2d* opengl:*gl-texture-wrap-s* opengl:*gl-repeat*) (opengl:gl-tex-parameteri opengl:*gl-texture-2d* opengl:*gl-texture-wrap-t* opengl:*gl-clamp*) (opengl:gl-tex-parameteri opengl:*gl-texture-2d* opengl:*gl-texture-mag-filter* (texture-filter viewer)) (opengl:gl-tex-parameteri opengl:*gl-texture-2d* opengl:*gl-texture-min-filter* (texture-filter viewer)) (opengl:gl-tex-envi opengl:*gl-texture-env* opengl:*gl-texture-env-mode* opengl:*gl-modulate*) (opengl:gl-enable opengl:*gl-texture-2d*))) (defun process-character (viewer character) (when (case character (#\o (opengl:rendering-on ((canvas viewer)) (setf (smoothp viewer) (setf (smoothp (icosahedron viewer)) (not (smoothp (icosahedron viewer))))) t)) (#\> (incf-subdivision viewer)) (#\< (decf-subdivision viewer)) (#\s (change-material-property '*material-specular* 0.05)) (#\S (change-material-property '*material-specular* -0.05)) (#\e (change-material-property '*material-emission* 0.05)) (#\E (change-material-property '*material-emission* -0.05)) (#\a (change-material-property '*light-ambient* 0.05)) (#\A (change-material-property '*light-ambient* -0.05)) (#\p (let ((new (max 0.0 (min 128.0 (+ *material-shininess* 8.0))))) (unless (= new *material-shininess*) (setf *material-shininess* new)))) (#\P (let ((new (max 0.0 (min 128.0 (+ *material-shininess* -8.0))))) (unless (= new *material-shininess*) (setf *material-shininess* new)))) (#\t (if (texturep (icosahedron viewer)) (turn-off-texture viewer) (turn-on-texture viewer)) t) (#\n (if (nice-texture-p viewer) (nice-texture-off viewer) (nice-texture-on viewer)) (when (texturep (icosahedron viewer)) (turn-off-texture viewer) (turn-on-texture viewer)) t) (:home (opengl:rendering-on ((canvas viewer)) (initialize-transform (icotransform viewer)) (initialize-transform (light-transform viewer)) t) (setf (xyz-y (eye (camera viewer))) (xyz-y *eye*))) (:insert (opengl:rendering-on ((canvas viewer)) (reset-lights-and-materials) t)) (#\escape (opengl:rendering-on ((canvas viewer)) (delete-display-list (icosahedron viewer))) (capi:quit-interface viewer))) (set-button-states viewer) (capi:with-busy-interface (viewer) (redisplay-canvas (canvas viewer))))) (defun incf-subdivision (viewer &optional (factor 2)) (let* ((old (subdivision (icosahedron viewer))) (new (if (zerop old) 1 (min 3 (* factor old))))) (and (/= old new) (opengl:rendering-on ((canvas viewer)) (setf (subdivision (icosahedron viewer)) new))))) (defun decf-subdivision (viewer &optional (factor 2)) (let* ((old (subdivision (icosahedron viewer))) (new (round old factor))) (and (/= old new) (opengl:rendering-on ((canvas viewer)) (setf (subdivision (icosahedron viewer)) new))))) (defun set-button-states (viewer) (with-slots (subdivision-buttons specular-buttons emission-buttons ambient-buttons shine-buttons) viewer (if (typep (object viewer) 'icosahedron) (capi:set-button-panel-enabled-items subdivision-buttons :set T :disable (append (and (= (subdivision (icosahedron viewer)) 0) (list #\<)) (and (= (subdivision (icosahedron viewer)) 3) (list #\>)))) (capi:set-button-panel-enabled-items subdivision-buttons :set T :disable (list #\< #\>))) (capi:set-button-panel-enabled-items specular-buttons :set T :disable (append (and (<= (opengl:gl-vector-aref *material-specular* 0) -1.0) (list #\S)) (and (>= (opengl:gl-vector-aref *material-specular* 0) 1.0) (list #\s)))) (capi:set-button-panel-enabled-items emission-buttons :set T :disable (append (and (<= (opengl:gl-vector-aref *material-emission* 0) -1.0) (list #\E)) (and (>= (opengl:gl-vector-aref *material-emission* 0) 1.0) (list #\e)))) (capi:set-button-panel-enabled-items ambient-buttons :set T :disable (append (and (<= (opengl:gl-vector-aref *light-ambient* 0) -1.0) (list #\A)) (and (>= (opengl:gl-vector-aref *light-ambient* 0) 1.0) (list #\a)))) (capi:set-button-panel-enabled-items shine-buttons :set T :disable (append (and (= *material-shininess* 0.0) (list #\P)) (and (= *material-shininess* 128.0) (list #\p)))) )) (defun redisplay-canvas (canvas &rest ignore) ignore (with-slots ((viewer capi:interface)) canvas (unless (icotransform viewer) (initialize-viewer viewer)) (opengl:rendering-on (canvas) (draw (camera viewer)) (opengl:with-matrix-pushed (opengl:gl-mult-matrixd (light-transform viewer)) (opengl:gl-light-modelfv opengl:*gl-light-model-ambient* *light-model-ambient*) (opengl:gl-light-modelf opengl:*gl-light-model-local-viewer* 0.0) (opengl:gl-light-modelf opengl:*gl-light-model-two-side* 0.0) (opengl:gl-enable opengl:*gl-light0*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-position* *light-position*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-ambient* *light-ambient*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-diffuse* *light-diffuse*) (opengl:gl-lightfv opengl:*gl-light0* opengl:*gl-specular* *light-specular*)) (opengl:with-matrix-pushed (opengl:gl-mult-matrixd (icotransform viewer)) (opengl:gl-cull-face opengl:*gl-back*) (opengl:gl-enable opengl:*gl-cull-face*) (opengl:gl-enable opengl:*gl-color-material*) (opengl:gl-color-material opengl:*gl-front* opengl:*gl-ambient-and-diffuse*) (opengl:gl-materialfv opengl:*gl-front* opengl:*gl-specular* *material-specular*) (opengl:gl-materialf opengl:*gl-front* opengl:*gl-shininess* *material-shininess*) (opengl:gl-materialfv opengl:*gl-front* opengl:*gl-emission* *material-emission*) (draw (icosahedron viewer))) (when (double-buffered-p viewer) (opengl:swap-buffers canvas))))) (defun resize-canvas (canvas x y width height) x y (when #+mswindows (win32:is-window-visible (win32:pane-hwnd (capi-internals:representation canvas))) #-mswindows t (opengl:rendering-on (canvas) (opengl:gl-viewport 0 0 width height)) (with-slots ((viewer capi:interface)) canvas (setf (aspect (projection (camera viewer))) (coerce (/ width height) 'double-float))) (redisplay-canvas canvas))) (defmethod (setf object) :before (new-object (viewer icosahedron-viewer)) (opengl:rendering-on ((canvas viewer)) (delete-display-list (object viewer)))) (defmethod (setf object) :after (new-object (viewer icosahedron-viewer)) (setf (viewer new-object) viewer (texturep new-object) (texturep viewer) (smoothp new-object) (smoothp viewer)) (set-button-states viewer) (redisplay-canvas (canvas viewer))) (defvar *ico* nil) (defun new-object (vertex-list index-list &key (colors :random)) (setf (object *ico*) (make-instance 'geom-object :vertexes vertex-list :indexes index-list :colors colors))) (defun reset-object () (setf (object *ico*) (make-instance 'icosahedron)))
46,034
Common Lisp
.lisp
926
38.641469
166
0.565965
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
4363528ae614e0311a2898aafc14fa2198e17b8f4b4af0df70dc3e01a0464956
823
[ -1 ]
824
3d-text.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/3d-text.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/3d-text.lisp,v 1.6.1.2 2014/06/05 11:59:33 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") (defun set-up-gl-fonts (pane obj) #-mswindows (declare (ignore pane obj)) #+mswindows (when (name obj) (unless (assoc :font (extra-display-lists obj)) (push (list :font (win32::wgl-use-font pane :start 0 :count 256 :outlinep t) 256) (extra-display-lists obj))))) (defmacro with-3d-text-state-saved (&body body) `(opengl:with-matrix-pushed #+mswindows (opengl:gl-push-attrib opengl:*gl-all-attrib-bits*) ,@body #+mswindows (opengl:gl-pop-attrib))) #+ftgl (defvar *ftgl-font-file* "/usr/share/fonts/paratype-pt-sans/PTN57F.ttf") (defun draw-3d-text (obj text) #+mswindows (let* ((base (second (assoc :font (extra-display-lists obj))))) ;; Set up for a string-drawing display list call. (opengl:gl-list-base base) ;; Draw a string using font display lists. (fli:with-foreign-string (ptr elts bytes :external-format win32:*multibyte-code-page-ef* :null-terminated-p nil) text (declare (ignore bytes)) (opengl:gl-call-lists elts opengl:*gl-unsigned-byte* ptr))) #+ftgl (let ((font (ftgl:ftgl-create-extrude-font *ftgl-font-file*))) (unwind-protect (opengl:with-matrix-pushed (let ((scale (float 1/72 0d0))) (opengl:gl-scaled scale scale scale)) (ftgl:ftgl-set-font-display-list font (if (use-display-list obj) 0 1)) (ftgl:ftgl-set-font-face-size font 72 72) (ftgl:ftgl-set-font-depth font 5.0) (ftgl:ftgl-render-font font text ftgl:FTGL_RENDER_ALL)) (ftgl:ftgl-destroy-font font)))) #+(or mswindows ftgl) (defun draw-positioned-3d-text (obj text x-pos y-pos z-pos x-rotation y-rotation z-rotation scale) (with-3d-text-state-saved (opengl:gl-translated x-pos y-pos z-pos) (opengl:gl-scaled scale scale scale) (opengl:gl-rotated x-rotation 1.0d0 0.0d0 0.0d0) (opengl:gl-rotated y-rotation 0.0d0 1.0d0 0.0d0) (opengl:gl-rotated z-rotation 0.0d0 0.0d0 1.0d0) ;; Draw the text. (draw-3d-text obj text))) #+(or mswindows ftgl) (defmethod draw :after ((obj geom-object)) (let* ((text (name obj))) (when text (opengl:gl-color4-d 1d0 0.5d0 0.0d0 1.0d0) (if (listp text) (dolist (spec text) (apply 'draw-positioned-3d-text obj spec)) (let* ((vertexes (vertexes obj)) (vertex (aref vertexes 0))) (draw-positioned-3d-text obj text (opengl:gl-vector-aref vertex 0) (opengl:gl-vector-aref vertex 1) (opengl:gl-vector-aref vertex 2) -90d0 0d0 180d0 0.5d0))))))
3,337
Common Lisp
.lisp
78
30.871795
160
0.550462
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
11bb07f4111fa1839bd597d8c19a6bd387b36ed43eac8af4ec7db75292908a2d
824
[ -1 ]
825
arrows.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/arrows.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/arrows.lisp,v 1.5.13.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") ;;; ---------------------------------------------------------------------- ;;; Load up the required generic images use #. reader syntax to embed the ;;; images within the fasl. ;;; ---------------------------------------------------------------------- (eval-when (compile eval) (defmacro register-button-image (pathname) (gp:read-external-image (merge-pathnames pathname (or #+LUCID *compile-file-pathname* (current-pathname)))))) (defvar *down-arrow* #.(register-button-image #p"./images/down-arrow.bmp")) (defvar *up-arrow* #.(register-button-image #p"./images/up-arrow.bmp")) (defvar *up-disabled* #.(register-button-image #p"./images/up-disabled.bmp")) (defvar *down-disabled* #.(register-button-image #p"./images/down-disabled.bmp")) (setf (gp:external-image-transparent-color-index *down-arrow*) 0 (gp:external-image-transparent-color-index *up-arrow*) 0 (gp:external-image-transparent-color-index *up-disabled*) 0 (gp:external-image-transparent-color-index *down-disabled*) 0)
1,319
Common Lisp
.lisp
19
63.684211
160
0.608359
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
8c833e87022b830de7c7c48a068fd469c29771fb7ff1157fdd55725e596a2f4e
825
[ -1 ]
826
texture.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/texture.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/texture.lisp,v 1.6.14.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "USER") (defvar *icosahedron-texture-data* nil) (defvar temp-icosahedron-texture-data '(#xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #xB1 #x42 #x10 #xFF #xB1 #x42 #x10 #xFF #xB1 #x42 #x10 #xFF #xBB #x46 #x0A #xFF #xC5 #x4A #x04 #xFF #xCC #x4C #x00 #xFF #xC5 #x4B #x00 #xFF #xBF #x4A #x00 #xFF #xC8 #x4C #x00 #xFF #xB4 #x43 #x0E #xFF #xAE #x41 #x12 #xFF #xAE #x41 #x12 #xFF #x97 #x38 #x21 #xFF #x79 #x2D #x34 #xFF #x45 #x19 #x56 #xFF #x20 #x0C #x6D #xFF #x09 #x03 #x7B #xFF #x0D #x04 #x79 #xFF #x10 #x06 #x77 #xFF #x13 #x07 #x75 #xFF #x2A #x10 #x66 #xFF #x41 #x18 #x58 #xFF #x4B #x1C #x51 #xFF #x4E #x1D #x4F #xFF #x45 #x19 #x56 #xFF #x3B #x16 #x5C #xFF #x45 #x19 #x56 #xFF #x55 #x20 #x4B #xFF #x5C #x22 #x47 #xFF #x5F #x23 #x45 #xFF #x66 #x26 #x41 #xFF #x6F #x29 #x3A #xFF #x76 #x2C #x36 #xFF #x73 #x2B #x38 #xFF #x6F #x29 #x3A #xFF #x69 #x27 #x3E #xFF #x6F #x29 #x3A #xFF #x80 #x30 #x30 #xFF #x8A #x33 #x29 #xFF #x8A #x33 #x29 #xFF #x90 #x36 #x25 #xFF #xA4 #x3D #x19 #xFF #xC5 #x4A #x04 #xFF #xB8 #x4A #x00 #xFF #xB2 #x49 #x00 #xFF #xB2 #x49 #x00 #xFF #xAF #x48 #x00 #xFF #xB5 #x49 #x00 #xFF #xBF #x4A #x00 #xFF #xB5 #x49 #x00 #xFF #xA8 #x48 #x00 #xFF #x99 #x46 #x00 #xFF #xA5 #x47 #x00 #xFF #xB2 #x49 #x00 #xFF #xAC #x48 #x00 #xFF #xA2 #x47 #x00 #xFF #xAC #x48 #x00 #xFF #xB5 #x49 #x00 #xFF #xBF #x4A #x00 #xFF #xC2 #x4B #x00 #xFF #xBF #x4A #x00 #xFF #xC5 #x4B #x00 #xFF #xCC #x4C #x00 #xFF #xBE #x47 #x08 #xFF #x69 #x27 #x3E #xFF #x62 #x25 #x43 #xFF #x66 #x26 #x41 #xFF #x62 #x25 #x43 #xFF #x48 #x1B #x53 #xFF #x2E #x11 #x64 #xFF #x27 #x0E #x68 #xFF #x2E #x11 #x64 #xFF #x3E #x17 #x5A #xFF #x3B #x16 #x5C #xFF #x52 #x1E #x4D #xFF #x55 #x20 #x4B #xFF #x41 #x18 #x58 #xFF #x13 #x07 #x75 #xFF #x1C #xAC #x1C #xFF #x21 #xA3 #x21 #xFF #x28 #x94 #x28 #xFF #x20 #xA5 #x20 #xFF #x19 #xCC #x00 #xFF #x1F #xA7 #x1F #xFF #x2A #x90 #x2A #xFF #x26 #x98 #x26 #xFF #x22 #xA1 #x22 #xFF #x2A #x10 #x66 #xFF #x3E #x17 #x5A #xFF #x4E #x1D #x4F #xFF #x55 #x20 #x4B #xFF #x4B #x1C #x51 #xFF #x5F #x23 #x45 #xFF #x8A #x33 #x29 #xFF #x86 #x32 #x2C #xFF #x69 #x27 #x3E #xFF #x55 #x20 #x4B #xFF #x41 #x18 #x58 #xFF #x55 #x20 #x4B #xFF #x62 #x25 #x43 #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #xA4 #x3D #x19 #xFF #xC8 #x4B #x02 #xFF #xB4 #x43 #x0E #xFF #xAE #x41 #x12 #xFF #xC2 #x48 #x06 #xFF #xB4 #x43 #x0E #xFF #xC2 #x4B #x00 #xFF #xC8 #x4C #x00 #xFF #xC2 #x4B #x00 #xFF #x92 #x45 #x00 #xFF #x82 #x43 #x00 #xFF #x95 #x45 #x00 #xFF #xAF #x48 #x00 #xFF #xB8 #x4A #x00 #xFF #xBC #x4A #x00 #xFF #x8F #x44 #x00 #xFF #xA2 #x47 #x00 #xFF #xAF #x48 #x00 #xFF #xC2 #x4B #x00 #xFF #xB8 #x45 #x0C #xFF #x94 #x37 #x23 #xFF #x7D #x2E #x32 #xFF #x6F #x29 #x3A #xFF #x6F #x29 #x3A #xFF #x6C #x28 #x3C #xFF #x66 #x26 #x41 #xFF #x3B #x16 #x5C #xFF #x37 #x14 #x5E #xFF #x37 #x14 #x5E #xFF #x52 #x1E #x4D #xFF #x3E #x17 #x5A #xFF #x34 #x13 #x60 #xFF #x1A #x09 #x71 #xFF #x33 #x33 #xB5 #xFF #x19 #xCC #x00 #xFF #x03 #x01 #x7F #xFF #x27 #x0E #x68 #xFF #x1D #x0B #x6F #xFF #x24 #x9B #x24 #xFF #x24 #x9B #x24 #xFF #x28 #x94 #x28 #xFF #x2E #x88 #x2E #xFF #x31 #x83 #x31 #xFF #x2F #x87 #x2F #xFF #x35 #x7A #x35 #xFF #x30 #x85 #x30 #xFF #x2F #x87 #x2F #xFF #x33 #x7F #x33 #xFF #x29 #x92 #x29 #xFF #x20 #xA5 #x20 #xFF #x25 #x99 #x25 #xFF #x24 #x9B #x24 #xFF #x00 #x00 #x82 #xFF #x03 #x01 #x7F #xFF #x24 #x0D #x6A #xFF #x1D #x0B #x6F #xFF #x34 #x13 #x60 #xFF #x3B #x16 #x5C #xFF #x45 #x19 #x56 #xFF #x24 #x0D #x6A #xFF #x24 #x0D #x6A #xFF #x66 #x26 #x41 #xFF #x83 #x31 #x2E #xFF #x73 #x2B #x38 #xFF #x62 #x25 #x43 #xFF #x8D #x35 #x27 #xFF #x69 #x27 #x3E #xFF #x48 #x1B #x53 #xFF #x41 #x18 #x58 #xFF #x1D #x0B #x6F #xFF #x34 #x13 #x60 #xFF #x73 #x2B #x38 #xFF #x8D #x35 #x27 #xFF #x9A #x39 #x1F #xFF #x80 #x30 #x30 #xFF #x94 #x37 #x23 #xFF #xB4 #x43 #x0E #xFF #xB8 #x45 #x0C #xFF #x90 #x36 #x25 #xFF #x94 #x37 #x23 #xFF #xCC #x4C #x00 #xFF #xC2 #x48 #x06 #xFF #xC2 #x48 #x06 #xFF #x9A #x39 #x1F #xFF #x79 #x2D #x34 #xFF #x73 #x2B #x38 #xFF #x79 #x2D #x34 #xFF #x80 #x30 #x30 #xFF #x58 #x21 #x49 #xFF #x41 #x18 #x58 #xFF #x27 #x0E #x68 #xFF #x1D #x0B #x6F #xFF #x4B #x1C #x51 #xFF #x3B #x16 #x5C #xFF #x1C #xAC #x1C #xFF #x03 #x01 #x7F #xFF #x10 #x06 #x77 #xFF #x1A #xB0 #x1A #xFF #x25 #x99 #x25 #xFF #x19 #xCC #x00 #xFF #x1E #xA9 #x1E #xFF #x06 #x02 #x7D #xFF #x1A #x09 #x71 #xFF #x22 #xA1 #x22 #xFF #x2E #x88 #x2E #xFF #x33 #x7F #x33 #xFF #x45 #x59 #x45 #xFF #x33 #x7F #x33 #xFF #x22 #xA1 #x22 #xFF #x3E #x17 #x5A #xFF #x09 #x03 #x7B #xFF #x19 #xCC #x00 #xFF #x24 #x9B #x24 #xFF #x20 #xA5 #x20 #xFF #x13 #x07 #x75 #xFF #x0D #x04 #x79 #xFF #x2E #x11 #x64 #xFF #x31 #x12 #x62 #xFF #x83 #x31 #x2E #xFF #x8A #x33 #x29 #xFF #x94 #x37 #x23 #xFF #x4E #x1D #x4F #xFF #x27 #x0E #x68 #xFF #x3E #x17 #x5A #xFF #x5F #x23 #x45 #xFF #x6F #x29 #x3A #xFF #x69 #x27 #x3E #xFF #x6F #x29 #x3A #xFF #x79 #x2D #x34 #xFF #x8D #x35 #x27 #xFF #x37 #x14 #x5E #xFF #x19 #xB2 #x19 #xFF #x17 #x08 #x73 #xFF #x06 #x02 #x7D #xFF #x5F #x23 #x45 #xFF #xA7 #x3E #x17 #xFF #x6F #x29 #x3A #xFF #x4B #x1C #x51 #xFF #x73 #x2B #x38 #xFF #x8A #x33 #x29 #xFF #x73 #x2B #x38 #xFF #x55 #x20 #x4B #xFF #x69 #x27 #x3E #xFF #x4B #x1C #x51 #xFF #x69 #x27 #x3E #xFF #x62 #x25 #x43 #xFF #x6C #x28 #x3C #xFF #x69 #x27 #x3E #xFF #x9D #x3B #x1D #xFF #x97 #x38 #x21 #xFF #xBF #x4A #x00 #xFF #xA7 #x3E #x17 #xFF #x37 #x14 #x5E #xFF #x19 #xB2 #x19 #xFF #x1A #xB0 #x1A #xFF #x34 #x13 #x60 #xFF #x41 #x18 #x58 #xFF #x31 #x12 #x62 #xFF #x13 #x07 #x75 #xFF #x1D #x0B #x6F #xFF #x1A #x09 #x71 #xFF #x20 #xA5 #x20 #xFF #x25 #x99 #x25 #xFF #x2B #x8E #x2B #xFF #x22 #xA1 #x22 #xFF #x2F #x87 #x2F #xFF #x30 #x85 #x30 #xFF #x32 #x81 #x32 #xFF #x30 #x85 #x30 #xFF #x22 #xA1 #x22 #xFF #x06 #x02 #x7D #xFF #x03 #x01 #x7F #xFF #x10 #x06 #x77 #xFF #x20 #x0C #x6D #xFF #x4B #x1C #x51 #xFF #x52 #x1E #x4D #xFF #x3B #x16 #x5C #xFF #x6C #x28 #x3C #xFF #x8A #x33 #x29 #xFF #x4E #x1D #x4F #xFF #xAE #x41 #x12 #xFF #xAE #x41 #x12 #xFF #x52 #x1E #x4D #xFF #x4E #x1D #x4F #xFF #x58 #x21 #x49 #xFF #x79 #x2D #x34 #xFF #x69 #x27 #x3E #xFF #x6C #x28 #x3C #xFF #x79 #x2D #x34 #xFF #x9A #x39 #x1F #xFF #x9D #x3B #x1D #xFF #x9D #x3B #x1D #xFF #x76 #x2C #x36 #xFF #x8D #x35 #x27 #xFF #x48 #x1B #x53 #xFF #x3B #x16 #x5C #xFF #x55 #x20 #x4B #xFF #x8D #x35 #x27 #xFF #x55 #x20 #x4B #xFF #x20 #x0C #x6D #xFF #x3E #x17 #x5A #xFF #x5C #x22 #x47 #xFF #x3B #x16 #x5C #xFF #x58 #x21 #x49 #xFF #x48 #x1B #x53 #xFF #x5F #x23 #x45 #xFF #x86 #x32 #x2C #xFF #x6C #x28 #x3C #xFF #x5F #x23 #x45 #xFF #xB1 #x42 #x10 #xFF #x8D #x35 #x27 #xFF #x8A #x33 #x29 #xFF #x97 #x38 #x21 #xFF #x3B #x16 #x5C #xFF #x45 #x19 #x56 #xFF #x5C #x22 #x47 #xFF #x62 #x25 #x43 #xFF #x2E #x11 #x64 #xFF #x2D #x8A #x2D #xFF #x28 #x94 #x28 #xFF #x27 #x0E #x68 #xFF #x6C #x28 #x3C #xFF #x10 #x06 #x77 #xFF #x10 #x06 #x77 #xFF #x31 #x12 #x62 #xFF #x1A #xB0 #x1A #xFF #x34 #x13 #x60 #xFF #x00 #x00 #x82 #xFF #x1D #xAA #x1D #xFF #x27 #x96 #x27 #xFF #x20 #xA5 #x20 #xFF #x31 #x12 #x62 #xFF #x37 #x14 #x5E #xFF #x1A #x09 #x71 #xFF #x28 #x94 #x28 #xFF #x22 #x9F #x22 #xFF #x19 #xCC #x00 #xFF #x1D #xAA #x1D #xFF #x1A #x09 #x71 #xFF #x48 #x1B #x53 #xFF #x13 #x07 #x75 #xFF #x27 #x0E #x68 #xFF #x76 #x2C #x36 #xFF #x83 #x31 #x2E #xFF #x73 #x2B #x38 #xFF #x4E #x1D #x4F #xFF #x45 #x19 #x56 #xFF #x1A #x09 #x71 #xFF #x1D #xAA #x1D #xFF #x24 #x0D #x6A #xFF #x41 #x18 #x58 #xFF #x34 #x13 #x60 #xFF #x62 #x25 #x43 #xFF #x1A #x09 #x71 #xFF #x2E #x11 #x64 #xFF #x27 #x0E #x68 #xFF #x66 #x26 #x41 #xFF #x62 #x25 #x43 #xFF #x97 #x38 #x21 #xFF #x66 #x26 #x41 #xFF #x1A #x09 #x71 #xFF #x31 #x12 #x62 #xFF #x37 #x14 #x5E #xFF #x58 #x21 #x49 #xFF #x6C #x28 #x3C #xFF #x83 #x31 #x2E #xFF #x48 #x1B #x53 #xFF #x79 #x2D #x34 #xFF #x3E #x17 #x5A #xFF #x5C #x22 #x47 #xFF #x5F #x23 #x45 #xFF #x9A #x39 #x1F #xFF #x86 #x32 #x2C #xFF #x97 #x38 #x21 #xFF #x66 #x26 #x41 #xFF #x5F #x23 #x45 #xFF #x27 #x0E #x68 #xFF #x19 #xCC #x00 #xFF #x3B #x16 #x5C #xFF #x79 #x2D #x34 #xFF #x79 #x2D #x34 #xFF #x13 #x07 #x75 #xFF #x20 #x0C #x6D #xFF #x00 #x00 #x82 #xFF #x37 #x14 #x5E #xFF #x1D #x0B #x6F #xFF #x2E #x11 #x64 #xFF #x41 #x18 #x58 #xFF #x20 #x0C #x6D #xFF #x31 #x12 #x62 #xFF #x06 #x02 #x7D #xFF #x09 #x03 #x7B #xFF #x2E #x11 #x64 #xFF #x1A #x09 #x71 #xFF #x03 #x01 #x7F #xFF #x06 #x02 #x7D #xFF #x20 #x0C #x6D #xFF #x20 #x0C #x6D #xFF #x28 #x94 #x28 #xFF #x22 #x9F #x22 #xFF #x03 #x01 #x7F #xFF #x28 #x94 #x28 #xFF #x27 #x0E #x68 #xFF #x8A #x33 #x29 #xFF #x37 #x14 #x5E #xFF #x4B #x1C #x51 #xFF #x52 #x1E #x4D #xFF #x41 #x18 #x58 #xFF #x69 #x27 #x3E #xFF #x3E #x17 #x5A #xFF #x17 #x08 #x73 #xFF #x00 #x00 #x82 #xFF #x1C #xAC #x1C #xFF #x19 #xCC #x00 #xFF #x34 #x13 #x60 #xFF #x45 #x19 #x56 #xFF #x90 #x36 #x25 #xFF #x24 #x0D #x6A #xFF #x31 #x12 #x62 #xFF #x58 #x21 #x49 #xFF #x7D #x2E #x32 #xFF #x97 #x38 #x21 #xFF #x83 #x31 #x2E #xFF #x52 #x1E #x4D #xFF #x10 #x06 #x77 #xFF #x20 #x0C #x6D #xFF #x06 #x02 #x7D #xFF #x3B #x16 #x5C #xFF #x37 #x14 #x5E #xFF #x6C #x28 #x3C #xFF #x5C #x22 #x47 #xFF #x48 #x1B #x53 #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #x76 #x2C #x36 #xFF #x58 #x21 #x49 #xFF #x58 #x21 #x49 #xFF #x4B #x1C #x51 #xFF #x2E #x11 #x64 #xFF #x55 #x20 #x4B #xFF #x37 #x14 #x5E #xFF #x09 #x03 #x7B #xFF #x34 #x13 #x60 #xFF #x69 #x27 #x3E #xFF #x5C #x22 #x47 #xFF #x45 #x19 #x56 #xFF #x31 #x12 #x62 #xFF #x2A #x10 #x66 #xFF #x17 #x08 #x73 #xFF #x1F #xA7 #x1F #xFF #x21 #xA3 #x21 #xFF #x1E #xA9 #x1E #xFF #x22 #xA1 #x22 #xFF #x1A #xB0 #x1A #xFF #x10 #x06 #x77 #xFF #x26 #x98 #x26 #xFF #x28 #x94 #x28 #xFF #x0D #x04 #x79 #xFF #x35 #x7A #x35 #xFF #x25 #x99 #x25 #xFF #x27 #x96 #x27 #xFF #x24 #x9B #x24 #xFF #x2E #x88 #x2E #xFF #x22 #xA1 #x22 #xFF #x20 #xA5 #x20 #xFF #x1A #xB0 #x1A #xFF #x1B #xAE #x1B #xFF #x0D #x04 #x79 #xFF #x1C #xAC #x1C #xFF #x52 #x1E #x4D #xFF #x0D #x04 #x79 #xFF #x1A #x09 #x71 #xFF #x41 #x18 #x58 #xFF #x52 #x1E #x4D #xFF #x4E #x1D #x4F #xFF #x55 #x20 #x4B #xFF #x24 #x0D #x6A #xFF #x48 #x1B #x53 #xFF #x4E #x1D #x4F #xFF #x66 #x26 #x41 #xFF #x1D #xAA #x1D #xFF #x1C #xAC #x1C #xFF #x19 #xB2 #x19 #xFF #x62 #x25 #x43 #xFF #x76 #x2C #x36 #xFF #x86 #x32 #x2C #xFF #x8A #x33 #x29 #xFF #x31 #x12 #x62 #xFF #x20 #x0C #x6D #xFF #x52 #x1E #x4D #xFF #x66 #x26 #x41 #xFF #x3E #x17 #x5A #xFF #x13 #x07 #x75 #xFF #x20 #x0C #x6D #xFF #x27 #x0E #x68 #xFF #x52 #x1E #x4D #xFF #x1F #xA7 #x1F #xFF #x6C #x28 #x3C #xFF #x73 #x2B #x38 #xFF #x31 #x12 #x62 #xFF #x13 #x07 #x75 #xFF #x33 #x33 #xB5 #xFF #x06 #x02 #x7D #xFF #x27 #x0E #x68 #xFF #x41 #x18 #x58 #xFF #x34 #x13 #x60 #xFF #x4E #x1D #x4F #xFF #x80 #x30 #x30 #xFF #x48 #x1B #x53 #xFF #x34 #x13 #x60 #xFF #x31 #x12 #x62 #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x34 #x13 #x60 #xFF #x03 #x01 #x7F #xFF #x2D #x8A #x2D #xFF #x0D #x04 #x79 #xFF #x27 #x96 #x27 #xFF #x2B #x8E #x2B #xFF #x33 #x7F #x33 #xFF #x03 #x01 #x7F #xFF #x19 #xB2 #x19 #xFF #x35 #x7A #x35 #xFF #x1E #xA9 #x1E #xFF #x1E #xA9 #x1E #xFF #x26 #x98 #x26 #xFF #x19 #xCC #x00 #xFF #x19 #xB2 #x19 #xFF #x33 #x33 #xB5 #xFF #x1D #xAA #x1D #xFF #x2B #x8E #x2B #xFF #x3C #x6C #x3C #xFF #x25 #x99 #x25 #xFF #x1D #x0B #x6F #xFF #x22 #x9F #x22 #xFF #x1D #xAA #x1D #xFF #x2E #x11 #x64 #xFF #x00 #x00 #x82 #xFF #x55 #x20 #x4B #xFF #x66 #x26 #x41 #xFF #x55 #x20 #x4B #xFF #x2E #x11 #x64 #xFF #x3E #x17 #x5A #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x1C #xAC #x1C #xFF #x1D #xAA #x1D #xFF #x41 #x18 #x58 #xFF #x4E #x1D #x4F #xFF #x3E #x17 #x5A #xFF #x69 #x27 #x3E #xFF #x00 #x00 #x82 #xFF #x55 #x20 #x4B #xFF #x20 #x0C #x6D #xFF #x41 #x18 #x58 #xFF #x5F #x23 #x45 #xFF #x41 #x18 #x58 #xFF #x19 #xB2 #x19 #xFF #x1E #xA9 #x1E #xFF #x55 #x20 #x4B #xFF #x00 #x00 #x82 #xFF #x24 #x0D #x6A #xFF #x0D #x04 #x79 #xFF #x52 #x1E #x4D #xFF #x17 #x08 #x73 #xFF #x29 #x92 #x29 #xFF #x17 #x08 #x73 #xFF #x4B #x1C #x51 #xFF #xB1 #x42 #x10 #xFF #x8D #x35 #x27 #xFF #x8A #x33 #x29 #xFF #x73 #x2B #x38 #xFF #x3E #x17 #x5A #xFF #x34 #x13 #x60 #xFF #x13 #x07 #x75 #xFF #x19 #xCC #x00 #xFF #x19 #xCC #x00 #xFF #x2F #x87 #x2F #xFF #x1F #xA7 #x1F #xFF #x1B #xAE #x1B #xFF #x20 #x0C #x6D #xFF #x2D #x8A #x2D #xFF #x25 #x99 #x25 #xFF #x4D #x4A #x4B #xFF #x3B #x6F #x3B #xFF #x29 #x92 #x29 #xFF #x29 #x92 #x29 #xFF #x1D #x0B #x6F #xFF #x1F #xA7 #x1F #xFF #x23 #x9D #x23 #xFF #x4B #x1C #x51 #xFF #x2A #x10 #x66 #xFF #x23 #x9D #x23 #xFF #x2B #x8E #x2B #xFF #x3D #x6A #x3D #xFF #x35 #x7A #x35 #xFF #x23 #x9D #x23 #xFF #x3B #x6F #x3B #xFF #x3B #x6F #x3B #xFF #x2A #x90 #x2A #xFF #x06 #x02 #x7D #xFF #x33 #x33 #xB5 #xFF #x2C #x8C #x2C #xFF #x1B #xAE #x1B #xFF #x2E #x11 #x64 #xFF #x09 #x03 #x7B #xFF #x4E #x1D #x4F #xFF #x55 #x20 #x4B #xFF #x48 #x1B #x53 #xFF #x09 #x03 #x7B #xFF #x28 #x94 #x28 #xFF #x00 #x00 #x82 #xFF #x2A #x10 #x66 #xFF #x27 #x0E #x68 #xFF #x1A #x09 #x71 #xFF #x27 #x0E #x68 #xFF #x34 #x13 #x60 #xFF #x21 #xA3 #x21 #xFF #x06 #x02 #x7D #xFF #x52 #x1E #x4D #xFF #x17 #x08 #x73 #xFF #x00 #x00 #x82 #xFF #x24 #x9B #x24 #xFF #x24 #x9B #x24 #xFF #x2A #x90 #x2A #xFF #x7D #x2E #x32 #xFF #x24 #x0D #x6A #xFF #x1B #xAE #x1B #xFF #x31 #x12 #x62 #xFF #x1D #xAA #x1D #xFF #x2A #x10 #x66 #xFF #x1D #x0B #x6F #xFF #x31 #x12 #x62 #xFF #x7D #x2E #x32 #xFF #x5C #x22 #x47 #xFF #x52 #x1E #x4D #xFF #x24 #x0D #x6A #xFF #x09 #x03 #x7B #xFF #x22 #xA1 #x22 #xFF #x03 #x01 #x7F #xFF #x1D #xAA #x1D #xFF #x31 #x83 #x31 #xFF #x30 #x85 #x30 #xFF #x09 #x03 #x7B #xFF #x1B #xAE #x1B #xFF #x1E #xA9 #x1E #xFF #x21 #xA3 #x21 #xFF #x1C #xAC #x1C #xFF #x3F #x67 #x3F #xFF #x28 #x94 #x28 #xFF #x3F #x67 #x3F #xFF #x40 #x64 #x40 #xFF #x2E #x11 #x64 #xFF #x19 #xB2 #x19 #xFF #x34 #x13 #x60 #xFF #x1A #xB0 #x1A #xFF #x21 #xA3 #x21 #xFF #x06 #x02 #x7D #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x13 #x07 #x75 #xFF #x3F #x67 #x3F #xFF #x33 #x7F #x33 #xFF #x28 #x94 #x28 #xFF #x2E #x88 #x2E #xFF #x41 #x61 #x41 #xFF #x35 #x7A #x35 #xFF #x27 #x96 #x27 #xFF #x22 #x9F #x22 #xFF #x3B #x16 #x5C #xFF #x20 #x0C #x6D #xFF #x1D #x0B #x6F #xFF #x28 #x94 #x28 #xFF #x2B #x8E #x2B #xFF #x2F #x87 #x2F #xFF #x27 #x96 #x27 #xFF #x45 #x19 #x56 #xFF #x1D #x0B #x6F #xFF #x09 #x03 #x7B #xFF #x2C #x8C #x2C #xFF #x1C #xAC #x1C #xFF #x2D #x8A #x2D #xFF #x26 #x98 #x26 #xFF #x33 #x7F #x33 #xFF #x03 #x01 #x7F #xFF #x03 #x01 #x7F #xFF #x1A #x09 #x71 #xFF #x28 #x94 #x28 #xFF #x19 #xCC #x00 #xFF #x1A #x09 #x71 #xFF #x00 #x00 #x82 #xFF #x1B #xAE #x1B #xFF #x31 #x12 #x62 #xFF #x24 #x9B #x24 #xFF #x1A #x09 #x71 #xFF #x58 #x21 #x49 #xFF #x86 #x32 #x2C #xFF #x80 #x30 #x30 #xFF #x3B #x16 #x5C #xFF #x4B #x1C #x51 #xFF #x06 #x02 #x7D #xFF #x26 #x98 #x26 #xFF #x10 #x06 #x77 #xFF #x25 #x99 #x25 #xFF #x28 #x94 #x28 #xFF #x32 #x81 #x32 #xFF #x4B #x4F #x4B #xFF #x2B #x8E #x2B #xFF #x1E #xA9 #x1E #xFF #x28 #x94 #x28 #xFF #x22 #x9F #x22 #xFF #x2B #x8E #x2B #xFF #x33 #x7F #x33 #xFF #x25 #x99 #x25 #xFF #x43 #x5F #x43 #xFF #x39 #x72 #x39 #xFF #x20 #x0C #x6D #xFF #x33 #x33 #xB5 #xFF #x25 #x99 #x25 #xFF #x1F #xA7 #x1F #xFF #x4E #x1D #x4F #xFF #x34 #x13 #x60 #xFF #x17 #x08 #x73 #xFF #x0D #x04 #x79 #xFF #x22 #xA1 #x22 #xFF #x1E #xA9 #x1E #xFF #x22 #x9F #x22 #xFF #x4B #x1C #x51 #xFF #x1A #xB0 #x1A #xFF #x35 #x7A #x35 #xFF #x39 #x72 #x39 #xFF #x13 #x07 #x75 #xFF #x1B #xAE #x1B #xFF #x3B #x16 #x5C #xFF #x27 #x0E #x68 #xFF #x19 #xB2 #x19 #xFF #x22 #x9F #x22 #xFF #x54 #x3C #x44 #xFF #x3B #x6F #x3B #xFF #x22 #x9F #x22 #xFF #x48 #x1B #x53 #xFF #x37 #x14 #x5E #xFF #x1A #xB0 #x1A #xFF #x33 #x33 #xB5 #xFF #x19 #xB2 #x19 #xFF #x31 #x83 #x31 #xFF #x27 #x96 #x27 #xFF #x2C #x8C #x2C #xFF #x06 #x02 #x7D #xFF #x10 #x06 #x77 #xFF #x03 #x01 #x7F #xFF #x1F #xA7 #x1F #xFF #x1E #xA9 #x1E #xFF #x20 #x0C #x6D #xFF #x24 #x0D #x6A #xFF #x20 #xA5 #x20 #xFF #x79 #x2D #x34 #xFF #x41 #x18 #x58 #xFF #x1D #xAA #x1D #xFF #x10 #x06 #x77 #xFF #x2E #x11 #x64 #xFF #x48 #x1B #x53 #xFF #x33 #x33 #xB5 #xFF #x41 #x18 #x58 #xFF #x10 #x06 #x77 #xFF #x22 #xA1 #x22 #xFF #x27 #x0E #x68 #xFF #x24 #x9B #x24 #xFF #x38 #x74 #x38 #xFF #x25 #x99 #x25 #xFF #x40 #x64 #x40 #xFF #x63 #x1D #x35 #xFF #x2A #x90 #x2A #xFF #x2B #x8E #x2B #xFF #x22 #xA1 #x22 #xFF #x26 #x98 #x26 #xFF #x3B #x6F #x3B #xFF #x48 #x54 #x48 #xFF #x23 #x9D #x23 #xFF #x2F #x87 #x2F #xFF #x2D #x8A #x2D #xFF #x2A #x90 #x2A #xFF #x22 #x9F #x22 #xFF #x1B #xAE #x1B #xFF #x55 #x20 #x4B #xFF #x83 #x31 #x2E #xFF #x34 #x13 #x60 #xFF #x52 #x1E #x4D #xFF #x2A #x10 #x66 #xFF #x1A #xB0 #x1A #xFF #x62 #x25 #x43 #xFF #x1D #x0B #x6F #xFF #x26 #x98 #x26 #xFF #x47 #x57 #x47 #xFF #x22 #xA1 #x22 #xFF #x20 #xA5 #x20 #xFF #x24 #x0D #x6A #xFF #x03 #x01 #x7F #xFF #x1E #xA9 #x1E #xFF #x24 #x0D #x6A #xFF #x21 #xA3 #x21 #xFF #x45 #x59 #x45 #xFF #x33 #x7F #x33 #xFF #x1B #xAE #x1B #xFF #x37 #x14 #x5E #xFF #x9D #x3B #x1D #xFF #x2E #x11 #x64 #xFF #x1D #x0B #x6F #xFF #x2A #x90 #x2A #xFF #x37 #x77 #x37 #xFF #x1A #xB0 #x1A #xFF #x1A #x09 #x71 #xFF #x13 #x07 #x75 #xFF #x22 #xA1 #x22 #xFF #x17 #x08 #x73 #xFF #x1A #xB0 #x1A #xFF #x10 #x06 #x77 #xFF #x52 #x1E #x4D #xFF #x0D #x04 #x79 #xFF #x00 #x00 #x82 #xFF #x45 #x19 #x56 #xFF #x1A #xB0 #x1A #xFF #x33 #x33 #xB5 #xFF #x28 #x94 #x28 #xFF #x10 #x06 #x77 #xFF #x6F #x29 #x3A #xFF #xBE #x47 #x08 #xFF #x27 #x0E #x68 #xFF #x0D #x04 #x79 #xFF #x22 #xA1 #x22 #xFF #x0D #x04 #x79 #xFF #x38 #x74 #x38 #xFF #x2D #x8A #x2D #xFF #x28 #x94 #x28 #xFF #x26 #x98 #x26 #xFF #x56 #x38 #x42 #xFF #x24 #x9B #x24 #xFF #x20 #xA5 #x20 #xFF #x35 #x7A #x35 #xFF #x32 #x81 #x32 #xFF #x33 #x7F #x33 #xFF #x3C #x6C #x3C #xFF #x19 #xB2 #x19 #xFF #x35 #x7A #x35 #xFF #x31 #x83 #x31 #xFF #x2B #x8E #x2B #xFF #x2A #x90 #x2A #xFF #x20 #x0C #x6D #xFF #x5F #x23 #x45 #xFF #x48 #x1B #x53 #xFF #x10 #x06 #x77 #xFF #x1D #x0B #x6F #xFF #x4B #x1C #x51 #xFF #x66 #x26 #x41 #xFF #x5C #x22 #x47 #xFF #x41 #x18 #x58 #xFF #x23 #x9D #x23 #xFF #x37 #x77 #x37 #xFF #x22 #x9F #x22 #xFF #x00 #x00 #x82 #xFF #x13 #x07 #x75 #xFF #x48 #x1B #x53 #xFF #x2A #x10 #x66 #xFF #x1D #xAA #x1D #xFF #x2B #x8E #x2B #xFF #x2E #x88 #x2E #xFF #x22 #x9F #x22 #xFF #x1A #xB0 #x1A #xFF #x10 #x06 #x77 #xFF #x62 #x25 #x43 #xFF #x1D #x0B #x6F #xFF #x1B #xAE #x1B #xFF #x30 #x85 #x30 #xFF #x20 #xA5 #x20 #xFF #x2E #x11 #x64 #xFF #x19 #xB2 #x19 #xFF #x58 #x21 #x49 #xFF #x4E #x1D #x4F #xFF #x58 #x21 #x49 #xFF #x03 #x01 #x7F #xFF #x1C #xAC #x1C #xFF #x03 #x01 #x7F #xFF #x2C #x8C #x2C #xFF #x22 #xA1 #x22 #xFF #x1E #xA9 #x1E #xFF #x40 #x64 #x40 #xFF #x24 #x0D #x6A #xFF #x19 #xB2 #x19 #xFF #x1A #xB0 #x1A #xFF #x09 #x03 #x7B #xFF #x03 #x01 #x7F #xFF #x20 #x0C #x6D #xFF #x1D #xAA #x1D #xFF #x1C #xAC #x1C #xFF #x22 #x9F #x22 #xFF #x22 #xA1 #x22 #xFF #x33 #x33 #xB5 #xFF #x23 #x9D #x23 #xFF #x49 #x51 #x49 #xFF #x3F #x67 #x3F #xFF #x38 #x74 #x38 #xFF #x34 #x7C #x34 #xFF #x26 #x98 #x26 #xFF #x3C #x6C #x3C #xFF #x3F #x67 #x3F #xFF #x2B #x8E #x2B #xFF #x09 #x03 #x7B #xFF #x35 #x7A #x35 #xFF #x37 #x77 #x37 #xFF #x29 #x92 #x29 #xFF #x38 #x74 #x38 #xFF #x1B #xAE #x1B #xFF #x37 #x14 #x5E #xFF #x5C #x22 #x47 #xFF #x2E #x11 #x64 #xFF #x20 #x0C #x6D #xFF #x76 #x2C #x36 #xFF #x45 #x19 #x56 #xFF #xB8 #x45 #x0C #xFF #x03 #x01 #x7F #xFF #x22 #x9F #x22 #xFF #x2A #x90 #x2A #xFF #x2E #x11 #x64 #xFF #x03 #x01 #x7F #xFF #x1F #xA7 #x1F #xFF #x1A #x09 #x71 #xFF #x03 #x01 #x7F #xFF #x38 #x74 #x38 #xFF #x34 #x7C #x34 #xFF #x4E #x48 #x4A #xFF #x38 #x74 #x38 #xFF #x1F #xA7 #x1F #xFF #x20 #xA5 #x20 #xFF #x1A #x09 #x71 #xFF #x3B #x16 #x5C #xFF #x13 #x07 #x75 #xFF #x27 #x0E #x68 #xFF #x79 #x2D #x34 #xFF #x1D #x0B #x6F #xFF #x03 #x01 #x7F #xFF #x45 #x19 #x56 #xFF #x09 #x03 #x7B #xFF #x4B #x1C #x51 #xFF #x21 #xA3 #x21 #xFF #x6C #x28 #x3C #xFF #x19 #xCC #x00 #xFF #x2B #x8E #x2B #xFF #x1D #x0B #x6F #xFF #x26 #x98 #x26 #xFF #x24 #x0D #x6A #xFF #x24 #x0D #x6A #xFF #x20 #x0C #x6D #xFF #x09 #x03 #x7B #xFF #x3E #x17 #x5A #xFF #x20 #x0C #x6D #xFF #x1C #xAC #x1C #xFF #x22 #xA1 #x22 #xFF #x22 #xA1 #x22 #xFF #x2C #x8C #x2C #xFF #x28 #x94 #x28 #xFF #x28 #x94 #x28 #xFF #x27 #x96 #x27 #xFF #x2A #x90 #x2A #xFF #x47 #x57 #x47 #xFF #x1A #xB0 #x1A #xFF #x31 #x83 #x31 #xFF #x2B #x8E #x2B #xFF #x4F #x46 #x49 #xFF #x5C #x2B #x3C #xFF #x3B #x6F #x3B #xFF #x25 #x99 #x25 #xFF #x2E #x88 #x2E #xFF #x1D #xAA #x1D #xFF #x33 #x33 #xB5 #xFF #x1F #xA7 #x1F #xFF #x0D #x04 #x79 #xFF #x17 #x08 #x73 #xFF #x4E #x1D #x4F #xFF #x76 #x2C #x36 #xFF #x34 #x13 #x60 #xFF #x48 #x1B #x53 #xFF #x34 #x13 #x60 #xFF #x37 #x14 #x5E #xFF #x1A #xB0 #x1A #xFF #x1C #xAC #x1C #xFF #x2A #x90 #x2A #xFF #x09 #x03 #x7B #xFF #x24 #x0D #x6A #xFF #x33 #x7F #x33 #xFF #x27 #x96 #x27 #xFF #x4B #x1C #x51 #xFF #x2C #x8C #x2C #xFF #x33 #x7F #x33 #xFF #x2C #x8C #x2C #xFF #x1E #xA9 #x1E #xFF #x41 #x61 #x41 #xFF #x52 #x1E #x4D #xFF #x1C #xAC #x1C #xFF #x24 #x0D #x6A #xFF #x1D #xAA #x1D #xFF #x3E #x17 #x5A #xFF #x73 #x2B #x38 #xFF #x76 #x2C #x36 #xFF #x1A #x09 #x71 #xFF #x19 #xB2 #x19 #xFF #x2E #x88 #x2E #xFF #x20 #xA5 #x20 #xFF #x03 #x01 #x7F #xFF #x31 #x12 #x62 #xFF #x33 #x33 #xB5 #xFF #x33 #x33 #xB5 #xFF #x2A #x10 #x66 #xFF #x1A #xB0 #x1A #xFF #x2A #x10 #x66 #xFF #x27 #x0E #x68 #xFF #x37 #x77 #x37 #xFF #x1B #xAE #x1B #xFF #x62 #x25 #x43 #xFF #x45 #x19 #x56 #xFF #x33 #x33 #xB5 #xFF #x13 #x07 #x75 #xFF #x25 #x99 #x25 #xFF #x1D #xAA #x1D #xFF #x19 #xCC #x00 #xFF #x20 #xA5 #x20 #xFF #x34 #x7C #x34 #xFF #x19 #xB2 #x19 #xFF #x31 #x83 #x31 #xFF #x2A #x90 #x2A #xFF #x40 #x64 #x40 #xFF #x35 #x7A #x35 #xFF #x4E #x48 #x4A #xFF #x52 #x40 #x46 #xFF #x43 #x5F #x43 #xFF #x3B #x6F #x3B #xFF #x34 #x7C #x34 #xFF #x28 #x94 #x28 #xFF #x19 #xB2 #x19 #xFF #x03 #x01 #x7F #xFF #x3B #x16 #x5C #xFF #x48 #x1B #x53 #xFF #x6C #x28 #x3C #xFF #x62 #x25 #x43 #xFF #x6F #x29 #x3A #xFF #x1A #xB0 #x1A #xFF #x7D #x2E #x32 #xFF #x48 #x1B #x53 #xFF #x6C #x28 #x3C #xFF #x2D #x8A #x2D #xFF #x52 #x40 #x46 #xFF #x29 #x92 #x29 #xFF #x1A #xB0 #x1A #xFF #x23 #x9D #x23 #xFF #x00 #x00 #x82 #xFF #x24 #x0D #x6A #xFF #x1D #xAA #x1D #xFF #x4B #x4F #x4B #xFF #x37 #x77 #x37 #xFF #x25 #x99 #x25 #xFF #x38 #x74 #x38 #xFF #x1E #xA9 #x1E #xFF #x4B #x1C #x51 #xFF #x03 #x01 #x7F #xFF #x1A #xB0 #x1A #xFF #x6F #x29 #x3A #xFF #x76 #x2C #x36 #xFF #x6F #x29 #x3A #xFF #x45 #x19 #x56 #xFF #x1A #xB0 #x1A #xFF #x1F #xA7 #x1F #xFF #x33 #x33 #xB5 #xFF #x1C #xAC #x1C #xFF #x17 #x08 #x73 #xFF #x3B #x16 #x5C #xFF #x20 #x0C #x6D #xFF #x1E #xA9 #x1E #xFF #x1D #xAA #x1D #xFF #x45 #x19 #x56 #xFF #x26 #x98 #x26 #xFF #x3C #x6C #x3C #xFF #x31 #x12 #x62 #xFF #x22 #xA1 #x22 #xFF #x1E #xA9 #x1E #xFF #x23 #x9D #x23 #xFF #x0D #x04 #x79 #xFF #x29 #x92 #x29 #xFF #x19 #xCC #x00 #xFF #x33 #x33 #xB5 #xFF #x31 #x12 #x62 #xFF #x2F #x87 #x2F #xFF #x33 #x33 #xB5 #xFF #x1D #x0B #x6F #xFF #x22 #x9F #x22 #xFF #x4B #x4F #x4B #xFF #x37 #x77 #x37 #xFF #x49 #x51 #x49 #xFF #x06 #x02 #x7D #xFF #x34 #x7C #x34 #xFF #x2D #x8A #x2D #xFF #x29 #x92 #x29 #xFF #x03 #x01 #x7F #xFF #x1F #xA7 #x1F #xFF #x24 #x0D #x6A #xFF #xB1 #x42 #x10 #xFF #xBC #x4A #x00 #xFF #x48 #x1B #x53 #xFF #x37 #x14 #x5E #xFF #x97 #x38 #x21 #xFF #x4E #x1D #x4F #xFF #x8A #x33 #x29 #xFF #x1C #xAC #x1C #xFF #x09 #x03 #x7B #xFF #x2A #x90 #x2A #xFF #x37 #x77 #x37 #xFF #x44 #x5C #x44 #xFF #x48 #x54 #x48 #xFF #x54 #x3C #x44 #xFF #x19 #xB2 #x19 #xFF #x2A #x90 #x2A #xFF #x31 #x83 #x31 #xFF #x1D #xAA #x1D #xFF #x3B #x6F #x3B #xFF #x31 #x83 #x31 #xFF #x41 #x61 #x41 #xFF #x1A #xB0 #x1A #xFF #x41 #x18 #x58 #xFF #x0D #x04 #x79 #xFF #x37 #x14 #x5E #xFF #x76 #x2C #x36 #xFF #x80 #x30 #x30 #xFF #x69 #x27 #x3E #xFF #x5F #x23 #x45 #xFF #x3B #x16 #x5C #xFF #x48 #x1B #x53 #xFF #x1A #x09 #x71 #xFF #x38 #x74 #x38 #xFF #x0D #x04 #x79 #xFF #x27 #x0E #x68 #xFF #x24 #x0D #x6A #xFF #x23 #x9D #x23 #xFF #x45 #x19 #x56 #xFF #x19 #xB2 #x19 #xFF #x4F #x46 #x49 #xFF #x09 #x03 #x7B #xFF #x20 #x0C #x6D #xFF #x28 #x94 #x28 #xFF #x32 #x81 #x32 #xFF #x1F #xA7 #x1F #xFF #x33 #x33 #xB5 #xFF #x51 #x42 #x47 #xFF #x19 #xB2 #x19 #xFF #x3E #x17 #x5A #xFF #x41 #x18 #x58 #xFF #x24 #x9B #x24 #xFF #x24 #x9B #x24 #xFF #x52 #x1E #x4D #xFF #x58 #x21 #x49 #xFF #x3B #x6F #x3B #xFF #x35 #x7A #x35 #xFF #x09 #x03 #x7B #xFF #x0D #x04 #x79 #xFF #x1A #xB0 #x1A #xFF #x00 #x00 #x82 #xFF #x1A #x09 #x71 #xFF #x1D #xAA #x1D #xFF #x1A #xB0 #x1A #xFF #x41 #x18 #x58 #xFF #x80 #x30 #x30 #xFF #xBF #x4A #x00 #xFF #x31 #x12 #x62 #xFF #x76 #x2C #x36 #xFF #x66 #x26 #x41 #xFF #x2E #x11 #x64 #xFF #x5C #x22 #x47 #xFF #x03 #x01 #x7F #xFF #x19 #xCC #x00 #xFF #x25 #x99 #x25 #xFF #x28 #x94 #x28 #xFF #x4C #x4C #x4C #xFF #x2C #x8C #x2C #xFF #x3B #x6F #x3B #xFF #x32 #x81 #x32 #xFF #x33 #x33 #xB5 #xFF #x2A #x90 #x2A #xFF #x35 #x7A #x35 #xFF #x54 #x3C #x44 #xFF #x3C #x6C #x3C #xFF #x48 #x54 #x48 #xFF #x37 #x14 #x5E #xFF #x3E #x17 #x5A #xFF #x1A #x09 #x71 #xFF #x37 #x14 #x5E #xFF #x86 #x32 #x2C #xFF #x80 #x30 #x30 #xFF #x48 #x1B #x53 #xFF #x1D #x0B #x6F #xFF #x45 #x19 #x56 #xFF #x13 #x07 #x75 #xFF #x2B #x8E #x2B #xFF #x28 #x94 #x28 #xFF #x23 #x9D #x23 #xFF #x1A #xB0 #x1A #xFF #x48 #x1B #x53 #xFF #x45 #x19 #x56 #xFF #xA7 #x3E #x17 #xFF #x20 #x0C #x6D #xFF #x33 #x7F #x33 #xFF #x20 #x0C #x6D #xFF #x21 #xA3 #x21 #xFF #x13 #x07 #x75 #xFF #x19 #xB2 #x19 #xFF #x26 #x98 #x26 #xFF #x03 #x01 #x7F #xFF #x56 #x38 #x42 #xFF #x1A #x09 #x71 #xFF #x1A #x09 #x71 #xFF #x79 #x2D #x34 #xFF #x1E #xA9 #x1E #xFF #x37 #x77 #x37 #xFF #x09 #x03 #x7B #xFF #x45 #x19 #x56 #xFF #x1A #xB0 #x1A #xFF #x49 #x51 #x49 #xFF #x1D #x0B #x6F #xFF #x24 #x0D #x6A #xFF #x33 #x33 #xB5 #xFF #x3B #x16 #x5C #xFF #x1A #xB0 #x1A #xFF #x21 #xA3 #x21 #xFF #x09 #x03 #x7B #xFF #x41 #x18 #x58 #xFF #x55 #x20 #x4B #xFF #xBB #x46 #x0A #xFF #x76 #x2C #x36 #xFF #x9D #x3B #x1D #xFF #x4E #x1D #x4F #xFF #x1F #xA7 #x1F #xFF #x1A #x09 #x71 #xFF #x19 #xB2 #x19 #xFF #x1D #x0B #x6F #xFF #x1F #xA7 #x1F #xFF #x25 #x99 #x25 #xFF #x2F #x87 #x2F #xFF #x2A #x90 #x2A #xFF #x26 #x98 #x26 #xFF #x34 #x7C #x34 #xFF #x1D #xAA #x1D #xFF #x26 #x98 #x26 #xFF #x31 #x83 #x31 #xFF #x61 #x21 #x37 #xFF #x2D #x8A #x2D #xFF #x32 #x81 #x32 #xFF #x1D #x0B #x6F #xFF #xBE #x47 #x08 #xFF #x24 #x0D #x6A #xFF #x37 #x14 #x5E #xFF #xAE #x41 #x12 #xFF #x9D #x3B #x1D #xFF #x4B #x1C #x51 #xFF #x1C #xAC #x1C #xFF #x24 #x0D #x6A #xFF #x17 #x08 #x73 #xFF #x1B #xAE #x1B #xFF #x2F #x87 #x2F #xFF #x35 #x7A #x35 #xFF #x32 #x81 #x32 #xFF #x45 #x19 #x56 #xFF #x58 #x21 #x49 #xFF #x55 #x20 #x4B #xFF #x76 #x2C #x36 #xFF #x69 #x27 #x3E #xFF #x37 #x14 #x5E #xFF #x06 #x02 #x7D #xFF #x31 #x12 #x62 #xFF #x2E #x11 #x64 #xFF #x48 #x1B #x53 #xFF #x1A #x09 #x71 #xFF #x2B #x8E #x2B #xFF #x3B #x16 #x5C #xFF #x76 #x2C #x36 #xFF #x1D #x0B #x6F #xFF #x25 #x99 #x25 #xFF #x1B #xAE #x1B #xFF #x4E #x1D #x4F #xFF #x69 #x27 #x3E #xFF #x19 #xB2 #x19 #xFF #x06 #x02 #x7D #xFF #x62 #x25 #x43 #xFF #x27 #x96 #x27 #xFF #x0D #x04 #x79 #xFF #x24 #x0D #x6A #xFF #x1A #xB0 #x1A #xFF #x1C #xAC #x1C #xFF #x1F #xA7 #x1F #xFF #x19 #xCC #x00 #xFF #x73 #x2B #x38 #xFF #xB1 #x42 #x10 #xFF #x37 #x14 #x5E #xFF #xA7 #x3E #x17 #xFF #x69 #x27 #x3E #xFF #x22 #xA1 #x22 #xFF #x2A #x90 #x2A #xFF #x3D #x6A #x3D #xFF #x19 #xB2 #x19 #xFF #x03 #x01 #x7F #xFF #x10 #x06 #x77 #xFF #x25 #x99 #x25 #xFF #x2B #x8E #x2B #xFF #x22 #xA1 #x22 #xFF #x48 #x54 #x48 #xFF #x22 #x9F #x22 #xFF #x3D #x6A #x3D #xFF #x38 #x74 #x38 #xFF #x3F #x67 #x3F #xFF #x41 #x61 #x41 #xFF #x24 #x0D #x6A #xFF #x45 #x19 #x56 #xFF #x34 #x13 #x60 #xFF #x21 #xA3 #x21 #xFF #x4E #x1D #x4F #xFF #x4E #x1D #x4F #xFF #x97 #x38 #x21 #xFF #x25 #x99 #x25 #xFF #x1B #xAE #x1B #xFF #x20 #x0C #x6D #xFF #x5C #x22 #x47 #xFF #x34 #x13 #x60 #xFF #x66 #x26 #x41 #xFF #x06 #x02 #x7D #xFF #x26 #x98 #x26 #xFF #x52 #x1E #x4D #xFF #x37 #x14 #x5E #xFF #x5F #x23 #x45 #xFF #x31 #x12 #x62 #xFF #x2E #x11 #x64 #xFF #x21 #xA3 #x21 #xFF #x1D #xAA #x1D #xFF #x1F #xA7 #x1F #xFF #x31 #x12 #x62 #xFF #x34 #x13 #x60 #xFF #x17 #x08 #x73 #xFF #x19 #xCC #x00 #xFF #x58 #x21 #x49 #xFF #x52 #x1E #x4D #xFF #x2B #x8E #x2B #xFF #x22 #xA1 #x22 #xFF #x2A #x90 #x2A #xFF #x2A #x10 #x66 #xFF #x1C #xAC #x1C #xFF #x4B #x1C #x51 #xFF #x27 #x96 #x27 #xFF #x5C #x22 #x47 #xFF #x1C #xAC #x1C #xFF #x22 #x9F #x22 #xFF #x1D #xAA #x1D #xFF #x09 #x03 #x7B #xFF #x21 #xA3 #x21 #xFF #x3B #x6F #x3B #xFF #x34 #x7C #x34 #xFF #x1D #x0B #x6F #xFF #xA8 #x48 #x00 #xFF #x17 #x08 #x73 #xFF #x94 #x37 #x23 #xFF #x48 #x1B #x53 #xFF #x1E #xA9 #x1E #xFF #x4D #x4A #x4B #xFF #x2F #x87 #x2F #xFF #x27 #x0E #x68 #xFF #x34 #x13 #x60 #xFF #x3B #x16 #x5C #xFF #x09 #x03 #x7B #xFF #x22 #x9F #x22 #xFF #x66 #x26 #x41 #xFF #x28 #x94 #x28 #xFF #x13 #x07 #x75 #xFF #x24 #x9B #x24 #xFF #x44 #x5C #x44 #xFF #x29 #x92 #x29 #xFF #x29 #x92 #x29 #xFF #x27 #x0E #x68 #xFF #x69 #x27 #x3E #xFF #x2A #x90 #x2A #xFF #x17 #x08 #x73 #xFF #x58 #x21 #x49 #xFF #x48 #x1B #x53 #xFF #x2A #x10 #x66 #xFF #x25 #x99 #x25 #xFF #x26 #x98 #x26 #xFF #x17 #x08 #x73 #xFF #x2E #x11 #x64 #xFF #x1C #xAC #x1C #xFF #x3E #x17 #x5A #xFF #x7D #x2E #x32 #xFF #x23 #x9D #x23 #xFF #x4B #x1C #x51 #xFF #x2A #x10 #x66 #xFF #xC2 #x4B #x00 #xFF #x5C #x22 #x47 #xFF #x31 #x12 #x62 #xFF #x19 #xCC #x00 #xFF #x34 #x13 #x60 #xFF #x48 #x1B #x53 #xFF #x1D #xAA #x1D #xFF #x00 #x00 #x82 #xFF #x66 #x26 #x41 #xFF #x1A #x09 #x71 #xFF #x1D #x0B #x6F #xFF #x3B #x16 #x5C #xFF #x27 #x0E #x68 #xFF #x5A #x2F #x3E #xFF #x41 #x61 #x41 #xFF #x22 #xA1 #x22 #xFF #x19 #xB2 #x19 #xFF #x1F #xA7 #x1F #xFF #x17 #x08 #x73 #xFF #x24 #x0D #x6A #xFF #x1D #xAA #x1D #xFF #x20 #x0C #x6D #xFF #x6C #x28 #x3C #xFF #x52 #x1E #x4D #xFF #x37 #x14 #x5E #xFF #x33 #x33 #xB5 #xFF #x3C #x6C #x3C #xFF #x25 #x99 #x25 #xFF #x80 #x30 #x30 #xFF #x76 #x2C #x36 #xFF #x73 #x2B #x38 #xFF #x1D #x0B #x6F #xFF #x10 #x06 #x77 #xFF #x21 #xA3 #x21 #xFF #x3B #x16 #x5C #xFF #x19 #xB2 #x19 #xFF #x06 #x02 #x7D #xFF #x19 #xCC #x00 #xFF #x1D #xAA #x1D #xFF #x1D #x0B #x6F #xFF #x69 #x27 #x3E #xFF #x1D #xAA #x1D #xFF #x03 #x01 #x7F #xFF #x21 #xA3 #x21 #xFF #x2D #x8A #x2D #xFF #x1F #xA7 #x1F #xFF #x17 #x08 #x73 #xFF #x03 #x01 #x7F #xFF #x27 #x0E #x68 #xFF #x2F #x87 #x2F #xFF #x27 #x96 #x27 #xFF #x6C #x28 #x3C #xFF #x24 #x0D #x6A #xFF #x55 #x20 #x4B #xFF #x19 #xCC #x00 #xFF #x19 #xB2 #x19 #xFF #x34 #x13 #x60 #xFF #x37 #x14 #x5E #xFF #x6C #x28 #x3C #xFF #x55 #x20 #x4B #xFF #x3B #x16 #x5C #xFF #x21 #xA3 #x21 #xFF #x17 #x08 #x73 #xFF #x17 #x08 #x73 #xFF #x9A #x39 #x1F #xFF #xAE #x41 #x12 #xFF #x8A #x33 #x29 #xFF #x33 #x33 #xB5 #xFF #x83 #x31 #x2E #xFF #x2A #x10 #x66 #xFF #x10 #x06 #x77 #xFF #x03 #x01 #x7F #xFF #x34 #x13 #x60 #xFF #x2A #x10 #x66 #xFF #x19 #xB2 #x19 #xFF #x3E #x17 #x5A #xFF #x5C #x22 #x47 #xFF #x49 #x51 #x49 #xFF #x5F #x25 #x39 #xFF #x4B #x4F #x4B #xFF #x03 #x01 #x7F #xFF #x1D #xAA #x1D #xFF #x34 #x13 #x60 #xFF #x1F #xA7 #x1F #xFF #x45 #x19 #x56 #xFF #x06 #x02 #x7D #xFF #x58 #x21 #x49 #xFF #x17 #x08 #x73 #xFF #x9D #x3B #x1D #xFF #x1D #xAA #x1D #xFF #x20 #x0C #x6D #xFF #x29 #x92 #x29 #xFF #x3E #x17 #x5A #xFF #x6C #x28 #x3C #xFF #x83 #x31 #x2E #xFF #x1D #x0B #x6F #xFF #x34 #x13 #x60 #xFF #x4E #x1D #x4F #xFF #x1D #x0B #x6F #xFF #x1E #xA9 #x1E #xFF #x4B #x1C #x51 #xFF #x22 #x9F #x22 #xFF #x30 #x85 #x30 #xFF #x20 #xA5 #x20 #xFF #x80 #x30 #x30 #xFF #x19 #xB2 #x19 #xFF #x45 #x59 #x45 #xFF #x03 #x01 #x7F #xFF #x2C #x8C #x2C #xFF #x24 #x9B #x24 #xFF #x10 #x06 #x77 #xFF #x5C #x22 #x47 #xFF #x00 #x00 #x82 #xFF #x21 #xA3 #x21 #xFF #x1C #xAC #x1C #xFF #x5F #x23 #x45 #xFF #x34 #x13 #x60 #xFF #x8A #x33 #x29 #xFF #x41 #x18 #x58 #xFF #x20 #x0C #x6D #xFF #x24 #x0D #x6A #xFF #x10 #x06 #x77 #xFF #x2A #x10 #x66 #xFF #x6F #x29 #x3A #xFF #x27 #x0E #x68 #xFF #x2E #x11 #x64 #xFF #x3B #x16 #x5C #xFF #x7D #x2E #x32 #xFF #xC2 #x48 #x06 #xFF #xA1 #x3C #x1B #xFF #x69 #x27 #x3E #xFF #x1A #xB0 #x1A #xFF #x3B #x16 #x5C #xFF #x5C #x22 #x47 #xFF #x26 #x98 #x26 #xFF #x1E #xA9 #x1E #xFF #x34 #x13 #x60 #xFF #x0D #x04 #x79 #xFF #x41 #x18 #x58 #xFF #x52 #x1E #x4D #xFF #x52 #x1E #x4D #xFF #x51 #x42 #x47 #xFF #x4D #x4A #x4B #xFF #x41 #x61 #x41 #xFF #x58 #x21 #x49 #xFF #x24 #x0D #x6A #xFF #x55 #x20 #x4B #xFF #x1A #xB0 #x1A #xFF #x45 #x19 #x56 #xFF #x94 #x37 #x23 #xFF #x1E #xA9 #x1E #xFF #x83 #x31 #x2E #xFF #x2E #x11 #x64 #xFF #x7D #x2E #x32 #xFF #x20 #x0C #x6D #xFF #x27 #x96 #x27 #xFF #x34 #x13 #x60 #xFF #x9A #x39 #x1F #xFF #x97 #x38 #x21 #xFF #x66 #x26 #x41 #xFF #xAE #x41 #x12 #xFF #x76 #x2C #x36 #xFF #x27 #x0E #x68 #xFF #x17 #x08 #x73 #xFF #x5F #x23 #x45 #xFF #x1B #xAE #x1B #xFF #x22 #x9F #x22 #xFF #x2C #x8C #x2C #xFF #x45 #x19 #x56 #xFF #x1D #xAA #x1D #xFF #x53 #x3E #x45 #xFF #x1D #xAA #x1D #xFF #x2C #x8C #x2C #xFF #x21 #xA3 #x21 #xFF #x13 #x07 #x75 #xFF #x5F #x23 #x45 #xFF #x69 #x27 #x3E #xFF #x55 #x20 #x4B #xFF #x37 #x14 #x5E #xFF #x45 #x19 #x56 #xFF #x09 #x03 #x7B #xFF #x66 #x26 #x41 #xFF #x55 #x20 #x4B #xFF #x17 #x08 #x73 #xFF #x17 #x08 #x73 #xFF #x27 #x0E #x68 #xFF #x1A #xB0 #x1A #xFF #x55 #x20 #x4B #xFF #xBE #x47 #x08 #xFF #x69 #x27 #x3E #xFF #x86 #x32 #x2C #xFF #xA1 #x3C #x1B #xFF #x97 #x38 #x21 #xFF #xBE #x47 #x08 #xFF #x20 #x0C #x6D #xFF #x17 #x08 #x73 #xFF #x79 #x2D #x34 #xFF #x19 #xCC #x00 #xFF #x23 #x9D #x23 #xFF #x33 #x33 #xB5 #xFF #x13 #x07 #x75 #xFF #x3E #x17 #x5A #xFF #x3B #x6F #x3B #xFF #x1D #x0B #x6F #xFF #x5C #x22 #x47 #xFF #x33 #x7F #x33 #xFF #x3F #x67 #x3F #xFF #x40 #x64 #x40 #xFF #x33 #x33 #xB5 #xFF #x37 #x14 #x5E #xFF #x31 #x12 #x62 #xFF #x0D #x04 #x79 #xFF #x7D #x2E #x32 #xFF #xB8 #x45 #x0C #xFF #x27 #x0E #x68 #xFF #x41 #x18 #x58 #xFF #x1D #x0B #x6F #xFF #x80 #x30 #x30 #xFF #x4E #x1D #x4F #xFF #x3B #x16 #x5C #xFF #x86 #x32 #x2C #xFF #x94 #x37 #x23 #xFF #xA7 #x3E #x17 #xFF #x80 #x30 #x30 #xFF #x97 #x38 #x21 #xFF #x86 #x32 #x2C #xFF #x1D #x0B #x6F #xFF #x94 #x37 #x23 #xFF #x62 #x25 #x43 #xFF #x10 #x06 #x77 #xFF #x32 #x81 #x32 #xFF #x21 #xA3 #x21 #xFF #x27 #x0E #x68 #xFF #x21 #xA3 #x21 #xFF #x2E #x88 #x2E #xFF #x25 #x99 #x25 #xFF #x2D #x8A #x2D #xFF #x20 #x0C #x6D #xFF #x2B #x8E #x2B #xFF #x4E #x1D #x4F #xFF #x80 #x30 #x30 #xFF #x6F #x29 #x3A #xFF #xAB #x40 #x14 #xFF #x4E #x1D #x4F #xFF #x06 #x02 #x7D #xFF #x24 #x0D #x6A #xFF #x83 #x31 #x2E #xFF #x00 #x00 #x82 #xFF #x31 #x12 #x62 #xFF #x45 #x19 #x56 #xFF #x34 #x13 #x60 #xFF #x52 #x1E #x4D #xFF #x90 #x36 #x25 #xFF #x79 #x2D #x34 #xFF #xA7 #x3E #x17 #xFF #x9A #x39 #x1F #xFF #x9C #x46 #x00 #xFF #xC5 #x4B #x00 #xFF #x34 #x13 #x60 #xFF #x19 #xCC #x00 #xFF #x3E #x17 #x5A #xFF #x19 #xB2 #x19 #xFF #x24 #x9B #x24 #xFF #x1D #x0B #x6F #xFF #x20 #xA5 #x20 #xFF #x20 #xA5 #x20 #xFF #x1D #xAA #x1D #xFF #x21 #xA3 #x21 #xFF #x4B #x1C #x51 #xFF #x21 #xA3 #x21 #xFF #x45 #x59 #x45 #xFF #x31 #x83 #x31 #xFF #x5F #x23 #x45 #xFF #x03 #x01 #x7F #xFF #x55 #x20 #x4B #xFF #x31 #x12 #x62 #xFF #x66 #x26 #x41 #xFF #xB8 #x45 #x0C #xFF #x2E #x11 #x64 #xFF #x7D #x2E #x32 #xFF #x27 #x0E #x68 #xFF #x0D #x04 #x79 #xFF #x9D #x3B #x1D #xFF #x6C #x28 #x3C #xFF #x6C #x28 #x3C #xFF #x3E #x17 #x5A #xFF #xBB #x46 #x0A #xFF #x73 #x2B #x38 #xFF #x9D #x3B #x1D #xFF #x21 #xA3 #x21 #xFF #x66 #x26 #x41 #xFF #x3E #x17 #x5A #xFF #x03 #x01 #x7F #xFF #x19 #xCC #x00 #xFF #x20 #x0C #x6D #xFF #x1A #xB0 #x1A #xFF #x55 #x20 #x4B #xFF #x21 #xA3 #x21 #xFF #x2A #x90 #x2A #xFF #x2E #x88 #x2E #xFF #x21 #xA3 #x21 #xFF #x30 #x85 #x30 #xFF #x26 #x98 #x26 #xFF #x4E #x1D #x4F #xFF #x58 #x21 #x49 #xFF #x97 #x38 #x21 #xFF #xB1 #x42 #x10 #xFF #x66 #x26 #x41 #xFF #x06 #x02 #x7D #xFF #x37 #x14 #x5E #xFF #x2E #x11 #x64 #xFF #x1A #x09 #x71 #xFF #x41 #x18 #x58 #xFF #x1D #x0B #x6F #xFF #x7D #x2E #x32 #xFF #x41 #x18 #x58 #xFF #xA1 #x3C #x1B #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #xB8 #x45 #x0C #xFF #xB2 #x49 #x00 #xFF #xC8 #x4B #x02 #xFF #x41 #x18 #x58 #xFF #x03 #x01 #x7F #xFF #x34 #x13 #x60 #xFF #x22 #xA1 #x22 #xFF #x25 #x99 #x25 #xFF #x20 #x0C #x6D #xFF #x1A #x09 #x71 #xFF #x22 #xA1 #x22 #xFF #x26 #x98 #x26 #xFF #x10 #x06 #x77 #xFF #x03 #x01 #x7F #xFF #x1B #xAE #x1B #xFF #x3F #x67 #x3F #xFF #x30 #x85 #x30 #xFF #x86 #x32 #x2C #xFF #x19 #xB2 #x19 #xFF #x41 #x18 #x58 #xFF #x2A #x10 #x66 #xFF #x6C #x28 #x3C #xFF #x90 #x36 #x25 #xFF #x37 #x14 #x5E #xFF #x4E #x1D #x4F #xFF #x19 #xB2 #x19 #xFF #x48 #x1B #x53 #xFF #x94 #x37 #x23 #xFF #x1A #xB0 #x1A #xFF #x48 #x1B #x53 #xFF #x5F #x23 #x45 #xFF #x34 #x13 #x60 #xFF #x55 #x20 #x4B #xFF #x34 #x13 #x60 #xFF #x1E #xA9 #x1E #xFF #x19 #xB2 #x19 #xFF #x1D #x0B #x6F #xFF #x33 #x33 #xB5 #xFF #x3E #x17 #x5A #xFF #x33 #x33 #xB5 #xFF #x1A #x09 #x71 #xFF #x24 #x0D #x6A #xFF #x32 #x81 #x32 #xFF #x37 #x77 #x37 #xFF #x76 #x2C #x36 #xFF #x20 #xA5 #x20 #xFF #x2B #x8E #x2B #xFF #x00 #x00 #x82 #xFF #x9A #x39 #x1F #xFF #x4E #x1D #x4F #xFF #xA7 #x3E #x17 #xFF #x9A #x39 #x1F #xFF #x4B #x1C #x51 #xFF #x27 #x0E #x68 #xFF #x76 #x2C #x36 #xFF #x55 #x20 #x4B #xFF #x4E #x1D #x4F #xFF #x4B #x1C #x51 #xFF #x5C #x22 #x47 #xFF #x37 #x14 #x5E #xFF #x37 #x14 #x5E #xFF #x80 #x30 #x30 #xFF #x8A #x33 #x29 #xFF #x8D #x35 #x27 #xFF #x83 #x31 #x2E #xFF #x7D #x2E #x32 #xFF #x6C #x28 #x3C #xFF #x19 #xB2 #x19 #xFF #x1F #xA7 #x1F #xFF #x00 #x00 #x82 #xFF #x33 #x33 #xB5 #xFF #x2A #x90 #x2A #xFF #x2E #x11 #x64 #xFF #x45 #x19 #x56 #xFF #x1D #x0B #x6F #xFF #x2A #x90 #x2A #xFF #x26 #x98 #x26 #xFF #x2A #x90 #x2A #xFF #x24 #x9B #x24 #xFF #x53 #x3E #x45 #xFF #x19 #xCC #x00 #xFF #x19 #xCC #x00 #xFF #x33 #x33 #xB5 #xFF #x1D #x0B #x6F #xFF #x48 #x1B #x53 #xFF #xA8 #x48 #x00 #xFF #x4B #x1C #x51 #xFF #x34 #x13 #x60 #xFF #x24 #x0D #x6A #xFF #x27 #x0E #x68 #xFF #x00 #x00 #x82 #xFF #x48 #x1B #x53 #xFF #x45 #x19 #x56 #xFF #x4E #x1D #x4F #xFF #x27 #x0E #x68 #xFF #x00 #x00 #x82 #xFF #x13 #x07 #x75 #xFF #x00 #x00 #x82 #xFF #x26 #x98 #x26 #xFF #x1D #x0B #x6F #xFF #x06 #x02 #x7D #xFF #x06 #x02 #x7D #xFF #x34 #x13 #x60 #xFF #x2C #x8C #x2C #xFF #x00 #x00 #x82 #xFF #x24 #x9B #x24 #xFF #x2A #x90 #x2A #xFF #x32 #x81 #x32 #xFF #x45 #x19 #x56 #xFF #x06 #x02 #x7D #xFF #x22 #x9F #x22 #xFF #x06 #x02 #x7D #xFF #xC5 #x4A #x04 #xFF #x7D #x2E #x32 #xFF #x83 #x31 #x2E #xFF #x94 #x37 #x23 #xFF #x4B #x1C #x51 #xFF #x06 #x02 #x7D #xFF #x1D #x0B #x6F #xFF #x80 #x30 #x30 #xFF #x6F #x29 #x3A #xFF #x6F #x29 #x3A #xFF #x41 #x18 #x58 #xFF #x45 #x19 #x56 #xFF #x24 #x0D #x6A #xFF #x31 #x12 #x62 #xFF #x52 #x1E #x4D #xFF #x79 #x2D #x34 #xFF #x4B #x1C #x51 #xFF #x90 #x36 #x25 #xFF #x76 #x2C #x36 #xFF #x3E #x17 #x5A #xFF #x20 #x0C #x6D #xFF #x1D #xAA #x1D #xFF #x03 #x01 #x7F #xFF #x32 #x81 #x32 #xFF #x2E #x88 #x2E #xFF #x34 #x13 #x60 #xFF #x66 #x26 #x41 #xFF #x20 #xA5 #x20 #xFF #x37 #x77 #x37 #xFF #x47 #x57 #x47 #xFF #x3C #x6C #x3C #xFF #x29 #x92 #x29 #xFF #x33 #x33 #xB5 #xFF #x1A #x09 #x71 #xFF #x20 #x0C #x6D #xFF #x2E #x11 #x64 #xFF #x5F #x23 #x45 #xFF #xBB #x46 #x0A #xFF #x34 #x13 #x60 #xFF #x3E #x17 #x5A #xFF #x06 #x02 #x7D #xFF #x13 #x07 #x75 #xFF #x1A #x09 #x71 #xFF #x66 #x26 #x41 #xFF #x48 #x1B #x53 #xFF #x55 #x20 #x4B #xFF #x09 #x03 #x7B #xFF #x21 #xA3 #x21 #xFF #x33 #x7F #x33 #xFF #x1B #xAE #x1B #xFF #x27 #x0E #x68 #xFF #x1E #xA9 #x1E #xFF #x2F #x87 #x2F #xFF #x10 #x06 #x77 #xFF #x24 #x0D #x6A #xFF #x28 #x94 #x28 #xFF #x13 #x07 #x75 #xFF #x44 #x5C #x44 #xFF #x2C #x8C #x2C #xFF #x1B #xAE #x1B #xFF #x4E #x1D #x4F #xFF #x33 #x33 #xB5 #xFF #x2D #x8A #x2D #xFF #x0D #x04 #x79 #xFF #xC5 #x4B #x00 #xFF #xC2 #x48 #x06 #xFF #x76 #x2C #x36 #xFF #x48 #x1B #x53 #xFF #x13 #x07 #x75 #xFF #x21 #xA3 #x21 #xFF #x33 #x33 #xB5 #xFF #x76 #x2C #x36 #xFF #x86 #x32 #x2C #xFF #xC5 #x4A #x04 #xFF #x4B #x1C #x51 #xFF #x3B #x16 #x5C #xFF #x1C #xAC #x1C #xFF #x20 #x0C #x6D #xFF #x62 #x25 #x43 #xFF #x79 #x2D #x34 #xFF #x1A #x09 #x71 #xFF #x37 #x14 #x5E #xFF #x0D #x04 #x79 #xFF #x29 #x92 #x29 #xFF #x2A #x10 #x66 #xFF #x1A #xB0 #x1A #xFF #x2D #x8A #x2D #xFF #x1F #xA7 #x1F #xFF #x22 #xA1 #x22 #xFF #x37 #x14 #x5E #xFF #x3E #x17 #x5A #xFF #x34 #x13 #x60 #xFF #x40 #x64 #x40 #xFF #x39 #x72 #x39 #xFF #x10 #x06 #x77 #xFF #x2A #x10 #x66 #xFF #x1D #x0B #x6F #xFF #x31 #x12 #x62 #xFF #x17 #x08 #x73 #xFF #x76 #x2C #x36 #xFF #x3B #x16 #x5C #xFF #x13 #x07 #x75 #xFF #x19 #xCC #x00 #xFF #x1A #x09 #x71 #xFF #x1D #x0B #x6F #xFF #x1F #xA7 #x1F #xFF #x22 #xA1 #x22 #xFF #x5C #x22 #x47 #xFF #xA7 #x3E #x17 #xFF #x55 #x20 #x4B #xFF #x03 #x01 #x7F #xFF #x06 #x02 #x7D #xFF #x06 #x02 #x7D #xFF #x19 #xB2 #x19 #xFF #x3B #x16 #x5C #xFF #x33 #x7F #x33 #xFF #x38 #x74 #x38 #xFF #x1C #xAC #x1C #xFF #x03 #x01 #x7F #xFF #x3C #x6C #x3C #xFF #x2B #x8E #x2B #xFF #x2A #x90 #x2A #xFF #x39 #x72 #x39 #xFF #x2A #x10 #x66 #xFF #x4B #x1C #x51 #xFF #x24 #x0D #x6A #xFF #x24 #x0D #x6A #xFF #x37 #x77 #x37 #xFF #x13 #x07 #x75 #xFF #x80 #x30 #x30 #xFF #x86 #x32 #x2C #xFF #x00 #x00 #x82 #xFF #x27 #x0E #x68 #xFF #x1B #xAE #x1B #xFF #x20 #x0C #x6D #xFF #x9A #x39 #x1F #xFF #xBE #x47 #x08 #xFF #xA1 #x3C #x1B #xFF #xB4 #x43 #x0E #xFF #x45 #x19 #x56 #xFF #x20 #xA5 #x20 #xFF #x1A #x09 #x71 #xFF #xB4 #x43 #x0E #xFF #x52 #x1E #x4D #xFF #x73 #x2B #x38 #xFF #xA1 #x3C #x1B #xFF #x24 #x0D #x6A #xFF #x1F #xA7 #x1F #xFF #x13 #x07 #x75 #xFF #x00 #x00 #x82 #xFF #x0D #x04 #x79 #xFF #x09 #x03 #x7B #xFF #x06 #x02 #x7D #xFF #x29 #x92 #x29 #xFF #x37 #x14 #x5E #xFF #x31 #x12 #x62 #xFF #x19 #xB2 #x19 #xFF #x21 #xA3 #x21 #xFF #x3E #x17 #x5A #xFF #x2A #x10 #x66 #xFF #xA7 #x3E #x17 #xFF #xB1 #x42 #x10 #xFF #x20 #xA5 #x20 #xFF #x10 #x06 #x77 #xFF #x1D #x0B #x6F #xFF #x22 #xA1 #x22 #xFF #x22 #xA1 #x22 #xFF #x69 #x27 #x3E #xFF #x1A #x09 #x71 #xFF #x06 #x02 #x7D #xFF #x37 #x14 #x5E #xFF #x5C #x22 #x47 #xFF #x97 #x38 #x21 #xFF #x73 #x2B #x38 #xFF #x73 #x2B #x38 #xFF #x22 #x9F #x22 #xFF #x19 #xB2 #x19 #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x1A #xB0 #x1A #xFF #x48 #x54 #x48 #xFF #x1E #xA9 #x1E #xFF #x20 #xA5 #x20 #xFF #x41 #x61 #x41 #xFF #x31 #x12 #x62 #xFF #x2A #x90 #x2A #xFF #x1E #xA9 #x1E #xFF #x3E #x17 #x5A #xFF #x58 #x21 #x49 #xFF #x21 #xA3 #x21 #xFF #x31 #x12 #x62 #xFF #x24 #x9B #x24 #xFF #x2E #x11 #x64 #xFF #x34 #x13 #x60 #xFF #x2A #x10 #x66 #xFF #x1A #xB0 #x1A #xFF #x33 #x33 #xB5 #xFF #x23 #x9D #x23 #xFF #x19 #xCC #x00 #xFF #x48 #x1B #x53 #xFF #x6C #x28 #x3C #xFF #x62 #x25 #x43 #xFF #x97 #x38 #x21 #xFF #x55 #x20 #x4B #xFF #x37 #x14 #x5E #xFF #x0D #x04 #x79 #xFF #x03 #x01 #x7F #xFF #x4B #x1C #x51 #xFF #x2E #x11 #x64 #xFF #x3E #x17 #x5A #xFF #x1D #x0B #x6F #xFF #x27 #x96 #x27 #xFF #x2E #x11 #x64 #xFF #x48 #x1B #x53 #xFF #x06 #x02 #x7D #xFF #x37 #x14 #x5E #xFF #x06 #x02 #x7D #xFF #x3B #x16 #x5C #xFF #x4B #x1C #x51 #xFF #x4B #x1C #x51 #xFF #x09 #x03 #x7B #xFF #x1A #xB0 #x1A #xFF #x34 #x13 #x60 #xFF #x1A #xB0 #x1A #xFF #xB1 #x42 #x10 #xFF #xA4 #x3D #x19 #xFF #x2C #x8C #x2C #xFF #x24 #x0D #x6A #xFF #x06 #x02 #x7D #xFF #x31 #x83 #x31 #xFF #x30 #x85 #x30 #xFF #x4E #x1D #x4F #xFF #x2A #x10 #x66 #xFF #x2B #x8E #x2B #xFF #x37 #x14 #x5E #xFF #x3B #x16 #x5C #xFF #x62 #x25 #x43 #xFF #x00 #x00 #x82 #xFF #x0D #x04 #x79 #xFF #x1E #xA9 #x1E #xFF #x1D #xAA #x1D #xFF #x41 #x18 #x58 #xFF #x19 #xB2 #x19 #xFF #x37 #x14 #x5E #xFF #x3C #x6C #x3C #xFF #x1B #xAE #x1B #xFF #x21 #xA3 #x21 #xFF #x22 #x9F #x22 #xFF #x20 #xA5 #x20 #xFF #x34 #x13 #x60 #xFF #x1D #xAA #x1D #xFF #x45 #x19 #x56 #xFF #x52 #x1E #x4D #xFF #x1C #xAC #x1C #xFF #x29 #x92 #x29 #xFF #x2A #x90 #x2A #xFF #x34 #x13 #x60 #xFF #x0D #x04 #x79 #xFF #x4E #x1D #x4F #xFF #x28 #x94 #x28 #xFF #x24 #x9B #x24 #xFF #x34 #x13 #x60 #xFF #x23 #x9D #x23 #xFF #x28 #x94 #x28 #xFF #x2A #x90 #x2A #xFF #x00 #x00 #x82 #xFF #x80 #x30 #x30 #xFF #x37 #x14 #x5E #xFF #x03 #x01 #x7F #xFF #x30 #x85 #x30 #xFF #x1F #xA7 #x1F #xFF #x24 #x0D #x6A #xFF #x1E #xA9 #x1E #xFF #x03 #x01 #x7F #xFF #x76 #x2C #x36 #xFF #x1D #xAA #x1D #xFF #x6C #x28 #x3C #xFF #x34 #x13 #x60 #xFF #x22 #x9F #x22 #xFF #x3B #x16 #x5C #xFF #x1C #xAC #x1C #xFF #x1C #xAC #x1C #xFF #x31 #x12 #x62 #xFF #x5F #x23 #x45 #xFF #x27 #x0E #x68 #xFF #x19 #xCC #x00 #xFF #x4B #x1C #x51 #xFF #x9A #x39 #x1F #xFF #x79 #x2D #x34 #xFF #x83 #x31 #x2E #xFF #x62 #x25 #x43 #xFF #x3B #x16 #x5C #xFF #x2B #x8E #x2B #xFF #x24 #x9B #x24 #xFF #x2A #x10 #x66 #xFF #x3B #x16 #x5C #xFF #x1D #xAA #x1D #xFF #x22 #xA1 #x22 #xFF #x20 #xA5 #x20 #xFF #x5F #x23 #x45 #xFF #x4B #x1C #x51 #xFF #x1A #xB0 #x1A #xFF #x29 #x92 #x29 #xFF #x22 #x9F #x22 #xFF #x30 #x85 #x30 #xFF #x19 #xB2 #x19 #xFF #x24 #x0D #x6A #xFF #x6F #x29 #x3A #xFF #x1C #xAC #x1C #xFF #x06 #x02 #x7D #xFF #x19 #xCC #x00 #xFF #x19 #xCC #x00 #xFF #x37 #x77 #x37 #xFF #x13 #x07 #x75 #xFF #x20 #x0C #x6D #xFF #x86 #x32 #x2C #xFF #x76 #x2C #x36 #xFF #x2A #x10 #x66 #xFF #x30 #x85 #x30 #xFF #x34 #x7C #x34 #xFF #x2A #x90 #x2A #xFF #x06 #x02 #x7D #xFF #x17 #x08 #x73 #xFF #x38 #x74 #x38 #xFF #x39 #x72 #x39 #xFF #x3B #x16 #x5C #xFF #x00 #x00 #x82 #xFF #x24 #x0D #x6A #xFF #x2D #x8A #x2D #xFF #x1A #xB0 #x1A #xFF #x76 #x2C #x36 #xFF #x58 #x21 #x49 #xFF #x33 #x33 #xB5 #xFF #x19 #xCC #x00 #xFF #x1A #xB0 #x1A #xFF #x73 #x2B #x38 #xFF #x6C #x28 #x3C #xFF #x69 #x27 #x3E #xFF #x9C #x46 #x00 #xFF #x4B #x1C #x51 #xFF #x4E #x1D #x4F #xFF #x0D #x04 #x79 #xFF #x21 #xA3 #x21 #xFF #x21 #xA3 #x21 #xFF #x13 #x07 #x75 #xFF #x1C #xAC #x1C #xFF #x24 #x0D #x6A #xFF #x45 #x19 #x56 #xFF #x2E #x11 #x64 #xFF #x3B #x16 #x5C #xFF #x31 #x12 #x62 #xFF #xB1 #x42 #x10 #xFF #x3B #x16 #x5C #xFF #x4B #x1C #x51 #xFF #x9A #x39 #x1F #xFF #x2A #x10 #x66 #xFF #x2F #x87 #x2F #xFF #x03 #x01 #x7F #xFF #x52 #x1E #x4D #xFF #x20 #x0C #x6D #xFF #x0D #x04 #x79 #xFF #x22 #xA1 #x22 #xFF #x31 #x12 #x62 #xFF #x58 #x21 #x49 #xFF #x27 #x0E #x68 #xFF #x03 #x01 #x7F #xFF #x03 #x01 #x7F #xFF #x13 #x07 #x75 #xFF #x00 #x00 #x82 #xFF #x22 #xA1 #x22 #xFF #x24 #x0D #x6A #xFF #x76 #x2C #x36 #xFF #x4E #x1D #x4F #xFF #x2B #x8E #x2B #xFF #x10 #x06 #x77 #xFF #x0D #x04 #x79 #xFF #x2C #x8C #x2C #xFF #x24 #x9B #x24 #xFF #x3E #x17 #x5A #xFF #x4B #x1C #x51 #xFF #x3E #x17 #x5A #xFF #x1B #xAE #x1B #xFF #x1A #x09 #x71 #xFF #x29 #x92 #x29 #xFF #x24 #x9B #x24 #xFF #x2A #x90 #x2A #xFF #x21 #xA3 #x21 #xFF #x29 #x92 #x29 #xFF #x35 #x7A #x35 #xFF #x26 #x98 #x26 #xFF #x62 #x25 #x43 #xFF #x1B #xAE #x1B #xFF #x21 #xA3 #x21 #xFF #x24 #x9B #x24 #xFF #x4E #x1D #x4F #xFF #x2A #x10 #x66 #xFF #x5C #x22 #x47 #xFF #x20 #x0C #x6D #xFF #x19 #xCC #x00 #xFF #x52 #x1E #x4D #xFF #x94 #x37 #x23 #xFF #x48 #x1B #x53 #xFF #x83 #x31 #x2E #xFF #xB2 #x49 #x00 #xFF #x5C #x22 #x47 #xFF #x17 #x08 #x73 #xFF #x33 #x33 #xB5 #xFF #x2C #x8C #x2C #xFF #x4B #x1C #x51 #xFF #x3C #x6C #x3C #xFF #x33 #x33 #xB5 #xFF #x1D #x0B #x6F #xFF #x22 #x9F #x22 #xFF #x20 #x0C #x6D #xFF #x0D #x04 #x79 #xFF #x8D #x35 #x27 #xFF #x73 #x2B #x38 #xFF #x76 #x2C #x36 #xFF #xB8 #x45 #x0C #xFF #x5C #x22 #x47 #xFF #x1D #xAA #x1D #xFF #x3E #x17 #x5A #xFF #x66 #x26 #x41 #xFF #x33 #x33 #xB5 #xFF #x7D #x2E #x32 #xFF #x00 #x00 #x82 #xFF #x1B #xAE #x1B #xFF #x90 #x36 #x25 #xFF #x9A #x39 #x1F #xFF #x39 #x72 #x39 #xFF #x24 #x0D #x6A #xFF #x22 #xA1 #x22 #xFF #x10 #x06 #x77 #xFF #x3B #x16 #x5C #xFF #x1A #x09 #x71 #xFF #x41 #x18 #x58 #xFF #x66 #x26 #x41 #xFF #x2B #x8E #x2B #xFF #x1D #xAA #x1D #xFF #x22 #xA1 #x22 #xFF #x19 #xB2 #x19 #xFF #x1F #xA7 #x1F #xFF #x19 #xCC #x00 #xFF #x1A #x09 #x71 #xFF #x2A #x90 #x2A #xFF #x06 #x02 #x7D #xFF #x5F #x23 #x45 #xFF #x2A #x10 #x66 #xFF #x3B #x6F #x3B #xFF #x2E #x88 #x2E #xFF #x2E #x88 #x2E #xFF #x3C #x6C #x3C #xFF #x5C #x22 #x47 #xFF #x1C #xAC #x1C #xFF #x83 #x31 #x2E #xFF #x37 #x14 #x5E #xFF #x33 #x33 #xB5 #xFF #x33 #x33 #xB5 #xFF #x73 #x2B #x38 #xFF #x83 #x31 #x2E #xFF #x03 #x01 #x7F #xFF #x13 #x07 #x75 #xFF #x27 #x96 #x27 #xFF #x19 #xCC #x00 #xFF #x73 #x2B #x38 #xFF #x2E #x11 #x64 #xFF #x76 #x2C #x36 #xFF #xAE #x41 #x12 #xFF #x83 #x31 #x2E #xFF #x1A #x09 #x71 #xFF #x55 #x20 #x4B #xFF #x21 #xA3 #x21 #xFF #x76 #x2C #x36 #xFF #x1F #xA7 #x1F #xFF #x1B #xAE #x1B #xFF #x00 #x00 #x82 #xFF #x24 #x9B #x24 #xFF #x8D #x35 #x27 #xFF #x19 #xCC #x00 #xFF #x76 #x2C #x36 #xFF #xC2 #x4B #x00 #xFF #x7D #x2E #x32 #xFF #xC8 #x4C #x00 #xFF #xAE #x41 #x12 #xFF #x34 #x13 #x60 #xFF #x62 #x25 #x43 #xFF #x83 #x31 #x2E #xFF #x5F #x23 #x45 #xFF #x86 #x32 #x2C #xFF #x45 #x19 #x56 #xFF #x0D #x04 #x79 #xFF #xAB #x40 #x14 #xFF #x9A #x39 #x1F #xFF #x23 #x9D #x23 #xFF #x62 #x25 #x43 #xFF #x45 #x19 #x56 #xFF #x5F #x23 #x45 #xFF #x3E #x17 #x5A #xFF #x58 #x21 #x49 #xFF #x69 #x27 #x3E #xFF #x4E #x1D #x4F #xFF #x1A #xB0 #x1A #xFF #x6F #x29 #x3A #xFF #x25 #x99 #x25 #xFF #x22 #xA1 #x22 #xFF #x06 #x02 #x7D #xFF #x10 #x06 #x77 #xFF #x22 #xA1 #x22 #xFF #x22 #x9F #x22 #xFF #x19 #xCC #x00 #xFF #x6C #x28 #x3C #xFF #x21 #xA3 #x21 #xFF #x26 #x98 #x26 #xFF #x21 #xA3 #x21 #xFF #x20 #xA5 #x20 #xFF #x20 #x0C #x6D #xFF #x20 #x0C #x6D #xFF #x31 #x12 #x62 #xFF #x29 #x92 #x29 #xFF #x24 #x0D #x6A #xFF #x06 #x02 #x7D #xFF #x33 #x7F #x33 #xFF #x09 #x03 #x7B #xFF #x3E #x17 #x5A #xFF #x00 #x00 #x82 #xFF #x33 #x33 #xB5 #xFF #x1A #xB0 #x1A #xFF #x06 #x02 #x7D #xFF #x97 #x38 #x21 #xFF #x24 #x0D #x6A #xFF #x4E #x1D #x4F #xFF #x58 #x21 #x49 #xFF #x52 #x1E #x4D #xFF #x24 #x0D #x6A #xFF #x5C #x22 #x47 #xFF #x24 #x0D #x6A #xFF #x4B #x1C #x51 #xFF #x37 #x14 #x5E #xFF #x30 #x85 #x30 #xFF #x3B #x16 #x5C #xFF #x24 #x0D #x6A #xFF #x58 #x21 #x49 #xFF #x62 #x25 #x43 #xFF #x92 #x45 #x00 #xFF #xC8 #x4C #x00 #xFF #x4B #x1C #x51 #xFF #x6F #x29 #x3A #xFF #xBC #x4A #x00 #xFF #x90 #x36 #x25 #xFF #x7D #x2E #x32 #xFF #x6F #x29 #x3A #xFF #x10 #x06 #x77 #xFF #x1D #x0B #x6F #xFF #x1D #x0B #x6F #xFF #x10 #x06 #x77 #xFF #x79 #x2D #x34 #xFF #xBE #x47 #x08 #xFF #x79 #x2D #x34 #xFF #x2A #x10 #x66 #xFF #x20 #x0C #x6D #xFF #x34 #x13 #x60 #xFF #x00 #x00 #x82 #xFF #x2A #x10 #x66 #xFF #x9A #x39 #x1F #xFF #x8A #x33 #x29 #xFF #x3B #x16 #x5C #xFF #xA1 #x3C #x1B #xFF #x23 #x9D #x23 #xFF #x10 #x06 #x77 #xFF #x3B #x16 #x5C #xFF #x4B #x1C #x51 #xFF #x1A #xB0 #x1A #xFF #x1C #xAC #x1C #xFF #xAB #x40 #x14 #xFF #x6C #x28 #x3C #xFF #x31 #x83 #x31 #xFF #x20 #xA5 #x20 #xFF #x45 #x59 #x45 #xFF #x23 #x9D #x23 #xFF #x03 #x01 #x7F #xFF #x41 #x18 #x58 #xFF #x1E #xA9 #x1E #xFF #x13 #x07 #x75 #xFF #x1A #x09 #x71 #xFF #x03 #x01 #x7F #xFF #x03 #x01 #x7F #xFF #x2A #x10 #x66 #xFF #x5F #x23 #x45 #xFF #x21 #xA3 #x21 #xFF #x0D #x04 #x79 #xFF #x37 #x77 #x37 #xFF #x09 #x03 #x7B #xFF #x1D #x0B #x6F #xFF #x37 #x14 #x5E #xFF #x27 #x0E #x68 #xFF #x6C #x28 #x3C #xFF #x94 #x37 #x23 #xFF #x24 #x0D #x6A #xFF #x29 #x92 #x29 #xFF #x2A #x90 #x2A #xFF #x1A #xB0 #x1A #xFF #x3E #x17 #x5A #xFF #x1E #xA9 #x1E #xFF #x4B #x1C #x51 #xFF #x90 #x36 #x25 #xFF #x69 #x27 #x3E #xFF #x76 #x2C #x36 #xFF #x95 #x45 #x00 #xFF #x5F #x23 #x45 #xFF #x1F #xA7 #x1F #xFF #xB1 #x42 #x10 #xFF #x9A #x39 #x1F #xFF #x1D #x0B #x6F #xFF #x6F #x29 #x3A #xFF #x58 #x21 #x49 #xFF #x33 #x33 #xB5 #xFF #x33 #x7F #x33 #xFF #x23 #x9D #x23 #xFF #x37 #x14 #x5E #xFF #x58 #x21 #x49 #xFF #x2E #x11 #x64 #xFF #x5F #x23 #x45 #xFF #x37 #x14 #x5E #xFF #x34 #x13 #x60 #xFF #x86 #x32 #x2C #xFF #x1D #xAA #x1D #xFF #x31 #x12 #x62 #xFF #x5C #x22 #x47 #xFF #x8D #x35 #x27 #xFF #x03 #x01 #x7F #xFF #x94 #x37 #x23 #xFF #x1E #xA9 #x1E #xFF #x1F #xA7 #x1F #xFF #x37 #x14 #x5E #xFF #x20 #xA5 #x20 #xFF #x41 #x18 #x58 #xFF #x58 #x21 #x49 #xFF #xAE #x41 #x12 #xFF #x6F #x29 #x3A #xFF #x13 #x07 #x75 #xFF #x06 #x02 #x7D #xFF #x23 #x9D #x23 #xFF #x37 #x77 #x37 #xFF #x0D #x04 #x79 #xFF #x2A #x90 #x2A #xFF #x20 #x0C #x6D #xFF #x20 #xA5 #x20 #xFF #x4B #x1C #x51 #xFF #x1A #x09 #x71 #xFF #x29 #x92 #x29 #xFF #x1F #xA7 #x1F #xFF #x1A #xB0 #x1A #xFF #x13 #x07 #x75 #xFF #x33 #x7F #x33 #xFF #x2F #x87 #x2F #xFF #x19 #xCC #x00 #xFF #x06 #x02 #x7D #xFF #x1D #xAA #x1D #xFF #x00 #x00 #x82 #xFF #x27 #x0E #x68 #xFF #x48 #x1B #x53 #xFF #x28 #x94 #x28 #xFF #x2C #x8C #x2C #xFF #x1A #xB0 #x1A #xFF #x48 #x1B #x53 #xFF #x3E #x17 #x5A #xFF #x30 #x85 #x30 #xFF #x13 #x07 #x75 #xFF #x45 #x19 #x56 #xFF #x3E #x17 #x5A #xFF #x2E #x11 #x64 #xFF #xA1 #x3C #x1B #xFF #x1A #x09 #x71 #xFF #x76 #x2C #x36 #xFF #x5C #x22 #x47 #xFF #x45 #x19 #x56 #xFF #x94 #x37 #x23 #xFF #x24 #x0D #x6A #xFF #x48 #x1B #x53 #xFF #x10 #x06 #x77 #xFF #x23 #x9D #x23 #xFF #x2A #x90 #x2A #xFF #x13 #x07 #x75 #xFF #x5C #x22 #x47 #xFF #x20 #x0C #x6D #xFF #xA1 #x3C #x1B #xFF #x6F #x29 #x3A #xFF #x66 #x26 #x41 #xFF #x90 #x36 #x25 #xFF #x19 #xB2 #x19 #xFF #x1D #xAA #x1D #xFF #x73 #x2B #x38 #xFF #x0D #x04 #x79 #xFF #x28 #x94 #x28 #xFF #x4E #x1D #x4F #xFF #x34 #x13 #x60 #xFF #x10 #x06 #x77 #xFF #x22 #xA1 #x22 #xFF #x45 #x19 #x56 #xFF #x30 #x85 #x30 #xFF #x7D #x2E #x32 #xFF #xB8 #x45 #x0C #xFF #x8F #x44 #x00 #xFF #x1B #xAE #x1B #xFF #x25 #x99 #x25 #xFF #x2B #x8E #x2B #xFF #x37 #x77 #x37 #xFF #x21 #xA3 #x21 #xFF #x2D #x8A #x2D #xFF #x34 #x13 #x60 #xFF #x33 #x33 #xB5 #xFF #x80 #x30 #x30 #xFF #x13 #x07 #x75 #xFF #x33 #x33 #xB5 #xFF #x06 #x02 #x7D #xFF #x20 #xA5 #x20 #xFF #x29 #x92 #x29 #xFF #x24 #x9B #x24 #xFF #x32 #x81 #x32 #xFF #x22 #x9F #x22 #xFF #x1E #xA9 #x1E #xFF #x34 #x7C #x34 #xFF #x29 #x92 #x29 #xFF #x79 #x2D #x34 #xFF #x17 #x08 #x73 #xFF #x23 #x9D #x23 #xFF #x34 #x7C #x34 #xFF #x03 #x01 #x7F #xFF #x34 #x13 #x60 #xFF #x1F #xA7 #x1F #xFF #x3B #x6F #x3B #xFF #x06 #x02 #x7D #xFF #x34 #x13 #x60 #xFF #x79 #x2D #x34 #xFF #x83 #x31 #x2E #xFF #xA1 #x3C #x1B #xFF #x86 #x32 #x2C #xFF #x41 #x18 #x58 #xFF #x79 #x2D #x34 #xFF #xC5 #x4A #x04 #xFF #x9A #x39 #x1F #xFF #x13 #x07 #x75 #xFF #x0D #x04 #x79 #xFF #x83 #x31 #x2E #xFF #x10 #x06 #x77 #xFF #x29 #x92 #x29 #xFF #x31 #x12 #x62 #xFF #x4B #x1C #x51 #xFF #x8A #x33 #x29 #xFF #x2A #x10 #x66 #xFF #x6C #x28 #x3C #xFF #x5C #x22 #x47 #xFF #x31 #x12 #x62 #xFF #x69 #x27 #x3E #xFF #x5C #x22 #x47 #xFF #x90 #x36 #x25 #xFF #x1E #xA9 #x1E #xFF #x0D #x04 #x79 #xFF #x5C #x22 #x47 #xFF #x09 #x03 #x7B #xFF #x13 #x07 #x75 #xFF #x2A #x10 #x66 #xFF #x73 #x2B #x38 #xFF #x5C #x22 #x47 #xFF #x58 #x21 #x49 #xFF #xAB #x40 #x14 #xFF #x9D #x3B #x1D #xFF #x19 #xB2 #x19 #xFF #x29 #x92 #x29 #xFF #x29 #x92 #x29 #xFF #x32 #x81 #x32 #xFF #x20 #xA5 #x20 #xFF #x3F #x67 #x3F #xFF #x03 #x01 #x7F #xFF #x6C #x28 #x3C #xFF #x55 #x20 #x4B #xFF #x6F #x29 #x3A #xFF #x1A #xB0 #x1A #xFF #x1D #x0B #x6F #xFF #x33 #x7F #x33 #xFF #x28 #x94 #x28 #xFF #x2F #x87 #x2F #xFF #x1B #xAE #x1B #xFF #x23 #x9D #x23 #xFF #x1E #xA9 #x1E #xFF #x27 #x96 #x27 #xFF #x40 #x64 #x40 #xFF #x24 #x0D #x6A #xFF #x03 #x01 #x7F #xFF #x1A #xB0 #x1A #xFF #x1C #xAC #x1C #xFF #x27 #x0E #x68 #xFF #x86 #x32 #x2C #xFF #x23 #x9D #x23 #xFF #x20 #xA5 #x20 #xFF #x20 #xA5 #x20 #xFF #x10 #x06 #x77 #xFF #x6C #x28 #x3C #xFF #x37 #x14 #x5E #xFF #xBB #x46 #x0A #xFF #x80 #x30 #x30 #xFF #x27 #x0E #x68 #xFF #x8D #x35 #x27 #xFF #xB8 #x45 #x0C #xFF #x8D #x35 #x27 #xFF #x2E #x11 #x64 #xFF #x2A #x90 #x2A #xFF #x1C #xAC #x1C #xFF #x09 #x03 #x7B #xFF #x4E #x1D #x4F #xFF #x25 #x99 #x25 #xFF #x5F #x23 #x45 #xFF #x00 #x00 #x82 #xFF #x3B #x16 #x5C #xFF #xAB #x40 #x14 #xFF #x27 #x0E #x68 #xFF #x41 #x18 #x58 #xFF #x2E #x11 #x64 #xFF #x66 #x26 #x41 #xFF #x73 #x2B #x38 #xFF #x1D #x0B #x6F #xFF #x69 #x27 #x3E #xFF #x27 #x0E #x68 #xFF #x2A #x10 #x66 #xFF #x2A #x10 #x66 #xFF #x33 #x33 #xB5 #xFF #x76 #x2C #x36 #xFF #x10 #x06 #x77 #xFF #x5C #x22 #x47 #xFF #xAB #x40 #x14 #xFF #x4B #x1C #x51 #xFF #x22 #xA1 #x22 #xFF #x24 #x9B #x24 #xFF #x24 #x9B #x24 #xFF #x33 #x33 #xB5 #xFF #x22 #xA1 #x22 #xFF #x23 #x9D #x23 #xFF #x34 #x13 #x60 #xFF #x37 #x14 #x5E #xFF #x4E #x1D #x4F #xFF #x52 #x1E #x4D #xFF #x17 #x08 #x73 #xFF #x03 #x01 #x7F #xFF #x09 #x03 #x7B #xFF #x1D #x0B #x6F #xFF #x33 #x33 #xB5 #xFF #x0D #x04 #x79 #xFF #x27 #x0E #x68 #xFF #x06 #x02 #x7D #xFF #x38 #x74 #x38 #xFF #x23 #x9D #x23 #xFF #x03 #x01 #x7F #xFF #x1A #x09 #x71 #xFF #x09 #x03 #x7B #xFF #x2A #x90 #x2A #xFF #x2C #x8C #x2C #xFF #x31 #x83 #x31 #xFF #x1D #x0B #x6F #xFF #x3B #x6F #x3B #xFF #x73 #x2B #x38 #xFF #x1B #xAE #x1B #xFF #x76 #x2C #x36 #xFF #xC2 #x48 #x06 #xFF #x97 #x38 #x21 #xFF #xBC #x4A #x00 #xFF #x66 #x26 #x41 #xFF #x76 #x2C #x36 #xFF #x8A #x33 #x29 #xFF #xBE #x47 #x08 #xFF #x1A #xB0 #x1A #xFF #x24 #x9B #x24 #xFF #x3B #x6F #x3B #xFF #x39 #x72 #x39 #xFF #x41 #x18 #x58 #xFF #x2A #x90 #x2A #xFF #x19 #xCC #x00 #xFF #x27 #x0E #x68 #xFF #x41 #x18 #x58 #xFF #x58 #x21 #x49 #xFF #x3B #x16 #x5C #xFF #x27 #x0E #x68 #xFF #x3E #x17 #x5A #xFF #x10 #x06 #x77 #xFF #x62 #x25 #x43 #xFF #x06 #x02 #x7D #xFF #x24 #x0D #x6A #xFF #x3E #x17 #x5A #xFF #x1B #xAE #x1B #xFF #x24 #x0D #x6A #xFF #x33 #x33 #xB5 #xFF #x20 #x0C #x6D #xFF #x13 #x07 #x75 #xFF #x03 #x01 #x7F #xFF #x9D #x3B #x1D #xFF #x2A #x10 #x66 #xFF #x2C #x8C #x2C #xFF #x30 #x85 #x30 #xFF #x37 #x14 #x5E #xFF #x1C #xAC #x1C #xFF #x26 #x98 #x26 #xFF #x1C #xAC #x1C #xFF #x4B #x1C #x51 #xFF #x10 #x06 #x77 #xFF #x45 #x19 #x56 #xFF #x4E #x1D #x4F #xFF #x19 #xB2 #x19 #xFF #x17 #x08 #x73 #xFF #x37 #x14 #x5E #xFF #x33 #x33 #xB5 #xFF #x1D #xAA #x1D #xFF #x24 #x0D #x6A #xFF #x19 #xCC #x00 #xFF #x20 #xA5 #x20 #xFF #x33 #x33 #xB5 #xFF #x37 #x77 #x37 #xFF #x31 #x12 #x62 #xFF #x2E #x11 #x64 #xFF #x4E #x1D #x4F #xFF #x1F #xA7 #x1F #xFF #x49 #x51 #x49 #xFF #x1F #xA7 #x1F #xFF #x2F #x87 #x2F #xFF #x1C #xAC #x1C #xFF #x27 #x0E #x68 #xFF #x48 #x1B #x53 #xFF #x17 #x08 #x73 #xFF #x1C #xAC #x1C #xFF #xC8 #x4C #x00 #xFF #x8C #x44 #x00 #xFF #x8F #x44 #x00 #xFF #xB1 #x42 #x10 #xFF #xA4 #x3D #x19 #xFF #x80 #x30 #x30 #xFF #x76 #x2C #x36 #xFF #x0D #x04 #x79 #xFF #x33 #x7F #x33 #xFF #x1F #xA7 #x1F #xFF #x1C #xAC #x1C #xFF #x58 #x21 #x49 #xFF #x1C #xAC #x1C #xFF #x1E #xA9 #x1E #xFF #x22 #xA1 #x22 #xFF #x37 #x14 #x5E #xFF #x2A #x10 #x66 #xFF #x5C #x22 #x47 #xFF #x20 #x0C #x6D #xFF #x41 #x18 #x58 #xFF #x52 #x1E #x4D #xFF #x45 #x19 #x56 #xFF #x21 #xA3 #x21 #xFF #x2A #x10 #x66 #xFF #x10 #x06 #x77 #xFF #x27 #x0E #x68 #xFF #x2A #x10 #x66 #xFF #x0D #x04 #x79 #xFF #x2D #x8A #x2D #xFF #x31 #x12 #x62 #xFF #x0D #x04 #x79 #xFF #x86 #x32 #x2C #xFF #x20 #xA5 #x20 #xFF #x19 #xB2 #x19 #xFF #x09 #x03 #x7B #xFF #x79 #x2D #x34 #xFF #x2A #x90 #x2A #xFF #x31 #x83 #x31 #xFF #x2A #x10 #x66 #xFF #x29 #x92 #x29 #xFF #x34 #x13 #x60 #xFF #x4E #x1D #x4F #xFF #x21 #xA3 #x21 #xFF #x1B #xAE #x1B #xFF #x7D #x2E #x32 #xFF #x4B #x1C #x51 #xFF #x19 #xB2 #x19 #xFF #x1A #xB0 #x1A #xFF #x20 #xA5 #x20 #xFF #x23 #x9D #x23 #xFF #x4E #x1D #x4F #xFF #x27 #x96 #x27 #xFF #x52 #x1E #x4D #xFF #x29 #x92 #x29 #xFF #x1B #xAE #x1B #xFF #x26 #x98 #x26 #xFF #x28 #x94 #x28 #xFF #x55 #x20 #x4B #xFF #x27 #x0E #x68 #xFF #x3E #x17 #x5A #xFF #x26 #x98 #x26 #xFF #x4B #x1C #x51 #xFF #x20 #xA5 #x20 #xFF #x10 #x06 #x77 #xFF #xB2 #x49 #x00 #xFF #x7F #x42 #x00 #xFF #xAC #x48 #x00 #xFF #xB8 #x4A #x00 #xFF #x9D #x3B #x1D #xFF #x9A #x39 #x1F #xFF #xAB #x40 #x14 #xFF #x45 #x19 #x56 #xFF #x1D #x0B #x6F #xFF #x52 #x1E #x4D #xFF #x5F #x23 #x45 #xFF #x1D #xAA #x1D #xFF #x2A #x90 #x2A #xFF #x2C #x8C #x2C #xFF #x28 #x94 #x28 #xFF #x06 #x02 #x7D #xFF #x3E #x17 #x5A #xFF #x5C #x22 #x47 #xFF #x41 #x18 #x58 #xFF #x79 #x2D #x34 #xFF #x73 #x2B #x38 #xFF #x52 #x1E #x4D #xFF #x27 #x0E #x68 #xFF #x13 #x07 #x75 #xFF #x24 #x0D #x6A #xFF #x5C #x22 #x47 #xFF #x58 #x21 #x49 #xFF #x17 #x08 #x73 #xFF #x47 #x57 #x47 #xFF #x2E #x11 #x64 #xFF #x48 #x1B #x53 #xFF #x4E #x1D #x4F #xFF #x1F #xA7 #x1F #xFF #x4B #x1C #x51 #xFF #x10 #x06 #x77 #xFF #x62 #x25 #x43 #xFF #x27 #x96 #x27 #xFF #x44 #x5C #x44 #xFF #x41 #x61 #x41 #xFF #x34 #x7C #x34 #xFF #x26 #x98 #x26 #xFF #x19 #xB2 #x19 #xFF #x28 #x94 #x28 #xFF #x33 #x33 #xB5 #xFF #x33 #x33 #xB5 #xFF #x73 #x2B #x38 #xFF #x45 #x19 #x56 #xFF #x13 #x07 #x75 #xFF #x10 #x06 #x77 #xFF #x2F #x87 #x2F #xFF #x45 #x19 #x56 #xFF #x00 #x00 #x82 #xFF #x20 #x0C #x6D #xFF #x1A #xB0 #x1A #xFF #x33 #x33 #xB5 #xFF #x28 #x94 #x28 #xFF #x2B #x8E #x2B #xFF #x37 #x14 #x5E #xFF #x4B #x1C #x51 #xFF #x86 #x32 #x2C #xFF #x30 #x85 #x30 #xFF #x62 #x25 #x43 #xFF #x37 #x14 #x5E #xFF #x37 #x14 #x5E #xFF #x90 #x36 #x25 #xFF #x8D #x35 #x27 #xFF #x5C #x3E #x00 #xFF #x8F #x44 #x00 #xFF #xB8 #x45 #x0C #xFF #x82 #x43 #x00 #xFF #x48 #x1B #x53 #xFF #x8D #x35 #x27 #xFF #x3B #x16 #x5C #xFF #x41 #x18 #x58 #xFF #xC2 #x48 #x06 #xFF #x00 #x00 #x82 #xFF #x3B #x6F #x3B #xFF #x3D #x6A #x3D #xFF #x31 #x83 #x31 #xFF #x3B #x16 #x5C #xFF #x34 #x13 #x60 #xFF #x52 #x1E #x4D #xFF #x73 #x2B #x38 #xFF #x4E #x1D #x4F #xFF #x69 #x27 #x3E #xFF #x25 #x99 #x25 #xFF #x33 #x33 #xB5 #xFF #x00 #x00 #x82 #xFF #x41 #x18 #x58 #xFF #x2A #x10 #x66 #xFF #x1A #x09 #x71 #xFF #x24 #x0D #x6A #xFF #x47 #x57 #x47 #xFF #x1C #xAC #x1C #xFF #x3E #x17 #x5A #xFF #x03 #x01 #x7F #xFF #x2E #x88 #x2E #xFF #x4B #x1C #x51 #xFF #x1D #xAA #x1D #xFF #x55 #x20 #x4B #xFF #x27 #x96 #x27 #xFF #x24 #x9B #x24 #xFF #x56 #x38 #x42 #xFF #x27 #x96 #x27 #xFF #x29 #x92 #x29 #xFF #x2E #x88 #x2E #xFF #x13 #x07 #x75 #xFF #x00 #x00 #x82 #xFF #x6C #x28 #x3C #xFF #x58 #x21 #x49 #xFF #x3B #x16 #x5C #xFF #x31 #x12 #x62 #xFF #x31 #x12 #x62 #xFF #x25 #x99 #x25 #xFF #x03 #x01 #x7F #xFF #x41 #x18 #x58 #xFF #x13 #x07 #x75 #xFF #x03 #x01 #x7F #xFF #x10 #x06 #x77 #xFF #x1E #xA9 #x1E #xFF #x1A #xB0 #x1A #xFF #x1D #x0B #x6F #xFF #x6F #x29 #x3A #xFF #x80 #x30 #x30 #xFF #x10 #x06 #x77 #xFF #x20 #xA5 #x20 #xFF #x1D #x0B #x6F #xFF #x86 #x32 #x2C #xFF #xBE #x47 #x08 #xFF #xBF #x4A #x00 #xFF #xC5 #x4A #x04 #xFF #xA7 #x3E #x17 #xFF #xA7 #x3E #x17 #xFF #xC8 #x4B #x02 #xFF #xB2 #x49 #x00 #xFF #x1D #x0B #x6F #xFF #x41 #x18 #x58 #xFF #x24 #x0D #x6A #xFF #x66 #x26 #x41 #xFF #x34 #x13 #x60 #xFF #x35 #x7A #x35 #xFF #x34 #x7C #x34 #xFF #x35 #x7A #x35 #xFF #x06 #x02 #x7D #xFF #x83 #x31 #x2E #xFF #x34 #x13 #x60 #xFF #x9A #x39 #x1F #xFF #x69 #x27 #x3E #xFF #x3B #x16 #x5C #xFF #x33 #x7F #x33 #xFF #x27 #x96 #x27 #xFF #x06 #x02 #x7D #xFF #x48 #x1B #x53 #xFF #x0D #x04 #x79 #xFF #x45 #x19 #x56 #xFF #x17 #x08 #x73 #xFF #x1D #xAA #x1D #xFF #x23 #x9D #x23 #xFF #x20 #x0C #x6D #xFF #x19 #xB2 #x19 #xFF #x1F #xA7 #x1F #xFF #x20 #x0C #x6D #xFF #x1D #xAA #x1D #xFF #x2A #x10 #x66 #xFF #x1A #xB0 #x1A #xFF #x1F #xA7 #x1F #xFF #x47 #x57 #x47 #xFF #x26 #x98 #x26 #xFF #x1F #xA7 #x1F #xFF #x19 #xB2 #x19 #xFF #x58 #x21 #x49 #xFF #x00 #x00 #x82 #xFF #x19 #xB2 #x19 #xFF #x2A #x10 #x66 #xFF #x20 #x0C #x6D #xFF #x55 #x20 #x4B #xFF #x1D #x0B #x6F #xFF #x1B #xAE #x1B #xFF #x19 #xCC #x00 #xFF #x10 #x06 #x77 #xFF #x1B #xAE #x1B #xFF #x28 #x94 #x28 #xFF #x19 #xB2 #x19 #xFF #x7D #x2E #x32 #xFF #x76 #x2C #x36 #xFF #x6F #x29 #x3A #xFF #x86 #x32 #x2C #xFF #x66 #x26 #x41 #xFF #x48 #x1B #x53 #xFF #x2A #x90 #x2A #xFF #x86 #x32 #x2C #xFF #x97 #x38 #x21 #xFF #xA7 #x3E #x17 #xFF #xAC #x48 #x00 #xFF #xCC #x4C #x00 #xFF #xBF #x4A #x00 #xFF #x90 #x36 #x25 #xFF #xAB #x40 #x14 #xFF #xBF #x4A #x00 #xFF #xA7 #x3E #x17 #xFF #x80 #x30 #x30 #xFF #x66 #x26 #x41 #xFF #x19 #xCC #x00 #xFF #x39 #x72 #x39 #xFF #x21 #xA3 #x21 #xFF #x32 #x81 #x32 #xFF #x2D #x8A #x2D #xFF #x24 #x9B #x24 #xFF #x34 #x13 #x60 #xFF #x7D #x2E #x32 #xFF #x5F #x23 #x45 #xFF #x83 #x31 #x2E #xFF #x8D #x35 #x27 #xFF #x17 #x08 #x73 #xFF #x25 #x99 #x25 #xFF #x06 #x02 #x7D #xFF #x55 #x20 #x4B #xFF #x27 #x96 #x27 #xFF #x24 #x0D #x6A #xFF #x5C #x22 #x47 #xFF #x1A #x09 #x71 #xFF #x06 #x02 #x7D #xFF #x13 #x07 #x75 #xFF #x10 #x06 #x77 #xFF #x1E #xA9 #x1E #xFF #x28 #x94 #x28 #xFF #x20 #xA5 #x20 #xFF #x10 #x06 #x77 #xFF #x37 #x14 #x5E #xFF #x34 #x13 #x60 #xFF #x1E #xA9 #x1E #xFF #x41 #x18 #x58 #xFF #x19 #xCC #x00 #xFF #x1C #xAC #x1C #xFF #x1D #xAA #x1D #xFF #x0D #x04 #x79 #xFF #x19 #xB2 #x19 #xFF #x1E #xA9 #x1E #xFF #x3E #x17 #x5A #xFF #x4E #x1D #x4F #xFF #x0D #x04 #x79 #xFF #x13 #x07 #x75 #xFF #x1A #xB0 #x1A #xFF #x17 #x08 #x73 #xFF #x58 #x21 #x49 #xFF #x1C #xAC #x1C #xFF #x19 #xCC #x00 #xFF #x00 #x00 #x82 #xFF #x86 #x32 #x2C #xFF #x27 #x0E #x68 #xFF #x06 #x02 #x7D #xFF #x62 #x25 #x43 #xFF #x19 #xB2 #x19 #xFF #x20 #xA5 #x20 #xFF #x03 #x01 #x7F #xFF #x5C #x22 #x47 #xFF #x5C #x22 #x47 #xFF #xBE #x47 #x08 #xFF #xBE #x47 #x08 #xFF #xB4 #x43 #x0E #xFF #xBC #x4A #x00 #xFF #xC2 #x48 #x06 #xFF #xA5 #x47 #x00 #xFF #xA4 #x3D #x19 #xFF #x34 #x13 #x60 #xFF #x4B #x1C #x51 #xFF #x26 #x98 #x26 #xFF #x25 #x99 #x25 #xFF #x2F #x87 #x2F #xFF #x23 #x9D #x23 #xFF #x33 #x33 #xB5 #xFF #x22 #x9F #x22 #xFF #x03 #x01 #x7F #xFF #x10 #x06 #x77 #xFF #x45 #x19 #x56 #xFF #x8A #x33 #x29 #xFF #x94 #x37 #x23 #xFF #x3B #x16 #x5C #xFF #x2B #x8E #x2B #xFF #x48 #x1B #x53 #xFF #x31 #x12 #x62 #xFF #x3B #x16 #x5C #xFF #x45 #x19 #x56 #xFF #x20 #x0C #x6D #xFF #x30 #x85 #x30 #xFF #x3B #x16 #x5C #xFF #x25 #x99 #x25 #xFF #x3E #x17 #x5A #xFF #x2A #x10 #x66 #xFF #x33 #x33 #xB5 #xFF #x2F #x87 #x2F #xFF #x25 #x99 #x25 #xFF #x29 #x92 #x29 #xFF #x4B #x1C #x51 #xFF #x45 #x19 #x56 #xFF #x5F #x23 #x45 #xFF #x21 #xA3 #x21 #xFF #x1A #xB0 #x1A #xFF #x1D #xAA #x1D #xFF #x1F #xA7 #x1F #xFF #x06 #x02 #x7D #xFF #x00 #x00 #x82 #xFF #x69 #x27 #x3E #xFF #x33 #x33 #xB5 #xFF #x00 #x00 #x82 #xFF #x19 #xB2 #x19 #xFF #x1A #x09 #x71 #xFF #x10 #x06 #x77 #xFF #x24 #x0D #x6A #xFF #x22 #x9F #x22 #xFF #x2D #x8A #x2D #xFF #x1A #x09 #x71 #xFF #x31 #x12 #x62 #xFF #x06 #x02 #x7D #xFF #x2A #x10 #x66 #xFF #x6F #x29 #x3A #xFF #x1A #x09 #x71 #xFF #x1B #xAE #x1B #xFF #x1F #xA7 #x1F #xFF #x45 #x19 #x56 #xFF #x79 #x2D #x34 #xFF #xA1 #x3C #x1B #xFF #xBE #x47 #x08 #xFF #xBB #x46 #x0A #xFF #xC2 #x48 #x06 #xFF #x8D #x35 #x27 #xFF #xC5 #x4A #x04 #xFF #xC8 #x4C #x00 #xFF #x34 #x13 #x60 #xFF #x03 #x01 #x7F #xFF #x3E #x17 #x5A #xFF #x33 #x33 #xB5 #xFF #x1C #xAC #x1C #xFF #x1C #xAC #x1C #xFF #x21 #xA3 #x21 #xFF #x39 #x72 #x39 #xFF #x22 #x9F #x22 #xFF #x29 #x92 #x29 #xFF #x2C #x8C #x2C #xFF #x0D #x04 #x79 #xFF #x66 #x26 #x41 #xFF #x90 #x36 #x25 #xFF #x00 #x00 #x82 #xFF #x20 #xA5 #x20 #xFF #x13 #x07 #x75 #xFF #x0D #x04 #x79 #xFF #x4B #x1C #x51 #xFF #x1A #x09 #x71 #xFF #x00 #x00 #x82 #xFF #xA1 #x3C #x1B #xFF #x13 #x07 #x75 #xFF #x20 #xA5 #x20 #xFF #x24 #x0D #x6A #xFF #x1F #xA7 #x1F #xFF #x49 #x51 #x49 #xFF #x43 #x5F #x43 #xFF #x20 #xA5 #x20 #xFF #x1A #xB0 #x1A #xFF #x3B #x16 #x5C #xFF #x1A #xB0 #x1A #xFF #x26 #x98 #x26 #xFF #x09 #x03 #x7B #xFF #x4E #x1D #x4F #xFF #x1E #xA9 #x1E #xFF #x1B #xAE #x1B #xFF #x2E #x11 #x64 #xFF #x3B #x16 #x5C #xFF #x27 #x0E #x68 #xFF #x66 #x26 #x41 #xFF #x1A #x09 #x71 #xFF #x1F #xA7 #x1F #xFF #x1A #xB0 #x1A #xFF #x2B #x8E #x2B #xFF #x35 #x7A #x35 #xFF #x22 #x9F #x22 #xFF #x1A #x09 #x71 #xFF #x6C #x28 #x3C #xFF #x1A #x09 #x71 #xFF #x13 #x07 #x75 #xFF #x09 #x03 #x7B #xFF #x1D #x0B #x6F #xFF #x33 #x33 #xB5 #xFF #x27 #x96 #x27 #xFF #x4B #x1C #x51 #xFF #x90 #x36 #x25 #xFF #xCC #x4C #x00 #xFF #x9D #x3B #x1D #xFF #xBF #x4A #x00 #xFF #x9A #x39 #x1F #xFF #x58 #x21 #x49 #xFF #x1E #xA9 #x1E #xFF #x62 #x25 #x43 #xFF #x80 #x30 #x30 #xFF #x45 #x19 #x56 #xFF #x55 #x20 #x4B #xFF #x2A #x10 #x66 #xFF #x23 #x9D #x23 #xFF #x41 #x18 #x58 #xFF #x1D #xAA #x1D #xFF #x50 #x44 #x48 #xFF #x1F #xA7 #x1F #xFF #x22 #x9F #x22 #xFF #x2B #x8E #x2B #xFF #x26 #x98 #x26 #xFF #x27 #x0E #x68 #xFF #x27 #x0E #x68 #xFF #x33 #x33 #xB5 #xFF #x28 #x94 #x28 #xFF #x1A #x09 #x71 #xFF #xA4 #x3D #x19 #xFF #x83 #x31 #x2E #xFF #x41 #x18 #x58 #xFF #x69 #x27 #x3E #xFF #xA4 #x3D #x19 #xFF #x1D #xAA #x1D #xFF #x4B #x1C #x51 #xFF #x5C #x22 #x47 #xFF #x2A #x10 #x66 #xFF #x2D #x8A #x2D #xFF #x26 #x98 #x26 #xFF #x17 #x08 #x73 #xFF #x34 #x13 #x60 #xFF #x69 #x27 #x3E #xFF #x1C #xAC #x1C #xFF #x22 #x9F #x22 #xFF #x1A #x09 #x71 #xFF #x2A #x10 #x66 #xFF #x20 #x0C #x6D #xFF #x06 #x02 #x7D #xFF #x13 #x07 #x75 #xFF #x1A #x09 #x71 #xFF #x2E #x11 #x64 #xFF #x10 #x06 #x77 #xFF #x2A #x10 #x66 #xFF #x19 #xB2 #x19 #xFF #x22 #x9F #x22 #xFF #x3B #x6F #x3B #xFF #x30 #x85 #x30 #xFF #x37 #x77 #x37 #xFF #x1D #xAA #x1D #xFF #x34 #x13 #x60 #xFF #x79 #x2D #x34 #xFF #x45 #x19 #x56 #xFF #x1D #xAA #x1D #xFF #x20 #x0C #x6D #xFF #x1F #xA7 #x1F #xFF #x1F #xA7 #x1F #xFF #x55 #x20 #x4B #xFF #x69 #x27 #x3E #xFF #xB5 #x49 #x00 #xFF #xB8 #x4A #x00 #xFF #xB1 #x42 #x10 #xFF #x6C #x28 #x3C #xFF #x3E #x17 #x5A #xFF #x17 #x08 #x73 #xFF #x25 #x99 #x25 #xFF #x20 #xA5 #x20 #xFF #x55 #x20 #x4B #xFF #x24 #x0D #x6A #xFF #x03 #x01 #x7F #xFF #x20 #x0C #x6D #xFF #x4E #x1D #x4F #xFF #x19 #xCC #x00 #xFF #x34 #x7C #x34 #xFF #x2D #x8A #x2D #xFF #x32 #x81 #x32 #xFF #x2A #x90 #x2A #xFF #x03 #x01 #x7F #xFF #x1A #xB0 #x1A #xFF #x20 #xA5 #x20 #xFF #x1F #xA7 #x1F #xFF #x17 #x08 #x73 #xFF #x4E #x1D #x4F #xFF #x66 #x26 #x41 #xFF #x7D #x2E #x32 #xFF #x5C #x22 #x47 #xFF #x34 #x13 #x60 #xFF #x97 #x38 #x21 #xFF #x09 #x03 #x7B #xFF #x69 #x27 #x3E #xFF #x20 #x0C #x6D #xFF #x22 #xA1 #x22 #xFF #x30 #x85 #x30 #xFF #x27 #x0E #x68 #xFF #x17 #x08 #x73 #xFF #x2A #x10 #x66 #xFF #x58 #x21 #x49 #xFF #x33 #x33 #xB5 #xFF #x1B #xAE #x1B #xFF #x80 #x30 #x30 #xFF #x48 #x1B #x53 #xFF #x17 #x08 #x73 #xFF #x48 #x1B #x53 #xFF #x1D #x0B #x6F #xFF #x33 #x33 #xB5 #xFF #x10 #x06 #x77 #xFF #x52 #x1E #x4D #xFF #x33 #x33 #xB5 #xFF #x2B #x8E #x2B #xFF #x2A #x90 #x2A #xFF #x1B #xAE #x1B #xFF #x2E #x88 #x2E #xFF #x2B #x8E #x2B #xFF #x17 #x08 #x73 #xFF #x37 #x14 #x5E #xFF #x58 #x21 #x49 #xFF #x41 #x18 #x58 #xFF #x13 #x07 #x75 #xFF #x13 #x07 #x75 #xFF #x22 #xA1 #x22 #xFF #x1A #xB0 #x1A #xFF #x1D #x0B #x6F #xFF #x86 #x32 #x2C #xFF #x90 #x36 #x25 #xFF #x94 #x37 #x23 #xFF #x45 #x19 #x56 #xFF #x0D #x04 #x79 #xFF #x3E #x17 #x5A #xFF #x33 #x7F #x33 #xFF #x2C #x8C #x2C #xFF #x29 #x92 #x29 #xFF #x21 #xA3 #x21 #xFF #x24 #x9B #x24 #xFF #x21 #xA3 #x21 #xFF #x48 #x1B #x53 #xFF #x2A #x10 #x66 #xFF #x0D #x04 #x79 #xFF #x40 #x64 #x40 #xFF #x27 #x96 #x27 #xFF #x2C #x8C #x2C #xFF #x33 #x33 #xB5 #xFF #x10 #x06 #x77 #xFF #x22 #x9F #x22 #xFF #x26 #x98 #x26 #xFF #x22 #xA1 #x22 #xFF #x3E #x17 #x5A #xFF #x31 #x12 #x62 #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #x58 #x21 #x49 #xFF #x31 #x12 #x62 #xFF #x79 #x2D #x34 #xFF #x97 #x38 #x21 #xFF #x4E #x1D #x4F #xFF #x09 #x03 #x7B #xFF #x1D #x0B #x6F #xFF #x52 #x1E #x4D #xFF #x1A #xB0 #x1A #xFF #x1D #xAA #x1D #xFF #x45 #x19 #x56 #xFF #x06 #x02 #x7D #xFF #x1B #xAE #x1B #xFF #x66 #x26 #x41 #xFF #x76 #x2C #x36 #xFF #x1A #x09 #x71 #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x5C #x22 #x47 #xFF #x1B #xAE #x1B #xFF #x19 #xCC #x00 #xFF #x24 #x9B #x24 #xFF #x2C #x8C #x2C #xFF #x1A #xB0 #x1A #xFF #x2E #x88 #x2E #xFF #x1A #xB0 #x1A #xFF #x00 #x00 #x82 #xFF #x19 #xCC #x00 #xFF #x5C #x22 #x47 #xFF #x7D #x2E #x32 #xFF #x37 #x14 #x5E #xFF #x8A #x33 #x29 #xFF #x76 #x2C #x36 #xFF #x4E #x1D #x4F #xFF #x83 #x31 #x2E #xFF #x27 #x0E #x68 #xFF #x23 #x9D #x23 #xFF #x31 #x12 #x62 #xFF #x2E #x11 #x64 #xFF #x6C #x28 #x3C #xFF #x20 #x0C #x6D #xFF #x1D #x0B #x6F #xFF #x2E #x88 #x2E #xFF #x2C #x8C #x2C #xFF #x34 #x7C #x34 #xFF #x2B #x8E #x2B #xFF #x4D #x4A #x4B #xFF #x2F #x87 #x2F #xFF #x1C #xAC #x1C #xFF #x1D #x0B #x6F #xFF #x22 #xA1 #x22 #xFF #x38 #x74 #x38 #xFF #x31 #x83 #x31 #xFF #x2C #x8C #x2C #xFF #x38 #x74 #x38 #xFF #x20 #xA5 #x20 #xFF #x21 #xA3 #x21 #xFF #x2A #x90 #x2A #xFF #x2D #x8A #x2D #xFF #x35 #x7A #x35 #xFF #x20 #xA5 #x20 #xFF #x3E #x17 #x5A #xFF #x80 #x30 #x30 #xFF #x83 #x31 #x2E #xFF #x6F #x29 #x3A #xFF #x69 #x27 #x3E #xFF #x86 #x32 #x2C #xFF #x7D #x2E #x32 #xFF #x80 #x30 #x30 #xFF #x24 #x0D #x6A #xFF #x26 #x98 #x26 #xFF #x2E #x11 #x64 #xFF #x00 #x00 #x82 #xFF #x58 #x21 #x49 #xFF #x20 #xA5 #x20 #xFF #x4B #x1C #x51 #xFF #x2A #x10 #x66 #xFF #x9A #x39 #x1F #xFF #x69 #x27 #x3E #xFF #x19 #xB2 #x19 #xFF #x13 #x07 #x75 #xFF #x27 #x0E #x68 #xFF #x31 #x12 #x62 #xFF #x27 #x0E #x68 #xFF #x6F #x29 #x3A #xFF #x21 #xA3 #x21 #xFF #x1D #xAA #x1D #xFF #x20 #xA5 #x20 #xFF #x1C #xAC #x1C #xFF #x13 #x07 #x75 #xFF #x76 #x2C #x36 #xFF #x66 #x26 #x41 #xFF #x62 #x25 #x43 #xFF #x9D #x3B #x1D #xFF #x9A #x39 #x1F #xFF #x83 #x31 #x2E #xFF #x62 #x25 #x43 #xFF #x00 #x00 #x82 #xFF #x3E #x17 #x5A #xFF #x37 #x14 #x5E #xFF #x1A #xB0 #x1A #xFF #x4B #x1C #x51 #xFF #x4B #x1C #x51 #xFF #x1A #xB0 #x1A #xFF #x24 #x9B #x24 #xFF #x24 #x9B #x24 #xFF #x30 #x85 #x30 #xFF #x2B #x8E #x2B #xFF #x2B #x8E #x2B #xFF #x27 #x96 #x27 #xFF #x2E #x88 #x2E #xFF #x37 #x77 #x37 #xFF #x40 #x64 #x40 #xFF #x28 #x94 #x28 #xFF #x33 #x7F #x33 #xFF #x40 #x64 #x40 #xFF #x2D #x8A #x2D #xFF #x33 #x7F #x33 #xFF #x2D #x8A #x2D #xFF #x25 #x99 #x25 #xFF #x0D #x04 #x79 #xFF #x22 #x9F #x22 #xFF #x1E #xA9 #x1E #xFF #x21 #xA3 #x21 #xFF #x1F #xA7 #x1F #xFF #x09 #x03 #x7B #xFF #x3B #x16 #x5C #xFF #x20 #x0C #x6D #xFF #x34 #x13 #x60 #xFF #x3E #x17 #x5A #xFF #x73 #x2B #x38 #xFF #x06 #x02 #x7D #xFF #x62 #x25 #x43 #xFF #x58 #x21 #x49 #xFF #x13 #x07 #x75 #xFF #x20 #x0C #x6D #xFF #x3B #x16 #x5C #xFF #x83 #x31 #x2E #xFF #x79 #x2D #x34 #xFF #x4B #x1C #x51 #xFF #xB1 #x42 #x10 #xFF #x76 #x2C #x36 #xFF #x4B #x1C #x51 #xFF #x58 #x21 #x49 #xFF #x45 #x19 #x56 #xFF #x33 #x7F #x33 #xFF #x2B #x8E #x2B #xFF #x69 #x27 #x3E #xFF #x2A #x10 #x66 #xFF #x24 #x0D #x6A #xFF #x80 #x30 #x30 #xFF #x66 #x26 #x41 #xFF #x5F #x23 #x45 #xFF #x6C #x28 #x3C #xFF #x4E #x1D #x4F #xFF #x83 #x31 #x2E #xFF #xAE #x41 #x12 #xFF #x8D #x35 #x27 #xFF #x58 #x21 #x49 #xFF #x4B #x1C #x51 #xFF #x52 #x1E #x4D #xFF #x41 #x18 #x58 #xFF #x26 #x98 #x26 #xFF #x21 #xA3 #x21 #xFF #x0D #x04 #x79 #xFF #x27 #x0E #x68 #xFF #x6F #x29 #x3A #xFF #x19 #xCC #x00 #xFF #x1A #xB0 #x1A #xFF #x2A #x90 #x2A #xFF #x2F #x87 #x2F #xFF #x2A #x90 #x2A #xFF #x17 #x08 #x73 #xFF #x2B #x8E #x2B #xFF #x22 #xA1 #x22 #xFF #x20 #xA5 #x20 #xFF #x39 #x72 #x39 #xFF #x27 #x96 #x27 #xFF #x22 #x9F #x22 #xFF #x35 #x7A #x35 #xFF #x30 #x85 #x30 #xFF #x29 #x92 #x29 #xFF #x09 #x03 #x7B #xFF #x28 #x94 #x28 #xFF #x23 #x9D #x23 #xFF #x21 #xA3 #x21 #xFF #x27 #x96 #x27 #xFF #x19 #xB2 #x19 #xFF #x28 #x94 #x28 #xFF #x00 #x00 #x82 #xFF #x1D #x0B #x6F #xFF #x20 #x0C #x6D #xFF #x80 #x30 #x30 #xFF #x31 #x12 #x62 #xFF #x62 #x25 #x43 #xFF #x0D #x04 #x79 #xFF #x24 #x0D #x6A #xFF #x3B #x16 #x5C #xFF #x37 #x14 #x5E #xFF #x5C #x22 #x47 #xFF #x55 #x20 #x4B #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #x80 #x30 #x30 #xFF #xA1 #x3C #x1B #xFF #x94 #x37 #x23 #xFF #x8D #x35 #x27 #xFF #x7D #x2E #x32 #xFF #x45 #x19 #x56 #xFF #x33 #x33 #xB5 #xFF #x73 #x2B #x38 #xFF #x48 #x1B #x53 #xFF #x80 #x30 #x30 #xFF #x7D #x2E #x32 #xFF #x94 #x37 #x23 #xFF #xC5 #x4A #x04 #xFF #x73 #x2B #x38 #xFF #x55 #x20 #x4B #xFF #x69 #x27 #x3E #xFF #x8A #x33 #x29 #xFF #x45 #x19 #x56 #xFF #x1D #x0B #x6F #xFF #x03 #x01 #x7F #xFF #x13 #x07 #x75 #xFF #x13 #x07 #x75 #xFF #x55 #x20 #x4B #xFF #x41 #x18 #x58 #xFF #x09 #x03 #x7B #xFF #x06 #x02 #x7D #xFF #x2A #x10 #x66 #xFF #x58 #x21 #x49 #xFF #x31 #x12 #x62 #xFF #x10 #x06 #x77 #xFF #x41 #x61 #x41 #xFF #x2E #x88 #x2E #xFF #x34 #x7C #x34 #xFF #x26 #x98 #x26 #xFF #x1E #xA9 #x1E #xFF #x28 #x94 #x28 #xFF #x35 #x7A #x35 #xFF #x2C #x8C #x2C #xFF #x25 #x99 #x25 #xFF #x2F #x87 #x2F #xFF #x4C #x4C #x4C #xFF #x2F #x87 #x2F #xFF #x31 #x83 #x31 #xFF #x2E #x88 #x2E #xFF #x2C #x8C #x2C #xFF #x22 #xA1 #x22 #xFF #x28 #x94 #x28 #xFF #x22 #xA1 #x22 #xFF #x31 #x12 #x62 #xFF #x3B #x16 #x5C #xFF #x26 #x98 #x26 #xFF #x1C #xAC #x1C #xFF #x37 #x14 #x5E #xFF #x41 #x18 #x58 #xFF #x48 #x1B #x53 #xFF #x1D #x0B #x6F #xFF #x10 #x06 #x77 #xFF #x31 #x12 #x62 #xFF #x13 #x07 #x75 #xFF #x3B #x16 #x5C #xFF #x62 #x25 #x43 #xFF #x48 #x1B #x53 #xFF #x6F #x29 #x3A #xFF #x5F #x23 #x45 #xFF #x6C #x28 #x3C #xFF #x86 #x32 #x2C #xFF #x94 #x37 #x23 #xFF #xA1 #x3C #x1B #xFF #x8A #x33 #x29 #xFF #x80 #x30 #x30 #xFF #x7D #x2E #x32 #xFF #x4B #x1C #x51 #xFF #x52 #x1E #x4D #xFF #x8D #x35 #x27 #xFF #x2A #x10 #x66 #xFF #x48 #x1B #x53 #xFF #x76 #x2C #x36 #xFF #xB4 #x43 #x0E #xFF #x8D #x35 #x27 #xFF #x37 #x14 #x5E #xFF #x3E #x17 #x5A #xFF #x06 #x02 #x7D #xFF #x0D #x04 #x79 #xFF #x1A #x09 #x71 #xFF #x1B #xAE #x1B #xFF #x24 #x0D #x6A #xFF #x37 #x14 #x5E #xFF #x24 #x0D #x6A #xFF #x3E #x17 #x5A #xFF #x17 #x08 #x73 #xFF #x31 #x12 #x62 #xFF #x48 #x1B #x53 #xFF #x17 #x08 #x73 #xFF #x33 #x33 #xB5 #xFF #x2E #x88 #x2E #xFF #x33 #x7F #x33 #xFF #x43 #x5F #x43 #xFF #x2F #x87 #x2F #xFF #x1F #xA7 #x1F #xFF #x1D #x0B #x6F #xFF #x25 #x99 #x25 #xFF #x1F #xA7 #x1F #xFF #x22 #x9F #x22 #xFF #x22 #xA1 #x22 #xFF #x29 #x92 #x29 #xFF #x24 #x9B #x24 #xFF #x1F #xA7 #x1F #xFF #x19 #xCC #x00 #xFF #x19 #xB2 #x19 #xFF #x20 #xA5 #x20 #xFF #x1F #xA7 #x1F #xFF #x09 #x03 #x7B #xFF #x27 #x0E #x68 #xFF #x13 #x07 #x75 #xFF #x21 #xA3 #x21 #xFF #x31 #x12 #x62 #xFF #x6F #x29 #x3A #xFF #x9A #x39 #x1F #xFF #x5F #x23 #x45 #xFF #x1A #xB0 #x1A #xFF #x2E #x88 #x2E #xFF #x2A #x10 #x66 #xFF #x48 #x1B #x53 #xFF #x1D #xAA #x1D #xFF #x34 #x13 #x60 #xFF #x09 #x03 #x7B #xFF #x24 #x0D #x6A #xFF #x48 #x1B #x53 #xFF #x45 #x19 #x56 #xFF #x20 #x0C #x6D #xFF #x1D #x0B #x6F #xFF #x09 #x03 #x7B #xFF #x19 #xB2 #x19 #xFF #x24 #x0D #x6A #xFF #x6F #x29 #x3A #xFF #x90 #x36 #x25 #xFF #x66 #x26 #x41 #xFF #x76 #x2C #x36 #xFF #x45 #x19 #x56 #xFF #x34 #x13 #x60 #xFF #x34 #x13 #x60 #xFF #xAB #x40 #x14 #xFF #xB8 #x45 #x0C #xFF #x83 #x31 #x2E #xFF #x52 #x1E #x4D #xFF #x17 #x08 #x73 #xFF #x19 #xB2 #x19 #xFF #x09 #x03 #x7B #xFF #x1A #x09 #x71 #xFF #x41 #x18 #x58 #xFF #x1D #x0B #x6F #xFF #x31 #x12 #x62 #xFF #x33 #x33 #xB5 #xFF #x27 #x0E #x68 #xFF #x1B #xAE #x1B #xFF #x21 #xA3 #x21 #xFF #x22 #xA1 #x22 #xFF #x27 #x96 #x27 #xFF #x37 #x77 #x37 #xFF #x2C #x8C #x2C #xFF #x20 #x0C #x6D #xFF #x48 #x1B #x53 #xFF #x19 #xB2 #x19 #xFF #x1B #xAE #x1B #xFF #x03 #x01 #x7F #xFF #x1C #xAC #x1C #xFF #x29 #x92 #x29 #xFF #x3B #x6F #x3B #xFF #x1E #xA9 #x1E #xFF #x1E #xA9 #x1E #xFF #x21 #xA3 #x21 #xFF #x1A #x09 #x71 #xFF #x33 #x33 #xB5 #xFF #x13 #x07 #x75 #xFF #x00 #x00 #x82 #xFF #x22 #xA1 #x22 #xFF #x09 #x03 #x7B #xFF #x03 #x01 #x7F #xFF #x03 #x01 #x7F #xFF #x2E #x11 #x64 #xFF #x2E #x11 #x64 #xFF #x79 #x2D #x34 #xFF #x34 #x13 #x60 #xFF #x10 #x06 #x77 #xFF #x09 #x03 #x7B #xFF #x48 #x1B #x53 #xFF #x4E #x1D #x4F #xFF #x13 #x07 #x75 #xFF #x76 #x2C #x36 #xFF #x62 #x25 #x43 #xFF #x5C #x22 #x47 #xFF #x4B #x1C #x51 #xFF #x58 #x21 #x49 #xFF #x8A #x33 #x29 #xFF #x5C #x22 #x47 #xFF #x19 #xCC #x00 #xFF #x1A #xB0 #x1A #xFF #x45 #x19 #x56 #xFF #x48 #x1B #x53 #xFF #x52 #x1E #x4D #xFF #x55 #x20 #x4B #xFF #xB8 #x45 #x0C #xFF #x8D #x35 #x27 #xFF #x24 #x0D #x6A #xFF #x24 #x0D #x6A #xFF #x24 #x0D #x6A #xFF #x62 #x25 #x43 #xFF #x76 #x2C #x36 #xFF #x97 #x38 #x21 #xFF #x3E #x17 #x5A #xFF #x1D #x0B #x6F #xFF #x37 #x14 #x5E #xFF #x69 #x27 #x3E #xFF #x4B #x1C #x51 #xFF #x10 #x06 #x77 #xFF #x34 #x13 #x60 #xFF #x20 #x0C #x6D #xFF #x13 #x07 #x75 #xFF #x17 #x08 #x73 #xFF #x0D #x04 #x79 #xFF #x17 #x08 #x73 #xFF #x28 #x94 #x28 #xFF #x25 #x99 #x25 #xFF #x03 #x01 #x7F #xFF #x24 #x0D #x6A #xFF #x13 #x07 #x75 #xFF #x48 #x1B #x53 #xFF #x10 #x06 #x77 #xFF #x20 #x0C #x6D #xFF #x03 #x01 #x7F #xFF #x25 #x99 #x25 #xFF #x34 #x7C #x34 #xFF #x33 #x7F #x33 #xFF #x24 #x9B #x24 #xFF #x25 #x99 #x25 #xFF #x26 #x98 #x26 #xFF #x25 #x99 #x25 #xFF #x03 #x01 #x7F #xFF #x1A #x09 #x71 #xFF #x41 #x18 #x58 #xFF #x66 #x26 #x41 #xFF #x37 #x14 #x5E #xFF #x4E #x1D #x4F #xFF #xB4 #x43 #x0E #xFF #xAE #x41 #x12 #xFF #x69 #x27 #x3E #xFF #x2E #x11 #x64 #xFF #x37 #x14 #x5E #xFF #x31 #x12 #x62 #xFF #x90 #x36 #x25 #xFF #x90 #x36 #x25 #xFF #x6C #x28 #x3C #xFF #xA1 #x3C #x1B #xFF #xB4 #x43 #x0E #xFF #x8A #x33 #x29 #xFF #x79 #x2D #x34 #xFF #x7D #x2E #x32 #xFF #x8D #x35 #x27 #xFF #x86 #x32 #x2C #xFF #x7D #x2E #x32 #xFF #x80 #x30 #x30 #xFF #x62 #x25 #x43 #xFF #x45 #x19 #x56 #xFF #x6F #x29 #x3A #xFF #x83 #x31 #x2E #xFF #x79 #x2D #x34 #xFF #x41 #x18 #x58 #xFF #x10 #x06 #x77 #xFF #x1A #x09 #x71 #xFF #x1D #x0B #x6F #xFF #x33 #x33 #xB5 #xFF #x00 #x00 #x82 #xFF #x10 #x06 #x77 #xFF #x3B #x16 #x5C #xFF #x34 #x13 #x60 #xFF #x2A #x10 #x66 #xFF #x00 #x00 #x82 #xFF #x29 #x92 #x29 #xFF #x3B #x16 #x5C #xFF #x1A #x09 #x71 #xFF #x58 #x21 #x49 #xFF #x6F #x29 #x3A #xFF #x2E #x11 #x64 #xFF #x10 #x06 #x77 #xFF #x24 #x0D #x6A #xFF #x03 #x01 #x7F #xFF #x22 #xA1 #x22 #xFF #x22 #xA1 #x22 #xFF #x1E #xA9 #x1E #xFF #x20 #xA5 #x20 #xFF #x1C #xAC #x1C #xFF #x19 #xB2 #x19 #xFF #x1D #xAA #x1D #xFF #x24 #x9B #x24 #xFF #x28 #x94 #x28 #xFF #x29 #x92 #x29 #xFF #x2A #x90 #x2A #xFF #x2A #x90 #x2A #xFF #x22 #x9F #x22 #xFF #x34 #x7C #x34 #xFF #x37 #x77 #x37 #xFF #x30 #x85 #x30 #xFF #x29 #x92 #x29 #xFF #x1B #xAE #x1B #xFF #x17 #x08 #x73 #xFF #x1D #x0B #x6F #xFF #x34 #x13 #x60 #xFF #x4B #x1C #x51 #xFF #x6C #x28 #x3C #xFF #x58 #x21 #x49 #xFF #x52 #x1E #x4D #xFF #x62 #x25 #x43 #xFF #x4E #x1D #x4F #xFF #x73 #x2B #x38 #xFF #x86 #x32 #x2C #xFF #x8D #x35 #x27 #xFF #xA4 #x3D #x19 #xFF #x8D #x35 #x27 #xFF #x73 #x2B #x38 #xFF #x4E #x1D #x4F #xFF #x52 #x1E #x4D #xFF #x4E #x1D #x4F #xFF #x86 #x32 #x2C #xFF #x90 #x36 #x25 #xFF #x6C #x28 #x3C #xFF #x7D #x2E #x32 #xFF #x7D #x2E #x32 #xFF #xA4 #x3D #x19 #xFF #x9A #x39 #x1F #xFF #x79 #x2D #x34 #xFF #x45 #x19 #x56 #xFF #x5F #x23 #x45 #xFF #xA1 #x3C #x1B #xFF #x94 #x37 #x23 #xFF #x76 #x2C #x36 #xFF #x90 #x36 #x25 #xFF #x76 #x2C #x36 #xFF #x5C #x22 #x47 #xFF #x52 #x1E #x4D #xFF #x3B #x16 #x5C #xFF #x48 #x1B #x53 #xFF #x37 #x14 #x5E #xFF #x34 #x13 #x60 #xFF #x48 #x1B #x53 #xFF #x58 #x21 #x49 #xFF #x4E #x1D #x4F #xFF #x48 #x1B #x53 #xFF #x4E #x1D #x4F #xFF #x4E #x1D #x4F #xFF #x24 #x0D #x6A #xFF #x00 #x00 #x82 #xFF #x1D #x0B #x6F #xFF #x1A #x09 #x71 #xFF #x10 #x06 #x77 #xFF #x06 #x02 #x7D #xFF #x10 #x06 #x77 #xFF #x09 #x03 #x7B #xFF #x1A #xB0 #x1A #xFF #x27 #x96 #x27 #xFF #x23 #x9D #x23 #xFF #x29 #x92 #x29 #xFF #x27 #x96 #x27 #xFF #x2B #x8E #x2B #xFF #x28 #x94 #x28 #xFF #x1B #xAE #x1B #xFF #x17 #x08 #x73 #xFF #x4B #x1C #x51 #xFF #x62 #x25 #x43 #xFF #x73 #x2B #x38 #xFF #x62 #x25 #x43 #xFF #x58 #x21 #x49 #xFF #x4E #x1D #x4F #xFF #x52 #x1E #x4D #xFF #x52 #x1E #x4D #xFF #x52 #x1E #x4D #xFF #x58 #x21 #x49 #xFF #x5F #x23 #x45 #xFF #x73 #x2B #x38 #xFF #x8A #x33 #x29 #xFF #x80 #x30 #x30 #xFF #x83 #x31 #x2E #xFF #x73 #x2B #x38 #xFF #x8A #x33 #x29 #xFF #x9D #x3B #x1D #xFF #xC8 #x4B #x02 #xFF #xBF #x4A #x00 #xFF #xC2 #x4B #x00 #xFF #xB2 #x49 #x00 #xFF #xA2 #x47 #x00 #xFF #xA5 #x47 #x00 #xFF #x9C #x46 #x00 #xFF #xA2 #x47 #x00 #xFF #xB8 #x4A #x00 #xFF #xC8 #x4B #x02 #xFF #xC8 #x4B #x02 #xFF #xB2 #x49 #x00 #xFF #x9C #x46 #x00 #xFF #x99 #x46 #x00 #xFF #xB8 #x4A #x00 #xFF #xC8 #x4C #x00 #xFF #xA7 #x3E #x17 #xFF #x9D #x3B #x1D #xFF #xA1 #x3C #x1B #xFF #x83 #x31 #x2E #xFF #x4E #x1D #x4F #xFF #x37 #x14 #x5E #xFF #xB4 #x43 #x0E #xFF #xA7 #x3E #x17 #xFF #xA4 #x3D #x19 #xFF #xAE #x41 #x12 #xFF #xB4 #x43 #x0E #xFF #xB4 #x43 #x0E #xFF #xB4 #x43 #x0E #xFF #xAE #x41 #x12 #xFF #xB8 #x45 #x0C #xFF #xC2 #x48 #x06 #xFF #xAE #x41 #x12 #xFF #x90 #x36 #x25 #xFF #x6C #x28 #x3C #xFF #x55 #x20 #x4B #xFF #x45 #x19 #x56 #xFF #x37 #x14 #x5E #xFF #x2A #x10 #x66 #xFF #x2A #x10 #x66 #xFF #x31 #x12 #x62 #xFF #x45 #x19 #x56 #xFF #x55 #x20 #x4B #xFF #x62 #x25 #x43 #xFF #x55 #x20 #x4B #xFF #x52 #x1E #x4D #xFF #x52 #x1E #x4D #xFF #x52 #x1E #x4D #xFF #x4B #x1C #x51 #xFF #x4E #x1D #x4F #xFF #x58 #x21 #x49 #xFF #x62 #x25 #x43 #xFF #x6C #x28 #x3C #xFF #x6F #x29 #x3A #xFF #x73 #x2B #x38 #xFF #x73 #x2B #x38 #xFF #x6F #x29 #x3A #xFF #x6F #x29 #x3A #xFF #x76 #x2C #x36 #xFF #x83 #x31 #x2E #xFF #x90 #x36 #x25 #xFF #x97 #x38 #x21 #xFF #xAB #x40 #x14 #xFF #xC5 #x4A #x04 #xFF #xC5 #x4B #x00 #xFF #xB5 #x49 #x00 #xFF #xA8 #x48 #x00 #xFF #x99 #x46 #x00 #xFF #x92 #x45 #x00 #xFF #x92 #x45 #x00 #xFF #x92 #x45 #x00 #xFF #x99 #x46 #x00 #xFF #x99 #x46 #x00 #xFF #x85 #x43 #x00 #xFF #x85 #x43 #x00 #xFF #x95 #x45 #x00 #xFF #x9C #x46 #x00 #xFF #x9F #x46 #x00 #xFF #xA8 #x48 #x00 #xFF #xB2 #x49 #x00 #xFF #xB8 #x4A #x00 #xFF #xC2 #x4B #x00 #xFF #xC8 #x4C #x00 #xFF #xC5 #x4A #x04 #xFF #xBB #x46 #x0A #xFF #xB4 #x43 #x0E #xFF )) ;;; Initialize the data... ;;; Once we've initialized *icosahedron-texture-data* we nolonger require ;;; temp-icosahedron-texture-data. (defun get-icosahedron-texture-data () (when temp-icosahedron-texture-data (setq *icosahedron-texture-data* (opengl:make-gl-vector :unsigned-8 (* 64 64 4) :contents temp-icosahedron-texture-data) temp-icosahedron-texture-data nil ;; free the data ) ) *icosahedron-texture-data*)
87,966
Common Lisp
.lisp
1,043
78.255992
161
0.572249
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
4ed15d3d63db7fdd3bc27324808af793c22ed2f47a47a159dc263b071e230f50
826
[ -1 ]
827
load.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/load.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/load.lisp,v 1.7.13.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "CL-USER") (load (current-pathname "../load")) (load (current-pathname "defsys")) (compile-system "OPENGL-EXAMPLES" :load t)
367
Common Lisp
.lisp
6
59
158
0.706215
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
c3892f7877ed219e0defa84fd4c19ec1bc3b3b847e159081ef48ded9c46af6f0
827
[ -1 ]
828
defsys.lisp
cac-t-u-s_om-sharp/src/packages/space/OpenGL/lw-opengl/examples/defsys.lisp
;; -*- Mode: Lisp; rcs-header: "$Header: /hope/lwhope1-cam/hope.0/compound/9/LISPopengl-examples/RCS/defsys.lisp,v 1.15.13.1 2014/05/27 20:56:57 davef Exp $" -*- ;; Copyright (c) 1987--2015 LispWorks Ltd. All rights reserved. (in-package "CL-USER") (defsystem "OPENGL-EXAMPLES" () :members (("OPENGL" :type :system :root-module nil) "arrows" "icosahedron" "texture" "3d-text") :rules ((:in-order-to :compile :all (:requires (:load "OPENGL"))) (:in-order-to :compile "icosahedron" (:requires (:load "arrows"))) ))
546
Common Lisp
.lisp
15
33.2
161
0.663498
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
e8eba6b435e3fe6d78bfc8b674c178f8fba17be1853bea756d952ad0c44fa1dc
828
[ -1 ]
829
metronome.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/metronome.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson, D. Bouche ;============================================================================ (in-package :om) ;========================================================================= ; METRONOME: An object to use as metronome in play-editor-mixin ;========================================================================= (defclass metronome (schedulable-object) ((editor :initform nil :initarg :editor :accessor editor) (tempo :initform 60.0 :initarg :tempo :accessor tempo) (time-signature :initform '(4 4) :initarg :time-signature :accessor time-signature) (metronome-on :initform nil :initarg :metronome-on :accessor metronome-on) (click :initform '(nil nil) :initarg :click :accessor click))) (defmethod get-obj-dur ((self metronome)) *positive-infinity*) ;;; the editor attached to metronome must return a tempo-automation instance from this method ;;; Note: the metronome reports changes to the editor with update-to-editor (defmethod editor-get-tempo-automation ((editor t)) nil) (defmethod get-action-list-for-play ((self metronome) time-interval &optional parent) (when (editor-get-tempo-automation (editor self)) (filter-list (loop for beat in (tempo-automation-get-beat-grid (editor-get-tempo-automation (editor self)) (car time-interval) (cadr time-interval)) collect (list (car beat) #'(lambda () (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOn :chan 10 :port 0 :fields (list 32 127))) (om-midi::midi-send-evt (om-midi:make-midi-evt :type :keyOff :chan 10 :port 0 :fields (list 32 127))) ))) (car time-interval) (cadr time-interval) :key 'car))) (defmethod metronome-on/off ((self metronome) on) (setf (metronome-on self) on) (when (editor self) (if on ;;; activate: (if (eq (state (get-obj-to-play (editor self))) :play) (player-play-object (player (editor self)) self nil :interval (list (get-obj-time (get-obj-to-play (editor self))) nil))) ;;; deactivate (player-stop-object (player (editor self)) self)))) (defmethod set-tempo ((self metronome) new-tempo) (setf (tempo self) new-tempo) (with-schedulable-object self (when (and (editor self) (get-g-component (editor self) :tempo-box)) ;;; see below... (set-value (cadr (om-subviews (get-g-component (editor self) :tempo-box))) new-tempo)) (update-to-editor (editor self) self))) (defmethod set-time-signature ((self metronome) new-signature) (with-schedulable-object self (setf (time-signature self) new-signature))) ;;;======================================= ;;; add controlers in editors: ;;;======================================= (defmethod player-play-object ((self scheduler) (object metronome) caller &key parent interval) (declare (ignore parent interval)) (when (metronome-on object) (call-next-method))) (defmethod player-continue-object ((self scheduler) (object metronome)) (when (metronome-on object) (call-next-method))) (defmethod player-stop-object ((self scheduler) (object metronome)) (call-next-method)) (defmethod player-pause-object ((self scheduler) (object metronome)) (call-next-method))
4,350
Common Lisp
.lisp
84
42.5
101
0.542157
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
c1da64e202f0b5e3d1c853871ee926a5d73c110d7356d7cc75c29ff5ca3cf165
829
[ -1 ]
830
sequencer-box.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer-box.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson ;============================================================================ (in-package :om) (defclass OMBoxSequencer (OMBoxPatch) ()) (defmethod special-box-p ((name (eql 'sequencer))) t) (defmethod get-box-class ((self OMSequencer)) 'OMBoxSequencer) (defmethod omNG-make-special-box ((reference (eql 'sequencer)) pos &optional init-args) (omNG-make-new-boxcall (make-instance 'OMSequencerInternal :name (if init-args (format nil "~A" (car (list! init-args))) "new-sequencer")) pos init-args ;; don't need to pass them in principle.. )) (defmethod next-optional-input ((self OMBoxSequencer)) (< (length (get-optional-inputs self)) 2)) (defmethod more-optional-input ((self OMBoxSequencer) &key name (value nil val-supplied-p) doc reactive) (declare (ignore name doc)) ;;; the first one is already here (add-optional-input self :name (if (get-optional-inputs self) "objs" "time") :value (if val-supplied-p value nil) :reactive reactive) t) ;;;===================================== ;;; BOX DISPLAY ;;;===================================== (defmethod display-modes-for-object ((self OMSequencer)) '(:mini-view :text :hidden)) (defmethod draw-mini-view ((self OMSequencer) box x y w h &optional time) (let* ((boxes (remove-if #'(lambda (b) (not (group-id b))) (get-all-boxes self))) (n-tracks (apply #'max (or (mapcar #'group-id boxes) '(1)))) (dur (get-obj-dur self)) (box-h (/ (- h 30) n-tracks))) (flet ((t-to-x (xpos) (round (* (/ xpos dur) w))) (id-to-y (id) (+ 8 (* box-h (1- id))))) (loop for b in boxes do (om-draw-rect (+ x (t-to-x (box-x b))) (+ y (id-to-y (group-id b))) (t-to-x (box-w b)) box-h :fill t :color (box-draw-color b)) (om-draw-rect (+ x (t-to-x (box-x b))) (+ y (id-to-y (group-id b))) (t-to-x (box-w b)) box-h :color (om-def-color :gray) :fill nil) ) ))) ;;;===================================== ;;; EVAL / COMPILE ;;;===================================== (defun default-delta (tlist) (cond ((null tlist) 0) ((= (length tlist) 1) (car tlist)) (t (- (car (last tlist 1)) (car (last tlist 2)))))) (defmethod put-boxes-in-sequencer ((self OMBoxSequencer)) (let* ((tlist-in (find "time" (get-optional-inputs self) :key #'name :test #'string-equal)) (tlist (and tlist-in (omng-box-value tlist-in))) (objs-in (find "objs" (get-optional-inputs self) :key #'name :test #'string-equal)) (objs (and objs-in (omng-box-value objs-in)))) (when objs (let* ((seq (reference self)) (timelist (if (listp tlist) tlist (list 0 tlist))) (objlist (list! objs)) (deftime (default-delta timelist)) (facty (round 100 (length objlist)))) (s-clear seq) (close-editor seq) (loop with old-time = 0 for item in objlist for i from 1 do (let* ((x (if timelist (pop timelist) (+ old-time deftime)))) (let ((newbox (cond ((subtypep (type-of item) 'OMBox) (let ((b (clone item))) (setf (lambda-state b) nil) b)) ((subtypep (type-of item) 'OMPatch) (if (is-persistant item) (omNG-make-new-boxcall item (omp 0 0)) (omNG-make-new-boxcall (clone item) (omp 0 0)) )) (t (omng-make-new-boxcall (class-of item) (omp 0 0) item))))) (when newbox (setf (box-x newbox) x (box-w newbox) 1000 ;;; (default) (box-y newbox) (* i facty) (box-h newbox) (- facty) (group-id newbox) (mod i 4)) (setf (display newbox) (or (find :mini-view (display-modes-for-object (get-box-value newbox))) :text)) (omNG-add-element seq newbox) )) (setf old-time x))) ;;; the duration of the patch boxes is not computed yet at this point.... (setf (range seq) (list :x1 0 :x2 (or (get-obj-dur seq) 4000) :y1 -10 :y2 110)) t )))) (defmethod omng-box-value :before ((self OMBoxSequencer) &optional numout) (unless (or (equal (lock-state self) :locked) (and (or (equal (lock-state self) :eval-once) (get-pref-value :general :auto-ev-once-mode)) (equal (ev-once-flag self) (get-ev-once-flag *ev-once-context*)))) (put-boxes-in-sequencer self) ;; eval the boxes in tracks but not the control-patch (eval-sequencer (reference self) NIL) )) (defmethod eval-box-inputs ((self OMBoxSequencer)) (loop for input in (get-standard-inputs self) collect (omNG-box-value input))) (defmethod compile-patch ((self OMSequencer)) (setf (compiled? self) t) (compile-patch (ctrlpatch self))) (defmethod compiled-fun-name ((self OMSequencer)) (compiled-fun-name (ctrlpatch self))) (defmethod compiled? ((self OMSequencer)) (compiled? (ctrlpatch self)))
6,338
Common Lisp
.lisp
134
35.970149
122
0.497243
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
6f908ffaf424a9feecdd6925f67b65ebbf7296eb9a2ce944df03104ed06a8f38
830
[ -1 ]
831
sequencer-object.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer-object.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson, D. Bouche ;============================================================================ ;========================================================================= ; OMSequencer = MAQUETTE 2.0 ! ;========================================================================= (in-package :om) (defclass OMSequencer (OMPatch schedulable-object timed-object) ((ctrlpatch :accessor ctrlpatch :initform nil :initarg :ctrlpatch) (range :accessor range :initform '(:x1 0 :x2 20000 :y1 0 :y2 100) :initarg :range) (view-mode :accessor view-mode :initarg :view-mode :initform :tracks) ;;; :tracks or :maquette (control-patch-visible-p :accessor control-patch-visible-p :initarg :control-patch-visible-p :initform nil)) (:metaclass omstandardclass)) (defclass OMSequencerFile (OMPersistantObject OMSequencer) () (:default-initargs :icon :sequencer-file) (:metaclass omstandardclass)) (add-om-doctype :sequencer "oseq" "Sequencer") (defclass OMSequencerInternal (OMSequencer) () (:default-initargs :icon :sequencer) (:metaclass omstandardclass)) ;;;=========================== (defmethod get-object-type-name ((self OMSequencer)) "Sequencer") (defmethod object-doctype ((self OMSequencer)) :sequencer) (defmethod make-new-om-doc ((type (eql :sequencer)) name) (make-instance 'OMSequencerFile :name name)) ;; For conversions (defmethod internalized-type ((self OMSequencerFile)) 'OMSequencerInternal) (defmethod externalized-type ((self OMSequencer)) 'OMSequencerFile) (defmethod externalized-icon ((self OMSequencer)) :sequencer-file) (defmethod type-check ((type (eql :sequencer)) obj) (let ((seq (ensure-type obj 'OMSequencer))) (when seq (change-class seq 'OMSequencerFile) (setf (icon seq) :sequencer-file)) seq)) (defmethod unregister-document ((self OMSequencer)) (player-stop-object *general-player* self) (call-next-method)) (defmethod play-obj? ((self OMSequencer)) t) (defmethod n-tracks ((self OMSequencer)) (n-tracks (editor self))) (defmethod n-current-active-tracks ((self OMSequencer)) (length (loop for box in (get-all-boxes self) if (box-being-rendered? self box) collect box))) (defmethod copy-contents ((from OMSequencer) (to OMSequencer)) (let ((rep (call-next-method))) (set-control-patch rep (om-copy (ctrlpatch from))) (setf (range rep) (range from)) rep)) ;;;=============================== ;;; SEQUENCER CONTENTS (BOXES) ;;;=============================== (defmethod get-obj-dur ((self OMSequencer)) (loop for tb in (get-all-boxes self) maximize (get-box-end-date tb))) (defmethod get-all-boxes ((self OMSequencer) &key (sorted nil) (track nil)) (let* ((boxes (get-boxes self))) (when track (setf boxes (remove-if-not #'(lambda (id) (and (numberp id) (= id track))) boxes :key 'group-id))) (when sorted (setf boxes (sort boxes '< :key 'get-box-onset))) boxes)) (defmethod get-box-onset ((self OMBox)) (box-x self)) (defmethod set-box-onset ((self OMBox) o) (setf (box-x self) o) (when (get-box-value self) (set-object-onset (get-box-value self) o))) ;(defmethod get-box-onset ((self omboxpatch)) (box-x self)) ;(defmethod set-box-onset ((self omboxpatch) o) ; (setf (box-x self) o) ; (when (get-box-value self) (set-object-onset (get-box-value self) o))) (defparameter *temporalbox-def-w* 1000) (defmethod get-box-duration ((self OMBox)) (box-w self)) (defmethod set-box-duration ((self OMBox) d) (setf (box-w self) (or d *temporalbox-def-w*)) (when (get-box-value self) (set-object-interval (get-box-value self) (list 0 (box-w self)))) (box-w self)) (defmethod get-box-end-date ((self OMBox)) (+ (get-box-onset self) (get-box-duration self))) (defmethod get-box-time-span ((self OMBox)) (list (get-box-onset self) (get-box-end-date self))) ;;; the box has changed, it must be updated (depending on its context) ;;; for convenience we do not allow the box being smaller than 100ms (defmethod contextual-update ((self OMBox) (container OMSequencer)) (let ((object (get-box-value self))) (set-object-onset object (box-x self)) (let ((duration (and (play-obj? object) (get-obj-dur object)))) (when duration ;;; (max 100 (or (get-obj-dur (get-box-value self)) *temporalbox-def-w*)) (set-box-duration self duration))) (when (editor container) (let ((view (get-view-from-mode (editor container)))) (if (listp view) ;;; tracks mode (when (group-id self) (om-invalidate-view (nth (1- (group-id self)) view))) ;;; maquette mode (update-temporalboxes view) ))))) ;;;========================================= ;;; EVALUATION ;;;========================================= ;;; NOT GOOD !!! NEED TO EVAL JUST TERMINAL BOXES (defmethod eval-sequencer ((seq OMSequencer) &optional (with-control-patch t) (from-editor nil)) (when from-editor (setf *current-eval-panel* (get-editor-view-for-action (editor seq)))) (loop for box in (get-all-boxes seq) when (not (find-if #'connections (outputs box))) do (progn (eval-box box) (reset-cache-display box) (contextual-update box seq) )) ; (set-meta-inputs (ctrlpatch seq) (car (references-to seq)) seq) (when (and from-editor (ctrlpatch seq) (editor (ctrlpatch seq))) (setf *current-eval-panel* (editor-view (ctrlpatch seq)))) (when with-control-patch (mapcar 'eval-box (get-boxes-of-type (ctrlpatch seq) 'omoutbox))) (clear-ev-once seq) (clear-ev-once (ctrlpatch seq)) (when from-editor (setf *current-eval-panel* nil)) ;(compile-patch (ctrlpatch seq)) ;(apply (intern (string (compiled-fun-name (ctrlpatch seq))) :om) `(,seq)) ) ;;=========================================================================== ;; Scheduling ;;=========================================================================== ;;; called after user modifications o check if resecheduling is required (defmethod box-being-rendered? ((self OMSequencer) (tb OMBox)) (let ((current-time (get-obj-time self))) (and (> (get-box-end-date tb) current-time) (< (get-box-onset tb) current-time)))) (defmethod box-cross-interval ((tb OMBox) interval) (not (or (< (get-box-end-date tb) (car interval)) (>= (get-box-onset tb) (cadr interval))))) (defmethod get-computation-list-for-play ((self OMSequencer) &optional interval) (loop for box in (get-all-boxes self :sorted t) append (let ((b box)) (when (and (find-if 'reactive (outputs box)) (or (not interval) (in-interval (- (get-box-onset box) (pre-delay box)) interval :exclude-high-bound t)) (not (ready b)) ;; avoids computing it several times ) (setf (ready b) t) (list (list (- (get-box-onset box) (pre-delay box)) (get-box-onset box) #'(lambda () ;; (with-schedulable-object self (eval-box b)) ;; with-schedulable-object has undesired effects when used in a loop (eval-box b) (clear-ev-once b) (reset-cache-display b) (set-display b :value) (contextual-update b self) ))) )))) (defmethod reset-box ((self OMBox)) nil) (defmethod reset-box ((self OMBoxAbstraction)) (setf (ready self) nil)) (defmethod reset-boxes ((self OMSequencer)) (loop for tb in (get-all-boxes self) do (reset-box tb))) ;;; from scheduler functions (defmethod reset-I :before ((self OMSequencer) &optional date) (reset-boxes self)) (defmethod get-action-list-for-play ((self OMSequencer) time-interval &optional parent) (sort (loop for box in (get-all-boxes self :sorted t) when (box-cross-interval box time-interval) ;; if it's a reactive box it must be "ready" (= computed) ;; when (not (and (find-if 'reactive (outputs box)) (not (ready box)))) when (group-id box) ;;; only boxes in tracks are played append (let ((interval-in-object (list (max (- (car time-interval) (get-box-onset box)) 0) (min (- (cadr time-interval) (get-box-onset box)) (get-box-duration box))))) (mapcar #'(lambda (b) (incf (car b) (get-box-onset box)) b) (get-action-list-for-play (play-obj-from-value (get-box-value box) box) interval-in-object self)))) '< :key 'car)) (defmethod set-object-current-time ((self OMSequencer) time) (set-time-callback self time) (call-next-method)) (defmethod set-time-callback ((self t) time) nil) (defmethod set-time-callback ((self OMSequencer) time) (let ((interval (or (interval self) (list time *positive-infinity*)))) (loop for box in (get-all-boxes self :sorted t) do (let ((object (get-box-value box))) (if (box-cross-interval box interval) (progn (set-object-interval object (list (- time (get-box-onset box)) (cadr interval))) (if (in-interval time (list (get-box-onset box) (get-box-end-date box))) (progn (set-object-current-time object (- (car interval) (get-box-onset box))) (set-time-callback object (- time (get-box-onset box)))) (player-stop-object *general-player* object))) (player-stop-object *general-player* object)))))) #| (with-schedulable-object seq ;;;Move the object (setf (onset tb) (max (+ (onset tb) dx) 0)) (if (box-being-rendered? seq tb) ;;;If the object was and is still being rendered, just set its time (set-object-current-time (object-from-box tb) (- (get-obj-time seq) (onset tb))) ;;;If the object was being rendered and is not anymore, stop- it (player-stop-object (player (editor seq)) (object-from-box tb)))) |# (defmethod player-play-object ((self scheduler) (object OMSequencer) caller &key parent interval) ;;;Ajouter ici la task begin : (mp:mailbox-send (taskqueue *engine*) *taskbegin*) (declare (ignore parent interval)) (call-next-method)) (defmethod player-pause-object ((self scheduler) (object OMSequencer)) ;;;Pause all boxes under the sequencer cursor (that is being rendered). ;;;Note : useful only for objects triggered by the sequencer (hierarchical). ;(loop for box in (get-all-boxes object) ; when (box-being-rendered? object box) ; do (player-pause-object self (get-box-value box))) (call-next-method)) (defmethod player-continue-object ((self scheduler) (object OMSequencer)) ;;;Continue all boxes under the sequencer cursor (that is being rendered). ;;;Note : useful only for objects triggered by the sequencer (hierarchical). ;(loop for box in (get-all-boxes object) ; when (box-being-rendered? object box) ; do (player-continue-object self (get-box-value box))) (call-next-method)) (defmethod player-stop-object ((self scheduler) (object OMSequencer)) ;;;Stop all boxes under the sequencer cursor (that is being rendered). ;;;Note : useful only for objects triggered by the sequencer (hierarchical). (loop for box in (get-all-boxes object) do (player-stop-object self (get-box-value box))) ;;;Ajouter ici la task end : (mp:mailbox-send (taskqueue *engine*) *taskend*) (call-next-method)) ;;;=============================== ;;; MODIFY/UPDATE SEQUENCER CONTENTS ;;;=============================== (defmethod allowed-element ((self OMSequencer) (elem time-sequence)) t) (defmethod allowed-element ((self OMSequencer) (elem timed-object)) (plusp (get-obj-dur elem))) ;; no object that have no duration => must be put in containers (defmethod allowed-element ((self OMSequencer) (elem OMBoxEditCall)) (allowed-element self (get-box-value elem))) (defmethod allowed-element ((self OMSequencer) (elem OMComment)) nil) (defmethod omNG-add-element ((self OMSequencer) (elem OMBox)) (set-box-duration elem (or (and (play-obj? (get-box-value elem)) (get-obj-dur (get-box-value elem))) (box-w elem))) ;; (unless (group-id elem) (setf (group-id elem) 1)) (with-schedulable-object self (call-next-method))) ;; evaluate the patch before ? (defmethod omNG-add-element ((seq OMSequencer) (tb OMBoxPatch)) ;(omng-box-value tb 0) (call-next-method)) (defmethod omNG-add-element ((seq OMSequencer) (tb OMBoxEditCall)) (setf (lock-state tb) :locked) (call-next-method)) (defmethod omng-remove-element ((seq OMSequencer) (tb OMBox)) ;;;If the box is under the sequencer cursor (that is being rendered), stop it. ;;;Note : useful only for objects triggered by the sequencer (hierarchical). (when (box-being-rendered? seq tb) (player-stop-object *general-player* (get-box-value tb))) ;;;Perform the remove operation asking the scheduler for a replan. (with-schedulable-object seq (call-next-method))) (defmethod move-box-in-sequencer ((seq OMSequencer) (tb OMBox) &key (dx 0) (dy 0)) ;;; this is +/- like move-box (with set-box-onset) (set-box-onset tb (max (+ (get-box-onset tb) dx) 0)) (setf (box-y tb) (+ (box-y tb) dy)) (when (frame tb) (update-frame-to-box-position tb)) (when (container tb) (report-modifications (editor (container tb)))) (update-connections tb) ;;; specific (if (and (get-box-value tb) (eq (get-object-state (get-box-value tb)) :play)) (let ((ti (get-obj-time seq))) (if (in-interval ti (list (get-box-onset tb) (get-box-end-date tb))) (set-object-current-time (get-box-value tb) (- ti (get-box-onset tb))) (player-stop-object *general-player* (get-box-value tb))))) ) ;;;====================================== ;;;SIMULATE TRACKS USING BOXES' GROUP-ID ;;;====================================== (defmethod add-box-in-track ((seq OMSequencer) (tb OMBox) tracknum) (setf (group-id tb) tracknum) (let* ((yrange (- (getf (range seq) :y2) (getf (range seq) :y1))) (trackw (round yrange (n-tracks seq))) (y (+ (getf (range seq) :y1) (if tracknum (* (- (n-tracks seq) (1- tracknum)) trackw) (round yrange 2))))) (setf (box-y tb) y (box-h tb) (round yrange 10)) (omNG-add-element seq tb) (om-invalidate-view (nth (1- tracknum) (get-g-component (editor seq) :track-views))))) (defmethod* get-objects ((self OMSequencer) &key (sorted nil) (track nil)) :initvals '(nil nil nil) :indoc '("a sequencer" "sort the boxes by onset?" "select a specific track (number)") :doc "Returns the objects/values of the boxes of <self>, or from the track <track> if specified, sorted by onset if <sorted>." (mapcar #'get-box-value (remove-if-not #'group-id (get-all-boxes self :sorted sorted :track track)))) ;;;========================================= ;;; TIME MARKERS METHODS ;;;========================================= ;;; Note: this is not used as long as sequencers are ;;; not embedded in other sequencers (defmethod get-time-markers ((self OMSequencer)) (loop for box in (boxes self) append (get-time-markers box))) (defmethod get-time-markers ((self OMBox)) (when (and (subtypep (type-of (get-box-value self)) 'time-sequence) (show-markers self)) (get-time-markers (get-box-value self)))) (defmethod get-elements-for-marker ((self OMSequencer) marker) (loop for box in (boxes self) collect (list box (get-elements-for-marker box marker)))) (defmethod get-elements-for-marker ((self OMBox) marker) (when (get-box-value self) (get-elements-for-marker (get-box-value self) marker))) (defmethod translate-elements-from-time-marker ((self OMSequencer) elems dt) (loop for elem in elems do (when (not (member nil (cdr elem))) (temporal-translate-points (car elem) (cdr elem) dt)))) (defmethod set-property ((self OMBox) (prop-id (eql :show-markers)) val) (call-next-method) ;;; in order to update the rulers (when (editor (container self)) (editor-invalidate-views (editor (container self))))) ;;;================================= ;;; PERSISTENCE / OM-SAVE ;;;================================= (defmethod save-patch-contents ((self OMSequencer) &optional (box-values nil)) (append (call-next-method self t) `((:range ,(range self)) (:control-patch ,(omng-save (ctrlpatch self))) (:loop-interval ,(interval self)) (:loop-on ,(looper self)) (:view-mode ,(view-mode self)) (:control-patch-visible-p ,(control-patch-visible-p self)) ))) (defmethod load-patch-contents ((patch OMSequencer) data) (let ((seq (call-next-method)) (patch (find-value-in-kv-list data :control-patch)) (range (find-value-in-kv-list data :range)) (interval (find-value-in-kv-list data :loop-interval)) (loop-on (find-value-in-kv-list data :loop-on)) (view-mode (find-value-in-kv-list data :view-mode)) (control-patch-visible-p (find-value-in-kv-list data :control-patch-visible-p))) (when patch (set-control-patch seq (omng-load patch))) (when range (setf (range seq) range)) (when interval (setf (interval seq) interval)) (setf (looper seq) loop-on) (when view-mode (setf (view-mode seq) view-mode)) (setf (control-patch-visible-p seq) control-patch-visible-p) seq)) (defmethod om-load-from-id ((id (eql :sequencer)) data) (let ((seq (make-instance 'OMSequencerInternal :name (find-value-in-kv-list data :name)))) (load-patch-contents seq data) seq)) (defmethod omng-save-relative ((self OMSequencerFile) ref-path) `(:sequencer-from-file ,(if (mypathname self) (omng-save (relative-pathname (mypathname self) ref-path)) (omng-save (pathname (name self)))))) (defmethod om-load-from-id ((id (eql :sequencer-from-file)) data) (let* ((path (omng-load (car data))) (checked-path (and (pathname-directory path) ;; normal case (check-path-using-search-path path))) (seq (if checked-path (load-doc-from-file checked-path :sequencer) ;;; no pathname-directory can occur while loading old patch abstractions from OM6 ;;; in this case we look for a not-yet-save file with same name in registered documents (let ((registered-entry (find (pathname-name path) *open-documents* :test 'string-equal :key #'(lambda (entry) (name (doc-entry-doc entry)))))) (when registered-entry (doc-entry-doc registered-entry))) ))) (unless seq (om-beep-msg "SEQUENCER FILE NOT FOUND: ~S !" path) (setf seq (make-instance'OMSequencerFile :name (pathname-name path))) (setf (mypathname seq) path)) seq))
19,980
Common Lisp
.lisp
401
43.162095
128
0.611034
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
57b14b6096312d5407324fdf162891ef650ddae3e3b73c7d3d2458754644b90d
831
[ -1 ]
832
sequencer-api.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer-api.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: D. Bouche ;============================================================================ ; SEQUENCER EDIT API ;========================================================================= (in-package :om) ;;;========================================= ;;; PLAYER ;;;========================================= (defmethod* s-play ((self OMSequencer) &optional trigger) :initvals '(nil nil) :indoc '("sequencer" "anything") :doc "Play <self> (a sequencer). <trigger> allows connecting anything else to be evaluated at the same time." :icon 's-play (declare (ignore trigger)) (when (editor self) (if (eq (state self) :pause) (player-continue-object (player (editor self)) self) (player-play-object (player (editor self)) self (editor self))) (button-select (play-button (editor self))) (button-unselect (pause-button (editor self))) t)) (defmethod* s-pause ((self OMSequencer) &optional trigger) :initvals '(nil nil) :indoc '("sequencer" "anything") :doc "Pause <self> (a sequencer). <trigger> allows connecting anything else to be evaluated at the same time." :icon 's-pause (declare (ignore trigger)) (when (editor self) (player-pause-object (player (editor self)) self) (button-select (pause-button (editor self))) (button-unselect (play-button (editor self))) t)) (defmethod* s-stop ((self OMSequencer) &optional trigger) :initvals '(nil nil) :indoc '("sequencer" "anything") :doc "Stop <self> (a sequencer). <trigger> allows connecting anything else to be evaluated at the same time." :icon 's-stop (declare (ignore trigger)) (when (editor self) (player-stop-object (player (editor self)) self) (button-unselect (play-button (editor self))) (button-unselect (pause-button (editor self))) t)) (defmethod* s-loop ((self OMSequencer) t1 t2 &optional trigger) :initvals '(nil nil nil nil) :indoc '("sequencer" "start-time (nil or ms)" "end-time (nil or ms)" "anything") :doc "Set the sequencer (<self>) loop interval from <t1> to <t2>. Set the loop on if either <t1> or <t2> is not null. <trigger> allows connecting anything else to be evaluated at the same time." :icon 's-loop (declare (ignore trigger)) (let* ((editor (editor self)) (begin (or t1 0)) (end (or t2 begin)) (loop-on (and (or t1 t2) t))) (when editor (editor-set-interval (editor self) (list begin end)) (editor-set-loop (editor self) loop-on) (if loop-on (button-select (repeat-button (editor self))) (button-unselect (repeat-button (editor self)))) t))) (defmethod* s-set-time ((self OMSequencer) (time integer) &optional trigger) :initvals '(nil nil nil) :indoc '("sequencer" "time (ms)" "anything") :doc "Set current play-time of <self> (a sequencer) to <time>. <trigger> allows connecting anything else to be evaluated at the same time." :icon 's-time (declare (ignore trigger)) (set-object-current-time self (max 0 (round time))) (reset-boxes self) time) (defmethod* s-get-time ((self OMSequencer)) :indoc '("sequencer") :doc "Get current play-time of <self> (a sequencer)." :icon 's-time (get-obj-time self)) ;;;========================================= ;;; OBJECTS ;;;========================================= (defmethod insert-object ((self OMSequencer) (object t) &key (time 0) (track 1) (pre-delay 0)) (declare (ignore pre-delay)) (let ((b (omng-make-new-boxcall (class-of object) (omp (or time 0) 0)))) (setf (value b) `(,object)) (set-display b :mini-view) (if (add-box-in-track self b track) t))) (defmethod insert-object ((self OMSequencer) (object ompatchinternal) &key (time 0) (track 1) (pre-delay 0)) (let ((b (omng-make-new-boxcall object (omp (or time 0) 0)))) (set-reactive b t) (setf (pre-delay b) pre-delay) (set-display b :mini-view) (if (add-box-in-track self b track) t))) (defmethod remove-object ((self OMSequencer) object &key multiple-instances) (let ((box (find object (boxes self) :key 'get-box-value))) (if box (omng-remove-element self box)) (if multiple-instances (loop while (setq box (find object (boxes self) :key 'get-box-value)) do (omng-remove-element self box))))) (defmethod move-object ((self OMSequencer) object &key multiple-instances (delta-t 0) (delta-y 0) track) (if (and multiple-instances (listp delta-t) (listp track)) (let ((boxes (loop for box in (sort (copy-list (boxes self)) '< :key 'get-box-onset) when (and (get-box-value box) (eq (get-box-value box) object)) collect box))) (mapcar #'(lambda (box dt dy trk) (set-box-onset box (max 0 (+ (get-box-onset box) dt))) (setf (box-y box) (+ (box-y box) dy)) (if trk (setf (group-id box) trk))) boxes delta-t delta-y track)) (let ((box (find object (boxes self) :key 'get-box-value))) (set-box-onset box (max 0 (+ (get-box-onset box) delta-t))) (setf (box-y box) (+ (box-y box) delta-y)) (if track (setf (group-id box) track))))) (defmethod clear ((self OMSequencer) &optional track) (loop for box in (get-all-boxes self :track track) do (omng-remove-element self box) (delete-box-frame (frame box)) ;;; removes the view (omng-delete box) ;;; deals with contents/references )) (defmethod* s-add ((seq OMSequencer) (object t) &key (time 0) (track 1) (pre-delay 0) trigger) :initvals '(nil nil 0 1 0 nil) :indoc '("sequencer" "a playable object" "onset (ms)" "track number" "pre-delay for reactive eval" "anything") :doc "Adds a box in the sequencer <seq>, track <track>, at time <time> containing <object> (a playable musical object). <pre-delay> sets this property for advanced computation when the box is reactive. <trigger> allows connecting anything else to be evaluated at the same time." (declare (ignore trigger)) (insert-object seq object :time time :track track :pre-delay pre-delay)) (defmethod* s-remove ((seq OMSequencer) object &key multiple-instances trigger) :initvals '(nil nil nil nil) :indoc '("sequencer" "a playable object from the sequencer" "remove all instances" "anything") :doc "Removes <object> from the sequencer <seq>, track <track>, at time <time> containing <object> (a playable musical object). If <multiple-instances> is not NIL, will try to eliminate all possible instances of <object> found in <seq>. <trigger> allows connecting anything else to be evaluated at the same time." (declare (ignore trigger)) (remove-object seq object :multiple-instances multiple-instances)) (defmethod* s-move ((seq OMSequencer) object &key multiple-instances (delta-t 0) (delta-y 0) track trigger) :initvals '(nil nil) :indoc '("sequencer" "a playable object from the sequencer" "move all instances" "time shift (ms)" "verticql shift" "track number" "anything") :doc "Moves <object> (an object from the sequencer <seq>): - in time (with a shift of <delta-t> - vertically (maquette view only) with a shift of <delta-y> - to another track <track> If <multiple-instances> is not NIL, will try to eliminate all possible instances of <object> found in <seq>. <trigger> allows connecting anything else to be evaluated at the same time." (declare (ignore trigger)) (move-object seq object :multiple-instances multiple-instances :delta-t delta-t :delta-y delta-y :track track)) (defmethod* s-clear ((seq OMSequencer) &key (track nil) trigger) :initvals '(nil nil) :indoc '("sequencer" "track number") :doc "Removes all boxes in <seq>, or in <track> if a track number is given." (declare (ignore trigger)) (clear seq track))
8,489
Common Lisp
.lisp
172
44.598837
144
0.628168
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
1d2408da2d7b099e0c89dba3cb288092de3f5ebe940ce5573fe79722e7633015
832
[ -1 ]
833
maquette-compatibility.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/maquette-compatibility.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson ;============================================================================ (in-package :om) ;;; load the Maquette / Converts to Sequencer (file) (defmacro om-load-maq2 (name boxes connections range markers &rest ignore) (declare (ignore range markers ignore)) `(let ((name-loaded ,name) (boxes-loaded ,boxes) (connections-loaded ,connections)) ;;; only top-level patch acually load their contents: (omng-load `(:sequencer (:name ,name-loaded) (:boxes .,(remove 'temp-marker (loop for box-code in boxes-loaded collect (eval box-code)) :key #'type-of)) (:connections .,(loop for c in connections-loaded collect (format-imported-connection c))) ) ) )) (defclass temp-marker () ()) (defmethod (setf doc) (doc self) nil) ;;; load the Maquette (internal) / Convert to Sequencer (defun om-load-maq-abs1 (name boxes connections range markers &rest ignore) (declare (ignore range markers ignore)) `(:sequencer (:name ,name) (:boxes .,(loop for box-code in boxes collect (eval box-code))) (:connections .,(loop for c in connections collect (format-imported-connection c))) ) ) ; (:input (:type :standard) (:name "time") (:value 1000)) (defun convert-maq-input (input) `(:input (:type :optional) ,(cddr input))) ;;; Maquette (internal) (defmethod om-load-boxcall ((self (eql 'maqabs)) name reference inputs position size value lock &rest rest) (declare (ignore value rest)) `(:box (:type :abstraction) (:reference ,reference) ;; contains the actual contents (:name ,name) (:x ,(om-point-x position)) (:y ,(om-point-y position)) (:w ,(and size (om-point-x size))) (:h ,(if size (om-point-y size) 48)) (:lock ,(if lock (cond ((string-equal lock "x") :locked) ((string-equal lock "&") :eval-once)))) (:lambda ,(if lock (cond ((string-equal lock "l") :lambda) ((string-equal lock "o") :reference)))) (:inputs .,(mapcar #'(lambda (i) (convert-maq-input (eval i))) inputs)) (:display :mini-view) ) ) ;;; Maquette (external) (defmethod om-load-boxcall ((self (eql 'maquette)) name reference inputs position size value lock &rest rest) (declare (ignore value rest)) (let ((loaded-reference (load-om6-patch-from-relative-path reference))) (om-load-boxcall 'abstraction name loaded-reference inputs position size value lock) )) ;;; TEMPOUT in patches = normal out (defun om-load-tempboxout (name position inputs &optional fname fsize) (om-load-boxout name 0 position inputs fname fsize)) ;;; => A BOX IN THE MAQUETTE (defun om-load-tempobj1 (name inputs refer numouts posx sizex clorf value ignorepict sizey posy strechfact &optional (store nil) (params nil) (lock nil) pict (showpict nil) (mute nil) (pos-locked nil) (showname nil) (doc "") &rest rest) (declare (ignore numouts ignorepict strechfact store params pict showpict mute pos-locked doc rest)) (multiple-value-bind (ref-type ref-val) (case (first refer) ;;; external abstractions (patchb (values 'patch-box (cadr refer))) (maq (values 'maquette (cadr refer))) ;;; internal abstractions (patch (values 'abstraction (cadr refer))) ;;; a bug (?) in OM6: the value is quoted only for internal maquettes... => eval (absmaq (values 'abstraction (eval (cadr refer)))) (yourobj (values NIL (cadr refer)))) (if ref-type ;;; => abstraction box (append (om-load-boxcall ref-type name ref-val inputs (om-make-point posx posy) (om-make-point sizex sizey) value lock) `((:color ,(omng-save clorf)) (:show-name ,showname) (:group-id ,(om-random 1 4)))) (append (om-load-boxinstance name ref-val inputs (om-make-point posx posy)) `((:w ,sizex) (:h ,sizey) (:color ,(omng-save clorf)) (:group-id ,(om-random 1 4)) )) ) )) ;;; META IN/OUTS: need some conversion (defun om-load-boxselfin (name position &optional fsize) (declare (ignore fsize name)) (om-print "Warning: 'self' input box converted to 'THISBOX': consider reconnecting the output using an 'OMBOX' SLOTS box." "Import/Compatibility") `(:box (:type :io) (:reference (:in (:type omselfin) (:index 0) (:name "THIS BOX"))) (:name "THIS BOX") (:x ,(om-point-x position)) (:y ,(om-point-y position)) (:outputs (:output (:name "out"))) )) (defun om-load-boxmaqselfin (name position &optional fsize) (declare (ignore name fsize)) (om-print "Warning: 'self-maquette' input box converted to 'thissequencer': consider reconnecting outputs using GET-OBJ-DUR / GET-BOXES / GET-OBJECTS." "Import/Compatibility") `(:box (:type :io) (:reference (:in (:type omsequencerin) (:index 0) (:name "THIS SEQUENCER"))) (:name "THIS SEQUENCER") (:x ,(om-point-x position)) (:y ,(om-point-y position)) (:outputs (:output (:name "out"))) ) ) ;;; IN/OUT in the maquette: no more supported (defun om-load-maq-boxin (name indice position docu &optional fname val fsize) (declare (ignore name indice position docu fname val fsize)) (om-print "Warning: Maquette inputs are no more supported in the sequencer. Use the control-patch." "Import/Compatibility") NIL) (defun om-load-maq-boxout (name indice position inputs &optional fname fsize) (declare (ignore name indice position inputs fname fsize)) (om-print "Warning: Maquette outputs no more supported in the sequencer. Use control-patch." "Import/Compatibility") NIL) ;====================================== ; old forms not supported: ;====================================== ; old-old: not exported by OM6 ; (defun om-load-maq1 (name boxes connections range markers &rest ignore) ) ; (defun om-load-temp-patch (name boxes connections &optional version) ) ; (defun om-load-temp-patch1 (name boxes connections &optional version pictlist) )
6,987
Common Lisp
.lisp
153
38.960784
153
0.604271
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
475e8d798059ed2fd493e25f8b154432b5185751be9a1ad7a33fa96113ad8f9b
833
[ -1 ]
834
sequencer-meta.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer-meta.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson, D. Bouche ;============================================================================ ;========================================================================= ; SEQUENCER CONTROL PATCH ;========================================================================= (in-package :om) ;;;========================== ;;; THE CONTROL PATCH ;;;========================== (defclass OMControlPatch (OMPatchInternal) ()) ;;; in principle there is only 1 reference (the sequencer) ;(defmethod update-from-editor ((self OMControlPatch)) ; (mapc #'(lambda (ref) (report-modifications (editor ref))) ; (references-to self))) (defmethod set-control-patch ((self OMSequencer) (patch OMPatch)) (change-class patch (find-class 'OMControlPatch)) (setf (ctrlpatch self) patch) (setf (references-to (ctrlpatch self)) (list self))) ;;; not used... (?) (defmethod sequencer-reference ((self t)) nil) (defmethod sequencer-reference ((self OMControlPatch)) (car (references-to self))) ;;; in principle this is the only one ! (defmethod find-persistant-container ((self OMControlPatch)) (find-persistant-container (car (references-to self)))) (defmethod get-internal-elements ((self OMSequencer)) (append (call-next-method) (get-internal-elements (ctrlpatch self)))) (defparameter *control-patch-help-comment* "This patch is a general controller for the sequencer. Additional inputs/outputs will appear on the sequencer box. ") (defmethod initialize-instance :after ((self OMSequencer) &rest args) ;;; put this somewhere else ?? ;; the sequencer doesn't auto-stop when its duration is passed (set-object-autostop self nil) (unless (ctrlpatch self) (let* ((patch (make-instance 'OMControlPatch :name "Control Patch")) (inbox (omng-make-special-box 'thissequencer (omp 30 12))) (outbox (omng-make-special-box 'out (omp 52 140))) (connection (omng-make-new-connection (car (outputs inbox)) (car (inputs outbox)))) ;(comment (omng-make-new-comment *control-patch-help-comment* (omp 60 40))) ) (setf (index (reference inbox)) 0 (defval (reference inbox)) self) (omng-add-element patch inbox) (omng-add-element patch outbox) (omng-add-element patch connection) ;(omng-resize comment (omp 120 120)) ;(omng-add-element patch comment) (set-control-patch self patch) )) self) ;;; called when some change is made in the sequencer or in the control-patch (defmethod update-from-reference ((self OMSequencer)) (loop for item in (references-to self) do (update-from-reference item))) (defmethod get-inputs ((self OMSequencer)) (get-inputs (ctrlpatch self))) (defmethod get-outputs ((self OMSequencer)) (get-outputs (ctrlpatch self))) ;;;==================================== ;;; Sequencer accessor for control patch or temporal boxes ;;;==================================== (defclass OMSequencerIn (OMMetaIn) () (:documentation "Returns the Sequencer containing this patch/subpatch.")) ;; for compatibility / remove me in a little while:) (defclass OMSequenceIn (OMSequencerIn) ()) (defclass OMSequencerInBox (OMMetaInBox) ()) (defmethod special-box-p ((name (eql 'thissequencer))) t) (defmethod get-box-class ((self OMSequencerIn)) 'OMSequencerInBox) (defmethod box-symbol ((self OMSequencerIn)) 'thissequencer) (defmethod special-item-reference-class ((item (eql 'thissequencer))) 'OMSequencerIn) (defmethod omNG-make-special-box ((reference (eql 'thissequencer)) pos &optional init-args) (omNG-make-new-boxcall (make-instance 'OMSequencerIn :name "THIS SEQUENCER") pos init-args)) ;;; FOR THE META INPUTS ;;; if there are several references (OMSequencerFile) we assume that the first in the list is the current caller (defmethod box-container ((self OMControlPatch)) (car (references-to (car (references-to self))))) ;;; check the container: can be a patch, a controlpatch or a sequencer (defmethod sequencer-container ((self OMBox)) (sequencer-container (container self))) ;;; the references-to a control patch is just the sequencer (defmethod sequencer-container ((self OMControlPatch)) (car (references-to self))) (defmethod sequencer-container ((self OMSequencer)) self) (defmethod sequencer-container ((self OMPatch)) (sequencer-container (car (box-references-to self)))) (defmethod sequencer-container ((self t)) nil) ;;; BOX VALUE (defmethod omNG-box-value ((self OMSequencerInBox) &optional (numout 0)) (set-value self (list (sequencer-container self))) (return-value self numout)) (defmethod gen-code ((self OMSequencerInBox) &optional (numout 0)) (set-value self (list (sequencer-container self))) (nth numout (value self))) #| ;;; note : maybe this is all not useful and I should set the meta just at eval ;;; TRY TO SET THE DEFVAL AS THE CONTAINER SEQUENCER (defmethod register-patch-io ((self OMControlPatch) (elem OMSequencerIn)) (call-next-method) ;;; For OMControlPatch the only references-to is the sequencer (setf (defval elem) (car (references-to self)))) (defmethod register-patch-io ((self OMPatchInternal) (elem OMSequencerIn)) (call-next-method) ;;; For OMPatchInternal the only references-to is the box ;;; => just check if it is in a sequencer... (when (subtypep (type-of (container (car (references-to self)))) 'OMSequencer) (setf (defval elem) (container (car (references-to self)))))) (defmethod register-patch-io ((self OMPatchFile) (elem OMSequencerIn)) (call-next-method) ;;; For OMPatchFile the only references-to can be multiples ! ;;; In this case, it will be set only before eval (if (and (= 1 (length (references-to self))) (subtypep (type-of (container (car (references-to self)))) 'OMSequencer)) (setf (defval elem) (container (car (references-to self)))))) |#
6,494
Common Lisp
.lisp
125
48.864
112
0.664665
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
01a28b80ee8a9d3cdf3528b7282c6429ff50acc76878f528bf7ccad0dfb37e3b
834
[ -1 ]
835
sequencer-editor.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File authors: J. Bresson, D. Bouche ;============================================================================ ;========================================================================= ; SEQUENCER EDITOR WINDOW ;========================================================================= (in-package :om) (defparameter *track-control-w* 36) (defparameter *track-h* 40) (defparameter *ruler-view-h* 20) (defparameter *control-view-h* 20) (defparameter +maq-bg-color+ (om-gray-color 0.65)) (defparameter +track-color-1+ (om-gray-color 0.5)) (defparameter +track-color-2+ (om-gray-color 0.6)) (defparameter +font-color+ (om-gray-color 1)) (defclass sequencer-editor (multi-view-editor patch-editor play-editor-mixin) ((beat-info :accessor beat-info :initarg :beat-info :initform (list :beat-count 0 :prevtime 0 :nexttime 1)))) (defmethod view-mode ((self sequencer-editor)) (view-mode (object self))) (defmethod control-patch-visible-p ((self sequencer-editor)) (control-patch-visible-p (object self))) (defmethod om-menu-items ((self sequencer-editor)) (remove nil (list (main-app-menu-item) (om-make-menu "File" (default-file-menu-items self)) (om-make-menu "Edit" (append (default-edit-menu-items self) (list (om-make-menu-comp (list (om-make-menu-item "Show Inspector" #'(lambda () (patch-editor-set-window-config self (if (equal (editor-window-config self) :inspector) nil :inspector))) :key "i" :selected #'(lambda () (equal (editor-window-config self) :inspector)) ) (om-make-menu-item "Edit lock" #'(lambda () (setf (lock (object self)) (not (lock (object self)))) (om-invalidate-view (main-view self))) :key "e" :selected #'(lambda () (lock (object self))) )) :selection t ) ))) (om-make-menu "Windows" (default-windows-menu-items self)) (om-make-menu "Help" (default-help-menu-items self)) ))) ;;; sequencer-editor is its own container ;;; this is needed by the multi-editor click-system ;;; => requires a check in the report-modification process ! (defmethod container-editor ((self sequencer-editor)) self) (defmethod get-editor-class ((self OMSequencer)) 'sequencer-editor) (defmethod get-obj-to-play ((self sequencer-editor)) (object self)) (defmethod is-playing ((self sequencer-editor)) (equal (player-get-object-state (player self) (get-obj-to-play self)) :play)) (defmethod get-editor-view-for-action ((self sequencer-editor)) (if (equal (view-mode self) :maquette) (get-g-component self :maq-view) (selected-view self))) ;; selected = the last clicked track (defmethod get-view-from-mode ((self sequencer-editor)) (if (equal (view-mode self) :maquette) (get-g-component self :maq-view) (get-g-component self :track-views))) (defmethod get-visible-selected-boxes ((self sequencer-editor)) (let ((selected-boxes (get-selected-boxes self))) (if (equal (view-mode self) :maquette) selected-boxes (remove-if-not #'group-id selected-boxes)))) (defmethod n-tracks ((self sequencer-editor)) (max 4 (or (and (boxes (object self)) (list-max (remove-if-not #'numberp (mapcar 'group-id (get-all-boxes (object self)))))) 0 ))) (defmethod get-range ((self sequencer-editor)) (range (object self))) (defmethod editor-get-tempo-automation ((self sequencer-editor)) (tempo-automation (get-g-component self :metric-ruler))) (defmethod cursor-panes ((self sequencer-editor)) (remove nil (append (list (get-g-component self :maq-view) (get-g-component self :metric-ruler) (get-g-component self :abs-ruler)) (get-g-component self :track-views)))) (defmethod move-editor-selection ((self sequencer-editor) &key (dx 0) (dy 0)) (loop for tb in (get-visible-selected-boxes self) do (move-box-in-sequencer (object self) tb :dx dx :dy dy))) (defmethod box-at-pos ((editor sequencer-editor) time &optional track) (let* ((seq (object editor))) (find time (if track (get-all-boxes seq :track track) (get-all-boxes seq)) :test #'(lambda (tt tb) (and (> tt (get-box-onset tb)) (< tt (get-box-end-date tb))))))) ;;; used for auto-connecting boxes (defmethod is-lower (y1 y2 (editor sequencer-editor)) (< y1 y2)) ;;; called from the tracks (defmethod new-box-in-track-view ((self sequencer-editor) at &optional (track 0)) (store-current-state-for-undo self) (let ((seq (object self)) (new-box (omng-make-special-box 'patch at))) (set-box-duration new-box *temporalbox-def-w*) (add-box-in-track seq new-box track) new-box)) ;;;; !!!!! (defmethod get-internal-view-components ((self patch-editor)) (let ((editorview (main-view self))) (append (get-boxframes editorview) (get-grap-connections editorview)))) ;;;======================== ;;; EDITOR WINDOW ;;;======================== (defclass sequencer-editor-window (OMEditorWindow) ()) (defmethod editor-window-class ((self sequencer-editor)) 'sequencer-editor-window) (defmethod update-to-editor ((self sequencer-editor) (from t)) (om-invalidate-view (window self))) (defmethod report-modifications ((self sequencer-editor)) (call-next-method) (om-invalidate-view (window self))) (defmethod editor-window-init-size ((self sequencer-editor)) (om-make-point 800 500)) ;;;======================== ;;; MAQUETTE-VIEW (OM STYLE) ;;;======================== (defclass maquette-view (patch-editor-view x-cursor-graduated-view y-graduated-view om-drop-view) () (:default-initargs :input-model (om-input-model :touch-pan t))) (defmethod omng-x ((container maquette-view) pix-x) (round (pix-to-x container pix-x))) (defmethod omng-y ((container maquette-view) pix-y) (pix-to-y container pix-y)) (defmethod omng-w ((container maquette-view) pix-w) (dpix-to-dx container pix-w)) (defmethod omng-h ((container maquette-view) pix-h) (+ (dpix-to-dy container pix-h))) (defmethod omg-x ((container maquette-view) s-x) (x-to-pix container s-x)) (defmethod omg-y ((container maquette-view) s-y) (y-to-pix container s-y)) (defmethod omg-w ((container maquette-view) s-w) (dx-to-dpix container s-w)) ;;; the ruler of the maquette-view is oriented bottom-up: (defmethod omg-h ((container maquette-view) s-h) (- (dy-to-dpix container s-h))) ;; not inherited from x-cursor-graduated-view due to multiple-inheritance (defmethod pixel-to-time ((self maquette-view) x) (round (pix-to-x self x))) (defmethod resize-handle ((self resize-area) (container maquette-view) frame pos) (let ((pp (om-add-points (p0 self) pos))) (om-set-view-size frame (om-max-point (om-make-point 10 20) (resize-frame-size self frame pp))) )) (defmethod update-temporalbox ((self maquette-view) frame) (let* ((box (object frame)) (x (x-to-pix self (box-x box))) (y (y-to-pix self (box-y box))) (w (if (scale-in-x-? box) (max 20 (omg-w self (box-w box))) (box-w box))) (h (if (scale-in-y-? box) (max 24 (omg-h self (box-h box))) (box-h box)))) (om-set-view-position frame (om-point-set (om-view-position frame) :x x :y y)) (om-set-view-size frame (om-point-set (om-view-size frame) :x w :y h)) (redraw-connections frame) )) (defmethod update-temporalboxes ((self maquette-view)) (loop for sv in (get-boxframes self) do (update-temporalbox self sv))) (defmethod update-view-from-ruler ((self x-ruler-view) (view maquette-view)) (call-next-method) (setf (getf (range (object (editor view))) :x1) (x1 self) (getf (range (object (editor view))) :x2) (x2 self))) (defmethod update-view-from-ruler ((self y-ruler-view) (view maquette-view)) (call-next-method) (setf (getf (range (object (editor view))) :y1) (y1 self) (getf (range (object (editor view))) :y2) (y2 self))) (defmethod update-view-from-ruler ((self ruler-view) (view maquette-view)) (call-next-method) (update-temporalboxes view)) (defmethod reinit-y-ranges ((self sequencer-editor)) (let ((boxes (boxes (object self)))) (if boxes (set-ruler-range (get-g-component self :y-ruler) (- (apply #'min (mapcar #'(lambda (b) (- (box-y b) (if (scale-in-y-? b) (box-h b) 40))) boxes)) 10) (+ (apply #'max (mapcar #'(lambda (b) (box-y b)) boxes)) 10)) (set-ruler-range (get-g-component self :y-ruler) -10 110) ))) (defmethod reinit-y-ranges-from-ruler ((self sequencer-editor) ruler) (reinit-y-ranges self)) (defmethod om-view-resized :after ((view maquette-view) new-size) (declare (ignore new-size)) (update-temporalboxes view)) (defmethod draw-patch-grid ((view maquette-view) &optional (d 50)) (declare (ignore d)) (om-with-fg-color (om-gray-color 0 0.1) (draw-grid-from-ruler view (get-g-component (editor view) :metric-ruler)) (draw-grid-from-ruler view (get-g-component (editor view) :y-ruler)) )) (defmethod allowed-element ((self OMSequencer) (elem OMInOutBox)) nil) (defmethod can-popup-new-box-from-val ((view maquette-view)) nil) (defmethod om-view-pan-handler ((self maquette-view) position dx dy) (shift-time-ruler (get-g-component (editor self) :abs-ruler) (* dx 10))) (defmethod om-view-zoom-handler ((self maquette-view) position zoom) (zoom-time-ruler (get-g-component (editor self) :abs-ruler) (- 1 zoom) position self)) (defmethod om-view-doubleclick-handler ((self maquette-view) position) (if (om-add-key-down) ;;; add new box etc. (call-next-method) ;;; set play cursor pos (let* ((editor (editor self)) (time (round (pix-to-x self (om-point-x position))))) (when (om-get-clipboard) (set-paste-position position self)) (editor-set-interval editor (list time time)) (set-object-current-time (get-obj-to-play editor) time)) )) (defmethod om-view-click-handler ((self maquette-view) position) (or (handle-selection-extent self position) (call-next-method))) (defmethod encapsulate-patchboxes ((editor patch-editor) (view maquette-view) boxes) (loop for b in boxes do (omng-resize b (default-size b))) (call-next-method)) ;;;======================== ;;; TRACK-VIEW ;;;======================== ;;; Note : the sequence-track-view is the 'frame' attribute for temporal boxes in the :tracks view-mode (defclass sequencer-track-view (multi-view-editor-view x-cursor-graduated-view omframe om-drop-view om-view) ((num :initarg :num :initform 0 :accessor num)) (:default-initargs ;:cursor-interval-lines-color (om-make-color 0.8 0.7 0.7) :cursor-interval-fill-color (om-make-color-alpha (om-def-color :white) 0.2) :input-model (om-input-model :touch-pan t) )) (defclass sequencer-track-control (om-view) ((num :initarg :num :initform 0 :accessor num))) ;;; redraw upon resize #-macosx (defmethod om-view-resized :after ((self sequencer-track-view) size) (om-invalidate-view self)) (defmethod om-draw-contents ((self sequencer-track-control)) (om-with-font (om-make-font "Arial" 80 :style '(:bold)) (om-with-fg-color (om-make-color 1 1 1 0.1) (om-draw-string (- (round (w self) 2) 20) (+ (round (h self) 2) 24) (number-to-string (num self)))))) (defmethod om-draw-contents-area ((self sequencer-track-view) x y w h) (let* ((editor (editor (om-view-window self))) (seq (object editor)) (xmax (+ x w)) (t1 (pixel-to-time self x)) (t2 (pixel-to-time self xmax)) (ruler (get-g-component editor :metric-ruler))) ;;;MARKERS (when (and ruler (markers-p ruler)) (loop for marker in (remove-if #'(lambda (mrk) (or (< mrk t1) (> mrk t2))) (get-all-time-markers ruler)) ;;;PAS OPTIMAL do (let ((pos (time-to-pixel ruler marker))) (om-with-fg-color (om-make-color 0.9 0.7 0 (if (find marker (selected-time-markers ruler)) 1 0.45)) (om-draw-line pos 0 pos (h self)))) )) ;;;GRID (when ruler (om-with-fg-color (om-gray-color 0 0.1) (om-with-line '(2 2) (loop for beat in (remove-if #'(lambda (pt) (or (< (car pt) t1) (> (car pt) t2))) (point-list ruler)) do (draw-grid-line-from-ruler self ruler (ruler-value-to-pix ruler (car beat))))))) ;;; will call 'om-draw-contents' (call-next-method) ;;;CONTENT (loop for tb in (get-all-boxes seq :track (num self)) do (let ((x1 (x-to-pix self (get-box-onset tb))) (x2 (if (scale-in-x-? tb) (x-to-pix self (get-box-end-date tb)) (+ (x-to-pix self (box-x tb)) (box-w tb))))) (when (selected tb) (om-with-fg-color (om-make-color-alpha (om-def-color :black) 0.5) (om-draw-rect x1 0 (- x2 x1) (h self) :fill t))) (unless (frame tb) (setf (frame tb) self)) (when (and (<= x1 xmax) (> x2 x)) (draw-temporal-box tb self x1 0 (- x2 x1) (h self) (- (pix-to-x self x) (get-box-onset tb))) ))) )) (defmethod resizable-box? ((self OMBox)) t) (defmethod resizable-box? ((self OMBoxEditCall)) nil) (defmethod update-view-from-ruler ((self x-ruler-view) (view sequencer-track-view)) (call-next-method) (setf (getf (range (object (editor view))) :x1) (x1 self) (getf (range (object (editor view))) :x2) (x2 self))) (defmethod om-view-pan-handler ((self sequencer-track-view) position dx dy) (shift-time-ruler (get-g-component (editor self) :abs-ruler) (* dx 10))) (defmethod om-view-zoom-handler ((self sequencer-track-view) position zoom) (zoom-time-ruler (get-g-component (editor self) :abs-ruler) (- 1 zoom) position self)) (defmethod om-view-click-handler ((self sequencer-track-view) position) (let* ((editor (editor (om-view-window self))) (time (round (pix-to-x self (om-point-x position)))) (selected-box (box-at-pos editor time (num self))) (p0 position)) (when (om-get-clipboard) (set-paste-position (omp time (num self)) self)) (editor-box-selection editor selected-box) (om-invalidate-view (om-view-window self)) (cond ((and selected-box (not (edit-lock editor))) (let ((selected-end-time-x (and (scale-in-x-? selected-box) ;;; otherwise we just don't rescale in tracks view (time-to-pixel self (get-box-end-date selected-box))))) (if (and (resizable-box? selected-box) (scale-in-x-? selected-box) (<= (om-point-x position) selected-end-time-x) (>= (om-point-x position) (- selected-end-time-x 5))) ;;; resize the box (progn (store-current-state-for-undo editor :action :resize :item selected-box) (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (declare (ignore view)) (when (> (- (om-point-x pos) (x-to-pix self (get-box-onset selected-box))) 10) (if (scale-in-x-? selected-box) (set-box-duration selected-box (- (round (pix-to-x self (om-point-x pos))) (get-box-onset selected-box))) (setf (box-w selected-box) (- (om-point-x pos) (x-to-pix self (box-x selected-box))))) (om-invalidate-view self))) :release #'(lambda (view pos) (declare (ignore view pos)) (notify-scheduler (object editor)) (report-modifications editor) (om-invalidate-view self)) :min-move 4) ) ;;; move the selection (let* ((visible-selected-boxes (get-visible-selected-boxes editor)) (copy? (when (om-option-key-p) (mapcar 'om-copy visible-selected-boxes))) (init-tracks (mapcar 'group-id visible-selected-boxes))) (when copy? (store-current-state-for-undo editor) (select-unselect-all editor nil) (mapcar #'(lambda (b) (setf (group-id b) NIL) (select-box b t)) copy?) (setf visible-selected-boxes copy?)) (store-current-state-for-undo editor :action :move :item selected-box) (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (declare (ignore view)) (let ((dx (round (dpix-to-dx self (- (om-point-x pos) (om-point-x p0))))) (py (om-point-y pos))) (when copy? (mapcar #'(lambda (b) (unless (group-id b) (add-box-in-track (object editor) b (num self)) (setf (frame b) self))) copy?)) (let ((diff-track-id (floor py (h self)))) (loop for tb in visible-selected-boxes for init-track in init-tracks do (let ((new-box-id (+ init-track diff-track-id))) (when (and (> new-box-id 0) (<= new-box-id (n-track-views editor))) (update-inspector-for-object tb) ;; here ? (setf (group-id tb) new-box-id) )))) (move-editor-selection editor :dx dx) (setf p0 pos) (om-invalidate-view (om-view-window self)) )) :release #'(lambda (view pos) (declare (ignore view pos)) (notify-scheduler (object editor)) (report-modifications editor) (om-invalidate-view (om-view-window self))) :min-move 4) ) ) )) ((and (om-add-key-down) (not (edit-lock editor))) (let ((box (new-box-in-track-view editor (omp time 0) (num self)))) (setf (frame box) self) (om-set-view-cursor self (om-get-cursor :h-size)) (set-box-duration box nil) ;;; will set a default duration (om-init-temp-graphics-motion self position nil :motion #'(lambda (view pos) (declare (ignore view)) (when (> (- (om-point-x pos) (x-to-pix self (get-box-onset box))) 10) (set-box-duration box (- (round (pix-to-x self (om-point-x pos))) (get-box-onset box))) (om-invalidate-view self))) :release #'(lambda (view pos) (declare (ignore view pos)) (notify-scheduler (object editor)) (report-modifications editor) (om-invalidate-view self)) :min-move 4) (report-modifications editor) )) (t (call-next-method)) ))) (defmethod om-view-mouse-motion-handler :around ((self sequencer-track-view) position) (let* ((ed (editor (om-view-window self))) (mouse-x (om-point-x position)) (end-times-x (mapcar #'(lambda (box) (time-to-pixel self (get-box-end-date box))) (remove-if-not #'resizable-box? (get-all-boxes (object ed) :track (num self)))))) (if (and (find mouse-x end-times-x :test #'(lambda (a b) (and (<= a b) (>= a (- b 5))))) (not (edit-lock ed))) (om-set-view-cursor self (om-get-cursor :h-size)) (progn (om-set-view-cursor self (om-view-cursor self)) (call-next-method) )))) (defmethod om-view-doubleclick-handler ((self sequencer-track-view) position) (let* ((editor (editor (om-view-window self))) (time (round (pix-to-x self (om-point-x position)))) (selected-box (box-at-pos editor time (num self)))) (if selected-box (open-editor selected-box) (progn (when (om-get-clipboard) (set-paste-position (omp time (num self)) self)) (editor-set-interval editor (list time time)) (set-object-current-time (get-obj-to-play editor) time))))) (defmethod om-drag-receive ((self sequencer-track-view) (dragged-view OMBoxFrame) position &optional (effect nil)) (let ((editor (editor (om-view-window self))) (dragged-obj (object dragged-view))) (when (allowed-element (object editor) dragged-obj) ; (get-box-value dragged-obj) (let ((new-box (om-copy dragged-obj))) (setf (box-x new-box) (round (pix-to-x self (om-point-x position))) (box-y new-box) 0 (box-h new-box) 10) (add-box-in-track (object editor) new-box (num self)) (setf (frame new-box) self) (update-to-editor editor self) t)))) (defmethod paste-command-for-view ((editor sequencer-editor) (view sequencer-track-view)) (unless (edit-lock editor) (let* ((boxes (car (get-om-clipboard))) (connections (cadr (get-om-clipboard))) (paste-info (get-paste-position view)) (paste-x-pos (if paste-info (om-point-x paste-info) (list-max (mapcar #'get-box-end-date boxes)))) (ref-x-pos (list-min (mapcar #'box-x boxes)))) (select-unselect-all editor nil) (set-paste-position nil) (loop for new-box in boxes do (let ((x-pos (+ paste-x-pos (- (box-x new-box) ref-x-pos)))) (setf (box-x new-box) x-pos (box-y new-box) 0 (box-h new-box) 10) (add-box-in-track (object editor) new-box (if paste-info (om-point-y paste-info) (group-id new-box))) (setf (frame new-box) view) (update-to-editor editor view) (set-om-clipboard (list (mapcar 'om-copy boxes) connections)) ))))) ;;;=============================== ;;; DISPLAY BOXES IN SEQUENCER TRACKS ;;;==============================- ;;; to be redefined by objects if they have a specific miniview for the sequencer (defmethod draw-sequencer-mini-view ((object t) (box OMBox) x y w h &optional time) (ensure-cache-display-draw box object) (draw-mini-view object box x y w h time)) (defmethod draw-sequencer-mini-view ((object OMBoxEditCall) (box OMBox) x y w h &optional time) (om-draw-rect (+ x 2) (+ y 4) (- w 4) (- h 16) :fill t :color (om-def-color :white)) (draw-sequencer-mini-view (get-box-value object) box (+ x 8) (+ y 4) (- w 12) (- h 16) nil)) (defmethod draw-temporal-box ((self OMBox) view x y w h &optional (time 0)) (let ((bgcolor (box-draw-color self))) (unless (om-color-null-p bgcolor) (om-with-fg-color (cond ((selected self) (om-make-color-alpha (color-color bgcolor) 1.0)) ;; 0.0 is also nice :) ((> (om-color-a (color-color bgcolor)) 0.6) (om-make-color-alpha (color-color bgcolor) 0.6)) (t (color-color bgcolor))) (om-draw-rect x y w h :fill t)))) (om-with-fg-color (om-def-color :white) (om-draw-rect x y w h :fill nil)) (om-with-fg-color (om-def-color :white) (om-draw-string (+ x 2) (+ y h -2) (number-to-string (get-box-onset self))))) (defmethod draw-temporal-box ((self OMBoxPatch) view x y w h &optional (time 0)) (call-next-method) (case (display self) (:mini-view (draw-sequencer-mini-view (reference self) self (+ x 20) y (- w 40) h time)) (:text ;; not called (draw-values-as-text self x y)) (:value (let ((dur (or (get-obj-dur (get-box-value self)) (box-w self)))) (om-with-clip-rect view x y w h (draw-sequencer-mini-view (get-box-value self) self x y (if (get-box-value self) (dx-to-dpix view dur) w) h time) (draw-mini-arrow (+ x 24) (+ y 9) 3 10 7 1) ))) (:hidden (om-with-font *box-label-font* (om-with-fg-color (om-make-color 0.6 0.6 0.6 0.5) (om-draw-string (+ x (/ w 2) -30) (max 22 (+ 6 (/ h 2))) "PATCH"))))) (draw-patch-icon self (icon (reference self)) x y) (draw-eval-buttons view self x y x 12) (draw-temporal-box-name self view x y w h) (when (or (reactive self) (find-if 'reactive (outputs self))) (om-draw-rect x y w h :line 2 :color (om-def-color :dark-red))) (if (plusp (pre-delay self)) (om-with-fg-color (om-def-color :red) (om-draw-circle (- x (dx-to-dpix view (pre-delay self))) (/ h 2) 3 :fill t) (om-draw-dashed-line x (/ h 2) (- x (dx-to-dpix view (pre-delay self))) (/ h 2))))) (defmethod draw-temporal-box ((self omboxeditcall) view x y w h &optional (time 0)) (call-next-method) (case (display self) (:mini-view (draw-sequencer-mini-view (get-box-value self) self x y w h time)) (:text (draw-mini-text (get-box-value self) self x y w h nil)) (:hidden (om-with-font *box-label-font* (om-with-fg-color (om-make-color 0.6 0.6 0.6 0.5) (om-draw-string (+ x 10) (max 22 (+ 6 (/ h 2))) (string-upcase (type-of (get-box-value self)))))))) (draw-temporal-box-name self view x y w h)) (defmethod draw-temporal-box-name ((self OMBox) view x y w h) (let ((name (and (show-name self) (or (name self) (default-name (get-box-value self))))) (font (box-draw-font self))) (when name (om-with-clip-rect view x y w h (multiple-value-bind (tw th) (om-string-size name font) (declare (ignore th)) (om-with-fg-color (box-draw-text-color self) (om-with-font font (om-draw-string (- (+ x w) tw 4) (- (+ y h) 4) name :selected nil :wrap (- w 10) ) ))))))) ;;; !! this is a special case : the frame of the object must change ;;; + the 'update' reference of the inspector window (= self) becomes the wrong one ;;; 1 solution = re-create the inspector if track is changed ;;; other solution = invalidate all tracks all the time (defmethod update-after-prop-edit ((self sequencer-track-view) (object OMBox)) (let ((editor (editor (om-view-window self)))) ;;; sets the right frame for the box (unless (or (equal :none (group-id object)) (and (frame object) (equal (num self) (group-id object)))) (setf (frame object) (find (group-id object) (get-g-component editor :track-views) :key 'num :test '=))) (mapcar 'om-invalidate-view (get-g-component editor :track-views)) )) (defmethod update-frame-connections-display ((self sequencer-track-view)) nil) ;;;======================== ;;; KEYBOARD ACTIONS ;;;======================== ;;; for the general windows menu (defmethod get-selection-for-menu ((self sequencer-editor)) (if (and (selected-view self) (not (equal self (editor (selected-view self))))) (get-selection-for-menu (editor (selected-view self))) (call-next-method))) (defmethod editor-key-action ((editor sequencer-editor) key) (let ((seq (object editor))) (case key (:om-key-left (unless (edit-lock editor) (store-current-state-for-undo editor :action :move :item (get-visible-selected-boxes editor)) (with-schedulable-object seq (move-editor-selection editor :dx (- (get-units (get-g-component editor :metric-ruler) (if (om-shift-key-p) 100 10))))) (om-invalidate-view (main-view editor)) (report-modifications editor))) (:om-key-right (unless (edit-lock editor) (store-current-state-for-undo editor :action :move :item (get-visible-selected-boxes editor)) (with-schedulable-object seq (move-editor-selection editor :dx (get-units (get-g-component editor :metric-ruler) (if (om-shift-key-p) 100 10)))) (om-invalidate-view (main-view editor)) (report-modifications editor))) (:om-key-up (unless (or (edit-lock editor) (equal (view-mode editor) :tracks)) (store-current-state-for-undo editor :action :move :item (get-visible-selected-boxes editor)) (with-schedulable-object seq (move-editor-selection editor :dy (if (om-shift-key-p) 10 1))) (om-invalidate-view (main-view editor)) (report-modifications editor))) (:om-key-down (unless (or (edit-lock editor) (equal (view-mode editor) :tracks)) (store-current-state-for-undo editor :action :move :item (get-visible-selected-boxes editor)) (with-schedulable-object seq (move-editor-selection editor :dy (if (om-shift-key-p) -10 -1))) (om-invalidate-view (main-view editor)) (report-modifications editor))) (:om-key-esc (select-unselect-all editor nil)) (#\v (eval-editor-boxes editor (get-visible-selected-boxes editor)) (report-modifications editor)) (#\c ;;; don't allow inserting comments, nor connecting in tracks view (when (and (get-selected-boxes editor) (equal :maquette (view-mode editor))) (call-next-method))) (#\C ;;; don't allow connecting in tracks view (when (equal :maquette (view-mode editor)) (call-next-method))) (#\e ;;; don't allow encapsulating in tracks view (when (equal :maquette (view-mode editor)) (call-next-method))) (#\u ;;; don't allow unencapsulating in tracks view (when (equal :maquette (view-mode editor)) (call-next-method))) (#\r (unless (edit-lock editor) (loop for tb in (or (get-visible-selected-boxes editor) (get-selected-connections editor)) do (set-reactive-mode tb)) (om-invalidate-view (window editor)))) (otherwise (call-next-method) (om-invalidate-view (window editor)) nil) ))) (defmethod eval-editor-boxes ((editor sequencer-editor) boxes) (let ((seq (object editor))) (setf *current-eval-panel* (get-editor-view-for-action editor)) (with-schedulable-object seq (loop for tb in boxes do (eval-box tb) (reset-cache-display tb) (contextual-update tb seq))) (om-invalidate-view (window editor)) (clear-ev-once seq) (setf *current-eval-panel* nil))) ;;; not supported for now... (defmethod align-selected-boxes ((editor sequencer-editor)) nil) (defmethod select-unselect-all ((self sequencer-editor) val) (if (and (selected-view self) (not (equal self (editor (selected-view self))))) (select-unselect-all (editor (selected-view self)) val) (if (equal (view-mode self) :tracks) (progn (mapc #'(lambda (x) (select-box x val)) (remove-if-not 'group-id (boxes (object self)))) (om-invalidate-view (main-view self))) (call-next-method)))) (defmethod remove-selection ((self sequencer-editor)) (if (and (selected-view self) (not (equal self (editor (selected-view self))))) (remove-selection (editor (selected-view self))) (call-next-method))) (defmethod copy-command-for-view ((editor sequencer-editor) (view t)) (if (and (selected-view editor) (not (equal editor (editor (selected-view editor))))) (copy-command-for-view (editor (selected-view editor)) view) (call-next-method))) (defmethod cut-command-for-view ((editor sequencer-editor) (view t)) (if (and (selected-view editor) (not (equal editor (editor (selected-view editor))))) (cut-command-for-view (editor (selected-view editor)) view) (call-next-method))) (defmethod paste-command-for-view ((editor sequencer-editor) (view patch-editor-view)) (if (and (selected-view editor) (not (equal editor (editor (selected-view editor))))) (paste-command-for-view (editor (selected-view editor)) view) (call-next-method))) (defmethod update-frame-size-for-view ((frame omboxframe) (view maquette-view)) (update-temporalbox view frame)) ;;;======================== ;;; TIME MARKERS API ;;;======================== (defmethod get-timed-objects-with-markers ((self sequencer-track-view)) (remove-if-not #'show-markers (get-all-boxes (get-obj-to-play (editor self)) :track (num self)))) (defmethod select-elements-at-time ((self sequencer-track-view) marker-time) (let* ((editor (editor (om-view-window self))) (box (box-at-pos editor marker-time (num self)))) (when box (select-box box t)) (update-to-editor editor self))) ;;; SNAP INTERVAL IF ALT/OPTION KEY IS DOWN (defmethod editor-set-interval ((self sequencer-editor) interval) (when (om-option-key-p) (setf interval (list (snap-time-to-grid (get-g-component self :metric-ruler) (car interval)) (snap-time-to-grid (get-g-component self :metric-ruler) (cadr interval))))) (call-next-method self interval)) ;;============================== ;; MARKER API SPECIAL SEQUENCER ;;============================== (defmethod translate-elements-from-time-marker ((self OMBox) elems dt) "translates elements from a time marker with dt" (when (get-box-value self) (translate-elements-from-time-marker (get-obj-to-play self) elems dt) (reset-cache-display self) (contextual-update self (container self)) (when (editor self) (update-to-editor (editor self) self)) )) ;;;======================== ;;; INSPECTOR IN SEQUENCER... ;;;======================== (defmethod update-inspector-for-editor ((self sequencer-editor) &optional obj (force-update nil)) (if (and (selected-view self) (not (equal self (editor (selected-view self))))) (update-inspector-for-editor (editor (selected-view self)) obj force-update) (call-next-method))) (defmethod default-editor-help-text ((self sequencer-editor)) " This is a sequencer editor window. Switch between the 'tracks' and the classic 'maquette' view with the icons of the toolbar at the top. Open the 'control patch' with the icon in the bottom-left corner. CMD-click to add boxes. Play contents, etc. ") ;;;======================== ;;; CONTROL PATCH ;;;======================== ;;; used by send/receive (defmethod patch-editors ((self sequencer-editor-window)) (let* ((main-editor (editor self)) (sequencer (object main-editor))) (list main-editor (editor (ctrlpatch sequencer))))) (defmethod editor-close ((self sequencer-editor)) (player-stop-object (player self) (metronome self)) (editor-close (editor (ctrlpatch (object self)))) (call-next-method)) (defun make-control-patch-view (sequencer-editor) (let ((ctrlpatch (ctrlpatch (object sequencer-editor)))) (unless (editor ctrlpatch) (setf (editor ctrlpatch) (make-instance 'patch-editor :object ctrlpatch :container-editor sequencer-editor))) (let ((pl (om-make-layout 'om-simple-layout)) (pv (cadr (multiple-value-list (make-editor-window-contents (editor ctrlpatch)))))) (om-add-subviews pl pv) (setf (main-view (editor ctrlpatch)) pv) (put-patch-boxes-in-editor-view ctrlpatch pv) ;;; so that the inspector calls are passed through (set-g-component (editor ctrlpatch) :inspector (get-g-component sequencer-editor :inspector)) (update-inspector-for-editor sequencer-editor) pl))) (defun show-hide-control-patch-editor (sequencer-editor show) (unless (equal (control-patch-visible-p sequencer-editor) show) (setf (control-patch-visible-p (object sequencer-editor)) show) (build-editor-window sequencer-editor) (init-editor-window sequencer-editor) )) (defun make-control-patch-buttons (editor) (om-make-view 'om-view :size (omp *track-control-w* *ruler-view-h*) :subviews (list (om-make-graphic-object 'om-icon-button :position (omp 0 0) :size (omp 16 16) :icon :ctrlpatch-open :icon-pushed :ctrlpatch-close :lock-push t :enabled t :pushed (control-patch-visible-p editor) :action #'(lambda (b) (show-hide-control-patch-editor editor (pushed b)) )) (om-make-graphic-object 'om-icon-button :position (omp 20 0) :size (omp 16 16) :icon :eval-sequence :icon-pushed :eval-sequence-pushed :lock-push nil :enabled t :action #'(lambda (b) (declare (ignore b)) (let ((seq (get-obj-to-play editor))) (eval-sequencer seq T T) (om-invalidate-view (get-g-component editor :main-sequencer-view)) ))) ))) ;;;================================ ;;; Metronome / Tempo ;;;================================ (defclass tempo-view (om-view) ((metronome :accessor metronome :initarg :metronome :initform nil))) (defmethod om-draw-contents ((self tempo-view)) (let* ((color (om-def-color :black))) (om-draw-char 4 14 (tempo-note :quater) :font (om-make-font *score-font* 11) :color color) (om-draw-string 10 15 "=" :font (om-def-font :small) :color color) )) (defmethod initialize-instance ((self tempo-view) &rest args) (call-next-method) (om-add-subviews self (om-make-graphic-object 'numbox :value (tempo (metronome self)) :border nil :decimals 0 :position (om-make-point 12 4) :size (om-make-point 40 14) :fg-color (om-def-color :black) :font (om-def-font :small) :min-val 20 :max-val 400 :change-fun #'(lambda (item) (set-tempo (metronome self) (value item)))))) (defclass metro-view (om-item-view) ((metronome :accessor metronome :initarg :metronome :initform nil))) (defmethod om-draw-contents ((self metro-view)) (let* ((color (if (metronome-on (metronome self)) (om-def-color :dark-blue) (om-def-color :black)))) (om-draw-string 10 12 "Metro" :font (om-def-font :gui) :color color) (om-draw-rect 0 4 8 8 :color color :fill (metronome-on (metronome self))) )) (defmethod om-view-click-handler ((self metro-view) position) (declare (ignore position)) (metronome-on/off (metronome self) (not (metronome-on (metronome self)))) (om-invalidate-view self)) ;;;======================== ;;; GENERAL CONSTRUCTOR ;;;======================== (defmethod build-editor-window :before ((editor sequencer-editor)) (mapc #'stop-cursor (cursor-panes editor))) (defmethod init-editor :after ((editor sequencer-editor)) (setf (play-interval editor) (interval (get-obj-to-play editor)))) (defmethod make-editor-window-contents ((editor sequencer-editor)) (let* ((tracks-or-maq-view (if (equal (view-mode editor) :maquette) (make-maquette-view editor) (make-tracks-view editor))) (ctrl-view (om-make-layout 'om-row-layout :scrollbars :nil :delta 2 :bg-color +track-color-2+ :ratios '(1 1000) :align :center :subviews (list (om-make-view 'om-view :size (omp *track-control-w* nil) :subviews (list (om-make-graphic-object 'lock-view-area :locked-icon :lock-sequence-closed :unlocked-icon :lock-sequence-open :position (omp 0 4) :size (omp 16 14) :editor editor) )) (om-make-layout 'om-row-layout :delta 10 :align :center :ratios '(1 100 1 100 1) :subviews (list (om-make-view 'om-view ;; needed to position the layout inside.. :subviews (list (om-make-layout 'om-row-layout :delta 2 :position (omp 30 3) :subviews (list (make-play-button editor :enable t :size (omp 14 14)) (make-pause-button editor :enable t :size (omp 14 14)) (make-stop-button editor :enable t :size (omp 14 14)) (make-previous-button editor :enable t :size (omp 14 14)) (make-next-button editor :enable t :size (omp 14 14)) (make-repeat-button editor :enable t :size (omp 14 14)) )) )) (make-time-monitor editor :h 16 :font (om-def-font :gui-title) :background +track-color-2+ :color (om-def-color :white) :time 0) (om-make-view 'om-view :size (omp 60 nil) :subviews (list (om-make-graphic-object 'metro-view :metronome (metronome editor) :size (omp 60 16) :position (omp 0 2)) )) nil (om-make-view 'om-view :subviews (let (b1 b2) (setq b1 (om-make-graphic-object 'om-icon-button :position (omp 0 2) :size (omp 16 16) :icon :maqview-off :icon-disabled :maqview-on :lock-push nil :enabled (equal (view-mode editor) :tracks) :action #'(lambda (b) (unless (equal (view-mode editor) :maquette) (button-disable b) (button-enable b2) (set-main-view editor :maquette) )))) (setq b2 (om-make-graphic-object 'om-icon-button :position (omp 20 2) :size (omp 16 16) :icon :trackview-off :icon-disabled :trackview-on :lock-push nil :enabled (equal (view-mode editor) :maquette) :action #'(lambda (b) (unless (equal (view-mode editor) :tracks) (button-disable b) (button-enable b1) (set-main-view editor :tracks) )))) (list b1 b2))) ))))) (bottom-view (om-make-layout 'om-simple-layout :subviews (list (om-make-di 'om-multi-text :size (omp 200 nil) :text "select a box to display its value..." :fg-color (om-def-color :gray) ) ))) (inspector-pane nil)) (set-g-component editor :bottom-view bottom-view) (set-g-component editor :ctrl-view ctrl-view) (set-g-component editor :main-sequencer-view (om-make-layout 'om-simple-layout)) ;;; the inspector must be created first because ;;; it is used in the control-patch-view creation ;;; the control patch constructor will update the inspector if necessary (when (equal (editor-window-config editor) :inspector) (setf inspector-pane (make-inspector-pane editor))) (when (control-patch-visible-p editor) (set-g-component editor :left-view (make-control-patch-view editor))) (om-add-subviews (get-g-component editor :main-sequencer-view) tracks-or-maq-view) (update-cursor-pane-intervals editor) (when (is-playing editor) (mapcar #'start-cursor (cursor-panes editor))) (om-make-layout 'om-row-layout :delta 2 :ratios (append (when (control-patch-visible-p editor) '(40 nil)) '(100) (when (equal (editor-window-config editor) :inspector) '(nil 1))) :subviews (append ;;; LEFT (PATCH) (when (control-patch-visible-p editor) (list (get-g-component editor :left-view) :divider)) ;;; MAIN (list (om-make-layout 'om-column-layout :delta 2 :ratios '(nil 100) ; nil 1 :subviews (list (get-g-component editor :ctrl-view) (get-g-component editor :main-sequencer-view) ;:divider ;(get-g-component editor :bottom-view) ))) ;;; RIGHT (INSPECTOR) (when (equal (editor-window-config editor) :inspector) (list :divider (om-make-layout 'om-column-layout :delta nil :ratios '(nil 1) :subviews (list (om-make-layout 'om-row-layout :subviews (list NIL (om-make-graphic-object 'om-icon-button :icon :xx :icon-pushed :xx-pushed :size (omp 12 12) :action #'(lambda (b) (declare (ignore b)) (patch-editor-set-window-config editor nil)) ))) (om-make-di 'om-simple-text :size (omp 230 18) :font (om-def-font :gui-title) :text "info and properties" :fg-color (om-def-color :dark-gray)) :separator inspector-pane)))) )) )) (defmethod editor-invalidate-views ((editor sequencer-editor)) (mapc #'om-invalidate-view (list (get-g-component editor :main-sequencer-view) (get-g-component editor :ctrl-view) (get-g-component editor :bottom-view) ))) (defun set-main-view (editor mode) (setf (view-mode (object editor)) mode) (om-remove-all-subviews (get-g-component editor :main-sequencer-view)) (mapcar #'stop-cursor (cursor-panes editor)) (om-add-subviews (get-g-component editor :main-sequencer-view) (if (equal mode :maquette) (make-maquette-view editor) (make-tracks-view editor))) ;;; needs to be done once the views are in place... (update-cursor-pane-intervals editor) (when (is-playing editor) (mapcar #'start-cursor (cursor-panes editor))) (mapc 'update-connections (boxes (object editor)))) (defun make-maquette-view (sequencer-editor) (let* ((ruler-maquette (om-make-view 'time-ruler :size (om-make-point 30 *ruler-view-h*) :x1 (or (getf (get-range sequencer-editor) :x1) 10000) :x2 (or (getf (get-range sequencer-editor) :x2) 10000) :scrollbars nil :bg-color +track-color-1+)) (metric-ruler (om-make-view 'metric-ruler :tempo (tempo (metronome sequencer-editor)) :size (om-make-point 30 *ruler-view-h*) :scrollbars nil :bg-color +track-color-1+)) (y-ruler (om-make-view 'y-ruler-view :y1 (or (getf (get-range sequencer-editor) :y1) 100) :y2 (or (getf (get-range sequencer-editor) :y2) 0) :size (om-make-point *track-control-w* 20) :scrollbars nil :bg-color +track-color-1+)) (maq-view (om-make-view 'maquette-view :editor sequencer-editor :scrollbars nil :bg-color +track-color-1+)) layout) (set-g-component sequencer-editor :track-views nil) (set-g-component sequencer-editor :maq-view maq-view) (set-g-component sequencer-editor :metric-ruler metric-ruler) (set-g-component sequencer-editor :y-ruler y-ruler) (set-g-component sequencer-editor :abs-ruler ruler-maquette) (attach-view-to-ruler ruler-maquette metric-ruler) (attach-view-to-ruler metric-ruler ruler-maquette) (attach-view-to-ruler ruler-maquette maq-view) (attach-view-to-ruler metric-ruler maq-view) (attach-view-to-ruler y-ruler maq-view) (update-span metric-ruler) (setf layout (om-make-layout 'om-column-layout :delta 2 :ratios '(1 100 1) :subviews (list (om-make-layout 'om-row-layout :delta 0 :ratios '(1 100) :subviews (list (om-make-view 'tempo-view :metronome (metronome sequencer-editor) :bg-color +track-color-1+ :size (omp (+ 2 *track-control-w*) *ruler-view-h*)) metric-ruler)) (om-make-layout 'om-row-layout :delta 2 :ratios '(1 100) :subviews (list y-ruler maq-view)) (om-make-layout 'om-row-layout :delta 2 :ratios '(1 100) :subviews (list (make-control-patch-buttons sequencer-editor) ruler-maquette)) ))) (put-patch-boxes-in-editor-view (object sequencer-editor) maq-view) layout )) (defmethod play-editor-get-ruler-views ((self sequencer-editor)) (list (get-g-component self :abs-ruler) (get-g-component self :metric-ruler))) (defun make-track-control (n editor) (declare (ignore editor)) (om-make-view 'sequencer-track-control :num n :size (om-make-point *track-control-w* *track-h*) :bg-color (nth (mod n 2) (list +track-color-1+ +track-color-2+)))) (defun n-track-views (sequencer-editor) (length (get-g-component sequencer-editor :track-views))) (defun make-tracks-view (sequencer-editor) (let* ((ruler-tracks (om-make-view 'time-ruler :size (om-make-point 30 *ruler-view-h*) :x1 (or (getf (get-range sequencer-editor) :x1) 0) :x2 (or (getf (get-range sequencer-editor) :x2) 10000) :scrollbars nil :bg-color +track-color-1+ :bottom-p nil :markers-p t)) (track-views (loop for n from 1 to (n-tracks sequencer-editor) collect (om-make-view 'sequencer-track-view :num n :size (omp nil *track-h*) :scrollbars nil :editor sequencer-editor :bg-color (nth (mod n 2) (list +track-color-1+ +track-color-2+))))) (metric-ruler (om-make-view 'metric-ruler :size (om-make-point 30 *ruler-view-h*) :scrollbars nil :bg-color +track-color-1+ :tempo (tempo (metronome sequencer-editor)) :markers-p t))) ;;; enable/disable markers here (set-g-component sequencer-editor :track-views track-views) (set-g-component sequencer-editor :maq-view nil) (set-g-component sequencer-editor :metric-ruler metric-ruler) (set-g-component sequencer-editor :abs-ruler ruler-tracks) (attach-view-to-ruler ruler-tracks metric-ruler) (attach-view-to-ruler metric-ruler ruler-tracks) (mapcar #'(lambda (v) (attach-view-to-ruler ruler-tracks v)) track-views) (mapcar #'(lambda (v) (attach-view-to-ruler metric-ruler v)) track-views) (update-span metric-ruler) ;;; set the track view as 'frame' for each box (loop for track-view in track-views do (loop for box in (get-all-boxes (object sequencer-editor) :track (num track-view)) do (setf (frame box) track-view))) (om-make-layout 'om-column-layout :delta 2 :ratios '(1 99 1) :subviews (list ;;; the ruler bar (om-make-layout 'om-row-layout :delta 0 :ratios '(1 99) :subviews (list (om-make-view 'tempo-view :metronome (metronome sequencer-editor) :bg-color +track-color-1+ :size (omp (+ 2 *track-control-w*) *ruler-view-h*)) metric-ruler)) ;;; allows scrolling the sub-layout (om-make-layout 'om-simple-layout :subviews (list (om-make-layout 'om-column-layout :delta 2 :scrollbars :v :subviews (loop for n from 1 to (n-tracks sequencer-editor) collect (om-make-layout 'om-row-layout :delta 2 :ratios '(1 99) :subviews (list (make-track-control n sequencer-editor) (nth (1- n) track-views))))))) (om-make-layout 'om-row-layout :delta 2 :ratios '(1 99) :subviews (list (make-control-patch-buttons sequencer-editor) ruler-tracks)) )))) ;;; when a box changes track (defmethod update-container-groups ((seq OMSequencer)) (when (and (editor seq) (equal (view-mode (editor seq)) :tracks) (not (= (n-tracks (editor seq)) (n-track-views (editor seq))))) ;;; will update the number of tracks (set-main-view (editor seq) :tracks))) ;;; called at init: (defmethod add-lock-item ((editor sequencer-editor) view) nil) ;;;===================== ;;; PLAYER INTERFACE ;;;===================== (defmethod editor-make-player ((self sequencer-editor)) ;;; create a metronome (setf (metronome self) (make-instance 'metronome :editor self)) ;;; return the default player (call-next-method)) (defmethod update-to-editor ((self sequencer-editor) (from metronome)) (let ((m-ruler (get-g-component self :metric-ruler))) (setf (tempo m-ruler) (tempo from)) (update-from-tempo m-ruler) (om-invalidate-view m-ruler)) (call-next-method)) (defmethod editor-next-step ((self sequencer-editor)) (let* ((object (get-obj-to-play self)) (step (get-units (cadr (cursor-panes self)))) (time (get-obj-time object))) (set-object-current-time object (+ step (- time (mod time step)))) (set-object-current-time (metronome self) (+ step (- time (mod time step)))))) (defmethod editor-previous-step ((self sequencer-editor)) (let* ((object (get-obj-to-play self)) (step (get-units (cadr (cursor-panes self)))) (time (get-obj-time object))) (set-object-current-time object (max 0 (- (- time (mod time step)) step))) (set-object-current-time (metronome self) (max 0 (- (- time (mod time step)) step))))) ;;;======================== ;;; PLAYER ;;;======================== (defmethod play-editor-callback ((self sequencer-editor) time) (set-time-display self time) ;;; draw cursor lines (does not work so well with the rulers...) (mapcar #'(lambda (view) (when view (update-cursor view time))) (cursor-panes self)) ;;; update range to play position ("turn pages") (let* ((x-ruler (get-g-component self :abs-ruler)) (m-ruler (get-g-component self :metric-ruler)) (x-range (round (- (v2 x-ruler) (v1 x-ruler))))) (cond ((> time (v2 x-ruler)) (set-ruler-range x-ruler (+ (v1 x-ruler) x-range) (+ (v2 x-ruler) x-range)) (update-span m-ruler)) ((< time (v1 x-ruler)) (set-ruler-range x-ruler time (+ time x-range)) (update-span m-ruler)) (t nil))) ;(let ((t-auto (editor-get-tempo-automation self))) ; (if (not (getf (beat-info self) :next-date)) ; (setf (getf (beat-info self) :next-date) (tempo-automation-get-beat-date t-auto (getf (beat-info self) :beat-count)))) ; (loop while (>= time (getf (beat-info self) :next-date)) ; do ; (om-set-dialog-item-text (cadr (om-subviews (tempo-box self))) (format nil "~$" (tempo-automation-tempo-at-beat t-auto (getf (beat-info self) :beat-count)))) ; (incf (getf (beat-info self) :beat-count) 0.1) ; (setf (getf (beat-info self) :next-date) (tempo-automation-get-beat-date t-auto (getf (beat-info self) :beat-count)))) ) (defmethod stop-editor-callback ((self sequencer-editor)) (setf (getf (beat-info self) :beat-count) 0 (getf (beat-info self) :next-date) nil) (when (get-g-component self :tempo-box) ;; see editor-play-mixin (set-value (cadr (om-subviews (get-g-component self :tempo-box))) (float (tempo-automation-tempo-at-beat (editor-get-tempo-automation self) 0)))) (reset-boxes (object self)) (call-next-method)) (defmethod get-interval-to-play ((self sequencer-editor)) (let ((sb (get-selected-boxes self))) (if sb (list (reduce 'min sb :key 'get-box-onset) (reduce 'max sb :key 'get-box-end-date)) (call-next-method)))) ;;;======================================= ;;; UNDO / REDO INTERFACE ;;;======================================= (defmethod update-after-state-change ((self sequencer-editor)) (let* ((seq (object self))) (when (equal (view-mode self) :maquette) (let ((view (get-g-component self :maq-view))) (om-remove-all-subviews view) (put-patch-boxes-in-editor-view seq view) (update-temporalboxes view) (om-invalidate-view view) )) (mapcar 'om-invalidate-view (get-g-component self :track-views)) )) ;;; forward to control-patch editor if active/selected (defmethod undo-command ((self sequencer-editor)) (let ((ed (editor (selected-view self)))) (if (or (null ed) (equal ed self)) (call-next-method) (when (undo-stack ed) #'(lambda () (do-undo ed)))))) (defmethod redo-command ((self sequencer-editor)) (let ((ed (editor (selected-view self)))) (if (or (null ed) (equal ed self)) (call-next-method) (when (redo-stack ed) #'(lambda () (do-redo ed))))))
62,130
Common Lisp
.lisp
1,255
37.39761
170
0.54949
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
5f2cbf955a802ad32f08db1ed90decd1c1fe4583fe2683bc063a5a45bc7f68aa
835
[ -1 ]
836
metric-ruler.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/metric-ruler.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: D. Bouche ;============================================================================ ; METRIC RULER ;========================================================================= (in-package :om) ;;;======================== ;;; METRIC RULER DISPLAY ;;;======================== (defclass metric-ruler (time-ruler) ((point-list :initform nil :initarg :point-list :accessor point-list) (tempo :initform 60 :initarg :tempo :accessor tempo) (tempo-automation :initform nil :initarg tempo-automation :accessor tempo-automation) (previous-span :initform '(0 0) :accessor previous-span))) (defun update-point-list (ruler) (let ((ta (tempo-automation ruler))) (setf (point-list ruler) (tempo-automation-get-beat-grid ta (v1 ruler) (v2 ruler) (tempo-automation-get-display-beat-factor ta (v1 ruler) (v2 ruler))) ) )) (defmethod update-from-tempo ((self metric-ruler)) (setf (tempo-automation self) (make-instance 'tempo-automation :x-points '(0 1000) :y-points (list (tempo self) (tempo self)))) (update-point-list self)) (defmethod initialize-instance ((self metric-ruler) &rest args) (let ((inst (call-next-method))) (unless (tempo-automation inst) (update-from-tempo inst)) inst)) ;;; Time markers API (not implemented) (defmethod get-timed-objects-with-markers ((self metric-ruler)) nil) (defmethod select-elements-at-time ((self metric-ruler) marker-time) nil) (defmethod clear-editor-selection ((self metric-ruler)) nil) (defun update-span (ruler) (let ((span (list (v1 ruler) (v2 ruler)))) (when (not (equal span (previous-span ruler))) (update-point-list ruler) (setf (previous-span ruler) span)))) (defmethod set-ruler-range ((self metric-ruler) v1 v2) (update-span self) (call-next-method)) (defmethod update-view-from-ruler ((self x-ruler-view) (view metric-ruler)) (update-span view) (call-next-method)) (defmethod snap-time-to-grid ((ruler metric-ruler) time &optional (snap-delta nil)) ;returns a time value corresponding to the given time aligned on the grid with a delta (in ms) treshold. ;default treshold is a tenth of the grid (let* ((i (position time (point-list ruler) :key 'car :test '<=)) (unit-dur (if i (if (< i 1) (caar (point-list ruler)) (if (< i (1- (length (point-list ruler)))) (- (car (nth i (point-list ruler))) (car (nth (1- i) (point-list ruler)))) (- (car (nth (1- i) (point-list ruler))) (car (nth (- i 2) (point-list ruler)))))) 0)) (delta (if snap-delta (min snap-delta (/ unit-dur 2)) (/ unit-dur 8))) (offset (if i (if (< i 1) time (- time (car (nth (1- i) (point-list ruler))))) 0))) (if i (if (> offset (- unit-dur delta)) (- (+ time unit-dur) offset) (if (< offset delta) (- time offset) time)) time))) (defmethod om-draw-contents ((ruler metric-ruler)) (let ((min-pix-step 20) cur-pix (last-pix 0)) (loop for beat in (point-list ruler) do (setq cur-pix (ruler-value-to-pix ruler (car beat))) (if (>= (- cur-pix last-pix) min-pix-step) (progn (if (numberp (cadr beat)) (om-with-font *ruler-font* (draw-line-at ruler cur-pix 6) (draw-string-at ruler cur-pix (format nil "~A" (1+ (cadr beat))))) (draw-line-at ruler cur-pix 4)) (setq last-pix cur-pix)) (draw-line-at ruler cur-pix 6)))) (when (markers-p ruler) (loop for marker in (get-all-time-markers ruler) do (let ((pos (time-to-pixel ruler marker))) (om-with-fg-color (om-make-color 0.9 0.7 0 (if (find marker (selected-time-markers ruler)) 1 0.45)) (om-draw-line pos 0 pos (h ruler)) (if (bottom-p ruler) (om-draw-polygon (list (omp (- pos 4) 0) (omp (- pos 4) (- (h ruler) 5)) (omp pos (h ruler)) (omp (+ pos 4) (- (h ruler) 5)) (omp (+ pos 4) 0) ) :fill t) (om-draw-polygon (list (omp (- pos 4) (h ruler)) (omp (- pos 4) 5) (omp pos 0) (omp (+ pos 4) 5) (omp (+ pos 4) (h ruler))) :fill t)))))) ;(let ((pos (x-to-pix ruler (cursor-pos ruler)))) ; (om-with-fg-color (om-make-color 1 1 1 0.5) ; (if (bottom-p ruler) ; (om-draw-polygon (list (omp (- pos 5) (- (h ruler) 5)) ; (omp (+ pos 5) (- (h ruler) 5)) ; (omp pos (h ruler))) ; :fill t) ; (om-draw-polygon (list (omp (- pos 5) 5) ; (omp (+ pos 5) 5) ; (omp pos 0)) ; :fill t)))) ) (defmethod draw-grid-from-ruler ((self om-view) (ruler metric-ruler)) (when (markers-p ruler) (loop for marker in (get-all-time-markers ruler) do (let ((pos (time-to-pixel ruler marker))) (om-with-fg-color (om-make-color 0.9 0.7 0 (if (find marker (selected-time-markers ruler)) 1 0.45)) (om-draw-line pos 0 pos (h self)))))) (om-with-line '(2 2) (loop for beat in (point-list ruler) do (draw-grid-line-from-ruler self ruler (ruler-value-to-pix ruler (car beat))))))
6,759
Common Lisp
.lisp
143
36.216783
115
0.482037
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
da9e9fb189438fe8ea94e592184837cf5fa991f63a35589f9b8308b360ad199d
836
[ -1 ]
837
sequencer.lisp
cac-t-u-s_om-sharp/src/packages/sequencer/sequencer.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (mapc #'(lambda (filename) (compile&load (decode-local-path filename))) '("sequencer-object" "metronome" "metric-ruler" "sequencer-editor" "sequencer-api" "sequencer-meta" "sequencer-box" "maquette-compatibility" )) (omNG-make-package "Sequencer" :container-pack *om-package-tree* :doc "Sequencer manipulation and control" :special-symbols '(thissequencer) :subpackages (list (omNG-make-package "Contents" :doc "" :functions '(get-objects s-add s-remove s-move s-clear)) (omNG-make-package "Player" :doc "" :functions '(s-play s-pause s-stop s-loop s-set-time s-get-time)) ))
1,722
Common Lisp
.lisp
40
32.325
91
0.454002
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
023cfc628d716046cd3cabe78fd0a019f2dc97d0803c1f2c8e93a1b3e5387f3d
837
[ -1 ]
838
osc.lisp
cac-t-u-s_om-sharp/src/packages/osc/osc.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) (require-om-package "basic") ;;; CL-OSC (load (merge-pathnames "cl-osc/osc.asd" *load-pathname*)) (asdf:operate 'asdf:load-op 'osc) (push :osc *features*) (compile&load (decode-local-path "osc-om/osc-struct")) (compile&load (decode-local-path "osc-om/osc-send-receive")) (compile&load (decode-local-path "osc-om/osc-route")) (compile&load (decode-local-path "osc-om/osc-preferences")) (omNG-make-package "OSC" :container-pack *om-package-tree* :doc "Tools for manipulating/communicating with data using the Open Sound Protocol" :classes '(osc-bundle) :functions '(osc-route) :subpackages (list (omng-make-package "Utilities" :functions '(osc-msg osc-set osc-get osc-delete osc-timetag)) (omng-make-package "In/Out" :functions '(osc-send osc-receive))))
1,607
Common Lisp
.lisp
37
39.810811
85
0.571337
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
3346cfb9abc265d67fd64eb55d29eb004793ca4f37c5b0b732094f3223aa61a1
838
[ -1 ]
839
osc-send-receive.lisp
cac-t-u-s_om-sharp/src/packages/osc/osc-om/osc-send-receive.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;================ ;;; OSC+UDP WRAPPERS ;;;================ (defun osc-decode (msg) (osc::decode-message-or-bundle msg)) (defun osc-encode-message (message) (apply #'osc::encode-message message)) (defun osc-encode-bundle (bundle) (osc::encode-bundle bundle)) (defun osc-send-message (port host message) (om-send-udp port host (apply #'osc::encode-message message))) (defun osc-send-bundle (port host bundle &optional time-tag) (om-send-udp port host (osc::encode-bundle bundle (or time-tag :now)))) (defun process-osc-bundle (bundle msg-processing-fun) (let ((tt nil)) (if (or (and (arrayp (car bundle)) (not (stringp (car bundle)))) (consp (car bundle))) ;;; LOOKS LIKE OSC... (loop for item in bundle unless (and (arrayp item) (not (stringp item)) (setf tt item)) ;;; THIS IS THE TIME TAG collect (if (and (consp item) (consp (car item))) ;;; THE FIRST ELEMENT OF THE MESSAGE IS ANOTHER MESSAGE (process-osc-bundle (if tt (cons tt (car item)) (car item)) msg-processing-fun) (process-message item msg-processing-fun)) ) ;;; NOT OSC (list (process-message bundle msg-processing-fun))))) ;;========== ;; OSC SEND / RECEIVE ;;========== (defmethod* osc-send (bundle host port) :icon 'osc :initvals '(("/test" 0) nil nil) :indoc '("OSC message" "IP address" "port number") :doc "Sends the an OSC message pf bundle (<bundle>) to the port <port> of <host>. An OSC message consists of a string (URL-style symbolic naming) followed by numerical parameters. Its is formatted as a list. See http://opensoundcontrol.org/introduction-osc <bundle> can also contain a list of messages (list of lists) to be sent simultaneously, or an object of type OSC-BUNDLE. Notes: - If NIL, <host> and <port> values are taken from the OSC preferences. - 127.0.0.1 is the 'localhost', i.e. the message is sent to the local computer. " (osc-send-bundle (or port (get-pref-value :osc :out-port)) (or host (get-pref-value :osc :out-host)) bundle)) (defmethod* osc-receive (port msg-processing &optional host) :icon 'osc :indoc '("port number" "incoming message processing patch" "an IP address") :initvals '(nil nil nil) :doc "A local server receiving OSC. Use 'R' to set the box reactive and activate/deactivate the server. When the server is on, OSC-RECEIVE waits for OSC messages on port <port> and calls <msg-processing> with the decoded message as parameter. <msg-processing> must be a patch in mode 'lambda' with 1 input corresponding to an OSC message. This patch should handle and process the incoming messages. - If NIL <port> value is taken from the OSC preferences. By default the server listen to ANY addresses (localhost and IP address). Set <host> to listen only to the messages sent from the network to the speficic address. " t) (defmethod boxclass-from-function-name ((self (eql 'osc-receive))) 'OMReceiveBox) (defmethod start-receive-process ((self (eql 'osc-receive))) 'osc-start-receive) (defmethod stop-receive-process ((self (eql 'osc-receive))) 'udp-stop-receive) ;;;======================================== ;;; oSC features ;;;======================================== ;;; OSC-RECEIVE PROCESSES ALL THE MESSAGES IN THE BUNDLE ONE BY ONE (defun osc-start-receive (box args) (let ((port (or (car args) (get-pref-value :osc :in-port))) (fun (cadr args)) (host (caddr args))) (if (and port (numberp port)) (let ((process (om-start-udp-server port host #'(lambda (msg) (let* ((message (osc-decode msg)) (delivered (process-osc-bundle message fun))) (when delivered (set-delivered-value box (reverse delivered)))) nil) nil box))) (when process (om-print (format nil "Start OSC receive server on ~A ~D" host port)) process)) (om-beep-msg (format nil "Error - bad port number for OSC-RECEIVE: ~A" port)))))
4,950
Common Lisp
.lisp
99
43.959596
162
0.602862
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
a8427cfb26ad30fc858240ccced3ec95130cb5d4fc1f66e38da14469ad26bb18
839
[ -1 ]
840
osc-preferences.lisp
cac-t-u-s_om-sharp/src/packages/osc/osc-om/osc-preferences.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ (in-package :om) (add-preference-module :osc "OSC") (add-preference-section :osc "OSC In/Out") (add-preference :osc :out-port "Default Output port" (make-number-in-range :min 0 :max 10000 :decimals 0) 3000 "OSC messages are sent by default to this UDP port of the receiver host") (add-preference :osc :out-host "Default Output receiver host" :string "127.0.0.1" "IP address of the receiver host") (add-preference :osc :in-port "Default Input port" (make-number-in-range :min 0 :max 10000 :decimals 0) 3000 "Default port for OM# toos and editors receiving OSC.")
1,299
Common Lisp
.lisp
24
48.916667
105
0.568504
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
0a2834002cc723ba01a1efdf63ce18e31eb1130af8682a1c43acc794e1b6ef9d
840
[ -1 ]
841
osc-route.lisp
cac-t-u-s_om-sharp/src/packages/osc/osc-om/osc-route.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;===================================== ;;; ROUTE OSC ("adress" data) ;;;===================================== (defun address-match (address route-path) (string-equal address route-path)) (defmethod* osc-route ((message list) &rest osc-paths) :icon 'osc :doc"OSC-ROUTE sets its outputs' values to <input> when <input> matches he OSC address of the corresponding inputs, or to NIL otherwise. If the box output connections are reactive, reactive notifications will be send for matching/non-NIL outputs. The input(s) left with :default will output value only if no addres matches. The first output always outputs <input>." (values-list (copy-list (cons message (mapcar #'(lambda (route-path) (if (listp (car message)) ;;; we have several messages here... (let ((rep nil)) (loop for msg in message while (null rep) do (when (address-match (car msg) route-path) (setf rep (cdr msg)))) rep) (when (address-match (car message) route-path) (cdr message)) )) osc-paths))))) (defmethod boxclass-from-function-name ((self (eql 'osc-route))) 'ReactiveRouteBox) ;;; DEPRECATED / RENAMED. KEPT FOR COMPATIBILITY (defmethod route-osc ((message list) &rest osc-paths) (apply 'osc-route (cons message osc-paths))) (defmethod boxclass-from-function-name ((self (eql 'route-osc))) 'ReactiveRouteBox)
2,322
Common Lisp
.lisp
45
44.311111
138
0.539514
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
cf9ca008eaaa55d64607e3e25871d5133cce5cec8a6e0e65bd51bf3296fdf101
841
[ -1 ]
842
osc-examples.lisp
cac-t-u-s_om-sharp/src/packages/osc/cl-osc/osc-examples.lisp
;; -*- mode: lisp -*- ;; ;; Examples of how to send OSC messages. .. ;; ;; Copyright (C) 2004 FoAM vzw ;; ;; Authors ;; - nik gaffney <[email protected]> ;; ;;;;; ;; ; ; ;; ; ; ;;;;;::::: : : : ; ;; ; ; ; ; ; ; ;; ;; Commentry ;; ;; These examples are currently sbcl specific, but should be easily ported to ;; work with trivial-sockets, acl-compat or something similar. They should be ;; able to explain enough to get you started. .. ;; ;; eg. listen on port 6667 for incoming msgs ;; ;; (osc-listen 6667) ;; ;; eg. listen on port 6667 and send to 10.0.89:6668 ;; note the ip# is formatted as a vector ;; ;; (osc-reflector 6667 #(10 0 0 89) 6668) ;; ;;;;;:::;;: ; ; ;::: ; ;; ;; ; ;; ; (require :sb-bsd-sockets) (use-package :osc) (use-package :sb-bsd-sockets) (defun osc-listen (port) "a basic test function which attempts to decode an osc message a given port." (let ((s (make-udp-socket)) (buffer (make-sequence '(vector (unsigned-byte 8)) 1024))) (socket-bind s #(0 0 0 0) port) (format t "listening on localhost port ~A~%~%" port) (unwind-protect (loop do (socket-receive s buffer nil) (format t "receiveded -=> ~S~%" (osc:decode-bundle buffer))) (when s (socket-close s))))) (defun osc-reflector (listen-port send-ip send-port) "reflector.. . listens on a given port and sends out on another note ip#s need to be in the format #(127 0 0 1) for now.. ." (let ((in (make-udp-socket)) (out (make-udp-socket)) (buffer (make-sequence '(vector (unsigned-byte 8)) 512))) (socket-bind in #(0 0 0 0) listen-port) (socket-connect out send-ip send-port) (let ((stream (socket-make-stream out :input t :output t :element-type '(unsigned-byte 8) :buffering :full))) (unwind-protect (loop do (socket-receive in buffer nil) (let ((oscuff (osc:decode-bundle buffer))) (format t "glonked -=> message with ~S~% arg(s)" (length oscuff)) (write-stream-t1 stream oscuff))) (when in (socket-close in)) (when out (socket-close out)))))) (defun make-udp-socket() (make-instance 'inet-socket :type :datagram :protocol :udp)) (defun write-stream-t1 (stream osc-message) "writes a given message to a stream. keep in mind that when using a buffered stream any funtion writing to the stream should call (finish-output stream) after it sends the mesages,. ." (write-sequence (osc:encode-message "/bzzp" "got" "it" ) stream) (finish-output stream)) (defmacro osc-write-to-stream (stream &body args) `(progn (write-sequence (osc:encode-message ,@args) ,stream) (finish-output ,stream))) ;end
2,821
Common Lisp
.lisp
76
32.513158
83
0.603877
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
d17e76bf13caaf94e113e7c0d28d84b400d0b9a198dfc3e8b5da31434dda3755
842
[ -1 ]
843
osc-dispatch.lisp
cac-t-u-s_om-sharp/src/packages/osc/cl-osc/osc-dispatch.lisp
;; -*- mode: lisp -*- ;; ;; patern matching and dispatching for OSC messages ;; ;; copyright (C) 2004 FoAM vzw ;; ;; You are granted the rights to distribute and use this software ;; under the terms of the Lisp Lesser GNU Public License, known ;; as the LLGPL. The LLGPL consists of a preamble and the LGPL. ;; Where these conflict, the preamble takes precedence. The LLGPL ;; is available online at http://opensource.franz.com/preamble.html ;; and is distributed with this code (see: LICENCE and LGPL files) ;; ;; authors ;; - nik gaffney <[email protected]> ;; requirements ;; - not too useful without osc ;; - probably cl-pcre for matching (when it happens). ;; commentary ;; an osc de-/re -mungulator which should deal with piping data ;; from incoming messages to the function/handler/method ;; designated by the osc-address. ;; ;; NOTE: only does direct matches for now, no pattern globs, ;; with single function per uri ;; changes ;; 2005-02-27 18:31:01 ;; - initial version (in-package :osc) ;; should probably be a clos object or an alist. ;; for now, a hash table is enuf. (defun make-osc-tree () (make-hash-table :test 'equalp)) ;;; ;; ;;;;;; ; ; ; ; ;; ;; register/delete and dispatch. .. ;; ;;;; ; ; ; ;; (defun dp-register (tree address function) "registers a function to respond to incoming osc message. since only one function should be associated with an address, any previous registration will be overwritten" (setf (gethash address tree) function)) (defun dp-remove (tree address) "removes the function associated with the given address.." (remhash address tree)) (defun dp-match (tree pattern) "returns a list of functions which are registered for dispatch for a given address pattern.." (list (gethash pattern tree))) (defun dispatch (tree osc-message) "calls the function(s) matching the address(pattern) in the osc message with the data contained in the message" (let ((pattern (car osc-message))) (dolist (x (dp-match tree pattern)) (unless (eq x NIL) (apply #'x (cdr osc-message))))))
2,099
Common Lisp
.lisp
58
34.017241
67
0.711889
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
8532253faf6afa3caf2d8ab5405c968f43c539345b2e0a944d0ac05d14eb10c0
843
[ -1 ]
844
osc.lisp
cac-t-u-s_om-sharp/src/packages/osc/cl-osc/osc.lisp
;;; -*- mode: lisp -*- ;;; ;;; an implementation of the OSC (Open Sound Control) protocol ;;; ;;; copyright (C) 2004 FoAM vzw. ;;; ;;; You are granted the rights to distribute and use this software ;;; under the terms of the Lisp Lesser GNU Public License, known ;;; as the LLGPL. The LLGPL consists of a preamble and the LGPL. ;;; Where these conflict, the preamble takes precedence. The LLGPL ;;; is available online at http://opensource.franz.com/preamble.html ;;; and is distributed with this code (see: LICENCE and LGPL files) ;;; ;;; authors ;;; ;;; nik gaffney <[email protected]> ;;; ;;; requirements ;;; ;;; dependent on sbcl, cmucl or openmcl for float encoding, other suggestions ;;; welcome. ;;; ;;; commentary ;;; ;;; this is a partial implementation of the OSC protocol which is used ;;; for communication mostly amongst music programs and their attatched ;;; musicians. eg. sc3, max/pd, reaktor/traktorska etc+. more details ;;; of the protocol can be found at the open sound control pages -=> ;;; http://www.cnmat.berkeley.edu/OpenSoundControl/ ;;; ;;; - doesnt send nested bundles or timetags later than 'now' ;;; - malformed input -> exception ;;; - int32 en/de-coding based on code (c) Walter C. Pelissero ;;; - unknown types are sent as 'blobs' which may or may not be an issue ;;; ;;; see the README file for more details... ;;; ;;; known BUGS ;;; - encoding a :symbol which is unbound, or has no symbol-value will cause ;;; an error ;;; ;;; Modif JBJMC201309 integrating changes from OM osc-over-udp ;;; - force-string for symbols in messages ;;; - LispWorks support for en/decoding float32 ;;; - decode-message-or-bundle (defpackage :osc (:use :cl) (:documentation "OSC aka the 'open sound control' protocol") (:export :encode-message :encode-bundle :decode-message :decode-bundle)) (in-package :osc) ;(declaim (optimize (speed 3) (safety 1) (debug 3))) ;;;;;; ; ;; ; ; ; ; ; ; ; ;; ;; eNcoding OSC messages ;; ;;;; ;; ;; ; ; ;; ; ; ; ; ;;; JBJMC201309 (defun force-string (data) (string-downcase (string data))) (defun encode-bundle (data &optional timetag) "will encode an osc message, or list of messages as a bundle with an optional timetag (symbol or 64bit int). doesnt handle nested bundles" (cat '(35 98 117 110 100 108 101 0) ; #bundle (if timetag (encode-timetag timetag) (encode-timetag :now)) (if (listp (car data)) (apply #'cat (mapcar #'encode-bundle-elt data)) (encode-bundle-elt data)))) (defun encode-bundle-elt (data) (let ((message (apply #'encode-message data))) (cat (encode-int32 (length message)) message))) (defun encode-message (address &rest data) "encodes an osc message with the given address and data." (concatenate '(vector (unsigned-byte 8)) (encode-address (force-string address)) ;;; JBJMC201309 (encode-typetags data) (encode-data data))) (defun encode-address (address) (cat (map 'vector #'char-code address) (string-padding address))) (defun encode-typetags (data) "creates a typetag string suitable for the given data. valid typetags according to the osc spec are ,i ,f ,s and ,b non-std extensions include ,{h|t|d|S|c|r|m|T|F|N|I|[|]} see the spec for more details. .. NOTE: currently handles the following tags i => #(105) => int32 f => #(102) => float s => #(115) => string b => #(98) => blob and considers non int/float/string data to be a blob." (let ((lump (make-array 0 :adjustable t :fill-pointer t))) (macrolet ((write-to-vector (char) `(vector-push-extend (char-code ,char) lump))) (write-to-vector #\,) (dolist (x data) (typecase x (integer (write-to-vector #\i)) (float (write-to-vector #\f)) (simple-string (write-to-vector #\s)) (symbol (if (or (null x) (equal x t)) (write-to-vector #\i) ;;; will be considered as (int 0/1) (write-to-vector #\s))) ;;; JBJMC201309: symbols = string (t (write-to-vector #\b))))) (cat lump (pad (padding-length (length lump)))))) (defun encode-data (data) "encodes data in a format suitable for an OSC message" (let ((lump (make-array 0 :adjustable t :fill-pointer t))) (macrolet ((enc (f) `(setf lump (cat lump (,f x))))) (dolist (x data) (typecase x (integer (enc encode-int32)) (float (enc encode-float32)) (simple-string (enc encode-string)) (symbol (cond ((null x) (setf lump (cat lump (encode-int32 0)))) ((equal x t) (setf lump (cat lump (encode-int32 1)))) (t (setf lump (cat lump (encode-string (force-string x))))) ;;; JBJMC201309 )) (t (enc encode-blob)))) lump))) ;;;;;; ; ;; ; ; ; ; ; ; ; ;; ;; decoding OSC messages ;; ;;; ;; ;; ; ; ; ; ; ; (defun decode-bundle (data) "decodes an osc bundle into a list of decoded-messages, which has an osc-timetagas its first element" (let ((contents '())) (if (equalp 35 (elt data 0)) ; a bundle begins with '#' (let ((timetag (subseq data 8 16)) (i 16) (bundle-length (length data))) (loop while (< i bundle-length) do (let ((mark (+ i 4)) (size (decode-int32 (subseq data i (+ i 4))))) (if (or (eq size 0) (> (+ mark size) bundle-length)) (setf bundle-length 0) (push (decode-bundle (subseq data mark (+ mark size))) contents)) (incf i (+ 4 size)))) (push timetag contents)) (decode-message data)))) (defun decode-message (message) "reduces an osc message to an (address . data) pair. .." (declare (type (vector *) message)) (let ((x (position (char-code #\,) message))) (if (eq x NIL) (format t "message contains no data.. ") (cons (decode-address (subseq message 0 x)) (decode-taged-data (subseq message x)))))) ;;; JBJMC201309 ;;; decode incoming (unspecified) data (defun decode-message-or-bundle (msg-or-bundle) (if (= (elt msg-or-bundle 0) 35) (decode-bundle msg-or-bundle) (decode-message msg-or-bundle))) (defun decode-address (address) (coerce (map 'vector #'code-char (delete 0 address)) 'string)) ;;; (defun decode-taged-data (data) "decodes data encoded with typetags... NOTE: currently handles the following tags i => #(105) => int32 f => #(102) => float s => #(115) => string b => #(98) => blob d => #(100) => double" (let ((div (position 0 data))) (let ((tags (subseq data 1 div)) (acc (subseq data (padded-length div))) (result '())) (map 'vector #'(lambda (x) (cond ((eq x (char-code #\i)) (push (decode-int32 (subseq acc 0 4)) result) (setf acc (subseq acc 4))) ((eq x (char-code #\f)) (push (decode-float32 (subseq acc 0 4)) result) (setf acc (subseq acc 4))) ;;; NEW ((eq x (char-code #\d)) (push (ieee-floats::decode-float64 (decode-uint64 (subseq acc 0 8))) result) (setf acc (subseq acc 8))) ((eq x (char-code #\t)) (push (decode-uint64 (subseq acc 0 8)) result) (setf acc (subseq acc 8))) ;;; === ((eq x (char-code #\s)) (let ((pointer (padded-length (position 0 acc)))) (push (decode-string (subseq acc 0 pointer)) result) (setf acc (subseq acc pointer)))) ((eq x (char-code #\b)) (let* ((size (decode-int32 (subseq acc 0 4))) (end (padded-length (+ 4 size)))) (push (decode-blob (subseq acc 0 end)) result) (setf acc (subseq acc end)))) (t (error "unrecognised typetag")))) tags) (nreverse result)))) ;;;;;; ;; ;; ; ; ; ; ; ;; ; ;; ;; timetags ;; ;; - timetags can be encoded using a value, or the :now and :time keywords. the ;; keywords enable either a tag indicating 'immediate' execution, or ;; a tag containing the current time (which will most likely be in the past ;; of anyt receiver) to be created. ;; ;; - note: not well tested, and probably not accurate enough for syncronisation. ;; see also: CLHS 25.1.4 Time, and the ntp timestamp format. also needs to ;; convert from 2 32bit ints to 64bit fixed point value. ;; ;; - see this c.l.l thread to sync universal-time and internal-time ;; http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/c207fef63a78d720/adc7442d2e4de5a0?lnk=gst&q=internal-real-time-sync&rnum=1#adc7442d2e4de5a0 ;; ;;;; ;; ; ; (defconstant +unix-epoch+ (encode-universal-time 0 0 0 1 1 1970 0)) (defun encode-timetag (utime &optional subseconds) "encodes an osc timetag from a universal-time and 32bit 'sub-second' part. for an 'instantaneous' timetag use (encode-timetag :now) for a timetag with the current time use (encode-timetag :time)" (cond ;; a 1bit timetag will be interpreted as 'imediately' ((equalp utime :now) #(0 0 0 0 0 0 0 1)) ;; converts seconds since 19000101 to seconds since 19700101 ;; note: fractions of a second is accurate, but not syncronised. ((equalp utime :time) (cat (encode-int32 (- (get-universal-time) +unix-epoch+)) (encode-int32 (round (* internal-time-units-per-second (second (multiple-value-list (floor (/ (get-internal-real-time) internal-time-units-per-second))))))))) ((integerp utime) (cat (encode-int32 (+ utime +unix-epoch+)) (encode-int32 subseconds))) (t (error "the time or subsecond given is not an integer")))) (defun decode-timetag (timetag) "decomposes a timetag into unix-time and a subsecond,. . ." (list (decode-int32 (subseq timetag 0 4)) (decode-int32 (subseq timetag 4 8)))) ;;;;; ; ; ;; ;; ; ; ;; ;; dataformat en- de- cetera. ;; ;;; ;; ; ; ; ;; floats are encoded using implementation specific 'internals' which is not ;; particulaly portable, but 'works for now'. ;;; JBJMC201309 (defun single-float-bits (x) (declare (type single-float x)) (assert (= (float-radix x) 2)) (if (zerop x) (if (eql x 0.0f0) 0 #x-80000000) (multiple-value-bind (lisp-significand lisp-exponent lisp-sign) (integer-decode-float x) (assert (plusp lisp-significand)) ;; Calculate IEEE-style fields from Common-Lisp-style fields. ;; ;; KLUDGE: This code was written from my foggy memory of what IEEE ;; format looks like, augmented by some experiments with ;; the existing implementation of SINGLE-FLOAT-BITS, and what ;; I found floating around on the net at ;; <http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html>, ;; <http://rodin.cs.uh.edu/~johnson2/ieee.html>, ;; and ;; <http://www.ttu.ee/sidu/cas/IEEE_Floating.htm>. ;; And beyond the probable sheer flakiness of the code, all the bare ;; numbers floating around here are sort of ugly, too. -- WHN 19990711 (let* ((significand lisp-significand) (exponent (+ lisp-exponent 23 127)) (unsigned-result (if (plusp exponent) ; if not obviously denormalized (do () (nil) (cond (;; special termination case, denormalized ;; float number (zerop exponent) ;; Denormalized numbers have exponent one ;; greater than the exponent field. (return (ash significand -1))) (;; ordinary termination case (>= significand (expt 2 23)) (assert (< 0 significand (expt 2 24))) ;; Exponent 0 is reserved for ;; denormalized numbers, and 255 is ;; reserved for specials like NaN. (assert (< 0 exponent 255)) (return (logior (ash exponent 23) (logand significand (1- (ash 1 23)))))) (t ;; Shift as necessary to set bit 24 of ;; significand. (setf significand (ash significand 1) exponent (1- exponent))))) (do () ((zerop exponent) ;; Denormalized numbers have exponent one ;; greater than the exponent field. (ash significand -1)) (unless (zerop (logand significand 1)) (warn "denormalized SINGLE-FLOAT-BITS ~S losing bits" x)) (setf significand (ash significand -1) exponent (1+ exponent)))))) (ecase lisp-sign (1 unsigned-result) (-1 (logior unsigned-result (- (expt 2 31))))))))) ;;; JBJMC201309 (defun kludge-opaque-expt (x y) (expt x y)) ;;; JBJMC201309 (defun make-single-float (bits) (cond ;; IEEE float special cases ((zerop bits) 0.0) ((= bits #x-80000000) -0.0) (t (let* ((sign (ecase (ldb (byte 1 31) bits) (0 1.0) (1 -1.0))) (iexpt (ldb (byte 8 23) bits)) (expt (if (zerop iexpt) ; denormalized -126 (- iexpt 127))) (mant (* (logior (ldb (byte 23 0) bits) (if (zerop iexpt) 0 (ash 1 23))) (expt 0.5 23)))) (* sign (kludge-opaque-expt 2.0 expt) mant))))) (defun encode-float32 (f) "encode an ieee754 float as a 4 byte vector. currently sbcl/cmucl specifc" #+sbcl (encode-int32 (sb-kernel:single-float-bits f)) #+cmucl (encode-int32 (kernel:single-float-bits f)) #+openmcl (encode-int32 (CCL::SINGLE-FLOAT-BITS f)) #+allegro (encode-int32 (multiple-value-bind (x y) (excl:single-float-to-shorts f) (+ (ash x 16) y))) #+lispworks (encode-int32 (single-float-bits f)) #-(or sbcl cmucl openmcl allegro lispworks) (error "cant encode floats using this implementation")) (defun decode-float32 (s) "ieee754 float from a vector of 4 bytes in network byte order" #+sbcl (sb-kernel:make-single-float (decode-int32 s)) #+cmucl (kernel:make-single-float (decode-int32 s)) #+openmcl (CCL::HOST-SINGLE-FLOAT-FROM-UNSIGNED-BYTE-32 (decode-uint32 s)) #+allegro (excl:shorts-to-single-float (ldb (byte 16 16) (decode-int32 s)) (ldb (byte 16 0) (decode-int32 s))) #+lispworks (make-single-float (decode-int32 s)) #-(or sbcl cmucl openmcl allegro lispworks) (error "cant decode floats using this implementation")) (defun decode-int32 (s) "4 byte -> 32 bit int -> two's compliment (in network byte order)" (let ((i (+ (ash (elt s 0) 24) (ash (elt s 1) 16) (ash (elt s 2) 8) (elt s 3)))) (if (>= i #x7fffffff) (- 0 (- #x100000000 i)) i))) (defun decode-uint32 (s) "4 byte -> 32 bit unsigned int" (let ((i (+ (ash (elt s 0) 24) (ash (elt s 1) 16) (ash (elt s 2) 8) (elt s 3)))) i)) (defun decode-uint64 (s) "4 byte -> 32 bit unsigned int" (let ((i (+ (ash (elt s 0) 56) (ash (elt s 1) 48) (ash (elt s 2) 40) (ash (elt s 3) 32) (ash (elt s 4) 24) (ash (elt s 5) 16) (ash (elt s 6) 8) (elt s 7)))) i)) (defun encode-int32 (i) "convert an integer into a sequence of 4 bytes in network byte order." (declare (type integer i)) (let ((buf (make-sequence '(vector (unsigned-byte 8)) 4))) (macrolet ((set-byte (n) `(setf (elt buf ,n) (logand #xff (ash i ,(* 8 (- n 3))))))) (set-byte 0) (set-byte 1) (set-byte 2) (set-byte 3)) buf)) ;; osc-strings are unsigned bytes, padded to a 4 byte boundary (defun decode-string (data) "converts a binary vector to a string and removes trailing #\nul characters" (string-trim '(#\nul) (coerce (map 'vector #'code-char data) 'string))) (defun encode-string (string) "encodes a string as a vector of character-codes, padded to 4 byte boundary" (cat (map 'vector #'char-code string) (string-padding string))) ;; blobs are binary data, consisting of a length (int32) and bytes which are ;; osc-padded to a 4 byte boundary. (defun decode-blob (blob) "decode a blob as a vector of unsigned bytes." (let ((size (decode-int32 (subseq blob 0 4)))) (subseq blob 4 (+ 4 size)))) (defun encode-blob (blob) "encodes a blob from a given vector" (let ((bl (length blob))) (cat (encode-int32 bl) blob (pad (padding-length bl))))) ;; utility functions for osc-string/padding slonking (defun cat (&rest catatac) (apply #'concatenate '(vector *) catatac)) (defun padding-length (s) "returns the length of padding required for a given length of string" (declare (type fixnum s)) (- 4 (mod s 4))) (defun padded-length (s) "returns the length of an osc-string made from a given length of string" (declare (type fixnum s)) (+ s (- 4 (mod s 4)))) (defun string-padding (string) "returns the padding required for a given osc string" (declare (type simple-string string)) (pad (padding-length (length string)))) (defun pad (n) "make a sequence of the required number of #\Nul characters" (declare (type fixnum n)) (make-array n :initial-element 0 :fill-pointer n)) (provide :osc) ;; end
18,782
Common Lisp
.lisp
456
32.239035
163
0.560889
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
59a22cd48a49b61c86bc7b1bcba6440eddca29f3cbe4630696e153e980bda21f
844
[ -1 ]
845
sound-preferences.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound-preferences.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;================= ;;; SOUND PREFS ;;;================= (in-package :om) (add-preference-section :audio "Files") (add-preference :audio :format "Default format" '(:aiff :wav) #+macosx :aiff #-macosx :wav "Applies as default choice for audio synthesis functions") (add-preference :audio :normalize "Normalization" :bool t "Applies as default choice for audio synthesis functions") (add-preference :audio :resolution "Default sample size" '(16 24 32) 16 "Applies as parameter for saving audio buffers") ;(add-preference :audio :normalize "Normalization level (db)" :bool t ; "Applies as default choice for audio synthesis functions")
1,445
Common Lisp
.lisp
27
50.444444
90
0.548227
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
9f47f5186a149c4d5e18442037fed27bb6f7836f0d635d5f27584a8d02e44bc5
845
[ -1 ]
846
sound.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;================= ;;; SOUND PROJECT ;;;================= (in-package :om) (load (decode-local-path "audio-api/load-audio-api.lisp")) (mapc #'(lambda (filename) (compile&load (decode-local-path filename))) '( "sound/audio-tools" "sound/sound-object" "sound/sound-editor" "sound/sound-processing" "sound/sound-analysis" "sound/synthesize" "player/juce-player" "player/buffer-player" "sound-preferences" "compatibility" "sound-pack" ))
1,284
Common Lisp
.lisp
33
34.636364
77
0.494779
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
86eddc8d7bfcf16f493d9bda62a23fbaaf151e8183d682fe5adf2c2892e31c37
846
[ -1 ]
847
compatibility.lisp
cac-t-u-s_om-sharp/src/packages/sound/compatibility.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;; LOAD OBJECTS AND CODE FROM OM6 (in-package :om) (defmethod update-arg-names ((reference (eql 'synthesize))) '(("elements" "obj"))) ;; :-( (defclass audio-mix-console () ((channels-ctrl :accessor channels-ctrl) (nbtracks :initarg :nbtracks)))
998
Common Lisp
.lisp
22
43.818182
77
0.510814
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
cdf66c910d77fe11a5753c3335ba4897bd36aafb21a37907472d1d584de1be27
847
[ -1 ]
848
sound-pack.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound-pack.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;================= ;;; SOUND OBJECT ;;;================= (in-package :om) (omNG-make-package "Audio" :container-pack *om-package-tree* :doc "Sound/DSP objects and support" :classes '(sound) :functions '(sound-dur sound-dur-ms sound-samples save-sound) :subpackages (list (omNG-make-package "Processing" :functions '(sound-silence sound-cut sound-fade sound-mix sound-seq sound-normalize sound-gain sound-mono-to-stereo sound-to-mono sound-stereo-pan sound-merge sound-split sound-resample sound-loop sound-reverse )) (omNG-make-package "Analysis" :functions '(sound-rms sound-transients)) (omNG-make-package "Conversions" :functions '(lin->db db->lin samples->sec sec->samples ms->sec sec->ms)) (omNG-make-package "Tools" :functions '(adsr))) )
1,966
Common Lisp
.lisp
44
32.795455
93
0.447808
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
5554d38b6b26e43e94b204d91c35a790e878ea09c718d7ec9cc265018607884a
848
[ -1 ]
849
sound-editor.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound/sound-editor.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ;==================== ; SOUND EDITOR ;==================== (in-package :om) (defclass sound-editor (data-track-editor) ((cache-display-list :accessor cache-display-list :initform nil))) (defclass sound-panel (data-track-panel) ()) (defmethod get-editor-class ((self sound)) 'sound-editor) (defmethod editor-view-class ((self sound-editor)) 'sound-panel) (defmethod extra-window-title-info ((self sound)) (if (file-pathname self) (namestring (file-pathname self)) "temp buffer")) (defmethod can-record ((self sound-editor)) nil) (defmethod frame-display-modes-for-object ((self sound-editor) (object sound)) '(:lines)) (defmethod make-left-panel-for-object ((editor sound-editor) (object t) view) (declare (ignore object view)) (om-make-view 'om-view :size (omp 28 nil))) (defmethod make-editor-controls ((editor sound-editor)) (let ((sound (object-value editor))) (om-make-layout 'om-row-layout :align :center :subviews (list (om-make-di 'om-simple-text :text "Gain" :size (omp 30 20) :font (om-def-font :gui)) (om-make-view 'om-view :size (om-make-point 28 20) :subviews (list (om-make-graphic-object 'numbox :value (gain sound) :bg-color (om-def-color :white) :border t :decimals 2 :size (om-make-point 36 18) :font (om-def-font :normal) :min-val 0.0 :max-val 10.0 :change-fun #'(lambda (item) (set-gain sound (get-value item))) :after-fun #'(lambda (item) (declare (ignore item)) (report-modifications editor))) )))))) (defmethod editor-view-after-init-space ((self sound)) 0) (defmethod default-editor-min-x-range ((self sound-editor)) 0) (defmethod om-draw-contents ((self sound-panel)) (when (get-pref-value :appearance :waveform-bg) (om-draw-rect 0 0 (w self) (h self) :color (get-pref-value :appearance :waveform-bg) :fill t)) (let* ((editor (editor self)) (sound (if (multi-display-p editor) (nth (stream-id self) (multi-obj-list editor)) (object-value editor)))) (if (or (buffer sound) (and (access-from-file sound) (valid-pathname-p (file-pathname sound)))) (editor-draw-sound-waveform sound editor self (x1 self) (x2 self) (stream-id self)) ;;; no sound (om-with-fg-color (om-def-color :light-gray) (om-with-font (om-make-font "Arial" (round (h self) 4) :style '(:bold)) (om-draw-string 10 (+ (round (h self) 2) (round (h self) 8)) "No sound loaded..") ))) ; will draw the markers (call-next-method) )) ;;;; EDITOR CACHE DISPLAY (defstruct sound-display-cache (array) (resolutions)) (defstruct sound-display-cache-resolution (samples-per-pixel) (cache)) ;;; box null = this is for the sound editor (defmethod get-cache-display-for-draw ((self sound) (box null)) (when (or (buffer self) (file-pathname self)) (let* ((height 512) (window 8) (array (get-sample-array-from-sound self window))) (when array (let ((max-pict-res (min (array-dimension array 1) 16368)) (n-samples (n-samples self))) (make-sound-display-cache :resolutions (reverse (append (list (make-sound-display-cache-resolution :samples-per-pixel 1 :cache (get-buffer self)) (make-sound-display-cache-resolution :samples-per-pixel window :cache array)) (loop for samples-per-pixel = (* window 4) then (* samples-per-pixel 4) for new-array-size = (ceiling n-samples samples-per-pixel) for new-array = (resample-sample-array array new-array-size) while (>= new-array-size 1024) collect (make-sound-display-cache-resolution :samples-per-pixel samples-per-pixel :cache (if (< new-array-size max-pict-res) (create-waveform-pict new-array height) new-array)))))) ))))) (defmethod find-best-cache-display ((self sound-display-cache) samples-per-pixel) (let ((rep (or (find samples-per-pixel (sound-display-cache-resolutions self) :key #'sound-display-cache-resolution-samples-per-pixel :test #'>=) (car (last (sound-display-cache-resolutions self)))))) ; (print (list "search" samples-per-pixel (sound-display-cache-resolution-samples-per-pixel rep))) rep)) (defparameter *gen-cache-flag* nil) (defun editor-draw-sound-waveform (sound editor view from to &optional (sound-id 0)) (cond ((and (access-from-file sound) (not (probe-file (file-pathname sound)))) (om-draw-string 10 16 (string+ "File not found: " (namestring (file-pathname sound))) :color (om-def-color :red))) ((not (and (sample-rate sound) (n-samples sound) (n-channels sound))) (om-draw-string 10 16 "Error with loaded sound data." :color (om-def-color :red))) (t (let ((editor-display-cache-ready-p (nth sound-id (cache-display-list editor)))) ;; (re)create display cache if needed (unless (or editor-display-cache-ready-p *gen-cache-flag*) (setf *gen-cache-flag* t) (om-run-process "Generate waveform cache" #'(lambda (ed) (setf (cache-display-list ed) (if (multi-display-p ed) (mapcar #'(lambda (o) (get-cache-display-for-draw o nil)) (multi-obj-list ed)) (list (get-cache-display-for-draw (object-value ed) nil)))) (setf *gen-cache-flag* nil) (editor-invalidate-views editor)) :args (list editor))) (let* (;; Use the box display cache if the editor cache is not ready (display-cache (or editor-display-cache-ready-p (ensure-cache-display-draw (object editor) (object-value editor)))) (sound-duration (get-obj-dur sound)) (draw-end-time (min sound-duration to)) ;; space after sound end (draw-end-pix (x-to-pix view draw-end-time)) (duration-to-draw (- draw-end-time from)) (samples-per-pixel (ceiling (ms->samples duration-to-draw (sample-rate sound)) draw-end-pix)) ;; If using the editor display cache, find best resolution (cache (if (sound-display-cache-p display-cache) (find-best-cache-display display-cache samples-per-pixel) display-cache))) (when cache (cond ;; Using the editor display cache at high-res (cache is an array or a buffer) ((and (sound-display-cache-resolution-p cache) (or (arrayp (sound-display-cache-resolution-cache cache)) (om-sound-buffer-p (sound-display-cache-resolution-cache cache)))) (let* ((array (sound-display-cache-resolution-cache cache)) (res (sound-display-cache-resolution-samples-per-pixel cache)) (sr (sample-rate sound))) (draw-waveform array (w view) (h view) (ms->samples from sr) (ms->samples to sr) res))) ;; Using the box display cache or the editor display cache at low-res (cache is a picture) (t (let* ((pict (if (sound-display-cache-resolution-p cache) (sound-display-cache-resolution-cache cache) cache)) (pict-factor (/ (om-pict-width pict) sound-duration))) (when (and pict (not (equal :error pict))) (let* ((n-channels (n-channels sound)) (channel-h (/ (h view) n-channels))) (dotimes (c n-channels) (let ((y (* channel-h (+ c .5)))) (om-draw-line 0 y (w view) y :color (get-pref-value :appearance :waveform-color))))) (om-draw-picture pict :w (w view) :h (h view) :src-x (* pict-factor from) :src-w (* pict-factor (- to from)))) (unless editor-display-cache-ready-p (om-draw-string 10 16 "Generating waveform display..." :color (om-def-color :orange))) )))) ))))) (defmethod update-to-editor ((editor sound-editor) (from t)) (unless (or (equal from editor) (and (multi-display-p editor) (equal from (container-editor editor)))) (setf (cache-display-list editor) nil)) (update-window-name editor) (call-next-method)) (defmethod editor-key-action ((editor sound-editor) key) (let* ((panel (active-panel editor)) (stream (object-value editor))) (case key (#\l (when (selection editor) (let ((newlabel (om-get-user-string "enter a new label for selected markers" :initial-string (or (label (nth (car (selection editor)) (frames stream))) "")))) (when newlabel (loop for pos in (selection editor) do (setf (label (nth pos (frames stream))) newlabel)) (om-invalidate-view panel) (report-modifications editor) ) ))) (#\L (loop for pos in (selection editor) do (setf (label (nth pos (frames stream))) nil)) (om-invalidate-view panel) (report-modifications editor)) (:om-key-esc NIL) ;;; we don't want to reinit-x-ranges as in the next-method (otherwise (call-next-method))) ))
11,594
Common Lisp
.lisp
218
37.53211
121
0.514906
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
28d90dfa2d3ad1ab521194905f87460fc68afc4c8c362a58655f7157cd27e826
849
[ -1 ]
850
synthesize.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound/synthesize.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ (in-package :om) ;;;============================================== ;;; A superclass for 'playable' synthesis objects ;;;============================================== (defclass SynthesisEvt (schedulable-object) ()) (defun filter-events (evt-list fun-s) (loop for item in evt-list when (let ((rep t)) (loop for fun in (list! fun-s) while rep do (setf rep (funcall fun item))) rep) collect item)) ;;; the function pointed by synthesize method must accept the following keyword arguments ;;; (even if it ignores them) : ;;; :name :run :format :inits :tables :filters :resolution :normalize :sr :kr (defmethod synthesize-method ((self t)) nil) (defun collect-events-by-synth (evt-list) (let ((rep nil)) (loop for evt in evt-list do (let ((synthesis-fun (synthesize-method evt))) (if synthesis-fun (let ((thislist (find synthesis-fun rep :key 'car))) (if thislist (setf (cadr thislist) (append (cadr thislist) (list evt))) (setf rep (append rep (list (list synthesis-fun (list evt))))))) (om-beep-msg "No synthesis method for events of type ~A" (type-of evt)))) ) rep)) ;;;============================================== ;;; A generic synthesizer function ;;; (calls appropriate specific method for the type of input) ;;;============================================== (defmethod* synthesize ((obj synthesisevt) &key (name "my-synth") (run t) format resolution (normalize nil normalize-supplied-p) inits tables filters sr kr) :indoc '("a synthesis even (or list)" "name of output file" "run synthesis or generate params?" "audio output format" "filter function for synthesis events" "synth initializers" "wave/gen tables" "sample rate" "control rate") :initvals '(nil "my-synth" t "aiff") (when (synthesize-method obj) (if (or (null filters) (filter-events (list obj) filters)) (funcall (synthesize-method obj) obj :name name :run run :format (or format (get-pref-value :audio :format)) :resolution resolution :normalize (if normalize-supplied-p normalize (get-pref-value :audio :normalize)) :inits inits :tables tables :sr sr :kr kr) (om-beep-msg "SYNTHESIZE: event did not pass filter(s) !")) )) (defmethod* synthesize ((obj list) &key (name "my-synth") (run t) format resolution (normalize nil normalize-supplied-p) inits tables filters sr kr) (let* ((evt-list (if filters (filter-events obj filters) obj)) (grouped-list (collect-events-by-synth evt-list)) (out-normalize (if normalize-supplied-p normalize (get-pref-value :audio :normalize)))) (when grouped-list (cond ((= 1 (length grouped-list)) ;; only one kind of synthesis (most frequent case...) (funcall (car (car grouped-list)) (cadr (car grouped-list)) :name name :run run :format format :inits inits :tables tables :resolution resolution :normalize out-normalize :sr sr :kr kr)) (t (let ((rep-list (loop for elt in grouped-list ;; several synthesis processes to mix for i = 1 then (+ i 1) collect (funcall (car elt) (cadr elt) :name (string+ name "-temp-" (number-to-string i)) :run run :format format :inits inits :tables tables :resolution resolution :normalize out-normalize :sr sr :kr kr)))) (if run ;;; mix all results (save-sound (reduce 'sound-mix rep-list) (if (pathnamep name) name (outfile name :type format))) rep-list))) ) )))
5,262
Common Lisp
.lisp
104
36.855769
141
0.486513
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
f671ab8eeda99972ec14d8d4f794305b3363f95756fef42d558a6b4eddc1c310
850
[ -1 ]
851
sound-object.lisp
cac-t-u-s_om-sharp/src/packages/sound/sound/sound-object.lisp
;============================================================================ ; om#: visual programming language for computer-assisted music composition ;============================================================================ ; ; This program is free software. For information on usage ; and redistribution, see the "LICENSE" file in this distribution. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; ;============================================================================ ; File author: J. Bresson ;============================================================================ ;;;================= ;;; SOUND OBJECT ;;;================= (in-package :om) ;;; use as :ptr for OM-SOUND-BUFFER (defun make-audio-buffer (nch size &optional (type :float)) (fli::allocate-foreign-object :nelems nch :type :pointer :initial-contents (loop for c from 0 to (1- nch) collect (fli::allocate-foreign-object :type type :nelems size :initial-element 0.0)))) ;;============================== ;; SOUND BUFFER ;;============================== (defparameter *default-internal-sample-size* :float) (defstruct (om-sound-buffer (:include oa::om-pointer)) (nch 1 :type integer)) (defmethod om-pointer-release-function ((self om-sound-buffer)) 'om-cleanup) ;;; if the om-sound-buffer is created like this, it will be garbaged automatically (defun make-om-sound-buffer-GC (&key ptr (count 1) (nch 1) (size nil)) (om-print-dbg "Initializing audio buffer (~A channels)..." (list nch)) (om-create-with-gc (make-om-sound-buffer :ptr ptr :count count :nch nch :size size))) ;;; this is the garbage action (defmethod om-cleanup ((self om-sound-buffer)) (om-print-dbg "Free Audio buffer: ~A" (list self)) (when (and (oa::om-pointer-ptr self) (not (om-null-pointer-p (oa::om-pointer-ptr self)))) (audio-io::om-free-audio-buffer (oa::om-pointer-ptr self) (om-sound-buffer-nch self)))) ;;; not useful if cleanup buffer works ;(defmethod oa::om-release ((ptr om-sound-buffer)) ; (om-print (format nil "Release audio buffer ~A in ~A" (oa::om-pointer-ptr ptr) ptr) "SOUND_DEBUG") ; (when (<= (decf (oa::om-pointer-count ptr)) 0) ; (om-print (format nil "CAN FREE Audio buffer ~A in ~A !" (oa::om-pointer-ptr ptr) ptr) "SOUND_DEBUG") ; (unless (om-null-pointer-p (oa::om-pointer-ptr ptr)) ; (audio-io::om-free-audio-buffer (oa::om-pointer-ptr ptr) (om-sound-buffer-nch ptr))) ; )) ;;; we never save it on disk (defmethod omng-save ((self om-sound-buffer)) nil) ;;============================== ;; SOUND ;;============================== ;; schedulable-object (defclass internal-sound (om-cleanup-mixin schedulable-object timed-object) ((buffer :accessor buffer :initform nil :initarg :buffer :documentation "the buffer of audio samples") (n-samples :accessor n-samples :initform nil :initarg :n-samples :type integer) (n-channels :accessor n-channels :initform nil :initarg :n-channels :type integer) (sample-rate :accessor sample-rate :initform nil :initarg :sample-rate :type integer) (smpl-type :accessor smpl-type :initform :float :initarg :smpl-type) (sample-size :accessor sample-size :initform 16 :initarg :sample-size :type integer) (mute :accessor mute :initform nil) (buffer-player :accessor buffer-player :initform nil :documentation "pointer to a buffer player"))) ;; internal-sound never explicitly frees its buffer but just releases it. ;; => buffer must be created 'with-GC' (defmethod om-cleanup ((self internal-sound)) (om-print-dbg "SOUND cleanup: ~A (~A)" (list self (buffer self))) (when (buffer self) (oa::om-release (buffer self)))) (defmethod additional-slots-to-copy ((from internal-sound)) (append (call-next-method) '(mute))) (defmethod excluded-slots-from-copy ((from internal-sound)) '(buffer)) ;;; CLONE A SOUND (defmethod clone-object ((self internal-sound) &optional clone) (let ((snd (call-next-method))) (when (buffer self) (let ((new-ptr (make-audio-buffer (n-channels self) (n-samples self))) (self-ptr (oa::om-pointer-ptr (buffer self)))) (om-print-dbg "Copying sound buffer (~D x ~D channels)..." (list (n-samples self) (n-channels self))) (dotimes (ch (n-channels self)) (dotimes (smp (n-samples self)) (setf (cffi::mem-aref (cffi::mem-aref new-ptr :pointer ch) :float smp) (cffi::mem-aref (cffi::mem-aref self-ptr :pointer ch) :float smp)))) (setf (buffer snd) (make-om-sound-buffer-gc :ptr new-ptr :nch (n-channels self) :size (n-samples self))) )) snd)) (defmethod release-sound-buffer ((self internal-sound)) (when (buffer self) (oa::om-release (buffer self)) (setf (buffer self) nil))) ;;; called by the box at eval (defmethod release-previous-value ((self internal-sound)) (release-sound-buffer self)) (defmethod check-valid-sound-buffer ((self internal-sound)) (or (and (buffer self) (oa::om-pointer-ptr (buffer self))) (om-beep-msg "Error: Invalid/null sound buffer"))) ;;; mostly for compatibility... (defmethod get-om-sound-data ((self internal-sound)) (buffer self)) (defclass* sound (internal-sound data-track named-object) ((markers :initform nil :documentation "a list of markers (ms)") ;; :accessor markers ;; => accessor is redefined below (file-pathname :initform nil :documentation "a pathname") ;; :accessor file-pathname ;; => accessor is redefined below (gain :accessor gain :initform 1.0 :documentation "gain controller [0.0-1.0]") (access-from-file :accessor access-from-file :initform nil :documentation "read from file or allocate buffer")) (:icon 'sound) (:default-initargs :default-frame-type 'marker-frame) (:documentation "Sound object. A sound can be initialized/attached to a pathname (<file-pathname>) corresponding to an audio file on the disk. If it is unlocked and unconnected, evaluating the box will open a file chooser dialog and allow the selection of a sound file to load. The other inputs/outputs : <gain> = a gain applied to the audio buffer for playback. <markers> = a list of markers (time in milliseconds). The markers can also be added/moved/removed from the sound editor. <access-from-file> = if this parameter is non-NIL, then this sound will work without an internal audio buffer, that is, referring to a file on disk. Press 'space' to play/stop the sound file. ")) (defmethod additional-class-attributes ((self sound)) '(markers file-pathname sample-rate n-channels n-samples gain access-from-file)) (defmethod play-obj? ((self sound)) t) (defmethod get-obj-dur ((self sound)) (if (and (sample-rate self) (n-samples self)) (* 1000.0 (/ (n-samples self) (sample-rate self))) 0)) (defmethod box-def-self-in ((self (eql 'sound))) :choose-file) (defmethod default-name ((self sound)) (when (file-pathname self) (if (stringp (pathname-type (file-pathname self))) (string+ (pathname-name (file-pathname self)) "." (pathname-type (file-pathname self))) (pathname-name (file-pathname self))))) ;;; specialized to save sound pathname relative ;;; + prevent saving unnecessary slots (defmethod omng-save ((self sound)) `(:object (:class ,(type-of self)) (:slots ((:onset 0) (:duration ,(get-obj-dur self)) (:n-samples ,(n-samples self)) (:n-channels ,(n-channels self)) (:sample-rate ,(sample-rate self)) (:smpl-type ,(smpl-type self)) (:sample-size ,(sample-size self)))) (:add-slots ((:markers ,(omng-save (markers self))) (:gain ,(gain self)) (:access-from-file ,(access-from-file self)) (:file-pathname ,(and (file-pathname self) (omng-save (relative-pathname (file-pathname self) *relative-path-reference*)))) )))) ;;;=========================== ;;; UTILS ;;;=========================== ;;; GET A SOUND OBJECT FROM ... ; used in : ; spat-object (sources) ; merge-sounds ; with-sound-buffer ;;; called when, for some reason, we want a full-featured sound (with info etc.) (defmethod get-sound ((self sound)) self) (defmethod get-sound ((self t)) nil) (defmethod get-sound ((self internal-sound)) (om-init-instance (clone-object self (make-instance 'sound)) nil)) ;; `((:file-pathname ,self) (:access-from-file t)) (defmethod get-sound ((self pathname)) (when (probe-file self) (let ((snd (make-instance 'sound))) (setf (file-pathname snd) self) (om-init-instance snd) ))) (defmethod get-sound ((self string)) (get-sound (pathname self))) (defmethod get-sound-name ((self pathname)) (pathname-name self)) (defmethod get-sound-name ((self string)) self) (defmethod get-sound-name ((self sound)) (if (file-pathname self) (pathname-name (file-pathname self)) "sound")) (defmethod get-sound-name ((self t)) "invalid sound") (defmethod get-sound-file ((self pathname)) self) (defmethod get-sound-file ((self string)) (pathname self)) (defmethod get-sound-file ((self sound)) (get-sound-file (file-pathname self))) (defmethod get-sound-file ((self t)) nil) ;;; cross-version API used in libs etc. (defmethod om-sound-file-name ((self sound)) (file-pathname self)) (defmethod om-sound-sample-rate ((self sound)) (sample-rate self)) (defmethod om-sound-n-samples ((self sound)) (n-samples self)) (defmethod om-sound-n-channels ((self sound)) (n-channels self)) (defmethod set-gain ((self sound) (gain number)) (setf (gain self) (float gain)) (when (buffer-player self) (buffer-player-set-gain (buffer-player self) (gain self)))) ;;; UTILS FOR SYNTHESIS AND PROCESSING (defmacro with-sound-output ((snd &key (size 0) (nch 1) (sr 44100) (type :float)) &body body) `(let ((,snd (make-instance 'sound :n-samples ,size :n-channels ,nch :sample-rate ,sr :smpl-type ,type :buffer (make-om-sound-buffer-GC :ptr (make-audio-buffer ,nch ,size ,type) :nch ,nch)))) ,@body ,snd)) (defmacro write-in-sound (snd chan pos value) `(setf (fli:dereference (fli:dereference (oa::om-pointer-ptr (buffer ,snd)) :index ,chan :type :pointer) :index ,pos :type (smpl-type ,snd)) ,value)) (defmacro read-in-sound (snd chan pos) `(fli:dereference (fli:dereference (oa::om-pointer-ptr (buffer ,snd)) :index ,chan :type :pointer) :index ,pos :type (smpl-type ,snd))) #| ;;; Example: (defun synth (dur freq gain envelope) (let* ((sr 44100) (nbsamples (round (* dur sr))) (freqs (list! freq)) (steps (loop for f in freqs collect (/ f sr))) (sampled-envelope (om-scale (nth 2 (multiple-value-list (om-sample envelope nbsamples))) 0.0 1.0))) (with-sound-output (mysound :nch 2 :size nbsamples :sr 44100 :type :float) (loop for x from 0 to (1- nbsamples) for y-list = (make-list (length steps) :initial-element 0) then (om+ y-list steps) for amp in sampled-envelope do (write-in-sound mysound 1 x (* gain amp (apply '+ (loop for y in y-list collect (sin (* 2 (coerce pi 'single-float) (cadr (multiple-value-list (floor y)))))) )) ) ) ))) |# (defmethod get-buffer ((self sound)) (or (buffer self) (when (and (valid-pathname-p (file-pathname self)) (probe-file (file-pathname self)) (n-channels self) (n-samples self)) (make-om-sound-buffer-GC :count 1 :nch (n-channels self) :size (n-samples self) :ptr (audio-io::om-get-audio-buffer (namestring (file-pathname self)) *default-internal-sample-size*))))) ;;;=========================== ;;; TIME MARKERS ;;;=========================== (defclass marker-frame (data-frame) ((label :accessor label :initarg :label :initform nil))) (defmethod print-object ((self marker-frame) out) (format out "[marker ~D: ~A]" (date self) (label self))) (defmethod data-frame-text-description ((self marker-frame)) (list (format nil "t=~A" (date self)) (or (label self) ""))) (defmethod get-frame-action ((self marker-frame)) nil) (defmethod get-frame-graphic-duration ((self marker-frame)) 10) (defmethod get-frame-color ((self marker-frame)) (om-make-color .5 .3 .3)) (defmethod get-frame-posy ((self marker-frame)) 100) (defmethod get-frame-sizey ((self marker-frame)) 200) (defmethod draw ((frame marker-frame) x y w h selected) (om-draw-line x y x h :line (if selected 3 2) :style '(4 4) :color (if selected (om-def-color :dark-red) nil)) (when (label frame) (om-draw-string (+ x 4) (+ y 12) (format nil "~A" (label frame)) :color (if selected (om-def-color :dark-red) nil))) t) (defmethod markers-time ((self sound)) (loop for frame in (data-track-get-frames self) collect (date frame))) (defmethod get-time-markers ((self sound)) (markers-time self)) ;;; (RE)DEFINE MARKERS ACCESSOR FOR SOUND ;;; for the user markers are just numbers ;;; (in fact they are data-frames) (defmethod markers ((self sound)) (loop for frame in (data-track-get-frames self) collect (if (label frame) (list (date frame) (label frame)) (date frame)) )) (defmethod (setf markers) (markers (self sound)) ;;; markers used to be in seconds in OM6... :-s (when (find-if #'floatp markers) (om-print "Warning: float-formatted markers will be converted to milliseconds" "SOUND-BOX") (setf markers (sec->ms markers))) (data-track-set-frames self (loop for m in markers collect (cond ((numberp m) (make-instance 'marker-frame :date m)) ((consp m) (make-instance 'marker-frame :date (car m) :label (cadr m))) ((typep m 'marker-frame) (om-copy m))) )) markers) ;;;=========================== ;;; INITIALIZATION... ;;;=========================== #| ;; NOT USED FOR THE MOMENT (defmacro om-sound-protect (sound &body body) `(if (equal (loaded ,sound) :error) (progn (print (format nil "sound ~s is disabled because of previous errors" (namestring (filename ,sound)))) nil) (or (ignore-errors ,@body) (progn (print (format nil "error in sound ~s" (namestring (filename ,sound)))) (setf (loaded ,sound) :error) nil)))) |# (defmethod objFromObjs ((model internal-sound) (target sound)) (clone-object model target)) (defmethod objFromObjs ((model sound) (target sound)) (clone-object model target)) (defmethod objFromObjs ((model t) (target sound)) (when (get-sound-file model) (objFromObjs (get-sound-file model) target))) (defmethod objFromObjs ((model pathname) (target sound)) (setf (file-pathname target) model) target) (defmethod objFromObjs ((model (eql :choose-file)) (target sound)) (let ((file (om-choose-file-dialog :prompt "Choose an audio file AIFF/WAV..." :types '("Audio files" "*.aiff;*.aif;*.wav" "AIFF files" "*.aiff;*.aif" "WAV files" "*.wav")))) (if file (objFromObjs file target) (abort-eval)))) ;;;================================= ;;; SOUND INIT RULES: ;;;================================= ;;; (RE)DEFINE file-pathname ACCESSORS (defmethod (setf file-pathname) (new-path (self sound)) (when new-path ;;; we're assigning a new file-pathname (let* ((old-path (slot-value self 'file-pathname)) (final-new-path (if (buffer self) ;;; a buffer was already in: save the buffer in the new file (save-sound-data self new-path) ;;; a path already existed: copy in new (if old-path (om-copy-file old-path new-path))))) (setf (slot-value self 'file-pathname) new-path) final-new-path))) (defmethod file-pathname ((self sound)) (slot-value self 'file-pathname)) (defmethod set-play-buffer ((self sound)) (if (and (file-pathname self) (access-from-file self)) (progn (om-print-dbg "Initializing FILE player for sound ~A (~D channels)" (list self (n-channels self))) (setf (buffer-player self) (make-player-from-file (namestring (file-pathname self))))) (when (buffer self) ;;; in principle at that point there should be a buffer.. (if (and (n-samples self) (n-channels self) (sample-rate self)) (progn (om-print-dbg "Initializing BUFFER player for sound ~A (~D channels)" (list self (n-channels self))) (setf (buffer-player self) (make-player-from-buffer (oa::om-pointer-ptr (buffer self)) (n-samples self) (n-channels self) (sample-rate self)))) (om-beep-msg "Incomplete info in SOUND object. Could not instanciate the player !!") )) )) (defmethod om-init-instance ((self sound) &optional initargs) (call-next-method) (if (access-from-file self) (if (and (valid-pathname-p (file-pathname self)) (file-exists-p (file-pathname self))) ;; We want to keep working with this file (and no buffer) (if (buffer self) (release-sound-buffer self) (if (pathname-type (file-pathname self)) (set-sound-info self (file-pathname self)) (om-beep-msg "Cannot load audio file without a valid extension!"))) (om-beep-msg "Cannot set SOUND with :ACCESS-FROM-FILE without a valid file!")) ;;; else we set the buffer (if needed) (when (and (file-pathname self) (not (buffer self))) (if (pathname-type (file-pathname self)) (set-sound-data self (file-pathname self)) (om-beep-msg "Cannot load audio file without a valid extension!")))) self) #| ;;; IF <SELF> + NO <FILE-PATHNAME> ;;; - access-from-file = T => SET FILE-PATHNAME and NO BUFFER ;;; - access-from-file = NIL => SET BUFFER and FILE-PATHNAME = NIL ;;; IF <SELF> + <FILE-PATHNAME> (same) ;;; - access-from-file = T => NO BUFFER, JUST SET SOUND INFO ;;; - access-from-file = NIL => SET BUFFER ;;; IF <SELF> + <FILE-PATHNAME> (different) ;;; - access-from-file = T => SAVE INCOMING DATA TO FILE-PATHNAME, NO BUFFER ;;; - access-from-file = NIL => SAVE INCOMING DATA TO FILE-PATHNAME, KEEP BUFFER ;;; IF NO <SELF> AND <FILE-PATHNAME> ONLY ;;; - access-from-file = T => NO BUFFER - JUST SET SOUND INFO ;;; - access-from-file = NIL => SET BUFFER (cond ((and FILE-IN (file-pathname self) (string-equal (namestring (file-pathname self)) (namestring FILE-IN))) ;;; FILE-IN maches the current file (if access-from-file ;; We want to keep working with this file (and no buffer) (if (buffer self) (release-sound-buffer self) (set-sound-info self FILE-IN)) ;;; else we set the buffer (if needed) (unless (buffer self) (set-sound-data self FILE-IN)))) ((and FILE-IN (file-pathname self)) ;;; there was already a file but different (om-copy-file (file-pathname self) FILE-IN) (setf (file-pathname self) FILE-IN) (if access-from-file ;; We want to keep working with this file (and no buffer) (if (buffer self) (release-sound-buffer self) (set-sound-info self FILE-IN)) ;;; create new buffer (set-sound-data self FILE-IN))) ((and FILE-IN (buffer self)) ;;; There was no file in the sound but already a buffer (save-sound-data self FILE-IN) (setf (file-pathname self) FILE-IN) (if access-from-file (release-sound-buffer self))) (FILE-IN ;;; there was nothing before... (if access-from-file (progn (setf (file-pathname self) FILE-IN) (set-sound-info self FILE-IN)) (set-sound-data self FILE-IN))) ((file-pathname self) ;;; No FILE-IN given but a file was in (if access-from-file (if (buffer self) (release-sound-buffer self) (set-sound-info self (file-pathname self))) (unless (buffer self) ;;; create the buffer if needed (set-sound-data self (file-pathname self))))) (t ;;; there was no file and no in-file is given (if access-from-file (om-beep-msg "Cannot use ACCESS-FROM-FILE without a file !!")) ;;; => if there was a buffer we just keep it ) ) |# ;;; executes its body with buffer-name bound to a valid audio buffer ;;; this buffer can be found in sound or produced from the filename ;;; in the second case, it is freed at the end ;;; sound must also have a valid n-samples and n-channels ;;; => do it without '-GC' ? (defmacro with-audio-buffer ((buffer-name sound) &body body) `(let ((snd (get-sound ,sound))) (if snd (let* ((tmp-buffer (unless (buffer snd) (when (and (valid-pathname-p (file-pathname snd)) (probe-file (file-pathname snd)) (n-channels snd) (n-samples snd)) (make-om-sound-buffer-GC :count 1 :nch (n-channels snd) :size (n-samples snd) :ptr (audio-io::om-get-audio-buffer (namestring (file-pathname snd)) *default-internal-sample-size*))))) (,buffer-name (or tmp-buffer (buffer snd)))) (unwind-protect (progn (unless ,buffer-name (om-print-format "Warning: no sound buffer allocated for ~A" (list (file-pathname snd)))) ,@body) (when tmp-buffer (oa::om-release tmp-buffer)) )) (om-beep-msg "Wrong input type for sound: ~A" ,sound)) )) (defun set-sound-data (sound path) (when (buffer sound) (oa::om-release (buffer sound))) (if (probe-file path) (progn (om-print-dbg "Loading sound from: ~s" (list path)) (multiple-value-bind (buffer format channels sr ss size) (audio-io::om-get-audio-buffer (namestring path) *default-internal-sample-size* nil) (declare (ignore format)) (when buffer (unwind-protect (progn (setf (buffer sound) (make-om-sound-buffer-GC :ptr buffer :count 1 :nch channels :size size) (smpl-type sound) *default-internal-sample-size* (n-samples sound) size (n-channels sound) channels (sample-rate sound) sr (sample-size sound) ss) sound))))) (progn (om-beep-msg "Unable to load sound from: ~s" path) (setf (buffer sound) nil) nil) )) (defun set-sound-info (sound path) (if (probe-file path) (multiple-value-bind (format channels sr ss size) (audio-io::om-get-sound-info (namestring path)) (declare (ignore format)) (setf (n-samples sound) size (n-channels sound) channels (sample-rate sound) sr (sample-size sound) ss) ) (om-beep-msg "Unable to load soudn from: ~s" path)) sound) (defun interleave-buffer (in out samples channels) (dotimes (smp samples) (dotimes (ch channels) (setf (cffi::mem-aref out :float (+ (* smp channels) ch)) (cffi::mem-aref (cffi::mem-aref in :pointer ch) :float smp)))) out) (defun split-buffer (in out samples channels) (dotimes (smp samples) (dotimes (ch channels) (setf (cffi::mem-aref (cffi::mem-aref out :pointer ch) :float smp) (cffi::mem-aref in :float (+ (* smp channels) ch))))) out) (defun save-sound-data (sound path) (when (buffer sound) (let* ((nch (n-channels sound)) (nsmp (n-samples sound))) (om-print-format "Writing file to disk: ~S" (list path)) (audio-io::om-save-buffer-in-file (oa::om-pointer-ptr (buffer sound)) (namestring path) nsmp nch (sample-rate sound) (get-pref-value :audio :resolution) (get-pref-value :audio :format)) (or (probe-file path) (om-beep-msg "Error -- no file written"))) )) ;;;=========================== ;;; METHODS ;;;=========================== (defmethod* sound-samples ((self sound) (num integer) &optional channel) :initvals '(nil 1000 1) :indoc '("a sound object" "number of points" "channel number") :doc "Returns <num> sampled points from the audio waveform of channel <channel> in <self>." :icon 'sound (when (check-valid-sound-buffer self) (with-audio-buffer (b self) (let ((numdat (n-samples self)) (numchan (n-channels self)) (ch (or channel 1))) (if (or (> ch numchan) (> num numdat)) (om-beep-msg "SOUND-POINTS: out-of-range input values !!") (let ((channel-ptr (om-read-ptr (om-sound-buffer-ptr b) (1- ch) :pointer))) (loop for i from 0 to numdat by (round numdat num) collect (om-read-ptr channel-ptr i :float))) ))))) ; compatibility (defmethod* sound-points ((self sound) (num integer) &optional channel) (sound-samples self num channel)) (defmethod* sound-dur ((sound sound)) :icon 'sound :initvals '(nil) :indoc '("a sound object or file pathname") :doc "Returns the duration of <sound> in seconds." (if (and (n-samples sound) (sample-rate sound) (> (sample-rate sound) 0)) (float (/ (n-samples sound) (sample-rate sound))) 0)) (defmethod* sound-dur ((sound pathname)) (sound-dur (namestring sound))) (defmethod* sound-dur ((sound string)) (if (probe-file sound) (multiple-value-bind (format channels sr ss size) (audio-io::om-get-sound-info sound) (declare (ignore format channels ss)) (if (and size sr (> sr 0)) (float (/ size sr)) 0)) (progn (om-beep-msg "File not found: ~s" sound) 0))) (defmethod* sound-dur-ms ((sound t)) :initvals '(nil) :indoc '("a sound object or file pathname") :doc "Returns the duration of <sound> in milliseconds." :icon 'sound (round (* 1000 (sound-dur sound)))) (defmethod* save-sound ((self internal-sound) filename &key format resolution) :icon 'save-sound :initvals '(nil nil :aiff) :indoc '("a sound or internal-sound buffer" "output file pathname" "audio format" "audio resolution (16, 24, 32)") :menuins '((2 (("AIFF" :aiff) ("WAV" :wav) ("FLAC" :flac) ("OGG Vorbis" :ogg))) (3 ((16 16) (24 24) (32 32)))) :doc "Saves a <self> (internal-sound buffer) as an audio file." (when (check-valid-sound-buffer self) (let* ((format (or format (get-pref-value :audio :format))) (file (or filename (om-choose-new-file-dialog :directory (def-save-directory) :prompt (om-str "Save as...") :types (cond ((equal format :aiff) (list (format nil (om-str :file-format) "AIFF") "*.aiff;*.aif")) ((equal format :wav) (list (format nil (om-str :file-format) "WAV") "*.wav")) ((equal format :flac) (list (format nil (om-str :file-format) "FLAC") "*.flac")) ((equal format :ogg) (list (format nil (om-str :file-format) "OGG Vorbis") "*.ogg")) (t nil))))) ) (when file (setf *last-saved-dir* (make-pathname :directory (pathname-directory file))) (audio-io::om-save-buffer-in-file (oa::om-pointer-ptr (buffer self)) (namestring file) (n-samples self) (n-channels self) (sample-rate self) (or resolution (get-pref-value :audio :resolution)) format) (or (file-exists-p file) (om-beep-msg "Error: File ~A was not written on disk. :(" (namestring file))))))) ;;;==================== ;;; PLAYER ;;;==================== ;;;Methods redefinitions using the slot "data" of schedulable object to bypass actions rendering and store the las pointer (defmethod get-action-list-for-play ((self sound) time-interval &optional parent) (external-player-actions self time-interval parent)) (defmethod player-play-object ((self scheduler) (object sound) caller &key parent interval) (declare (ignore parent)) (unless (buffer-player object) (set-play-buffer object)) (when (buffer-player object) (buffer-player-set-gain (buffer-player object) (gain object)) (start-buffer-player (buffer-player object) :start-frame (if (car interval) (round (* (car interval) (/ (sample-rate object) 1000.0))) (or (car interval) 0)))) (call-next-method)) (defmethod player-stop-object ((self scheduler) (object sound)) (when (buffer-player object) (stop-buffer-player (buffer-player object))) (call-next-method)) (defmethod player-pause-object ((self scheduler) (object sound)) (when (buffer-player object) (pause-buffer-player (buffer-player object))) (call-next-method)) (defmethod player-continue-object ((self scheduler) (object sound)) (when (buffer-player object) (continue-buffer-player (buffer-player object))) (call-next-method)) (defmethod set-object-current-time ((self sound) time) (when (buffer-player self) (jump-to-time (buffer-player self) time)) (call-next-method)) (defmethod set-time-callback ((self sound) time) (when (buffer-player self) (jump-to-time (buffer-player self) time)) (call-next-method)) ;;; UTIL FUNCTION FOR JUST PLAYING A SOUND (NOW) E.G. IN A PATCH (defmethod play-sound ((sound internal-sound)) (player-play-object *general-player* sound nil)) ;;;============================================ ;;; DISPLAY ARRAY ;;;============================================ (add-preference-section :appearance "Sound") (add-preference :appearance :waveform-color "Waveform color" :color (om-make-color 0.41 0.54 0.67)) (add-preference :appearance :waveform-bg "Waveform background" :color-a nil) (defmethod get-sample-array-from-sound ((self sound) window-size) (with-audio-buffer (b self) (when b (let* ((n-channels (n-channels self)) (n-samples (n-samples self)) (array-size (ceiling n-samples window-size))) (let ((array (make-array (list n-channels array-size) :element-type 'single-float :initial-element 0.0 :allocation :static))) (fli:with-dynamic-lisp-array-pointer (array-ptr array :type :float) (let* ((maxindx (1- n-samples)) (audio-ptr (om-sound-buffer-ptr b)) (pos-in-buffer 0)) (if (or (fli:null-pointer-p audio-ptr) (fli:null-pointer-p array-ptr)) (om-beep-msg "Error building SOUND display array: NULL POINTER") (dotimes (array-frame array-size) (setq pos-in-buffer (* window-size array-frame)) (dotimes (chan n-channels) (let ((max-value 0.0)) (dotimes (i window-size) (let ((val (fli:dereference (fli:dereference audio-ptr :type :pointer :index chan) :type :float :index (min maxindx (+ pos-in-buffer i))))) (when (> (abs val) (abs max-value)) (setq max-value val)))) (setf (fli:dereference array-ptr :index (+ array-frame (* chan array-size))) max-value))) )))) array))))) (defun resample-sample-array (array nb-samples &key from-sample to-sample) (let ((from (or from-sample 0)) (to (or to-sample (1- (array-dimension array 1))))) (assert (> (array-dimension array 1) to)) (assert (> to from)) (let* ((n-channels (array-dimension array 0)) (slice-size (1+ (- to from))) (result (make-array (list n-channels nb-samples) :element-type 'single-float))) (if (>= nb-samples slice-size) (progn (dotimes (n n-channels) (dotimes (i slice-size) (setf (aref result n i) (aref array n (+ from i)))) (loop for pad from slice-size to (1- nb-samples) do (setf (aref result n pad) 0.0)))) (let ((window-size (/ slice-size nb-samples))) (dotimes (c n-channels) (dotimes (i nb-samples) (let ((window-start (+ from (floor (* i window-size)))) (window-end (+ from (1- (floor (* (1+ i) window-size))))) (max-value 0.0)) (loop for j from window-start to window-end do (let ((val (aref array c j))) (when (> (abs val) (abs max-value)) (setq max-value val)))) (setf (aref result c i) max-value))))) ) result))) ;; resolution = number of samples per array-point (defun draw-waveform (array width height &optional from to (resolution 1)) (let* ((n-channels (cond ((arrayp array) (array-dimension array 0)) ((om-sound-buffer-p array) (om-sound-buffer-nch array)) (t 0))) (n-points (cond ((arrayp array) (array-dimension array 1)) ((om-sound-buffer-p array) (om-sound-buffer-size array)) (t 0))) (from-sample (or from 0)) (to-sample (or to (* resolution (1- n-points)))) (n-samples-to-draw (1+ (- to-sample from-sample))) (channel-h (round height n-channels)) (wave-h (* .49 channel-h)) (offset-y (round channel-h 2)) (access-fun (cond ((arrayp array) #'(lambda (array channel sample) (aref array channel sample))) ((om-sound-buffer-p array) #'(lambda (array channel sample) (fli:dereference (fli:dereference (om-sound-buffer-ptr array) :index channel :type :pointer) :index sample :type :float))) (t (error "wrong array for waveform"))))) (multiple-value-bind (first-index offset-samples) (ceiling from-sample resolution) (let* ((samples-per-pixel (/ n-samples-to-draw width)) (offset-x (/ (- offset-samples) samples-per-pixel)) (array-x-factor (/ width (/ n-samples-to-draw resolution))) (draw-mode (if (and from to (<= samples-per-pixel 128)) :samples :lines))) (om-with-fg-color (get-pref-value :appearance :waveform-color) (dotimes (c n-channels) (let ((ch-y (+ (* c channel-h) offset-y)) (y 0)) (om-draw-line 0 ch-y width ch-y) (when (< first-index n-points) (loop with previous-x = (- offset-x array-x-factor) with previous-y = (* wave-h (funcall access-fun array c (max (1- first-index) 0))) for i = 0 then (+ i 1) for x = (+ offset-x (* i array-x-factor)) for index = (+ first-index i) while (and (< (* index resolution) (+ to-sample resolution)) (< index n-points)) do (setq y (* wave-h (funcall access-fun array c index))) (unless (= previous-y y 0) (case draw-mode (:samples (om-draw-line previous-x (+ ch-y previous-y) x (+ ch-y y) :line 1)) (:lines (om-draw-line x (+ ch-y y) x (- ch-y y) :line 1)) (:polygons (om-draw-polygon (list (om-make-point previous-x (+ ch-y previous-y)) (om-make-point x (+ ch-y y)) (om-make-point x (+ ch-y (- y))) (om-make-point previous-x (- ch-y previous-y))) :fill t)) ) (setq previous-x x) (setq previous-y y))) )))) )))) (defun create-waveform-pict (array height) (let ((width (array-dimension array 1))) (om-record-pict width height (when (get-pref-value :appearance :waveform-bg) (om-draw-rect 0 0 width height :color (get-pref-value :appearance :waveform-bg) :fill t)) (draw-waveform array width height)))) (defmethod get-pict-from-sound ((self sound) &key (width 512) (height 200)) (when (and (n-samples self) (> (n-samples self) 0) (n-channels self) (or (buffer self) (file-pathname self))) (let* ((window 128) (array (get-sample-array-from-sound self window))) (if array (create-waveform-pict (resample-sample-array array (min width (array-dimension array 1))) height) :error)))) (defmethod get-cache-display-for-draw ((self sound) (box ombox)) (get-pict-from-sound self :width 512 :height 512)) ;;;=========================== ;;; BOX ;;;=========================== ;;; Drop a sound file in patch (pushr '(:sound ("aif" "aiff" "wav" "wave") "Audio files") *doctypes*) (defmethod omNG-make-new-box-from-file ((type (eql :sound)) file pos) (let* ((sound (objfromobjs file (make-instance 'sound))) (box (make-new-box-with-instance (om-init-instance sound) pos))) (set-lock-state box :locked) box)) (defmethod display-modes-for-object ((self sound)) '(:mini-view :text :hidden)) (defmethod get-cache-display-for-text ((object sound) box) (declare (ignore box)) (append (call-next-method) (list (list :buffer (buffer object))))) (defmethod draw-mini-view ((self sound) (box t) x y w h &optional time) (let ((pict (ensure-cache-display-draw box self))) (cond ((equal pict :error) (om-with-fg-color (om-make-color .8 .4 .4) (om-with-font (om-def-font :normal-b) (om-draw-string (+ x 6) (+ y 12) "File not loaded:" :wrap (- w 20))) (when (file-pathname self) (om-with-font (om-def-font :small) (om-draw-string (+ x 6) (+ y 24) (namestring (file-pathname self)) :wrap (- w 20)))) )) (pict (om-draw-picture pict :x x :y (+ y 4) :w w :h (- h 8))) (t (om-draw-string (+ x 6) (+ y 12) "NO SOUND" :color (om-def-color :white) :font (om-def-font :normal-b)))) (let ((marker-times (markers-time self))) (when marker-times (let* ((dur (if (plusp (get-obj-dur self)) (get-obj-dur self) (+ (last-elem marker-times) (- (last-elem marker-times) (or (last-elem (butlast marker-times)) 0))))) (fact (/ w dur))) (loop for mrk in marker-times do (om-with-fg-color (om-def-color :gray) (om-draw-line (+ x (* mrk fact)) 8 (+ x (* mrk fact)) h :style '(2 2) )) )))) ))
40,923
Common Lisp
.lisp
830
39.278313
148
0.570232
cac-t-u-s/om-sharp
167
14
31
GPL-3.0
9/19/2024, 11:25:22 AM (Europe/Amsterdam)
60c6278b23caf33e965532c789745975008b5a45e61aa3fd88b7e130fde6f1ae
851
[ -1 ]