# CsoundUnity for beat matching

**URL:** <https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553>\
**Category:** Csound for Games\
**Created:** [27 May 2017 14:33 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553 "2017-05-27T14:33:44Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [2 June 2017 19:54 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/21 "2017-06-02T19:54:50Z")

</div>

I won’t be able to try it until next week, but I’ll certainly let you know what I find out.

---

<div class="post-metadata">

**Author:** ![Tao\_Yao](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Tao\_Yao](https://forum.cabbageaudio.com/u/Tao_Yao)\
**Post date:** [3 June 2017 00:00 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/22 "2017-06-03T00:00:38Z")

</div>

No problem, thanks! Have a great weekend.

---

<div class="post-metadata">

**Author:** ![Tao\_Yao](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Tao\_Yao](https://forum.cabbageaudio.com/u/Tao_Yao)\
**Post date:** [4 June 2017 19:38 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/23 "2017-06-04T19:38:07Z")

</div>

Hi Rory,

Another problem I got and haven’t told you yet is since I’ve imported CsoundUnity to Unity and using my .csd file to process the audio in Unity, every time I modify and compile my C# script to Unity will cause Unity to crash and auto quit.

Also I can’t click the “PLay” button on my CsoundQT IDE to compile my csd file anymore since it will crash even Unity is not opening. If I use terminal on my Mac to compile Csound file it still works (csound -odac my\_csound\_file\_path).

I also tried some of my other Unity projects that didn’t import CsoundUnity, and compile a script won’t cause the Unity program to crash.

Did anybody have these problems before?

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [5 June 2017 19:19 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/24 "2017-06-05T19:19:22Z")

</div>

> [@Tao\_Yao](#):
>
> Another problem I got and haven’t told you yet is since I’ve imported CsoundUnity to Unity and using my .csd file to process the audio in Unity, every time I modify and compile my C# script to Unity will cause Unity to crash and auto quit.

Are you editing the .csd file while Unity is running the game? What is your C# script? Perhaps it’s causing something to go astray? [quote=“Tao\_Yao, post:23, topic:553”]  
Also I can’t click the “PLay” button on my CsoundQT IDE to compile my csd file anymore since it will crash even Unity is not opening. If I use terminal on my Mac to compile Csound file it still works (csound -odac my\_csound\_file\_path).  
[/quote]

I’m not sure what’s going on here. Both CsoundUnity and CsoundQT should be using the same version of Csound. One thing I have noted about Unity in the past, is that you must close it and reopen it whenever you use any other audio software. it seems to like to grab audio focus away from other apps. It catches me out on Windows all the time.[quote=“Tao\_Yao, post:23, topic:553”]  
I also tried some of my other Unity projects that didn’t import CsoundUnity, and compile a script won’t cause the Unity program to crash.

Did anybody have these problems before?  
[/quote]

Oh I’ve written quite a few scripts in my time that could take down Unity. You’re not alone there 😉 You should check the Unity editor log. That should may give you more details to work with.

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [6 June 2017 13:35 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/25 "2017-06-06T13:35:04Z")

</div>

> [@Tao\_Yao](#):
>
> But when I use CsoundUntiy Audio Source, the negative frequency is no longer playing the audio back wards, instead it will just pause the audio just like you set the pitch to ‘0’, but pitch higher than +1 will still make it play faster, can you try that sometime when you are free? I’m curious what is the main reason.

I don’t have any such issues. I’ve attached the file I tested with. It loads a sound file to a table, which the next instrument reads using a `temposcal` opcode. When I move my Pitch slider to the negative in my AudioSource inspector I get the expected change in playback direction. [TemposcaleTest.csd](https://forum.cabbageaudio.com/uploads/default/original/1X/31642de6b93fd6714f6dba1754885852d9cfba7a.csd) (514 Bytes)

---

<div class="post-metadata">

**Author:** ![Tao\_Yao](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Tao\_Yao](https://forum.cabbageaudio.com/u/Tao_Yao)\
**Post date:** [6 June 2017 21:01 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/26 "2017-06-06T21:01:48Z")

</div>

Hi Rory,

I think I found another bug of CsoundUnity.

Did you remember the relative path you told me before?, the “AudioPath” channel in Csonund stand for Assets/Audio and use that channel to store in a String variable so that you don’t have to type the directory from the root in your computer? Although it works in Unity, but when you build the project if you use “AudioPath” %s, the audio processed by CsoundUnity won’t be played anymore. The I switched back to using the directory from the root “/user/…/UnityProject/Assets…”, and build the project, the audio will play.

Is that also happens to you? Maybe you can try it out sometime.

Sorry for so many questions, haha, but I really think CsoundUnity will help a lot of game audio developers.

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [7 June 2017 11:29 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/27 "2017-06-07T11:29:09Z")

</div>

> [@Tao\_Yao](#):
>
> Although it works in Unity, but when you build the project if you use “AudioPath” %s, the audio processed by CsoundUnity won’t be played anymore.

Do you mean it won’t play when you build your game?

---

<div class="post-metadata">

**Author:** ![Tao\_Yao](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Tao\_Yao](https://forum.cabbageaudio.com/u/Tao_Yao)\
**Post date:** [7 June 2017 14:04 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/28 "2017-06-07T14:04:29Z")

</div>

Yes, if you use relative path with “AudioPath” channel %s, it won’t play the audio when you build the game, but when I switch back to use the directory from /user… instead of using “AudioPath” channel it WILL play when you build the game, I actually tried both on PC and Mac.

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [7 June 2017 15:21 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/29 "2017-06-07T15:21:11Z")

</div>

Ok, I better sort that. It’s not something I ever tried myself.

---

<div class="post-metadata">

**Author:** ![Tao\_Yao](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/t/f475e1/32.png) [@Tao\_Yao](https://forum.cabbageaudio.com/u/Tao_Yao)\
**Post date:** [8 June 2017 02:14 UTC](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553/30 "2017-06-08T02:14:08Z")

</div>

Sure, let me know when you try it out, thanks!

[Previous page](https://forum.cabbageaudio.com/t/csoundunity-for-beat-matching/553.md?page=1)
