Chunity Debugging Community

From CCRMA Wiki
Revision as of 16:22, 16 November 2018 by Carat (Talk | contribs) (Syntaxl)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a page for people to post common and unusual problems and solutions that come about in using Chunity. Hopefully we can all learn from each other and make the debugging process a little less frustrating!


Sound

Sound not working

My scene wasn't making any sound, but I could see the sound going on the green level meters on my ChuckSubInstance. Other applications on my computer made sound too. I figured out that there was a "Mute Audio" button on the game scene view, and it was accidentally pressed. Unmuting audio fixed my problem.

Sound glitchy

Once I added more than 32 ChuckSubInstances, my scene's audio got glitchy. It seemed like some of the ChuckSubInstances were just straight up not playing. I found out that there's a setting Edit > Project Settings > Audio > Real Voices. Unity will completely ignore more Audio Sources than this number, and all my ChuckSubInstances had the default priority, so it was just jumping around between them all not sure what to do. I increased the number of Real Voices to be more than my number of ChuckSubInstances, and my project went back to normal.

Microphone

Crash with no mic

I found out that Chunity crashes / hangs if my computer has no microphone when I start the scene. I told the Chunity developers, and for now, I just need to make sure to have a mic plugged in before starting my scene.


General

Syntaxl

If you run your chuck code inside the RunCode() function, make sure your brackets are escaped. https://stackoverflow.com/questions/91362/how-to-escape-braces-curly-brackets-in-a-format-string-in-net

Instantiated ChuckSubInstances don't have ChuckMainInstance

If you need to add your ChuckMainInstance to a ChuckSubInstance in a script, there are two ways to do it:

  1. Edit line 480 in the script, ChuckSubInstance, to be: chuckMainInstance = GameObject.Find("nameofchuckobject").GetComponent<ChuckMainInstance>();
  2. Add a "TheChuck" component to your ChuckMainInstance. Then you can access it through the static variable TheChuck.instance. New ChuckSubInstances will check this variable automatically if you don't set their ChuckMainInstance.

Storing/Accessing Values in ChucK from Unity

In many cases, it can be useful to use global arrays in ChucK to store many values at a time. Values can easily be set from the graphics thread using the SetIntArrayValue or SetFloatArrayValue methods of the chuck subinstance. However, getting values back can be slightly more complicated. It involves a callback function (created using CreateGetIntCallback or CreateGetFloatCallback) that will return the value of the array and index in question. When you invoke GetIntArrayValue or GetFloatArrayValue (using your newly created callback function), you will be able to access the value of the array index specified. However, as the callback function operates on the audio thread, it will only run after the graphics thread is complete. Thus, if you make multiple "Get" calls within the graphics thread using the same callback function, the value will be continually overwritten on each call and you will only be able to access the value of the most recent call. To get around this, you can instantiate multiple callback functions associated with different "Get" calls, that way the values aren't overwritten before they can be accessed.

Collaboration

Use WeChat as much as possible for getting help in debugging. Also would be nice to team up and work alongside another student so that knowledge transfer is possible even if the ideas are different.