(How) Is it possible to use Csound as a library in a c/c++ application?
If i.e. we want to make some simple c/c++ application where we would like to filter or generate something, is it possible to benefit from well written c-algorithms from csound src code and then use them directly without making a .csd design?
Hi @rory! Thanks for your reply but I think I wasnāt clear enough as I posted the question.
So when using Csound API the basic principle, if I understand it correctly, is something like this; you make your csound design and then you make an object, compile it and then you interact with it using API. But what I mean is, is it possible to use only csound algorithms without creating an csound design?
I.e. csound/pffft.h at master Ā· csound/csound Ā· GitHub is an excellent example of āstand-aloneā algorithm that I can include in c/c++ app if I need to make just a fft on some data that I have. Here I donāt need an csd design, just some buffers
Now, Iāve looked (briefly I must admit) over some of the csound src code and so far Iāve seen only functions/algorithms that require Csound object as an input parameter like i.e. csound/circularbuffer.c at master Ā· csound/csound Ā· GitHub and many others similarly.
Is there a way to overcome this some āhackā or workaround?
Sorry, youāre right, I read your post too quickly!
@stevenyi once did some work on a framework that would let you call Csound opcodes directly from your C++ applications. Thatās pregnant with looking at.
Of course you are free to use any of the Csound source code as long as you respect the license. But Iām not sure how easy it might be to use chunks of Csound source in your own applications.
The original paper is at: https://www.cs.cmu.edu/~rbd/papers/Extending-Aura-ICMC-SMC-2014.pdf. I think the code may still be found in the Aura repository but would need to look. The plan was to use it as a new UGEN API in Csound7 but that hasnāt been done yet. I have heard this work was used in another project but wasnāt made public, but I heard it was still easy enough to modify and repurpose. Let me know if you have any questions.
Iāve looked on github for Aura repository but didnāt find anything, could you post here a link to it?
Iām still relatively new to Csound but it is an extremely cool language and having an option to use its opcodes directly in c++ app would give it a whole new usage dimension
Using opcodes directly from c (or c++) is possible but you still need a CSOUND * instance since opcodes need access to it for any interaction with the system (allocating memory, printing messages, etc). It is not trivial to do. If you want to look at a working version of this approach you can take a look at the code of āpolyā (https://github.com/csound-plugins/csound-plugins/blob/master/src/poly/src/poly.c). Within this opcode we run another opcode a given number of times. The poly opcode allocates/frees all memory for the wrapped opcode and calls its init and perf functions as needed, in fact doing exactly what csound itself does.