audulus
(Taylor Holliday)
1
I have the following property wrapper:
@propertyWrapper
public struct Parameter {
var parameter: AUParameter?
public var wrappedValue: AUValue {
get { parameter?.value ?? 0.0 }
set {
parameter?.value = newValue
}
}
public var projectedValue: AUParameter {
return parameter!
}
public init() { }
}
This might be used in an object like so:
class Oscillator : Node {
@Parameter var frequency: AUValue
init() {
_frequency.parameter = self.getParameterByName("frequency")
}
}
What I'd like to do is have:
class Oscillator : Node {
@Parameter("frequency") var frequency: AUValue
}
And not need to look the parameter up by name in the init method.
Is this doable?
MarSe32m
(Sebastian Toivonen)
2
Add the key / name of the parameter to the Parameter initializer
public init(_ key: String) { self.parameter = getParameterByName(key) }
audulus
(Taylor Holliday)
3
getParameterByName isn't at global scope ... it's on the Node class. I added self. to make that clear.