Updating Synth Parameters from MIDI CC in an AU | Synth Book Questions | Forum


Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Updating Synth Parameters from MIDI CC in an AU
New Member
July 23, 2016 - 7:48 pm
Member Since: July 14, 2016
Forum Posts: 1
sp_UserOfflineSmall Offline

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).

July 26, 2016 - 6:37 pm
Member Since: January 29, 2017
Forum Posts: 693
sp_UserOfflineSmall Offline

Hi msedran

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.

- Will

Forum Timezone: America/New_York

Most Users Ever Online: 152

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Chaes: 56

Skyler: 48

StevieD: 46

Derek: 46

Frodson: 45

Peter: 43

TheSmile: 43

Nickolai: 43

clau_ste: 39

jeanlecode: 37

Member Stats:

Guest Posters: 2

Members: 784

Moderators: 1

Admins: 6

Forum Stats:

Groups: 13

Forums: 42

Topics: 850

Posts: 3372

Moderators: W Pirkle: 693