Skip to content

Latest commit

 

History

History
160 lines (138 loc) · 10.3 KB

plan.md

File metadata and controls

160 lines (138 loc) · 10.3 KB

Plan

A piano learning app for two beginner players on iPad. It listens to an acoustic keyboard through the microphone, guides them through songs, and keeps them coming back. No price, no ads, no in-app purchases. Working name piano; the name options are at the end.

The one big risk: listening

Everything else is ordinary app work. Whether the app can hear the keyboard reliably is not, so it comes first and decides go or no-go.

The first keyboard is the Yamaha Remie PSS-E30: 37 mini keys, F to F, built-in speaker, and no MIDI, USB or Bluetooth. Its range is probably F2–F5 (about 87–698 Hz), but that is not verified yet. Yamaha's manual PDF blocks automated downloads, so a parent should check the manual or the keyboard itself before the keyboard profile is fixed.

Why it's hard

  • A small speaker barely produces the fundamental of the low notes (F2–B2 at 87–123 Hz). The detector hears mostly the harmonics, so it can pick the wrong octave.
  • Piano voices decay quickly. The useful signal lasts a few hundred milliseconds.
  • A family room is noisy: talking, TV, a sibling, the keyboard's own rhythm styles.
  • Kids press two keys at once by accident.

What makes it easier

  • We almost always know which note should come next. Wait mode doesn't need to recognise any note at all. It only needs to answer "was the expected note just played, or a different one?" That is a much easier, closed-set question. Open-set detection is needed only for free play and the song editor's tap-in.
  • There are only 37 possible notes, so each candidate is checked against a fixed list.
  • We can choose the voice. The keyboard profile names a recommended voice (a clean piano, or a sustained voice if it detects better), and the app tells the player which voice to pick.

Approach

  1. Use AVAudioEngine with the input tap at 48 kHz, voice processing off: Apple's echo and noise processing smears pitch. Measurement mode, small buffers, and a target of under 50 ms from key press to on-screen reaction.
  2. Onset detection (spectral flux) finds each key press. Pitch is estimated in the first 60–150 ms after the onset.
  3. YIN (or McLeod MPM) gives the base pitch estimate. A harmonic-template score over the 37 candidate notes fixes octave errors and tells "expected note" from "neighbour or octave". Confidence and a noise gate drop speech and claps.
  4. Simple chords later: the same harmonic templates scored for two or three notes at once, checked against the known chord.

How the risk gets retired: the spike (phase 1)

  • A small iPad test app plus a Swift package (PitchKit) with the detector, and a Mac command line tool that runs the same code over recordings.
  • Recordings: a parent plays every key of the Remie slowly, low to high, then a few short passages (a scale, Happy Birthday, a few two-note mistakes), on the voice we'd recommend. Each is recorded twice: once in a quiet room and once with normal family-room noise. Made on the iPad itself, at the distance a child would sit. The recordings stay out of Git (gitignored recordings/), unless they're a parent playing with no voices and you say they can go in.
  • Labels come from the known script ("all 37 keys in order"), so no hand labelling is needed.
  • Go/no-go bar (to be tuned once we hear the data):
    • Wait mode (expected note vs anything else): at least 98% of right notes accepted and at most 2% of wrong notes accepted, in normal family-room noise.
    • Open-set note identification: at least 95% on single notes, every key, both rooms.
    • Latency from key press to on-screen reaction: under 80 ms on both iPads.
  • If it falls short: try another recommended voice, a per-keyboard calibration step (play each sticker key once at setup), or a small on-device classifier (Core ML) trained on our own recordings. If none of that works, the fallback is an inexpensive USB-MIDI keyboard. The keyboard profiles allow that later anyway.

Phases

Phase What Needs you for
0 This plan, app name, public repo from template-webapp, licence (BSL 1.1, OpenCozy terms), CI on GitHub-hosted runners Pick a name
1 Listening spike: PitchKit, the test app, recording kit, measurements, go/no-go report Cable install on one iPad, ~10 min of recordings
2 Playable v1, offline: two profiles, one world each, Happy Birthday plus 4–6 songs, wait mode, stars Cable installs on both iPads, a first try with the kids
3 Play-along and adaptive: timing mode, early/late feedback, repeat the hard bars, speed up, "play next" suggestions, streaks and unlocks A try with the kids
4 Backend, sync, parent editor: Go API, Postgres, the web editor, deploy on a home cluster, no public route Infrastructure PR review, if you want one
5 Later, raised not built: practice earns OpenCozy points; more keyboards including MIDI; chords; reading sheet music Your call

Phase 2: playable v1 (on the iPads, offline)

  • SwiftUI app, XcodeGen project.yml like OpenCozy's iOS app, iPadOS 26. Signing values only in a gitignored Local.xcconfig. Cable installs from Xcode.
  • Keyboard drawn to match the Remie: 37 keys, mini proportions, the same F-to-F layout, so what's on screen looks like what's under their hands. Sticker spots can be added to the profile later and drawn on the screen keyboard.
  • Note lane: notes fall towards the keyboard (Simply Piano style), with the note name and a coloured key highlight. A toggle shows notes on a staff instead, for moving up.
  • Wait mode: the song pauses on each note until it hears the right key. A wrong key gets a gentle "try the one that's glowing". After two misses on the same note, a hint (the key pulses, the note name is said on screen). No buzzers, no red X's.
  • Profiles: two players, names and colours set on the device at first launch (nothing personal in the code). Each player picks a world.
  • Worlds (original art and music, nothing borrowed):
    • Starforge (working title): a sci-fi armour and ring-world adventure. Songs are "missions"; a heroic original "space march".
    • Frostspire (working title): an ice-castle world. Songs are "rooms" in the palace; an original "ice palace waltz".
    • Art is drawn in code (SwiftUI shapes, gradients, particles) plus a small set of original generated or hand-made illustrations. Each world has its own palette, type and sounds.
  • Songs v1: Happy Birthday first, then Twinkle Twinkle, Ode to Joy, Jingle Bells, Mary Had a Little Lamb, Hot Cross Buns, plus one original piece per world. All public domain or original. Songs are plain JSON (notes, lengths, tempo, hand), bundled in the app.
  • Stars: 1–3 per song from accuracy and how many hints were needed. Progress is stored on the device (SwiftData); practice never waits on a server.
  • Not babyish: level-ups come quickly; a song unlocks the next as soon as it's passed, and a "skip ahead" challenge lets a player prove a level instead of grinding it.

Phase 3: play-along and adaptive

  • Play-along: the song keeps time. Feedback says early / on time / late per note, with a window that narrows as they improve.
  • Adaptive: songs are split into short phrases. A phrase that keeps going wrong gets looped slower until it's clean, then back to full speed. Tempo steps up after clean runs. "What next" suggests the next song or a phrase to practise, from their history.
  • Hooks: daily streaks (gentle: one missed day doesn't reset it), unlockable world items (armour parts, palace rooms), a short celebration on a new star.
  • A "free play" screen shows what they're playing on the keyboard as notes, for fun and as a test of the listening.

Phase 4: backend, sync, parent editor

  • From template-webapp: Go API with an OpenAPI contract, Postgres (CNPG) via sqlc/goose, React web app for parents, Helm chart.
  • Data: households, players, songs (with the household's own songs), progress events, keyboard profiles.
  • Parent song editor (web): type a melody as notes and lengths, or tap it in on a screen keyboard, preview it, and publish it to the players' iPads. Entering copyrighted melodies is up to the family; the app ships none.
  • Sync: the iPad keeps working offline and queues progress events; it syncs when the server is reachable and pulls new songs. The Swift client is generated from the same OpenAPI contract.
  • Device sign-in: pair each iPad once from the parent web app (a short code), giving the iPad a device credential for its player. No passwords for the kids.
  • Hosting: self-hosted in a home cluster, reachable from the players' iPads on the home network, no public route. Site-specific settings live outside this repo. Infrastructure PR: namespace, values, Argo app, DNS, pg-dump backups.

Repo and privacy rules

  • Public repo, BSL 1.1 with OpenCozy's terms; the README says "source-available".
  • Nothing about the family in the repo: no names, photos, voices, recordings, device names, progress data or home hostnames, in code, issues, PRs, fixtures or screenshots. Players are "Player 1/2" in code and named at runtime. Family-specific config lives in the infrastructure repo.
  • Audio never leaves the iPad. No third-party analytics, ads, or cloud speech or audio services.
  • No borrowed themes: no names, characters, logos, art, sounds or melodies from existing franchises. Worlds are original and only in the spirit of what the kids like.
  • CI on GitHub-hosted runners (Linux for the backend, macOS for the iPad build and PitchKit tests). Fork PRs never run at home. A TestFlight pipeline comes later, with the App Store Connect key in a GitHub environment that needs your approval, uploads only from main, and no secrets for forks.

App name options

Short, easy for kids to say, not tied to either world so both feel at home:

  1. Keyquest (recommended): songs are quests, fits both worlds, says "keys" plainly.
  2. Encore: what you shout when someone plays well; grown-up enough to last.
  3. Tunetrail: a path of songs to climb; good for the level map.
  4. Starkeys: stars are the reward; bright and simple.
  5. Notebound: "bound for the next note"; a bit more of an adventure name.

Before the name is fixed: check the App Store and GitHub for clashes, and whether the domain is free if it might be published one day.