Featured image of post Pocket Pulse: Turning My Phone Into a GarageBand MIDI Controller

Pocket Pulse: Turning My Phone Into a GarageBand MIDI Controller

An experiment in turning my phone into a local Wi-Fi MIDI controller for GarageBand. Not the only way to do it, and probably not the best, but a lot of fun to build and jam with.

I like messing around in GarageBand, and I kept having the same minor thought: it would be nice to have another touch controller on my desk for tapping out drum beats or playing synth lines, without buying more hardware that I don’t really need.

I already had a multi-touch screen in my pocket. I didn’t particularly want to shop around for iOS apps, mess with Bluetooth MIDI pairing, or install a bunch of drivers. I mostly just wanted to see if I could throw together something simple: run a command on my Mac, scan a QR code on my phone, and start playing.

That little experiment turned into Pocket Pulse, a browser-based MIDI controller, XY synth, and 16-step sequencer that talks to GarageBand over local Wi-Fi.

I’m sure there are plenty of different ways to build something like this, and almost certainly better ones already out there. This is just my take on it. What surprised me is how much I’ve actually enjoyed playing with it since building it. I’ll sit down to tweak one small thing, test a few pads, start a drum loop, and end up spending twenty minutes just jamming and making fairly questionable music.

Still enjoying the low barrier to experimenting

This is really just a continuation of what I was writing about almost a year ago when I built our family planner with coding agents. None of that is new anymore, it’s just become my normal way of poking at side projects.

Even so, I still appreciate how much it lowers the barrier for small experiments like this. A few years back, an idea like a phone-controlled MIDI surface would probably have stayed on the “maybe one day” list. Not because any single piece is impossibly hard, but because of the time and friction involved in gluing it all together: looking up Core MIDI boilerplate in Swift, sorting out multi-touch Pointer Events in the browser, writing a Standard MIDI File exporter from scratch. Each one is an evening of yak-shaving on its own.

Being able to get past that boilerplate quickly means I can stay in the fun part, which is experimenting. Try an idea, see how it feels on a phone screen, decide it’s missing something, and try the next thing. It makes it easy to build small, slightly silly tools purely out of curiosity.

Here’s a quick demo of where it’s got to so far:

Terminal QR pairing, 8 drum pads, the XY synth, and the 16-step sequencer.

Keeping the architecture simple

Before adding any features, I wanted the simplest path I could think of from a finger tap on a phone to a note in GarageBand:

1
Phone browser → WebSocket over Wi-Fi → Node.js → Swift over stdin → Core MIDI → GarageBand

There’s no native iOS app and no frontend build step, just plain HTML, CSS, vanilla ES modules, and one npm dependency (ws).

  1. The phone browser sends a small JSON message over WebSocket when a finger touches or lifts off a control.
  2. The Node.js server (server.js) serves the static files, checks the session token, and writes three space-separated numbers to a child process’s stdin. A kick drum hit at velocity 100 is just 144 36 100.
  3. The Swift bridge (midi-bridge.swift, around 100 lines) reads stdin, packs those three bytes into a Core MIDI packet, and sends it through a virtual MIDI source called Pocket Pulse. GarageBand picks it up on whatever software instrument track is selected.

Again, you could definitely do this other ways (native app, network MIDI, all in Swift, etc.), but keeping the boundary between Node and Swift to three numbers on a line made it very easy to follow and debug.

Starting with drum pads

The first version was just eight drum pads mapped to standard General MIDI notes (kick on 36, snare on 38, closed hat on 42) with an octave offset (-12, 0, +12) for kits that sit elsewhere.

Pocket Pulse drum pads
The eight drum pads with custom layouts and MIDI learn.

Once I started trying different GarageBand drum kits and percussion patches, fixed presets got limiting pretty quickly. So I added a pad editor where you can rename a pad, set an exact MIDI note, or use MIDI learn. Learn mode briefly listens to any physical MIDI keyboard plugged into the Mac, waits for the next note you press, and assigns it to the pad.

