Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some initial parameter values not received (Unity) #254

Open
finbarw opened this issue Mar 2, 2018 · 6 comments
Open

Some initial parameter values not received (Unity) #254

finbarw opened this issue Mar 2, 2018 · 6 comments
Labels

Comments

@finbarw
Copy link

finbarw commented Mar 2, 2018

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.

synth1.zip

@diplojocus
Copy link
Contributor

diplojocus commented Mar 2, 2018

@chuckyOHare can you post a URL link to your heavy patch?

@finbarw
Copy link
Author

finbarw commented Mar 2, 2018

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.

@finbarw
Copy link
Author

finbarw commented Mar 10, 2018

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?

@diplojocus
Copy link
Contributor

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!

@diplojocus
Copy link
Contributor

diplojocus commented Mar 10, 2018

poolKb is the internal patch message memory pool
inQueueKb is the input parameter memory pool
outQueueKb is the output parameter memory pool

@finbarw
Copy link
Author

finbarw commented Mar 10, 2018

It works! Thanks a million, I definitely wouldn't have found that myself. Onwards at last!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants