# Waveform to Text (声波变文字)

A waveform collapses into three flat lines, and three text lines open out of those exact lines one after another; a bridge from audio or meetings to written notes.

- Ref: `video/motion-transition-waveform-to-text` (code video · motion · feature, launch, tutorial · any · 4.5s at 30fps)
- Page: https://uifino.com/en/videos/motion-transition-waveform-to-text
- Markdown: https://uifino.com/md/videos/motion-transition-waveform-to-text.md
- Preview image: https://uifino.com/videos/motion-transition-waveform-to-text/poster.jpg

## Install

- ZIP: https://uifino.com/videos/motion-transition-waveform-to-text/source.zip

A waveform collapses into three flat lines, and three text lines open out of those exact lines one after another; a bridge from audio or meetings to written notes.

Rendered video: https://uifino.com/videos/motion-transition-waveform-to-text/preview.mp4

## Beats

- 0-1.2s Show the sound: A single 4px waveform across the frame, seeded, with smoothly changing amplitude Camera: static.
- 1.2-2s The wave becomes the position of text lines: Amplitude flattens, one line splits into three and shrinks to the position and width of three text rows, power2.inOut 0.8 s Camera: static. Transition: shape morph.
- 2-2.9s Lines become words: Three text rows open out of their lines 0.15 s apart, 0.6 s power3.out each, whole line at once Camera: static. On-screen text: "Confirm the launch date / Finish the landing copy / Ship the film by Wednesday".
- 2.9-4.5s Let the viewer read: Three text rows stay completely still Camera: static.

## Parameters

- `collapseStart` Collapse start: default 1.2s, range 0.8 to 2s
- `collapseDuration` Collapse duration: default 0.8s, range 0.5 to 1.2s
- `collapseEase` Collapse ease: default power2.inOut
- `rowStagger` Delay between rows: default 0.15s, range 0.1 to 0.3s
- `revealDuration` Row reveal duration: default 0.6s, range 0.3 to 0.9s
- `revealEase` Row reveal ease: default power3.out
- `waveAmp` Wave peak amplitude: default 240px, range 80 to 320px
- `strokeWidth` Line width: default 4px, range 2 to 8px
- `fontSize` Text size: default 80px, range 48 to 96px

## Good for

- Features that turn voice, recordings or meetings into text
- A transition that joins two kinds of content through one continuous shape
- Entrance of a list of three short points

## Not for

- More than three lines or very long lines
- Captions that must be typed letter by letter
- Music pieces where a colourful equalizer is the subject

## Source files (plain text)

- https://uifino.com/videos/motion-transition-waveform-to-text/source/SPEC.md
- https://uifino.com/videos/motion-transition-waveform-to-text/source/PROMPT.md
- https://uifino.com/videos/motion-transition-waveform-to-text/source/NOTICE.md
- https://uifino.com/videos/motion-transition-waveform-to-text/source/project/assets/fonts/OFL.txt
- https://uifino.com/videos/motion-transition-waveform-to-text/source/project/compositions/wave.html
- https://uifino.com/videos/motion-transition-waveform-to-text/source/project/hyperframes.json
- https://uifino.com/videos/motion-transition-waveform-to-text/source/project/index.html

## How to use

- Copy the beats and parameters; replace only the copy, the accent color and the product screenshots.
- `PROMPT.md` has two prompts: one to reproduce this video exactly, one to learn only the technique.
- Build with HyperFrames (`/hyperframes`); the project in the ZIP is a ready starting point.

## Files

| Path | Role | Size |
| :--- | :--- | ---: |
| PROMPT.md | doc | 3.2 KB |
| SPEC.md | doc | 7.4 KB |

### PROMPT.md

