add basic rng init on RandomNoise plugin

This commit is contained in:
Luna 2019-07-13 17:49:09 -03:00
parent 16116371f5
commit 3edca782ac
2 changed files with 10 additions and 3 deletions

3
examples/noise.scri Normal file
View File

@ -0,0 +1,3 @@
load :0;
noise 3 1;
quicksave;

View File

@ -5,20 +5,24 @@ const plugins = @import("plugin.zig");
const c = lv2.c;
const RunContext = plugins.RunContext;
const RunBuffers = plugins.RunBuffers;
pub const RandomNoise = struct {
allocator: *std.mem.Allocator,
r: std.rand.DefaultPrng,
pub fn init(
allocator: *std.mem.Allocator,
) RandomNoise {
var r = std.rand.DefaultPrng.init(std.time.timestamp());
return RandomNoise{
.allocator = allocator,
.r = r,
};
}
pub fn run(self: *RandomNoise, rctx: *RunContext) void {
rctx.in_buf[0] = f32(2);
pub fn run(self: *RandomNoise, bufs: *RunBuffers) void {
bufs.out[0] = self.r.random.float(f32);
}
};