cap redrawing at 15 times /s
authorNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Tue, 19 Jun 2018 18:53:55 +0000 (13:53 -0500)
committerNikolaus Gullotta <nikolaus.gullotta@gmail.com>
Tue, 19 Jun 2018 18:54:16 +0000 (13:54 -0500)
scripts/noisegen.lua

index 684f421364c4e4c5bf32af9578671692a4783872..a4a5df8ff8e8d15dfc3d72fa1e14774ac0b75e96 100644 (file)
@@ -19,7 +19,14 @@ function dsp_ioconfig ()
        return { [1] = { audio_in = -1, audio_out = -1}, }
 end
 
+local rate = 0
+
+function dsp_init (rate)
+       sr = rate
+end
+
 local ao = 0
+local draw = 0
 
 function dsp_run (ins, outs, n_samples)
 
@@ -57,15 +64,16 @@ function dsp_run (ins, outs, n_samples)
                end
        end
 
+       if (draw > (sr/15)) then
+               self:queue_draw()
+               draw = 0
+       end
+
        -- passes array a {} into buffer
        for c = 1,#outs do
                outs[c]:set_table(a, n_samples)
        end
-
-       if (a ~= ao) then
-               self:queue_draw()
-       end
-       ao = amplitude
+       draw = draw + n_samples
 end
 
 function render_inline (ctx, w, max_h) --inline display