8000 GitHub - thoka/draw-music: Android app that plays a drawn paper score through the camera, like a mechanical orchestrion · GitHub
[go: up one dir, main page]

Skip to content

About

Android app that plays a drawn paper score through the camera, like a mechanical orchestrion

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

draw-music

draw-music is an Android app that plays a drawing like a mechanical instrument. You draw colored marks on paper. The camera looks at the paper, and the app plays a note for each mark that crosses a scan line on the screen.

The position on the line sets the pitch: top is high, bottom is low. The color of a mark can choose the instrument. Its darkness or its width sets the loudness. The design document in the folder docs explains the idea and the structure.

Build

You need the tools of mise.toml and the Android platform 35.

mise install
eval "$(mise env)"
sdkmanager "platforms;android-35" "build-tools;35.0.0"
./gradlew :app:assembleDebug

The APK is then in app/build/outputs/apk/debug/app-debug.apk. Without the platform 35, Gradle builds only the module core.

Install on a phone

Turn on USB debugging on the phone (Settings, About phone, tap the build number seven times, then Developer options). Connect the phone with USB and run:

adb install -r app/build/outputs/apk/debug/app-debug.apk

Play

  1. Draw thick marks on white paper with markers. Plain, even light helps.
  2. Start the app and allow the camera.
  3. Hold the phone over the paper, so that the paper fills the screen.
  4. Choose a mode with the button at the bottom:
    • Moving paper: the white line stays in the middle. Pull the paper slowly under the camera, from side to side. When the paper stops, the sound stops.
    • Sweep: lay the paper still. The line glides from left to right and plays what lies under it.

The colored bands along the line are the zones. Each zone plays one instrument over a range of notes. A circle is a trigger: a mark that reaches it plays one hit, by default a drum.

In Settings you can change the mode, the speed of the sweep, the threshold that tells a mark from the paper, and the source of the loudness. You can add, edit, and delete zones and triggers, choose an instrument per color, load your own WAV file (16-bit PCM, mono or stereo) for each instrument, and send the notes to a USB or Bluetooth MIDI device instead of the built-in sounds. The app saves the settings at once.

The fifth instrument, Drumkit, plays a different drum sound for each General MIDI drum note: kick 35 and 36, snare 38 and 40, hi-hats 42, 44, and 46, toms 41 to 50, crash 49 and 57, ride 51 and 59. Other notes play a short click. On a MIDI device, it plays on the drum channel. A zone or a trigger can have a label, and the line shows it.

The drum sounds play to their end by default (one-shot), also when the mark leaves the line, and after each hit a short dead time (60 ms) keeps the same zone or trigger from playing again. A switch per instrument and the field "Dead time of one-shot notes" in Settings change this, a zone or trigger can override both, and a preset can set its own dead time; docs/presets.md describes the keys.

The button "Edit view" fits the line to your grid sheet: pinch to zoom the camera picture, drag to move it, and double tap to reset it, while the line keeps its place on the screen and plays only the part of the picture that you see. In this mode the sound is muted, the button "Done" ends it and saves the view, and "Reset view" in Settings shows the whole picture again.

Presets

A preset is a named set of play settings: the mode, the screen orientation, the sweep period, the threshold, the loudness source, the objects on the line, and the instruments of the colors. The section Presets at the top of the settings shows the active preset. There you activate or delete a preset, save the current settings as a new preset, and export or import all presets as one YAML file. An import either replaces all presets or merges the file into them. The app ships with a few presets; the first one is a drum set. The file form is in docs/presets.md.

Landscape

Each preset, and the settings, choose portrait or landscape. The scan line stays vertical on the screen in both. When the orientation changes, the app starts its screen again and binds the camera anew. The view keeps its zoom and its place as fractions of the shown picture.

Remote API

The section Remote API of the settings switches on a small HTTP server on the phone, shows its port, its token, and the IP addresses of the phone (also a Tailscale address). A computer can then read, write, and activate presets; docs/api.md describes the calls.

Polar grid sheet

bin/polar-grid makes a PDF with a thin concentric grid, for drawing scores. It needs only Python 3.

bin/polar-grid --rings 12 --spokes 24 --page A4 -o grid.pdf

Options: --landscape, --margin, --radius, --hole (empty center, its edge is drawn as the first ring), --line (line width in mm, default 0.1), --start (angle of the first spoke). Run bin/polar-grid --help for all of them. Tests: python3 -I -m unittest discover -s tests.

License

The code is under the MIT license, see LICENSE in the root.

Each subfolder can hold its own license file. A file there rules the content of that folder and replaces the root license for it. This is how we keep material from other sources under the license of its source. The folder patterns/ holds drum patterns under CC BY-SA 4.0. Look for a license file in a folder before you reuse its content.

About

Android app that plays a drawn paper score through the camera, like a mechanical orchestrion

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0