Vocal engine (wauvio/vocal)
Lyric input (kana, romaji, phonemes)
Header yune-v3/japanese.hpp. Lyrics are parsed into Moras by parse_lyric(): UTF-8 kana first; plain ASCII is read as romaji; braces switch to phoneme mode.
See it in action: Hello, singer · Text score for the sing_score tool
Accepted notations
| Notation | Example | Notes |
|---|---|---|
| Hiragana / katakana | さくら, サクラ | Katakana is folded to hiragana; ー continues the previous vowel; small ゃゅょ and small vowels form yo-on and foreign sounds (ふぁ, てぃ, つぁ …); っ geminate; ん moraic nasal |
| Romaji | ka ki kya shi chi tsu fu n xtu - | Hepburn/Kunrei style; doubled consonants give a geminate; write n' or nn for ん before a vowel/y |
| Phonemes (v2+) | {k a n a}, {N}, {Q}, {ng a}, {v a} | Space-separated romaji/IPA-like tokens in braces. Consonant + vowel tokens join. Capital N = ん, Q = っ. IPA symbols accepted (ɕ ʃ tɕ dʑ ʑ ɸ ɾ ɯ ŋ ɲ ç ɴ ː) |
| Per-phoneme overrides | {k*1.6 a@2 n@0.5} | *x consonant strength, @w relative share of the note’s time |
| Time weights (v2+) | さ[0.7]ん[0.3] | Relative time per segment |
| Events | <laugh> | Lyric tags expanded into notes; see Events |
ParseOptions
merge_long_vowels(true) — “おう/えい/ああ” inside one lyric become a single long vowel.cute(false, v2+) — baby-talk softening: s/z/t/d/n/r palatalise.particles(false, v3) — a trailing は/へ is read as わ/え. Independent of the flag, a trailing^marks a single は/へ as a particle anywhere (は^,へ^).
Model types
VowelA I U E O;Cons(kana rows): None, K, G, S, Z, T, D, N, H, P, B, M, R, Y, W.Mora—c,v,palatal,geminate,nasal,longv,force(foreign overrides F, TI, DI, TS, J, CH, SH, S, Z, V),labial,ng,weight,cons_scale,text.Surf— the realised consonant classes the synthesiser builds: K G T D P B TS CH J S SH Z H HY FU N NY M R Y W GEM MORAIC_N NG V (v3 addsV= [v] for ヴ).surface(mora)resolves the allophone;is_voiced,is_obstruent_unvoiced.decode_lyric_bytes()— decodes MIDI karaoke lyric bytes (UTF-8, ASCII or a minimal Shift-JIS kana subset).parse_kana,parse_romaji,parse_phonemes,parse_lyric.
Full API listing
wauvio/vocal/yune-v3/japanese.hpp
wauvio::vocal::v3::enum class Vowel
enum class Vowel : uint8_t { A = 0, I = 1, U = 2, E = 3, O = 4 };
wauvio::vocal::v3::enum class Cons
// Underlying (phonological) consonant of a mora: the kana row.
enum class Cons : uint8_t
None, K, G, S, Z, T, D, N, H, P, B, M, R, Y, W
wauvio::vocal::v3::struct Mora
struct Mora
Cons c = Cons::None;
Vowel v = Vowel::A;
bool palatal = false; // yo-on: きゃ しゅ ちょ ...
bool geminate = false; // っ
bool nasal = false; // ん (moraic nasal)
bool longv = false; // ー or merged long vowel: continue previous vowel
// Foreign-sound overrides (ふぁ てぃ つぁ ...): force a particular surface
// consonant in place of the one implied by (c, v).
enum class Force : uint8_t { None, F, TI, DI, TS, J, CH, SH, S, Z, V } force = Force::None;
bool labial = false; // V2: w-glide between consonant and vowel (くぁ ぐぁ ...)
bool ng = false; // V2: velar nasal [ŋ] (phoneme input "ng" / ガ行 nasalisation)
float weight = 1.f; // V2: relative share of the note's time (lyric syntax さ[0.7]ん[0.3], phoneme "@0.7")
float cons_scale = 1.f; // V2: consonant strength multiplier (phoneme "*1.5")
std::string text; // source text of the mora (UTF-8), for diagnostics
wauvio::vocal::v3::enum class Surf
// Realised consonant classes (what the synthesizer actually builds).
enum class Surf : uint8_t
None,
K, G, // velar stops (palatalised before i / yo-on)
T, D, // alveolar stops
P, B, // labial stops
TS, CH, J, // affricates: ts, tɕ, dʑ
S, SH, Z, // fricatives: s, ɕ, z
H, HY, FU, // h, ç, ɸ
N, NY, M, // nasals
R, // alveolar tap ɾ
Y, W, // glides j, ɰᵝ
GEM, // sokuon
MORAIC_N, // ん
NG, // [ŋ] velar nasal (V2: ガ行 nasalisation, phoneme input)
V // V3: [v] voiced labiodental fricative (ヴ, "v" in romaji/phonemes)
inline bool is_voiced(Surf s)
inline bool is_obstruent_unvoiced(Surf s)
wauvio::vocal::v3::struct SurfaceMora
struct SurfaceMora
Surf surf = Surf::None;
bool palatal = false; // palatalised release / j-glide between C and V
bool labial = false; // w-glide between C and V (V2)
// Resolve the allophone of a mora (independent of neighbours).
inline SurfaceMora surface(const Mora& m)
inline bool next_cp(const std::string& s, size_t& i, uint32_t& cp)
inline std::string cp_to_utf8(uint32_t cp)
inline bool valid_utf8(const std::string& s)
// Katakana -> hiragana (ァ..ヶ -> ぁ..ゖ); ー stays.
inline uint32_t to_hira(uint32_t cp)
struct Row { Cons c; bool pal; };
// Basic consonant-vowel table keyed by hiragana code point -> (consonant, vowel).
struct Cv { Cons c; Vowel v; };
inline const std::map<uint32_t, Cv>& cv_table()
inline bool is_small_ya(uint32_t cp, Vowel& v)
inline bool is_small_vowel(uint32_t cp, Vowel& v)
wauvio::vocal::v3::struct ParseOptions
struct ParseOptions
// "おう" / "えい" / "ああ" ... inside ONE lyric string become a single long
// vowel (ō, ē, aa) instead of two separate morae.
bool merge_long_vowels = true;
// V2: "cute speech" (baby-talk style) softening: s/z/t/d/n/r palatalise (さ -> しゃ-like).
bool cute = false;
// V3: grammatical particles. When true, は / へ at the END of a lyric string are read as わ / え
// ("わたしは" -> wa-ta-shi-wa). Independent of this flag, a trailing '^' marks a single は / へ as a
// particle anywhere ("は^", "へ^"), and "は" stays /ha/ otherwise.
bool particles = false;
// Kana (hiragana or katakana) -> morae. Whitespace, '|', ',' and '/' are ignored.
inline std::vector<Mora> parse_kana(const std::string& text, const ParseOptions& opt = {})
// Hepburn/Kunrei-style romaji -> morae. "ka ki kya shi chi tsu fu n xtu(=っ) -"
// Doubled consonants (kka, ssa, tta) produce a geminate; "n" before a vowel/y
// must be written "n'" or "nn".
inline std::vector<Mora> parse_romaji(const std::string& text, const ParseOptions& opt = {})
// Space-separated phonemes in a romaji/IPA-like notation, written between braces in a lyric:
// {k a n a} {ky a} {sh i} {ts u} {N} {Q} {-} {ng a} {v a}
// A consonant token followed by a vowel token is joined (k + a = ka, n + a = na). Write the
// moraic nasal ん as capital N, and the sokuon っ as Q. IPA symbols are accepted:
// ɕ ʃ tɕ dʑ ʑ ɸ ɾ ɯ ŋ ɲ ç ɴ ː. Per-phoneme overrides follow the token:
// *1.5 consonant strength x1.5 @0.7 share of the note's time (relative weight)
// e.g. {k*1.6 a@2 n@0.5}
inline std::vector<Mora> parse_phonemes(const std::string& text, const ParseOptions& opt = {})
inline std::vector<Mora> parse_lyric_plain(const std::string& text, const ParseOptions& opt)
// Parse a lyric string: UTF-8 kana first; if it is plain ASCII, treat as romaji.
// V2 syntax: `{k a n a}` phoneme mode, and `さ[0.7]ん[0.3]` relative time weights per segment.
inline std::vector<Mora> parse_lyric(const std::string& text, const ParseOptions& opt = {})
// Minimal Shift-JIS kana decoder for MIDI karaoke files (kana, ー, ASCII only).
// Returns UTF-8, or empty if the bytes are not decodable as UTF-8/ASCII/SJIS-kana.
inline std::string decode_lyric_bytes(const std::vector<uint8_t>& b)