(c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "main.hh"
-#include "input-smob.hh"
#include "music.hh"
-#include "music-list.hh"
-#include "warn.hh"
-#include "pitch.hh"
+
+#include "duration.hh"
+#include "input-smob.hh"
#include "ly-smobs.icc"
#include "main.hh"
-
+#include "music-list.hh"
+#include "pitch.hh"
+#include "score.hh"
+#include "warn.hh"
bool
Music::internal_is_music_type (SCM k) const
Music::name () const
{
SCM nm = get_property ("name");
- if (ly_symbol_p (nm))
+ if (scm_is_symbol (nm))
{
return ly_symbol2string (nm);
}
stack vars that hold the copy might be optimized away, meaning
that they won't be protected from GC. */
smobify_self ();
- mutable_property_alist_ = ly_deep_mus_copy (m.mutable_property_alist_);
+ mutable_property_alist_ = ly_music_deep_copy (m.mutable_property_alist_);
set_spot (*m.origin ());
}
SCM lst = get_property ("length");
if (unsmob_moment (lst))
return *unsmob_moment (lst);
- else if (ly_procedure_p (lst))
+ else if (ly_c_procedure_p (lst))
{
SCM res = scm_call_1 (lst, self_scm ());
return *unsmob_moment (res);
Music::start_mom () const
{
SCM lst = get_property ("start-moment-function");
- if (ly_procedure_p (lst))
+ if (ly_c_procedure_p (lst))
{
SCM res = scm_call_1 (lst, self_scm ());
return *unsmob_moment (res);
print_alist (SCM a, SCM port)
{
/* SCM_EOL -> catch malformed lists. */
- for (SCM s = a; ly_pair_p (s); s = ly_cdr (s))
+ for (SCM s = a; scm_is_pair (s); s = scm_cdr (s))
{
- scm_display (ly_caar (s), port);
+ scm_display (scm_caar (s), port);
scm_puts (" = ", port);
- scm_write (ly_cdar (s), port);
+ scm_write (scm_cdar (s), port);
scm_puts ("\n", port);
}
}
Music* m = unsmob_music (s);
SCM nm = m->get_property ("name");
- if (ly_symbol_p (nm) || ly_string_p (nm))
+ if (scm_is_symbol (nm) || scm_is_string (nm))
scm_display (nm, p);
else
scm_puts (classname (m),p);
void
Music::transpose (Pitch delta)
{
+ for (SCM s = this->get_property_alist (true); scm_is_pair (s); s = scm_cdr (s))
+ {
+ SCM entry = scm_car (s);
+ SCM val = scm_cdr (entry);
+
+ if (Pitch * p = unsmob_pitch (val))
+ {
+ Pitch transposed = p->transposed (delta);
+ scm_set_cdr_x (entry, transposed.smobbed_copy ());
+
+ if (abs (transposed.get_alteration ()) > DOUBLE_SHARP)
+ {
+ warning (_f ("Transposition by %s makes alteration larger than two",
+ delta.to_string ()));
+ }
+ }
+ }
+
SCM elt = get_property ("element");
if (Music* m = unsmob_music (elt))
{
SCM s = scm_sloppy_assq (sym, mutable_property_alist_);
if (s != SCM_BOOL_F)
- return ly_cdr (s);
+ return scm_cdr (s);
s = scm_sloppy_assq (sym, immutable_property_alist_);
- return (s == SCM_BOOL_F) ? SCM_EOL : ly_cdr (s);
+ return (s == SCM_BOOL_F) ? SCM_EOL : scm_cdr (s);
}
void
if (!type_check_assignment (s, v, ly_symbol2scm ("music-type?")))
abort ();
- mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
+ mutable_property_alist_ = scm_assq_set_x (mutable_property_alist_, s, v);
}
void
return ip ? ip : & dummy_input_global;
}
+int
+Music::duration_log () const
+{
+ if (is_mus_type ("rhythmic-event"))
+ return unsmob_duration (get_property ("duration"))->duration_log ();
+ return 0;
+}
+
+Music*
+make_music_by_name (SCM sym)
+{
+ SCM make_music_proc = ly_lily_module_constant ("make-music");
+ SCM rv = scm_call_1 (make_music_proc, sym);
+
+ /* UGH. */
+ scm_gc_protect_object (rv);
+ return unsmob_music (rv);
+}
+
LY_DEFINE (ly_music_length, "ly:music-length",
1, 0, 0, (SCM mus),
"Get the length of music expression @var{mus}, and return as a @code{Moment} object.")
{
Music * sc = unsmob_music (mus);
SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
- SCM_ASSERT_TYPE (ly_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
return sc->internal_get_property (sym);
}
{
Music * sc = unsmob_music (mus);
SCM_ASSERT_TYPE (sc, mus, SCM_ARG1, __FUNCTION__, "music");
- SCM_ASSERT_TYPE (ly_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
bool ok = type_check_assignment (sym, val, ly_symbol2scm ("music-type?"));
if (ok)
"for creating music objects. "
)
{
- SCM_ASSERT_TYPE (ly_string_p (type), type, SCM_ARG1, __FUNCTION__, "string");
+ SCM_ASSERT_TYPE (scm_is_string (type), type, SCM_ARG1, __FUNCTION__, "string");
SCM s = make_music (ly_scm2string (type))->self_scm ();
unsmob_music (s)->immutable_property_alist_ = props;
scm_gc_unprotect_object (s);
"of music objects.")
{
if (scm_list_p (lst) == SCM_BOOL_T)
- while (ly_pair_p (lst))
+ while (scm_is_pair (lst))
{
- if (!unsmob_music (ly_car (lst)))
+ if (!unsmob_music (scm_car (lst)))
return SCM_BOOL_F;
- lst = ly_cdr (lst);
+ lst = scm_cdr (lst);
}
return SCM_BOOL_T;
}
-LY_DEFINE (ly_deep_mus_copy, "ly:music-deep-copy",
+LY_DEFINE (ly_music_deep_copy, "ly:music-deep-copy",
1, 0, 0, (SCM m),
"Copy @var{m} and all sub expressions of @var{m}")
{
copy = unsmob_music (m)->clone ()->self_scm ();
scm_gc_unprotect_object (copy);
}
- else if (ly_pair_p (m))
- copy = scm_cons (ly_deep_mus_copy (ly_car (m)),
- ly_deep_mus_copy (ly_cdr (m)));
+ else if (scm_is_pair (m))
+ copy = scm_cons (ly_music_deep_copy (scm_car (m)),
+ ly_music_deep_copy (scm_cdr (m)));
return copy;
}
return sc->self_scm ();
}
-Music*
-make_music_by_name (SCM sym)
+LY_DEFINE (ly_music_scorify, "ly:music-scorify",
+ 2, 0, 0,
+ (SCM music, SCM parser),
+ "Return MUSIC encapsulated in SCORE.")
{
- SCM make_music_proc = ly_scheme_function ("make-music");
- SCM rv = scm_call_1 (make_music_proc, sym);
+#if 0
+ SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
+#endif
+ Score *score = new Score;
- /* UGH. */
- scm_gc_protect_object (rv);
- return unsmob_music (rv);
-}
+ score->set_music (music, parser);
+ scm_gc_unprotect_object (score->self_scm ());
+ return score->self_scm ();
+}