10.04.2013 Views

in Snippets - LilyPond

in Snippets - LilyPond

in Snippets - LilyPond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Contexts and engravers 370<br />

%%%<br />

%%% Grob utilities<br />

%%%<br />

%%% These are literal rewrites of some C++ methods used by the ambitus engraver.<br />

#(def<strong>in</strong>e (ly:separation-item::add-conditional-item grob grob-item)<br />

"Add @var{grob-item} to the array of conditional elements of @var{grob}.<br />

Rewrite of @code{Separation_item::add_conditional_item} from @file{lily/separation-item.cc}.<br />

(ly:po<strong>in</strong>ter-group-<strong>in</strong>terface::add-grob grob 'conditional-elements grob-item))<br />

#(def<strong>in</strong>e (ly:accidental-placement::accidental-pitch accidental-grob)<br />

"Get the pitch from the grob cause of @var{accidental-grob}.<br />

Rewrite of @code{accidental_pitch} from @file{lily/accidental-placement.cc}."<br />

(ly:event-property (ly:grob-property (ly:grob-parent accidental-grob Y) 'cause)<br />

'pitch))<br />

#(def<strong>in</strong>e (ly:accidental-placement::add-accidental grob accidental-grob)<br />

"Add @var{accidental-grob}, an @code{Accidental} grob, to the<br />

list of the accidental grobs of @var{grob}, an @code{AccidentalPlacement}<br />

grob.<br />

Rewrite of @code{Accidental_placement::add_accidental} from @file{lily/accidental-placement.<br />

(let ((pitch (ly:accidental-placement::accidental-pitch accidental-grob)))<br />

(set! (ly:grob-parent accidental-grob X) grob)<br />

(set! (ly:grob-property accidental-grob 'X-offset)<br />

ly:grob::x-parent-position<strong>in</strong>g)<br />

(let* ((accidentals (ly:grob-object grob 'accidental-grobs))<br />

(handle (assq (ly:pitch-notename pitch) accidentals))<br />

(entry (if handle (cdr handle) '())))<br />

(set! (ly:grob-object grob 'accidental-grobs)<br />

(assq-set! accidentals<br />

(ly:pitch-notename pitch)<br />

(cons accidental-grob entry))))))<br />

%%%<br />

%%% Ambitus data structure<br />

%%%<br />

%%% The class holds the various grobs that are created<br />

%%% to pr<strong>in</strong>t an ambitus:<br />

%%% - ambitus-group: the grob that groups all the components of an ambitus<br />

%%% (Ambitus grob);<br />

%%% - ambitus-l<strong>in</strong>e: the vertical l<strong>in</strong>e between the upper and lower ambitus<br />

%%% notes (AmbitusL<strong>in</strong>e grob);<br />

%%% - ambitus-up-note and ambitus-down-note: the note head and accidental<br />

%%% for the lower and upper note of the ambitus (see class<br />

%%% below).<br />

%%% The other slots def<strong>in</strong>e the key and clef context of the engraver:<br />

%%% - start-c0: position of middle c at the beg<strong>in</strong>n<strong>in</strong>g of the piece. It<br />

%%% is used to place the ambitus notes accord<strong>in</strong>g to their pitch;<br />

%%% - start-key-sig: the key signature at the beg<strong>in</strong>n<strong>in</strong>g of the piece. It<br />

%%% is used to determ<strong>in</strong>e if accidentals shall be pr<strong>in</strong>ted next to ambitus<br />

%%% notes.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!