Avatar

Please consider registering
Guest

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 sp_TopicIcon
Updating Synth Parameters from MIDI CC in an AU
No permission to create posts
July 23, 2016
7:48 pm
Avatar
msedran
New Member
Members
Forum Posts: 1
Member Since:
July 14, 2016
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
Avatar
W Pirkle
Admin
Forum Posts: 140
Member Since:
January 28, 2017
sp_UserOnlineSmall Online

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: 36

Currently Online: W Pirkle
4 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Derek: 41

Peter: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 478

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 29

Topics: 479

Posts: 1870

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