Cabbage Logo
Back to Cabbage Site

CsoundUnity Package (UPM) development

So I’m going to hard reset against the current dev2 branch and quickly add these. I’ll push to git and you can look at better organising things. I was just use string arrays and samples arrays, but perhaps dictionaries are better?

Yes I’ll look at it and polish it if needed

I just noticed I had 13 not pushed commits, I am very sorry, I’ll add the changes again after pulling your changes, I don’t know how this could happen

Don’t worry about it. I think this is the last big thing to polish up. I’ve a checklist in my mind of little things that we need to be sure to include!

I pushed by mistake, this is not my day

I can hard push my changes here, but I don’t want you to lose yours? You know what, i’ll simply send you my scripts, you can diff and update?

Yes send me the scripts, I’m sorry :pray:

https://github.com/rorywalsh/CsoundUnity/commits/dev2 I don’t see the commits I just pushed here is this normal?

It seems ok I have copies of my last version, I’ll add your changes and we’re good to go

Arrgghh, I’ve been called away on something else :rage:. Anyhow, I was going to implement this with List, but I think a list of dictionaries might be better. I’m going to just tidy some code that works for a single channel, and maybe you can look at scaling it? Sorry about that…

I have a feeling my GitHub Desktop was a bit out of mind, it was strange I didn’t pushed the commits about SetYieldCallback, since you were using that! So I just pushed nothing!
Yes no problem send me what you have then I’ll do the rest!

So should be safe pushing to the repo

So here is is working with a single hard code channel. In fact, working might be a bit of a stretch, but it’s certainly close. The audio might be dropping a sample every now and then, but I’m not too concerned about that. I’m still testing with the .csd file I sent earlier. i simple create a scene, add two cubes, on one place a CsoundUnity, and the other a CsoundUnityNode. I still can’t work out why I must manually add an AudioSource to my CsoundUnity Node component? Anyhow, let me know if you have any questions, and good luck!

CsoundUnity.cs (33.9 KB) CsoundUnityNode.cs (2.1 KB)

If you add the CsoundUnityNode script to a GameObject it should also add the AudioSource, at least for me it worked!

That’s good to know. Not sure what was going on here then…

A CsoundNode can have more than one namedAudioChannel?

public string[] GetChannelNames()
{
    return namedAudioChannelNames;
}

for (int i = 0, sampleIndex = 0; i < samples.Length; i += numChannels, sampleIndex++)
{
    for (uint channel = 0; channel < numChannels; channel++)
    {
        samples[i + channel] = (float)(namedAudioChannelData[sampleIndex] / zerodbfs);
    }
}

How do I set samples then? Is it possible?

I think we need a list of dictionaries? Each one should hold a channel name and a MYFLT[] of dsp buffer size?

So it’s possible, but how to update the samples in the CsoundUnityNode then?

The same way I was, ok we access the correct entry based on the channel names. I’ll get something together a little later. I can return to it in a half hour or so. You’ll still need to look over it!

No hurry, I am able to update the CsoundUnityNode as long as it has just one namedAudioChannelName, or how do I combine samples?

now it’s like this:

public void ProcessBlock(float[] samples, int numChannels)
{
    var namedAudioChannelData = csoundUnity.namedAudioChannelDataDict[namedAudioChannelNames[0]];

    for (int i = 0, sampleIndex = 0; i < samples.Length; i += numChannels, sampleIndex++)
    {
        for (uint channel = 0; channel < numChannels; channel++)
        {
            samples[i + channel] = (float)(namedAudioChannelData[sampleIndex] / zerodbfs);
        }
    }
}

it works, I still have clicks because I’m not updating correctly the csoundUnity.namedAudioChannelDataDict, but it works!

Did you push? Can you?

Ok I’ll push but there are indexes out of range:

Schermata 2020-05-14 alle 19.05.51