forked from Shirakumo/harmony
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmixers.lisp
More file actions
53 lines (41 loc) · 1.67 KB
/
Copy pathmixers.lisp
File metadata and controls
53 lines (41 loc) · 1.67 KB
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
#|
This file is a part of harmony
(c) 2017 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:org.shirakumo.fraf.harmony)
(defclass mixer (segment cl-mixed:mixer)
((buffers :initform NIL :accessor buffers)))
(defgeneric channels-per-source (mixer))
(defmethod initialize-instance :after ((segment mixer) &key)
(let ((buffers (make-array (channels-per-source segment))))
(dotimes (i (length buffers))
(setf (aref buffers i) (cl-mixed:make-buffer (buffersize (context segment)))))
(setf (buffers segment) buffers)))
(defmethod add :before ((segment cl-mixed:segment) (mixer mixer))
(let ((buffers (buffers mixer)))
(dotimes (i (length buffers))
(setf (cl-mixed:output-field :buffer i segment) (aref buffers i)))))
(defmethod add :around ((segment cl-mixed:segment) (mixer mixer))
(with-body-in-mixing-context ((context mixer)
;; Apparently synchronising is unbearably slow.
#-(and sbcl windows) :synchronize #-(and sbcl windows) T)
(call-next-method))
segment)
(defmethod withdraw :around ((segment cl-mixed:segment) (mixer mixer))
(with-body-in-mixing-context ((context mixer) :synchronize T)
(call-next-method))
segment)
(defmethod sources ((mixer mixer))
(loop for v being the hash-values of (cl-mixed:sources mixer)
collect v))
(defclass basic-mixer (cl-mixed:basic-mixer mixer)
()
(:default-initargs
:channels 2))
(defmethod channels-per-source ((segment basic-mixer))
(channels segment))
(defclass space-mixer (cl-mixed:space-mixer mixer)
())
(defmethod channels-per-source ((segment space-mixer))
1)