pouët.net

"Optimize" 4klang tune?

category: music [glöplog]
Hi. I am making my first tune using 4klang. It's great and it's fun. But I have one big problem - HUGE CPU usage.

Is there any way to get it a little down? Sometimes the sound "twitches" so much I can't even hear what's playing.

I'm using Intel Core2Duo @ 2.4GHz, Renoise
The track uses 9 intruments in its most complex moment (too much?)
It is 1xPolyphone
added on the 2011-07-29 12:16:43 by AceMan AceMan
Haven't actually tried the 4klang synth myself, but used to dealing with size-restricted (and often really CPU-heavy) synths, I'd suggest you first identify which instruments consumes most CPU-power. When done - identify what parts of it is most CPU-heavy. Is it a specific oscillator, a specific effect or modulation?

Usually, you'd be able to come rather close to what you created, without using those CPU-heavy effects/oscillators/modulation-waveforms etc.. And you always have to remember that the ordience haven't heard "the original", and thus don't know how much more "correct" it would be since they have nothing to compare with.

If you insist on using the complete set of instruments as CPU-heavy as they may be, you could always compose your tune with muted channels here and there. It won't allow you to hear the complete track/pattern in it's whole, but usually it's not a problem in the player of the synth. You should, however, always check and make sure your tune will play correctly in the production/executable before entering it. Most players pre-render the song or fills a nice large buffer, so you won't suffer from the high CPU-usage during replay.

Also, I don't know if 4klang handles multiple CPUs and is able to process audio in multiple threads. You'd have to search the website or ask p0wl or someone close to the developer(s)

But I completely understand your
added on the 2011-07-29 12:35:23 by Punqtured Punqtured
.... frustrations ;) Don't know why I missed that last word :-D
added on the 2011-07-29 12:38:04 by Punqtured Punqtured
Thanks a lot for hints, I'll look into instruments and try to make them a bit lighter.

And thanks for info about pre-rendering the tune in the actual intro - it's a relief 'cause I was afraid it'll be the same as in Renoise :)
added on the 2011-07-29 12:44:11 by AceMan AceMan
If you have problems with the CPU usage in your intro you can pre-render the music see the WavWriter example in the 4klang package.
added on the 2011-07-29 12:48:12 by raer raer
I think the problem is during composing ...
added on the 2011-07-29 12:53:05 by Punqtured Punqtured
Aceman, i am using 4klang on a single core cpu. haven't been able to use more than 8 instruments total. Tried a lot, nothing really helped reducing the cpu-load. Live with it ;)
Btw. i recently tried V2, the Farbrausch softsynth and my first impression is, it is extremly cpu-friendly.
added on the 2011-07-29 19:00:00 by CONS CONS
There's also the size to take into consideration. V2 wouldn't do you any good if creating 4k intros. For 64k intros, it's definately _the_ most versatile synth freely available. But sadly there's always a pretty tight connection between CPU-usage and sound-quality. Perhaps a lot tighter connection than that between size and quality. The better / more correct signal-processing, the more processingpower is required. Synths that are CPU-heavy AND have the option of pre-rendering would definately be my synth of choice for intros, regardless if it's for a 4k or 64k intros. 4klang sure sounds like a really CPU-heavy synth, and I'd defiantely reconsider whether that was the right choice for me, since composing would grind to a painfull halt whenever songs get just a little complex. I mean - 8 instruments isn't that much, and to a certain degree, you need to be able to hear the complete track to avoid distortion and strangely odd volume-levels of some instruments compared to others.

Not saying it can't be done, but it'd be quite a lot easier if you wouldn't have to worry about the CPU-usage.
added on the 2011-07-29 19:35:19 by Punqtured Punqtured
as neither gopher nor pOWL yet found this thread, lemme put my 2 cents (been one of the first beta-testers) :

with a 2.4GHz CPU you should try some less cpu-consuming tracker like MadTracker, which i used in my first time with 4klang aswell, and never ran into problems! ;)

also i know its kinda optimised for dualCores, atleast at runtime of the intro, so after export!
cant say how it is with the VSTi (i think it depends on the tracker -> trackers_usage of VSTi).

best is to just wait until gopher clears it all up!
sooo ....
yes, 4klang is cpu heavy :)

it processes all signals on a per sample base, no precalculations done, no modulation frames used ... just brute force processing it all per sample, and only running on one thread/cpu.

at least thats the case for the player in the exported song for a 4k.

the vsti contains some checks and extra code to be able to skip certain instruments. digging though the code again after quite some months the relevant lines are:

Code:// if the instrument signal stack is valid and we still got a signal from that instrument if (SynthObj.InstrumentSignalValid[i] && (fabs(SynthObj.SignalTrace[i]) > 0.00001f))


so there are 2 ways to prevent an instrument stack from beeing processed in the vsti:
1. is to make the stack invalid (signalcount != 0 at the end). wouldnt exploit that really :)
2. the better solution during composing: mute the channels which you dont want to hear currently in your host program

another option is to activate the Solo Mode in 4klang itself in which case you'd only hear that current instrument.

but in the end thats pretty much all you can do to prevent stuttering in the vsti except getting a more powerful cpu :)

as already pointed out, for the intro (or also a render to disk with renoise) it wont matter, as the synth can take its time to render what needs to be rendered.
in the intro you have 2 options again:
1. letting the whole song be precalculated before the intro starts (which obviously on your machine would probably take as much time as song length if not more)
2. or the preferred alternative: have the synth render in a seperate thread. in your case i would just make sure that before you start the actual intro loop and playback of the sound, just introduce a few seconds Sleep() so the buffer can prefill some seconds already.

what hardy said is kinda true though.
At least compared to Renoise, Madtracker has a lower CPU overhead, so more or more complex 4klang instruments can be used there before it fucks up.

What helps with renoise a bit is to disable the cpu overload prevention (under Preferences / Audio).


added on the 2011-07-29 22:09:22 by gopher gopher
Thanks for clearing that up, gopher. I think this answers all further questions on cpu load and optimization options.
added on the 2011-07-29 22:49:36 by CONS CONS
gopher: What's a modulation frame?
added on the 2011-07-30 00:26:27 by Sesse Sesse
I think what is meant by a modulation frame is a processing buffer for which the modulations are constant. Gopher?
added on the 2011-07-30 00:58:05 by trc_wm trc_wm
trc_wm: yep
a modulation frame (to my understanding at least) is a block of samples the modulation inputs would be constant for and thus heavy calculations need to be done only for the first sample of each frame (like filter coeffs, oscillator frequency, ...)
added on the 2011-08-01 21:13:40 by gopher gopher
Thanks again people :)
added on the 2011-08-03 13:40:24 by AceMan AceMan
Punqtured: Not too sure about the connection between CPU usage and quality. V2 and 4Klang are in about the same league sound wise (with both of the synths having their distinct advantages and disadvantages) yet they sit on the opposite ends of the CPU usage spectrum.

The way I see it it's more a triangle like "Speed / Size / Quality". 4Klang as a 4k synth is optimized purely for size while V2, being more than 10 years old now, needed to feature quite a bit of CPU optimization to get those 24 voices out of a Pentium2@300Mhz while an intro was running; so it's a comprimize between size and speed. Funny thing is that this alone makes 4klang the better synth quality-wise because it's sample exact (instead of calculating everything in 128-sample frames like V2 does) which enables it to do eg. far better drums. Luckily I had enough space back then to sacrifice code size for quality and eg. implement some antialiasing, refine the filter coefficent calculation and first of all have non-linear scales for most of the parameters.

Of course with professional VSTs of which most haven't ever been optimized for.. anything, there's a quite distinct correlation between CPU usage and quality. Thing is, it doesn't need to be this way. As nice as it is to get comments like "omg, fastest synth EVAR" on KVRAudio, as much it hurts to see your CPU meter jump up to 30% just by playing with some commercial synth that doesn't anything but a few wave tables, filters and an echo. :) Ah well, the old demoscener/console gamedev problem. Nobody else cares :( :D

added on the 2011-08-03 14:11:26 by kb_ kb_
Yeah, the little I've seen of “professional” VST code has been horrible speed-wise. People are gladly doing a zillion function calls per-sample, have lookup tables where they only use 1-f(x) (why not simply invert the table, then?), and so on.

At least in a VST you can assume the other effects live on other cores; in a 64k synth you'd usually rather use your space on something else than multithreading.
added on the 2011-08-03 15:16:28 by Sesse Sesse
Sesse: The code needed to start off a synth thread is neglectable in the scope of a 64k intro, at least on Windows...
added on the 2011-08-03 15:26:25 by kusma kusma
Sure, the synth runs in its own thread, but you're rarely doing things like rendering each voice in separate threads. The sync code is a bit too much for me, at least.
added on the 2011-08-03 16:37:13 by Sesse Sesse
kb_: No doubt there's some kind of iron triangle. And based on your comment about kvraudio, 30% cpu and wavetables, I take it you probably read about and tried revival's "Quiver" already ;-)

But is speed really that big a deal anymore? I mean - it's possible to precalc pretty much the whole track. Yeah, it's boring waiting for the intro to start and all, but if no tradeoff on quality has to be made for speed, isn't that just great?

The problem is with synths trading off on speed for no apparent reason. Some things simply require cpu power to be done properly. Like generating a wavetable for an oscillator (which can be done in a seperate thread, Sesse) ;-)
added on the 2011-08-03 22:35:56 by Punqtured Punqtured
Another important tradeoff that goes into synth development (and any other type of software development) is development time and code legibility.

I can tell you exactly why a developer would do 1-f(x) using a lookup table: it's easier to think about conceptually (matches the math/algorithm), it's fast enough, something could subtly break in the rewrite, OMG MY TODO LIST IS BIG.

It's not lazyness, it's just market forces. Which is a silly thing to blame any developer for.
added on the 2011-08-03 23:03:16 by revival revival
Punqtured: My wavetables are generated in 250ms. SSE, yo. :-P
added on the 2011-08-04 00:19:28 by Sesse Sesse
I have no clue if that's fast or not :-) I just use them. What synth did you create and is it possible to try it out?
added on the 2011-08-04 00:36:54 by Punqtured Punqtured
It's fast enough that you don't need a separate thread for it, since it only needs to do that on startup.

The synth is called SaneStation; it was used in Nemesis and has been lying dormant ever since, but I've started tinkering with it again (and a lot of small but important things have been happening with it recently). It's a pretty standard fixed-function virtual-analogue design, so in some respects perhaps less interesting than your synth (no PADsynth etc.), but I think it does what it does quite OK.

Send me an email (e.g. the Nemesis .nfo has my address) and I'll bump you a copy of the latest build -- I'm always interested in musician feedback, since I don't make music on computers myself.

I'd love to actually take a look at the Fnuque synth myself (it sounds like a really fun beast), but I forgot to ask during Solskogen. :-/
added on the 2011-08-04 10:33:28 by Sesse Sesse
There's a publically available beta-release so knock yourself out ;-) I'll drop you a mail later tonight when not at work.
added on the 2011-08-04 12:44:27 by Punqtured Punqtured

login