source file of the GNU LilyPond music typesetter
- (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1999--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "chord-name.hh"
#include "molecule.hh"
#include "paper-def.hh"
#include "lookup.hh"
+#include "lily-guile.icc"
-SCM
-pitch2scm (Musical_pitch p)
-{
- return gh_cons (gh_int2scm (p.notename_i_), gh_int2scm (p.accidental_i_));
-}
-
-Chord_name::Chord_name (Chord const& c)
-{
- chord_ = c;
-}
+/*
+ TODO: move text lookup out of Chord_name
+ */
/*
word is roman text or styled text:
{
while (gh_cdr (scm) != SCM_EOL)
{
- mol.add_at_edge (X_AXIS, RIGHT,
- ly_word2molecule (gh_car (scm)), 0);
+ mol.add_at_edge (X_AXIS, RIGHT, ly_word2molecule (gh_car (scm)), 0);
scm = gh_cdr (scm);
}
scm = gh_car (scm);
}
- mol.add_at_edge (X_AXIS, RIGHT,
- ly_word2molecule (scm), 0);
+ mol.add_at_edge (X_AXIS, RIGHT, ly_word2molecule (scm), 0);
return mol;
}
Molecule
Chord_name::pitch2molecule (Musical_pitch p) const
{
- SCM name = scm_eval (gh_list (ly_symbol2scm ("user-pitch-name"), ly_quote_scm (pitch2scm (p)), SCM_UNDEFINED));
+ SCM name = scm_eval (gh_list (ly_symbol2scm ("user-pitch-name"),
+ ly_quote_scm (to_scm (p)),
+ SCM_UNDEFINED));
if (name != SCM_UNSPECIFIED)
{
return diff;
}
+/*
+ JUNKME
+ */
bool
Chord_name::user_chord_name (Array<Musical_pitch> pitch_arr, Chord_mol* name_p) const
{
- SCM chord = SCM_EOL;
Array<Musical_pitch> chord_type = pitch_arr;
Chord::rebuild_transpose (&chord_type, diff_pitch (pitch_arr[0], Musical_pitch (0)), false);
+#if 0
+ SCM chord = SCM_EOL;
for (int i= chord_type.size (); i--; )
- chord = gh_cons (pitch2scm (chord_type[i]), chord);
+ chord = gh_cons (to_scm (chord_type[i]), chord);
+#else
+ SCM chord = array_to_scm (chord_type);
+#endif
- SCM name = scm_eval (gh_list (ly_symbol2scm ("user-chord-name"), ly_quote_scm (chord), SCM_UNDEFINED));
+ SCM name = scm_eval (gh_list (ly_symbol2scm ("user-chord-name"),
+ ly_quote_scm (chord),
+ SCM_UNDEFINED));
if (gh_pair_p (name))
{
name_p->modifier_mol = ly_text2molecule (gh_car (name));
scale.push (Musical_pitch (i));
Musical_pitch tonic = pitch_arr[0];
- chord_.rebuild_transpose (&scale, tonic, true);
+ Chord::rebuild_transpose (&scale, tonic, true);
/*
Does chord include this step? -1 if flat
}
}
-Molecule*
-Chord_name::do_brew_molecule_p () const
+/*
+ TODO:
+ fix silly to-and-fro scm conversions
+ */
+Molecule
+Chord_name::do_brew_molecule () const
{
- Musical_pitch tonic = chord_.pitch_arr_[0];
+ Array<Musical_pitch> pitch_arr;
+ scm_to_array (get_elt_property ("pitches"), &pitch_arr);
+ Musical_pitch tonic = pitch_arr[0];
Chord_mol name;
name.tonic_mol = pitch2molecule (tonic);
maybe we should check all sub-lists of pitches, not
just full list and base triad?
*/
- if (!user_chord_name (chord_.pitch_arr_, &name))
+ if (!user_chord_name (pitch_arr, &name))
{
/*
else, check if user has listed base triad
use user base name and add banter for remaining part
*/
- if ((chord_.pitch_arr_.size () > 2)
- && user_chord_name (chord_.pitch_arr_.slice (0, 3), &name))
+ if ((pitch_arr.size () > 2)
+ && user_chord_name (pitch_arr.slice (0, 3), &name))
{
Array<Musical_pitch> base = Chord::base_arr (tonic);
- base.concat (chord_.pitch_arr_.slice (3, chord_.pitch_arr_.size ()));
+ base.concat (pitch_arr.slice (3, pitch_arr.size ()));
banter (base, &name);
}
/*
*/
else
{
- banter (chord_.pitch_arr_, &name);
+ banter (pitch_arr, &name);
}
}
- if (chord_.inversion_b_)
+ SCM s = get_elt_property ("inversion");
+ if (s != SCM_UNDEFINED)
{
name.inversion_mol = lookup_l ()->text ("", "/", paper_l ());
- // zucht const&
- Molecule mol = pitch2molecule (chord_.inversion_pitch_);
+ Musical_pitch p;
+ p = scm_to (s, &p);
+ Molecule mol = pitch2molecule (p);
name.inversion_mol.add_at_edge (X_AXIS, RIGHT, mol, 0);
}
- if (chord_.bass_b_)
+ s = get_elt_property ("bass");
+ if (s != SCM_UNDEFINED)
{
name.bass_mol = lookup_l ()->text ("", "/", paper_l ());
- Molecule mol = pitch2molecule (chord_.bass_pitch_);
+ Musical_pitch p;
+ p = scm_to (s, &p);
+ Molecule mol = pitch2molecule (p);
name.bass_mol.add_at_edge (X_AXIS, RIGHT, mol, 0);
}
if (!name.addition_mol.empty_b ())
name.addition_mol.translate (Offset (0, super_y));
- Molecule* mol_p = new Molecule;
- mol_p->add_at_edge (X_AXIS, RIGHT, name.tonic_mol, 0);
+ Molecule mol;
+ mol.add_at_edge (X_AXIS, RIGHT, name.tonic_mol, 0);
// huh?
if (!name.modifier_mol.empty_b ())
- mol_p->add_at_edge (X_AXIS, RIGHT, name.modifier_mol, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, name.modifier_mol, 0);
if (!name.addition_mol.empty_b ())
- mol_p->add_at_edge (X_AXIS, RIGHT, name.addition_mol, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, name.addition_mol, 0);
if (!name.inversion_mol.empty_b ())
- mol_p->add_at_edge (X_AXIS, RIGHT, name.inversion_mol, 0);
+ mol.add_at_edge (X_AXIS, RIGHT, name.inversion_mol, 0);
if (!name.bass_mol.empty_b ())
- mol_p->add_at_edge (X_AXIS, RIGHT, name.bass_mol, 0);
- return mol_p;
+ mol.add_at_edge (X_AXIS, RIGHT, name.bass_mol, 0);
+ return mol;
}