- Item *note_p = new Item (get_property ("NoteHead"));
-
- Music * req = note_req_l_arr_[i];
-
- Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
-
- note_p->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
-
- if (dur.dot_count ())
- {
- Item * d = new Item (get_property ("Dots"));
- Rhythmic_head::set_dots (note_p, d);
-
- if (dur.dot_count ()
- != gh_scm2int (d->get_grob_property ("dot-count")))
- d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
-
- d->set_parent (note_p, Y_AXIS);
- announce_grob (d, SCM_EOL);
- dot_p_arr_.push (d);
- }
-
- Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
-
- int pos = pit->steps ();
- SCM c0 = get_property ("centralCPosition");
- if (gh_number_p (c0))
- pos += gh_scm2int (c0);
-
- note_p->set_grob_property ("staff-position", gh_int2scm (pos));
- announce_grob (note_p,req->self_scm());
- note_p_arr_.push (note_p);
+ Stream_event *ev = note_evs_[i];
+ Item *note = make_item ("NoteHead", ev->self_scm ());
+
+ Pitch *pit = unsmob<Pitch> (ev->get_property ("pitch"));
+
+#if 0 /* TODO: should have a mechanism to switch off these warnings. */
+
+ if (!pit)
+ ev->origin ()->warning (_ ("NoteEvent without pitch"));
+#endif
+
+ int pos;
+ if (pit == 0)
+ pos = 0;
+ else if (ly_is_procedure (layout_proc))
+ {
+ SCM pitch = ev->get_property ("pitch");
+ pos = scm_to_int (scm_call_1 (layout_proc, pitch));
+ }
+ else
+ pos = pit->steps ();
+
+ if (scm_is_number (c0))
+ pos += scm_to_int (c0);
+
+ note->set_property ("staff-position", scm_from_int (pos));
+
+ /*
+ Shape note heads change on step of the scale.
+ */
+ SCM shape_vector = get_property ("shapeNoteStyles");
+ if (scm_is_vector (shape_vector))
+ {
+ SCM scm_tonic = get_property ("tonic");
+ Pitch tonic;
+ if (unsmob<Pitch> (scm_tonic))
+ tonic = *unsmob<Pitch> (scm_tonic);
+
+ unsigned int delta = (pit->get_notename () - tonic.get_notename () + 7) % 7;
+
+ SCM style = SCM_EOL;
+ if (scm_c_vector_length (shape_vector) > delta
+ && scm_is_symbol (scm_vector_ref (shape_vector, scm_from_int (delta))))
+ style = scm_vector_ref (shape_vector, scm_from_int (delta));
+ if (scm_is_symbol (style))
+ note->set_property ("style", style);
+ }