# Returning to CsoundUnity and updating old project

**URL:** <https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933>\
**Category:** Csound for Games\
**Created:** [5 November 2023 11:47 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933 "2023-11-05T11:47:05Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [17 November 2024 09:47 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/101 "2024-11-17T09:47:16Z")

</div>

![image](https://forum.cabbageaudio.com/uploads/default/original/2X/5/510bb09784fbe8394d47f6874a3fda8f4a1448c1.png)  
under the star you can select your package name (sorry NDA)

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [17 November 2024 09:56 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/102 "2024-11-17T09:56:41Z")

</div>

here’s mine:

![Screenshot 2024-11-17 at 1.53.36 AM](https://forum.cabbageaudio.com/uploads/default/optimized/2X/c/c855b5814233b61e13d9c4e82a42ac8a9785bc96_2_689x24.png)

i’m on Unity 2022.3.14 but it looks like you have more options than me in Logcat.

also it appears that Debug.Log won’t actually print anything in Logcat or it’s highly inconsistent - there’s a huge thread i just scrolled through on it. i changed everything to Debug.LogWarning, so we’ll see if anything shows.

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [17 November 2024 10:04 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/103 "2024-11-17T10:04:52Z")

</div>

okay @giovannibedetti - a small modicum of progress but some important info to share:

1. Debug.LogError did print the info but only on a BuildAndRun and not while just running the build. and the path is exactly what they stated in the UnityAPI
2. Build and Run will ERASE the PersistentDataPath folder and replace it. and THIS is what was causing the crashes, because the SF2 files were erased as soon as i did Build And Run
3. i used your script that copies from StreamingAssets but i had compilation errors because your version is the 4.0 version not 3.5 and it references a WAFU namespace that doesn’t exist for me, so i commented out the code that added audio files.

and now that it doesn’t crash when playing back SF2 files i get - nothing. no sound. Csound is definitely working as the playbar moves and that is driven by the Layer’s time division. i did try sfplay3 as well as sfinstr3 - both of these opcodes played the sound font in the editor just fine but the build is utterly silent on the Quest.

i can’t really get you good logs from Csound in logcat unless all Debug.Log messages are replaced by Debug.LogError - and even then this will likely only print during a Build and Run session.

if you had a Unity project for Quest Android using a sound font i could test that and see but as it looks right now it’s not seeming to work at all, no matter what opcode i use. i’m heading to bed now at this point. some progress but still discouraging.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 08:52 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/104 "2024-11-18T08:52:14Z")

</div>

> [@metaphysician](#):
>
> i’m on Unity 2022.3.14 but it looks like you have more options than me in Logcat.

This is Unity 2022.3.52f1:

 ![image](https://forum.cabbageaudio.com/uploads/default/original/2X/a/a53a9ae935f88631c10e5664aaf7b8b4a509cf9b.png)  
If you connect a device you will see it listed under the drop down menu that now says “No device”.  
If you start the app, you will see it under the drop down menu that now says “No filter”.  
It should work if you start the app without using Build and Run too.  
If you don’t like Android Logcat you can simply use adb to log Unity output (maybe add adb to your path so that it’s easier to use).  
Simply use this command to log Unity output on your terminal:

```
adb logcat -s Unity

```

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:08 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/105 "2024-11-18T09:08:36Z")

</div>

> [@metaphysician](#):
>
> Build and Run will ERASE the PersistentDataPath folder and replace it.

I’m not sure this is true.  
In my past experience it will create the folder if it doesn’t exist, but the next runs will keep the content of the folder.

> [@metaphysician](#):
>
> i used your script that copies from StreamingAssets but i had compilation errors because your version is the 4.0 version not 3.5 and it references a WAFU namespace that doesn’t exist for me, so i commented out the code that added audio files.

Yes correct, but as you did you can safely comment the part related to audio files.

I’ll make some tests and upload a project that uses soundfonts today.  
But you can simply import the SFDIR sample from the CsoundUnity package and build it for Android.  
It was working 😃

I remember an issue with soundfonts some months ago though:

> <https://github.com/csound/csound/issues/1783>
>
> I am experiencing a weird behaviour with Sound Fonts on Android. I have no issue…s with the same csd on a Windows machine.
> I can replicate the issue with the soundfont used in the examples, sf\_GMbank.sf2.
> With this sound font, the pitch of the played notes behaves erratically and it's wrong for some notes.
> With other sound fonts I tried (for example the \[MuseScore generic SF\](https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore\_General/MuseScore\_General.sf2)), most of the presets don't play at all.
> This (zipped) csd shows the issue
> \[TestSoundFonts\_Android.zip\](https://github.com/csound/csound/files/13306260/TestSoundFonts\_Android.zip)
> The issue may be related with the handling of presets, since soundfonts with a single preset don't have the same issue and play correctly.
> Tested with the \[Csound for Android app\](https://github.com/gogins/csound-android/releases/download/v38/CsoundApplication-release.apk) (Csound 6.18.1), \[Cabbage for Android\](https://github.com/rorywalsh/cabbage\_v1\_old/releases/download/v1.0.0/Cabbage-release.apk) (Csound 6.08), and CsoundUnity 3.4.1 (Csound 6.18) (sorry but I failed to build the Android repo)
> 
> See this \[Cabbage thread\](https://forum.cabbageaudio.com/t/pitch-issue-on-android-with-sf2-sequence-playback/3926) for more info.

it should have been fixed in this commit:

> <https://github.com/rorywalsh/CsoundUnity/commit/32b7f100657701d4d8f17484ba0054c71faba32f>
>
> Fixes sound font issues on Android.
> Also added x86 libraries

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 09:40 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/106 "2024-11-18T09:40:12Z")

</div>

it’s the Build part that wipes the files, not the Run part. and i can verify, as i did copy them over to the same path earlier via AFT.

i just looked at the samples and grabbed a couple that seemed cool and i don’t see any sample marked as SFDIR. if you could link that i’d appreciate it! especially if plays easily or autoplays.

i also remember that thread on sf2 files - but as i recall, the audio was weird and transposed i think? but it wasn’t about not hearing any audio at all, unless i’m misremembering. so i don’t think my issue is related.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:44 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/107 "2024-11-18T09:44:37Z")

</div>

Yes sorry, the sample related with sfonts is under Environment Vars.

Here is a project that runs on the Quest (just tried on a Quest 2)

I just imported the sample and built with IL2CPP on and for ARM64

> **[TestSfonts.zip](https://drive.google.com/file/d/1Xtr9KnpX2hA_yuVscGtspE1gEk0S4dxF/view?usp=drive_link)**
>
> Google Drive file.

 ![image](https://forum.cabbageaudio.com/uploads/default/original/2X/7/733d201dbc20cbfd5e6b8f78de1ebec72e18273e.png)

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:46 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/108 "2024-11-18T09:46:21Z")

</div>

> [@metaphysician](#):
>
> i also remember that thread on sf2 files - but as i recall, the audio was weird and transposed i think? but it wasn’t about not hearing any audio at all, unless i’m misremembering. so i don’t think my issue is related.

Sometimes sfonts have different volume ranges, so I guess it’s worth trying other values for volumes, as if you don’t get any error it could simply be that the volume is too low

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 09:49 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/109 "2024-11-18T09:49:45Z")

</div>

😀 mille grazie G! i will test this in a few hours.

interesting though about the volume - i just figured if the volume is fine in the editor it should be fine in the build. i checked to make sure no sources were 3D. at any rate i just need to find if i’m going crazy or there really is an issue on Quest3.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:50 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/110 "2024-11-18T09:50:46Z")

</div>

> [@metaphysician](#):
>
> it’s the Build part that wipes the files, not the Run part. and i can verify, as i did copy them over to the same path earlier via AFT.

I just tried to Build and Run after duplicating one of the Sound Fonts in Windows. The folder doesn’t seem to be touched by the Build process

 ![image](https://forum.cabbageaudio.com/uploads/default/original/2X/9/9751f657ec50fbdb020e1dbe7a6c519487bc09c6.png)

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:53 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/111 "2024-11-18T09:53:39Z")

</div>

To be honest, I think that there is still an issue with pitches (it seems slightly higher than I would expect, like a tone higher).  
This could be an issue with the sampling rate being different on the Android device (for example on my Pixel 4a Csound runs at 28000Hz)  
But you can handle that rescaling the pitch in some way

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 09:57 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/112 "2024-11-18T09:57:26Z")

</div>

well it is on my Mac. those files were there. i didn’t touch the folder and only did Build And Runs. once i finally got logcat to print ANYTHING from Unity i ran the ChatGPT script you sent, and that showed no files but the expected path as listed by Unity API. went back to check via AFT and they weren’t there. so somewhere along the line the folder got replaced. i haven’t been doing serial builds but i am replacing the previous build several times.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 09:59 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/113 "2024-11-18T09:59:27Z")

</div>

Uhm that is strange.  
I will test on my Mac now

Edit:  
Android File Transfer on the Mac is a nightmare

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 10:06 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/114 "2024-11-18T10:06:37Z")

</div>

i’d say ‘very limited’ but it does work. but there is the matter of whether a different app accessing the quest maybe doesn’t play well with Unity?

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 10:07 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/115 "2024-11-18T10:07:23Z")

</div>

Files are still there after build and run

 ![image](https://forum.cabbageaudio.com/uploads/default/original/2X/0/063096adeda0f50e6f17b2364091b4eb5cfb56e4.png)

Note: this is my phone

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 10:08 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/116 "2024-11-18T10:08:49Z")

</div>

Btw on the Quest you should really use Meta Quest Developer Hub  
[https://developers.meta.com/horizon/documentation/unity/ts-odh/](https://developers.meta.com/horizon/documentation/unity/ts-odh/)  
Download it from here:  
[https://developers.meta.com/horizon/downloads/package/oculus-developer-hub-mac](https://developers.meta.com/horizon/downloads/package/oculus-developer-hub-mac)

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 10:11 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/117 "2024-11-18T10:11:08Z")

</div>

yeah i have it. i find it a mixed bag in terms of needing it. obviously all official Meta builds i use it, but it’s more than once forgotten the Q3 and i have to manually register it. tends to sour my opinion of it.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 10:14 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/118 "2024-11-18T10:14:27Z")

</div>

I just reinstalled it and apparently there’s no way to put files into an app folder 😑  
So I guess it’s possible that the folder gets erased on build.  
Then you will definitely need the script that copies the soundfonts there on start.

---

<div class="post-metadata">

**Author:** ![metaphysician](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/metaphysician/32/549_2.png) [@metaphysician](https://forum.cabbageaudio.com/u/metaphysician)\
**Post date:** [18 November 2024 10:16 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/119 "2024-11-18T10:16:32Z")

</div>

…and which works great BTW, after my light editing.

---

<div class="post-metadata">

**Author:** ![giovannibedetti](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/giovannibedetti/32/4146_2.png) [@giovannibedetti](https://forum.cabbageaudio.com/u/giovannibedetti)\
**Post date:** [18 November 2024 10:24 UTC](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933/120 "2024-11-18T10:24:12Z")

</div>

Great!

Btw there’s another better way to see the content of the folder:

```
./adb shell

```

(on Mac)

```
adb shell

```

(on Windows)

With this you can browse the device folders

 ![image](https://forum.cabbageaudio.com/uploads/default/original/2X/4/441b95c39fa7a1e8353a6373d1a959c5c3741637.png)

[Previous page](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933.md?page=5)

[Next page](https://forum.cabbageaudio.com/t/returning-to-csoundunity-and-updating-old-project/3933.md?page=7)
