ws-audio2: move music/midi/Render to codecs/audio/MidiRender (attach: summary + render method, shared by the MIDI variants); .kar lyrics -> meta.lyrics / karaoke / tags
This commit is contained in:
1 parent
de4f14a343
commit
4dd6cd1400
5 files changed
+156
-43
No files matched your search
@@ -254,6 +254,40 @@ for _, c in Cases do
|
||||
table.insert(samples, c.data)
|
||||
end
|
||||
end
|
||||
-- .kar karaoke: the "Words" track's text events (FF 01) with @ headers, plus FF 05 lyrics, timed through the tempo map
|
||||
do
|
||||
local function txt(tick: number, meta: number, s: string): any
|
||||
return { tick = tick, type = "meta", meta = meta, data = { string.byte(s, 1, -1) } }
|
||||
end
|
||||
local k = Types.Midi.new(96)
|
||||
table.insert(k.tracks, { events = {
|
||||
{ tick = 0, type = "meta", meta = 0x51, data = { 0x0F, 0x42, 0x40 } }, -- 1 s per quarter
|
||||
txt(0, 1, "Copyright notice, not a lyric"),
|
||||
{ tick = 192, type = "noteOn", channel = 0, data = { 60, 100 } },
|
||||
{ tick = 288, type = "noteOff", channel = 0, data = { 60, 0 } },
|
||||
} })
|
||||
table.insert(k.tracks, { events = {
|
||||
txt(0, 3, "Words"), txt(0, 1, "@KMIDI KARAOKE FILE"), txt(0, 1, "@LENG"), txt(0, 1, "@TSong title"),
|
||||
txt(0, 1, "@TThe artist"), txt(0, 1, "@Isome info"), txt(96, 1, "\\Hel"), txt(144, 1, "lo"),
|
||||
txt(192, 1, "/world"), txt(240, 5, "!"),
|
||||
} })
|
||||
local m = assert(decode(Midi.encode(k)))
|
||||
local ly = m.meta.lyrics
|
||||
t:eq(#ly, 4, "kar: lyric count")
|
||||
t:eq(ly[1].text, "\\Hel", "kar: first lyric (paragraph marker kept)")
|
||||
t:eq(ly[1].tick, 96, "kar: tick")
|
||||
t:check(math.abs(ly[1].time - 1) < 1e-9 and math.abs(ly[3].time - 2) < 1e-9, "kar: times through the tempo map")
|
||||
t:eq(ly[4].text, "!", "kar: FF 05 lyric")
|
||||
t:eq(m.meta.karaoke.T[2], "The artist", "kar: @T lines")
|
||||
t:eq(m.meta.karaoke.K[1], "MIDI KARAOKE FILE", "kar: @K")
|
||||
t:eq(m.meta.tags.title, "Song title", "kar: tags.title")
|
||||
t:eq(m.meta.tags.artist, "The artist", "kar: tags.artist")
|
||||
t:eq(m.meta.tags.language, "ENG", "kar: tags.language")
|
||||
t:eq(m:render().tags.title, "Song title", "kar: decoder title")
|
||||
local plain = assert(decode(Midi.encode(Types.Midi.new(96))))
|
||||
t:eq(plain.meta.lyrics, nil, "no lyrics without text events")
|
||||
end
|
||||
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
return decode(b)
|
||||
end, samples, { mutations = 40 })
|
||||
|
||||
Reference in new issue
Block a user