```md
# PROMPT：motion-transition-waveform-to-text

## 照抄复刻
> 给用户的 AI。告诉它用 `/hyperframes` 按本条目的节拍和参数复刻。

用 `/hyperframes` 做一个 1920×1080、30 fps、4.5 秒的转场：一条声波线变成三行文字。底色 #0F1712，文字 #ECF2EE，声波和横线 #7FD99A，基准线 #1F2B24；字体中文 Noto Sans SC、西文 IBM Plex Sans，字重 500，字号只用 80px，行高 144px，三行以画面中心为轴垂直居中，行距 144px，整块水平居中，行内左对齐。全程不加任何标签、图标、产品截图。

节拍：
1. 0 - 1.2 秒：一条 4px 单线 SVG 声波，横向 160 到 1760，中线 y = 540，200 个采样点。令 u = 序号/200，TAU = 6.2832。用 mulberry32（种子 20240611）先为 4 个包络分量各依次抽 a、k、f、p：a = 0.6 + 0.4·rnd，k = 1.2 + 2.0·rnd，f = 0.25 + 0.35·rnd，p = TAU·rnd；再为 2 个载波各抽相位 p = TAU·rnd。包络 n = Σ a·sin(TAU·(k·u − f·t) + p) ÷ Σ a，沿线变化 local = 0.25 + 0.75·n²；载波 c = 0.7·sin(TAU·(11·u − 1.3·t) + p0) + 0.3·sin(TAU·(19·u + 0.9·t) + p1)；两端收细窗口 sin(π·u)^1.5。点的纵向偏移 = 整体振幅 × 240px × 拉平系数 × 窗口 × local × c，整体振幅 0.62 + 0.38·sin(2π·0.45·t + 0.8) 平滑起伏。画面从第 0 秒就有声波，不要渐入。线下面 2px 的 #1F2B24 基准线。不要柱状均衡器，不要麦克风图标。
2. 1.2 - 2.0 秒：收拢 0.8 秒，`power2.inOut`。同一条声波先复制成三条完全重合的线，进度到 50% 时振幅按 smoothstep 归零（振幅乘以 1 − smoothstep(进度/0.5)），同时三条线竖直分开到 y = 396 / 540 / 684，左右端点收到各自那一行文字的左右边缘（先量好文字宽度）。基准线在进度 35% 时淡出。
3. 2.0 - 2.9 秒：三行文字依次显出，间隔 0.15 秒，整行同时出现，不逐字。每行的起点比上面的时间提前 0.1 秒：此时文字以 `clip-path: inset()` 的「中间 4px 高的一条缝」出现在横线的位置，同时那条线用 0.1 秒 `power2.out` 淡出，线消失后缝保持到起点，再展开到整行，0.6 秒 `power3.out`。这样线不会划过字中腰，任何一帧都不是空画面。
4. 2.9 - 4.5 秒：三行文字完全静止。

需要替换的地方：
- 三行文字：`line1`、`line2`、`line3`（默认「确认发布日期 / 补齐落地页文案 / 周三前出片」；英文「Confirm the launch date / Finish the landing copy / Ship the film by Wednesday」，每行不超过 8 个汉字或 5 个英文词）。
- 配色：`accentColor`、`bg`、`ink`、`rule`。
- 字号和线：`fontSize`、`strokeWidth`、`waveAmp`。
- 节奏：`collapseStart`、`collapseDuration`、`collapseEase`、`rowStagger`、`revealDuration`、`revealEase`。

## 只学手法
一条单线波形收拢成文字行的位置和宽度，过渡 0.8 秒 `power2.inOut`；收拢前先把一条线复制成三条重合的线，再分开，最后用 `clip-path` 从 4px 的缝里把整行文字展开（间隔 0.15 秒），线在文字以缝的形式出现的同一刻用 0.1 秒淡出（提前 0.1 秒，避免线划过字），所以形状从声波到文字始终连续、没有空帧。
```

### SPEC.md

```md
# SPEC：motion-transition-waveform-to-text

一条声波线先起伏 1.2 秒，接着用 0.8 秒收成三条横线，三条线的位置和长度正好是三行文字的位置和长度，文字从线的位置整行显出。手法是靠「形状连续」把两种内容接起来：声波、横线、文字三者之间没有任何一帧是空的。

## LOOK
- 色值：底 `#0F1712`；文字 `#ECF2EE`；基准线 `#1F2B24`（2px 的一条淡线，只在声波阶段出现）；强调色 `#7FD99A`（声波和横线，面积远小于 10%）。中性色共 3 个，没有渐变、没有辉光、没有阴影。
- 字体：中文 Noto Sans SC，西文 IBM Plex Sans，本地 `@font-face`（`assets/fonts/noto-sans-sc.woff2`、`assets/fonts/ibm-plex-sans.woff2`，门禁按片中的字生成子集）。字重 500。
- 字号：只用 1 档，80px（行高 144px）。
- 圆角：无圆角元素，全片 0 档。
- 阴影：无。
- 线宽：声波和横线都是 4px 单线，`stroke-linecap: butt`，`stroke-linejoin: round`。

