Ok I pushed the CsoundUnityChild Editor.
It’s working, but needs tests.
I still have the same clicks/pops of this morning, i’m on macOS 10.13.3, didn’t try on Windows
Edit: ehm, the message of the commit is wrong
CsoundUnity Package (UPM) development
Yeah as far as I know, URP/ HDRP have to be set for the entire project, so use of VFX/ ShaderGraph might not be a simple out-the-box until scriptable RP’s become the norm.
However, you can get some good results by just using the inbuilt particle system. But regardless of the pretty visuals, I think the goal should be to design an engaging “instrument” with a few available notes (either triggered or on loop), and giving user control over modulating parameters. Maybe something along the lines of my first attempt at doing this stuff last year, here’s a demo: https://www.youtube.com/watch?v=yL9-VBAgPa4 (this is using a lot of the Shuriken particle system)
btw, I ran a few tests with the latest dev2, works great! Though you’ll have to explain to me in layman terms how some of these new classes apply, i.e CsoundUnityChild.
I’m still getting sound issues with the old OscBankSynth which I’m using as a main synth on a new project.
(do turn your volume way down )
I tried to recreate the scene from scratch and it is working!
But remains an issue for the CsoundUnityChild, the settings of the audiochannel to pass is reset on play.
A CsoundUnityChild instance can receive an audio channel from the master CsoundUnity.
In Csound you can create a bus channel with chnset, like this:
instr 2
a1 oscili .5, 440
a2 oscili .5, 882
chnset a1, "oscil1"
chnset a2, "oscil2"
endin
When a csd with some chnset opcodes is choosen in the master CsoundUnity, this scans and saves the channels, in this case “oscil1” and “oscil2”
If you add a CsoundUnityChild, drag the above CsoundUnity gameobject in the Csound Unity Game Object field. After choosing the AudioSettings (MONO and STEREO) you could choose the available audio channels from the dropdown.
So CsoundUnityChild acts as an AudioSource that receives updates from the master CsoundUnity.
And the spatialization is done by Unity.
This is great! Very cool visuals! And sound too!
For the OscBankSynth problem we should analyse it deeper to understand why these things happen. And surely we will find some bug in the CsoundUnity editor, I feel something doesn’t get initialized or updated sometimes! I’ll dig into it as soon as I can!
It looks like the .csd channels are not being parsed, @giovannibedetti, is there a reason why this was commented out again?
Or did we just mess it up again by accident
Yes we don’t need the parse again on Start, this is done just when setting the csd via editor, or when a change happens on the csd file by an external editor (caught by the filewatcher)
So channels are serialized by the editor and should be saved. If this is not true we must ensure the editor saves them correctly, I still have a feeling something could go wrong.
In fact there’s a potential concurrency problem if these channels are set at the same time by the editor and by the filewatcher. I should add a lock somewhere.
I think the sound that @Alex_Emile is getting now are the same as the problem he was getting before. That would point to it being a problem with default values for the channels?
Yes I think so, very likely
I’m updating the CsoundUnityChild editor, when done I’ll look again in the CsoundUnity editor, to see what can be the problem. I think the flow could be simplified, now I am updating the serialized properties one by one! Absurd, since this should be just CsoundUnity.SetCsd, and then serializedObject.ApplyModifiedProperties();
but it doesn’t work in all cases!
For now we could bypass the filewatcher, to be certain that the editor works correctly.
And then reintroduce it afterwards
Btw, I just pulled you latest changes. Great stuff! How are you populating the drop down menus with channels? It’s deadly but I’m too lazy to look at your source code!
I can obtain the CsoundUnity script like this:
SerializedProperty m_csoundUnityGO;
var csdORV = (GameObject)m_csoundUnityGO.objectReferenceValue;
var csd = csdORV.GetComponent<CsoundUnity>();
and the available channels like this:
csd.availableAudioChannels
Now I did some mods because it was updating the values every update of the editor, and when you go to play mode the choices are overwritten!
But it’s interesting you can change the selection of the audiochannel when in play, without any problem!
Ah, so you’re parsing the .csd file for audio channels. Nice.
I don’t get any audio when I play my CsoundUnityChild scene? Strange?
Do you see the options? Did you select them?
The problem is hiding in CsoundUnityChild from line 97 to 103, where we update the namedAudioChannelData
Give me ten mins I’ll update the CsoundUnityChild
Great. In the meantime I’m going to start a new thread about the examples scenes we can add.
I still have problems. broke everything.
I’ll look into it as soon as I have some quiet time!
The key is to serialize everything, or strange things happen.
When in play mode the editor is totally recompiled, so I have some fields that get initialized again.
This could lead to problems as @Alex_Emile is facing.
Hope tomorrow I’ll have some time!
No problem. Don’t be stressed!
It seems to be working now, already pushed! (Filewatcher is disabled to avoid distractions)
Going to grab it now and take it for a short test run…
It’s working now. But I’m still getting some glitches in the CsoundUnityChild examples. It’s odd, it sounds more like a problem with CPU than audio? I launched the Profiler and I see spikes around the times of the clicks. I’ve never used the Unity Profiler before so I’m not sure just how to dig deeper.
p.s. the localisation is working fine, so long as we set the spatial blend to full 3D. We should probably set this in the script, as it will most likely be the default.
[edit] I went back to the Profiler and looked at the audio stuff. I don’t see anything in there that might be a problem.