Work-in-progress repo for ambisonics extensions for OM-SoX
Marlon Schumacher
4 days ago 6ae8ed47dd6caf4ff4df39f1195b87d02e2537f0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
;*********************************************************************
; 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*
                                                             )))
    
    ))