## MOTION
- 声波：单条 SVG 折线，200 个采样点，横向 x 从 160 到 1760（宽 1600），中线 y = 540。线上每一点的高度 = 峰值振幅（240px）× 两端收细的窗口 × 沿线变化的包络 × 载波，全部是时间的函数，没有随机数；用固定种子 `20240611` 生成 4 个包络分量和 2 个载波的频率与相位。整体振幅 `0.62 + 0.38·sin(2π·0.45·t + 0.8)`，范围 0.24 到 1，平滑起伏，第 0 秒就有振幅。
  - 令 u = 采样序号 / 200（0 到 1），t 为秒，TAU = 6.2832。
  - 随机数发生器 mulberry32，种子 20240611：`a=(a+0x6D2B79F5)|0; t=imul(a^(a>>>15),1|a); t=(t+imul(t^(t>>>7),61|t))^t; 返回 ((t^(t>>>14))>>>0)/4294967296`。
  - 抽数顺序固定：先依次生成 4 个包络分量，每个按 a、k、f、p 各抽一次；再生成载波 0 和 1 的相位 p 各抽一次（共 18 次）。
  - 包络分量：幅度 a = 0.6 + 0.4·rnd，空间频率 k = 1.2 + 2.0·rnd（1.2 到 3.2），时间频率 f = 0.25 + 0.35·rnd（0.25 到 0.6），相位 p = TAU·rnd（0 到 TAU）。
  - 包络 n = Σ a·sin(TAU·(k·u − f·t) + p) ÷ Σ a；沿线变化 local = 0.25 + 0.75·n²。
  - 载波：载波 0 空间频率 11、时间速度 −1.3、权重 0.7；载波 1 空间频率 19、时间速度 0.9、权重 0.3；相位 p = TAU·rnd。载波 c = Σ 权重·sin(TAU·(空间频率·u + 时间速度·t) + p)。
  - 两端收细窗口 win = sin(π·u)^1.5。
  - 线上一点的纵向偏移 = 整体振幅 × 峰值振幅 × 拉平系数 × win × local × c。
- 收拢：1.2 秒开始，0.8 秒，`power2.inOut`，一次进度 `m` 同时驱动三件事：
  1. 声波振幅乘以 `1 − smoothstep(m / 0.5)`，到 `m = 0.5` 完全拉平，三条线分开时已是直线，不会纠缠；
  2. 一条线分成三条：1.2 秒起三条线完全重合（和原来的一条线看起来一样），再沿竖直方向从 y = 540 分开到 y = 396 / 540 / 684；
  3. 每条线的左右端点从 160 / 1760 收到各自那一行文字的左右边缘。
  基准线在 `m` 到 0.35 时淡出。
- 文字显出：收拢结束（2.0 秒）起，三行依次间隔 0.15 秒，展开起点 2.0 / 2.15 / 2.3 秒，整行同时显出，不逐字。每行用 `clip-path: inset()` 从「中间 4px 高的一条缝」展开成整行，0.6 秒，`power3.out`。缝的位置和横线重合，所以横线就是文字的第一道切口。
- 横线退场：每行显出的起点提前 0.1 秒（常量 `LEAD`）：第 i 行的起点 = 收拢结束 + i × 间隔 − 0.1 秒，此刻文字以 4px 的缝出现在横线的位置，同时那条线用 0.1 秒（常量 `LINE_FADE`）、`power2.out` 淡出，到缝开始展开时线已经消失，所以文字展开时不会有一条绿线划过字中腰。缝保持 0.1 秒后才展开。任何一帧都不是空画面。
- 落定后文字完全不动，保持到 4.5 秒；最后一行 2.3 秒开始显出，约 2.5 秒已能读，之后停留 2 秒。

