Audio
The Audio Presenter, on the Visual Novel Kit prefab’s Dialogue Runner, plays four kinds of audio:
| Kind | How it plays |
|---|---|
| Music | On a loop. A new track fades in over the old one. |
| Ambience | On a loop, under the music, for sounds like rain or waves. |
| Sound effects | Once each. Several can play at the same time. |
| Voice | A voice line for each line of dialogue, with no Commands. |
Music, ambience and sound effects
| Command | What it does |
|---|---|
<<music track seconds>> | Plays a music track on a loop. If music is already playing, the new track fades in while the old one fades out. If it’s the same track, nothing changes. |
<<stop_music seconds>> | Fades the music out. |
<<music_volume volume seconds>> | Changes the music’s volume, from 0 to 1. |
<<ambience track seconds>> | Plays an ambience track on a loop. |
<<stop_ambience seconds>> | Fades the ambience out. |
<<ambience_volume volume seconds>> | Changes the ambience’s volume, from 0 to 1. |
<<sound effect seconds>> | Plays a sound effect once. |
<<stop_sound seconds>> | Fades out every sound effect that’s playing. |
The duration is how long the fade takes. Like every VNKit Command, the story waits for the fade to finish, unless you add nowait:
<<ambience waves 2 nowait>>
<<music beach 3 nowait>>
<<sound thud>><<sound thud>> has no duration, so it starts at full volume, and the story carries on straight away.
Where audio files go
VNKit finds audio files in a Resources folder, the same way it finds images. Each kind looks in its own folder first:
| Command | Looks in first |
|---|---|
music | Resources/music |
ambience | Resources/ambience |
sound | Resources/sounds |
So <<music beach>> plays Resources/music/beach. If the file isn’t there, VNKit looks through the rest of your Resources folders, trying the names described in Naming your images. If it can’t find the file, it warns you in the Console.
Voice lines
Voice lines use Yarn Spinner’s own voice over setup. Each line in your Yarn script has a line ID, and the audio file with the same name plays with that line.
Give every line a line ID, with a
#line:hashtag:c: Lovely day for selling yarn. #line:bab4f433A line with the line ID bab4f433.Put the voice lines in a folder next to your Yarn Project, named after their line IDs, without the
line:. For this line, the file isbab4f433.wav.Open your
.yarnprojectfile in a text editor, and point the base language’s localisation at the folder:"localisation": { "en": { "assets": "Voice/en" } }Pointing the English localisation at Voice/en.
Lines without an audio file are shown without a voice. The VNKit Template is set up this way, with its voice lines in Assets/Dialogue/Voice/en.
See Localisation and Assets in the Yarn Spinner for Unity docs for more about line IDs and localised assets.
Keeping voice and text together
A line’s voice starts when its text starts appearing in the text box. When a different character speaks, the text box fades out and back in first, and the voice waits for the fade.
- Pressing to finish typing a line leaves its voice playing.
- Moving on to the next line fades the voice out.
- If Auto Advance Dialogue is on, on the Main Presenter, the box waits for the voice to finish, then for its Auto Advance Hold Duration, before moving on.
Voiced Lines, in the Dialogue Visuals group of your Configuration asset, sets how lines with a voice are typed out:
| Voiced Lines | What it does |
|---|---|
| Normal | Types the line out with the Typewriter, like a line without a voice. |
| MatchVoice | Types the line out over the length of the voice line, so the text and the voice finish together. |
| Instant | Shows the whole line as the voice starts. |
Volume settings
The Audio Presenter has a slot for an Audio Mixer Group for each kind of audio: Voice Group, Music Group, Ambience Group and Sound Group. Route each kind through its own group, and you can give each one its own volume control.
The Audio Presenter also has these settings:
| Setting | What it does | Starts as |
|---|---|---|
| Voice Fade Out On Advance | How long a voice line takes to fade out when the player moves on, in seconds. | 0.05 |
| Fade Out On Dialogue Complete | How long the music and ambience take to fade out when the dialogue ends, in seconds. | 0.5 |
Saving
When the game saves, VNKit saves the music and ambience that are playing, and their volumes. Loading a save starts them again.