ws-apifix: music is audio (F.save / F.convert of a Module or Midi to an audio format renders it, render options from opts; F.audio.open / load render music bytes), F.music builder (ops/MusicOps: new, addPattern, setCell / getCell, addSample, addInstrument, note; also F.ops.music), MIDI writer writes track.name as a 0x03 event
api (init.luau): detectFor() falls back from audio to rendering music formats; encoderFor finds audio formats for music values; renderMusic() through codecs/audio/Tracker or music/midi render.
This commit is contained in:
1 parent
25d8e4ff25
commit
10bd6b021f
7 files changed
+692
-16
No files matched your search
@@ -169,6 +169,23 @@ do
|
||||
t:check(nope == nil and nerr.code == Err.ARG, "encode refuses nil")
|
||||
end
|
||||
|
||||
-- track.name is written as a 0x03 meta event at tick 0 when the track has none; an existing one wins
|
||||
do
|
||||
local m = Types.Midi.new(96)
|
||||
local notes = { { tick = 0, type = "noteOn", channel = 0, data = { 60, 100 } }, { tick = 96, type = "noteOff", channel = 0, data = { 60, 0 } } }
|
||||
m.tracks[1] = { name = "Lead", events = notes }
|
||||
m.tracks[2] = { name = "Ignored", events = { { tick = 0, type = "meta", meta = 0x03, data = { string.byte("Bass", 1, -1) } } } }
|
||||
m.tracks[3] = { name = "", events = {} }
|
||||
local back = decode(Midi.encode(m) :: buffer)
|
||||
t:eq(back.tracks[1].name, "Lead", "track.name written")
|
||||
local first = back.tracks[1].events[1]
|
||||
t:check(first.type == "meta" and first.meta == 0x03 and first.tick == 0, "as a 0x03 event at tick 0")
|
||||
t:eq(#back.tracks[1].events, 4, "name + 2 notes + end of track")
|
||||
t:eq(back.tracks[2].name, "Bass", "the track's own 0x03 event wins")
|
||||
t:eq(back.tracks[3].name, nil, "empty name: nothing written")
|
||||
t:eq(#m.tracks[1].events, 2, "the caller's events are not changed")
|
||||
end
|
||||
|
||||
-- crafted bad files
|
||||
for _, c in Bad do
|
||||
local ok, m, err = pcall(decode, c.data)
|
||||
|
||||
Reference in new issue
Block a user