Adding the XY synth

After the pads worked, I wanted to see if a phone screen could be a fun surface for playing synths as well.

I split the horizontal axis into vertical scale lanes (Major, Natural minor, Major/Minor pentatonic, or Chromatic) with root notes highlighted so it’s easier to stay in key. Touching higher up gives a higher attack velocity, and sliding sideways moves to the next note.

Pocket Pulse XY synth performance view
Performance view on the XY synth with two-finger chords and scale lanes.

Using Pointer Events, each finger gets its own pointer ID, tracked pitch, and a trail on an HTML canvas:

  • Sliding into another lane releases the previous note (as long as no other finger is holding it) and triggers the new one.
  • Multiple fingers let you play chords on the screen.
  • Performance view hides the extra controls so you get more space to play.

I also added a basic arpeggiator (ascending or descending) that steps through whatever notes you’re holding in eighth-note intervals. This is probably the part I spend the most time messing around with. Picking a synth patch in GarageBand and dragging a couple of fingers around the screen is a very easy way to lose track of time, even if you’re not much of a keyboard player.

A 16-step sequencer to jam over

Next, I wanted a simple way to keep a beat going so I could play the synth over the top of it. That turned into the 16-step sequencer:

Pocket Pulse 16-step sequencer
The 16-step sequencer with swing, accents, A–D pattern slots, and queued bar changes.

  • Off / Hit / Accent on each step (tap to cycle).
  • Swing (0–50%) to shift every off-beat sixteenth note, using the same timing logic in sequencer.mjs for both live playback and MIDI export.
  • Pattern slots A–D saved in localStorage. When stopped, tapping a slot lets you edit it. While playing, tapping another slot queues it for the next bar so you can switch patterns without stopping the beat.
  • Browser drums vs. GarageBand MIDI: Because GarageBand only focuses one software instrument track at a time, I added a small Web Audio API drum synth (drums.js) in the browser. That way you can run a drum loop in the browser while the XY pad plays a GarageBand synth, or switch the output to GarageBand MIDI to drive GarageBand’s own kits instead.
  • MIDI export: If a pattern actually turns out alright, Export MIDI downloads it as a one-bar .mid file (including tempo, swing, accents, and custom pad pitches) that you can drag straight into GarageBand.

A couple of practical annoyances

Using a phone as a wireless MIDI controller throws up two boring problems pretty much straight away:

  1. Typing local IP addresses on a phone is a pain. On startup, a small Core Image script (qr-code.swift) prints a scannable QR code straight into the terminal. Each launch generates a fresh 36-character token placed after # in the URL. Because URL fragments aren’t sent in HTTP requests, the token stays in the browser and is only used when opening the WebSocket. Traffic is still plain HTTP/WS though, so it’s strictly for a trusted home network.
  2. Phones lock themselves mid-chord. Nothing ruins a jam faster than a stuck synth note. The browser releases all held notes if you switch tabs or lock the screen, and the Node server tracks per-client note ownership with a 15-second ping/pong heartbeat. If a phone drops off Wi-Fi without closing cleanly, the server sends note-off for whatever that device was holding (and if two phones are holding the same pitch, it only stops when the last one lets go).

Where it goes from here

Pocket Pulse is open source under the MIT licence at github.com/mdugmore/pocket-pulse.

If you’ve got a Mac with GarageBand (or any other Core MIDI DAW), Node.js 22+, and Xcode Command Line Tools, it’s quick to try out:

1
2
3
4
git clone https://github.com/mdugmore/pocket-pulse.git
cd pocket-pulse
npm ci
npm start

There’s no grand plan for it. I’ll probably keep tinkering with it as I play around and think of things I want (maybe mapping Y-axis drag to MIDI CC filter sweeps, or trying out Linux/Windows bridges if the mood strikes). If anyone else wants to poke at it or send a PR, great. Otherwise, I’m quite happy just using it to make questionable music on the sofa and seeing what else I can bolt onto it next.

Built with Hugo
Theme Stack designed by Jimmy