Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
4 days ago 6ae8ed47dd6caf4ff4df39f1195b87d02e2537f0
feat: start adding editor window for SoX-HOAENCODE
2 files modified
131 ■■■■ changed files
sources/classes/sox-hoaencode.lisp 39 ●●●●● patch | view | raw | blame | history
sources/sox-editors.lisp 92 ●●●●● patch | view | raw | blame | history
sources/classes/sox-hoaencode.lisp
@@ -102,41 +102,6 @@
        )
    ))
; #### Utility functions ####
#|
(defun sox-hoaencode-auto-convert-positions (positions)
"Ensures that positions are given as '((azimuth elevation) ...) (in degrees), i.e.
1) if list of list of three values, input is assumed to be '(x y z) coordinates and will be transformed to '(azimuth elevation) coordinates (in the navigational spherical coordinate system).
2) if list of list of two values, input is assumed to be '(azimuth elevation) coordinates and won't be transformed any further.
3) if 3dc, input is transformed to '(azimuth elevation) coordinates.
"
    (cond
        ((subtypep (type-of positions) '3dc)
            (progn ; convert xyz->aed, keep azimuth and elevation only.
                (mat-trans
                    (butlast
                        (mat-trans
                            (mapcar
                                (lambda (xyz) (multiple-value-list (om:xyz->aed (first xyz) (second xyz) (third xyz))))
                                (mat-trans (list (x-points positions) (y-points positions) (z-points positions)))
                            ))))))
        ((subtypep (type-of positions) 'list)
            (cond
                ((= 2 (length (first positions)))
                    positions)
                ((= 3 (length (first positions)))
                    (mat-trans
                        (butlast
                            (mat-trans
                                (mapcar
                                    (lambda (xyz) (multiple-value-list (om:xyz->aed (first xyz) (second xyz) (third xyz))))
                                    positions
                                )))))
                (t (error "Positions must consist of lists of length 2 (ae) or 3 (xyz)."))
            ))
        (t (error "Positions must be of type 3dc or list."))))
|#
; ####### High-level API ########## 
@@ -159,7 +124,7 @@
    )
; (sox-hoaencode-gain-single-component 1 1 45 0)
; what is the difference between "order" and "degree"?
; @AN: what is the difference between "order" and "degree"?
(defun sox-hoaencode-gains-by-order (order azimuth_deg elevation_deg)
@@ -178,7 +143,7 @@
(defclass! sox-hoaencode (sox-input)
    (
     (gain :accessor gain :initarg :gain :initform 0 :documentation "gain value in dB (decibel)")
     (gains :accessor gains :initarg :gains :initform nil :documentation *sox-gain-doc*)
     (azimuth :accessor azimuth :initarg :azimuth :initform 0 :documentation "azimuth angle in degrees")
     (elevation :accessor elevation :initarg :elevation :initform 0 :documentation "elevation angle in degrees")
     (order :accessor order :initarg :order :initform 3 :documentation *sox-hoaencode-order-doc*)
sources/sox-editors.lisp
@@ -79,7 +79,7 @@
  (let ((pos 0) pantxt gaintxt)
    (setf pos (+ pos 5))
    (om-add-subviews self (setf pantxt (om-make-dialog-item 'om-static-text
                                                            (om-make-point 15 pos)
                                                            (om-make-point 5 pos)
                                                            (om-make-point soxconsole-trackw 16)
                                                            (string+ (pathname-name (nth (tracknum self) (list! (sound (sox-object self)))))
                                                                     "." (pathname-type (nth (tracknum self) (list! (sound (sox-object self))))))
@@ -87,6 +87,10 @@
                                                            )))
    (setf pos (+ pos 25))    
    (add-pan-controls self (sox-object self) pos)
    ;(add-azi-controls self (sox-object self) pos)
    ;(add-ele-controls self (sox-object self) pos)
    ;(add-order-controls self (sox-object self) pos)
    (om-add-subviews self (om-make-view 'graphic-numbox 
                                        :position (om-make-point 30 pos) 
@@ -116,7 +120,7 @@
;%%%%%%% Editor for SOX-PAN %%%%%%%%%%%%%%%
(defmethod get-win-ed-size ((self sox-pan)) 
  (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (list! (sound self))))))) 200))
  (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (list! (sound self))))))) 200)) ; should not have a case for lists
