Swiftpack.co - bradhowes/typedfullstate as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bradhowes.
bradhowes/typedfullstate 1.1.0
Typed fullState collection for AUv3 components
⭐️ 0
🕓 1 week ago
iOS macOS tvOS
.package(url: "https://github.com/bradhowes/typedfullstate.git", from: "1.1.0")

CI COV License: MIT


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.


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


Stars: 0
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics