Compare commits
2 commits
4aa9e9d7b9
...
c0269ead20
Author | SHA1 | Date | |
---|---|---|---|
c0269ead20 | |||
99382d0a66 |
2 changed files with 16 additions and 7 deletions
|
@ -5,11 +5,11 @@ const custom = @import("custom.zig");
|
||||||
|
|
||||||
const plugins = @import("plugin.zig");
|
const plugins = @import("plugin.zig");
|
||||||
|
|
||||||
/// Approximate size of the BMP header.
|
/// Approximate size of the BMP header, in bytes.
|
||||||
pub const BMPHeaderSize: usize = 82000;
|
pub const BMPHeaderSize: usize = 82000;
|
||||||
|
|
||||||
/// Buffer size for main copying
|
/// Buffer size for main image copying.
|
||||||
pub const BufferSize: usize = 60000;
|
pub const BufferSize: usize = 300000;
|
||||||
|
|
||||||
pub const ImageError = error{
|
pub const ImageError = error{
|
||||||
OpenFail,
|
OpenFail,
|
||||||
|
@ -176,6 +176,7 @@ pub const Image = struct {
|
||||||
return n_read == 1;
|
return n_read == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Copy bytes from the current file to out_file.
|
||||||
fn copyBytes(
|
fn copyBytes(
|
||||||
self: *Image,
|
self: *Image,
|
||||||
out_file: *c.SNDFILE,
|
out_file: *c.SNDFILE,
|
||||||
|
|
|
@ -95,6 +95,8 @@ pub const RunContext = struct {
|
||||||
plugin: *const c.LilvPlugin,
|
plugin: *const c.LilvPlugin,
|
||||||
) !RunContext {
|
) !RunContext {
|
||||||
var instance = c.lilv_plugin_instantiate(plugin, f64(44100), null);
|
var instance = c.lilv_plugin_instantiate(plugin, f64(44100), null);
|
||||||
|
errdefer c.lilv_instance_free(instance);
|
||||||
|
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
return ImageError.InstantiateFail;
|
return ImageError.InstantiateFail;
|
||||||
}
|
}
|
||||||
|
@ -139,13 +141,17 @@ pub const RunContext = struct {
|
||||||
|
|
||||||
pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Context {
|
pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Context {
|
||||||
const cstr_plugin_uri = try std.cstr.addNullByte(allocator, plugin_uri);
|
const cstr_plugin_uri = try std.cstr.addNullByte(allocator, plugin_uri);
|
||||||
var world = c.lilv_world_new().?;
|
|
||||||
|
var world: *c.LilvWorld = c.lilv_world_new().?;
|
||||||
|
errdefer c.lilv_world_free(world);
|
||||||
|
|
||||||
c.lilv_world_load_all(world);
|
c.lilv_world_load_all(world);
|
||||||
|
|
||||||
var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse blk: {
|
var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse blk: {
|
||||||
std.debug.warn("Invalid plugin URI <{}>\n", plugin_uri);
|
std.debug.warn("Invalid plugin URI <{}>\n", plugin_uri);
|
||||||
return ImageError.InvalidPlugin;
|
return ImageError.InvalidPlugin;
|
||||||
};
|
};
|
||||||
|
defer c.lilv_node_free(uri);
|
||||||
|
|
||||||
const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world);
|
const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world);
|
||||||
|
|
||||||
|
@ -154,7 +160,9 @@ pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Conte
|
||||||
return ImageError.UnknownPlugin;
|
return ImageError.UnknownPlugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
c.lilv_node_free(uri);
|
return Context{
|
||||||
|
.allocator = allocator,
|
||||||
return Context{ .allocator = allocator, .world = world, .plugin = plugin };
|
.world = world,
|
||||||
|
.plugin = plugin,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue