# Miafy cinematic local tools — 7

Free local, deterministic procedural composition. No model invocation, no registration, no server catalogue admission and no metrics. A browser instrument desk is at `/taller#cine`; founder descriptions stay in browser memory.

After downloading `runtime/miafy-cinema.mjs`, a local JavaScript agent can use:

```js
import {composeCinema, defaultCinema, cinemaMidi, validateCinema} from './miafy-cinema.mjs';
const score = composeCinema({...defaultCinema, palette:'adventure', journey:'hope', seconds:600, intensity:0.65, seed:20260927});
validateCinema(score);
const midi = cinemaMidi(score); // Uint8Array, full-length MIDI type 1
```

No dependencies or account needed for these pure functions. Obtain resources only when you choose to; the runtime does not call a network service. Downloaded code should be reviewed under the agent's own execution policy.

## Contract

`CinemaSpec`: `palette` = chamber | hybrid | adventure | lyrical | space | romantic; `journey` = hope | calm | explore | resolve; `seconds` = integer 5..2400; `intensity` = 0.1..1; `seed` = uint32. Optional `lead` = piano | violin | cello | flute | oboe | clarinet | horn | trumpet; `ensemble` = distinct voice IDs from the manifest (empty means only the lead); `expression` = 0..1. Defaults are piano, chamber palette, piano/strings/cello/oboe accompaniment, expression 0.7. Unknown fields are not copied into output.

`mia-cinema-1` is distinct from the existing `mia-arrangement-1` format. Notes have `voice`, integer MIDI `pitch`, `at` and `duration` in **seconds**, `velocity` and `pan`. Chapters have name, at, end, energy. `origin` is always `procedural-test`. Score duration includes its final coda and fade. The validator enforces numeric note bounds but is not a security boundary for server admission; no upload or execution endpoint is provided.

The local desk uses 122 CC0 VSCO 2 CE samples (approximately 43 MB for the complete bank; only needed samples load for a piece), served from the same site, plus a synthesizer. Source URLs, pinned Git blobs, transformations and SHA-256 hashes are in `/orchestra/manifest.json`; license and credits are alongside it. The small bank does not reproduce the expressiveness of a professional orchestra. It contains recordings of real musicians playing individual notes; compositions are produced by rules.

MIDI carries the full composition and chapter markers, with General MIDI timbres that approximate—not embed—the browser instruments. The browser streams scheduled notes with look-ahead, rather than rendering 40 minutes into RAM. Keep the page visible; it pauses when hidden and iOS can suspend audio. WAV export is at most 60 seconds from the current position (or the entire piece if <=60s), with a short ending fade. Adjacent WAV fragments are not seamless stems.

## Creative limits

No copyrighted themes or recordings from film scores are included. The six palettes describe broad musical approaches, not clones or endorsements by composers. Sustain notes can last up to 28 seconds using crossfaded loops; common accompaniment tones tie across bars, optional legato-style overlaps are synthesized, not recorded interval transitions. Multiple recorded dynamic layers exist for some instruments, not all. Short strings and bass drum alternate two takes. A cello protagonist uses section samples, not a solo cello. MIDI dynamics do not reproduce the browser envelope.

Development uses seeded motifs, harmonic changes, question/answer phrases, register, dynamics and instrumentation. Repetition remains possible; no human-quality, originality, copyright ownership or emotional effect is certified. Text recognition is limited Spanish/English keyword matching with editable preferences; it is not general instruction following.

## Phrase performance (revision 3)

`performance` may be `phrased` (default) or `even` (comparison with previous note-level expression). With identical seed and other controls, pitches, roles and note count remain the same. The phrased mode adds shared timing deviations (bounded approximately 4% local tempo), phrase arcs and continuous crossfades between recorded dynamic layers when both exist. Notes spanning a phrase extend their gesture through the held note. Register and role balances are heuristic, not a calibrated physical orchestra. Exact total duration is retained. Browser MIDI exports CC11 expression curves; it intentionally does not map timbre to CC1 because General MIDI players may interpret CC1 as vibrato. Samples and interval legato limitations remain.

Browser comparison requires recomposing with the same seed and pressing Listen again. It is not blinded, loudness-matched or evidence of emotional impact.

## Piano and chamber (revision 4)

`palette: chamber` creates a distinct sparse arrangement with staggered entries, generated motif/answer, slower harmony and a continuous energy arc. It is an original rule design, not a transcription or an audio-conditioned model. The upright piano has 39 recordings (13 roots, three force layers) with natural decay, common recording gain and no loops/pedal simulation. One piano layer is selected at each attack; phrase swells and CC11 are reserved for sustained instruments. More than 15 pitched MIDI voices use port metadata; playback requires multi-port support. No perceptual equivalence to a concert piano, Nyman or a film score has been verified.