(defmethod add-pan-controls ((self sox-track-panel) (object sox-pan) posy)
  (let ((pantxt (om-make-dialog-item 'om-static-text
@@ -144,8 +148,92 @@
                                               :max-val (max 10 (* 50 (1- (numchannels object))))))
    ))
;%%%%%%% Editor for SOX-HOAENCODE %%%%%%%%%%%%%%%
(defmethod get-editor-class ((self sox-hoaencode)) 'sox-console-editor)
(defmethod get-win-ed-size ((self sox-hoaencode))
  (om-make-point (+ 2 (+ soxconsole-trackw 2)) 328))
(defmethod add-azi-controls ((self sox-track-panel) (object sox-hoaencode) posy)
  (let ((azitxt (om-make-dialog-item 'om-static-text
                                     (om-make-point 28 (+ posy 156))
                                     (om-make-point 65 16)
                                     (string+ "azi: " (number-to-string (om-round (azimuth object) 3)))
                                     :font *om-default-font1*
                                     )))
    (om-add-subviews self azitxt (om-make-view 'graphic-numbox
                                               :position (om-make-point 40 (+ posy 132))
                                               :size (om-make-point 26 26)
                                               :pict (om-load-and-store-picture "dial" 'di)
                                               :nbpict 65
                                               :pict-size (om-make-point 24 24)
                                               :di-action (om-dialog-item-act item
                                                            (let ((val (float (value item))))
                                                              (om-set-dialog-item-text azitxt (format nil "azi: ~3f" val))
                                                              (setf (azimuth object) val)
                                                              (report-modifications (om-view-container self))))
                                               :font *om-default-font2*
                                               :value (/ (azimuth object) 360)
                                               :min-val 0 :max-val 360)
                     )
    )
  )
(defmethod add-ele-controls ((self sox-track-panel) (object sox-hoaencode) posy)
  (let ((eletxt (om-make-dialog-item 'om-static-text
                                     (om-make-point 28 (+ posy 208))
                                     (om-make-point 65 16)
                                     (string+ "ele: " (number-to-string (om-round (elevation object) 3)))
                                     :font *om-default-font1*
                                     )))
    (om-add-subviews self eletxt (om-make-view 'graphic-numbox
                                               :position (om-make-point 40 (+ posy 184))
                                               :size (om-make-point 26 26)
                                               :pict (om-load-and-store-picture "dial" 'di)
                                               :nbpict 65
                                               :pict-size (om-make-point 24 24)
                                               :di-action (om-dialog-item-act item
                                                            (let ((val (float (value item))))
                                                              (om-set-dialog-item-text eletxt (format nil "ele: ~3f" val))
                                                              (setf (elevation object) val)
                                                              (report-modifications (om-view-container self))))
                                               :font *om-default-font2*
                                               :value (/ (elevation object) 360)
                                               :min-val 0 :max-val 360)
                     )
    )
  )
(defmethod add-order-controls ((self sox-track-panel) (object sox-hoaencode) posy)
    (let ((ordertxt (om-make-dialog-item 'om-static-text
                                     (om-make-point 28 (+ posy 248))
                                     (om-make-point 65 16)
                                     (string+ "order: " (number-to-string (order object)))
                                     :font *om-default-font1*
                                     )))
      (om-add-subviews self (om-make-dialog-item 'edit-numbox
                                                 (om-make-point 36 (+ posy 248))
                                                 (om-make-point 36 18)
                                                 (format nil " ~2D" (order object))
                                                 :di-action (om-dialog-item-act item
                                                            (let ((val (value item)))
                                                            (om-set-dialog-item-text ordertxt (format nil "order: ~1d" val))
                                                              (setf (order object) val)
                                                              (report-modifications (om-view-container self))))
                                                 :value (order object)
                                                 :font *om-default-font1*
                                                 :incr 1
                                                 :min-val 0 :max-val 5
                                                 ))
      )
    )
;%%%%%%% Editor for SOX-MIX-CONSOLE %%%%%%%%%%%%%%%
(defmethod get-win-ed-size ((self sox-mix-console))