Non-Audio TutorialIn the AudioKit Playgrounds, you'll learn a lot about processing audio, but we won't explain most other basic programming concepts that we'll use. So, here's a mini-tutorial of things that you should probably understand going forward.
You will always see the
import lines which bring in all of
AudioKit's functionality to the playground.
ALERT: This is also the line that most commonly shows an error "No such module" This just means you haven't built the framework yet, in which case pressing Cmd-B or accessing the "Product" menu and choosing "Build".
This main bundle line just helps the playground find the files (such as audio clips) it will be able to play and process.
To reference a file, you use the bundle from about and the
method that includes the name with the extension given in the
You are not limited to using the sound files provided with AudioKit, in fact
we encourage you to drag your own sound files to the Resources folder.
Ideally, to keep things running quickly, loopable 10-20 second
files are recommended. Many free loops are avaiable online at sites such as
looperman.com or freesound.org.
While we will do our best to annotate the playgrounds well, you can also get more information about the different code elements on the page by clicking on them and looking at the Quick Help Inspector. Or, you can also option-click on any class, method, or variable name to show information about that element. Try it with the lines below:
The following line keeps a playground executing even after the last line is run so that the audio elements that were started have time to play and make sounds for us to listen to.
The other ways we'll keep playgrounds running will by using
functions and infinite while loops.
You can view the waveform on the timeline for any playground page by adding the following lines if they don't exist. The plot does not usually appear by default because it takes significant power to draw the plots and we don't want your laptop's fan to fire up and drain your battery unnecessarily
Now that we are near the bottom of the screen (unless you have a majorly tall monitor!) we'd like to call your attention to the playground controls on the bottom left right below the navbar.
The first button toggles the console log which can be useful to look at when things go wrong. The second button is your play / stop button which is useful to control playback of the audio in the playground. If you click and hold on this button you will get a pop-up that will allow you choose between automatically running the playground or manually pressing play. They both have their reason. Automatic running is great for changing a parameter and quickly hearing the audio results. Manual Run is better for when you're in the middle of creating an audio system and you don't want to hear results until you're further along in the process.