TypedFullState
This Swift package is a typed container for values stored in an AUv3 fullState attribute of an AUAudioUnit entity. This attribute is defined by Apple to be a dictionary of String keys and Any values. In comparison, the TypeFullState dictionary is a dictionary of String keys and TypedAny values, which is an enum of supported types.
Usage
Here’s a simple example of moving from AUAudioUnit.fullState value ([String:Any]) to a typed representation, conversion to/from JSON and finally setting the same attribute with a value derived from a typed representation:
let state = sampler.auAudioUnit.fullState!
let typedState = try! state.asTypedAny()
let encoded = try! JSONEncoder().encode(typedState)
...
let decoded = try! JSONDecoder().decode(TypedFullState.self, from: encoded)
let fullState = FullState.make(from: decoded)!
sampler.auAudioUnit.fullState = fullState
If there are any problems with types, the code raises a TypedAnyError.invalidType exception.
The types that are currently supported for values are:
Array([TypedAny])BoolDataDateDictionary([String: TypedAny])DoubleFloat(AUValue)IntStringUUID
0 Comments