Chapter 9. Xylophone

Figure 9-0.

It’s hard to believe that using technology to record and play back music only dates back to 1878, when Edison patented the phonograph. We’ve come so far since thenwith music synthesizers, CDs, sampling and remixing, phones that play music, and even long-distance jamming over the Internet. In this chapter, you’ll take part in this tradition by building a Xylophone app that records and plays music.

What You’ll Build

The Xylophone app UI
Figure 9-1. The Xylophone app user interface

With the app shown in Figure 9-1 (originally created by Liz Looney of the App Inventor team), you can:

  • Play eight different notes by touching colored buttons on the screen.
  • Press a Play button to replay the notes you played earlier.
  • Press a Reset button to make the app clear any notes you played earlier so that you can enter a new song.

What You’ll Learn

This tutorial covers the following concepts:

  • Using a single Sound component to play different audio files.
  • Using the Clock component to measure and enforce delays between actions.
  • Deciding when to create a procedure.
  • Creating a procedure that calls itself.
  • Advanced use of lists, including adding items, accessing them, and clearing the list.

Getting Started

Connect to the App Inventor website and start a new project. Name it “Xylophone”, ...

Get App Inventor 2, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.