40 lines
1.2 KiB
Zig
40 lines
1.2 KiB
Zig
|
const c = @cImport({
|
||
|
@cInclude("lilv/lilv.h");
|
||
|
@cInclude("lv2/core/lv2.h");
|
||
|
});
|
||
|
|
||
|
const LV2_CORE_URI = "http://lv2plug.in/ns/lv2core";
|
||
|
|
||
|
pub fn Lv2Core(ns: []const u8) ![]const u8 {
|
||
|
var allocator = std.heap.direct_allocator;
|
||
|
|
||
|
return try std.cstr.addNullByte(
|
||
|
allocator,
|
||
|
try std.fmt.allocPrint(allocator, "{}{}", LV2_CORE_URI, ns),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
pub fn lilv_instance_connect_port(
|
||
|
instance: [*c]c.LilvInstance,
|
||
|
port_index: u32,
|
||
|
data_location: ?*c_void,
|
||
|
) void {
|
||
|
instance.?.*.lv2_descriptor.?.*.connect_port.?(instance.?.*.lv2_handle, port_index, data_location);
|
||
|
}
|
||
|
|
||
|
pub fn lilv_instance_activate(instance: [*c]c.LilvInstance) void {
|
||
|
if (instance.?.*.lv2_descriptor.?.*.activate != null) {
|
||
|
instance.?.*.lv2_descriptor.?.*.activate.?(instance.?.*.lv2_handle);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn lilv_instance_run(instance: [*c]c.LilvInstance, sample_count: u32) void {
|
||
|
instance.?.*.lv2_descriptor.?.*.run.?(instance.?.*.lv2_handle, sample_count);
|
||
|
}
|
||
|
|
||
|
pub fn lilv_instance_deactivate(instance: [*c]c.LilvInstance) void {
|
||
|
if (instance.?.*.lv2_descriptor.?.*.deactivate != null) {
|
||
|
instance.?.*.lv2_descriptor.?.*.deactivate.?(instance.?.*.lv2_handle);
|
||
|
}
|
||
|
}
|