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 372<br />

|- AmbitusNoteHead for upper note<br />

|- AmbitusAccidental for upper note<br />

|- AmbitusNoteHead for lower note<br />

|- AmbitusAccidental for lower note<br />

The parent of an accidental is the correspond<strong>in</strong>g note head,<br />

and the accidental is set as the 'accidental-grob of the note head<br />

so that is pr<strong>in</strong>ted by the function that pr<strong>in</strong>ts notes."<br />

;; make the ambitus object<br />

(let ((ambitus (make )))<br />

;; build the Ambitus grob, which will conta<strong>in</strong> all other grobs<br />

(set! (ambitus-group ambitus) (ly:engraver-make-grob translator 'Ambitus '()))<br />

;; build the AmbitusL<strong>in</strong>e grob (l<strong>in</strong>e between lower and upper note)<br />

(set! (ambitus-l<strong>in</strong>e ambitus) (ly:engraver-make-grob translator 'AmbitusL<strong>in</strong>e '()))<br />

;; build the upper and lower AmbitusNoteHead and AmbitusAccidental<br />

(for-each (lambda (direction)<br />

(let ((head (ly:engraver-make-grob translator 'AmbitusNoteHead '()))<br />

(accidental (ly:engraver-make-grob translator 'AmbitusAccidental '())<br />

(group (ambitus-group ambitus)))<br />

;; The parent of the AmbitusAccidental grob is the<br />

;; AmbitusNoteHead grob<br />

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

;; The AmbitusAccidental grob is set as the accidental-grob<br />

;; object of the AmbitusNoteHead. This is later used by the<br />

;; function that pr<strong>in</strong>ts notes.<br />

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

;; both the note head and the accidental grobs are added<br />

;; to the ma<strong>in</strong> ambitus grob.<br />

(ly:axis-group-<strong>in</strong>terface::add-element group head)<br />

(ly:axis-group-<strong>in</strong>terface::add-element group accidental)<br />

;; the note head and the accidental grobs are added to the<br />

;; ambitus object<br />

(set! (ambitus-note-head (ambitus-note ambitus direction))<br />

head)<br />

(set! (ambitus-note-accidental (ambitus-note ambitus direction))<br />

accidental)))<br />

(list DOWN UP))<br />

;; The parent of the ambitus l<strong>in</strong>e is the lower ambitus note head<br />

(set! (ly:grob-parent (ambitus-l<strong>in</strong>e ambitus) X)<br />

(ambitus-note-head (ambitus-note ambitus DOWN)))<br />

;; the ambitus l<strong>in</strong>e is added to the ambitus ma<strong>in</strong> grob<br />

(ly:axis-group-<strong>in</strong>terface::add-element (ambitus-group ambitus) (ambitus-l<strong>in</strong>e ambitus))<br />

ambitus))<br />

#(def<strong>in</strong>e-method (<strong>in</strong>itialize-ambitus-state (ambitus ) translator)<br />

"Initialize the state of @var{ambitus}, by gett<strong>in</strong>g the start<strong>in</strong>g<br />

position of middle C and key signature from @var{translator}'s context."<br />

(if (not (ambitus-start-c0 ambitus))<br />

(beg<strong>in</strong><br />

(set! (ambitus-start-c0 ambitus)<br />

(ly:context-property (ly:translator-context translator)<br />

'middleCPosition

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

Saved successfully!

Ooh no, something went wrong!