Vocal engine (wauvio/vocal)
v3 — Singer API
Header wauvio/vocal/yune-v3/singer.hpp, namespace wauvio::vocal::v3. A Singer is a monophonic performer: you add notes with lyrics, set defaults, then render.
Building a score
| Method | Meaning |
|---|---|
Singer() / Singer(VoiceProfile) | Default is Yune. set_profile(p) switches character (model, default look, lyric defaults, personas); call before adding notes |
set_voice(VoiceModel) | Override only the tract model, keeping the profile’s personas and look |
set_tempo(bpm, ppq = 480) | Tick-based timing |
note(midi, ticks, lyric, velocity = 0.75) → NoteRef | Add a note at the cursor (ticks) |
note_sec(midi, seconds, lyric, vel) | Same in seconds |
note_at(start_sec, midi, seconds, lyric, vel) | Absolute placement; cursor moves to the note end |
rest(ticks), rest_sec(seconds) | Advance the cursor |
say(text, seconds, kind, base_midi, velocity, accent) | Speech utterance with intonation; kind: statement, question, flat, trail, emphatic, ne, yo, ka, no. accent: Tokyo pitch-accent nucleus (0 heiban, 1 atamadaka, n = falls after mora n, −1 none); with an accent the sentence contour shrinks to 60% and the word-level H/L pattern rides on it |
event(kind, midi, seconds, intensity, variant) | Non-lexical event at the cursor; see Events |
load_midi_file(path, track = −1), load_midi_track(file, track) | Read notes and Lyric/Text meta events from a MIDI track (−1 = first track with lyrics). Notes without a lyric continue the previous vowel (melisma). Lyrics may be UTF-8 or Shift-JIS kana. Returns the note count |
clear(), size(), notes(), cursor(), ticks_to_sec() | Inspection and reset |
Singer-wide settings (apply to notes added afterwards)
| Method | Meaning |
|---|---|
style() | Mutable default Style |
parse_options() | Lyric ParseOptions (merge_long_vowels, cute, particles) |
seed(s) | Master seed for all deterministic variation |
accent_height(semitones) | Low–high distance used by say(…, accent) (default 3) |
persona(name, amount), persona_blend(a, b, t, amount) | Move the default look toward a persona |
persona_lane(name, curve) | Persona amount (0–1) vs absolute seconds, for verse/chorus changes |
lane(name, curve) | Singer-wide automation lane (absolute seconds) |
phrase_pitch_curve(curve) | Semitone offset vs seconds applied across the phrase |
phrase_arc(kind, t0, t1, depth) | Volume shape over a span: arch, crescendo, decrescendo, swell |
humanize(timing_s, pitch_st, length, bias_s, take) | Small deterministic imperfections in timing, tuning, length; different take = different performance |
natural(amount = −1, take) | One call for a living voice: sets the natural voice control and humanisation; amount < 0 uses the voice’s recommended strength; 0 turns it off |
auto_expression(on, phrase_gap), auto_expression_options() | Rule-based vibrato, dynamics, phrase-end and articulation; only fills fields still at defaults |
NoteRef — per-note tweaks (chainable)
Returned by note(); valid until clear() or destruction (notes live in a std::deque, so adding notes never invalidates earlier refs).
| Group | Methods |
|---|---|
| Dynamics / articulation | velocity, articulation |
| Pitch | vibrato(depth_st, rate_hz, delay_s, fade_s), no_vibrato, portamento(s), glide_from(midi), bend(curve), overshoot, scoop, ornament(name, depth) |
| Voice quality | growl, tremor(v, rate), fry, breathy, falsetto, formant_shift, mouth_open, hard_onset |
| Automation / persona | lane(name, curve), persona(name, amount), persona_morph(name, curve), style() for direct field access |
Lane names: volume, brightness, breathiness, tension, formant, mouth, growl, tremor, fry, air, register and pitch (semitones).
Rendering
| Method | Result |
|---|---|
render(sr) | Mono Buffer (deterministic for a given score and seed) |
render_stereo(sr), save(path, sr) | Stereo / WAV file |
stream(sr) → VoiceStream | On-demand rendering: the score is analysed once, then audio is pulled in chunks of any size with read(); identical to render() however chunked. Notes added afterwards are not heard |
key_track(sr) | The articulation control track (formants, bandwidths, noise, amplitude per key-frame) exactly as the synthesiser receives it, for tooling |
transposed(semitones) | Copy with every note shifted (harmonies); personas, look and lanes are kept |
doubled(take, natural_amount, detune_cents) | Copy that performs the same notes as another take |
diagnostics() | Strings describing problems worth knowing before rendering (empty = none) |
Singer::render_tap() | Static debug hook called with every finished render |
SingerInstrument
A music::Instrument that renders one note with a fixed lyric (lyric default “あ”, style, profile default Yune), so a singer can sit in a Track/Arrangement or a MidiMusic part. There is no coarticulation between notes; use Singer for phrases.
Full API listing
wauvio/vocal/yune-v3/singer.hpp
wauvio::vocal::v3::Free functions, constants and aliases
class Singer;
wauvio::vocal::v3::class NoteRef
// Returned by Singer::note(); chain setters to tweak that one note.
// V3: stays valid for the life of the Singer (notes live in a std::deque, so adding more notes
// never moves earlier ones); it is invalidated only by Singer::clear() or destroying the Singer.
class NoteRef
public:
NoteRef(SynthNote& n, const PersonaLibrary* lib) : n_(n), lib_(lib) {}
NoteRef& velocity(float v) { n_.vel = v; return *this; }
NoteRef& articulation(wauvio::music::Articulation a) { n_.art = a; return *this; }
NoteRef& vibrato(float depth_st, float rate_hz = -1.f, float delay_s = -1.f, float fade_s = -1.f)
NoteRef& no_vibrato() { n_.style.vibrato_depth = 0.f; return *this; }
NoteRef& portamento(float seconds) { n_.style.portamento = seconds; return *this; }
NoteRef& glide_from(double midi) { n_.glide_from = midi; return *this; }
NoteRef& bend(const Curve& semitones_vs_seconds) { n_.bend = semitones_vs_seconds; return *this; }
NoteRef& overshoot(float o) { n_.style.overshoot = o; return *this; }
NoteRef& scoop(float semitones) { n_.style.scoop = semitones; return *this; }
Style& style() { return n_.style; }
// V2: expression and automation. Names: volume, brightness, breathiness, tension, formant,
// mouth, growl, tremor, fry, air, register, plus "pitch" (semitones). Curve time = seconds
// from the note start.
NoteRef& lane(const std::string& name, const Curve& c)
// Persona for this note only (moves its look toward the persona by `amount`).
NoteRef& persona(const std::string& name, float amount = 1.f) { if (lib_) apply_persona(*lib_, n_.style, name, amount); return *this; }
// Morph this note's look toward a persona over time. amount: 0..1 vs seconds from note start.
// Only channel-capable fields move inside a note (see persona_morph_lanes).
NoteRef& persona_morph(const std::string& name, const Curve& amount)
NoteRef& growl(float v) { n_.style.growl = v; return *this; }
NoteRef& tremor(float v, float rate_hz = -1.f) { n_.style.tremor = v; if (rate_hz > 0) n_.style.tremor_rate = rate_hz; return *this; }
NoteRef& fry(float v) { n_.style.fry = v; return *this; }
NoteRef& breathy(float v) { n_.style.breathiness = v; return *this; }
NoteRef& falsetto(float v) { n_.style.reg = v; return *this; }
NoteRef& formant_shift(float st){ n_.style.formant_shift = st; return *this; }
NoteRef& mouth_open(float v) { n_.style.mouth_open = v; return *this; }
NoteRef& hard_onset(float v) { n_.style.glottal_onset = v; return *this; }
// Pitch ornament: fall, doit, shakuri, scoop_in, kobushi, turn, mordent, trill. depth scales size.
NoteRef& ornament(const std::string& name, float depth = 1.f)
wauvio::vocal::v3::class Singer
class Singer
public:
Singer() { set_profile(voice_yune()); } // Yune is the default voice
explicit Singer(const VoiceProfile& p) { set_profile(p); }
// Switch character: model, default look, lyric defaults and personas all come from the profile.
// Call before adding notes (the default look applies to notes added afterwards).
Singer& set_profile(const VoiceProfile& p)
const VoiceProfile& profile() const { return profile_; }
const PersonaLibrary& personas() const { return profile_.personas; }
// Engine-level override of the tract model only (keeps the profile's personas and look).
Singer& set_voice(const VoiceModel& v) { voice_ = v; return *this; }
const VoiceModel& voice() const { return voice_; }
Singer& set_tempo(double bpm, int ticks_per_quarter = 480) { bpm_ = bpm; ppq_ = ticks_per_quarter; return *this; }
Style& style() { return style_; } // defaults applied to notes added afterwards
const Style& style() const { return style_; }
ParseOptions& parse_options() { return popt_; }
Singer& phrase_pitch_curve(const Curve& semitones_vs_seconds) { phrase_curve_ = semitones_vs_seconds; return *this; }
Singer& seed(uint32_t s) { seed_ = s; return *this; }
Singer& accent_height(float semitones) { accent_height_ = semitones; return *this; } // V3: L-H distance used by say(..., accent)
// V2 personas. These move the Singer's default look for notes added afterwards.
Singer& persona(const std::string& name, float amount = 1.f) { apply_persona(profile_.personas, style_, name, amount); return *this; }
Singer& persona_blend(const std::string& a, const std::string& b, float t, float amount = 1.f) { apply_persona_blend(profile_.personas, style_, a, b, t, amount); return *this; }
// Persona automation over the whole song: amount (0..1) vs absolute seconds, relative to the
// current default look. Drive verse/chorus changes without re-annotating notes.
Singer& persona_lane(const std::string& name, const Curve& amount)
// V2: small deterministic imperfections in timing, length and tuning. Different seeds = different takes.
Singer& humanize(double timing_s = 0.012, double pitch_st = 0.05, double length = 0.03, double bias_s = 0.0, uint32_t take = 1)
// V2: one call for a more living voice. amount 0..1 sets the `natural` voice control (jitter, wander, irregular
// vibrato) AND per-note human imperfections (timing, tuning, entry error, length, phrase breath pressure).
// `take` picks a different performance. amount 0 turns it off.
Singer& natural(float amount = -1.f, uint32_t take = 1) { // amount < 0: the voice's recommended strength
// V2: rule-based expression (vibrato shape, phrase-end, dynamics). Only fills fields left at defaults.
Singer& auto_expression(bool on = true, double phrase_gap = 0.30) { auto_.on = on; auto_.phrase_gap = phrase_gap; return *this; }
AutoExpr& auto_expression_options() { return auto_; }
// V2: volume shape over [t0,t1] seconds: "arch", "crescendo", "decrescendo", "swell".
Singer& phrase_arc(const std::string& kind, double t0, double t1, float depth = 1.f)
// V2 speech: one utterance at `base_midi`. kind: statement, question, flat, trail, emphatic, ne, yo, ka, no.
// Intonation moves pitch only; vibrato and scoop are off, morae are weighted by type.
// V3: `accent` = Tokyo pitch-accent nucleus (0 heiban, 1 atamadaka, n = fall after mora n; -1 = none).
// With an accent the sentence contour is reduced to 60% and the word-level H/L pattern rides on it.
NoteRef say(const std::string& text, double seconds, const std::string& kind = "statement", int base_midi = 64, float velocity = 0.7f, int accent = -1)
// Problems worth knowing about before rendering (empty = none).
std::vector<std::string> diagnostics() const
// V2: Singer-wide automation lane (absolute seconds). See NoteRef::lane for names.
Singer& lane(const std::string& name, const Curve& c)
NoteRef note(int midi, int ticks, const std::string& lyric, float velocity = 0.75f)
Singer& rest(int ticks) { cursor_ += ticks_to_sec(ticks); return *this; }
NoteRef note_sec(int midi, double seconds, const std::string& lyric, float velocity = 0.75f)
Singer& rest_sec(double seconds) { cursor_ += seconds; return *this; }
// V2 events at the cursor: laugh, giggle, sob, hum, shout, kyaa and
// interjections (ah, eh, un, fuun, uun, eeto, ano, waa, hya, hee, eee, maa). Same as the lyric
// tag, e.g. note_sec(69, 1.2, "<laugh>"). `variant` and extra "key=value" go in the tag.
NoteRef event(const std::string& kind, int midi, double seconds, float intensity = 0.6f, const std::string& variant = "")
// Absolute placement; the cursor moves to the end of the note.
NoteRef note_at(double start_sec, int midi, double seconds, const std::string& lyric, float velocity = 0.75f)
void clear() { notes_.clear(); cursor_ = 0.0; phrase_curve_.clear(); lanes_.clear(); }
size_t size() const { return notes_.size(); }
const std::deque<SynthNote>& notes() const { return notes_; }
double cursor() const { return cursor_; }
double ticks_to_sec(int ticks) const { return static_cast<double>(ticks) / ppq_ * 60.0 / bpm_; }
// Debug/listening hook: when set, every finished render is passed to it.
using TapFn = std::function<void(const Buffer&, int)>;
static TapFn& render_tap() { static TapFn f; return f; }
Buffer render(int sample_rate = 0) const
Buffer render_impl(int sample_rate) const
/// V3: on-demand rendering. The score is analysed once when the stream is created; audio is then pulled
/// in chunks of any size with VoiceStream::read(). The samples are identical to render(), however the
/// reads are chunked. (Notes added after the stream was created are not heard by it.)
VoiceStream stream(int sample_rate = 0) const
/// V3: the articulation control track (formants, bandwidths, noise, amplitude per key-frame) exactly as the
/// synthesiser will receive it, before pitch tracking and expression. For inspection and tooling
/// (tools/locus_probe.cpp measures consonant loci from it).
KeyTrack key_track(int sample_rate = 0) const
/// V3: a copy with every note moved by `semitones` (for harmonies). Personas, look and lanes are kept.
Singer transposed(int semitones) const
/// V3: a copy that performs the same notes as a different take: its own timing/pitch imperfection and
/// voice wobble (`natural_amount`), optionally detuned by a constant number of cents.
Singer doubled(uint32_t take, float natural_amount = 0.3f, double detune_cents = 0.0) const
StereoBuffer render_stereo(int sample_rate = 0) const
void save(const std::string& path, int sample_rate = 0) const
// Reads notes (and Lyric/Text meta events) from one track of a parsed MIDI
// file. track < 0 picks the first track that contains lyrics. Notes without a
// lyric continue the previous vowel (melisma). Lyrics may be UTF-8 or
// Shift-JIS kana. Returns the number of notes added.
size_t load_midi_track(const midi::ParsedMidiFile& f, int track = -1)
size_t load_midi_file(const std::string& path, int track = -1)
wauvio::vocal::v3::class SingerInstrument
// Drop-in for Arrangement / MidiMusic parts: renders ONE note with a fixed lyric
// (no coarticulation with neighbouring notes; use Singer for phrases).
class SingerInstrument : public wauvio::music::Instrument
public:
std::string lyric = "あ";
Style style;
VoiceProfile profile = voice_yune(); // which character sings (default Yune)
SingerInstrument() { name = "Japanese Female Singer"; }
explicit SingerInstrument(std::string lyr) : lyric(std::move(lyr)) { name = "Japanese Female Singer"; }
StereoBuffer render_note(const wauvio::music::Note& n, int sample_rate = 0) const override
std::vector<wauvio::music::Articulation> supported_articulations() const override