Some initial parameter values not received (Unity)
Hi there. I've built a basic synth and I'm trying to integrate it into Unity.
My issue is that a lot of the parameters don't receive their initial values.
I've been debugging for ages trying to figure out why some parameters receive their initial values and some don't. It appears to change depending on the receiver name. A receiver called OSC1_AMFreq will get its initial value while OSC1_level will not.
Am I missing something regarding naming conventions for receivers? Is there a maximum number of receivers which I'm exceeding?
I've surpassed my 40th compile already, most of which have just been trying to figure this out. Any help would be appreciated.
FYI, the initial values do appear correctly in the Unity editor, however I can hear that they don't actually transmit to the patch. I've double checked by sending their received values (or lack of) straight back into Unity's console.
@chuckyOHare can you post a URL link to your heavy patch?
Sure thing: https://enzienaudio.com/h/buckyohare/pd_test/ It's shamefully messy right now as I've been renaming and moving parameters around while I debug. I've since made a tidier version which I can upload if that helps.
Ok, I've made a patch which features all 46 of the receive objects which I'm using in my synth patch (minus all the synth stuff) and I've sent each one back into the Unity console via a unique send. https://enzienaudio.com/h/buckyohare/connection_test/ In this case, with an effectively blank patch, all receivers seem to work fine and receive their initial parameter values in Unity on play - I get 46 initial float values in the Unity console. However in my actual patch, with these same receivers connected to various inlets of my synth, I only get 28 initial values. https://enzienaudio.com/h/buckyohare/synth1/ I guess there must be something in my patch which is causing this error, any idea what?
Sorry I should have realised the potential solution much earlier!
In the generated *AudioLib.cs file change the following line (1481):
private void Awake() {
_context = new Hv_synth1_Context((double) AudioSettings.outputSampleRate);
}
to
private void Awake() {
_context = new Hv_synth1_Context((double) AudioSettings.outputSampleRate, 20, 20, 20);
}
Your patch works for me now in Unity.
Basically, there's a pre-allocated amount of memory that handles input messages on every process block. Because you've got a lot of parameters it'll reach the memory pool limit pretty quickly. The code change above increases the amount of memory allocated.
Here are the default values:
Hv_synth1_Context(double sampleRate, int poolKb=10, int inQueueKb=2, int outQueueKb=2)
This actually reminds me I should make a change to scale the default values based on the number of in/output parameters.
Sorry about any inconvience that caused!
poolKb is the internal patch message memory pool
inQueueKb is the input parameter memory pool
outQueueKb is the output parameter memory pool
It works! Thanks a million, I definitely wouldn't have found that myself. Onwards at last!