Congratulations to the AudioKit team for releasing version 2.0 of their amazing audio libraries for iOS and OS X. Version 2 includes a load of updates including Playgrounds for developing audio code in realtime and, excitingly for me, some real time graphing classes.

I've added their AKAudioOutRollingWaveformPlot to the background of my SpriteKit/AudioKit physics based generated music application. The wiring up is super easy: first, I have to add the header file for the class to my bridging header file:

        #import "AKAudioOutputRollingWaveformPlot.h"

Then I create an instance of AKAudioOutputRollingWaveformPlot and add it as a child to my view:

        let rollingWaveformPlot = AKAudioOutputRollingWaveformPlot()
        view.addSubview(rollingWaveformPlot)

As with any visual component, I need to ensure it's properly sized:

        rollingWaveformPlot.frame = CGRect(x: 0, y: topMargin + toolbarHeight, width: view.frame.width, height: sceneHeight)

Finally, I bind the visual component to the AKManager 

        AKManager.addBinding(rollingWaveformPlot)

...and that's all there is to it! For my app, I wanted to render the graph visualisation as a more subtle effect than a "harsh" plot, so I popped a UIVisualEffect of type UIBlurEffect over the top and got the result you can see in the video above.

If you like the "radiating visual pulses" effect that I use for collisions and when nodes are deleted by dragging to either side, I've now implemented it as an extension to SKShapeNode and it can be found in my Extensions file here. I've also added a handy class function onto CGMutablePath for creating equilateral triangles in the same file.

The source code for this project is all available in my GitHub repository here and a full breakdown of AudioKit's features is available here.

Finally, a big thanks to discchord for this blog post regarding a recent screen recording of this app.



0

Add a comment

About Me
About Me
Labels
Labels
Blog Archive
Loading