Cabbage Logo
Back to Cabbage Site

CsoundUnity Package (UPM) development

It’s working fine here with my simple test. Let me try one of Iain’s instruments…

I am using the simplest instr:

 instr 1
   a1 oscil .2, chnget:k("freqSlider"), 1
  outs a1, a1
endin

Mine isn’t much more complex:

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
rslider bounds(296, 162, 100, 100), channel("gain"), range(0, 1, .4, 1, .01), text("Gain"), trackercolour("lime"), outlinecolour(0, 0, 0, 50), textcolour("black")
rslider bounds(10, 10, 60, 60) range(0, 1, 1, 1, 0.001), channel("hrm1")
rslider bounds(80, 10, 60, 60) range(0, 1, 0, 1, 0.001), channel("hrm2")
rslider bounds(150, 10, 60, 60) range(0, 1, 0, 1, 0.001), channel("hrm3")
rslider bounds(220, 10, 60, 60) range(0, 1, 0, 1, 0.001), channel("hrm4")
keyboard bounds(10, 82, 316, 70)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
print p4
kEnv madsr 0.1, .5, .6, 1
a1 oscili kEnv*chnget:k("hrm1"), cpsmidinn(p4)
a2 oscili kEnv*chnget:k("hrm2"), cpsmidinn(p4)*2
a3 oscili kEnv*chnget:k("hrm3"), cpsmidinn(p4)*3
a4 oscili kEnv*chnget:k("hrm4"), cpsmidinn(p4)*4
aMix = a1+a2+a3+a4
outs aMix*kEnv*chnget:k("gain"), aMix*kEnv*chnget:k("gain")
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
</CsScore>
</CsoundSynthesizer>

Note that when I change the .csd file I have to drag it over again to the component to update it. But I think you already know about this?

Yes the file watch is still not implemented. But it’s a matter of minutes. Do the sliders in the editor work? Do they keep their values when you click on another gameobject or after starting the scene?
Because for now the values are not sent to csound on start, so it should start with the default ones

Odd, when i try one of Iain’s instrument I just get high pitched whine…

There’s still something wrong under the hoods
But I know what is needed, trying a reboot! :rofl:

Yeah. But let me try selecting something in the scene mode once the game has started…

They can be used in game mode without any issues, but yeah, but it looks like none of the default values are actually getting through. I need to click a slider to get anything to work…

This might explain it:

        //channels = ParseCsdFile(csoundFilePath);

        //if (channels != null)
        //    //initialise channels if found in xml descriptor..
        //    for (int i = 0; i < channels.Count; i++)
        //    {
        //        csound.SetChannel(channels[i].channel, channels[i].value);
        //    }

Is there a reason this is commented?

Yes I have to add this somehow.
For now I just recreated the editor using SerializedProperties.
Btw I’m thinking of adding a text field and a button to send a test score directly from the CsoundUnity inspector

No I forgot to restore it!

It’s working fine for me now. I will try one of the more complex ones…

1 Like

Yes I have sound! :partying_face:

Yeah, still some work to do there I think. I think the comboboxes are not working. Did you use my code from two days ago? Although it was probably in the ‘old’ style…

Yes they’re not tested. I assumed an intslider was needed, since they represent something like options?

Yeah, I’m just taking a look now…

[edit] I’m getting issues on line 166 in the editor cs ‘type is not a supported int value’

else if (type.Contains("combobox"))
{
    var min = cc.FindPropertyRelative("min").floatValue;
    var max = cc.FindPropertyRelative("max").floatValue;

    EditorGUI.BeginChangeCheck();
    chanValue.intValue = EditorGUILayout.IntSlider(label, chanValue.intValue, min, max);
    if (EditorGUI.EndChangeCheck() && Application.isPlaying)
    {
        csoundUnity.SetChannel(channel, chanValue.floatValue);
    }
}

because the channel value comes like a float maybe…
we should build the dropdown menu it should not be very difficult if we parse the string correctly!

Is there a drop down menu widget? That would be great. When I started this, many many years ago there was only buttons and sliders :laughing:

The parsing code is already there at the bottom of CsoundUnity.cs