AudioKit / Playgrounds

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

More information around .playgroundbook limitations #1

Closed ythecombinator closed 7 years ago

ythecombinator commented 7 years ago

This isn't a technical issue with AudioKit or this .playgroundbook themselves–it's more about clarifying some beginner questions I have 😃.

Well, I've just started playing with AudioKit's APIs–and I'm lovin' them all–aiming to implement a .playgroundbook project which consists of allowing readers to design and visualize–e.g. through { sine, square, sawtooth }waves form plots– musical algorithms making use of audio streams generated with math functions–e.g. the following code:

func sineWave(t: Double) -> Double {

    func sin(α: Double) -> Double {
        return Foundation.sin(2.0 * M_PI * t * α)
    }

    return sin(α: 440.0)

}

where the second returned function gets run 44000 times per second and returns a Double between -1 and 1 which represents the wave amplitude.

After reading the APIs–and observing a few regular playgrounds of yours–I noticed I should use a few classes–mainly responsible for oscillators–e.g.:

Just like you did in awesome exemples here:

captura de tela 2017-03-23 as 00 15 38

But, what you said here scared me a bit:

[...] *It is not a complete copy of AudioKit's functionality and only contains a fraction of the playgrounds available from within Xcode. There are no synthesis or analysis playgrounds [...]

My point is: is there any known issues related to using the APIs used here in .playgroundbooks? Would AKOscillator, AKPlaygroundView, AKOutputWaveformPlot–and others–be suitable in such special kind of playground? Have you tried anything like this before? Any suggestions?

Also, I'm kinda a newbie with Playground (Book)s as well 😭

Thanks!

aure commented 7 years ago

Yeah, it's a limitation on playground books, that you can't use anything but standard libraries or swift files. Since a lot of AudioKit is built with lightweight, fast, and audio-safe C processing, those parts are missing from the playground book. That includes the oscillators unfortunately. Now, we all hope that Apple will allow us to add C libraries to playground books someday, we're not exactly holding our breaths.

ythecombinator commented 7 years ago

Hey @aure, thanks for the amazingly fast feedback–and sorry for the delay in answering as well.

I was really excited about using AudioKit in my .playgroundbook–shame on you, Apple.

As a workaround, I thought about using some set of audio stream generation + stream waveform drawing JavaScript libs–which I've used before in other projects–inside a WKWebView–but it seems that webviews can't actually play sounds in .playgroundbooks.

Anyway, I'm gonna study other alternatives–and, if you're interested, I'll tell you what I've discovered.

aure commented 7 years ago

Definitely, I'd love to know what you discover. Good luck!