and updated:
A few years ago, I developed a Data Tube class. This class models a fixed-latency queue. That is, the queue fills up to a certain length (in this example, that comes to 100 samples). It then auto-pops each time a new item is added.
This behavior forces the collection to store a fixed number of items, creating a moving window across a set of newly generated data points.
Today, I decided to use data tubes along with an AV foundation recording instance. Basically, I just took audio samples over time, and used those average levels to drive a UIBezierCurve.
Everything is connected to a standard CADisplayLink. It creates the heartbeat for the algorithm and tells the view when to sample and re-draw the curve.
You see the results in the video at the top of this post.
In the bigger picture, this is part of my effort to build a motivation section of the iOS Drawing book. Specifically, I want to answer, “Why draw?”. This sample shows the flexibility created by building your own feedback by using simple drawing primitives. I think it’s pretty nifty.
Note: The YouTube compression makes the output look a lot glitchier than it looks on an actual device.
One Comment
any chance of having access to the source code?