X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fambitus.cc;h=a4864d6b2973437c5f6a2cbd5eb313ce22d7d8b3;hb=062b17ac5868311ee1e31655da86da1c931ffe31;hp=ccc7ba3318c455a6818f3f2358807eff12fb7866;hpb=680d569e15890605428c5174b438ac11b63c32d5;p=lilypond.git diff --git a/lily/ambitus.cc b/lily/ambitus.cc index ccc7ba3318..a4864d6b29 100644 --- a/lily/ambitus.cc +++ b/lily/ambitus.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (C) 2002 Juergen Reuter + (c) 2002--2003 Juergen Reuter */ #include "staff-symbol-referencer.hh" @@ -40,34 +40,38 @@ */ /** - * Given a pitch and a key_signature, decide what accidentals to show. - * - * Possible return values: - * - * 0: do not show any accidental - * 1: show pitch->alteration_i_ only - * 2: show pitch->alteration_i_, preceded by a natural sign + Given a pitch and a key_signature, decide what accidentals to show. + + Possible return values: + + 0: do not show any accidental + 1: show pitch->alteration_ only + 2: show pitch->get_alteration, preceded by a natural sign + + UGH: code duplication! See accidental-engraver. + */ static int number_accidentals (SCM key_signature, Pitch *pitch, bool ignore_octave_b, bool force_accidental) { - int notename = pitch->notename_i_; - int octave = pitch->octave_i_; - int alteration = pitch->alteration_i_; + int notename = pitch->get_notename (); + int octave = pitch->get_octave(); + int alteration = pitch->get_alteration(); if (force_accidental) // ignore key signature return 1; + #if DEBUG_AMBITUS scm_display (key_signature, scm_current_output_port ()); #endif SCM prev; if (ignore_octave_b) - prev = ly_assoc_cdr (gh_int2scm (notename), key_signature); + prev = ly_assoc_cdr (scm_int2num (notename), key_signature); else - prev = gh_assoc (gh_cons (gh_int2scm (octave), gh_int2scm (notename)), + prev = scm_assoc (gh_cons (scm_int2num (octave), scm_int2num (notename)), key_signature); /* should really be true unless prev == SCM_BOOL_F */ @@ -78,9 +82,9 @@ number_accidentals (SCM key_signature, Pitch *pitch, /* If an accidental was not found */ if (prev == SCM_BOOL_F) - prev = gh_assoc (gh_int2scm (notename), key_signature); + prev = scm_assoc (scm_int2num (notename), key_signature); - SCM prev_acc = (prev == SCM_BOOL_F) ? gh_int2scm (0) : ly_cdr (prev); + SCM prev_acc = (prev == SCM_BOOL_F) ? scm_int2num (0) : ly_cdr (prev); int sig_alteration = gh_number_p (prev_acc) ? gh_scm2int (prev_acc) : 0; if (alteration == sig_alteration) // no accidental at all needed @@ -101,23 +105,23 @@ add_accidentals (Item *me, Molecule *head, int num_acc, { if (!num_acc) return; - if (pitch->alteration_i_) + if (pitch->get_alteration()) { Molecule accidental (Font_interface::get_default_font (me)-> find_by_name (String ("accidentals-") + accidentals_style + - to_str (pitch->alteration_i_))); + to_string (pitch->get_alteration()))); accidental.translate_axis (yoffs, Y_AXIS); - head->add_at_edge (X_AXIS, LEFT, accidental, 0.1); + head->add_at_edge (X_AXIS, LEFT, accidental, 0.1, 0); } if (num_acc == 2) { Molecule natural (Font_interface::get_default_font (me)-> find_by_name (String ("accidentals-") + accidentals_style + - to_str ("0"))); + to_string ("0"))); natural.translate_axis (yoffs, Y_AXIS); - head->add_at_edge (X_AXIS, LEFT, natural, 0.1); + head->add_at_edge (X_AXIS, LEFT, natural, 0.1, 0); } } @@ -133,7 +137,7 @@ Ambitus::brew_molecule (SCM smob) if (gh_symbol_p (scm_note_head_style)) { String note_head_style = - ly_scm2string (scm_symbol_to_string (scm_note_head_style)); + ly_symbol2string (scm_note_head_style); } else { @@ -142,22 +146,40 @@ Ambitus::brew_molecule (SCM smob) if (Font_interface::get_default_font (me)->find_by_name (note_head_style).empty_b ()) { String message = "Ambitus: no such note head: `" + note_head_style + "'"; - me->warning (_ (message.ch_C ())); + me->warning (_ (message.to_str0 ())); return SCM_EOL; } + /* + FIXME: Use positions. + */ + int p_min, p_max; Pitch *pitch_min = unsmob_pitch (me->get_grob_property ("pitch-min")); - int p_min = pitch_min->steps (); + if (!pitch_min) + { + me->programming_error("Ambitus: pitch_min undefined; assuming 0"); + p_min = 0; + } + else + { + p_min = pitch_min->steps (); + } Pitch *pitch_max = unsmob_pitch (me->get_grob_property ("pitch-max")); - int p_max = pitch_max->steps (); + if (!pitch_max) + { + me->programming_error("Ambitus: pitch_max undefined; assuming 0"); + p_max = 0; + } + else + { + p_max = pitch_max->steps (); + } if (p_min > p_max) { - String message = "Ambitus: no range to output"; - me->warning (_ (message.ch_C ())); - return SCM_EOL; + me->programming_error ("Ambitus: reverse range"); } - SCM c0 = me->get_grob_property ("centralCPosition"); + SCM c0 = me->get_grob_property ("c0-position"); if (gh_number_p (c0)) { p_min += gh_scm2int (c0); @@ -176,8 +198,8 @@ Ambitus::brew_molecule (SCM smob) if (to_boolean (me->get_grob_property ("join-heads")) && ((p_max - p_min) >= 3)) { - Real linethickness = me->paper_l ()->get_var ("linethickness"); - Real blotdiameter = me->paper_l ()->get_var ("blotdiameter"); + Real linethickness = me->get_paper ()->get_var ("linethickness"); + Real blotdiameter = me->get_paper ()->get_var ("blotdiameter"); Interval x_extent = 0.5 * Interval (-linethickness, +linethickness); Interval y_extent = 0.5 * Interval (p_min + 1.35, p_max - 1.35); Box line_box (x_extent, y_extent); @@ -204,13 +226,13 @@ Ambitus::brew_molecule (SCM smob) molecule.add_molecule (ledger_lines); // add accidentals - SCM key_signature = me->get_grob_property ("keySignature"); + SCM key_signature = me->get_grob_property ("key-signature"); SCM scm_accidentals_style = me->get_grob_property ("accidentals-style"); String accidentals_style; if (gh_symbol_p (scm_accidentals_style)) { accidentals_style = - ly_scm2string (scm_symbol_to_string (scm_accidentals_style)); + ly_symbol2string (scm_accidentals_style); } else { @@ -233,4 +255,4 @@ Ambitus::brew_molecule (SCM smob) ADD_INTERFACE (Ambitus, "ambitus-interface", "An ambitus represents the pitch range of a voice.", - "note-head-style join-heads"); + "c0-position pitch-min pitch-max accidentals note-head-style join-heads");