- handling midifile meta events
> I couldn't find any examples how to use meta events
There are a couple of examples in files like lib/wharmony.k
and lib/wbargen9.k. You don't have to use midibytes().
Instead you represent meta events as 'text notes' with a particular format.
Here's the line in lib/wharmony.k that creates a lyric
phr = '"Lyric=rest",ac10o-3v1'
This phrase expression has two notes, the first one
is the lyric meta event, the second one is a normal note.
So, meta events are notes in a phrase expression
that look like "key=value". Said another way,
a double-quoted string contained within a
single-quoted phrase expression.
The meta 'key' names (case-and-space-sensitive) are:
The first 10 of those have single values, e.g.
phr = '"Instrument Name=Bass Guitar"'
The last 3 have multiple values in a particular
format specific to each metatype. Here's an
example of each:
phr = '"Timesig=4/4,24,8"'
phr = '"Keysig=0,1"' # flats-sharps,major-minor
phr = '"Smpte=1,2,3,4,5"' # hr,mn,se,fr,ff
This page has some nice explanation of the meta events:
So, don't use midibytes(), use phrase expressions like these.
If there's any question about exact format/values, you should
be able to read in a MIDI file (using readmf) that contains
meta events, and print the phrase (using print) to see what
the meta events look like in keykit phrase syntax. The same
syntax used in printing the phrases should work when specifying
them. If you need to specify them using variables (i.e. the
values for the meta event aren't constant, as in the examples
above), you can construct the value as shown in this
line from lib/wbargen9.k :
kp = phrase("'\"Keysig=" + sharpflats[v] + "," + majmin + "\" '")
The phrase() function takes a string that looks like a phrase constant,
and converts it to a real phrase value. When doing this, you end up
needing to have double-quotes (for the string) containing
single-quotes (for the phrase) containing double-quotes
(for the meta message), hence the need to escape the inner double-quotes
with a backslash, shown in that example.