;********************************************************************* ; OM-SoX, (c) 2011-2013 Marlon Schumacher (CIRMMT/McGill University) * ; http://sourceforge.net/projects/omsox/ * ; * ; Multichannel Audio Manipulation and Functional Batch Processing. * ; DSP based on SoX - (c) C.Bagwell and Contributors * ; http://sox.sourceforge.net/ * ;********************************************************************* ; ;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,10 USA. ; ;Authors: M. Schumacher (in-package :om) ; This file contains editors for the sox-input-classes (defparameter soxconsole-trackw 100) ;%%%%%%% Editor for SOX-INPUT %%%%%%%%%%%%%%%%%%%%% (defmethod class-has-editor-p ((self sox-input)) t) (defclass sox-console-editor (editorview) ((track-panels :initform nil :accessor track-panels :type list))) (defclass sox-track-panel (om-view) ((sox-object :accessor sox-object :initarg :sox-object :initform nil) (tracknum :accessor tracknum :initarg :tracknum :initform 0))) (defmethod get-editor-class ((self sox-input)) 'sox-console-editor) (defmethod get-win-ed-size ((self sox-input)) (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (list! (sound self))))))) 150)) (defmethod initialize-instance :after ((self sox-console-editor) &rest l) (declare (ignore l)) (om-set-bg-color self *om-dark-gray-color*) (initialize-panels self)) ; typo or correct? (defmethod initialize-panels ((self sox-console-editor)) (om-with-delayed-redraw self (setf (track-panels self) (loop for i from 0 to (1- (length (list! (sound (object self))))) collect (om-make-view 'sox-track-panel :tracknum i :sox-object (object self) :bg-color *om-light-gray-color* :position (om-make-point (+ 2 (* i (+ soxconsole-trackw 2))) 2) :size (om-make-point soxconsole-trackw (- (h self) 4))))) (apply 'om-add-subviews (cons self (track-panels self))) (let ((size (get-win-ed-size (object self)))) (oa::set-not-resizable (window self) (om-point-h size) (om-point-v size))) )) (defmethod update-editor-after-eval ((self sox-console-editor) val) (setf (object self) val) (initialize-panels self)) (defmethod add-pan-controls ((self sox-track-panel) (object t) posy) nil) (defmethod initialize-instance :after ((self sox-track-panel) &rest l) (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 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)))))) :font *om-default-font1b* ))) (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) :size (om-make-point 45 100) :pict (om-load-and-store-picture "fader" 'di) :nbpict 77 :pict-size (om-make-point 31 94) :di-action (om-dialog-item-act item (om-set-dialog-item-text gaintxt (format nil " dB: ~4f" (* (- (value item) 120) 0.5))) (setf (nth (tracknum self) (gains (sox-object self))) (* (- (value item) 120) 0.5)) (report-modifications (om-view-container self))) :font *om-default-font2* :value (+ (* (nth (tracknum self) (gains (sox-object self))) 2) 120) :min-val 0 :max-val 132 )) (om-add-subviews self (setf gaintxt (om-make-dialog-item 'om-static-text (om-make-point 20 (+ pos 99)) (om-make-point 60 16) (format nil " dB: ~4f" (nth (tracknum self) (gains (sox-object self)))) :font *om-default-font1* ))) )) ;%%%%%%% 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)) ; 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 (om-make-point 28 (+ posy 148)) (om-make-point 65 16) (string+ "pan: " (number-to-string (om-round (panning object) 3))) :font *om-default-font1* ))) (om-add-subviews self pantxt (om-make-view 'graphic-numbox :position (om-make-point 40 (+ posy 124)) :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 ; perhaps this could be made more efficient by manipulating min-val and max-val rather then as a let statement (let ((val (+ 1 (* (value item) 0.02)))) (om-set-dialog-item-text pantxt (format nil "pan: ~3f" val)) ;(om-set-dialog-item-text pantxt (string+ "pan: " (number-to-string (om-round val 2)))) (setf (panning object) val) (report-modifications (om-view-container self)))) :font *om-default-font2* :value (* 50 (1- (panning object))) :min-val 0 :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)) (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (list! (sound self))))))) 200)) (defmethod add-pan-controls ((self sox-track-panel) (object sox-mix-console) posy) (let ((pantxt (om-make-dialog-item 'om-static-text (om-make-point 28 (+ posy 148)) (om-make-point 65 16) (string+ "pan: " (number-to-string (om-round (nth (tracknum self) (panning object)) 2))) :font *om-default-font1* ))) (om-add-subviews self pantxt (om-make-view 'graphic-numbox :position (om-make-point 40 (+ posy 124)) :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 ; perhaps this could be made more efficient by manipulating min-val and max-val rather then as a let statement (let ((val (+ 1 (* (value item) 0.02)))) (om-set-dialog-item-text pantxt (format nil "pan: ~3f" val)) ;(om-set-dialog-item-text pantxt (string+ "pan: " (number-to-string (om-round val 2)))) (setf (nth (tracknum self) (panning object)) val) (report-modifications (om-view-container self)))) :font *om-default-font2* :value (* 50 (1- (nth (tracknum self) (panning object)))) :min-val 0 :max-val (max 10 (* 50 (1- (numchannels object)))))) )) ;%%%%%%% Editor for SOX-REMIX %%%%%%%%%%%%%%%%%%%%% (defclass sox-remix-editor (editorview) ((channel-panels :initform nil :accessor channel-panels :type list))) (defclass sox-channel-panel (om-view) ((sox-object :accessor sox-object :initarg :sox-object :initform nil) (panel-id :accessor panel-id :initarg :panel-id :initform nil) (channel :accessor channel :initarg :channel :initform nil) (gain :accessor gain :initarg :gain :initform nil))) (defmethod get-editor-class ((self sox-remix)) 'sox-remix-editor) (defmethod get-win-ed-size ((self sox-remix)) (om-make-point (+ 2 (* 102 (max 1 (min 32 (length (channel-matrix self)))))) (+ 0 (* (+ soxconsole-trackw 2) (max 1 (min 32 (or (list-max (loop for item in (channel-matrix self) collect (length item))) 0) )) )))) (defmethod initialize-instance :after ((self sox-remix-editor) &rest l) (declare (ignore l)) (om-set-bg-color self *om-dark-gray-color*) (initialize-panels self)) (defmethod initialize-panels ((self sox-remix-editor)) ;(if (sound (object self)) (om-with-delayed-redraw self (when (sound (object self)) (setf (channel-panels self) (loop for subchannellist in (channel-matrix (object self)) for subgainlist in (gain-matrix (object self)) for i from 0 to (length (channel-matrix (object self))) collect ; i = y position (loop for channel in subchannellist for gain in subgainlist for j from 0 to (length subchannellist) collect ; j = x position (om-make-view 'sox-channel-panel :channel channel ; maybe 'panel-nr' would be less ambiguous here :gain gain :panel-id (list i j) ; i = rows, j = columns :sox-object (object self) :bg-color *om-light-gray-color* :position (om-make-point (+ 2 (* i (+ soxconsole-trackw 2))) (* j (+ soxconsole-trackw 2))) ;(om-make-point (+ 2 (* j (+ soxconsole-trackw 2))) (* i (+ soxconsole-trackw 2))) :size (om-make-point soxconsole-trackw 101 )) ;4 (- (h self) 205) ) ) ) ) (loop for panel in (channel-panels self) do (apply 'om-add-subviews (cons self panel))) (let ((size (get-win-ed-size (object self)))) (oa::set-not-resizable (window self) (om-point-h size) (om-point-v size))) ) ;(om-beep-msg "Please specify a sound to be processed")) ) (defmethod update-editor-after-eval ((self sox-remix-editor) val) (setf (object self) val) (initialize-panels self)) (defmethod initialize-instance :after ((self sox-channel-panel) &rest l) (let ((pos 0) label gaintxt) #| (setf pos (+ pos 5)) (om-add-subviews self (setf label (om-make-dialog-item 'om-static-text (om-make-point 15 pos) (om-make-point soxconsole-trackw 16) ;16 (string+ (pathname-name (sound (sox-object self))) "." (pathname-type (sound (sox-object self))) ) :font *om-default-font1b* ))) |# (setf pos (+ pos 5)) (om-add-subviews self (setf label (om-make-dialog-item 'om-static-text (om-make-point 20 pos) (om-make-point soxconsole-trackw 16) ;16 (string+ "Channel-" (number-to-string (channel self))) :font *om-default-font1b* ))) (setf pos (+ pos 30)) (om-add-subviews self (om-make-view 'graphic-numbox :position (om-make-point 35 pos) :size (om-make-point 35 35) :pict (om-load-and-store-picture "dial" 'di) :nbpict 65 :pict-size (om-make-point 24 24) :di-action (om-dialog-item-act item (om-set-dialog-item-text gaintxt ;(format nil " dB: ~4f" (* (- (value item) 240) 0.25))) (string+ " dB: " (number-to-string (om-round (* (value item) 0.5) 2)))) (setf (nth (second (panel-id self)) (nth (first (panel-id self)) (gain-matrix (sox-object self)))) (* (value item) 0.5)) (report-modifications (om-view-container self))) :font *om-default-font2* :value (* (gain self) 2) :min-val -72 :max-val 72 )) (om-add-subviews self (setf gaintxt (om-make-dialog-item 'om-static-text (om-make-point 20 80) ;(+ pos 99) (om-make-point 70 16) (format nil " dB: ~4f" (gain self)) :font *om-default-font1* ))) )) ;%%%%%%% Editor for SOX-SPLIT %%%%%%%%%%%%%%%%%%%%%% (defclass sox-split-console-editor (editorview) ((track-panels :initform nil :accessor track-panels :type list))) (defclass sox-split-panel (om-view) ((sox-object :accessor sox-object :initarg :sox-object :initform nil) (panel-id :accessor panel-id :initarg :panel-id :initform nil) (channel :accessor channel :initarg :channel :initform nil) (gain :accessor gain :initarg :gain :initform nil))) (defmethod get-editor-class ((self sox-split)) 'sox-split-console-editor) (defmethod get-win-ed-size ((self sox-split)) (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (channels self)))))) 150)) (defmethod initialize-instance :after ((self sox-split-console-editor) &rest l) (declare (ignore l)) (om-set-bg-color self *om-dark-gray-color*) (when (sound (object self)) (initialize-panels self))) (defmethod initialize-panels ((self sox-split-console-editor)) (om-with-delayed-redraw self (setf (track-panels self) (loop for channel in (channels (object self)) for gain in (gains (object self)) for i from 0 to (- (length (channels (object self))) 1) collect (om-make-view 'sox-split-panel :channel channel ; maybe 'panel-nr' would be less ambiguous here :gain gain :panel-id i ; i = rows, j = columns :sox-object (object self) :bg-color *om-light-gray-color* :position (om-make-point (+ 2 (* i (+ soxconsole-trackw 2))) 2) ;(om-make-point (+ 2 (* j (+ soxconsole-trackw 2))) (* i (+ soxconsole-trackw 2))) :size (om-make-point soxconsole-trackw (- (h self) 4) )) ;4 (- (h self) 205) )) (apply 'om-add-subviews (cons self (track-panels self))) (let ((size (get-win-ed-size (object self)))) (oa::set-not-resizable (window self) (om-point-h size) (om-point-v size))) )) (defmethod initialize-instance :after ((self sox-split-panel) &rest l) (let ((pos 0) pantxt gaintxt) (setf pos (+ pos 5)) (om-add-subviews self (setf label (om-make-dialog-item 'om-static-text (om-make-point 20 pos) (om-make-point soxconsole-trackw 16) ;16 (string+ "Channel-" (number-to-string (channel self))) :font *om-default-font1b* ))) (setf pos (+ pos 25)) (om-add-subviews self (om-make-view 'graphic-numbox :position (om-make-point 30 pos) :size (om-make-point 45 100) :pict (om-load-and-store-picture "fader" 'di) :nbpict 77 :pict-size (om-make-point 31 94) :di-action (om-dialog-item-act item (om-set-dialog-item-text gaintxt (format nil " dB: ~4f" (* (- (value item) 120) 0.5))) (setf (nth (panel-id self) (gains (sox-object self))) (* (- (value item) 120) 0.5)) (report-modifications (om-view-container self))) :font *om-default-font2* :value (+ (* (nth (panel-id self) (gains (sox-object self))) 2) 120) :min-val 0 :max-val 132 )) (om-add-subviews self (setf gaintxt (om-make-dialog-item 'om-static-text (om-make-point 20 (+ pos 99)) (om-make-point 60 16) (format nil " dB: ~4f" (nth (panel-id self) (gains (sox-object self)))) :font *om-default-font1* ))) )) ;########################### ;; the editor for SOX-RECORD (defmethod class-has-editor-p ((self sox-record)) t); not a subclass of sox-input (defclass sox-record-console-editor (editorview) ((track-panels :initform nil :accessor track-panels :type list))) (defclass sox-record-channel-panel (om-view) ((sox-object :accessor sox-object :initarg :sox-object :initform nil) (panel-id :accessor panel-id :initarg :panel-id :initform nil) (channel :accessor channel :initarg :channel :initform nil) (gain :accessor gain :initarg :gain :initform nil))) (defmethod get-editor-class ((self sox-record)) 'sox-record-console-editor) (defmethod get-win-ed-size ((self sox-record)) (om-make-point (+ 2 (* (+ soxconsole-trackw 2) (max 1 (min 32 (length (list! (gains self))))))) 100)) (defmethod initialize-instance :after ((self sox-record-console-editor) &rest l) (declare (ignore l)) (om-set-bg-color self *om-dark-gray-color*) (initialize-panels self)) (defmethod initialize-panels ((self sox-record-console-editor)) (om-with-delayed-redraw self (setf (track-panels self) (loop for channel in (channels (object self)) for gain in (gains (object self)) for i from 0 to (- (length (channels (object self))) 1) collect (om-make-view 'sox-record-channel-panel :channel channel ; maybe 'panel-nr' would be less ambiguous here :gain gain :panel-id i ; i = rows, j = columns :sox-object (object self) :bg-color *om-light-gray-color* :position (om-make-point (+ 2 (* i (+ soxconsole-trackw 2))) 2) ;(om-make-point (+ 2 (* j (+ soxconsole-trackw 2))) (* i (+ soxconsole-trackw 2))) :size (om-make-point soxconsole-trackw (- (h self) 4) )) ;4 (- (h self) 205) )) (apply 'om-add-subviews (cons self (track-panels self))) (let ((size (get-win-ed-size (object self)))) (oa::set-not-resizable (window self) (om-point-h size) (om-point-v size))) )) (defmethod initialize-instance :after ((self sox-record-channel-panel) &rest l) (let ((pos 0) label gaintxt) (setf pos (+ pos 5)) (om-add-subviews self (setf label (om-make-dialog-item 'om-static-text (om-make-point 20 pos) (om-make-point soxconsole-trackw 16) ;16 (string+ "Channel-" (number-to-string (channel self))) :font *om-default-font1b* ))) (setf pos (+ pos 30)) (om-add-subviews self (om-make-view 'graphic-numbox :position (om-make-point 35 pos) :size (om-make-point 35 35) :pict (om-load-and-store-picture "dial" 'di) :nbpict 65 :pict-size (om-make-point 24 24) :di-action (om-dialog-item-act item (om-set-dialog-item-text gaintxt ;(format nil " dB: ~4f" (* (- (value item) 240) 0.25))) (string+ " dB: " (number-to-string (om-round (* (value item) 0.5) 2)))) (setf (nth (panel-id self) (gains (sox-object self))) (* (value item) 0.5)) (report-modifications (om-view-container self))) :font *om-default-font2* :value (* (gain self) 2) :min-val -72 :max-val 72 )) (om-add-subviews self (setf gaintxt (om-make-dialog-item 'om-static-text (om-make-point 20 80) ;(+ pos 99) (om-make-point 70 16) (format nil " dB: ~4f" (gain self)) :font *om-default-font1* ))) ))