18
19:- module(interps,[]).
52:- use_module(library(dcg_core)). 53:- use_module(library(dcg_codes)). 54:- use_module(library(dcg_macros)). 55:- use_module(library(humdrum/humutils)). 56:- op(550,xfx,--). 57
58:- set_prolog_flag(double_quotes,codes). 60
61
71
72humdrum:hum_interp_hook(Term) --> interp(Term).
73
74
75
76secname(A) --> atom_chars_ex(text,"",">[,",A).
77
79interp(section(A)) --> ">", secname(A).
80interp(section(B,A)) --> ">", secname(B), ">", secname(A).
81interp(explist(A)) --> ">", sqbr(seqmap_with_sep(",",secname,A)).
82interp(explist(B,A)) --> ">", secname(B), sqbr(seqmap_with_sep(",",secname,A)).
83
85interp(tb(R)) --> "tb", nat(R). 86interp(metre(N,D)) --> "M", nat(N), "/", nat(D).
87interp(metro(M)) --> "MM", float(M).
88interp(metro(M1--M2))--> "MM", float(M1), "-", float(M2).
89interp(tempo(W)) --> "MM", sqbr(charsex(alpha,[],[],WW)),
90 {atom_codes(W,WW)}.
91
92
94interp(staff(S)) --> "staff", staff_numbers(S).
95interp(clef(C)) --> "clef", atom_chars_ex(graph,[],[],C).
96interp(instr(I)) --> "I", atom_chars_ex(graph,"CGT",[],I).
97interp(igroup(I)) --> "IG", atom_chars_ex(graph,[],[],I).
98interp(iclass(I)) --> "IC", atom_chars_ex(graph,[],[],I).
99
100interp(keysig(K)) --> "k", sqbr(seqmap(pitchclass(lower),K)).
101interp(key(P,maj))--> pitchclass(upper,P), ":".
102interp(key(P,min))--> pitchclass(lower,P), ":".
103interp(trans) --> "ITr".
104
105staff_numbers(S) --> seqmap_with_sep("/",nat,S).
106
109atom_chars_ex(Type,Ex1,Ex,A) -->
110 charsex(Type,Ex1,Ex,Codes),
111 {Codes\=[], atom_codes(A,Codes)}
Hooks for parsing Humdrum spine interpretations
This module defines the hook predicate hum_interp_hook//1 for recognising when a Humdrum spine contains interpretation data.
It currently produces interpretation terms with the following type:
See
humutils.pl
for definition of pitch_class type. */