## 逐拍节拍表
| 拍 | 起止秒 | 画面 | 镜头 | 转场 | 屏幕文案原文 |
| --- | --- | --- | --- | --- | --- |
| wave | 0 - 1.2 | 一条 4px 声波线横贯画面，振幅平滑起伏，下面一条淡基准线 | 固定 | 无 | 无 |
| collapse | 1.2 - 2.0 | 声波拉平，分成三条线，收到文字行的位置和宽度 | 固定 | 形状收拢，`power2.inOut` 0.8 秒 | 无 |
| reveal | 2.0 - 2.9 | 三条线依次变成三行文字，间隔 0.15 秒 | 固定 | 横线即切口，文字从缝里展开 | 确认发布日期 / 补齐落地页文案 / 周三前出片 |
| hold | 2.9 - 4.5 | 三行文字静止 | 固定 | 无 | 同上 |

英文版文案（把变量换成这三句即可，代码按词宽自动测量行宽）：Confirm the launch date / Finish the landing copy / Ship the film by Wednesday。

## 参数接线
全部是 `compositions/wave.html` 场景根上的 `data-composition-variables`，和 `entry.json` 的 `variables` 一一对应。

| 变量 | 默认值 | 范围 | 改了画面哪里变 |
| --- | --- | --- | --- |
| line1 / line2 / line3 | 确认发布日期 / 补齐落地页文案 / 周三前出片 | 每行不超过 8 个汉字或 5 个英文词 | 三行文字，行宽和横线长度自动跟着变 |
| accentColor | #7FD99A | 颜色 | 声波和横线颜色 |
| bg | #0F1712 | 颜色 | 背景 |
| ink | #ECF2EE | 颜色 | 文字颜色 |
| rule | #1F2B24 | 颜色 | 基准线颜色 |
| fontSize | 80 | 48 到 96，单位 px | 文字大小，行高固定 144px |
| strokeWidth | 4 | 2 到 8，单位 px | 声波、横线、起始缝的粗细 |
| waveAmp | 240 | 80 到 320，单位 px | 声波峰值振幅 |
| collapseStart | 1.2 | 0.8 到 2.0，单位秒 | 收拢开始时刻，文字显出时刻跟着后移 |
| collapseDuration | 0.8 | 0.5 到 1.2，单位秒 | 收拢时长 |
| collapseEase | power2.inOut | 缓动名 | 收拢缓动 |
| rowStagger | 0.15 | 0.1 到 0.3，单位秒 | 三行显出的间隔 |
| revealDuration | 0.6 | 0.3 到 0.9，单位秒 | 每行文字展开时长 |
| revealEase | power3.out | 缓动名 | 文字展开缓动 |

写死在 `wave.html` 里的常量：采样点数 200、波形左右端 160 / 1760、中线 540、行距和行高 144、横线淡出 0.1 秒（常量 `LINE_FADE`）、淡出和缝出现提前量 0.1 秒（常量 `LEAD`）、随机种子 20240611、整体振幅公式、拉平区间 0.5、基准线淡出区间 0.35。

## 禁用项
- 彩色渐变的均衡器柱子、麦克风或录音图标。
- 文字逐字打出；画面上的编号、时间码、说明标签。
- 呼吸、漂浮、脉冲循环；文字落定后的任何缩放或位移。
- 假浏览器、产品截图、辉光和阴影。

## 已知取舍
- 开场第 0 秒就是满振幅的声波，不是空画面，所以没有 `first_frame_empty` 警告；封面 `poster` 取 2.2 秒：第一行已落定、第二行正在从缝里展开、第三行还是一条线，一张图能看出整个手法。
- 行宽和行位在字体加载完成后、建时间线之前量一次（`document.fonts.load` 之后再注册时间线），时间线回调里只用已经量好的数字，不再碰 DOM，这样不会触发 `gsap_callback_dom_measurement`。换了文案后重新量，横线长度自动跟着变。
- 文字块落定后只有约 440px 宽，居中放在 1920 画面里留白较多；字号在变量范围内可加大到 96px，本片按 BRIEF 取 80px。
- 三条横线在 1.2 秒前完全重合，所以收拢前画面上只看到一条声波线；`rule` 基准线对比度很低（约 1.2:1），只是一条参照线，不承载信息。
```
