From 5d650d9a2fd9fd0f5103e9ed51ad7feba08d4e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 16 Nov 2026 00:58:32 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Pitch=20takes=20fractional=20semito?= =?UTF-8?q?nes=20(v58=20when=20one=20is=20set),=20a=20speed=20ramp=20holds?= =?UTF-8?q?=20up=20to=2064=20keys,=20a=20given=20audio=5Fkbps=20re-encodes?= =?UTF-8?q?=20the=20sound=20rather=20than=20being=20refused,=20and=20EDITH?= =?UTF-8?q?=5FFONTS=5FDIR=20adds=20font=20folders=20ahead=20of=20the=20sys?= =?UTF-8?q?tem's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCP.md | 8 +- crates/app/src/export_ui.rs | 1 + crates/app/src/player/cards.rs | 6 +- crates/app/src/player/export.rs | 2 +- crates/app/src/player/sections.rs | 2 +- crates/app/src/tests/cards.rs | 4 +- crates/app/src/tests/editing.rs | 8 +- crates/app/src/tests/layout.rs | 2 +- crates/app/src/tests/menu_wire.rs | 2 +- crates/app/src/tests/view.rs | 2 +- crates/app/src/timeline_math.rs | 2 +- crates/app/src/ui/cards/mix.rs | 17 ++-- crates/engine/examples/bench.rs | 2 +- crates/engine/src/audio.rs | 2 +- crates/engine/src/beats.rs | 2 +- crates/engine/src/edith.rs | 60 +++++++------ crates/engine/src/export.rs | 31 ++++--- crates/engine/src/playback.rs | 15 ++-- crates/engine/src/project.rs | 90 +++++++++---------- crates/engine/src/proxy.rs | 2 +- crates/engine/src/silence.rs | 2 +- crates/engine/src/sweep.rs | 2 +- crates/engine/src/text.rs | 30 +++++-- crates/engine/tests/audio_mix_rates.rs | 2 +- crates/engine/tests/export.rs | 8 +- crates/engine/tests/it/audio_export.rs | 24 ++--- crates/engine/tests/it/audio_files.rs | 2 +- crates/engine/tests/it/av1_software_export.rs | 2 +- crates/engine/tests/it/av_sync.rs | 2 +- crates/engine/tests/it/clip_gain.rs | 2 +- crates/engine/tests/it/duck_audio.rs | 2 +- crates/engine/tests/it/eq_audio.rs | 2 +- crates/engine/tests/it/pan.rs | 2 +- crates/engine/tests/it/placement_walls.rs | 2 +- crates/engine/tests/it/project_fuzz.rs | 4 +- crates/engine/tests/it/reverse.rs | 2 +- crates/engine/tests/it/silence.rs | 4 +- crates/engine/tests/it/transform_keys.rs | 2 +- crates/engine/tests/it/trim_walls.rs | 2 +- crates/engine/tests/it/undo_stress.rs | 2 +- crates/engine/tests/it/voice_audio.rs | 2 +- crates/engine/tests/it/voice_early_stop.rs | 2 +- crates/engine/tests/lanes.rs | 4 +- crates/engine/tests/opus_export.rs | 4 +- crates/mcp/src/help.rs | 4 +- crates/mcp/src/tools/edit.rs | 6 +- crates/mcp/src/tools/edit_fx.rs | 20 ++--- crates/mcp/src/tools/export.rs | 3 +- crates/mcp/src/tools/look.rs | 10 +-- 49 files changed, 226 insertions(+), 189 deletions(-) diff --git a/MCP.md b/MCP.md index 4299235..31d9cb0 100644 --- a/MCP.md +++ b/MCP.md @@ -334,12 +334,12 @@ prints it live, and `help {topic:""}` gives one op's entry. The recipes and | place | `place {source, at, lane?, in?, out?, length?, stretch?, audio?, audio_lane?, audio_track?, overwrite?}` (no lane: linked V1+A1; with lane: overwrites it; `at:"end"` is the timeline end, not the lane's, so it can leave a hole on a lane that ends sooner; a `length` past the source is refused ("runs past the source end") unless `stretch:true`; `audio_track:N` picks the sound track of a multi-audio file, 0-based as `media_probe` numbers them, and a track other than the source's own is placed as a source of its own, `src:N` with the same file name) · `append {source, in?, out?}` (to the end of its lane; not the timeline end) · `keep {source, ranges:[[in,out]…], lane?, at?}` (ranges back to back, the rough-cut workhorse) · `assemble {items:[{source,in?,out?}…], lane?, at?, gap?}` (keep across sources) | | three-point | `insert {source, in?, out?, at, to?, length?, lanes?}` · `overwrite {source, in?, out?, at, to?, length?, lanes?}` (`src` also spells `source`; the source range `in..out`, else the whole file, goes at `at`; `to` is a timeline out mark and `length` a duration, either sets the length from `in` instead of `out`; the take lands on `lanes`, at most one V and one A, else the first unlocked V and A lanes the source has, linked as one take; a still takes a V lane and `length` (default 5 s), a song an A lane. `insert` cuts the clip `at` falls inside and ripples what follows on those lanes only; it never moves or splits a lane outside the take, and refuses by name when that would pull a linked take apart. `overwrite` replaces what is there, trimming or splitting it, and nothing moves. Captions and titles keep their time; a locked lane refuses; one undo step each) | | cut | `split {at, lanes?}` · `trim {clip, edge: in\|out, to, scope?}` [group] · `roll {clip, by\|to, edge?}` [group] (move the cut between two clips) · `slip {clip, by}` [group] (shift the source in/out, same slot) · `slide {clip, by}` [group] (move the clip between its neighbours) · `move {clip, at, to_lane?, insert?, titles?, split_captions?}` [group] (`insert:true` is a ripple move) · `delete {clip}` [group] · `lift {clip}` · `ripple_delete {clip}` · `close_gaps {lane}` · `cut_regions {regions:[[from,to]…], lanes?}` (accepts `silence` output verbatim) · `insert_time {at, duration, lanes?}` (ripples empty time in; a clip `at` falls inside is cut first) · `remove_time {at, duration, lanes?}` (the `cut_regions` cut for one span; a title wholly inside the span is removed, and one straddling an edge is trimmed to the part outside; the reply names both) · `swap {a, b}` (two clips on one lane trade places; a clip in a linked take is refused until the take is ungrouped) | -| time | `speed {clip, x}` 0.25–4 [group] (x is the absolute rate, not a multiplier: re-sending 0.5 on a clip already at 0.5 changes nothing) · `reverse {clip, on?}` [group] (plays the clip backward, picture and sound, or forward again; `on` omitted toggles; composes with speed and ramps; a still refuses; `clip_info` and `timeline` say `reversed`) · `speed_ramp {clip, keys:[{at, speed}…], ripple?, lanes?}` [group] (up to 8 keys at clip-relative times, speed 0.25–4 linear between them and held outside them; `keys:[]` clears the ramp) · `fade {clip, in?, out?}` (int = frames, `"0.5s"` = time) · `dissolve {clip, frames}` (video transition into the next clip) · `transition {clip, kind?=dissolve, length?, direction?}` (the same overlap with a look: `dissolve`, `dip-black`, `dip-white`, `wipe`, `slide`, `push` or `zoom`; `wipe`/`slide`/`push` move `left` (default), `right`, `up` or `down`, the way things move, so `wipe-left` shows the next clip from the right edge; `length` or `frames` is the overlap, kept when omitted; `dissolve` accepts `kind` too; the picture changes with the kind, the sound is always the crossfade; `timeline` flags and `clip_info.transition_kind` show it) · `crossfade {clip, frames}` (audio) · `freeze {at, duration, lane?=V1, insert?=true}` (holds the composed frame at `at` as a still; needs a project path, saved or not; see below) | +| time | `speed {clip, x}` 0.25–4 [group] (x is the absolute rate, not a multiplier: re-sending 0.5 on a clip already at 0.5 changes nothing) · `reverse {clip, on?}` [group] (plays the clip backward, picture and sound, or forward again; `on` omitted toggles; composes with speed and ramps; a still refuses; `clip_info` and `timeline` say `reversed`) · `speed_ramp {clip, keys:[{at, speed}…], ripple?, lanes?}` [group] (up to 64 keys at clip-relative times, speed 0.25–4 linear between them and held outside them; `keys:[]` clears the ramp) · `fade {clip, in?, out?}` (int = frames, `"0.5s"` = time) · `dissolve {clip, frames}` (video transition into the next clip) · `transition {clip, kind?=dissolve, length?, direction?}` (the same overlap with a look: `dissolve`, `dip-black`, `dip-white`, `wipe`, `slide`, `push` or `zoom`; `wipe`/`slide`/`push` move `left` (default), `right`, `up` or `down`, the way things move, so `wipe-left` shows the next clip from the right edge; `length` or `frames` is the overlap, kept when omitted; `dissolve` accepts `kind` too; the picture changes with the kind, the sound is always the crossfade; `timeline` flags and `clip_info.transition_kind` show it) · `crossfade {clip, frames}` (audio) · `freeze {at, duration, lane?=V1, insert?=true}` (holds the composed frame at `at` as a still; needs a project path, saved or not; see below) | | look | `color {clip, brightness?, contrast?, saturation?, tint?, reset?}` · `transform {clip, x?, y?, corner?, margin?, scale?, rotate?, crop?:[l,r,t,b], opacity?, reset?}` (`corner` is centre, top-left, top-right, bottom-left or bottom-right: the engine sets x and y from the picture's own size (after crop and quarter turn), the scale given and a `margin` in pixels (default 32) from the two edges it touches; giving x or y with corner is refused, and so is margin without corner; picture in picture is `corner:"bottom-right", scale:0.3`) · `transform_keys {clip, keys?:[{at, x?, y?, scale?, rotate?, opacity?, ease?}…], clear?}` (animates the transform over the clip's own time) · `opacity_keys {clip, keys?:[{at, opacity, ease?}…], clear?}` (opacity 0..1 over the clip's own time, fades multiply on top) · `color_keys {clip, keys?:[{at, brightness?, contrast?, saturation?, tint?, ease?}…], clear?}` (the grade over the clip's own time, interpolated per frame) · `look {clip, name}` (the whole grade becomes a look, one undo step: a built-in `Warm`, `Cool`, `Teal & orange`, `Bleach bypass`, `Black & white`, `Faded film`, `High contrast` or `Vintage`, or a saved one from the colour card's "Save current as look" (`$XDG_DATA_HOME/edith/looks/.look`); an unknown name is refused with the list; `help {topic:"looks"}` lists them) · `look {clip, save:""}` (the reverse: the clip's grade is saved as a look of that name, as the grading card's "Save current as look" does; the project does not change, so no undo step; a built-in's name is refused) · `auto_color {clip}` (reads the clip's middle frame as shot: grey-world white balance into the wheels' channel gains, then brightness and contrast so the 0.5 % and 99.5 % luma percentiles land near 0.02 and 0.98; saturation, tint, curves and LUT kept; the reply gives the values set; one undo step) · · `wheels {clip, lift?, gamma?, gain?, reset?}` (each `[master, red, green, blue]`, -1..1, or one number for the master) · `curves {clip, master?, red?, green?, blue?, reset?}` (each up to 16 `[input, output]` points in 0..1, monotone cubic; `[]` straightens one) · `lut {clip, path?, mix?, clear?}` / `lut {relink, path}` (a `.cube` file, 1D or 3D up to 65, tetrahedral, mix 0..1; a broken file is refused; relink moves every clip naming a file, one undo step). The grade runs wheels → curves → LUT → the four sliders, in Rec. 709 R'G'B' for the first three; colour keys animate the sliders and the look holds under them; saved as v43 `wheels`/`curve`/`lut` lines. Recipe: `edit {ops:[{op:"lut", clip:"V1@0", path:"~/luts/warm.cube", mix:0.8}]}`, then `scopes {at:"2s"}` to read the shift · `copy_look {from, to | to_lane, what?}` (copies colour, transform, fit, effects, EQ, gain or speed onto other clips, one undo step) · `replace {clip, source, in?}` (the replace edit: overwrite the clip and its linked half with another source, same place and length) · `nudge {clips, by}` [group] (move clips by a signed distance, all or nothing) · `fit {clip, policy: fit\|fill\|stretch\|center}` · `deinterlace {clip, mode: frame\|field\|off\|ivtc-auto\|ivtc}` (how a video clip's interlaced source is made progressive, frame by default; only matters for an interlaced source, which `media_probe` reports; field and off are stored, the render acts on frame for now; `ivtc` removes 3:2 pulldown from telecined 29.97i H.264 and MPEG-2, giving the 23.976p film frames (best cadence found in the first 60 pictures, one cadence for the whole file), `ivtc-auto` does so only when that cadence is clear and otherwise deinterlaces as frame; put the project on 23.976 (`set_frame_rate`) for one timeline frame per film frame; soft pulldown (MPEG-2 repeat_first_field, H.264 pic_struct) in a transport stream is always presented as 23.976p; saved as v46 `deint` lines) · `visualizer {clip, on?, style?, fast?}` (the clip becomes a sound picture: style fill\|ribbon\|ring\|wave, fill by default; `fast` paints from a 0.2 s window; `on:false` turns it off, from the waveform picture or from the sound clip). On a sound clip, `on:true` places a waveform picture on the next free top picture lane (V2 or V3), grouped with the sound and covering the picture under it where they overlap; place it with `transform` (x, y move its centre, -1 to 1; scale; opacity). A picture address (`V1@…`) is mapped to its linked sound clip, which gets the picture; a picture with no linked sound is refused · `reframe {clip, aspect?=fit, smoothness?=0.5}` (auto reframe: a cheap saliency per sampled frame -- what moved since the last sample, local contrast, a pull to the middle, no models -- gives the subject's path, which is smoothed (`0.25 + 1.75 × smoothness` s), held still inside a dead zone and thinned to the keys where it turns; the keys scale the clip to cover the canvas and pan the subject to the middle, clamped so no edge ever shows; sets `fit` to fit and replaces the clip's `transform_keys` in one undo step, so no format change; it analyses before it answers; `aspect` is a guard that the project canvas has that shape; `engine::reframe`) · `stabilize {clip, on?, strength?=0.5, crop?=zoom, off?, cancel?}` (takes the camera shake out of a video clip: corners tracked frame to frame by pyramidal Lucas-Kanade, a shift-turn-zoom fitted by RANSAC, the camera path smoothed by a Gaussian of strength × 2 s (a steady pan is kept), each frame moved to the smoothed path before the clip's transform; `crop` `zoom` enlarges just enough that no frame shows an edge (≤1.5×), `full` keeps the frame and shows black edges; the analysis runs in the background, is cached per source and file-frame range under `~/.cache/edith/stabilise`, follows the footage through trims, speed, ramps and reverse; an export measures a missing analysis itself, which `export_status` shows as its `Measuring shake` stage with its own percent, while `frame` and `contact_sheet` never wait: they start it, draw the clip unstabilised and say the analysis is pending; `engine::stabilise`, format v44) | | generated | `generator_add {kind: solid\|gradient\|countdown\|bars\|rectangle\|ellipse\|line\|arrow, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?, lane?=V1, at?, duration?=5s}` (shapes `rectangle`, `ellipse`, `line` and `arrow` draw on a transparent canvas and composite over the lanes below: `fill` and `stroke` are `"#rrggbb"` or `"none"`, `width` the stroke in pixels 0..400, `radius` rounds a rectangle 0..2000; a line and an arrow are all stroke, a line runs left to right and an arrow points right; a shape lands at 40% scale and its size and place are the clip's `transform`; a clip made from numbers instead of a file: `color` is `"#ff3366"`, `angle` 0..359 degrees with 0 left to right and 90 top to bottom, `from` the countdown's whole seconds 1..3600, which is also its default duration; `at` defaults to the end of the lane; the lane must exist; a param the kind does not take, an unknown kind or a bad colour is refused by name; it overwrites what it lands on like a still, and is an ordinary clip afterwards, so trim, move, split, `color`, `transform` and effects all work) · `generator_set {clip, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?}` (params merged onto a generator clip, place and length kept; a clip that plays a file is refused) · `adjustment_add {lane?=V2, at?, duration?=5s}` (a clip with no picture whose grade and effects reach everything composed beneath it; with no lane, V2, added when there is only V1; a transform on it moves the whole composite below, so uncovered area goes black, while crop only limits where it reaches and cropped-away areas keep the untouched picture; adjacent layers hard-cut) · `label {clip \| clips, value}` (a name from the label palette in any case, 1..8, or `none`) · `enable {clip \| clips, on}` (`on:false` keeps the clip but skips its picture and sound; an off adjustment layer stops adjusting). One undo step each; `timeline` and `clip_info` show `generator solid #ff3366`, `adjustment layer`, `label Rose` and `disabled`, and `media_list` does not call a generator an offline file. A generator's source is a pseudo-path `/edith-gen/.gen` (`engine::generate`), so the library, trims and saves treat it as a still. Format v48 (older formats still load): written only when a project has a generator, a label or a switched-off clip, so other projects keep their older version | | sequences | `nest {clips:[addr…], name?}` (folds the picked clips and their linked partners into a new sequence and leaves one compound clip, on the lowest picked video and sound lanes, linked; refuses when an unpicked clip sits between picked ones; one undo step) · `break_apart {clips}` (puts a compound clip's contents back, trimmed to the stretch it played, one undo step) · `place_sequence {sequence, at, lane?=V1}` (a sequence as a compound clip; a cycle is refused). A compound clip's source is `1<<30 + sequence id`; the render inlines it into the flat timeline, so a nested render equals the flat one; it has no speed, ramp or reverse (refused) and its own colour/effects/transform are not applied. Format v45 (`MAGIC_V44` still loads): the active sequence is the body as before, then `seqactive `, `seqorder ` and one `seq ` … `endseq` block per parked sequence holding a complete document; only written when there is more than one sequence or a compound clip, so other projects stay v44 or older. The frame rate is locked then | | multicam | `angle {clip, at?, angle?, audio?}` (switches a multicam clip's angle from `at` on: the clip is cut there when `at` is inside it, and the right part shows `angle`, a number from 1 or a name; the sound follows the picture unless `audio` is `"follow"` or an angle, which keeps it there; `clip` may be the picture or its linked sound clip; one undo step; refused for a clip that is not multicam, an angle that does not exist, or no change). A multicam clip is a compound clip (`source = 1<<30 + id`) with an `Angle {video, audio?}` on the clip; the sequence it plays is flagged multicam and holds angle `n` as its `n`th video lane and `n`th audio lane, so the render inlines exactly that angle's lane (`expand`), `break_apart` and `multicam_flatten` do the same. `timeline` rows read `multicam "Name" angle 2 "cam_b"`. Format v47 (`MAGIC_V46` and older still load; the version lives in `edith.rs` `MAGIC`/`NEWEST_VERSION`): `mcam ` lines in angle order after `seqorder`, and `angle ` per clip that is not on angle 1 (angles counted from 1); written only when a project has a multicam source or a switched clip, so other projects keep their older version | -| sound | `eq {clip, bands:[{f,db,q,kind}] (max 10), reset?}` (f 20–20000 Hz, db ±12, q 0.3–12 default 0.707; kind peak (default), low_shelf, high_shelf, low_cut, high_cut) · `gain {clip, db (-60..24) \| add_db}` (one audio clip's own volume, on top of its lane's; relative steps clamp to the range) · `gain_keys {clip, keys:[[time, db]…]}` (the clip's volume envelope, audio only: replaces all points, `[]` clears, max 256; times are timeline times inside the clip) · `gain_key {clip, at, db}` (one point; the same frame is replaced) · `gain_key_remove {clip, at}` (the point within a frame of `at`; a miss lists the points) · `gain_ramp {clip, from, to, to_db, from_db?}` (straight dB ramp; `from_db` defaults to the envelope's level at `from`) · `gain_dip {clip, from, to, db, ramp?="0.5s"}` (dips over `from..to` with ramps in and out, starting from the level there now and clamped to the clip). The ramp and dip ops replace the points inside their span. · `lane_gain {lane, db}` (-60..12) · `pan {clip, pan}` (-1 left .. 1 right, 0 the middle; an audio clip's balance, format v50 `clippan` line) · `pitch {clip, semitones}` (-12..12 whole semitones, 0 the original; an audio clip's pitch with its speed kept, format v52 `pitch` line) · `lane_pan {lane, pan}` (the same for an audio lane, on top of the clips' `lanepan` line) · `limiter {on?, ceiling_db?}` (ceiling -24..0 dB) · `duck {lane, under, depth_db?=-12, threshold_db?=-40, attack_ms?=80, release_ms?=400, off?}` (the lane dips while the key lane speaks) |· `dynamics {lane, gate?, nr?, compressor?, deesser?, reset?}` (an audio lane's voice processors, run gate, noise reduction, compressor, de-esser after the clips' own EQ and before the limiter; each is true, false (bypass) or an object of settings; `engine::voice`, format v41) | +| sound | `eq {clip, bands:[{f,db,q,kind}] (max 10), reset?}` (f 20–20000 Hz, db ±12, q 0.3–12 default 0.707; kind peak (default), low_shelf, high_shelf, low_cut, high_cut) · `gain {clip, db (-60..24) \| add_db}` (one audio clip's own volume, on top of its lane's; relative steps clamp to the range) · `gain_keys {clip, keys:[[time, db]…]}` (the clip's volume envelope, audio only: replaces all points, `[]` clears, max 256; times are timeline times inside the clip) · `gain_key {clip, at, db}` (one point; the same frame is replaced) · `gain_key_remove {clip, at}` (the point within a frame of `at`; a miss lists the points) · `gain_ramp {clip, from, to, to_db, from_db?}` (straight dB ramp; `from_db` defaults to the envelope's level at `from`) · `gain_dip {clip, from, to, db, ramp?="0.5s"}` (dips over `from..to` with ramps in and out, starting from the level there now and clamped to the clip). The ramp and dip ops replace the points inside their span. · `lane_gain {lane, db}` (-60..12) · `pan {clip, pan}` (-1 left .. 1 right, 0 the middle; an audio clip's balance, format v50 `clippan` line) · `pitch {clip, semitones}` (-12..12 semitones, fractions too, 0.37; 0 the original; an audio clip's pitch with its speed kept, format v55 `pitch` line, v58 when fractional) · `lane_pan {lane, pan}` (the same for an audio lane, on top of the clips' `lanepan` line) · `limiter {on?, ceiling_db?}` (ceiling -24..0 dB) · `duck {lane, under, depth_db?=-12, threshold_db?=-40, attack_ms?=80, release_ms?=400, off?}` (the lane dips while the key lane speaks) |· `dynamics {lane, gate?, nr?, compressor?, deesser?, reset?}` (an audio lane's voice processors, run gate, noise reduction, compressor, de-esser after the clips' own EQ and before the limiter; each is true, false (bypass) or an object of settings; `engine::voice`, format v41) | | lanes | `lane_add {kind}` · `lane_remove {lane}` · `lane_move {lane, to}` · `lane_flags {lane, hidden?, muted?, locked?}` · `lane_name {lane, name}` (the lane's display label, like a track name, at most 40 characters, `""` clears it; the address V1/A2 is unchanged and still what every op takes; `timeline` shows the name on the lane header and as `name` in its structured lanes; one undo step; saved as v46 `lanename` lines) | | group | `group {clips:[addr…]}` · `ungroup {clip}` | | captions | edit ops, not tools: `subtitles_import {path}` (tracks, no lane yet) · `captions_place {track, lane?, at?}` · `sub_move {clip, at, to_lane?}` [group] · `sub_trim {clip, edge:in|out, to}` · `sub_delete {clip}` · `captions_remove {track, force?}` · `cue_add {track, at, to, text, overwrite?}` · `cue_text {track, index, text}` (`\n` = line break) · `cue_delete {track, index}` · `cue_time {track, index, at?, to?}` (timeline times: trim or move one cue inside its neighbours, 0.1 s minimum) · `cue_merge {track, index}` (with the next cue) · `cue_split {track, index, at}` · `cue_replace {track?, find, replace, case_sensitive?}` (every cue of one track, or all tracks; case-insensitive unless `case_sensitive`; reports occurrences and cues). Written as `edit {ops:[{op:"cue_text", …}]}`; `captions` (the tool) lists the cues as `track T cue C` | @@ -402,11 +402,13 @@ flag turns that off; the server does not pass it. Voice needs piper (`EDITH_PIPER`, or `~/.local/share/piper-venv/bin/piper`). Piper's stderr is reported on failure. +Subtitle fonts: `EDITH_FONTS_DIR` (directories separated by `:`) adds font files that win over system fonts. + ### 4.7 Export | tool | args | does | |---|---|---| -| `export_start` | **out**, preset (an `export_presets` id; explicit args override it), loudness (-30 to -5 LUFS, the integrated target; the true peak holds at the preset's ceiling or -1 dBTP, the gain is cut back and never a limiter), format (mp4, av1, av1-mp4, hevc, hevc-mp4, webm, wav, flac, mp3, ogg, m4a, opus, prores, png_sequence, still, gif), gif_width (320/480/640/720, default 480), gif_fps (1-60, default 15), gif_loop (default true), range, size, fit, bitrate_kbps, qp (0-51, a constant quantiser instead of a bitrate: the hardware seat for H.264, HEVC and AV1, and software HEVC; software H.264 and AV1 refuse it; not with bitrate_kbps), keyframe_s (0.1-10 seconds between key frames of the picture, default the encoder's two; not with intra_only), faststart (true lays an mp4, hevc-mp4, av1-mp4 or m4a out moov-first so it plays before it is fully read; other formats refused), audio_kbps (128/192/256/320, and 384 for AAC only: mp4, av1, av1-mp4, hevc, hevc-mp4, m4a), bit_depth (8\|10; 10 is AV1 and HEVC only), prores_profile (proxy\|lt\|standard\|hq\|4444\|4444xq; format `prores`, a `.mov`), hdr (off\|pq\|hlg; HEVC only, implies 10-bit), hevc_speed (default\|fast\|faster; HEVC only: fast is about 1.2-1.6x quicker for 0-3% more bits, faster about 1.5-2x quicker for up to 27% more), audio_bit_depth (16\|24; ProRes sound), chapters (default true; `"markers"` writes the comment markers as the chapters), intra_only, seat (auto\|hardware\|software), subtitles, burn_captions, overwrite | starts an export; returns `job:` at once. The reply counts the chapters written (`3 chapters`) and, for an AV1 or HEVC file, its depth (`output 10-bit, from the source`) · `queue` (true: line the export up behind the others -- it keeps its own copy of the timeline as it is now, so later edits do not change it, and starts when every earlier export has finished, one encode at a time, polled or not; `export_status` shows it as `waiting`; default false starts at once beside any others) | +| `export_start` | **out**, preset (an `export_presets` id; explicit args override it), loudness (-30 to -5 LUFS, the integrated target; the true peak holds at the preset's ceiling or -1 dBTP, the gain is cut back and never a limiter), format (mp4, av1, av1-mp4, hevc, hevc-mp4, webm, wav, flac, mp3, ogg, m4a, opus, prores, png_sequence, still, gif), gif_width (320/480/640/720, default 480), gif_fps (1-60, default 15), gif_loop (default true), range, size, fit, bitrate_kbps, qp (0-51, a constant quantiser instead of a bitrate: the hardware seat for H.264, HEVC and AV1, and software HEVC; software H.264 and AV1 refuse it; not with bitrate_kbps), keyframe_s (0.1-10 seconds between key frames of the picture, default the encoder's two; not with intra_only), faststart (true lays an mp4, hevc-mp4, av1-mp4 or m4a out moov-first so it plays before it is fully read; other formats refused), audio_kbps (128/192/256/320, and 384 for AAC only: mp4, av1, av1-mp4, hevc, hevc-mp4, m4a; given, the sound is re-encoded at it rather than copied, a preset's counts too), bit_depth (8\|10; 10 is AV1 and HEVC only), prores_profile (proxy\|lt\|standard\|hq\|4444\|4444xq; format `prores`, a `.mov`), hdr (off\|pq\|hlg; HEVC only, implies 10-bit), hevc_speed (default\|fast\|faster; HEVC only: fast is about 1.2-1.6x quicker for 0-3% more bits, faster about 1.5-2x quicker for up to 27% more), audio_bit_depth (16\|24; ProRes sound), chapters (default true; `"markers"` writes the comment markers as the chapters), intra_only, seat (auto\|hardware\|software), subtitles, burn_captions, overwrite | starts an export; returns `job:` at once. The reply counts the chapters written (`3 chapters`) and, for an AV1 or HEVC file, its depth (`output 10-bit, from the source`) · `queue` (true: line the export up behind the others -- it keeps its own copy of the timeline as it is now, so later edits do not change it, and starts when every earlier export has finished, one encode at a time, polled or not; `export_status` shows it as `waiting`; default false starts at once beside any others) | | `export_presets` | – | lists the export presets (id, label, format, bitrate_kbps, audio_kbps, size, bit_depth, prores_profile, hdr, loudness): youtube_1080p/1080p60/1080p_hevc/4k/4k60/4k_hevc, shorts_reels, podcast, podcast_ogg and podcast_opus (-16 LUFS, -1 dBTP), archive (10-bit AV1 mkv), archive_prores (ProRes 422 HQ .mov), hdr10_hevc (10-bit HEVC mp4 tagged PQ), archive_flac, archive_wav | | `export_captions` | format (`srt` or `vtt`, required unless chapters), path, overwrite, chapters | writes the timeline's captions (every cue on the subtitle lanes, in start order) as SRT or WebVTT; picture and empty cues are left out. Without `path`: ` edit.` in the Videos folder. Refuses an existing file unless `overwrite` is true, and writes nothing when there are no captions. `chapters: true` writes nothing and returns the chapter markers as the YouTube description listing (`00:00 Intro`, one line each), the text File > Copy chapters copies, as the reply text and as JSON (`chapters` lines, `text`, `warnings`) | | `proxies` | action (`status`, the default, `make`, `cancel` or `delete`), source (`src:`, a list or `"all"`) | the editing copies (proxies) of sources. `status` shows each source's state (ready, making with its percent, off, not needed for a sound or still, or why a stand-in failed). `make` starts one in the background and turns that film's switch back on; a film that plays at speed on this machine needs none, and says so. `cancel` stops one being made and leaves the film off, as the Proxies switch on a library row does. `delete` removes the stand-in and keeps the film off. With `auto_proxies` on, each `media_import` starts its stand-ins the same way | diff --git a/crates/app/src/export_ui.rs b/crates/app/src/export_ui.rs index d48fd56..800ef81 100644 --- a/crates/app/src/export_ui.rs +++ b/crates/app/src/export_ui.rs @@ -753,6 +753,7 @@ pub(crate) fn export_settings( // free function cannot see; an empty list means "use the project's chapters". chapters: Vec::new(), audio_kbps: Some(audio_kbps), + reencode_audio: false, audio_bit_depth: None, bitrate: Some(bitrate), // The copy path (the old `Quality::Exact`) is off this surface: the diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 093bc78..7708461 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -2656,8 +2656,8 @@ impl Player { ), MixDrag::Pitch(..) => ( self.mix_panel.borrow().pitch_bar.clone(), - f32::from(engine::project::MIN_CLIP_PITCH), - f32::from(engine::project::MAX_CLIP_PITCH), + engine::project::MIN_CLIP_PITCH, + engine::project::MAX_CLIP_PITCH, ), MixDrag::Ceiling => ( self.mix_panel.borrow().ceiling_bar.clone(), @@ -2717,7 +2717,7 @@ impl Player { /// Sets the selected clip's pitch in semitones; `true` when it moved. pub(crate) fn set_clip_pitch_mix(&mut self, lane: Lane, idx: usize, semitones: i32) -> bool { match self.session.as_mut() { - Some(session) => session.set_clip_pitch(lane, idx, semitones), + Some(session) => session.set_clip_pitch(lane, idx, semitones as f32), None => false, } } diff --git a/crates/app/src/player/export.rs b/crates/app/src/player/export.rs index 80a0648..3bb52e3 100644 --- a/crates/app/src/player/export.rs +++ b/crates/app/src/player/export.rs @@ -579,7 +579,7 @@ impl Player { /// sound: there is nothing to write either way. pub(crate) fn audio_rate_refusal(&self) -> Option<&'static str> { match &self.session { - Some(session) => session.audio_rate_refusal(self.format, self.export_span().is_some()), + Some(session) => session.audio_rate_refusal(self.format, self.export_span().is_some(), false), None => Some("no sound to write"), } } diff --git a/crates/app/src/player/sections.rs b/crates/app/src/player/sections.rs index 3d91619..f0dd6f0 100644 --- a/crates/app/src/player/sections.rs +++ b/crates/app/src/player/sections.rs @@ -187,7 +187,7 @@ impl Player { } Section::Effects => !clip.effects.is_empty(), Section::Eq => session.eq_of(lane, idx).is_some_and(|e| !e.is_identity()), - Section::Mix => clip.gain_db != 0. || clip.pan != 0 || clip.pitch != 0 || !clip.gain_keys.is_empty() || clip.fade_in != 0 || clip.fade_out != 0, + Section::Mix => clip.gain_db != 0. || clip.pan != 0 || clip.pitch != 0.0 || !clip.gain_keys.is_empty() || clip.fade_in != 0 || clip.fade_out != 0, } } } diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 7985229..5a7ff20 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -2060,7 +2060,7 @@ fn a_duration_row_shows_only_for_a_transition_and_its_room_is_the_successors() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -2163,7 +2163,7 @@ fn the_transition_kinds_are_palette_actions_and_set_through_a_gated_door() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), }; let mut b = a.clone(); diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 02d9262..e92ff87 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -715,7 +715,7 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1205,7 +1205,7 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -2001,7 +2001,7 @@ fn a_copied_clip_is_renumbered_or_dropped_when_a_row_leaves_the_library() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -2373,7 +2373,7 @@ fn trim_to_playhead_needs_a_subject_cut_with_the_playhead_on_it() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index fad3b34..a3d6b4c 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -742,7 +742,7 @@ fn a_drop_moves_the_clip_that_was_picked_up_not_its_old_index() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/app/src/tests/menu_wire.rs b/crates/app/src/tests/menu_wire.rs index 6d16421..9454a88 100644 --- a/crates/app/src/tests/menu_wire.rs +++ b/crates/app/src/tests/menu_wire.rs @@ -26,7 +26,7 @@ fn clip() -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/app/src/tests/view.rs b/crates/app/src/tests/view.rs index 0bad2b6..aa74e4d 100644 --- a/crates/app/src/tests/view.rs +++ b/crates/app/src/tests/view.rs @@ -224,7 +224,7 @@ fn the_marks_are_every_lane_the_playhead_and_the_start() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/app/src/timeline_math.rs b/crates/app/src/timeline_math.rs index 7459b73..96ec838 100644 --- a/crates/app/src/timeline_math.rs +++ b/crates/app/src/timeline_math.rs @@ -1108,7 +1108,7 @@ mod drop_landing_tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/app/src/ui/cards/mix.rs b/crates/app/src/ui/cards/mix.rs index c6b71a7..fcb27ad 100644 --- a/crates/app/src/ui/cards/mix.rs +++ b/crates/app/src/ui/cards/mix.rs @@ -17,10 +17,11 @@ use crate::*; /// What the dynamics section has switched on, in plain words and kept short: one line /// under the section, so it never wraps into the rows below. /// A clip's pitch as the row reads it: `0 semitones`, `+3 semitones`, `-12 semitones`. -fn pitch_text(semitones: i32) -> String { - match semitones { - 0 => "0 semitones".into(), - n => format!("{n:+} semitones"), +fn pitch_text(semitones: f32) -> String { + if semitones == 0.0 { + "0 semitones".into() + } else { + format!("{semitones:+} semitones") } } @@ -372,9 +373,9 @@ impl Player { let t = tokens(); let semis = target .and_then(|(lane, idx)| self.session.as_ref()?.clip_pitch_of(lane, idx)) - .unwrap_or(0); - let value = pitch_text(i32::from(semis)); - let changed = semis != 0; + .unwrap_or(0.0); + let value = pitch_text(semis); + let changed = semis != 0.0; let bar = self.mix_panel.borrow().pitch_bar.clone(); let me = cx.entity(); let typed = target.map(|(lane, idx)| SliderTyped { @@ -409,7 +410,7 @@ impl Player { ); let track = centred_track( "mix-clip-pitch", - (f32::from(semis) + 12.) / 24., + (semis + 12.) / 24., bar, move |this: &mut Player, x: Pixels, cx: &mut Context| { if let Some((lane, idx)) = target { diff --git a/crates/engine/examples/bench.rs b/crates/engine/examples/bench.rs index e59fd07..5440e94 100644 --- a/crates/engine/examples/bench.rs +++ b/crates/engine/examples/bench.rs @@ -900,7 +900,7 @@ fn export_bench(path: &Path, seat: &str, out_dir: &Path) { fit: engine::scale::FitPolicy::default(), speed: Speed::NORMAL, transform: None, - pitch: 0, + pitch: 0.0, }; // The sound, where it was asked for, is the same clip on an audio lane: // the very window the picture covers, so the two passes measure one export. diff --git a/crates/engine/src/audio.rs b/crates/engine/src/audio.rs index d86aef2..712c674 100644 --- a/crates/engine/src/audio.rs +++ b/crates/engine/src/audio.rs @@ -5576,7 +5576,7 @@ mod tests { fit: FitPolicy::default(), speed: Speed::NORMAL, transform: None, - pitch: 0, + pitch: 0.0, }; // One second of the mono source, then one second of the stereo one. let project = Project::from_parts( diff --git a/crates/engine/src/beats.rs b/crates/engine/src/beats.rs index 1d986ec..307df0e 100644 --- a/crates/engine/src/beats.rs +++ b/crates/engine/src/beats.rs @@ -446,7 +446,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed: Speed::default(), - pitch: 0, + pitch: 0.0, }; // 0.5 s is source frame 62.5, rounded to 63 -> timeline 113; 1.0 s is 75 -> 125. // 20 s is past the clip's end and is dropped. diff --git a/crates/engine/src/edith.rs b/crates/engine/src/edith.rs index d433622..be1263e 100644 --- a/crates/engine/src/edith.rs +++ b/crates/engine/src/edith.rs @@ -248,9 +248,11 @@ //! with none is the bytes a v28 one was bar the version line. //! //! A `pitch` line is `pitch audio `: an audio clip's pitch -//! shift in whole semitones, `-12` to `12`, written for each clip that is not at `0`, -//! after the lanes it names (as `clippan` is). **Version 52** is the first dialect -//! with one; a project with none is the bytes a v51 one was bar the version line. +//! shift in semitones, `-12` to `12`, written for each clip that is not at `0`, +//! after the lanes it names (as `clippan` is). **Version 55** is the first dialect +//! with one, whole semitones only. **Version 58** allows a fraction (`0.37`), which a +//! pre-v58 reader would refuse; a project whose shifts are all whole keeps the header +//! it needed before. A project with none is the bytes a v54 one was bar the version line. //! //! The `resolution` line is the **project's** picture size, which is a //! different thing from any source's: media of other sizes are placed on it. @@ -444,11 +446,12 @@ use crate::transform::{KeyEase, MAX_TRANSFORM_KEYS, OpacityKey, TransformKey, Tr /// The newest project format version: the `N` in the `edith N` first line that /// [`save`] writes for a project that uses the newest features. A reader refuses any /// higher version by name. -pub const NEWEST_VERSION: u32 = 57; +pub const NEWEST_VERSION: u32 = 58; /// What [`save`] writes. Read support goes back to `edith 1`; see the module /// docs for what those dialects looked like. Kept at [`NEWEST_VERSION`]. -const MAGIC: &[u8] = b"edith 57"; +const MAGIC: &[u8] = b"edith 58"; +const MAGIC_V57: &[u8] = b"edith 57"; const MAGIC_V56: &[u8] = b"edith 56"; const MAGIC_V55: &[u8] = b"edith 55"; const MAGIC_V54: &[u8] = b"edith 54"; @@ -830,13 +833,17 @@ pub fn encode_flagged( // ...and one with an effect's keys is v56 (`ekeys`), as is one with a custom bezier key easing. let keyed = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.effects.iter().any(|e| !e.keys.is_empty()))); // ...and one with a clip's pitch shift is v55. - let pitched = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.pitch != 0)); + let pitched = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.pitch != 0.0)); + // ...and one with a fractional pitch shift is v58. + let fractional = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.pitch.fract() != 0.0)); // ...and one with a title's own keys is v56 (`ttkeys`). let title_keyed = titles.iter().any(|t| !t.keys.is_empty()); let curved = keyed || title_keyed || lanes.iter().any(|(_, clips)| clips.iter().any(has_bezier)); if curved || pitched || titled || panned || styled || marked || angled || named || deinterlaced || steadied || looked || effected || voiced || captioned || animated || reversed || transitioned || ramped || !chapters.is_empty() || !markers.is_empty() { let first_end = bytes.iter().position(|&b| b == b'\n').unwrap_or(bytes.len()); - let header = if curved { + let header = if fractional { + MAGIC + } else if curved { MAGIC_V56 } else if pitched { MAGIC_V55 @@ -971,7 +978,7 @@ pub fn noted(mut main: Vec, notes: &str, still_secs: f64, speech_model: Opti return main; } let first_end = main.iter().position(|&b| b == b'\n').unwrap_or(main.len()); - let header = raise_header(&main[..first_end], if speech { MAGIC } else { MAGIC_V52 }); + let header = raise_header(&main[..first_end], if speech { MAGIC_V57 } else { MAGIC_V52 }); main.splice(..first_end, header); if main.last() != Some(&b'\n') { main.push(b'\n'); @@ -1064,7 +1071,8 @@ pub fn sequenced(main: Vec, active: (u32, &str), order: &[u32], blocks: &[Se // v47 only when something in the file needs it (a multicam source or an angle somewhere), v46 // when a part is v46; a newer-only line under an older header is refused. let is = |b: &[u8], m: &[u8]| b.starts_with(m) && b.get(m.len()) == Some(&b'\n'); - let v57 = is(&bytes, MAGIC) || blocks.iter().any(|b| is(&b.bytes, MAGIC)); + let v58 = is(&bytes, MAGIC) || blocks.iter().any(|b| is(&b.bytes, MAGIC)); + let v57 = v58 || is(&bytes, MAGIC_V57) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V57)); let v56 = v57 || is(&bytes, MAGIC_V56) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V56)); let v55 = v56 || is(&bytes, MAGIC_V55) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V55)); let v54 = v55 || is(&bytes, MAGIC_V54) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V54)); @@ -1076,7 +1084,7 @@ pub fn sequenced(main: Vec, active: (u32, &str), order: &[u32], blocks: &[Se let v48 = v49 || is(&bytes, MAGIC_V48) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V48)); let v47 = !mcam.is_empty() || is(&bytes, MAGIC_V47) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V47)); let v46 = is(&bytes, MAGIC_V46) || blocks.iter().any(|b| is(&b.bytes, MAGIC_V46)); - let header = if v57 { MAGIC } else if v56 { MAGIC_V56 } else if v55 { MAGIC_V55 } else if v54 { MAGIC_V54 } else if v53 { MAGIC_V53 } else if v52 { MAGIC_V52 } else if v51 { MAGIC_V51 } else if v50 { MAGIC_V50 } else if v49 { MAGIC_V49 } else if v48 { MAGIC_V48 } else if v47 { MAGIC_V47 } else if v46 { MAGIC_V46 } else { MAGIC_V45 }; + let header = if v58 { MAGIC } else if v57 { MAGIC_V57 } else if v56 { MAGIC_V56 } else if v55 { MAGIC_V55 } else if v54 { MAGIC_V54 } else if v53 { MAGIC_V53 } else if v52 { MAGIC_V52 } else if v51 { MAGIC_V51 } else if v50 { MAGIC_V50 } else if v49 { MAGIC_V49 } else if v48 { MAGIC_V48 } else if v47 { MAGIC_V47 } else if v46 { MAGIC_V46 } else { MAGIC_V45 }; bytes.splice(..first_end, header.iter().copied()); bytes.extend_from_slice(format!("seqactive {} ", active.0).as_bytes()); escape_text(active.1, &mut bytes); @@ -1316,7 +1324,7 @@ fn pitch_lines(lanes: &[(LaneKind, Vec)]) -> Vec { } audio += 1; for (idx, c) in clips.iter().enumerate() { - if c.pitch != 0 { + if c.pitch != 0.0 { out.extend_from_slice(format!("pitch audio {audio} {idx} {}\n", c.pitch).as_bytes()); } } @@ -2313,7 +2321,8 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { // The one that carries a clip's placement animation, as `tkeys` lines... // The one that carries a clip's stabilisation, as `stab` lines... // The one that carries a clip's pitch shift, as `pitch` lines... - let v57 = first == MAGIC; + let v58 = first == MAGIC; + let v57 = v58 || first == MAGIC_V57; let v56 = v57 || first == MAGIC_V56; let v55 = v56 || first == MAGIC_V55; let v54 = v55 || first == MAGIC_V54; @@ -2797,9 +2806,9 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { .map(|(at, _)| at) .ok_or_else(|| format!("line {n}: pitch names a lane that is not there"))?; let idx = number(f[2], n)? as usize; - let semitones = std::str::from_utf8(f[3]).ok().and_then(|s| s.parse::().ok()); + let semitones = std::str::from_utf8(f[3]).ok().and_then(|s| s.parse::().ok()); let semitones = match semitones { - Some(v) if (crate::project::MIN_CLIP_PITCH..=crate::project::MAX_CLIP_PITCH).contains(&v) => v, + Some(v) if (crate::project::MIN_CLIP_PITCH..=crate::project::MAX_CLIP_PITCH).contains(&v) && (v58 || v.fract() == 0.0) => v, _ => return Err(format!("line {n}: pitch has a number out of its range").into()), }; doc.lanes[at] @@ -4060,7 +4069,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, &doc, n, @@ -4258,7 +4267,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result { )?, fit: fit_policy(f.get(7).copied(), n)?, speed, - pitch: 0, + pitch: 0.0, }, &doc, n, @@ -5533,7 +5542,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, } } @@ -5998,7 +6007,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed: Speed::from_permille(permille), - pitch: 0, + pitch: 0.0, }; // 30 source frames at 2x is 15 timeline frames, which is where the // second clip starts -- the file writes the source range and the rate, @@ -6100,7 +6109,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; let lanes = vec![(LaneKind::Video, vec![faded])]; let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); @@ -6169,7 +6178,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; let lanes = vec![(LaneKind::Video, vec![dissolving])]; let bytes = emit(&dir, &sources, &lanes, &[], &[], (1280, 720), 0); @@ -7184,13 +7193,13 @@ mod tests { assert!(!before.contains("pitch"), "{before}"); assert!(!before.starts_with("edith 55"), "{before}"); let mut lanes = plain.clone(); - lanes[1].1[1].pitch = -7; + lanes[1].1[1].pitch = -7.0; let text = save(&lanes); assert!(text.starts_with("edith 55\n"), "{text}"); assert!(text.contains("\npitch audio 1 1 -7\n"), "{text}"); let back = load(&path).expect("v55 loads"); - assert_eq!(back.lanes[1].1[1].pitch, -7); - assert_eq!(back.lanes[1].1[0].pitch, 0); + assert_eq!(back.lanes[1].1[1].pitch, -7.0); + assert_eq!(back.lanes[1].1[0].pitch, 0.0); assert_eq!(save(&back.lanes), text, "saved again: the same bytes"); let dirp = PathBuf::from("/proj"); let head = "edith 55\nplayhead 0\nresolution 1280 720\nsource 0 a.mp4\n\ @@ -8052,7 +8061,7 @@ mod clip_gain_tests { visualizer: 0, viz_paint: 0, gain_db, - pitch: 0, + pitch: 0.0, }; let lanes = vec![ (LaneKind::Video, vec![clip(0.0)]), @@ -8423,11 +8432,12 @@ mod gain_key_tests { let err = parse(v34.as_bytes(), &dir).unwrap_err().to_string(); assert!(err.contains("speedkeys"), "{err}"); let head = format!("edith 35\n{HEAD}"); + let too_many: String = (0..65).map(|i| format!(" {i}:1000")).collect(); for line in [ + &format!("speedkeys audio 1 0{too_many}\n")[..], "speedkeys audio 1 0 0:9000\n", "speedkeys audio 1 0 30:1000 0:1000\n", "speedkeys audio 1 0 0\n", - "speedkeys audio 1 0 0:1000 1:1000 2:1000 3:1000 4:1000 5:1000 6:1000 7:1000 8:1000\n", ] { let err = parse(format!("{head}{line}").as_bytes(), &dir).unwrap_err().to_string(); assert!(err.contains("line 6"), "{line}: {err}"); diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs index b419712..5f903e7 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -583,6 +583,8 @@ pub struct ExportSettings { /// it used to. Means nothing to WAV and FLAC, which code no rate, and /// nothing to a *copied* AAC track, which carries its source's. pub audio_kbps: Option, + /// Code the sound at [`ExportSettings::audio_kbps`] even where its packets could be copied. + pub reencode_audio: bool, /// Bits per sample of the PCM sound in a ProRes `.mov`: 16 or 24. `None` (and /// anything else) is 24. No other format reads it. pub audio_bit_depth: Option, @@ -1453,6 +1455,7 @@ fn audio_label( sound: bool, copied: Option, ranged: bool, + reencode: bool, ) -> &'static str { if !sound { return "no sound to write"; @@ -1467,7 +1470,7 @@ fn audio_label( // Never a copy: WebM carries Opus, and the sound is mixed and encoded // for it at 48 kHz ([`start`], [`encode_audio`]). Format::Webm => "Opus · SW encode (ec-opus)", - _ => match copied.unwrap_or(!forces_encode(project, ranged)) { + _ => match copied.unwrap_or(!(reencode || forces_encode(project, ranged))) { true => "AAC copy", // A Matroska file gets Opus where the mix allows it -- 48 kHz and // stereo, which is every Opus source and most of everything else -- @@ -1511,7 +1514,7 @@ fn measured_audio_label( (Some(false), false) if format.is_mkv() => "AAC · SW encode (ec-aac)", // `sound` is already what happened, not a prediction, so `copied` is // filled in and `ranged` never reaches the branch that reads it. - _ => audio_label(project, format, sound.is_some(), sound, false), + _ => audio_label(project, format, sound.is_some(), sound, false, false), } } @@ -1521,7 +1524,7 @@ fn measured_audio_label( /// a marked range -- a copy needs the source's own packets to *be* the file, /// which a range's exact offset and length rule out ([`copy_audio`]). pub fn planned_audio(project: &Project, format: Format, ranged: bool) -> &'static str { - audio_label(project, format, has_sound(project), None, ranged) + audio_label(project, format, has_sound(project), None, ranged, false) } /// Why the sound's rate is nothing this timeline can be asked about in this @@ -1533,7 +1536,7 @@ pub fn planned_audio(project: &Project, format: Format, ranged: bool) -> &'stati /// [`ExportSettings::audio_kbps`] like every other encode. So the value travels /// even where this refuses; what it cannot do is silently write a rate nobody /// picked. -pub fn audio_rate_refusal(project: &Project, format: Format, ranged: bool) -> Option<&'static str> { +pub fn audio_rate_refusal(project: &Project, format: Format, ranged: bool, reencode: bool) -> Option<&'static str> { match format { _ if !has_sound(project) => Some("no sound to write"), Format::Wav | Format::Flac | Format::ProRes => Some("lossless — the samples themselves, at no rate"), @@ -1546,7 +1549,7 @@ pub fn audio_rate_refusal(project: &Project, format: Format, ranged: bool) -> Op Format::Ogg => Some("quality-coded — Vorbis holds no rate to pick"), // The bitrate is the one choice WebM leaves: Opus at the rate picked. Format::Mp3 | Format::Webm | Format::Opus => None, - _ if forces_encode(project, ranged) => None, + _ if reencode || forces_encode(project, ranged) => None, _ => Some("the source's own packets are copied — at the rate they hold"), } } @@ -1951,7 +1954,7 @@ fn export_spans(project: &Project, range: Option<(u32, u32)>) -> Vec Option, range: Option<(u32, u32)>, ) -> crate::Result> { // WebM's sound is Opus, which no source's packets are: always the mix. A loudness target is a - // gain over the mix, which a copied packet cannot carry. - if webm || shared.loudness.is_some() { + // gain over the mix, which a copied packet cannot carry. A rate the caller chose is a re-encode. + if webm || reencode || shared.loudness.is_some() { return encode_audio(project, meta, kbps, mkv, webm, shared, sample_rate, range); } // A ranged export needs an exact offset and an exact length, which a @@ -5244,6 +5250,7 @@ fn run( audio_kbps_of(&settings), settings.format.is_mkv(), settings.format == Format::Webm, + settings.reencode_audio, &shared, // WebM's sound is mixed at the rate Opus codes at, so the // one encoder path it takes is the one that resamples. @@ -7514,7 +7521,7 @@ fn mix_pcm( // publishes its own. if !format.has_video() { *shared.encoders.lock().unwrap() = - Some(audio_label(project, format, true, None, settings.range.is_some()).to_string()); + Some(audio_label(project, format, true, None, settings.range.is_some(), settings.reencode_audio).to_string()); } let channels = usize::from(audio.channels); let out_frames = settings.range.map_or(project.media_frames(), |(s, e)| { @@ -7594,6 +7601,7 @@ fn run_aac( audio_kbps_of(settings), false, false, + settings.reencode_audio, shared, sample_rate, settings.range, @@ -7610,6 +7618,7 @@ fn run_aac( true, Some(track.copied), settings.range.is_some(), + settings.reencode_audio, ) .to_string(), ); diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index 109b205..2a70a4f 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -1185,7 +1185,7 @@ impl PlaybackSession { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; let project = Project::from_parts( vec![Source::new(path, 0)], @@ -1311,7 +1311,7 @@ impl PlaybackSession { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; // No group and no audio clip: a still is silent, and a clip on `A1` // playing from a PNG is a source the audio worker cannot open. @@ -2002,8 +2002,9 @@ impl PlaybackSession { &self, format: crate::export::Format, ranged: bool, + reencode: bool, ) -> Option<&'static str> { - crate::export::audio_rate_refusal(&self.project.render_view(), format, ranged) + crate::export::audio_rate_refusal(&self.project.render_view(), format, ranged, reencode) } /// Why this session plays silent although the file has sound -- an audio @@ -3985,14 +3986,14 @@ impl PlaybackSession { } /// The clip's pitch shift in semitones at `idx` of `lane` ([`Project::clip_pitch`]). - pub fn clip_pitch_of(&self, lane: Lane, idx: usize) -> Option { + pub fn clip_pitch_of(&self, lane: Lane, idx: usize) -> Option { self.project.clip_pitch(lane, idx) } /// Sets that clip's pitch in semitones, clamped to `-12..=12`. One undo step; the /// sound is rebuilt where the playhead is, as for [`set_clip_gain`](Self::set_clip_gain). /// `false` for a video lane, a bad index, or a value already set. - pub fn set_clip_pitch(&mut self, lane: Lane, idx: usize, semitones: i32) -> bool { + pub fn set_clip_pitch(&mut self, lane: Lane, idx: usize, semitones: f32) -> bool { self.edit(Dirty::Sound, |p| p.set_clip_pitch(lane, idx, semitones)) } @@ -5927,7 +5928,7 @@ impl PlaybackSession { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; // Which lane a source may land on is decided here and only here, so a // front-end never has to make the same call twice: a file with no @@ -6255,7 +6256,7 @@ impl PlaybackSession { transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; let end = start + clip.frames(); let overlaps = |lane: Lane| { diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index d6bfab1..802a33b 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -329,7 +329,7 @@ impl Speed { /// Most keys a speed ramp may hold ([`Clip::speed_keys`]). A fixed cap, so that a /// [`Span`] carrying a ramp stays `Copy`. -pub const MAX_SPEED_KEYS: usize = 8; +pub const MAX_SPEED_KEYS: usize = 64; /// How long a still image is placed for when the project does not say (the 5 s every project had /// before v52), and the shortest and longest length a project may set for one. @@ -895,12 +895,12 @@ pub struct Clip { /// gain. Audio clips only ([`Project::set_clip_pan`]); [`Clip::pan_value`] reads it as /// `-1.0..=1.0`. pub pan: i8, - /// The clip's pitch in whole semitones, `-12` (an octave down) to `12` (up), `0` the + /// The clip's pitch in semitones, `-12.0` (an octave down) to `12.0` (up), `0.0` the /// default and the original sound. Changes the pitch and keeps the speed: the /// stretch and the resample that make it are built by [`Project::lane_speeds_from`], /// so playback and export hear the same thing. Audio clips only - /// ([`Project::set_clip_pitch`]). One byte, in the same padding as [`Clip::pan`]. - pub pitch: i8, + /// ([`Project::set_clip_pitch`]). + pub pitch: f32, /// The clip's placement animation: whole [`TransformParams`] at SOURCE /// frames, sorted by [`TransformKey::at`] with no two alike. Empty is the /// single [`Clip::transform`] for the whole clip. Video lanes only @@ -1080,9 +1080,9 @@ pub const MIN_CLIP_GAIN_DB: f32 = -60.0; pub const MAX_CLIP_GAIN_DB: f32 = 24.0; /// The widest a clip's pitch shift may be, in semitones either way ([`Clip::pitch`]). -pub const MAX_CLIP_PITCH: i8 = 12; +pub const MAX_CLIP_PITCH: f32 = 12.0; /// The lowest a clip's pitch shift may be ([`Clip::pitch`]). -pub const MIN_CLIP_PITCH: i8 = -12; +pub const MIN_CLIP_PITCH: f32 = -12.0; /// The most points a clip's gain envelope may hold ([`Clip::gain_keys`]). pub const MAX_GAIN_KEYS: usize = 256; @@ -1289,7 +1289,7 @@ impl Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, } } @@ -2026,7 +2026,7 @@ impl<'a> SourceWalls<'a> { /// What a lane holds over one stretch of the timeline: either a placed clip or /// a gap. Returned already trimmed to the position it was asked about, so a /// caller can hand `len` straight to a decoder (or to a black-frame generator). -#[derive(Clone, Copy, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, PartialEq, Debug)] pub struct Span { /// Timeline frame the span starts at. pub start: u32, @@ -2055,8 +2055,8 @@ pub struct Span { /// [`timeline_at`](Span::timeline_at) count distance walked, as they do forwards. /// `false` for a gap. pub reverse: bool, - /// The pitch in semitones of the clip this came off ([`Clip::pitch`]); `0` for a gap. - pub pitch: i8, + /// The pitch in semitones of the clip this came off ([`Clip::pitch`]); `0.0` for a gap. + pub pitch: f32, } impl Span { @@ -2152,14 +2152,14 @@ pub struct Stretch { /// The pitch in semitones the segment is shifted by ([`Clip::pitch`]), `0` for none. /// The stretch then runs at `step / 2^(pitch/12)` and the resample at the same ratio /// up: the pitch moves, the length does not. - pub pitch: i8, + pub pitch: f32, } impl Stretch { /// Whether the segment is only played backwards, at the rate it was recorded: /// no change of time, so no stretch is built for it. pub fn is_straight(&self) -> bool { - self.reverse && self.step == 1.0 && self.ramp.is_none() && self.pitch == 0 + self.reverse && self.step == 1.0 && self.ramp.is_none() && self.pitch == 0.0 } /// The frequency ratio the segment's pitch shift is: `2^(pitch/12)`, `1.0` for none. @@ -2169,7 +2169,7 @@ impl Stretch { } /// The frequency ratio of a shift of `semitones`: `2^(semitones/12)`, so `12` is an octave up. -pub fn pitch_ratio(semitones: i8) -> f64 { +pub fn pitch_ratio(semitones: f32) -> f64 { (f64::from(semitones) / 12.0).exp2() } @@ -2887,7 +2887,7 @@ impl Project { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -3508,7 +3508,7 @@ impl Project { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -6021,14 +6021,14 @@ impl Project { /// Give the clip at `idx` of `lane` this pitch in semitones, clamped to `-12..=12`. /// One undo step. `false` -- and no history -- for an index that is not there, a /// non-audio lane, or a value already set. - pub fn set_clip_pitch(&mut self, lane: Lane, idx: usize, semitones: i32) -> bool { + pub fn set_clip_pitch(&mut self, lane: Lane, idx: usize, semitones: f32) -> bool { if lane.kind != LaneKind::Audio { return false; } let Some(current) = self.lane(lane).get(idx).map(|c| c.pitch) else { return false; }; - let semitones = semitones.clamp(i32::from(MIN_CLIP_PITCH), i32::from(MAX_CLIP_PITCH)) as i8; + let semitones = semitones.clamp(MIN_CLIP_PITCH, MAX_CLIP_PITCH); if current == semitones { return false; } @@ -6039,7 +6039,7 @@ impl Project { /// The pitch in semitones of the clip at `idx` of `lane`, or `None` for an index that /// is not there. - pub fn clip_pitch(&self, lane: Lane, idx: usize) -> Option { + pub fn clip_pitch(&self, lane: Lane, idx: usize) -> Option { self.lane(lane).get(idx).map(|c| c.pitch) } @@ -6824,7 +6824,7 @@ impl Project { /// refused, and the caller is told how far it would have run. pub fn set_speed_ramp(&mut self, lane: Lane, idx: usize, keys: &[SpeedKey]) -> crate::Result<()> { if !keys.is_empty() && !valid_speed_keys(keys) { - return Err("a speed ramp takes 1 to 8 keys, in strictly increasing frames".into()); + return Err(format!("a speed ramp takes 1 to {MAX_SPEED_KEYS} keys, in strictly increasing frames").into()); } let Some(members) = self.group_of(lane, idx) else { return Err(format!("there is no clip {idx} on {}", lane.label()).into()); @@ -7575,7 +7575,7 @@ impl Project { speed: Speed::NORMAL, ramp: None, reverse: false, - pitch: 0, + pitch: 0.0, // The next placement, or the end of the timeline: a gap is // bounded by what comes after it, never by its own bookkeeping. len: clips @@ -7658,7 +7658,7 @@ impl Project { speed, ramp, reverse, - pitch: 0, + pitch: 0.0, }) } @@ -11034,7 +11034,7 @@ impl Project { Some(_) => f64::from(span.source_len()) / f64::from(span.len), None => span.speed.as_f64(), }; - (ramped || !span.speed.is_normal() || span.reverse || span.pitch != 0).then(|| Stretch { + (ramped || !span.speed.is_normal() || span.reverse || span.pitch != 0.0).then(|| Stretch { step, timeline_secs: f64::from(span.len) / fps, reverse: span.reverse, @@ -12365,7 +12365,7 @@ mod tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -15089,7 +15089,7 @@ mod tests { len: 3, from: Some((0, 6)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }) ); assert_eq!(p.span_at(Lane::V1, 9), None); @@ -15126,7 +15126,7 @@ mod tests { assert_eq!(std::mem::size_of::(), 1); assert_eq!( std::mem::size_of::(), - 224, + 232, "Clip changed size: {} bytes", std::mem::size_of::() ); @@ -15162,7 +15162,7 @@ mod tests { transform: None, fit: FitPolicy::Fit, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; #[test] @@ -15387,7 +15387,7 @@ mod tests { len: 2, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }) ); assert_eq!(p.map(Lane::V1, 4), Some((1, 4)), "video plays on"); @@ -15409,7 +15409,7 @@ mod tests { len: 4, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }), "the audio lane holds silence to the end of the picture" ); @@ -15509,7 +15509,7 @@ mod tests { len: 11, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }) ); assert!(!p.place(Lane::V1, 0, clip(0, 7, 7, 0)), "empty clip"); @@ -16449,7 +16449,7 @@ mod tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -17972,13 +17972,13 @@ mod tests { /// (the visualizer `u64` and six `Vec`s, the volume, placement, speed /// ramp, opacity and colour keys and the effects stack, are the wide fields; the placement keys raised it from 96 by one /// `Vec`, the speed ramp raised it from 120 by another, the opacity and - /// colour keys took it from 144 to 192, and the effects stack to 216, the multicam angle to 224). The + /// colour keys took it from 144 to 192, and the effects stack to 216, the multicam angle to 224, the fractional pitch to 232). The /// bound is `<=` rather than `==` so a field that shrinks the clip does not /// trip it; growing past it is the thing to notice. #[test] - fn a_clip_stays_within_224_bytes() { + fn a_clip_stays_within_232_bytes() { assert!( - std::mem::size_of::() <= 224, + std::mem::size_of::() <= 232, "Clip grew to {} bytes -- every undo snapshot and clone pays for it", std::mem::size_of::() ); @@ -18210,7 +18210,7 @@ mod tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -18797,7 +18797,7 @@ mod tests { len: 4, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }) ); // Every lane still covers the whole timeline, gaps included. @@ -19296,7 +19296,7 @@ mod tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -19480,7 +19480,7 @@ mod tests { len: 10, from: Some((0, 0)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, Span { reverse: false, @@ -19489,7 +19489,7 @@ mod tests { len: 10, from: Some((1, 5)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, Span { reverse: false, @@ -19498,7 +19498,7 @@ mod tests { len: 10, from: Some((0, 20)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, ], "V2 takes over for its own span and hands V1 back" @@ -19513,7 +19513,7 @@ mod tests { len: 5, from: Some((1, 10)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }) ); assert_eq!(p.composite_span_at(30), None, "past the end"); @@ -19538,7 +19538,7 @@ mod tests { len: 5, from: Some((0, 0)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, Span { reverse: false, @@ -19547,7 +19547,7 @@ mod tests { len: 5, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, Span { reverse: false, @@ -19556,7 +19556,7 @@ mod tests { len: 10, from: Some((1, 0)), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, Span { reverse: false, @@ -19565,7 +19565,7 @@ mod tests { len: 10, from: None, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }, ] ); @@ -20702,7 +20702,7 @@ mod pro_trim_tests { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), start, in_frame, diff --git a/crates/engine/src/proxy.rs b/crates/engine/src/proxy.rs index 65cee52..bd8719f 100644 --- a/crates/engine/src/proxy.rs +++ b/crates/engine/src/proxy.rs @@ -606,7 +606,7 @@ fn started( transform: None, fit: FitPolicy::default(), speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, }; let project = Project::from_parts( vec![Source::new(source, 0)], diff --git a/crates/engine/src/silence.rs b/crates/engine/src/silence.rs index fbef21f..f455992 100644 --- a/crates/engine/src/silence.rs +++ b/crates/engine/src/silence.rs @@ -338,7 +338,7 @@ mod tests { transform: None, fit: FitPolicy::default(), speed, - pitch: 0, + pitch: 0.0, } } diff --git a/crates/engine/src/sweep.rs b/crates/engine/src/sweep.rs index b55e4d7..3d0d6ea 100644 --- a/crates/engine/src/sweep.rs +++ b/crates/engine/src/sweep.rs @@ -93,7 +93,7 @@ fn clip(start: u32, in_frame: u32, out_frame: u32) -> Clip { transform: None, fit: FitPolicy::Fit, speed: Speed::NORMAL, - pitch: 0, + pitch: 0.0, } } diff --git a/crates/engine/src/text.rs b/crates/engine/src/text.rs index cb16e5e..f26e932 100644 --- a/crates/engine/src/text.rs +++ b/crates/engine/src/text.rs @@ -183,9 +183,11 @@ fn family_k(font: &FontRef<'_>, data: &[u8], index: u32) -> f32 { /// The system face `name` names, or None when the system has no such family or its face does not /// parse. Each name is looked up once; the database is read on first use. A face's bytes live for -/// the rest of the process, as the bundled faces do. +/// the rest of the process, as the bundled faces do. Faces in the `EDITH_FONTS_DIR` directories win +/// over system faces of the same family. pub(crate) fn family_face(name: &str) -> Option { static DB: OnceLock = OnceLock::new(); + static ENV_DB: OnceLock = OnceLock::new(); static FOUND: Mutex>> = Mutex::new(BTreeMap::new()); let mut found = FOUND.lock().ok()?; if let Some(known) = found.get(name) { @@ -196,16 +198,26 @@ pub(crate) fn family_face(name: &str) -> Option { db.load_system_fonts(); db }); + let env_db = ENV_DB.get_or_init(|| { + let mut db = fontdb::Database::new(); + for dir in crate::envcfg::var("EDITH_FONTS_DIR").unwrap_or_default().split(':').filter(|dir| !dir.is_empty()) { + db.load_fonts_dir(dir); + } + db + }); let query = fontdb::Query { families: &[fontdb::Family::Name(name)], ..fontdb::Query::default() }; - let family = db.query(&query).and_then(|id| { - db.with_face_data(id, |data, index| { - let data: &'static [u8] = Box::leak(data.to_vec().into_boxed_slice()); - let font = FontRef::try_from_slice_and_index(data, index).ok()?; - let k = family_k(&font, data, index); - Some(Family { font: Box::leak(Box::new(font)), k }) + let face = |db: &fontdb::Database| { + db.query(&query).and_then(|id| { + db.with_face_data(id, |data, index| { + let data: &'static [u8] = Box::leak(data.to_vec().into_boxed_slice()); + let font = FontRef::try_from_slice_and_index(data, index).ok()?; + let k = family_k(&font, data, index); + Some(Family { font: Box::leak(Box::new(font)), k }) + }) + .flatten() }) - .flatten() - }); + }; + let family = face(env_db).or_else(|| face(db)); found.insert(name.to_string(), family); family } diff --git a/crates/engine/tests/audio_mix_rates.rs b/crates/engine/tests/audio_mix_rates.rs index eff4e18..fa658a3 100644 --- a/crates/engine/tests/audio_mix_rates.rs +++ b/crates/engine/tests/audio_mix_rates.rs @@ -175,7 +175,7 @@ fn clip(start: u32, frames: u32, source: usize) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/export.rs b/crates/engine/tests/export.rs index 4eee8fd..677d123 100644 --- a/crates/engine/tests/export.rs +++ b/crates/engine/tests/export.rs @@ -276,7 +276,7 @@ fn exports_at_the_project_resolution_with_the_watched_geometry() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -385,7 +385,7 @@ fn exports_the_audio_stream_the_timeline_plays() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -2102,7 +2102,7 @@ fn one_source_clip(source: &Path, fade_in: u32, out_frame: u32) -> (Project, eng gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -2248,7 +2248,7 @@ fn two_clip_edit(source: &Path, first: u32, second: u32) -> (Project, engine::Vi gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/audio_export.rs b/crates/engine/tests/it/audio_export.rs index 4612f5f..d24788d 100644 --- a/crates/engine/tests/it/audio_export.rs +++ b/crates/engine/tests/it/audio_export.rs @@ -74,7 +74,7 @@ fn mixed_project() -> Project { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -115,7 +115,7 @@ fn mixed_project() -> Project { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -484,7 +484,7 @@ fn a_still_and_a_song_export_as_an_mp4_with_sound() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -575,7 +575,7 @@ fn a_fader_is_one_tracks_own_and_the_limiter_holds_the_sum() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -829,7 +829,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -862,7 +862,7 @@ fn the_sound_is_written_at_the_rate_that_was_asked_for() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -944,7 +944,7 @@ fn a_silent_clip_exports_as_silence_over_its_own_span() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1056,7 +1056,7 @@ fn a_51_ac3_source_round_trips_through_a_wav() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1215,7 +1215,7 @@ fn a_fade_in_reaches_the_exported_audio() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1325,7 +1325,7 @@ fn a_split_and_crossfaded_clip_has_no_muted_interior() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1450,7 +1450,7 @@ fn a_mono_timeline_exports_as_dual_mono_ogg() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -1559,7 +1559,7 @@ fn plain_clip(source: usize, out_frame: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/audio_files.rs b/crates/engine/tests/it/audio_files.rs index 141119c..6eeae18 100644 --- a/crates/engine/tests/it/audio_files.rs +++ b/crates/engine/tests/it/audio_files.rs @@ -431,7 +431,7 @@ fn a_silent_first_source_does_not_stop_the_scan_for_one_with_sound() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/av1_software_export.rs b/crates/engine/tests/it/av1_software_export.rs index 1bb02af..1a13a67 100644 --- a/crates/engine/tests/it/av1_software_export.rs +++ b/crates/engine/tests/it/av1_software_export.rs @@ -182,7 +182,7 @@ fn a_mid_clip_av1_frame_composes_with_a_start_and_an_in_point() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/av_sync.rs b/crates/engine/tests/it/av_sync.rs index 556eecd..896fe15 100644 --- a/crates/engine/tests/it/av_sync.rs +++ b/crates/engine/tests/it/av_sync.rs @@ -87,7 +87,7 @@ fn clip(shot: Shot) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), start: shot.start, in_frame: shot.in_frame, diff --git a/crates/engine/tests/it/clip_gain.rs b/crates/engine/tests/it/clip_gain.rs index d2d9893..189a518 100644 --- a/crates/engine/tests/it/clip_gain.rs +++ b/crates/engine/tests/it/clip_gain.rs @@ -38,7 +38,7 @@ fn clip(frames: u32, gain_db: f32) -> Clip { gain_db, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/duck_audio.rs b/crates/engine/tests/it/duck_audio.rs index fbcf37f..41d3b77 100644 --- a/crates/engine/tests/it/duck_audio.rs +++ b/crates/engine/tests/it/duck_audio.rs @@ -45,7 +45,7 @@ fn clip(source: usize, frames: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/eq_audio.rs b/crates/engine/tests/it/eq_audio.rs index f17e736..a78ccc2 100644 --- a/crates/engine/tests/it/eq_audio.rs +++ b/crates/engine/tests/it/eq_audio.rs @@ -67,7 +67,7 @@ fn clip(start: u32, source: usize, frames: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/pan.rs b/crates/engine/tests/it/pan.rs index 07b9767..0312245 100644 --- a/crates/engine/tests/it/pan.rs +++ b/crates/engine/tests/it/pan.rs @@ -37,7 +37,7 @@ fn clip(frames: u32, gain_db: f32) -> Clip { gain_db, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/placement_walls.rs b/crates/engine/tests/it/placement_walls.rs index 9752e90..c99051b 100644 --- a/crates/engine/tests/it/placement_walls.rs +++ b/crates/engine/tests/it/placement_walls.rs @@ -49,7 +49,7 @@ fn clip(source: usize, in_frame: u32, out_frame: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/project_fuzz.rs b/crates/engine/tests/it/project_fuzz.rs index f1a6144..fa7bf26 100644 --- a/crates/engine/tests/it/project_fuzz.rs +++ b/crates/engine/tests/it/project_fuzz.rs @@ -311,7 +311,7 @@ fn random_project(rng: &mut Rng, dir: &Path) -> Project { }, gain_keys: random_gain_keys(rng, frames), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: if kind == LaneKind::Video { random_transform_keys(rng, frames) } else { @@ -1095,7 +1095,7 @@ fn plain_clip(start: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/reverse.rs b/crates/engine/tests/it/reverse.rs index a2ba914..72b858a 100644 --- a/crates/engine/tests/it/reverse.rs +++ b/crates/engine/tests/it/reverse.rs @@ -150,7 +150,7 @@ fn audio_clip(in_frame: u32, out_frame: u32, speed: u16, reversed: bool) -> Clip gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), start: 0, in_frame, diff --git a/crates/engine/tests/it/silence.rs b/crates/engine/tests/it/silence.rs index 2c3c525..6285f25 100644 --- a/crates/engine/tests/it/silence.rs +++ b/crates/engine/tests/it/silence.rs @@ -154,7 +154,7 @@ fn speed_mode_refuses_a_clip_that_laps_over_a_silence() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -208,7 +208,7 @@ fn whole(source: usize, frames: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/transform_keys.rs b/crates/engine/tests/it/transform_keys.rs index b5ca442..824621d 100644 --- a/crates/engine/tests/it/transform_keys.rs +++ b/crates/engine/tests/it/transform_keys.rs @@ -180,7 +180,7 @@ fn a_still_keeps_its_keys_at_the_same_timeline_times_after_a_head_trim() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/trim_walls.rs b/crates/engine/tests/it/trim_walls.rs index 50273eb..da8fec5 100644 --- a/crates/engine/tests/it/trim_walls.rs +++ b/crates/engine/tests/it/trim_walls.rs @@ -40,7 +40,7 @@ fn clip(source: usize, in_frame: u32, out_frame: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/undo_stress.rs b/crates/engine/tests/it/undo_stress.rs index 0e88bc4..9a8be83 100644 --- a/crates/engine/tests/it/undo_stress.rs +++ b/crates/engine/tests/it/undo_stress.rs @@ -155,7 +155,7 @@ fn random_clip(rng: &mut Rng) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/it/voice_audio.rs b/crates/engine/tests/it/voice_audio.rs index fda4896..f1c6331 100644 --- a/crates/engine/tests/it/voice_audio.rs +++ b/crates/engine/tests/it/voice_audio.rs @@ -29,7 +29,7 @@ fn clip(source: usize, frames: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), start: 0, in_frame: 0, diff --git a/crates/engine/tests/it/voice_early_stop.rs b/crates/engine/tests/it/voice_early_stop.rs index 25fbcd1..bc89286 100644 --- a/crates/engine/tests/it/voice_early_stop.rs +++ b/crates/engine/tests/it/voice_early_stop.rs @@ -31,7 +31,7 @@ fn clip(frames: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), start: 0, in_frame: 0, diff --git a/crates/engine/tests/lanes.rs b/crates/engine/tests/lanes.rs index 175f4a1..4234e5a 100644 --- a/crates/engine/tests/lanes.rs +++ b/crates/engine/tests/lanes.rs @@ -247,7 +247,7 @@ fn the_mp4_copy_follows_the_lane_that_holds_the_sound() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -329,7 +329,7 @@ fn two_audio_lanes_are_summed() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/engine/tests/opus_export.rs b/crates/engine/tests/opus_export.rs index d32a875..1332a5f 100644 --- a/crates/engine/tests/opus_export.rs +++ b/crates/engine/tests/opus_export.rs @@ -95,7 +95,7 @@ fn project(video: &Path, sound: &Path, sound_in: u32) -> Project { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), @@ -494,7 +494,7 @@ fn a_copied_picture_names_the_sound_it_was_written_with() { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, transform_keys: Vec::new(), opacity_keys: Vec::new(), color_keys: Vec::new(), diff --git a/crates/mcp/src/help.rs b/crates/mcp/src/help.rs index cfc1d6f..b55618e 100644 --- a/crates/mcp/src/help.rs +++ b/crates/mcp/src/help.rs @@ -214,7 +214,7 @@ LANES lane_gain {lane, db} sets a lane's level, -60..12 dB. Each clip's own gain adds on top. pan {clip, pan} and lane_pan {lane, pan} place sound between the speakers, -1 (left) to 1 (right), 0 the middle; a balance, so the far side is turned down and the near one stays. A clip's pan and its lane's stack. Stereo mixes only. edit {ops:[{op:\"pan\", clip:\"A1@0\", pan:-0.5}]} - pitch {clip, semitones (-12..12)} shifts an audio clip's pitch in whole semitones and keeps its length (12 an octave up). edit {ops:[{op:\"pitch\", clip:\"A1@0\", semitones:12}]} + pitch {clip, semitones (-12..12)} shifts an audio clip's pitch in semitones, fractions too (0.37), and keeps its length (12 an octave up). edit {ops:[{op:\"pitch\", clip:\"A1@0\", semitones:12}]} Ducks stack: a lane can carry one duck per key lane (`under`), so several keys can pull it down. edit {ops:[{op:\"duck\", lane, under, off:true}]} removes that one; edit {ops:[{op:\"duck\", lane, off:true}]} with no under clears every duck on the lane. Not supported (help {topic:\"unsupported\"}): custom transition shapes. @@ -622,7 +622,7 @@ const OP_TEXTS: &[(&str, &str)] = &[ ), ( "pitch", - "pitch {clip, semitones (-12..12)} — the audio clip's pitch in whole semitones: 12 an octave up, -12 an octave down, 0 the original (the default). The speed does not change, so the clip is the same length. Playback and export hear it. Audio clips only.", + "pitch {clip, semitones (-12..12)} — the audio clip's pitch in semitones, fractions allowed (0.37): 12 an octave up, -12 an octave down, 0 the original (the default). The speed does not change, so the clip is the same length. Playback and export hear it. Audio clips only.", ), ( "lane_pan", diff --git a/crates/mcp/src/tools/edit.rs b/crates/mcp/src/tools/edit.rs index 67a28f0..cf38528 100644 --- a/crates/mcp/src/tools/edit.rs +++ b/crates/mcp/src/tools/edit.rs @@ -96,7 +96,7 @@ insert_time {at, duration, lanes?} — ripple empty time in at `at`: clips, capt remove_time {at, duration, lanes?} — ripple a span out of the unlocked lanes (or `lanes`): the cut_regions cut for one span. Titles after it move back; a title wholly inside the span is removed and one straddling an edge is trimmed to the part outside (both named in the reply). TIME speed {clip, x, ripple?, lanes?} — rate 0.25..4. [group] Its length changes, so a neighbour in its way refuses; ripple:true moves the later items in the RIPPLE RULE scope (titles too) by the length change: slower pushes them later, faster closes the gap. A clip on another lane that spans the change is never cut: outside the scope it is left in place and the reply names it; a scope lane (named in lanes) that holds one refuses, naming it. One undo step. -speed_ramp {clip, keys:[{at, speed}...], ripple?, lanes?} [group] — a speed that changes over the clip: each key sets a speed 0.25–4 at a clip-relative time `at` ("0s", "2s", "end" or frames), linear between keys and held before the first and after the last. Keys must be in increasing `at`, at most 8, and keys:[] clears the ramp back to the clip's constant speed. The clip's length follows the ramp, and ripple:true moves the later items as speed does. preset:"speed_up"|"slow_down"|"fast_middle"|"slow_middle" lays one of the speed card's shapes across the clip's length instead of keys (speed_up: 1x to 2x; slow_down: 2x to 1x; fast_middle: slow–fast–slow; slow_middle: fast–slow–fast); not with keys. +speed_ramp {clip, keys:[{at, speed}...], ripple?, lanes?} [group] — a speed that changes over the clip: each key sets a speed 0.25–4 at a clip-relative time `at` ("0s", "2s", "end" or frames), linear between keys and held before the first and after the last. Keys must be in increasing `at`, at most 64, and keys:[] clears the ramp back to the clip's constant speed. The clip's length follows the ramp, and ripple:true moves the later items as speed does. preset:"speed_up"|"slow_down"|"fast_middle"|"slow_middle" lays one of the speed card's shapes across the clip's length instead of keys (speed_up: 1x to 2x; slow_down: 2x to 1x; fast_middle: slow–fast–slow; slow_middle: fast–slow–fast); not with keys. regroup {at} — rejoins the clips that meet at `at` in every lane and puts them back in one group: the inverse of split (metadata only, one undo step; refused when no cut sits there). copy_paste {clips:[addr,...], at, lane?} — pastes copies of the named clips at `at`, with their effects, keys and volume, keeping their spacing. A paste past the end appends at the end, and the reply says where the copies landed. One clip splits and ripples the room open as the GUI's paste does; several (or any with `lane`) land as one set on their own lanes, refused whole when a landing would overlap. `lane` puts every copy on that lane (the same kind, V or A, as each copy). Links come back among the copies: copied clips that were one take (a picture and its sound, say) land as one new take, while a clip whose partner was not copied comes back unlinked. A set with a `lane` override keeps a take only where its members land on different lanes. close_gap {lane, at} — closes the one gap on `lane` that `at` stands in (the GUI's Close gap): a gap that borders a linked take closes with the take's other lane too; nothing else moves. Refused for a clip at `at`, the time past the lane's last clip, and the empty lead-in before its first clip. Captions use close_gaps. @@ -135,7 +135,7 @@ gain_keys {clip, keys:[[time, db, ease?],...]} — the clip's volume envelope (a gain_key {clip, at, db, ease?} — one point (a point at that frame is replaced) · gain_key_remove {clip, at} — takes out the point within a frame of at gain_ramp {clip, from, to, to_db, from_db?} — a straight dB ramp from from to to; from_db defaults to the envelope's level at from. Points inside from..to are replaced. gain_dip {clip, from, to, db, ramp?=0.5s} — dips to db over from..to with ramps in and out; the ramps start from the level there now and clamp to the clip. Points inside the dip are replaced. For a dip that follows speech by itself, use duck. -pan {clip, pan (-1..1)} — the audio clip's place between the speakers, -1 left, 0 middle, 1 right (a balance: the far side is turned down) · pitch {clip, semitones (-12..12)} — the audio clip's pitch in whole semitones, 12 an octave up, -12 down, 0 the original; its length and speed are kept · lane_pan {lane, pan (-1..1)} — the same for a whole audio lane, on top of the clips' own +pan {clip, pan (-1..1)} — the audio clip's place between the speakers, -1 left, 0 middle, 1 right (a balance: the far side is turned down) · pitch {clip, semitones (-12..12)} — the audio clip's pitch in semitones, fractions allowed (0.37), 12 an octave up, -12 down, 0 the original; its length and speed are kept · lane_pan {lane, pan (-1..1)} — the same for a whole audio lane, on top of the clips' own lane_gain {lane, db (-60..12)} — level · limiter {on, ceiling_db?} — the master limiter on the output: ceiling_db -24..0 dB, the highest level the output may reach (default -1 dB) duck {lane, under, depth_db?=-12, threshold_db?=-40, attack_ms?=80, release_ms?=400, off?} — music lane dips while the key lane speaks dynamics {lane, gate?, nr?, compressor?, deesser?, reset?} — an audio lane's voice processors: each of gate, nr, compressor, deesser is true, false (bypass) or an object of settings; clean_voice sets the whole chain at once @@ -843,7 +843,7 @@ fn clip_of(source: usize, in_frame: u32, out_frame: u32) -> Clip { gain_db: 0.0, gain_keys: Vec::new(), pan: 0, - pitch: 0, + pitch: 0.0, } } diff --git a/crates/mcp/src/tools/edit_fx.rs b/crates/mcp/src/tools/edit_fx.rs index be399e3..e494bed 100644 --- a/crates/mcp/src/tools/edit_fx.rs +++ b/crates/mcp/src/tools/edit_fx.rs @@ -1756,7 +1756,7 @@ fn pan(s: &mut PlaybackSession, op: &Value) -> Result { Ok(done(format!("{who} → {pan:+.2}"), vec![(lane, start)])) } -/// `pitch {clip, semitones}`, -12 (an octave down) to 12 (up), whole semitones. The speed is kept. +/// `pitch {clip, semitones}`, -12 (an octave down) to 12 (up), fractions allowed. The speed is kept. fn pitch(s: &mut PlaybackSession, op: &Value) -> Result { let (lane, idx, raw, start) = clip_arg(s, op)?; let who = format!("pitch {raw}"); @@ -1764,11 +1764,8 @@ fn pitch(s: &mut PlaybackSession, op: &Value) -> Result { return Err(format!("{who}: {raw} is on a video lane, and a clip's pitch is set on its audio clip; set it on the audio clip split from the same take")); } let v = num(op, "semitones")?.ok_or_else(|| format!("{who}: missing argument `semitones` (-12 an octave down to 12 an octave up, 0 the original)"))?; - if v.fract() != 0.0 { - return Err(format!("{who}: semitones {} is not a whole number", fmt(v))); - } - let semitones = ranged(&who, "semitones", v, -12.0, 12.0)? as i32; - if s.clip_pitch_of(lane, idx) == Some(semitones as i8) { + let semitones = ranged(&who, "semitones", v, -12.0, 12.0)?; + if s.clip_pitch_of(lane, idx) == Some(semitones) { return Ok(done(format!("{who} → already {semitones:+}"), Vec::new())); } if !s.set_clip_pitch(lane, idx, semitones) { @@ -4441,14 +4438,17 @@ mod pitch_op_tests { let mut s = session(); let len = s.lane_clips(Lane::A1)[0].len(); run(&mut s, json!({"op": "pitch", "clip": "A1#0", "semitones": 12})).expect("pitch up an octave"); - assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(12)); + assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(12.0)); assert_eq!(s.lane_clips(Lane::A1)[0].len(), len, "pitch keeps the clip's length"); assert!(s.undo(), "pitch is one undo step"); - assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(0)); - assert!(run(&mut s, json!({"op": "pitch", "clip": "A1#0", "semitones": 1.5})).is_err()); + assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(0.0)); + run(&mut s, json!({"op": "pitch", "clip": "A1#0", "semitones": 0.37})).expect("a fraction sets"); + assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(0.37)); + assert!(s.undo()); + assert!(run(&mut s, json!({"op": "pitch", "clip": "A1#0", "semitones": 12.5})).is_err()); assert!(run(&mut s, json!({"op": "pitch", "clip": "A1#0", "semitones": 13})).is_err()); assert!(run(&mut s, json!({"op": "pitch", "clip": "A1#0"})).is_err()); assert!(run(&mut s, json!({"op": "pitch", "clip": "V1#0", "semitones": 2})).is_err()); - assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(0), "refusals change nothing"); + assert_eq!(s.clip_pitch_of(Lane::A1, 0), Some(0.0), "refusals change nothing"); } } diff --git a/crates/mcp/src/tools/export.rs b/crates/mcp/src/tools/export.rs index b3bd18b..361079e 100644 --- a/crates/mcp/src/tools/export.rs +++ b/crates/mcp/src/tools/export.rs @@ -1607,7 +1607,7 @@ fn export_start(srv: &mut Server, args: &Value) -> Reply { AUDIO_KBPS.map(|v| v.to_string()).join(", ") )); }; - if let Some(why) = s.audio_rate_refusal(format, ranged) { + if let Some(why) = s.audio_rate_refusal(format, ranged, true) { return Reply::err(format!( "audio_kbps can't be chosen for {}: {why}", format_name(format) @@ -1763,6 +1763,7 @@ fn export_start(srv: &mut Server, args: &Value) -> Reply { keyframe_s, faststart, audio_kbps, + reencode_audio: audio_kbps.is_some(), subtitles, no_soft_subtitles: no_soft, range, diff --git a/crates/mcp/src/tools/look.rs b/crates/mcp/src/tools/look.rs index 120fb69..7a24212 100644 --- a/crates/mcp/src/tools/look.rs +++ b/crates/mcp/src/tools/look.rs @@ -677,13 +677,13 @@ fn media_rows(s: &PlaybackSession, lane: Lane, fps: f64, range: Option<(u32, u32 // always; brief shows only the ones set off their default. let (pan, pitch, deint) = ( s.clip_pan_of(lane, idx).unwrap_or(0.0), - s.clip_pitch_of(lane, idx).unwrap_or(0), + s.clip_pitch_of(lane, idx).unwrap_or(0.0), s.deinterlace_of(lane, idx), ); if lane.kind == LaneKind::Audio && (full || pan != 0.0) { body.push_str(&format!(" pan {}", num(f64::from(pan)))); } - if lane.kind == LaneKind::Audio && (full || pitch != 0) { + if lane.kind == LaneKind::Audio && (full || pitch != 0.0) { body.push_str(&format!(" pitch {pitch:+}")); } if lane.kind == LaneKind::Video && (full || deint != engine::project::Deinterlace::Frame) { @@ -1390,14 +1390,14 @@ fn media_info(s: &PlaybackSession, lane: Lane, idx: usize, fps: f64) -> Reply { // Pan, pitch and deinterlace, each shown only when it is off its default. let (pan, pitch, deint) = ( s.clip_pan_of(lane, idx).unwrap_or(0.0), - s.clip_pitch_of(lane, idx).unwrap_or(0), + s.clip_pitch_of(lane, idx).unwrap_or(0.0), s.deinterlace_of(lane, idx), ); let mut tweaks = Vec::new(); if pan != 0.0 { tweaks.push(format!("pan {}", num(f64::from(pan)))); } - if pitch != 0 { + if pitch != 0.0 { tweaks.push(format!("pitch {pitch:+} semitones")); } if deint != engine::project::Deinterlace::Frame { @@ -2324,7 +2324,7 @@ mod tests { let audio = call(&mut srv, "clip_info", json!({"clip": "A1#0"})); assert!(audio.text.contains("pan -0.5 · pitch +3 semitones"), "{}", audio.text); assert_eq!(audio.structured.as_ref().unwrap()["pan"], -0.5); - assert_eq!(audio.structured.as_ref().unwrap()["pitch"], 3); + assert_eq!(audio.structured.as_ref().unwrap()["pitch"], 3.0); let video = call(&mut srv, "clip_info", json!({"clip": "V1#0"})); assert!(video.text.contains("deinterlace field"), "{}", video.text); assert!(video.text.contains("speed keys: 3\n at clip 0.000s speed 1x\n at clip 1.000s speed 1.5x\n at clip 2.000s speed 2x"), "{}", video.text);