AudioKit / Playgrounds

The AudioKit Playground Book for iPad Playgrounds and Xcode Playgrounds
http://audiokit.io
192 stars 37 forks source link

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

Open ozgurshn opened 3 years ago

ozgurshn commented 3 years ago

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

ozgurshn commented 3 years ago

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 .

ViaJables commented 3 years ago

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

scottpuhl commented 3 years ago

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.

sigmonkycnbc commented 3 years ago

@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
    }
andy380743909 commented 1 year ago

still not resolved on version 4.11.2