Lesson 6: Automated Playback
Goals for This Lesson
Learn how to create automated music playback using text data and GUI tools.
Specifically, this lesson covers:
- Automated output using text data
- Automated audio file playback driven by text sequences
- Beat programming with a GUI (rhythm machine)
- Overview of DAW integration via MIDI
Automated Output with Text Data
In Pd, you can use text data to output messages at specified timings in sequence. This makes it possible to play sounds automatically based on pre-written data.
Objects Used
| Object | Function |
|---|---|
text define | Define and store text data |
text sequence | Output text data line by line in order |
Text Data Format
Text data is written in the following format. Each line corresponds to one event, ending with a semicolon (;).
data c;
data d;
data e;
data f;Writing Text Data
- Write one piece of data per line
- Each line must end with a semicolon (
;) - Write the value after
datafollowed by a space - You can include multiple values on one line separated by spaces (e.g.,
data c 500;)
Patch Example

Write text data inside the text define object, and text sequence outputs it line by line.
Automated Audio File Playback via Text
By connecting the output of text sequence to else/play.file~, you can automatically play audio files in the order specified by the text data.
Key Messages
| Message | Action |
|---|---|
auto | Enable auto-play mode (automatically outputs the next line based on timing in the text data) |
bang | Output the next line manually (manual mode) |
line 0 | Return to the beginning |
Steps
- Write text data (file names, note data, etc.) inside
text define - Create a
text sequenceand specify the name of thetext defineas its argument - Send
autoto automatically output each line in order - Send
bangto output one line at a time manually - Send
line 0to return to the first line
Choosing Between auto and bang
auto: Advances automatically at time intervals specified in the text data. Best for BGM and automated playback.bang: Advances one step at a time with user interaction (e.g., pressing a button). Best for interactive performance.
Patch Example

Beat Programming with a GUI
The else/drum.seq object provides a graphical interface for programming rhythm patterns. You can click with the mouse to intuitively build beats.
Objects Used
| Object | Function |
|---|---|
else/drum.seq | Rhythm pattern GUI editor |
else/tempo | Set the tempo (BPM) |
route | Route output data to different instruments |
Setting the BPM
Use the else/tempo object to set the BPM (Beats Per Minute).
- Specify the BPM value as an argument (e.g.,
else/tempo 120) - You can also change the BPM dynamically by sending a number message
BPM Reference
| BPM | Feel |
|---|---|
| 60--80 | Slow (ballad) |
| 100--120 | Medium (pop) |
| 120--140 | Somewhat fast (dance music) |
| 140--180 | Fast (drum and bass) |
Building a Rhythm Machine
- Create an
else/drum.seqand program rhythm patterns in the GUI - Set the BPM with
else/tempo - Use
routeto distribute each track's output (kick, snare, hi-hat, etc.) - Connect audio sources (
else/play.file~or synthesizers) to each track
Patch Example

Automated Playback via MIDI with a DAW
Reference Information
Pd can also connect to DAW (Digital Audio Workstation) software using MIDI (Musical Instrument Digital Interface).
Overview
MIDI is a standard protocol for exchanging performance data between electronic instruments and computers. Pd can send MIDI messages to or receive them from external DAWs such as Ableton Live and GarageBand.
Using MIDI in Pd
- MIDI output: Use the
noteoutobject to send MIDI notes - MIDI input: Use the
noteinobject to receive MIDI notes from external sources - Virtual MIDI bus: On macOS, you can create a virtual MIDI bus in "Audio MIDI Setup" to connect Pd and a DAW
Scope in This Course
MIDI integration is an advanced topic. We will only cover the overview in this course, but feel free to consult the instructor if you want to use it in your project.
Practice Exercises
Exercise 1: Play "Frog Song" One Note at a Time with the A Button
Use text define and text sequence to prepare the melody of "Frog Song" (Kaeru no Uta), and create a patch that plays one note each time the micro:bit's A button is pressed.
Hint
- Write the note data in
text define(e.g.,data c;data d;data e;data f;...) - Use the
bangmessage ontext sequenceto output one note at a time - Send
bangwhen the A button is pressed - Connect the output note data to
osc~or an audio file player - Consider using
line 0to return to the beginning when the song ends
Exercise 2: Rhythm Machine with Tilt-Controlled Tempo
Create a rhythm machine using else/drum.seq, and make the BPM (tempo) change based on the micro:bit's tilt.
Hint
- Create rhythm patterns with
else/drum.seq - Control the BPM with
else/tempo - Get the micro:bit's tilt (accelerometer) value
- Map the tilt value to a BPM range (e.g., 60--180)
- Use the
scaleobject to convert the value range - If the value changes too rapidly, use
else/lowpassto smooth it out