It’s just a sketch, but it’s giving me problems that I think are nothing more than overtaxing the CPU.
It’s not a complicated program, but it makes use of a gentable
widget that refreshes 2 times per second to display a waveform.
What the program does: it plays a simple mono psytrance-style rolling kick/bass and displays the waveform on the screen. I wanted to duplicate the style of LFO tool - how it displays a single beat’s worth of waveform that updates on each beat so that instead of scrolling, the waveform is locked so that the same part of the beat is always at the same horizontal position within the waveform display. It’s more complicated to explain then to understand if you look at it.
My issue is that the context for all these problems are the very underpowered and old laptop I’m on. I was hoping someone with a decent computer could tell me whether the program struggles? I’m not sure if the program itself is much of a CPU hog or if my computer is just weak af.
If it’s also underperforming on decent computers, then the question becomes why and how to fix it, because it’s not a long program, and it’s certainly not the audio parts that are to blame.
<Cabbage>
form caption("Untitled") size(900, 300), guiMode("queue"), pluginId("def1")
gentable bounds(8, 8, 800, 286) channel("display") tableBackgroundColour("blue") tableNumber(99) fill(0)
button bounds(820,8,75,25) latched(1) channel("refresh") text("refresh") colour:0("blue") colour:1("green")
nslider bounds(820,40,75,25) channel("bdlt")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
--displays -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
gibeats = sr*0.50 ;audio samples in a beat
cabbageSet "display", "sampleRange", 0, gibeats
gienv2 ftgen 0,0,16384,-7, 1, 16384, 1
gibuf ftgen 99,0,-gibeats,-2,0 ;empty buffer
instr 1
if (chnget:i("refresh"))==1 then
cabbageSet "display", "tableNumber", 99
cabbageSetValue "refresh", 0
endif
icps = cpspch(5.05)
anv expsega 1/100, 0.0005, 1, p3/8, 2/3, p3/4, 1/3, p3/8, 1/100
an2 tablei line:a(0,p3,1), gienv2, 1, 0, 0
af1 expsega icps*7, p3/16, icps, p3, icps
akik oscil anv*an2, af1
abasf init icps
asqr init 0
asaw init .95
abas squinewave abasf, asqr, asaw, asqr
aben expseg 0.00001, p3/4-0.0005, 0.00001, .0005, 1, p3/4-0.0005, 0.001, 0.0005, 1, p3/4-0.0005, .001, 0.0005, 1, p3/4-0.0005, 0.001, 0.0005, 0.00001
abas *= aben
kdlt chnget "bdlt"
abas vdelayx abas, a(kdlt/icps), 1.00, 16
adisp = akik+abas
andx line 0, p3, p3*sr
tablew adisp, andx, gibuf, 0, 0, 0
ares =.5*(akik+abas)
outs ares, ares
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
t 0 120
{64 x
i 1 [$x] 1
}
</CsScore>
</CsoundSynthesizer>
Does this question belong in Cabbage Recipes by the way?