Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer-lab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ python -m studio.summary out_studio
«Кульм.», «Конц.»), полное имя видно во всплывающей подсказке. «Скачать MIDI» и
«Скачать табы (MusicXML)» сохраняют готовый трек для DAW и Guitar Pro.

«Тональность» в параметрах пьесы переводит все ноты в выбранную тональность и лад по ступеням: ритм, форма и состав нот остаются прежними, а аппликатура и приёмы (легато, слайды, тэппинг) заново выводятся для новых нот по секциям (легато на первую ноту секции не переносится) и могут отличаться от исходных; аккорды перестраиваются так, чтобы их можно было сыграть и в них не было полутонов. Октава меняется целиком для участка гитары в секции, если он не помещается в гриф; «Как в пьесе» возвращает исходную тональность.

Стек «Вернуть» хранится в `redo.json` рядом с `undo.json` в папке пьесы и
доступен как `POST /api/piece/{id}/redo`; в журнал `history.jsonl` пишется
действие `redo`. Оба стека ограничены 50 шагами.
Expand Down Expand Up @@ -139,6 +141,6 @@ nix shell nixpkgs#fluidsynth nixpkgs#sox nixpkgs#ffmpeg -c bash build_samples.sh

### Как пользоваться в браузере (для владельца)

Откройте страницу на компьютере или телефоне: при первом запуске браузер загрузит Pyodide и сэмплы гитары (далее они берутся из кеша браузера). Нажмите «Новая пьеса» (при желании задайте `seed`), запускайте воспроизведение кнопкой «Играть» или кликом по блокам секций на таймлайне. Перегенерируйте отдельные слои, закрепляйте удачные кнопкой «Закрепить» (параметры снизу всё равно действуют и на закреплённые секции), отменяйте и возвращайте шаги кнопками «Отменить: …» и «Вернуть», сразу меняйте глухие ноты ритм-гитары, долю октавных тактов, длину вступления, повтор квадрата в куплетах и прочие параметры снизу (дозы перегенерации скрыты в «Дополнительно») и скачивайте готовый результат в MIDI, MusicXML или ASCII-табах. Стек «Вернуть» хранится в состоянии пьесы рядом со стеком «Отменить» (до 50 шагов, команда `redo` в `web_api`). Все пьесы и журнал действий сохраняются локально в браузере; в боковой панели доступны «Скачать журнал» (`history.jsonl`), «Экспорт пьес» и «Импорт пьес» для переноса между устройствами.
Откройте страницу на компьютере или телефоне: при первом запуске браузер загрузит Pyodide и сэмплы гитары (далее они берутся из кеша браузера). Нажмите «Новая пьеса» (при желании задайте `seed`), запускайте воспроизведение кнопкой «Играть» или кликом по блокам секций на таймлайне. Перегенерируйте отдельные слои, закрепляйте удачные кнопкой «Закрепить» (параметры снизу всё равно действуют и на закреплённые секции), отменяйте и возвращайте шаги кнопками «Отменить: …» и «Вернуть», сразу меняйте глухие ноты ритм-гитары, долю октавных тактов, длину вступления, повтор квадрата в куплетах, тональность и прочие параметры снизу (дозы перегенерации скрыты в «Дополнительно») и скачивайте готовый результат в MIDI, MusicXML или ASCII-табах. Стек «Вернуть» хранится в состоянии пьесы рядом со стеком «Отменить» (до 50 шагов, команда `redo` в `web_api`). Все пьесы и журнал действий сохраняются локально в браузере; в боковой панели доступны «Скачать журнал» (`history.jsonl`), «Экспорт пьес» и «Импорт пьес» для переноса между устройствами.


61 changes: 61 additions & 0 deletions composer-lab/STUDIO-KEY-SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Studio: change the key of a piece (specification)

Base: `main` at 552831d (after #222 and #223). Both front ends
(`studio/index.html`, Studio Web) share `studio/engine.py`, `studio/web_api.py`
and `composer.py`.

## Problem (from the owner)

The owner wants to move a finished piece to another key and mode, e.g. from A major
to D minor, keeping everything else: the same notes in the same places, each
note moved to the same scale degree of the new scale.

Today a recipe can be recomposed with another `intent.tonic` / `intent.mode`,
but that is not "everything else unchanged". On seed 802000, A aeolian to
E aeolian keeps the onsets but changes durations (4 -> 2, 8 -> 2) and legato,
and the register jumps unevenly (77 -> 84 but 76 -> 71) because octave choice
and fingering are re-derived per note. In 19 of 24 probes the note set
changed by 0-12 notes per piece.

## Required behaviour

New whole-piece option `key`, stored in `studio.options`, default unset
(today's output byte for byte). Value: `{"tonic": one of TONICS,
"mode": one of ionian, dorian, phrygian, lydian, mixolydian, aeolian,
locrian}`. It applies at once, is undoable/redoable and logged like other
options; locks are unaffected (same rule as the other piece parameters).

1. Every note keeps its onset, duration, guitar, velocity and articulation
intent (dead, palm mute, accent). Its pitch moves to the same scale degree
in the new scale. Chromatic notes (not in the old scale) keep their
offset from the nearest lower scale degree.
2. Register: the whole piece shifts by one common octave offset chosen so that
all pitches fit the guitar range (40-88); within a phrase the melodic
contour (up/down/same between consecutive notes of one guitar) is
preserved. No per-note octave folding.
3. Fingering is recomputed for the new pitches with the existing fretboard
pass; legato/slide/tap are kept where they remain playable under the
existing rules (same string, slide_max, taps above the fretting hand) and
dropped otherwise.
4. After mapping, the existing minor-ninth rule between the guitars holds; if
a mapped note creates a minor ninth, apply the existing resolution and
report how often that happens in the tests.
5. UI: "Тональность" in "Параметры пьесы" — a tonic choice (E, F#, G, A, B,
C#, D, as available in TONICS; add C and F only if trivially supported)
and a mode choice with Russian names (мажор, натуральный минор,
дорийский, фригийский, лидийский, миксолидийский, локрийский), plus
"Как в пьесе" to reset. Hint: "Переводит все ноты в выбранную тональность
по ступеням; ритм и форма не меняются. Применяется сразу." The piece header
shows the current key in Russian.

## Tests (write first)

- Unset key: byte-identical MIDI for the frozen seeds and 20 random seeds.
- For 30 seeds and several target keys: onsets, durations, guitar assignment
identical to the source; each pitch is the mapped scale degree; contour
preserved per guitar; all pitches in 40-88; ComposerInvariants hold;
MusicXML measures fill their meter.
- Mapping to the piece's own key is the identity.
- A -> D minor -> back to the original key restores the original pitches
(round trip), when no note was clipped by range.
- Undo/redo and web_api parity as for the other options.
Loading
Loading