Playgrounds icon indicating copy to clipboard operation
Playgrounds copied to clipboard

Use of unimplemented initializer 'init(property:value:range:taper:format:frame:callback:)' for class 'AudioKitUI.AKSlider'

Open ozgurshn opened this issue 4 years ago • 5 comments

AkSliders in Playgrounds give this error. Which init method shoud I use? Fatal error: Use of unimplemented initializer 'init(property:value:range:taper:format:frame:callback:)' for class 'AudioKitUI.AKSlider'

For example, this init is called in Playground.

AKSlider(property: "Modulating Multiplier",
                 value: fmBank.modulatingMultiplier,
                 range: 0 ... 2
) { multiplier in
    fmBank.modulatingMultiplier = multiplier
}

Xcode and Pod versions: Xcode 12.2

  • AudioKit (4.11.2):
    • AudioKit/Core (= 4.11.2)
    • AudioKit/UI (= 4.11.2)
  • AudioKit/Core (4.11.2)
  • AudioKit/UI (4.11.2):
    • AudioKit/Core

ozgurshn avatar Jan 11 '21 06:01 ozgurshn

I tried to downgrade to 4.11.1 as I read this issue https://github.com/AudioKit/Playgrounds/pull/15 but still the same error exists .

ozgurshn avatar Jan 11 '21 07:01 ozgurshn

I also cannot get the playgrounds to work, and am having trouble finding where the akslider version they are referencing exists.

ViaJables avatar Jan 19 '21 09:01 ViaJables

I was able to work around this by specifying the color: parameter.

This is a line from the playground that was breaking.

addView(AKSlider(property: "Drums Volume", value: drums.volume) { sliderValue in
            drums.volume = sliderValue
        })

This is the same line fixed by adding a color: parameter.

addView(AKSlider(property: "Drums Volume", value: drums.volume, color: .red) { sliderValue in
            drums.volume = sliderValue
        })

I needed to do this for every AKSlider being created.

scottpuhl avatar Jan 25 '21 17:01 scottpuhl

@scottpuhl -- confirming that fix! All the params for the AKSlider init have default values, and, as your example demonstrates, they don't all need to be set on instantiation.

  public init(property: String, 
        value: Double = 0.0, 
        range: ClosedRange<Double> = 0 ... 1, 
        taper: Double = 1, format: String = "%0.3f", 
        color: AudioKitUI.AKColor = AKStylist.sharedInstance.nextColor, 
        frame: CGRect = CGRect(width: 440, height: 60), 
        callback: @escaping (Double) -> Void = { _ in })

Maybe it has something to do with the color param being set with a getter on the AKStylist singleton interface? I experimented with assigning AKStylist.sharedInstance.nextColor to an AKSlider instantiation in a playground and it worked fine.

   frequencySlider = AKSlider(property: "Frequency",
                               alue: oscillator.baseFrequency,
                               range: 0 ... 800,
                               format: "%0.2f Hz",
                               color: AKStylist.sharedInstance.nextColor
    ) { frequency in
        oscillator.baseFrequency = frequency
    }

sigmonkycnbc avatar Jan 29 '21 18:01 sigmonkycnbc

still not resolved on version 4.11.2

andy380743909 avatar Sep 21 '22 07:09 andy380743909