Cabbage Logo
Back to Cabbage Site

How to control cpu overload ? help me please

Now i use vco2 opcode unison 13 opcode so it not smooth for play
Help me please about control cpu overload except use increase ksmps
I still want ksmps = 1 but sound still smooth .
thanks .

Can you post some code that shows the issue? vco2 can be a little CPU hungry, but there may be other areas that can be improved.

asig vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave), i(gksave),.5 ;
;
;
asig = asig ;
; DETUNE OSCILLATOR SECTION;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;
;
aDetune1 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)-.1666, i(gksave), .5 ;
aDetune2 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)-.3332, i(gksave), .5 ;
aDetune3 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)+.1666, i(gksave), .5 ;
aDetune4 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)+.3332, i(gksave), .5 ;
aDetune5 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)-.4998, i(gksave), .5 ;
aDetune6 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)-.6664, i(gksave), .5 ;
aDetune7 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)+.4998, i(gksave), .5 ;
aDetune8 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)+.6664, i(gksave), .5 ;
aDetune9 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)-.833, i(gksave), .5 ;
aDetune10 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)-.9996, i(gksave), .5 ;
aDetune11 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.005)+.833, i(gksave), .5 ;
aDetune12 vco2 gkcheck1== 1 ? 1 : 0, p4 * octave(gkoctave) * semitone(gkDetuneWidth * 0.01)+.9996, i(gksave), .5 ;

[quote=“theoxes, post:1, topic:1261”]
I still want ksmps = 1 but sound still smooth
[/quote]That’s a little contradiction… :slight_smile: If you absolutely need sample-by-sample computations, then you should consider to make a native (C/C++) opcode yourself.

Anyway, from your posted snippet of code, I can see various strange things…

  1. asig = asig ; <----- ???

  2. Why you make that gkcheck1==1 ? ... so many times? It should be done just one time at the beginning of that section. The same with “p4 * octave(gkoctave)”.

It might be better to organise things that need ksmps=1 into a UDO which has its local ksmps set to 1. That way the global ksmps rate can be different. If the only reason you’re using ksmps=1 is to avoid noise on envelopes, why not use audio rate envelopes? Or are there other reasons for ksmps=1?

[quote=“rorywalsh, post:5, topic:1261”]
It might be better to organise things that need ksmps=1 into a UDO which has its local ksmps set to 1.
[/quote]Yes, absolutely.

Anyway, I think that in Csound you should avoid as much as possible to have a ksmps=1 (even locally to an UDO), unless it’s for experimenting, because from my experience, sample-by-sample computations in Csound are about 20 times slower than a native opcode that does the same thing.
It’s like your 3GHz CPU becomes a 150Mhz old relic… :older_man: :smiley:

Personally, to not hurt performance, I always try to have a ksmps of 256. For precise envelopes, as you said, you can always use a-rate opcodes, like linseg, transeg, etc.

Ok thank I will try. I just newbie hahaha

Rory I don’t know about (If,elseif) these are impact to cpu ?

If you have ksmps set to 1 then it means these are going to be tested on every audio cycle. That will surly east up some CPU. I would start out by increasing ksmps to 64 or 128 and then try to iron out the audio signals using a-rate opcodes. Are you updating Cabbage at the same time using identchannels(), if so be careful that these messages only send when absolutely required and definitely not on every k-cycle.