Created
January 5, 2024 00:51
-
-
Save catfact/5fe646c229b12341274baee8da07e3d3 to your computer and use it in GitHub Desktop.
simple input capture class for SuperCollider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = NetAddr.localAddr; | |
n.sendMsg('/capture/arm', "/Users/emb/Desktop/test.wav"); | |
n.sendMsg('/capture/start'); | |
n.sendMsg('/capture/stop'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SimpleStereoCapture { | |
classvar <bufSize; | |
classvar <synth; | |
classvar <buf; | |
classvar <oscFunc; | |
*initClass { | |
var s = Server.default; | |
bufSize = 2**12; | |
s.waitForBoot { | |
buf = Buffer.alloc(s, bufSize, 2); | |
SynthDef.new(\SimpleStereoCapture, { | |
var in = \in.kr(0); | |
DiskOut.ar(\buf.kr, SoundIn.ar([in, in+1])); | |
}).send(Server.default); | |
oscFunc = Dictionary.new; | |
oscFunc.add(\arm -> OSCFunc({ arg msg; SimpleStereoCapture.arm(msg[1])}, '/capture/arm')); | |
oscFunc.add(\start -> OSCFunc({ SimpleStereoCapture.start }, '/capture/start')); | |
oscFunc.add(\stop -> OSCFunc({ SimpleStereoCapture.stop }, '/capture/stop')); | |
} | |
} | |
*arm { arg path, headerFormat="wav", sampleFormat="int24"; | |
postln("arming capture to file: " ++ path); | |
buf.write(path, headerFormat, sampleFormat, leaveOpen:true); | |
if (synth.notNil, { synth.free; }); | |
synth = Synth.newPaused(\SimpleStereoCapture, [\buf, buf]); | |
} | |
*start { | |
if (synth.notNil, { | |
synth.run(true); | |
postln("starting capture"); | |
}, { | |
postln("not armed!"); | |
}); | |
} | |
*stop { | |
postln("stopping capture"); | |
if (synth.notNil, { synth.free; synth = nil; }); | |
buf.close; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment