[Csnd] Additive synthesis using many independent oscillators

Hello folks, I’m hoping someone can share with me what the best way to run additive synthesis in csound is if I want total control over each partial. I realize this is super expensive, but it’s for a computation analysis class and is more a proof of concept than perhaps practical. I wish to control each oscillator’s params (phase, amp, cps, env) from Scheme, so the logistic side of dealing with the numbers is not really a problem as I can get the numbers into csound from Scheme in whatever format make sense.

The first thing I tried was just making a simple one osc, one env instrument and triggering many instances of it. I’m able to trigger 128 instances of a poscil sine wave using 128 sequential messages to the csound~ object in Max, but it starts crapping out at 256, even though cpu usage seems to still have lots of headroom. So I’m curious if anyone knows if this is a csound~/Max specific issue, or does csound create a particularly large spike from 128 simultaneously note onsets, or some other thing I don’t know. I have some ideas for other things to try, but figured I’d ask in case a) I’m just doing this wrong and it’s stupid, or b) there are ways around it (like having csound receive one really long message and internally dispatching to 128 oscillators or something.

thanks!
iain

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Without looking at code it is difficult to say why sound “starts crapping out”. With my laptop and built-in soundcard, which aren’t anything to be proud of I can get ~2000 single instances of oscili (being driven by “poly”, otherwise using one instance per oscil reduces that number to ~1200), or ~10000 using beadsynt. The cpu usage is stable and can be pushed to around 90% without xruns. This is without using -j, just a single core.

regards,

Eduardo

Csound mailing list Send bugs reports to Discussions of bugs and features can be posted here

thanks Eduardo, that’s helpful to know. I expect I’m hitting something to do with the number of messages going into the csound~ object at once in Max as your numbers seem much more inline with that I was expecting. I will experiment with the same stuff on command line.

I have been away from Csound for a long time so am coming up to speed on new practices. If you have example code anywhere of how you do it, it would be great to see it.

iain

Also, the orc code I am using is below. If this is not a good way, I’m all ears!

giSine ftgen 0, 0, 8192, 10, 1
instr 1
aosc oscil p4, p5, giSine
aenv adsr 0.05, 0.2, 0.5, 0.4
asig = aosc * aenv * .1
outs asig, asig
endin

iain

oops, I was actually using poscil, that was copied from the wrong buffer

I would not use poscil for this (or in general), it is quite inefficient. For linearly interpolated table lookup use oscili, it is as efficient as it can be (although not particularly simd friendly). If using lots of oscillators, oscil is also just fine and you don’t need the linear interpolation.


Csound mailing list Send bugs reports to Discussions of bugs and features can be posted here

Thanks Eduardo, that helped. I have switched things around so that I now send a message from Scheme for Max to csound~ with the data for many oscillators at once, and between that and switching to oscil and a krate env for each oscil I’m getting 1024 oscillators ok at once. Should be enough to go on for now.

iain