-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soundcards.sc
71 lines (57 loc) · 1.82 KB
/
Soundcards.sc
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
SoundCard {
classvar <>defaultCard;
var <name;
var <bufSize;
var <memSize;
var <numOutCh;
var <numInCh;
var <server;
*saffire {
arg bufSize = 256, memSize = (2**10) * 100 /* 100Mb*/, inCh = 4, outCh = 6;
^super.new.init("Saffire", bufSize, memSize, inCh, outCh, "127.0.0.1", 58009);
}
*mbox {
arg bufSize = 256, memSize = (2**10) * 100 /* 100Mb*/, inCh = 6, outCh = 6;
^super.new.init("Mbox Pro", bufSize, memSize, inCh, outCh, "127.0.0.1", 58010);
}
*builtin {
arg bufSize = 512, memSize = (2**10) * 100 /* 100Mb*/, inCh = 2, outCh = 2;
^super.new.init("BuiltIn", bufSize, memSize, inCh, outCh, "127.0.0.1", 58011);
}
*default {
if(SoundCard.defaultCard.isNil) { SoundCard.defaultCard = \builtin };
switch(SoundCard.defaultCard,
\builtin, {^SoundCard.builtin},
\mbox, {^SoundCard.mbox},
\saffire, {^SoundCard.saffire},
{^nil}
)
}
init {
arg sName, bufsize, memsize, inCh, outCh, host, port;
var options;
name = sName;
bufSize = bufsize;
memSize = memsize;
numInCh = inCh;
numOutCh = outCh;
options = ServerOptions.new.device_(name)
.memSize_(memSize).hardwareBufferSize_(bufSize)
.numInputBusChannels_(numInCh)
.numOutputBusChannels_(numOutCh);
server = Server.new(name, NetAddr(host, port), options);
server.makeWindow;
server.window.alwaysOnTop = true;
Server.default_(server);
^this;
}
printOn {
arg stream;
var str = format("SoundCard % (in: %, out: %, buf=%, mem=%)",
name.quote, numInCh, numOutCh, bufSize, memSize);
stream << str;
}
options {
^server.options;
}
}