Piano roots now span MIDI 37..85 every four semitones, limiting transposition in that range to two semitones. Notes outside it use the nearest edge sample. Soft/medium/strong attacks are selected by note velocity; sustained instruments still crossfade. Download size in the desk is calculated from only the selected PCM files, not the whole bank. No new model, plugin or paid service.

## Scene composition (revision 5)

`composition: scene` is the current default; legacy preserves the previous deterministic engine. Each seed generates two melodic contours, rhythmic patterns, meter, harmony cycle, harmonic pace, phrase length and accompaniment pattern. `scenes` accepts the ordered mood IDs from ENTRY.md. The Spanish/English text helper detects limited keywords; it is not an LLM or complete scene understanding. Fresh-button seeds change every time; phrase comparison keeps the seed. No uniqueness against world repertoire or human-level quality is certified. Public structured HTTP entry is documented in ENTRY.md; it returns unpersisted scores and does not admit catalogue uploads.

## One scene, three musical perspectives (revision 6)

The **local** module and browser now support `perspective`: intimate | narrative | kinetic, `pace`: spacious | balanced | driving, `climax`: 0.3..0.9 and `ending`: resolved | open | fading. They affect composition and form, not just timbre. `composeThreePerspectives(spec)` returns three scores with the same scene, ensemble, duration and seed. The grammars differ in melodic contour, harmonic routes, rhythm, phrase length, density and development. Phrase timing follows the generated phrase boundaries. Short pieces simplify their form; longer ones add response, contrast, development and return sections. This remains finite procedural music, not an unrestricted composer.

```js
import {composeThreePerspectives, defaultCinema, validateCinema, cinemaMidi}
  from './miafy-cinema.mjs';
const scores = composeThreePerspectives({
  ...defaultCinema, seconds:90, seed:202610032,
  scenes:['mystery','tension','hope'], pace:'balanced',
  climax:0.75, ending:'resolved', lead:'piano',
  ensemble:['piano','strings','cello','oboe']
});
for (const score of scores) validateCinema(score);
const midi = cinemaMidi(scores[1]); // notes, not a rendered audio recording
```

Reproducible examples are in `examples/intimidad.json`, `examples/tension.json` and `examples/asombro.json`. Their recipes and authorship/origin labels are included; there is no claim of independent participants. Load their `spec` with `composeCinema`. Player links are `/taller?example=intimidad#cine`, `/taller?example=tension#cine`, and `/taller?example=asombro#cine`.

The **HTTP API retains revision 5** and its published limits; it does not accept these new local fields. Existing revision-5 recipes remain reproducible. The browser's three-perspective action uses the local module and does not consume API quota. The browser keeps only the selected score and three recipes, and reuses already decoded required samples when changing perspective.

For measured comparisons hold instruments and seed constant, compare lead pitch **intervals**, normalized inter-onset times and harmony degrees. This can establish difference, not beauty or emotion. `performance: even` is useful for isolating composition from expression. The workshop's phrased/even switch is not a blind listening study.

`critiqueTemplate(score, position)` creates an empty, unsent local critique. See [CONVERSATIONS.md](./CONVERSATIONS.md) for the Spanish/English workflow, evidence labels, comparisons and the shared-service work that remains unactivated.

## Revise a musical idea (revision 7)

The workshop separates **Aplicar ajustes** (revise the current recipe) from **Crear otra idea musical** (new seed and three new perspectives). Revision keeps each recipe's seed, composition engine and perspective. Changing accompaniment or intensity can retain the lead theme; changing scenes, duration or narrative pace can restructure the music. It is not a promise to keep every note under every edit.

```js
import {reviseCinema, composeCinema} from './miafy-cinema.mjs';
const revised = reviseCinema(score.spec, {ensemble:['strings','cello'], intensity:0.35});
const restored = composeCinema(score.spec); // exact original recipe
```

`reviseCinema(reference, changes)` preserves the reference's `seed`, `composition` and `perspective` even if they appear in `changes`. Other choices use the existing validation. It creates a fresh score without mutating the reference. Older scene-1/legacy recipes retain their engine. This helper is local; the HTTP contract is unchanged.

The browser retains **one previous recipe set** in tab memory for recovery. It is not an account, backup or saved catalogue. Save JSON/MIDI or copy the musical recipe link before closing the page. The previous free-text description, if any, remains only in tab memory and is not included in downloads or links; **Borrar texto** also clears it from this recovery state. While edits are pending, apply or discard them before choosing another perspective so they are not silently lost.
