Chapter 9. Xylophone

image with no caption

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 then—with 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

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

The Xylophone app UI
Figure 9-1. The Xylophone app UI
  • 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 forget what notes you played earlier so 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”, and also set the screen’s title to “Xylophone”. Open ...

Get App Inventor now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.