forked from momor666/up-debian_ubuntu_update_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderbinUHJ.sc
82 lines (74 loc) · 2.73 KB
/
renderbinUHJ.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
// using the Ctk quark.
(
var cond, score, sndbuf, kernelInfo, sd, decoderUHJ, decoder, filename, scaledRate;
score = CtkScore.new;
s.options.sampleRate_(48000);
s.boot;
// we still need to boot the Server for now to allocate ids for the kernels /* FIX THIS */
s.waitForBoot({
// filename = "/home/iain/b-format_demos/Spitfire_Pass_wav-WXYZ.wav";
filename = thisProcess.argv[0];
filename.postln;
sndbuf = CtkBuffer.playbuf(filename);
score.add(sndbuf);
// encoder = FoaEncoderKernel.newUHJ;
decoder = FoaDecoderKernel.newCIPIC(21, s, s.sampleRate.asInteger);
decoderUHJ = FoaDecoderKernel.newUHJ;
s.sync(cond);
// the FoaEncoderKernel and FoaDecoderKernel classes will return info that can be
// used to make CtkBuffers for the CtkScore. An array of [path, bufnum, channel] is
// returned that will line up with the kernel info that the FoaEncode and FoaDecode
// classes expect
// kernelInfo = encoder.kernelInfo ++ decoder.kernelInfo;
kernelInfo = decoder.kernelInfo;
kernelInfo.do({arg thisInfo;
var path, bufnum, channel, buf;
#path, bufnum, channel = thisInfo;
buf = CtkBuffer(path, bufnum: bufnum, channels: channel);
score.add(buf);
});
sd = CtkSynthDef(\kernelEncodeDecode, {arg buffer;
var out, src, encode;
scaledRate = BufRateScale.kr(buffer);
src = PlayBuf.ar(4, buffer, scaledRate);
//encode = FoaEncode.ar(src, encoder);
// out = FoaDecode.ar(encode, decoder);
out = FoaDecode.ar(src, decoder);
Out.ar(0, out);
});
score.add(sd.note(1.0, sndbuf.duration).buffer_(sndbuf));
score.write("binaural/".standardizePath ++ "binaural_" ++ filename.basename,
sampleRate: 48000,
headerFormat: "WAVE",
sampleFormat: "float",
options: ServerOptions.new.numOutputBusChannels_(2)
);
kernelInfo = decoderUHJ.kernelInfo;
kernelInfo.do({arg thisInfo;
var path, bufnum, channel, buf;
#path, bufnum, channel = thisInfo;
buf = CtkBuffer(path, bufnum: bufnum, channels: channel);
score.add(buf);
});
sd = CtkSynthDef(\kernelDecodeUHJ, {arg buffer;
var out, src, encode;
src = PlayBuf.ar(4, buffer, scaledRate);
//encode = FoaEncode.ar(src, encoder);
// out = FoaDecode.ar(encode, decoder);
out = FoaDecode.ar(src, decoderUHJ);
Out.ar(0, out);
});
score.add(sd.note(1.0, sndbuf.duration).buffer_(sndbuf));
score.write("stereo/".standardizePath ++ "stereo_" ++ filename.basename,
sampleRate: 48000,
headerFormat: "WAVE",
sampleFormat: "float",
options: ServerOptions.new.numOutputBusChannels_(2)
);
// encoder.free;
decoder.free;
decoderUHJ.free;
thisProcess.argv.postln;
0.exit;
})
)