Skip to content

Import CopyVocal bundles (.cvf) as editable projects - #59

Open
Xiantaidu wants to merge 1 commit into
YuFeng926:standalonefrom
Xiantaidu:feat/copyvocal-cvf-import
Open

Xiantaidu wants to merge 1 commit into
YuFeng926:standalonefrom
Xiantaidu:feat/copyvocal-cvf-import

Conversation

@Xiantaidu

@Xiantaidu Xiantaidu commented Nov 12, 2026 •

Copy link
Copy Markdown

What

CopyVocal exports a correction job as a versioned document; this imports it into
OpenTune as a project that can still be edited, rather than as a flat rendered
wav. The student reference audio, the notes, the student's original F0,
CopyVocal's corrected target F0 mapped back to source time, and the
source→output time grid all enter the editing model.

The format identifier is copyvocal.file and the extension is .cvf. The
format is CopyVocal's: this repository carries only the reader and a
user-facing import guide, and the authoritative definition lives in CopyVocal's
own docs/copyvocal-bundle-v1.md.

Structure

  • Source/Utils/CopyVocalBundle.* parses and validates the JSON, decodes the
    base64 F0 arrays, and builds the editable domain types (Note / PitchCurve /
    TimeGridSnapshot). It is deliberately free of the audio engine, project
    session and UI so it can be tested on its own.
  • ProjectSession::prepareCopyVocalBundle runs on a worker: it fits the student
    media to the bundle's declared duration, injects both F0 layers (no extraction
    is started) and proposes an .otproj path next to the bundle.
  • The editor accepts files by menu and by drag-and-drop. The chooser, the
    drag-accept test and the loader all read the extension from
    CopyVocalBundle::kFileExtension instead of spelling it out at each call site.

Time grid granularity

buildTimeGrid emits word granularity. A region spans one word, so its
student/teacher start and end are the anchors worth exposing; the region's
teacher_anchors / student_anchors arrays are sub-word phoneme splits, and
silence / mute regions have a zero-length student span and map nothing.

Expanding the phoneme arrays put 38 handles on a 17-word sentence, with gaps
down to 30 ms
— a wall of handles nobody edits by hand, and dense enough to
fail TimeGridSnapshot::validate's 150 ms editing-spacing rule. Using region
endpoints yields 22 anchors, all on word boundaries, minimum spacing 150 ms.

TimeGridSnapshot::validate now exempts pairs touching a Confidence::High
anchor from that 150 ms minimum. The limit is an editing-UX constraint, not a
DSP invariant, and an externally imported analysis is entitled to place anchors
closer than a human would. Without the exemption a dense grid fails validation
and buildTimeGrid silently falls back to identity — the import "succeeds" with
the time mapping gone, which is the worst possible failure mode.

Docs

docs/copyvocal-import.md is the user-facing walkthrough for this importer and
is whitelisted because docs/ is gitignored upstream. The .gitignore change
uses docs/* rather than docs/ — a trailing slash excludes the directory
itself, and Git then never descends to apply the ! exception.

The bundle format itself is not documented here: .cvf is CopyVocal's file, so
its definition lives in the CopyVocal repository. This repository carries only
the reader.

Requires a matching CopyVocal change

The format identifier is now copyvocal.file and .cvf is the only accepted
extension. CopyVocal's exporter was renamed and updated in the same effort
(application/copyvocal_file.py, --export-cvf, default output
copyvocal.cvf), and its docs/copyvocal-bundle-v1.md defines the format.

There is no compatibility path for the earlier experimental spelling: files
carrying opentune.copyvocal-bundle or a .cvot extension are rejected. The
feature had no external users before this rename.

Tests

  • CopyVocalBundleTests — parses a synthetic bundle; rejects a future
    formatVersion and a duration mismatch; takes a real export as argv[1] for
    a round-trip.
  • CopyVocalImportTests — drives the full prepare path, including the trim case
    where corrected output is shorter than the student media.

41/41 ctest passing. Verified that this branch builds and passes on its own,
without the Stage 1 bake branch.

Relationship to the other PR

Independent of #58, in either merge order. That PR changes how an imported grid
is rendered; this one changes how it is constructed. Both were verified
standalone.

@Xiantaidu
Xiantaidu force-pushed the feat/copyvocal-cvf-import branch from bfd032c to 42a13e0 Compare November 12, 2026 10:03
CopyVocal exports a correction job as a versioned document; OpenTune imports it
as a project that can still be edited, rather than as a flat rendered wav. The
student reference audio, the notes, the student's original F0, CopyVocal's
corrected target F0 mapped back to source time, and the source->output time
grid all enter the editing model.

The format is CopyVocal's: identifier "copyvocal.file", extension .cvf. This
repository carries only the reader and a user-facing import guide; the format
definition lives in CopyVocal's own docs/. There is no compatibility path for
the earlier experimental spelling -- the format had no external users.

- Source/Utils/CopyVocalBundle.* parses and validates the JSON, decodes the
  base64 F0 arrays, and builds the editable domain types (Note / PitchCurve /
  TimeGridSnapshot). It is deliberately free of the audio engine, project
  session and UI so it can be tested on its own.
- ProjectSession::prepareCopyVocalBundle runs on a worker: it fits the student
  media to the bundle's declared duration, injects both F0 layers (no
  extraction is started) and proposes an .otproj path next to the bundle.
- The editor accepts files by menu and by drag-and-drop; the chooser, the drag
  test and the loader all read the extension from CopyVocalBundle::kFileExtension
  instead of spelling it out at each call site.

Two TimeGrid points the importer depends on:

- buildTimeGrid emits word granularity. A region spans one word, so its
  student/teacher start and end are the anchors worth exposing; the region's
  teacher_anchors/student_anchors arrays are sub-word phoneme splits, and
  silence/mute regions have a zero-length student span and map nothing.
  Expanding the phoneme arrays put 38 handles on a 17-word sentence with gaps
  down to 30 ms -- a wall of handles nobody edits by hand.
- TimeGridSnapshot::validate exempts pairs touching a High-confidence anchor
  from the 150 ms minimum source spacing. That limit is an editing-UX
  constraint, not a DSP invariant, and an externally imported analysis is
  entitled to place anchors closer than a human would. Without the exemption a
  dense grid fails validation and buildTimeGrid silently falls back to
  identity, so the import succeeds with the time mapping gone.

docs/copyvocal-import.md is the user-facing walkthrough and is whitelisted in
.gitignore, which ignores docs/ wholesale. The whitelist uses docs/* rather
than docs/ -- a trailing slash excludes the directory itself, and Git then
never descends to apply the ! exception.

Tests: CopyVocalBundleTests parses a synthetic bundle and rejects a future
formatVersion and a duration mismatch (it also takes a real export as argv[1]
for a round-trip); CopyVocalImportTests drives the full prepare path including
the trim case where corrected output is shorter than the student media.
@Xiantaidu
Xiantaidu force-pushed the feat/copyvocal-cvf-import branch from 42a13e0 to 96d4bbf Compare November 12, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant