Saving non-parameter based presets in AUv3 extensions

Hello!


I'm trying to allow hosts to save presets for my AUv3 extension. Currently I save presets as files within the extension itself, but I'd like to support state saving within hosts. My problem is that I can't really reduce my preset format down to parameters in the parameter tree. Can anyone point me in the right direction? I'm happy to clarify anything further.

Post not yet marked as solved Up vote post of JHostetler2 Down vote post of JHostetler2
2.6k views

Replies

Hi @JHostetler2, did you find a way to solve this? I have exactly the same issue. Did you have to transform everything you wanted to save into parameters in a parameter tree and then use the fullStateForDocument to be able to save everything? If so, how is the fullStateForDocument used? I really can't find good documentation of how to use this. Thanks.

This is an old post but maybe someone is still looking for a solution. I found that you can just override the fullStateForDocument property and just archive your settings using a Dictionary. No need to play with parameter trees if you don't need your settings to be modified by the Host.


// Save an NSString named setting.
- (NSDictionary<NSString *,id> *)fullStateForDocument {
    NSMutableDictionary *state = [[NSMutableDictionary alloc] initWithDictionary: super.fullStateForDocument];
    NSDictionary<NSString*, id> *settingsToSave = @{@"setting": setting,};
    state[@"savedSettings"] = [NSKeyedArchiver archivedDataWithRootObject:settingsToSave requiringSecureCoding:NO error:nil];
    return state;
}


// Retrieve settings
- (void)setFullStateForDocument:(NSDictionary<NSString *,id> *)fullStateForDocument {
    NSData *data = (NSData *)fullStateForDocument[@"savedSettings"];
    NSDictionary *savedSettings = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSDictionary class] fromData:data error:nil];
    setting = (NSString *)savedSettings[@"setting"];
}