feat(export): export grani in JSON via --grain-json (#73)#93
Open
DMGiulioRomano wants to merge 2 commits into
Open
feat(export): export grani in JSON via --grain-json (#73)#93DMGiulioRomano wants to merge 2 commits into
DMGiulioRomano wants to merge 2 commits into
Conversation
Aggiunge GrainJsonWriter che serializza i grani di ogni stream in JSON
per i client di visualizzazione (PGE-ui#13). Un file per stream:
{cache}/{basename}__{stream_id}__grains.json
- Schema: stream_id, duration, num_voices, grains[{t,dur,vol,ptr,v}]
- t relativo a stream.onset (puo' essere < 0 con onset offset per-voce)
- itera stream.voices per preservare l'indice voce
- JSON compatto, grani ordinati per t
- flag CLI --grain-json, attivo solo con --per-stream
https://claude.ai/code/session_015LPLSKXNZW6Qg67gyzVZcy
…ache_dir I file grain JSON sono sidecar degli stem audio a cui si riferiscono: PGE-ui li trova nella stessa directory degli .aif (output STEMS) invece che in cache_dir, che non ha relazione semantica con l'export e poteva non esistere senza --cache. Riusa il pattern os.path.dirname(abspath) gia' usato per aif_dir nel garbage collect. https://claude.ai/code/session_019N8ZDHmri8tCNCu2WgGRzc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contesto
Chiude #73. PGE-ui (consumer tracciato in PGE-ui#13) deve disegnare i rettangoli dei singoli grani nella clip timeline di ogni stream. L'IR
Grainera già calcolato instream.voicesma mai persistito in forma strutturata (solo.scoCsound o buffer audio). Questa PR aggiunge un flag CLI--grain-jsonche esporta i grani in JSON.Design
Nessuna interfaccia/ABC condivisa tra exporter (scelta deliberata). Reaper export e JSON export divergono troppo — input (
aif_pathsvs no), cardinalità output (1 file vs N), profondità dati (stream-level vs grain-level) — quindi un'astrazione comune ora sarebbe leaky/prematura (Rule of Three: solo 2 exporter).GrainJsonWriternasce standalone e riusa l'unica convenzione utile del Reaper writer: splitgenerate()(puro) /write()(I/O).Modifiche
src/export/grain_json_writer.py(nuovo) —GrainJsonWriterconbuild()/generate()/write(). Iterastream.voicesper preservare l'indice voce, ordina pert, JSON compatto.tests/export/test_grain_json_writer.py(nuovo) — 19 test (TDD rosso→verde).src/main.py— flag--grain-json, attivo solo con--per-stream. I file JSON sono scritti come sidecar accanto agli stem.aif(stessa directory dell'output STEMS), così PGE-ui trova grain JSON e audio nello stesso posto. Usage aggiornato.Schema JSON
Un file per stream, accanto allo stem audio:
{output_dir}/{basename}__{stream_id}__grains.json{"stream_id":"s1","duration":8.0,"num_voices":2,"grains":[{"t":-0.5,"dur":0.05,"vol":-9.0,"ptr":0.1,"v":1}, ...]}t=grain.onset - stream.onset(relativo allo stream; può essere< 0con onset offset per-voce)v= indice voce;dur/vol/ptr=duration/volume/pointer_posptrha unità variabile per stream (secondi o frazione)t, JSON compatto (no whitespace)num_voices=len(stream.voices)(voci effettivamente generate)Verifica
make tests: 4273 passed, 2 skipped — verde.Grain(ordinamento,tnegativo, mapping,write() == generate()).refs/privo di sample audio; il blocco grain-json gira dopo il render). Logica coperta da test unitari e verifica diretta.Impatto cross-repo
.aif— verificare che il consumer cerchi i JSON nella directory degli stem. Nessuna nuova issue (aggiornare PGE-ui#13 se necessario).Changelog branch
3b2c49ffeat: implementazione iniziale--grain-json(output incache_dir).254352cfix: grain JSON scritto accanto agli stem.aifinvece che incache_dir(sidecar coerente con l'audio a cui si riferiscono;cache_dirnon aveva relazione semantica con l'export e poteva non esistere senza--cache).https://claude.ai/code/session_019N8ZDHmri8tCNCu2WgGRzc
Generated by Claude Code