Cabbage Logo
Back to Cabbage Site

Embedded Filter System for CsoundUnity

Hey Csounders,

Just want to thank everyone again for an awesome time at the convention last week. Really was great and inspiring. I’m looking forward to becoming a more active participant in the development of CsoundinUnity!

Anyways, @gio and @rory, I think I brought up briefly an idea for CsoundUnity with you both. I think it’d be a very useful thing to include inherent ways to alter and control CsoundUnity componants using C# scripting. I envision something like an embedded filter system that is callable from any csoundUnity reference.

As an example, a user could script something like: csoundUnity.Lowpass(400, 16); This would add a Lowpass filter at the end of the csd file with a cutoff freq of 400, and a slope of 16 bands. Or, it could look this: csoundUnity.lowpass.cutoff = 400; Where just an initial reference to that variable creates the filter, and adjusts it as well.

I think this would be an excellent way for users to easily add very specific sonic effects and qualities in the same place they are making corresponding interactions. I.E. on collisions, gestures, positions, whatever… This same sort of system can apply to not only just specific parameters of objects, but also to pre-defined effects/events! For example, there could be a method like csoundUnity.Sweep(40, 2000, .5, 4); where a bandpass filter will be generated and centered from 40hz, and moved to 2000hz, with a gain of .5, and the entire movement lasting 4 seconds. Just an example. Maybe there is an empty .csd file that the user .csd is being ran through where these kinds of things take place?

Let me know what you think! I’d be excited to chat more about it.

Hi @Marshall_Chad, yeah it was a great conference. Really inspiring.

So I’ve been down the road of wrapping various Csound things in the past, and I’m not sure it’s something I think I need to be involved in right now :slight_smile: I understand your desire to make things more accessible to users, but as you know, to achieve good results with this system you really need to learn Csound. I like the idea of having a set of Csound instruments that can easily be called but I’m not sure about writing lots of wrapper functions to various bits and pieces of Csound code. I think it will be difficult to maintain, and I wonder if it’s worth the effort? Sorry, I’m not shooting down the idea, just expressing my thoughts on it. Your input is important, and the work you guys showed us was amazing. @giovannibedetti, what do you think?

What you don’t know is that I have started writing a native Unity plugin for Csound, which will let us distribute a full set of effects that can accessed and controlled through a Mixer. Users in this instance won’t even need to know Csound. And they can easily access the parameters in real-time via C#. Maybe this addresses some of things you would like to see in terms of ease of use? The standard Unity effects are good, but there are not many, we could provide so many different effects. It would be nice.

I can think of several situations where this won’t work, because on Csound you can’t assume where the output is, and to which audio variable apply the effect. Maybe I miss something obvious but csds won’t be able to support a feature like this out of the box, so you would have to rely on some “assumptions” and prepare the csds to accept those calls.
You can still achieve something that looks like this sending orchestras to Csound, but still, you would have to know how the rest is set up to be able to apply your effects. Not a really great addition to adding those effects directly to the csd. :sweat_smile:
I’m trying to think how we could encapsulate the csd in a “global” one, but it doesn’t look that easy.
Of course I’m very open to change my mind :exploding_head:

So yes this looks interesting but I think that the plugin solution is more flexible.
Technically with the plugins we should also be able to implement audio routing, so any kind of combinations and instrument stacks would be possible.
Also it could be possible to add those effects with code at runtime, we should investigate how Unity is able to have some audio effects as components (so for example you can add a Chorus to an AudioSource without using the mixer).
The difficulty with the plugin will be supporting mobile platforms, or well, at least Android, so that we can use the plugins on the Oculus.
But I’m sure we can get there!
Stay tuned :wink:

We’ll get there :slight_smile: I was just thinking we could also embed the possibility of live coding effects as they are running. That would be powerful.

1 Like

I see! Thanks a ton for the feedback from both of you. Totally understand the reasoning and definitely learned more about that perspective as well. That’s really cool that you’re working on a native Unity plugin! I’d love to hear more about that. Not something I really know much about at all but seems like it would carry a lot of the heavy lifting for what I’m talking about. @giovannibedetti yes I hear you on making ‘assumptions’. Finding the right place to make an output in the csd would be pretty weird. What I sort of had in mind was a separate .csd file, that way you can guarantee you’re at the end of the signal chain, but that’s also weird. @rorywalsh do you have any recommendations about where I could learn more about audio plugins in unity?

Hopefully we will be able to achieve signal chaining with the native plugin implementation.
Probably it will be a separate package from CsoundUnity, but we will see.
You can find the official Unity native audio plugin project (it has lots of interesting stuff) here:


This is the documentation:
https://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html

1 Like

We just plan on providing a lightweight wrapper for Csound. Last week I coded an experimental export of Cabbage instruments as native Unity plugins. It worked, but the performance was poor. There really is no need to have all the overhead of Cabbage inside Unity. Things are much improved with a lightweight wrapper. The performance is good and Cabbage syntax is parsed so that widgets appear in the editor, in the same way they do for CsoundUnity csd files. I will create a repo for this and maintain it outside of CsoundUnity and Cabbage. In the same way I do for the CsoundFMOD plugins. I will add a simple export option to Cabbage, and pull the binaries into the installer when I package Cabbage so that all users have access to them. I’m pretty bust this week, but I will try to find to create an early beta.

2 Likes