commit | author | age
|
92c40d
|
1 |
;********************************************************************* |
AN |
2 |
; OM-SoX, (c) 2011-2013 Marlon Schumacher (CIRMMT/McGill University) * |
|
3 |
; http://sourceforge.net/projects/omsox/ * |
|
4 |
; * |
|
5 |
; Multichannel Audio Manipulation and Functional Batch Processing. * |
|
6 |
; DSP based on SoX - (c) C.Bagwell and Contributors * |
|
7 |
; http://sox.sourceforge.net/ * |
|
8 |
;********************************************************************* |
|
9 |
; |
|
10 |
;This program is free software; you can redistribute it and/or |
|
11 |
;modify it under the terms of the GNU General Public License |
|
12 |
;as published by the Free Software Foundation; either version 2 |
|
13 |
;of the License, or (at your option) any later version. |
|
14 |
; |
|
15 |
;See file LICENSE for further informations on licensing terms. |
|
16 |
; |
|
17 |
;This program is distributed in the hope that it will be useful, |
|
18 |
;but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
;GNU General Public License for more details. |
|
21 |
; |
|
22 |
;You should have received a copy of the GNU General Public License |
|
23 |
;along with this program; if not, write to the Free Software |
|
24 |
;Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,10 USA. |
|
25 |
; |
|
26 |
;Authors: M. Schumacher |
|
27 |
|
|
28 |
(in-package :om) |
|
29 |
|
|
30 |
; ==== SOX-MIX-CONSOLE ======================== |
|
31 |
|
|
32 |
; there's basically 2 options: |
|
33 |
; 1) Use sox-mix-console but in a way that there can be a list of effects which is applied internally to each of the components (drawback: inconsistent handling of polymorphism) |
|
34 |
; 2) Write a 'macro' (as a patch) that does what sox-mix-console does, but explicitly 'fills' a sox-mix object with pipes from (sox-process '(sox-remixes) '(sox-pads)) |
|
35 |
|
|
36 |
(defclass! sox-mix-console (sox-input) |
|
37 |
( |
|
38 |
(gains :accessor gains :initarg :gains :initform nil :documentation *sox-gain-doc*) |
|
39 |
(panning :accessor panning :initform nil :initarg :panning :documentation *sox-panning-doc*) |
|
40 |
(numchannels :accessor numchannels :initform 2 :initarg :numchannels :documentation "Number of output channels for mixing process.") |
|
41 |
) |
|
42 |
(:icon 12) ;918 |
|
43 |
(:documentation "Sox-Mix-Console allows mixing and panning inputs on an array of output channels. Inputs do not need to have the same number of channels. |
|
44 |
|
|
45 |
Multichannel inputs are first mixed into a single channel before panning/mixing with other soundfiles. |
|
46 |
NB: Input audio must have the same samplerate.") |
|
47 |
) |
|
48 |
|
|
49 |
; pipe input not possible with this class |
|
50 |
; why isn't this using sox-init-panning? not for lists? |
|
51 |
|
|
52 |
(defmethod initialize-instance :after ((self sox-mix-console) &rest args) |
|
53 |
(when (sound self) |
|
54 |
(let* ((sound-length (length (list! (sound self)))) |
|
55 |
(linear-panning (om-scale (arithm-ser 1 sound-length 1) 1 (numchannels self))) |
|
56 |
(panning-list (loop for sound in (list! (sound self)) |
|
57 |
for i from 0 to (- sound-length 1) collect |
|
58 |
(if (soundp sound) |
|
59 |
(if (equal (tracknum sound) 0) |
|
60 |
(nth i linear-panning) |
|
61 |
(+ (tracknum sound) (* 0.01 (pan sound)))) |
|
62 |
) |
|
63 |
)) |
|
64 |
(nunumchannels (+ 1 (floor (list-max panning-list))))) |
|
65 |
(unless (consp (panning self)) |
|
66 |
(setf (panning self) panning-list)) |
|
67 |
(sox-init-gains self) |
|
68 |
(sox-init-sound self 'list) |
|
69 |
(when (< (numchannels self) (list-max (panning self))) |
|
70 |
(setf (numchannels self) nunumchannels) |
|
71 |
) |
|
72 |
) |
|
73 |
) |
|
74 |
) |