With note info strings, you are required to enter something at every
timestep, even if it is only the duration. This makes sense because if you
do not enter something, there is simply no indication of a timestep.
A nice feature of music strings is that explicit timesteps are achieved
just by having notes present, allowing you to leave out durations entirely
when they repeat, inheriting them from the previous timestep where duration
was given explicitly. There is no need to enter the same number across
consecutive timesteps; the first will suffice and the rest are automatically
filled in for you when the object is constructed.
musical()
returns a scalar logical result indicating whether all timesteps
contain exclusively valid entries.
as_music()
can be used to coerce to the music
class. Coercion will fail
if the string is not musical. The music
class has its own print()
and
summary()
methods. music
objects are primarily intended to represent an
aggregation of a noteworthy
object and a noteinfo
. You can optionally
fold in a lyrics
object as well. However, for music data analysis, any
operations will involve first splitting the object into its component parts.
The value of this class is for the more efficient data entry it provides.
When accidentals
or format
are NULL
, these settings are inferred from
the musical string input. When mixed formats are present, flats are the
default for accidentals.
Other attributes are attached to a music
object. key
uses the tabr
syntax, e.g., "c"
, "b_"
, "f#m"
, etc. time
and tempo
use the
LilyPond string format. For music programming and analysis, key
, time
and
tempo
can most likely be ignored. They are primarily relevant when
rendering a music snippet directly from a music
object with LilyPond.
These additional attributes provide more complete context for the rendered
sheet music.
If you plan to render music snippets from a music
object that you are
defining from a new character string, and the context you have in mind is a
stringed and fretted instrument like guitar, you can specify string numbers
at the end of each timestep with numbers following a semicolon delimiter.
This would still precede any *
timestep multiplier number. See examples.
Note that if you convert a music object to a phrase object, you are changing
contexts. The phrase object is the simplest LilyPond-format music structure.
Coercion with phrase()
strips all attributes of a music object and
retains only notes, note info and string numbers.