X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmusic.cc;h=83f88fbcd91a06e66988d8c6f52b6de4264d5f2f;hb=2b3f35ab8156c3332799e53ab6fffdb023ce1df9;hp=8a169a217baa4c1031724fe03f2f08bca2eec4aa;hpb=486dff860f7b34dfe4c88a9ad6d565a02ad9bf76;p=lilypond.git diff --git a/lily/music.cc b/lily/music.cc index 8a169a217b..83f88fbcd9 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -11,12 +11,11 @@ #include "context.hh" #include "dispatcher.hh" #include "duration.hh" -#include "input-smob.hh" +#include "input.hh" #include "international.hh" #include "ly-smobs.icc" #include "main.hh" #include "music-sequence.hh" -#include "pitch.hh" #include "score.hh" #include "warn.hh" @@ -139,7 +138,7 @@ Music::generic_to_relative_octave (Pitch last) Pitch expected_pit (scm_to_int (check), new_pit.get_notename (), new_pit.get_alteration ()); - origin ()->warning (_f ("octave check failed; expected \"%s\", found: %s", + origin ()->warning (_f ("octave check failed; expected \"%s\", found: \"%s\"", expected_pit.to_string (), new_pit.to_string ())); new_pit = expected_pit; @@ -185,7 +184,7 @@ Music::compress (Moment factor) } /* -TODO: make transposition non-destructive + This mutates alist. Hence, make sure that it is not changed */ SCM transpose_mutable (SCM alist, Pitch delta) @@ -203,7 +202,7 @@ transpose_mutable (SCM alist, Pitch delta) Pitch transposed = p->transposed (delta); scm_set_cdr_x (entry, transposed.smobbed_copy ()); - if (abs (transposed.get_alteration ()) > DOUBLE_SHARP) + if (transposed.get_alteration ().abs () > Rational (1,1)) { warning (_f ("transposition by %s makes alteration larger than double", delta.to_string ())); @@ -218,7 +217,8 @@ transpose_mutable (SCM alist, Pitch delta) transpose_music_list (val, delta); else if (prop == ly_symbol2scm ("pitch-alist") && scm_is_pair (val)) - entry = scm_cons (prop, ly_transpose_key_alist (val, delta.smobbed_copy ())); + entry = scm_cons (prop, + ly_transpose_key_alist (val, delta.smobbed_copy ())); retval = scm_cons (entry, retval); } @@ -253,23 +253,9 @@ Music::origin () const Stream_event * Music::to_event () const { - /* UGH. Temp hack */ - SCM orig_sym = get_property ("name"); - char out[200]; - string in = ly_symbol2string (orig_sym); - /* don't add '-' before first character */ - out[0] = tolower (in[0]); - size_t outpos = 1; - for (size_t inpos = 1; inpos < in.size () && outpos < 190; inpos++) - { - if (isupper (in[inpos])) - out[outpos++] = '-'; - out[outpos++] = tolower (in[inpos]); - } - out[outpos] = 0; - SCM class_name = ly_symbol2scm (out); + SCM class_name = ly_camel_case_to_lisp_identifier (get_property ("name")); - // catch mistakes. + // catch programming mistakes. if (!internal_is_music_type (class_name)) { programming_error ("Not a music type"); @@ -280,24 +266,32 @@ Music::to_event () const if (length.to_bool ()) e->set_property ("length", length.smobbed_copy ()); + // articulations as events. + SCM art_mus = e->get_property ("articulations"); + if (scm_is_pair (art_mus)) + { + SCM art_ev = SCM_EOL; + for (; scm_is_pair (art_mus); art_mus = scm_cdr (art_mus)) + { + Music *m = unsmob_music (scm_car (art_mus)); + SCM ev = m ? m->to_event ()->unprotect () : scm_car (art_mus); + art_ev = scm_cons (ev, art_ev); + } + e->set_property ("articulations", scm_reverse_x (art_ev, SCM_EOL)); + } + /* ES TODO: This is a temporary fix. Stream_events should not be aware of music. */ e->set_property ("music-cause", self_scm ()); + return e; } void Music::send_to_context (Context *c) { - /* - TODO: This is a work-in-progress solution. Send the event so it - can be read both by old-style translators and the new ones. - */ - send_stream_event (c, "OldMusicEvent", origin (), - ly_symbol2scm("music"), self_scm (), 0); - Stream_event *ev = to_event (); c->event_source ()->broadcast (ev); ev->unprotect ();