source file of the GNU LilyPond music typesetter
- (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "main.hh"
#include "ly-smobs.icc"
-SCM ly_deep_mus_copy (SCM);
bool
Music::internal_is_music_type (SCM k)const
{
- SCM ifs = get_mus_property ("types");
+ SCM ifs = get_property ("types");
return scm_memq (k, ifs) != SCM_BOOL_F;
}
String
Music::name () const
{
- SCM nm = get_mus_property ("name");
+ SCM nm = get_property ("name");
if (gh_symbol_p (nm))
{
return ly_symbol2string (nm);
}
}
-void
-Music::transpose (Pitch)
-{
-}
-void
-Music::compress (Moment)
-{
-}
Music::Music (Music const &m)
{
Moment
Music::get_length () const
{
- SCM l = get_mus_property ("length");
+ SCM l = get_property ("length");
if (unsmob_moment (l))
return *unsmob_moment (l);
else if (gh_procedure_p (l))
Moment
Music::start_mom () const
{
- SCM l = get_mus_property ("start-moment-function");
+ SCM l = get_property ("start-moment-function");
if (gh_procedure_p (l))
{
SCM res = gh_call1 (l, self_scm ());
scm_puts ("#<Music ", p);
Music* m = unsmob_music (s);
- SCM nm = m->get_mus_property ("name");
+ SCM nm = m->get_property ("name");
if (gh_symbol_p (nm) || gh_string_p (nm))
{
scm_display (nm, p);
}
Pitch
-Music::to_relative_octave (Pitch m)
+Music::to_relative_octave (Pitch p)
{
- return m;
+ SCM elt = get_property ("element");
+
+ if (Music* m = unsmob_music (elt))
+ p = m->to_relative_octave (p);
+
+ p = music_list_to_relative (get_property ("elements"),
+ p, false);
+ return p;
+}
+
+void
+Music::compress (Moment factor)
+{
+ SCM elt = get_property ("element");
+
+ if (Music* m = unsmob_music (elt))
+ m->compress (factor);
+
+ compress_music_list (get_property ("elements"), factor);
+}
+
+
+void
+Music::transpose (Pitch delta)
+{
+ SCM elt = get_property ("element");
+
+ if (Music* m = unsmob_music (elt))
+ m->transpose (delta);
+
+ transpose_music_list (get_property ("elements"), delta);
}
/****************************/
SCM
-Music::internal_get_mus_property (SCM sym) const
+Music::internal_get_property (SCM sym) const
{
SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
if (s != SCM_BOOL_F)
}
void
-Music::internal_set_mus_property (SCM s, SCM v)
+Music::internal_set_property (SCM s, SCM v)
{
if (internal_type_checking_global_b)
if (!type_check_assignment (s, v, ly_symbol2scm ("music-type?")))
mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
}
-
-
#include "main.hh"
void
Music::set_spot (Input ip)
{
- set_mus_property ("origin", make_input (ip));
+ set_property ("origin", make_input (ip));
}
Input*
Music::origin () const
{
- Input *ip = unsmob_input (get_mus_property ("origin"));
+ Input *ip = unsmob_input (get_property ("origin"));
return ip ? ip : & dummy_input_global;
}
}
-LY_DEFINE(ly_get_music_length,
- "ly:get-music-length", 1, 0, 0, (SCM mus),
+LY_DEFINE(ly_music_length,
+ "ly:music-length", 1, 0, 0, (SCM mus),
"Get the length (in musical time) of music expression @var{mus}.")
{
Music * sc = unsmob_music (mus);
return sc->get_length().smobbed_copy();
}
-LY_DEFINE(ly_get_mus_property,
- "ly:get-mus-property", 2, 0, 0, (SCM mus, SCM sym),
+LY_DEFINE(ly_music_property,
+ "ly:music-property", 2, 0, 0, (SCM mus, SCM sym),
"Get the property @var{sym} of music expression @var{mus}.\n"
- "If @var{sym} is undefined, return @code{'()}.\n"
- )
+ "If @var{sym} is undefined, return @code{'()}.\n" )
{
Music * sc = unsmob_music (mus);
SCM_ASSERT_TYPE(sc, mus, SCM_ARG1, __FUNCTION__, "music");
SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
- return sc->internal_get_mus_property (sym);
+ return sc->internal_get_property (sym);
}
-LY_DEFINE(ly_set_mus_property,
- "ly:set-mus-property!", 3, 0, 0,
+LY_DEFINE(ly_music_set_property,
+ "ly:music-set-property!", 3, 0, 0,
(SCM mus, SCM sym, SCM val),
"Set property @var{sym} in music expression @var{mus} to @var{val}.")
{
bool ok = type_check_assignment (sym, val, ly_symbol2scm ("music-type?"));
if (ok)
{
- sc->internal_set_mus_property (sym, val);
+ sc->internal_set_property (sym, val);
}
return SCM_UNSPECIFIED;
// to do property args
LY_DEFINE(ly_extended_make_music,
"ly:make-bare-music", 2, 0, 0, (SCM type, SCM props),
- "Make a music object/expression of type @var{type}, init with\n"
-"@var{props}. Warning: this interface will likely change in the near\n"
-"future.\n"
-"\n"
-"Music is the data type that music expressions are stored in. The data\n"
-"type does not yet offer many manipulations.\n"
-"\n"
-"WARNING: only for internal use. Please use make-music-by-name. \n"
-)
+ "Make a C++ music object of type @var{type}, initialize with\n"
+ "@var{props}. \n\n"
+ ""
+ "This function is for internal use, and is only called by "
+ "@code{make-music}, which is the preferred interface "
+ "for creating music objects. "
+ )
{
SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string");
// to do property args
LY_DEFINE(ly_get_mutable_properties,
"ly:get-mutable-properties", 1, 0, 0, (SCM mus),
-"Return an alist signifying the mutable properties of @var{mus}.\n"
-"The immutable properties are not available; they should be initialized\n"
-"by the functions make-music-by-name function.\n"
-)
+ "Return an alist containing the mutable properties of @var{mus}.\n"
+ "The immutable properties are not available; they should be initialized\n"
+ "by the @code{make-music} function.\n"
+ )
{
Music *m = unsmob_music (mus);
SCM_ASSERT_TYPE(m, mus, SCM_ARG1, __FUNCTION__, "music");
return m->get_property_alist (true);
}
-LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0,
+LY_DEFINE(ly_music_list_p,"ly:music-list?", 1, 0, 0,
(SCM l),"Type predicate: return true if @var{l} is a list of music objects.")
{
if (scm_list_p (l) != SCM_BOOL_T)
make_music_by_name (SCM sym)
{
if (!make_music_proc)
- make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music-by-name"));
+ make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music"));
SCM rv = scm_call_1 (make_music_proc, sym);
scm_gc_protect_object (rv);
return unsmob_music (rv);
}
+