diff --git a/src/image.zig b/src/image.zig index 0189882..16e682f 100644 --- a/src/image.zig +++ b/src/image.zig @@ -285,7 +285,7 @@ pub const Image = struct { idx, param.value, ); - ports[idx].value = param.value; + (&ports[idx]).value = param.value; } // now we need to generate a temporary file and put the output of diff --git a/src/lv2_helpers.zig b/src/lv2_helpers.zig index 50f99a1..d9a89f5 100644 --- a/src/lv2_helpers.zig +++ b/src/lv2_helpers.zig @@ -59,14 +59,14 @@ pub const Port = struct { /// Setup ports for a given plugin. Gives an array to pointers of Port structs. /// This setup is required so we link the plugin to the ports later on, and /// also link our buffers, and control values. -pub fn setupPorts(ctx: *plugin.Context) ![]*Port { +pub fn setupPorts(ctx: *plugin.Context) ![]Port { var world = ctx.world; const n_ports: u32 = c.lilv_plugin_get_num_ports(ctx.plugin); - var ports = try ctx.allocator.alloc(*Port, n_ports); + var ports = try ctx.allocator.alloc(Port, n_ports); - for (ports) |port_ptr, idx| { - var port = try ctx.allocator.create(Port); + for (ports) |_, idx| { + var port: *Port = &ports[idx]; port.* = Port{ .lilv_port = null, .ptype = .Control, @@ -75,8 +75,6 @@ pub fn setupPorts(ctx: *plugin.Context) ![]*Port { .is_input = false, .optional = false, }; - - ports[idx] = port; } var values: []f32 = try ctx.allocator.alloc(f32, n_ports); @@ -100,7 +98,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]*Port { var i: u32 = 0; while (i < n_ports) : (i += 1) { - var port: *Port = ports[i]; + var port: *Port = &ports[i]; const lport = c.lilv_plugin_get_port_by_index(ctx.plugin, i).?; diff --git a/src/plugin.zig b/src/plugin.zig index 1de854f..daf8023 100644 --- a/src/plugin.zig +++ b/src/plugin.zig @@ -112,15 +112,16 @@ pub const RunContext = struct { self.buffers.deinit(); } - pub fn connectPorts(self: *RunContext, ports: []*lv2.Port) void { + pub fn connectPorts(self: *RunContext, ports: []lv2.Port) void { var i: usize = 0; var o: usize = 0; var in_buf = self.buffers.in; var out_buf = self.buffers.out; - for (ports) |port, p_idx| { + for (ports) |_, p_idx| { var p = @intCast(u32, p_idx); + var port: *lv2.Port = &ports[p_idx]; switch (port.ptype) { .Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value),