Hello Guest

How to implement AUv3 User Preset Support [fullState]

  • 3 Replies
  • 407 Views
How to implement AUv3 User Preset Support [fullState]
« on: July 25, 2018, 06:45:24 PM »
Hi, I'm working on an AUv3 MIDI Plugin for iOS. It's working as expected right now and I'm about to release it.
Factory Presets are working fine in AU Hosts like AUM, Garageband, BM3 etc.
However, user presets are not working in AUM at all. It sometimes works sometimes not in Garageband.
As a developer, should I implement my custom user preset management system or hosts are responsible for this?
I saw fullState and fullStateForDocument parameters in AUv3 but I have no idea how are they working or are they related to user presets.
There are hardly any resource/tutorial for the subject on the net. So, I want to try asking here.

Thanks.
« Last Edit: July 26, 2018, 04:32:28 PM by cemolcay »

*

crony

  • **
  • 85
    • View Profile
Re: How to implement AUv3 User Preset Support
« Reply #1 on: July 25, 2018, 08:10:37 PM »
https://audiokit.io/

Some good examples here !

Re: How to implement AUv3 User Preset Support
« Reply #2 on: July 26, 2018, 04:31:45 PM »
Hi,

I'm already a member of AudioKit community :)
I seek answers in there but had no luck, unfortunately.

Re: How to implement AUv3 User Preset Support [fullState]
« Reply #3 on: July 28, 2018, 06:47:16 PM »
OK, I finally figured it out. You need to set/get fullState like this, for enabling user preset saving.

Code: [Select]
- (NSDictionary<NSString *,id> *)fullState {
  NSMutableDictionary *state = [[NSMutableDictionary alloc] initWithDictionary:super.fullState];
  NSDictionary<NSString*, id> *params = @{
                                          @"velocityParameter": [NSNumber numberWithInt:velocityParameter.value]
                                          };
  state[@"data"] = [NSKeyedArchiver archivedDataWithRootObject:params];
  return state;
}

- (void)setFullState:(NSDictionary<NSString *,id> *)fullState {
  NSData *data = (NSData *)fullState[@"data"];
  NSDictionary *params = [NSKeyedUnarchiver unarchiveObjectWithData:data];
  velocityParameter.value = [(NSNumber *)params[@"velocityParameter"] intValue];
}