[Csnd] Help needed with Csound and Faust
Date | 2024-08-10 23:55 |
From | Bryan Tysinger |
Subject | [Csnd] Help needed with Csound and Faust |
Hi all! This is my first post to the Csound list.
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
I read Victor Lazzarini's "Computer Music Instruments" recently and it got me excited about trying to improve the performance of a big real-time audio Csound project I've built by bringing in some faster (?) objects from Faust. The current guidance with Faust seems to be to use the web-based IDE and export a Csound .dylib file. I've convinced myself that the Faust code works (it is just one of their examples for now) and that I've exported the .dylib file. When I try to use the opcode in Csound (full example code is at the end of this), I don't get anywhere. Folks have suggested several things so far: 1. Maybe the web-based IDE doesn't export code that works on M2 Macs. 2. Try using the faust2csound tool in Faust instead. 3. Maybe I need the "CSound Dev Kit." If 1 is true, that leads me to 2. I can't get 2 to work, which leads me to 3. Any guidance on getting this to work? I think I have Csound 6.18, no idea about the "dev kit." Thank you! Bryan <Cabbage> form caption("Faust Opcode") size(400, 300), guiMode("queue") pluginId("def1") colour(0,0,0) rslider bounds(10,50,50,50), channel("window"), range(50, 10000, 1000,1, 1), text("window") rslider bounds(70, 50, 50, 50), channel("xfade"), range(1, 10000, 10,1, 1), text("xfade") rslider bounds(130, 50, 50, 50), channel("shift"), range(-12, 12, 0,1, 0.1), text("shift") rslider bounds(250, 50, 50, 50), channel("gain"), range(0, 1, 0 ,1, 0.01), text("gain") </Cabbage> <CsoundSynthesizer> <CsOptions> -n -d --opcode-lib=/Users/bryantysinger/Documents/svn_checkouts/loobt_v1/Prototypes/Faust/pitch_shift.dylib </CsOptions> <CsInstruments> ; Initialize the global variables. ksmps = 32 nchnls = 2 0dbfs = 1 instr 1 a1_in inch 1 kGain cabbageGetValue "gain" kWindow cabbageGetValue "window" kXfade cabbageGetValue "xfade" kShift cabbageGetValue "shift" ; Generate osc with custom opcode a_process pitchShifter a1_in, kWindow, kXfade, kShift outs a1_in*kGain, a_process*kGain endin </CsInstruments> <CsScore> ;causes Csound to run for about 7000 years... f0 z ;starts instrument 1 and runs it for a week i1 0 [60*60*24*7] </CsScore> </CsoundSynthesizer> |
Date | 2024-08-11 09:41 |
From | vlz |
Subject | Re: [Csnd] Help needed with Csound and Faust |
There is no Csound (it's spelt Csound, not CSound) Dev Kit as such. When you install Csound on Mac or Windows you have the API headers. This is all you need to build opcodes (if you have a C/C++ toolchain installed). The faust2csound tool will give you the opcode source file, which then can be built into a .dylib: c++ -dynamiclib myop.cpp -o myop.dylib -I/Library/Frameworks/CsoundLib64.framework/Headers (you may also need -std=c++11 or something if the faust emitted code uses newer C++ versions) If the problem is that the .dylib is for intel, then this should be the solution. You can also ask the maintainers of the site if that is the case. HTH Victor On 11 Aug 2024, at 00:06, Bryan Tysinger <bryantysinger@gmail.com> wrote:
|
Date | 2024-08-11 16:23 |
From | Bryan Tysinger |
Subject | Re: [Csnd] Help needed with Csound and Faust |
Thanks Victor! That gave me some insight into where things were going wrong. There is a Csound header file (csdl.h) that wasn't being included. It seems the path to it wasn't being followed before (maybe because it has to follow an alias?), so I explicitly included it like this: -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers -L/Library/Frameworks/CsoundLib64.framework/Versions/6.0 Unfortunately, that then leads to compilation errors associated with the C++ code with some FAUST-specific macro variables when I try to compile the cpp file directly. I tried a few different compilers with the same issues. I then tried to use the faust2csound tool instead, spelling out all of the -L and -I paths explicitly but that still doesn't produce anything or give any error messages. This sort of thing: faust2csound -I/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Headers -L/Library/Frameworks/CsoundLib64.framework/Versions/6.0 -std=c++11 HPF.dsp I feel like I'm close, but also pretty frustrated. Bryan On Sun, Aug 11, 2024 at 1:41 AM vlz <viclazzarini@gmail.com> wrote:
|
Date | 2024-08-11 19:52 |
From | vlz |
Subject | Re: [Csnd] Help needed with Csound and Faust |
You don't need the -L flag, because there's no library to link to (it's a path to find link libraries), it's only -I that is needed. Maybe the faust2csound script is not quite right? You could run the faust command with csound architecture option and then c++ on the cpp file generated. Prof. Victor Lazzarini Maynooth University Ireland On 11 Aug 2024, at 16:23, Bryan Tysinger <bryantysinger@gmail.com> wrote:
|
Date | 2024-08-19 01:46 |
From | Aaron Krister Johnson |
Subject | Re: [Csnd] Help needed with Csound and Faust |
Where `faust2csound` shines is the ability to create a plugin you can just drop into the plugins64 directory. B/c of the plugin aspect, the template for csound architecture targeted by `fasut2csound` is pretty complex. But, there are other ways if you're willing to roll up your sleeves and be bold, to get faust code working in csound as a built-in opcode that you extend csound with yourself. For example, I've done this before in my stripped-down csound project called `diet_csound`. Here's an example of a waveguide opcode I made b/c I got fed-up with csound's built-in waveguides (except for pluck) being out-of-tune: https://github.com/akjmicro/diet_csound/blob/master/diet_csound/Opcodes/faust_wguide.c I did this w/o using `faust2csound`, which is overkill for this, actually. `faust` to raw C (look up the options to get faust to compile to C, not C++, which is also overkill) is perfect for this. It can be pretty obvious when looking at "raw" faust output what the
core DSP code actually is. If you read a tutorial about how to create an
opcode from scratch, or even just study a simpler csound opcode and use
its structure as a template, it's not a problem to re-compile csound
itself to add a custom opcode. You just have to be smart about variable naming, and know where the init-style code vs where the inner loop of DSP samples is in faust's output. If you contact me privately, I can show you the raw faust output and you could see how it can be used in a typical csound opcode source-code situation. I should also say: I've not tested it, and don't know how well or performant they are, but there are the faust opcodes right in csound that allow one to put faust code into an instrument and run it. It's pretty cool as a concept, but I cannot say how well it works. I think when I last tried it, my standard csound build didn't have those opcodes. On Sun, Aug 11, 2024 at 8:23 AM Bryan Tysinger <bryantysinger@gmail.com> wrote:
|