Csound and Unity..

If anyone is interested, I’ve written a Csound wrapper for Unity. Needless to say it makes it very easy to do all sorts of procedural music, and gives users all of Csound’s synthesis and audio processing tools, including ambisonic decoding/encoding, bin-aurual diffusion, OSC support, etc. It’s completely open source and available on my github page:

Let me know if you have any questions, suggestions, or comments.

Rory.

p.s. I’m relatively new here, I hope I’m not breaking forum etiquette by posting this announcement…

4 Likes

Very cool, will definitely try this out. Thanks for sharing!

Let me know if you come up with anything interesting. I’m pretty new to Unity but I’m loving learning to use it. Throw in Csound and I’m in heaven.

Hey, nice work
Have you any experience running it on mobile? I’m working on sort of sequencer and sound synthesis would be great addition to it. Unfortunately most of system resources is spent on drawing the UI and not much left for anything else…

I haven’t had time to explore this yet, but I’ve used Csound for Android applications before, so technically I don’t see why it wouldn’t work. Lots of people have also used Csound on iOS. It would involve a bit of work. It’s something I would like to add when I get the time.

Thanks for this. I’ve been a long time Csound user but relatively new to Unity. Does anyone know if something of the kind exists for MaxMSP and/or Pure Data as well since I’m more comfortable in those environments when making procedural music.

You can try this for Pure Data. I never got it to work, and I think you may need to compile libpd yourself which is a pain. Considering that you have to code in both environments, i.e., Csound and Unity, I find the two go together quite well.

I cannot make it work. I tried all the three scenes included in the package.
Unity hangs forever after hitting play.
I’m on Os X 10.9.5, Unity 5.3.5f1, and I have Csound 6.07 installed.

You don’t actually need to have Csound installed but that shouldn’t be a problem. I have only tried this with 10.10. Did you try the scenes before installing Csound? I’m not in a position look into this right now as I’m taking a few weeks off. How are your C# chops? You could try editing the code so that Unity loads your installed Csound over the one that ships with the package. Or you can try using Csound with fmod

Sorry I can’t offer more support right now. Just bad timing I’m afraid but the fmod plugin should work ok.

Thank you for your answer. I will try it on Os X 10.10, then.
No hurry!

Tried on Os X 10.10, same problem, Unity hangs forever and I have to force quit.
If I add a CsoundUnity component to a gameobject without specifying the csd file, I have the following output:

I also tried to load Csound from my installed one, setting dataPath=“/Library/Frameworks”; inside CsoundUnity.cs
No error, but Unity hangs if I add a csd file and hit play.

Now it’s working (also without changing datapath)! I don’t know why, I just restarted Unity several times.

Glad it’s working but obviously totally miffed as to why. Perhaps Csound was already running as a process?

I think not. I didn’t use Csound with CsoundQt or anything similar, nor via CLI. But shouldn’t it be able to run multiple instances simultaneously?
I have to say I also tried reinstalling Csound 6.07 a couple of times.
Then, after some Unity hanging/restarting, it worked.
Now I am going to try some csd to test it!
Thank you for your work, I was looking for this since ages!

Let me know how it goes for you. I’d be happy to answer any specific questions you have. The good thing is that you can go ahead and add your own methods or change things as you see fit. The source is not that complex at all.

I tried to build a standalone app for Os X, and I get this error:

I had to (brutally) add some compiler flags to export a standalone build:

CsoundUnity.cs, line 20:

#if UNITY_EDITOR
using UnityEditor;
#endif

CsoundUnity.cs, line 211:

/**
    * process a ksmps-sized block of samples
    */
    public string getFilePath(Object obj)
    {
        #if UNITY_EDITOR
        return Application.dataPath.Replace("Assets", "") + AssetDatabase.GetAssetPath(obj);
        #endif
        return "";
    }

Yes, the current code in the repo is missing this. I have more up to date code but I’ve not had a chance to update yet. It’ll have to wait till I am back at work as it’s right there on my work PC. But as you might imagine, I’m in no rush to get back to work :wink:

1 Like

As I said, no hurry! I am very happy with what I have right now, a lot to experiment with :slight_smile:
Thank you again!

just a little bump to ask if I can expect an update…
I have audio only on left channel, what can I try?

Can you confirm you have the latest source? I can look into this tomorrow as I’ll have a bit of time then.