add basic rng init on RandomNoise plugin
This commit is contained in:
		
							parent
							
								
									16116371f5
								
							
						
					
					
						commit
						3edca782ac
					
				
					 2 changed files with 10 additions and 3 deletions
				
			
		
							
								
								
									
										3
									
								
								examples/noise.scri
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								examples/noise.scri
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| load :0; | ||||
| noise 3 1; | ||||
| quicksave; | ||||
|  | @ -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); | ||||
|     } | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue