-
Notifications
You must be signed in to change notification settings - Fork 9
/
XiiLangRecord.sc
115 lines (91 loc) · 2.96 KB
/
XiiLangRecord.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
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
// ixi adaptation of Newton Armstrong's Record class
XiiLangRecord {
var <server, <inbus, <numChannels, <headerFormat, <sampleFormat;
var <isRecording=false, <bufnum, synth;
*new { arg server, inbus=0, numChannels=2, headerFormat='aiff', sampleFormat='int16'; ^super.new.initXiiLangRecord(server, inbus, numChannels, headerFormat, sampleFormat)
}
*initClass {
for(1, 8, { arg i;
//
//SynthDef.writeOnce("xii-diskout-" ++ i.asString, { arg in, bufNum=0, amp=1;
// DiskOut.ar(bufNum, amp * InFeedback.ar(in, i));
//});
Class.initClassTree(SynthDef);
Class.initClassTree(SynthDescLib);
// Adding Limiter as sometimes I was getting bad noises on overload
SynthDef.writeOnce("xii-diskout-" ++ i.asString, { arg in, bufNum=0, amp=1;
DiskOut.ar(bufNum, Limiter.ar(amp * InFeedback.ar(in, i), 0.99, 0.01) );
});
});
}
initXiiLangRecord { arg argServer, argInbus, argChans, argHeaderFormat, argSampleFormat;
server = argServer ? Server.default;
inbus = argInbus;
numChannels = argChans;
headerFormat = argHeaderFormat.asString.collect({ arg char; char.toLower });
sampleFormat = argSampleFormat;
CmdPeriod.add(this);
}
start { arg path, argBufnum;
var ext;
//if( isRecording, { ^nil });
ext = headerFormat;
if( ext == "none", { ext = "" }, {
if( ext == "sun", { ext = "au" });
if( ext == "ircam", { ext = "sf" });
ext = "." ++ ext;
});
// This is because there is no Date.localtime.stamp on windows!
if(thisProcess.platform.name==\windows, { // windows
path = path ? ("sound" ++ Main.elapsedTime.round ++ ext);
}, {
path = path ? (Date.localtime.stamp ++ ext);
});
bufnum = argBufnum ? server.bufferAllocator.alloc(numChannels);
//[\bufnum, bufnum].postln;
server.sendMsg("/b_alloc", bufnum, 32768, numChannels,
["/b_write", bufnum, path, headerFormat, sampleFormat, 0, 0, 1]
);
// synth = Synth.new("xii-diskout-" ++ numChannels,
// [\i_in, inbus, \i_bufNum, bufnum],
// target: server,
// addAction: \addToTail // added by thor
// );
// thor: changing to the use of RootNode
synth = Synth.tail(RootNode(server), "xii-diskout-" ++ numChannels, [\in, inbus, \bufNum, bufnum]);
isRecording = true;
"RECORDING...".postln;
//this.changed;
//inform("RECORDING...");
}
stop {
if( isRecording.not, { ^nil });
try{ synth.free };
server.sendMsg("/b_close", bufnum, ["/b_free", bufnum]);
isRecording = false;
//this.changed;
inform("RECORDING STOPPED.");
}
cmdPeriod {
this.stop;
}
inbus_ { arg argInbus;
inbus = argInbus;
this.changed(thisMethod.name);
}
setAmp_ {arg amp;
synth.set(\amp, amp);
}
numChannels_ { arg argNumChannels;
numChannels = argNumChannels;
this.changed(thisMethod.name);
}
headerFormat_ { arg argHeaderFormat;
headerFormat = argHeaderFormat.asString.collect({ arg char; char.toLower });
this.changed(thisMethod.name);
}
sampleFormat_ { arg argSampleFormat;
sampleFormat = argSampleFormat;
this.changed(thisMethod.name);
}
}