Guides & examples

Vocal guide

The vocal engine synthesises a Japanese singing or speaking voice from notes and lyrics, with no recordings. Include wauvio/vocal/v3.hpp (or v3_fx.hpp for the effects chain). This guide uses v3, the current generation.

Lyrics in 30 seconds

  • One syllable per note: hiragana (さ), katakana (サ) or romaji (sa).
  • ー or an empty lyric continues the previous vowel.
  • For exact control write phonemes in braces: {k a z e}.
  • Notes are MIDI numbers; lengths are in ticks (480 = one quarter note) via note(), or in seconds via note_sec().
  • Stay inside a voice’s range: Yune is comfortable around MIDI 52–88.

Full details: Lyric input.

g++ -std=c++17 -O2 -I/path/to/wauvio-repo NAME.cpp -o NAME && ./NAME

1. Hello, singer

Create a Singer, add notes with lyrics, save. The default voice is Yune.

// The smallest singing program. Lyrics are Japanese kana (or romaji); each note carries one syllable.
#include "wauvio/vocal/v3.hpp"
using namespace wauvio::vocal::v3;

int main() {
    Singer s;                          // default voice: Yune
    s.set_tempo(100);                  // timing is in ticks; 480 ticks = one quarter note

    //       MIDI note, length in ticks, lyric
    s.note(67, 480, "こ");             // G4
    s.note(69, 480, "ん");
    s.note(71, 480, "に");
    s.note(72, 480, "ち");
    s.note(74, 960, "は");

    s.save("vocal_01_hello.wav");      // mono render, normalised
}

Download vocal_01_hello.cpp

Try this: change a lyric to romaji, e.g. "ka".

2. Make it expressive

natural() adds small human imperfections; auto_expression() adds rule-based vibrato and dynamics. note() returns a NoteRef for per-note control: vibrato, breathiness, ornaments, glides. A persona is a named vocal “look”, and lanes automate parameters over time.

// Making it sound like a performance: vibrato, ornaments, per-note tweaks, a persona and automation lanes.
#include "wauvio/vocal/v3.hpp"
using namespace wauvio::vocal::v3;

int main() {
    Singer s;
    s.set_tempo(80);
    s.natural();                       // slight human imperfections (timing, pitch, tone), tuned for this voice
    s.auto_expression();               // rule-based vibrato and dynamics; only fills fields you have not set
    s.persona("soft", 0.8);            // a ready-made "look" (Yune ships: normal, soft)

    // Note-level control: note() returns a NoteRef; every setter returns it again, so calls chain.
    s.note(69, 480, "さ");
    s.note(72, 480, "く").breathy(0.3);
    s.note(76, 1440, "ら").vibrato(0.45, 5.5, /*delay*/0.3, /*fade-in*/0.4).ornament("fall", 1.0);
    s.rest(240);
    s.note(74, 480, "さ").glide_from(71);          // slide up into the note
    s.note(72, 1920, "く").portamento(0.08);

    // Lanes: automation over time (absolute seconds). This one swells the volume then fades it.
    s.lane("volume", {{0.0, 0.7}, {3.0, 1.0}, {6.0, 0.5}});

    s.save("vocal_02_expressive.wav");
}

Download vocal_02_expressive.cpp

Try this: change ornament("fall") to "kobushi" or "turn"; remove natural() to hear the difference.

3. Speech and non-lexical sounds

say() speaks with intonation (statement, question, flat…) and optional Tokyo pitch accent. Events like laughs and hums are produced by the same voice, either through event() or as <tags> inside a lyric. See Events.

// Speech and non-lexical sounds: say() for spoken lines, event() / <tags> for laughs, hums and more.
#include "wauvio/vocal/v3.hpp"
using namespace wauvio::vocal::v3;

int main() {
    Singer s;
    s.natural();

    s.say("こんにちは", 1.2, "statement");
    s.rest_sec(0.2);
    s.say("げんき", 0.9, "question");               // rising intonation
    s.rest_sec(0.3);
    s.say("はし", 0.7, "statement", 69, 0.75, /*accent nucleus*/ 1);   // Tokyo accent: HIGH-low (箸, chopsticks)
    s.rest_sec(0.5);

    s.event("laugh", 72, 1.0, /*intensity*/ 0.7);
    s.rest_sec(0.3);
    s.note_sec(72, 1.0, "<hum>");                   // the same thing written as a lyric tag

    s.save("vocal_03_speech_events.wav");
}

Download vocal_03_speech_events.cpp

Try this: try the kinds giggle, sob and shout.

4. Harmonies and doubling

An Ensemble mixes several singers to stereo. add_harmony copies the lead transposed by some semitones; add_double adds slightly different takes for a thicker lead. Harmonies can be sung by a different voice.

// A lead voice with a harmony and double-tracked takes, mixed to stereo by an Ensemble.
#include "wauvio/vocal/v3.hpp"
using namespace wauvio::vocal::v3;

int main() {
    Singer lead;
    lead.set_tempo(90); lead.natural();
    for (auto [midi, ticks, syl] : { std::tuple<int,int,const char*>{67,480,"ら"}, {69,480,"ら"}, {71,480,"ら"}, {72,1440,"あ"} })
        lead.note(midi, ticks, syl);

    Ensemble choir;
    choir.add(lead, "lead");                                   // centre
    choir.add_double(lead, /*copies=*/2);                      // two extra takes, slightly detuned and spread
    choir.add_harmony(lead, +4, "third", -0.5f, 0.6f);         // a major third above, panned left, quieter
    choir.add_harmony(lead, -5, "fourth below", 0.5f, 0.55f);  // a fourth below, panned right

    wauvio::StereoBuffer mix = choir.render_stereo();
    wauvio::normalize(mix, 0.9);
    wauvio::save_wav_stereo(mix, "vocal_04_harmony.wav");
}

