A MIDI studio in Python. Each song is code: music21 turns keys, scale steps and chord symbols into notes. The studio shows the notes as a piano roll, plays them in the browser and gives each song as a Standard MIDI File.
The studio runs in its own AWS Lambda function, with a public address. Deploy tells how to put a new version there.
src/studio/songs.pyhas the songs and the catalog. Change a line there and the music changes.src/studio/app.pyis the web app (WSGI, standard library only): the page, the songs as JSON and the MIDI files.src/studio/public/has the page: a piano roll and a player on the Web Audio API. It has no build step.src/studio/aws.pyis the entry of the Lambda function. It turns a function URL event into a WSGI request.tests/has the tests. They read the MIDI file of each song of the catalog.Dockerfile,template.yamlanddeploy.share the deployment.
python3 -m pip install music21 pytest
PYTHONPATH=src python3 -m studio # the page, on http://127.0.0.1:8090/
PYTHONPATH=src python3 -m studio render # the MIDI file of each song, in out/
python3 -m pytest- Write a function in
src/studio/songs.pythat returns the parts of the song.partmakes a part with a General MIDI program,drumsmakes the drum part andlineputs notes one after the other. Time is in quarter notes. - Add one
Songwith a new id toCATALOG. - Run the tests: they check each song of the catalog.
You need the AWS CLI version 2 with credentials that can make the stack, and Docker or Podman.
./deploy.sh # prints the address of the studio
ENGINE=podman ./deploy.sh # the same, with PodmanThe script builds the image, pushes it to Amazon ECR and deploys template.yaml.
It is safe to run again. The stack has one function with a function URL and one log group.
| Variable | Default | Use |
|---|---|---|
STACK |
midi-studio |
The name of the stack, of the function and of the ECR repository |
AWS_REGION |
eu-central-1 |
The region |
ENGINE |
docker |
docker or podman |
- The address is public and needs no password. The studio only reads its own files.
- The function has no permission for an AWS service. It writes only its own log.
- At most 5 requests run at the same time. An answer has at most 30 seconds.
- A push to
maindoes not deploy. GitHub Actions is off in this repository, because Vis sessions can push here. Rundeploy.shto put a version on Lambda.
To remove the deployment, delete the stack and then the ECR repository:
aws cloudformation delete-stack --stack-name midi-studio
aws ecr delete-repository --repository-name midi-studio --forceDurable Lambda is a
separate stack that runs Vis on AWS Lambda. Its sessions and workflows get a clone of the
main branch of this repository. They can read, change and test the code, and publish their
commits back here. That stack does not run the studio, and this repository holds no part of it.