Page 1 of 1

Help With Code

Posted: Mon Nov 14, 2016 2:02 pm
by Audiocave
Hi guys.

I have a schematic for a drum sequencer which will play midi notes from a plugin out to my daw. It's all fine except for when I send midi notes the CPU use goes through the roof, spikes really badly. I've done a few things to try to reduce the load like..

    - Move some of the graphics drawing for the progress update to global variables so that instead of it creating a new pen, new color, etc, etc, on every 8-16th note trigger those things are already set. That helped a tiny bit.

    - Rewrote the project to put most of my Ruby code into the main module. That helped a tiny bit.

    - Put the midi trigger code into it's own module so only the ticker triggers would be hitting that event block.

But still, it's unworkable as it is sending a midi note even one midi note while running. Assume below that the ticker is sending 0-64 for 8 bars of 8th notes and this code below triggering a single note spikes my CPU, let alone trying to fill out the grid later with multiple drum notes.

Code: Select all

def event i,v
      if @ins[0] == 8 then
            on = Midi.new 144,1,36, $triggers[@pos]
            off = Midi.new 128,1,36,100
            output 0, on
            output 0, off, t+0.25
      end
end


Here's my main module code...

Any help would be appreciated. Thanks.

Re: Help With Code

Posted: Fri Nov 18, 2016 8:42 am
by nix
DS_RC2015.fsm
(371.93 KiB) Downloaded 882 times


Here is a sequencer I wrote, it doesn't use much cpu, but it uses a little too much RAM.
The timer itself doesn't though.

I can't see why the code snippet is too heavy, it goes slowly

If you up the schematic, maybe I or someone is keen to have a look mate