Meet Melody —
music tutoring with a real keyboard

ClawTutor's third subject is live. A second Raspberry Pi reads a USB MIDI keyboard, sends notes via MQTT, and an AI tutor named Melody gives real-time feedback — all through WhatsApp.

👨‍💻
Oliver Gruhn-van Dorp
Creator of ClawTutor

Beyond text quizzes

Maths and English work beautifully as text-based tutors. The kid types an answer, the tutor checks it, screen time is earned. Simple loop, clean feedback.

Music is different. You can't tutor someone on the piano through text alone. You need to hear what they're playing — or at least see the notes. That's where the MIDI interface comes in.

The setup: two Pis, one keyboard

The idea is straightforward: plug a USB MIDI keyboard into a second Raspberry Pi (a 3B+ is more than enough), run a Python script that reads the MIDI data, and send it to the ClawTutor Pi via MQTT. Melody — the Music tutor agent — picks it up and knows exactly what's being played.

┌─────────────────────┐ ┌─────────────────────┐ │ Musik-Pi │ │ ClawTutor-Pi │ │ │ │ │ │ ┌───────────────┐ │ │ ┌───────────────┐ │ │ │ Keyboard │ │ │ │ Mosquitto │ │ │ │ (USB MIDI) │ │ │ │ (MQTT Broker) │ │ │ └───────┬───────┘ │ │ └───────┬───────┘ │ │ │ │ │ │ │ │ ┌───────▼───────┐ │ │ ┌───────▼───────┐ │ │ │ midi_sender │──┼─────┼──│music_receiver │ │ │ │ (Python) │ │ MQTT│ │ (Python) │ │ │ └───────────────┘ │ │ └───────┬───────┘ │ │ │ │ │ │ └─────────────────────┘ │ ┌───────▼───────┐ │ │ │ Melody Agent │ │ │ │ (OpenClaw) │ │ │ └───────────────┘ │ └─────────────────────┘

The midi_sender.py runs on the Musik-Pi as a systemd service. It auto-detects USB MIDI devices — Korg, Yamaha, Roland, whatever you plug in. Every note press, every release, every velocity value gets published to MQTT topics on the ClawTutor Pi.

On the other end, music_receiver.py listens, aggregates the data into practice sessions, calculates how long the kid played, evaluates rhythm consistency, and feeds everything to the Melody agent inside OpenClaw.

What Melody actually does

Melody is a full tutor agent with her own personality, curriculum, and progress tracking — just like Matteo (Maths) and Nelly (English). But she has something the others don't: live instrument data.

She can see:

Here's what a typical Melody interaction looks like:

Kid
I practised for 10 minutes!
Melody 🎹
Wow, 10 minutes — awesome! 🎵 I saw 47 notes and your rhythm scored 72/100 — getting better! You earned 20 minutes of screen time. Keep the streak going and you'll get a bonus tomorrow! 🎶

She can also quiz on music theory — note names, intervals, chord types, composer trivia — the same way Matteo quizzes on fractions. Text-based quizzes for theory, MIDI data for practice. Both earn screen time.

Screen time for practice

The reward system for Music is slightly different from the quiz-based subjects. Instead of per-answer credits, it's time-based:

ActionReward
1 minute of practice+2 min screen time
Rhythm score ≥ 75/100+25% bonus
3+ day streak+20% bonus
Theory quiz (correct answer)+10 min

The bonuses stack. A kid who practices 10 minutes with good rhythm on a 3-day streak earns 30 minutes of screen time (20 base + 25% rhythm + 20% streak). That's a strong incentive to keep showing up at the keyboard.

Hardware: what you need

The Musik-Pi is intentionally cheap and simple:

Total cost if you don't already have a Pi: about €40–50. If you already have one lying around from another project, it's essentially free.

💡 No monitor needed. The Musik-Pi runs headless. Plug in the keyboard, power it up, and it auto-starts the MIDI sender via systemd. The kid just sits down and plays — Melody picks it up through WhatsApp.

MQTT under the hood

The communication uses three MQTT topics:

Mosquitto runs on the ClawTutor Pi as the MQTT broker. It's lightweight, stable, and needs zero maintenance once installed. The Musik-Pi connects over WiFi — no cables between the two Pis.

Why a second Pi?

USB MIDI needs a host device. The keyboard plugs into a USB port, and something has to read that data in real time. I could have connected the keyboard directly to the ClawTutor Pi, but I wanted the keyboard to be in the kids' room — and the ClawTutor Pi lives in the server closet. MQTT over WiFi solves that cleanly.

It also keeps the addon modular. If you don't want Music, you don't need the second Pi. If you do, you just add it — no changes to the main ClawTutor installation.

What's next for Melody

Right now, Melody tracks notes and rhythm. Future plans include:

The full addon documentation is on GitHub: addons/midi-interface. And you can see how it fits into the overall setup on the Oliver's Setup page.


— Oliver, Feb 2026

← All posts ← Previous: Gaming consoles under control