July 14, 2016
I am using the book and synth projects examples as a basis for my own first project. Overall, the structure is great.
I would like to have my synth respond to MIDI CC messages for parameter updates. At a high level, turn a knob on a MIDI controller, sending MIDI CC, update the filter cutoff. I am able to update the parameter, but the GUI is not updating.
I’m working within: AUSynth.cpp > HandleControlChange. With a call to Global->SetParameter(parameter, value), the synth engine operates on the new value. The GUI does not update to the new value, though. The GUI will reflect the new parameter value when re-launched. So, I’m confident that the AU parameter has been updated.
It looks like Global->SetParameter is not sending the AUEvent out. I’m struggling to find a way to do this within the context of the AUSynth.cpp.
I’m sure I’m just missing something simple here. But, theres seems to be lots of similarly named functions (AUParameterSet, AudioUnitSetParameter, AUParameterListenerNotify).
January 28, 2017
I am currently on vacation at the moment and don't have an exact solution for you but I will work on it when I get some free time afterwards. However in the meantime I can explain what is going on. The first thing is to familiarize yourself with section 2.45 of the synth book, especially the bullet points at the end of that section. Next, you should be aware that AU does not explicitly use any kind of thread synchronization object to guarantee thread safety between GUI and processing threads (of all the APIs, RackAFX (v6.8 and above), AU, AAX, and VST3, it is the only one that does this - the authors did not want to have the overhead of taking a mutex lock in the processing thread). I will be posting a major update in about 3 weeks that explains all of this for all the APIs.
AU *does* use atomic writes of global data so you are guaranteed that your parameter changes from the GUI will not be "half baked" however, by the same token, it is possible to write AU plugins that are not thread safe. In order to avoid that you must follow the Apple-approved paradigm for writing the plugin, which makes the plugin thread-safe *by design* -- this involves the somewhat convoluted Global Parameter/AU Event Listener scheme that the Synth book projects all follow.
In order for you to update the GUI from the AU object, you will need to post an AUEvent into the message queue, however to use the Apple-approved (and synth book) code you would technically also need to know the pointer of the GUI control that is being changed (which is an objective-C object) in addition to the GUI's AUListener object.
When I get back from holiday, I will work out a method to allow you to post a special message to re-sync the GUI to the Global Parameter(s) and post that here, hopefully in the next few weeks. It will also make a nice App Note for others with similar issues.
Also, one thing that I stopped doing around 2012 was implementing MIDI CC -> GUI updates within the plugin code as you are attempting here. The reason was that most DAWs have their own specific way of handling this internally (Ableton might be the best), and with VST3, it is actually part of the spec.
Most Users Ever Online: 36
Currently Online: W Pirkle
Currently Browsing this Page:
Guest Posters: 1
Newest Members:certvalue111, sobhana s, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc
Moderators: W Pirkle: 140
Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 140