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

Making use of ofParameters #8

Open
thomasgeissl opened this issue Dec 22, 2015 · 7 comments
Open

Making use of ofParameters #8

thomasgeissl opened this issue Dec 22, 2015 · 7 comments

Comments

@thomasgeissl
Copy link
Contributor

Can we make use of ofParameter?
I would like to add ofParameterGroup and a getter to ofxSoundObject base class.
This would allow us to create GUIs in a very fast way.

Any cons?

@roymacdonald
Copy link
Owner

I'd rather keep the base class clean and simple as it is. There's no need to add a ofParameterGroup to the base class, as it will be useless without subclassing. In the case that you want to have all your ofxSoundObjects as pointers in an array and from there call the parameter group I'd recommend you to make a new subclass with the ofParameterGroup and anything else you might consider necessary. Also any parameter change is a very possible thread problem, as the audio runs on a different thread. adding a mutex will not solve this as you'll need to add a callback to make use of it. if you happen to add parameters to your own subclass, add the corresponding call back for the parameters and flag an update so the next time the audio is processed the parameters are updated. It might sound crazy but is the only way to keep it thread safe. If you have a different idea just let me know :)
best!

@thomasgeissl
Copy link
Contributor Author

Hey Roy, thanks for the explanation. Sounds trickier than i thought. I will think about it.

@thomasgeissl
Copy link
Contributor Author

I added an ofParameterGroup to my custom base class and the very first step in my processBlock function is to get the values from the parameters and store them in a variable. While iterating the buffer i use the value from the variable instead of the parameter which might have already changed again.

@roymacdonald
Copy link
Owner

Hey thomas, right that's a possible solution.
I still think that there shouldn't be a parameterGroup within the ofxSoundObject class.
take care

@thomasgeissl
Copy link
Contributor Author

Just a little note on this, the current solution is not thread safe either.
Example: we can call DigitalDelay::setFeedback(float value); during processing.
How would we avoid this?

@roymacdonald
Copy link
Owner

Hi, you're right! I guess that using another local variable should work, as you described. Although I'm not completely sure if in the particular case of the delay feedback it would be a problem to have it's value changed during processing. Think of the delay as a real analog delay. Whenever you changed any knob it´s effect is inmediate -there's no need to wait for the next chunk of data to be able to use the new value of the parameter. Hence, maybe it's enough just to have a mutex whithin the setFeedback function. I think that this should be analyzed for each particular case in order to determine the best solution.
thanks for your enthusiasm!

@thomasgeissl
Copy link
Contributor Author

Yes, I also think that this can be ignored in most cases.

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

No branches or pull requests

2 participants