TypedFullState

main

Typed fullState collection for AUv3 components
bradhowes/typedfullstate

CI COV License: MIT

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])
  • Bool
  • Data
  • Date
  • Dictionary ([String: TypedAny])
  • Double
  • Float (AUValue)
  • Int
  • String
  • UUID

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Nov 13 2022 17:49:35 GMT-0500 (GMT-05:00)