Did you know ... Search Documentation:
Pack musicxml -- prolog/musicxml.pl
PublicShow source

This module provides tools for handling MusicXML files. Some of the types used are defined as follows:

chord ---> chord(pitch_class, pitch_class, list(interval)).
pitch ---> rest; pitch(pitch_class, octave).

octave      == integer.
pitch_class == alterable(nominal).
interval    == alterable(degree).

alterable(A) ---> a(A, integer).

nominal ---> 'A'; 'B'; 'C'; 'D'; 'E'; 'F'; 'G'.
degree  ---> 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14.

An 'alterable' in this context is something that can have a number of sharps or flats associated with it, including pitch classes and scale degrees. The event type is a pair of a time spec and a payload type. The time spec can be a number (a time point), a span (a pair of start and end time), or a tagged union of points and spans. Tied objects (notes) are specified by a pair of bools indicating if the object is tied to the previous and next objects respectively.

event(T, X) == pair(T, X).
ties == pair(bool, bool)
span == pair(number, number)
time_spec ---> point(number); span(span).
score_token ---> end; bar; change(chord); slice(list(tied(Pitch))).
tied(A) == pair(ties, A).
 musicxml_score(+Source:source, -Score:xml) is det
Read MusicXML from Source and unify Score with XML data structure. Source can be a file name or stream(StreamHandle) as recognised by load_xml/3.
 score_prop(+S:xml, -P:score_prop) is nondet
Valid props:
score_prop ---> parts(list(pid))
              ; title(atom)
              ; software(atom)
              ; date(atom).
 score_part_prop(+S:xml, +P:pid, -P:part_prop) is nondet
Also verifies that measure numbers are contiguous. Valid props:
part_prop ---> divisions(nat)   % time is counted in this fraction of a crochet.
             ; fifths(integer)  % number of sharps (+ve) or flats (-ve) in key sig
             ; n_measures(nat). % number of measures in part
 events_slices(+Events:list(event(time_spec,score_token)), -Slices:list(event(span,list(tied(pitch))))) is det
 score_part_slices(+S:xml, +P:pid, -Slices:list(event(span,list(tied(pitch))))) is det
 score_part_notes(+S:xml, +P:pid, -Notes:list(event(span,pitch))) is det
 score_part_chords(+S:xml, +P:pid, -Chords:list(event(span,chord))) is det
 score_part_events(+S:xml, +P:pid, -Events:list(event(time_spec,score_token))) is det
 slices_notes(+Slices:list(event(span,list(tied(pitch)))), -Notes:list(event(span,pitch))) is det
Converts a sequence of time slices each containing multiple tied notes into a sequence of complete, possibly overlapping note events (without rests).