«OSC recorder» by LFSaw

on 04 Feb'13 15:36 in osctoolrecorder

basic OSC recorder, writes messages to zipped files.

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
(
var beginTime;

e  = e ? ();
e.oscMsgs = [];
thisProcess.addOSCRecvFunc({|time, netAddr, msg| 
	var relTime , cmd, sep;
	
	beginTime = beginTime ? time;
	relTime = time - beginTime;
	#cmd ... msg = msg;
	#sep ... cmd = cmd.asString;

	e.oscMsgs = e.oscMsgs ++ [[relTime, [cmd] ++ msg]];
// debug
//	[time -beginTime, netAddr, msg.collect{|it| format("% (: %)", it, it.class)}].postln
})

)

// send messages...

// show message array
e.oscMsgs.do{|osc| osc.postln}; ""


(
// write object file
f = File("~/tmp/oscRecorderOut.txt".standardizePath,"w");
f.write(e.oscMsgs.asCompileString);
f.close;
//
)


// write csv file
FileWriter.write(e.oscMsgs.collect{|row| row.flatten}, "~/tmp/oscRecorderOut.csv".standardizePath);


// write tab-delimited file file
FileWriter.write(e.oscMsgs.collect{|row| row.flatten}, "~/tmp/oscRecorderOut.tdv".standardizePath, "\t");


// write OSC file
Score.write(e.oscMsgs, "~/tmp/oscRecorderOut.osc".standardizePath)


(
// write zipped txt
a = ZArchive.write("~/tmp/oscRecorderOut.zscar".standardizePath);
a.writeItem(e.oscMsgs);
a.writeClose
)


// test:
n = NetAddr.localAddr;
n.sendMsg("/test2", 100.rand, "dfkljsdflkjsdflksdjflsdkfjlsdkfjsd".scramble);
raw 1249 chars (focus & ctrl+a+c to copy)
reception
comments