midi-recorder 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- midi_recorder-1.0.0/.gitignore +223 -0
- midi_recorder-1.0.0/LICENSE +21 -0
- midi_recorder-1.0.0/Makefile +120 -0
- midi_recorder-1.0.0/PKG-INFO +135 -0
- midi_recorder-1.0.0/README.md +102 -0
- midi_recorder-1.0.0/midi_recorder.py +488 -0
- midi_recorder-1.0.0/midi_recorder_gui.py +138 -0
- midi_recorder-1.0.0/pyproject.toml +82 -0
- midi_recorder-1.0.0/stubs/mido/__init__.pyi +41 -0
- midi_recorder-1.0.0/stubs/mido/ports.pyi +4 -0
- midi_recorder-1.0.0/tests/test_midi_recorder.py +234 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# uv
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs/Zensical documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
201
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
203
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
|
221
|
+
*.mid
|
|
222
|
+
*.journal
|
|
223
|
+
recordings/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Maarten Boot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# midi-recorder: run and check everything inside a virtualenv.
|
|
2
|
+
# make -> show targets
|
|
3
|
+
# make all -> clean rebuild of the venv, then format, lint, typecheck and test
|
|
4
|
+
# make check -> ruff check + ruff format --check + mypy --strict + pytest
|
|
5
|
+
# make build -> check, then build sdist + wheel into dist/ and run twine check
|
|
6
|
+
# make testpypi -> build, then upload dist/* to TestPyPI (repository section mboot_testpypi in ~/.pypirc)
|
|
7
|
+
# make pypi -> only from a clean tree whose HEAD is tagged v<version>: build, then upload dist/* to PyPI after you retype the version
|
|
8
|
+
# make run ARGS="-o ~/midi --idle 20"
|
|
9
|
+
|
|
10
|
+
PYTHON ?= python3
|
|
11
|
+
VENV ?= .venv
|
|
12
|
+
|
|
13
|
+
ifeq ($(OS),Windows_NT)
|
|
14
|
+
VBIN := $(VENV)/Scripts
|
|
15
|
+
else
|
|
16
|
+
VBIN := $(VENV)/bin
|
|
17
|
+
endif
|
|
18
|
+
|
|
19
|
+
STAMP := $(VENV)/.installed
|
|
20
|
+
VERSION = $(shell sed -n 's/^__version__ = "\(.*\)"/\1/p' midi_recorder.py)
|
|
21
|
+
PY := midi_recorder.py midi_recorder_gui.py
|
|
22
|
+
SRC := $(PY) tests stubs
|
|
23
|
+
|
|
24
|
+
.DEFAULT_GOAL := help
|
|
25
|
+
.PHONY: help all venv lint format format-check typecheck test check build run run-gui clean distclean testpypi pypi pypi-guard
|
|
26
|
+
|
|
27
|
+
help:
|
|
28
|
+
@echo "all distclean + venv + lint + format + format-check + typecheck + test"
|
|
29
|
+
@echo "venv create the virtualenv and install dependencies"
|
|
30
|
+
@echo "lint ruff check"
|
|
31
|
+
@echo "format ruff format (rewrites files)"
|
|
32
|
+
@echo "format-check ruff format --check"
|
|
33
|
+
@echo "typecheck mypy --strict"
|
|
34
|
+
@echo "test pytest"
|
|
35
|
+
@echo "check lint + format-check + typecheck + test"
|
|
36
|
+
@echo "build build sdist + wheel into dist/ and run twine check"
|
|
37
|
+
@echo "run run the recorder (ARGS=\"...\" passes options)"
|
|
38
|
+
@echo "run-gui run the status window (needs tkinter; ARGS=\"...\" passes options)"
|
|
39
|
+
@echo "clean remove caches"
|
|
40
|
+
@echo "distclean clean + remove the virtualenv"
|
|
41
|
+
@echo "testpypi check + build + upload dist/* to TestPyPI"
|
|
42
|
+
@echo "pypi clean + tagged commit only; check + build + upload dist/* to PyPI after confirmation"
|
|
43
|
+
|
|
44
|
+
all: distclean venv lint format format-check typecheck test
|
|
45
|
+
|
|
46
|
+
venv: $(STAMP)
|
|
47
|
+
|
|
48
|
+
$(STAMP): pyproject.toml
|
|
49
|
+
$(PYTHON) -m venv $(VENV)
|
|
50
|
+
$(VBIN)/python -m pip install --upgrade pip
|
|
51
|
+
$(VBIN)/python -m pip install -e ".[dev]"
|
|
52
|
+
touch $(STAMP)
|
|
53
|
+
|
|
54
|
+
lint: $(STAMP)
|
|
55
|
+
$(VBIN)/ruff check $(SRC)
|
|
56
|
+
|
|
57
|
+
format: $(STAMP)
|
|
58
|
+
$(VBIN)/ruff format $(SRC)
|
|
59
|
+
|
|
60
|
+
format-check: $(STAMP)
|
|
61
|
+
$(VBIN)/ruff format --check $(SRC)
|
|
62
|
+
|
|
63
|
+
typecheck: $(STAMP)
|
|
64
|
+
$(VBIN)/mypy $(PY) tests
|
|
65
|
+
|
|
66
|
+
test: $(STAMP)
|
|
67
|
+
$(VBIN)/pytest
|
|
68
|
+
|
|
69
|
+
check: lint format-check typecheck test
|
|
70
|
+
|
|
71
|
+
build: $(STAMP) check
|
|
72
|
+
rm -rf dist
|
|
73
|
+
$(VBIN)/python -m build
|
|
74
|
+
$(VBIN)/twine check dist/*
|
|
75
|
+
|
|
76
|
+
run: $(STAMP)
|
|
77
|
+
$(VBIN)/python midi_recorder.py $(ARGS)
|
|
78
|
+
|
|
79
|
+
run-gui: $(STAMP)
|
|
80
|
+
$(VBIN)/python midi_recorder_gui.py $(ARGS)
|
|
81
|
+
|
|
82
|
+
clean:
|
|
83
|
+
rm -rf .mypy_cache .ruff_cache .pytest_cache build dist *.egg-info
|
|
84
|
+
find . -name __pycache__ -not -path "./$(VENV)/*" -prune -exec rm -rf {} +
|
|
85
|
+
|
|
86
|
+
distclean: clean
|
|
87
|
+
rm -rf $(VENV)
|
|
88
|
+
|
|
89
|
+
# ---------------------------------------
|
|
90
|
+
# Manual uploads. Credentials come from the repository sections in ~/.pypirc (username __token__, password = API token).
|
|
91
|
+
# The normal way to publish is a GitHub release (.github/workflows/release.yml, trusted publishing, no token).
|
|
92
|
+
# Every upload needs a new __version__ in midi_recorder.py: neither index accepts the same file twice.
|
|
93
|
+
testpypi: build
|
|
94
|
+
$(VBIN)/twine upload \
|
|
95
|
+
--config-file=$${HOME}/.pypirc \
|
|
96
|
+
--repository=mboot_testpypi \
|
|
97
|
+
dist/*
|
|
98
|
+
|
|
99
|
+
pypi-guard:
|
|
100
|
+
@set -e; \
|
|
101
|
+
version="$(VERSION)"; \
|
|
102
|
+
[ -n "$$version" ] || { echo "error: cannot read __version__ from midi_recorder.py"; exit 1; }; \
|
|
103
|
+
git rev-parse --git-dir >/dev/null 2>&1 || { echo "error: not a git checkout"; exit 1; }; \
|
|
104
|
+
if [ -n "$$(git status --porcelain)" ]; then \
|
|
105
|
+
echo "error: the working tree is not clean, commit or stash first:"; git status --short; exit 1; \
|
|
106
|
+
fi; \
|
|
107
|
+
tags="$$(git tag --points-at HEAD)"; \
|
|
108
|
+
if ! echo "$$tags" | grep -qxF -e "v$$version" -e "$$version"; then \
|
|
109
|
+
echo "error: HEAD is not tagged v$$version (tags at HEAD: $${tags:-none})"; exit 1; \
|
|
110
|
+
fi; \
|
|
111
|
+
echo "ok: clean tree, HEAD is tagged for $$version"
|
|
112
|
+
|
|
113
|
+
pypi: pypi-guard build
|
|
114
|
+
@echo; echo "About to upload to PyPI, the real index. An upload can never be replaced:"; ls -1 dist
|
|
115
|
+
@printf "Type the version (%s) to upload, anything else aborts: " "$(VERSION)"; \
|
|
116
|
+
read -r answer || answer=""; \
|
|
117
|
+
[ "$$answer" = "$(VERSION)" ] || { echo "aborted, nothing uploaded"; exit 1; }
|
|
118
|
+
$(VBIN)/twine upload \
|
|
119
|
+
--repository=mboot_pypi \
|
|
120
|
+
dist/*
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: midi-recorder
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Record all incoming MIDI events to timestamped .mid files, saved automatically when playing stops
|
|
5
|
+
Project-URL: Homepage, https://github.com/maarten-boot/recording-midi-data
|
|
6
|
+
Project-URL: Issues, https://github.com/maarten-boot/recording-midi-data/issues
|
|
7
|
+
Author: Maarten Boot
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: daw,midi,mido,piano,recorder
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Environment :: X11 Applications
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: mido>=1.3
|
|
25
|
+
Requires-Dist: python-rtmidi>=1.5.8
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build; extra == 'dev'
|
|
28
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
31
|
+
Requires-Dist: twine; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# recording-midi-data
|
|
35
|
+
|
|
36
|
+
**midi-recorder** records everything that comes in on your MIDI inputs and saves it as a standard MIDI file.
|
|
37
|
+
There is nothing to press: the first note starts a recording, and when you stop playing the file is closed and saved.
|
|
38
|
+
|
|
39
|
+
Each file is named after the moment the recording started: `2026-10-05_21-35-12.mid`.
|
|
40
|
+
|
|
41
|
+
- Notes, sustain and other pedals, channel and polyphonic aftertouch, pitch bend and all other messages are kept. Only `clock` and `active_sensing` are dropped.
|
|
42
|
+
- Listens on **all** MIDI inputs at once; inputs plugged in later are picked up automatically.
|
|
43
|
+
- Plays back in real time in any DAW (1 tick = 1 ms).
|
|
44
|
+
- Crash safe: a journal is written while you play, and recovered at the next start.
|
|
45
|
+
- Command line, plus a small status window.
|
|
46
|
+
- Linux, Windows and macOS.
|
|
47
|
+
|
|
48
|
+
There is no live display of the notes; open the finished file in your DAW for that.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pipx install midi-recorder # or: pip install midi-recorder
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Python 3.10 - 3.12. The MIDI backend `python-rtmidi` has no prebuilt wheels for Python 3.13 yet, so on 3.13 pip would have to compile it.
|
|
57
|
+
|
|
58
|
+
| System | Notes |
|
|
59
|
+
|---|---|
|
|
60
|
+
| Linux (Debian, Ubuntu, Fedora) | Needs the ALSA sequencer, which any normal desktop install has. The status window needs tkinter: `sudo apt install python3-tk` (Debian/Ubuntu) or `sudo dnf install python3-tkinter` (Fedora). |
|
|
61
|
+
| Windows 10, 11 | A MIDI input can usually be opened by only one program at a time. Close your DAW first, or route the keyboard through a loopback driver such as loopMIDI so both can listen. |
|
|
62
|
+
| macOS | Should work through CoreMIDI. The automated tests run on macOS, but it has not been tried with a real keyboard. |
|
|
63
|
+
|
|
64
|
+
## Quick start
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
midi-recorder --list # show the MIDI inputs it can see
|
|
68
|
+
midi-recorder -o ~/midi # record into ~/midi, stop with Ctrl-C
|
|
69
|
+
midi-recorder-gui -o ~/midi # the same, with a status window
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`midi-recorder --list` prints a short error instead of a traceback when no MIDI backend is available.
|
|
73
|
+
|
|
74
|
+
If you leave out `-o`, files go into the current directory.
|
|
75
|
+
|
|
76
|
+
## How a recording works
|
|
77
|
+
|
|
78
|
+
1. A recording **starts** with the first event from any input.
|
|
79
|
+
2. It **ends** when no event has arrived for `--idle` seconds (default 30), *and* no note is held and no sustain pedal is down. While a key or the pedal is held, it waits up to `--max-hold` seconds (default 120) instead, so a long held chord does not cut the file, and a stuck note cannot keep it open forever.
|
|
80
|
+
3. The file is written as a type 1 MIDI file: a tempo track plus **one track per input**, named after the input. With only one keyboard you get one note track.
|
|
81
|
+
4. Ctrl-C (or closing the window) saves the recording in progress before exiting.
|
|
82
|
+
|
|
83
|
+
Timestamps are taken when the event reaches the program, so their accuracy is whatever your operating system's MIDI driver and scheduling give you, typically about a millisecond.
|
|
84
|
+
|
|
85
|
+
## Options
|
|
86
|
+
|
|
87
|
+
Both programs take the same options.
|
|
88
|
+
|
|
89
|
+
| Option | Default | Meaning |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `-o`, `--outdir` | `.` | Folder for the `.mid` files, created if missing. |
|
|
92
|
+
| `--idle` | `30` | Seconds of silence that end a recording. |
|
|
93
|
+
| `--max-hold` | `120` | Longest silence allowed while a note or the sustain pedal is held. |
|
|
94
|
+
| `--log-level` | `INFO` | `DEBUG`, `INFO`, `WARNING` or `ERROR`. |
|
|
95
|
+
| `--log-file` | `<outdir>/midi_recorder.log` | Where to write the log. |
|
|
96
|
+
| `--no-log-file` | | Log to stderr only. |
|
|
97
|
+
| `--list` | | `midi-recorder` only: list the MIDI inputs and exit. |
|
|
98
|
+
|
|
99
|
+
## Status window
|
|
100
|
+
|
|
101
|
+
`midi-recorder-gui` shows whether it is **recording** (with the number of events and the elapsed time) or **ready**, the inputs it is listening on, the recordings saved so far, and a button that opens the output folder.
|
|
102
|
+
Closing the window saves the recording in progress.
|
|
103
|
+
|
|
104
|
+
## If it crashes
|
|
105
|
+
|
|
106
|
+
While you play, every event is also appended to `YYYY-MM-DD_HH-MM-SS.journal` in the output folder, and the file is flushed as events arrive.
|
|
107
|
+
When a recording is saved normally the journal is deleted.
|
|
108
|
+
If the program or the computer dies mid-recording, the next start turns each leftover journal into a `.mid` file and logs a warning. A write that was cut off by the crash is skipped. If a `.mid` with that name already exists, the recovered file gets `_recovered` in its name instead of overwriting it.
|
|
109
|
+
|
|
110
|
+
Run only one recorder per output folder, otherwise one could mistake the other's live journal for a crash.
|
|
111
|
+
|
|
112
|
+
## Logging
|
|
113
|
+
|
|
114
|
+
Messages go to stderr and to `<outdir>/midi_recorder.log`, which is rotated at 1 MB and keeps 3 old files. A failing MIDI backend or an input that cannot be opened is logged once, not every few seconds.
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
git clone https://github.com/maarten-boot/recording-midi-data
|
|
120
|
+
cd recording-midi-data
|
|
121
|
+
make check # ruff, ruff format --check, mypy --strict, pytest (creates .venv)
|
|
122
|
+
make all # the same from a fresh venv, also runs ruff format
|
|
123
|
+
make build # checks, then builds the sdist and wheel into dist/ and runs twine check
|
|
124
|
+
make run ARGS="-o ~/midi"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`make` with no target lists everything. The checks run on Linux, Windows and macOS in GitHub Actions.
|
|
128
|
+
|
|
129
|
+
`mido` ships no type information, so a minimal stub for the part this program uses lives in `stubs/mido/`.
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT, see `LICENSE`.
|
|
134
|
+
|
|
135
|
+
Thanks Claude.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# recording-midi-data
|
|
2
|
+
|
|
3
|
+
**midi-recorder** records everything that comes in on your MIDI inputs and saves it as a standard MIDI file.
|
|
4
|
+
There is nothing to press: the first note starts a recording, and when you stop playing the file is closed and saved.
|
|
5
|
+
|
|
6
|
+
Each file is named after the moment the recording started: `2026-10-05_21-35-12.mid`.
|
|
7
|
+
|
|
8
|
+
- Notes, sustain and other pedals, channel and polyphonic aftertouch, pitch bend and all other messages are kept. Only `clock` and `active_sensing` are dropped.
|
|
9
|
+
- Listens on **all** MIDI inputs at once; inputs plugged in later are picked up automatically.
|
|
10
|
+
- Plays back in real time in any DAW (1 tick = 1 ms).
|
|
11
|
+
- Crash safe: a journal is written while you play, and recovered at the next start.
|
|
12
|
+
- Command line, plus a small status window.
|
|
13
|
+
- Linux, Windows and macOS.
|
|
14
|
+
|
|
15
|
+
There is no live display of the notes; open the finished file in your DAW for that.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pipx install midi-recorder # or: pip install midi-recorder
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Python 3.10 - 3.12. The MIDI backend `python-rtmidi` has no prebuilt wheels for Python 3.13 yet, so on 3.13 pip would have to compile it.
|
|
24
|
+
|
|
25
|
+
| System | Notes |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Linux (Debian, Ubuntu, Fedora) | Needs the ALSA sequencer, which any normal desktop install has. The status window needs tkinter: `sudo apt install python3-tk` (Debian/Ubuntu) or `sudo dnf install python3-tkinter` (Fedora). |
|
|
28
|
+
| Windows 10, 11 | A MIDI input can usually be opened by only one program at a time. Close your DAW first, or route the keyboard through a loopback driver such as loopMIDI so both can listen. |
|
|
29
|
+
| macOS | Should work through CoreMIDI. The automated tests run on macOS, but it has not been tried with a real keyboard. |
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
midi-recorder --list # show the MIDI inputs it can see
|
|
35
|
+
midi-recorder -o ~/midi # record into ~/midi, stop with Ctrl-C
|
|
36
|
+
midi-recorder-gui -o ~/midi # the same, with a status window
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`midi-recorder --list` prints a short error instead of a traceback when no MIDI backend is available.
|
|
40
|
+
|
|
41
|
+
If you leave out `-o`, files go into the current directory.
|
|
42
|
+
|
|
43
|
+
## How a recording works
|
|
44
|
+
|
|
45
|
+
1. A recording **starts** with the first event from any input.
|
|
46
|
+
2. It **ends** when no event has arrived for `--idle` seconds (default 30), *and* no note is held and no sustain pedal is down. While a key or the pedal is held, it waits up to `--max-hold` seconds (default 120) instead, so a long held chord does not cut the file, and a stuck note cannot keep it open forever.
|
|
47
|
+
3. The file is written as a type 1 MIDI file: a tempo track plus **one track per input**, named after the input. With only one keyboard you get one note track.
|
|
48
|
+
4. Ctrl-C (or closing the window) saves the recording in progress before exiting.
|
|
49
|
+
|
|
50
|
+
Timestamps are taken when the event reaches the program, so their accuracy is whatever your operating system's MIDI driver and scheduling give you, typically about a millisecond.
|
|
51
|
+
|
|
52
|
+
## Options
|
|
53
|
+
|
|
54
|
+
Both programs take the same options.
|
|
55
|
+
|
|
56
|
+
| Option | Default | Meaning |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| `-o`, `--outdir` | `.` | Folder for the `.mid` files, created if missing. |
|
|
59
|
+
| `--idle` | `30` | Seconds of silence that end a recording. |
|
|
60
|
+
| `--max-hold` | `120` | Longest silence allowed while a note or the sustain pedal is held. |
|
|
61
|
+
| `--log-level` | `INFO` | `DEBUG`, `INFO`, `WARNING` or `ERROR`. |
|
|
62
|
+
| `--log-file` | `<outdir>/midi_recorder.log` | Where to write the log. |
|
|
63
|
+
| `--no-log-file` | | Log to stderr only. |
|
|
64
|
+
| `--list` | | `midi-recorder` only: list the MIDI inputs and exit. |
|
|
65
|
+
|
|
66
|
+
## Status window
|
|
67
|
+
|
|
68
|
+
`midi-recorder-gui` shows whether it is **recording** (with the number of events and the elapsed time) or **ready**, the inputs it is listening on, the recordings saved so far, and a button that opens the output folder.
|
|
69
|
+
Closing the window saves the recording in progress.
|
|
70
|
+
|
|
71
|
+
## If it crashes
|
|
72
|
+
|
|
73
|
+
While you play, every event is also appended to `YYYY-MM-DD_HH-MM-SS.journal` in the output folder, and the file is flushed as events arrive.
|
|
74
|
+
When a recording is saved normally the journal is deleted.
|
|
75
|
+
If the program or the computer dies mid-recording, the next start turns each leftover journal into a `.mid` file and logs a warning. A write that was cut off by the crash is skipped. If a `.mid` with that name already exists, the recovered file gets `_recovered` in its name instead of overwriting it.
|
|
76
|
+
|
|
77
|
+
Run only one recorder per output folder, otherwise one could mistake the other's live journal for a crash.
|
|
78
|
+
|
|
79
|
+
## Logging
|
|
80
|
+
|
|
81
|
+
Messages go to stderr and to `<outdir>/midi_recorder.log`, which is rotated at 1 MB and keeps 3 old files. A failing MIDI backend or an input that cannot be opened is logged once, not every few seconds.
|
|
82
|
+
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
git clone https://github.com/maarten-boot/recording-midi-data
|
|
87
|
+
cd recording-midi-data
|
|
88
|
+
make check # ruff, ruff format --check, mypy --strict, pytest (creates .venv)
|
|
89
|
+
make all # the same from a fresh venv, also runs ruff format
|
|
90
|
+
make build # checks, then builds the sdist and wheel into dist/ and runs twine check
|
|
91
|
+
make run ARGS="-o ~/midi"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`make` with no target lists everything. The checks run on Linux, Windows and macOS in GitHub Actions.
|
|
95
|
+
|
|
96
|
+
`mido` ships no type information, so a minimal stub for the part this program uses lives in `stubs/mido/`.
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
MIT, see `LICENSE`.
|
|
101
|
+
|
|
102
|
+
Thanks Claude.
|