Download vocal_04_harmony.cpp

Try this: add a third harmony an octave up (+12).

5. Finish with mic and effects

process_vocal applies an optional mic model and a ready-made chain (EQ, compressor, delay, reverb, limiter). Presets: natural, pop, intimate, hall.

// Finishing a vocal: mic model + the ready-made FX chain (EQ, compression, delay, reverb, limiter).
#include "wauvio/vocal/v3_fx.hpp"
using namespace wauvio::vocal::v3;

int main() {
    Singer s;
    s.set_tempo(110); s.natural(); s.auto_expression();
    s.note(72, 480, "ひ"); s.note(74, 480, "か"); s.note(76, 480, "り"); s.note(79, 1440, "へ");

    wauvio::Buffer dry = s.render();

    MicModel mic;                       // optional "recording" colour
    mic.proximity = 0.4; mic.air = 0.3; mic.de_ess = 0.5;

    // Presets: natural, pop, intimate, hall. bpm > 0 syncs the delay in "pop".
    wauvio::StereoBuffer finished = process_vocal(dry, "pop", &mic, 44100, 110);
    wauvio::normalize(finished, 0.9);
    wauvio::save_wav_stereo(finished, "vocal_05_polish.wav");
}

Download vocal_05_polish.cpp

Try this: compare the four presets on the same line.

6. Compare the built-in voices

Each voice has its own character and range. voice_ids() lists them, make_voice loads one (or a .wvc voicebank file). See Voices for how to make your own.

// Same melody, every built-in voice. Voices differ in tract (formants), range and default look.
#include "wauvio/vocal/v3.hpp"
#include <cstdio>
using namespace wauvio::vocal::v3;

int main() {
    for (const std::string& id : voice_ids()) {
        VoiceProfile voice; std::string err;
        if (!make_voice(id, voice, &err)) { std::printf("skip %s: %s\n", id.c_str(), err.c_str()); continue; }

        Singer s(voice);                        // or: s.set_profile(voice)
        s.set_tempo(100);
        s.natural();                            // uses this voice's recommended strength
        // Stay inside the voice's comfortable range (voice.model.range_low / range_high).
        int base = (voice.model.range_low + voice.model.range_high) / 2;
        s.note(base, 480, "あ"); s.note(base + 2, 480, "い"); s.note(base + 4, 480, "う"); s.note(base + 5, 960, "え");
        s.save("vocal_06_voice_" + id + ".wav");
        std::printf("%-9s %s\n", id.c_str(), voice.display.c_str());
    }
}

Download vocal_06_voices.cpp

Try this: combine voices in an Ensemble for a duet.

7. Sing a MIDI karaoke file

Notes plus lyric events in a MIDI file become a vocal line. Always set the voice before loading notes. diagnostics() reports problems like unreadable lyrics.

// Sing a MIDI karaoke-style file: notes + Lyric meta events become a vocal line.
// Usage: ./vocal_07_midi_lyrics song.mid [voice-id-or-file.wvc]
#include "wauvio/vocal/v3.hpp"
#include <cstdio>
using namespace wauvio::vocal::v3;

int main(int argc, char** argv) {
    if (argc < 2) { std::printf("usage: %s song.mid [voice]\n", argv[0]); return 0; }

    VoiceProfile voice; std::string err;
    Singer s;
    if (argc > 2 && make_voice(argv[2], voice, &err)) s.set_profile(voice);   // set the voice BEFORE adding notes

    // track = -1: use the first track that has lyrics. Notes without a lyric continue the previous vowel.
    int n = s.load_midi_file(argv[1], -1);
    std::printf("loaded %d notes\n", n);
    for (auto& warning : s.diagnostics()) std::printf("warning: %s\n", warning.c_str());

    s.natural(); s.auto_expression();
    s.save("vocal_07_midi_lyrics.wav");
}

Download vocal_07_midi_lyrics.cpp

Try this: use the optional second argument to choose a voice.

8. Text score for the sing_score tool

You can also write a score as plain text and render it with the sing_score tool, with no C++ needed beyond building the tool once: sing_score vocal_08_score_file.txt out.wav. Command reference: Vocal tools.

# A score for the sing_score tool:  sing_score vocal_08_score_file.txt out.wav
# One command per line. '#' starts a comment.
voice yune
tempo 100
natural
auto_expression on
persona soft 0.7

#    midi ticks lyric  [options]
note 67 480 さ
note 69 480 く
note 71 480 ら   vib=0.4,5.5,0.3
note 72 960 さ   orn=fall,1.0
rest 240
note 74 480 {k a z e}     # phoneme input in braces
event laugh 72 0.8 0.6    # kind midi seconds intensity

# v3 extras: a harmony a third above, panned left, and the "pop" vocal chain
harmony 4 -0.4 0.6
chain pop

Download vocal_08_score_file.txt

Try this: add double 2 for double-tracking.

Earlier generations

v1 and v2 are kept for compatibility: v1, v2 — differences from v1. New projects should use v3.