# Writing scenarios

## 7. Voice

```
@voice yui/001.ogg
Yui "Good morning."
@voice-auto Yui pattern="yui/{n:3}.ogg"
Yui "This line plays yui/001.ogg."
Yui "This line plays yui/002.ogg."
Ren "Wait{@voice ren/wait.ogg}"
```

- Put voice files in `assets/voice/` (`folder=sound` also looks in the sound effects folder).
- `//!` lines directly above a line of dialogue are acting notes (`//! Whispering`). They go in the "acting notes" column of the recording script (`lim voice-script`). Plain `//` comments aren't included
  (to include every `//` line as before, write `"voiceScript": { "notes": "comments" }` in liminalia.json).

**Playing one at a time (`@voice`)**

- Written before a text line, it plays once with the next line of dialogue.
- Written inside text, it plays on the spot and becomes the voice of that page.

**Playing numbered files (`@voice-auto`)**

- `@voice-auto speaker pattern=…` plays a numbered file for each of that speaker's lines. `{n}` is the number, and `{n:3}` pads it to 3 digits.
- A line with `@voice` plays that file instead, and the number doesn't advance.
- `@voice-auto-off` stops it while keeping the number. `@voice-auto speaker` (without `pattern`; omit the speaker too for all) resumes it.
- `start=false` only sets up the numbering and leaves it stopped without starting to play (`[voconfig]` in TyranoScript). To start it, write it the same way as resuming above.
- The number is kept in the state, so after loading, the same line plays the same file.

**Locking the numbers (`lim voice-lock`)**

With numbered voices, adding one line of dialogue shifts every number after it, and the numbers also change depending on which branch was taken.
Once the voices are recorded, lock a number to each line with `lim voice-lock` (`voice-lock.json`; chapter 10).
With a lock, the locked number plays, and lines that aren't in the lock (lines added after recording) don't play.
Numbers are given only to lines where `@voice-auto` is in effect and there is no `@voice`, as at run time (lines before it's set, after `@voice-auto-off`, and lines with `@voice` don't get numbers).

**Playback**

- Moving to the next page stops the previous voice (you can also choose "Keep playing" for "On advance" in the Settings screen).
- In auto mode, the page advances after the voice finishes. While skipping, voices don't play.
- You can replay the voice of each page from the backlog.

**Two people speaking at once (`who=`, `channel=`)**

```
@voice yui/010.ogg
@voice mika/010.ogg who=Mika
Yui "Ready, set..."
```

- Writing two `@voice` lines with different speakers (`who=` gives the speaker of that voice) before the same line of dialogue plays both at once. Putting them on different channels, as in `channel=2`, also plays them at once
  (a second one with the same speaker and the same channel replaces the first).
- Lip sync moves the mouth of each voice's speaker while that voice plays, and the name box shows both names ("Yui, Mika"). The backlog, text-to-speech, and copying the text use the same names. The setting that highlights the speaker (`@chara-config focus=`) applies to both too.
- Both speakers appear in the per-speaker voice volume in the settings (they count as speakers whose voice was heard).
- Auto advances after the longest voice finishes. Replaying from the log plays both.
- The recording script (`lim voice-script`) and the voice screen in Studio also list the second voice as a line (its speaker is the `who=` speaker).

**Sound filters (`filter=`, `@voice-filter`)**

```
@voice-filter phone who=Mika
Mika "Hello? Can you hear me?"
@voice-filter none who=Mika
@bgm night.ogg filter=muffled filter-strength=60
@bgm night.ogg filter-fade=1s
```

- `filter=` is `muffled` (a muffled sound: through a wall, underwater), `phone` (over the phone), `radio` (a radio or walkie-talkie), `hall` (the echo of a large hall) or `none` (no filter).
  `filter-strength=` (0 to 100) mixes it with the original sound. It can be written in `@bgm`, `@se` and `@voice`.
- `@voice-filter kind who=speaker` keeps applying it to that speaker's voices (omit `who` for all speakers; `none` removes it). It applies right away to a voice that's playing too (over `time=`), and it's kept in the save.
  `@voice … filter=none` removes it for that voice only.
- Writing `@bgm` again for the same track that's playing changes only the filter, without stopping the track (over `filter-fade=`; without `filter`, it's removed).
  Filters on BGM and looping sound effects are kept in the save, and loading plays them with the same filter.

**Captions (`caption=`)**

Giving a caption to a voice that isn't written in the text (laughter, a sigh, words different from the text), as in `@voice yui/laugh.ogg caption="(laughs)"`,
shows it to players who have turned on "Sound captions" in Settings, in the same place as sound effect captions. In translation files, it can be translated as command text.

**Text only for reading aloud (`@describe`, `alt=`)**

```
@bg classroom_rain.webp alt="A classroom at dusk. Rain is falling outside the window"
@describe "Yui silently looks out the window"
Yui "..."
```

- `@describe "…"` isn't shown on screen. Before the next text (or choice), it's passed to screen readers (an aria-live region that isn't visible) and
  to text-to-speech (in Settings). Use it to describe scenes that are conveyed only by pictures or effects.
- `alt=` in `@bg`, `@chara` and `@image` passes a description of that picture in the same way (each time the picture is shown; pictures shown while skipping aren't passed).
- Both can be translated as command text (Languages).
