Challenge: Create a musical instrument in Swift Playgrounds
June 8, 2021
The first part to composing a musical masterpiece? Making your own instrument from scratch! In this challenge, you’ll use graphical tools to create a musical instrument in Swift Playgrounds and give a performance that will leave your audience floored (and waiting for an encore)!
Begin the challenge
The Swift Playgrounds app includes several Playgrounds books with starting points to help you explore different coding concepts and ideas. For this challenge, we're asking you to use the Sonic Create book in the Swift Playgrounds app to build a musical instrument of your own creation. Now, this musical instrument doesn’t have to look or sound like an ordinary instrument — it could be a bunch of crystal pianos laid out like piano keys, or a beat-maker board that plays notes on a constant loop. Sonic Create comes with an entire set of sounds and instruments, as well as great graphics for building the look and feel of your instrument.
If you’d like to get in a little musical practice before venturing into the virtual instrument-making world, we recommend first downloading the Sonic Workshop challenge book from Swift Playgrounds, where you can explore using graphics to play sounds and loops. Once you’re familiar with some of the API, you can start creating graphic instances to respond to touch or drag events. You can also check out some of the musical examples provided in the Sensor Create book (iPad only), including “Using Light to Play Sound,” “Synesthesia,” and “Beat Maker.”
Ready to build your own instrument? Think about how you might want to make music with only these objects to guide you, and the kinds of sounds you want to create. Consider how the code you write influences the objects — their placement, their resonance, and the kinds of music you can make. How can you design your instrument to be intuitive, and also to invite people to explore and play? As a developer, the tools you make for yourself or others can completely change how other people use those tools and experience the world. (Pretty cool when you think about it!)
Once you’ve created something you like, share it with community on the Developer Forums.