-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.zig
More file actions
58 lines (49 loc) · 1.83 KB
/
Copy pathclient.zig
File metadata and controls
58 lines (49 loc) · 1.83 KB
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
const std = @import("std");
const zosc = @import("zosc");
const l = std.log.scoped(.@"zosc-example-client");
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
try zosc.init();
defer zosc.deinit();
var client = zosc.Client{ .port = 8001, .allocator = allocator };
try client.connect(false, "127.0.0.1");
const msg_count: usize = 200;
var i: usize = 0;
var curr: i16 = -250;
// var rot_curr: i16 = -740;
var zoom_curr: i16 = -740;
while (i < msg_count) {
// const rot_msg = zosc.Message{ .address = "/io/0/knob/0/enc", .arguments = &[_]zosc.Argument{.{ .i = rot_curr }} };
// try client.sendMessage(rot_msg);
// rot_curr += 5;
// std.Thread.sleep(std.time.ns_per_ms * 30);
// const zoom_msg = zosc.Message{ .address = "/io/0/knob/1/enc", .arguments = &[_]zosc.Argument{.{ .i = zoom_curr }} };
// try client.sendMessage(zoom_msg);
// std.Thread.sleep(std.time.ns_per_ms * 30);
// const msg = zosc.Message{ .address = "/io/0/knob/2/enc", .arguments = &[_]zosc.Argument{.{ .i = curr }} };
// try client.sendMessage(msg);
// l.info("\n{any}", .{msg});
if (i < msg_count / 2) {
zoom_curr -= 3;
curr += 1;
} else {
zoom_curr += 3;
curr -= 1;
}
const str_msg = zosc.Message{
.address = "/two/strings",
.arguments = &.{
.{ .i = 42 },
.{ .s = "Hallo" },
.{ .f = 3.14 },
.{ .s = "Hallo Welt!" },
},
};
l.info("\n{f}", .{str_msg});
try client.sendMessage(str_msg);
i += 1;
std.Thread.sleep(std.time.ns_per_ms * 30);
}
}