]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/command-request.cc (transpose_key_alist): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 22 Sep 2002 23:11:18 +0000 (23:11 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 22 Sep 2002 23:11:18 +0000 (23:11 +0000)
* lily/key-performer.cc (create_audio_elements): cleanup.

12 files changed:
ChangeLog
lily/chord.cc
lily/command-request.cc
lily/completion-note-heads-engraver.cc
lily/include/chord.hh
lily/include/command-request.hh
lily/include/music.hh
lily/key-performer.cc
lily/lyric-combine-music-iterator.cc
lily/music.cc
lily/parser.yy
lily/part-combine-music-iterator.cc

index 78ae6829a62501917af53639f78acc8cdbda4c57..165e0273f7693bf6ce15c3e75e36d94a69d31355 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2002-09-23  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/command-request.cc (transpose_key_alist): new function.
+
+       * lily/key-performer.cc (create_audio_elements): cleanup. 
+
 2002-09-22  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * lily/parser.yy: remove TYPED_MAKE_MUSIC().
index 3e26dc847446870e5c5ab58d20b6eedcc7ff4ec4..196cf0e0f42450de90698c21e3f3e7d6583c1f43 100644 (file)
@@ -318,7 +318,7 @@ Chord::tonic_add_sub_to_pitches (SCM tonic, SCM add, SCM sub)
 
 
 /* --Het lijkt me dat dit in het paarse gedeelte moet. */
-Simultaneous_music *
+Music *
 Chord::get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur)
 {
   SCM pitches = tonic_add_sub_to_pitches (tonic, add, sub);
@@ -331,7 +331,7 @@ Chord::get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur)
        {
          /* Then, delete and add as base note, ie: the inversion */
          pitches = scm_delete (s, pitches);
-         Note_req* n = new Note_req;
+         Music * n = make_music_by_name (ly_symbol2scm ("NoteEvent"));
          n->set_mus_property ("pitch", ly_car (add_below_tonic (s, pitches)));
          n->set_mus_property ("duration", dur);
          n->set_mus_property ("inversion", SCM_BOOL_T);
@@ -346,7 +346,7 @@ Chord::get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur)
   /* Bass is easy, just add if requested */
   if (bass != SCM_EOL)
     {
-      Note_req* n = new Note_req;
+      Music * n = make_music_by_name (ly_symbol2scm ("NoteEvent"));
       n->set_mus_property ("pitch", ly_car (add_below_tonic (bass, pitches)));
       n->set_mus_property ("duration", dur);
       n->set_mus_property ("bass", SCM_BOOL_T);
@@ -356,14 +356,14 @@ Chord::get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur)
   
   for (SCM i = pitches; gh_pair_p (i); i = ly_cdr (i))
     {
-      Note_req* n = new Note_req;
+      Music * n = make_music_by_name(ly_symbol2scm ("NoteEvent"));
       n->set_mus_property ("pitch", ly_car (i));
       n->set_mus_property ("duration", dur);
       list = gh_cons (n->self_scm (), list);
       scm_gc_unprotect_object (n->self_scm ());
     }
 
-  Simultaneous_music*v = new Request_chord ();
+  Music * v = make_music_by_name(ly_symbol2scm ("RequestChord"));
   v->set_mus_property ("elements", list);
 
   return v;
index 9e2e0970ca140533a907021b77aad2211e5fe057..06d31d1f8a4788cfe5f71e454c3f5a48c46b395d 100644 (file)
@@ -15,12 +15,15 @@ Tempo_req::Tempo_req ()
   set_mus_property ("duration", Duration (2,0).smobbed_copy ());
 }
 
-void
-Key_change_req::transpose (Pitch p)
+
+LY_DEFINE(transpose_key_alist,"transpose-key-alist",
+         2, 0,0, (SCM l, SCM pitch),
+         "Make a new key alist of @var{l} transposed by pitch @var{pitch}")
 {
   SCM newlist = SCM_EOL;
-  SCM pa = get_mus_property ("pitch-alist");
-  for (SCM s = pa; gh_pair_p (s); s = ly_cdr (s))
+  Pitch *p = unsmob_pitch (pitch);
+  
+  for (SCM s = l; gh_pair_p (s); s = ly_cdr (s))
     {
       SCM key = ly_caar (s);
       SCM alter = ly_cdar (s);
@@ -30,7 +33,7 @@ Key_change_req::transpose (Pitch p)
                              gh_scm2int (ly_cdr (key)),
                              gh_scm2int (alter));
 
-         orig.transpose (p);
+         orig.transpose (*p);
 
          SCM key = gh_cons (scm_int2num (orig.get_octave ()),
                             scm_int2num (orig.notename_));
@@ -41,15 +44,22 @@ Key_change_req::transpose (Pitch p)
       else if (gh_number_p (key))
        {
          Pitch orig (0, gh_scm2int (key), gh_scm2int (alter));
-         orig.transpose (p);
+         orig.transpose (*p);
 
          key =scm_int2num (orig.notename_);
          alter = scm_int2num (orig.alteration_);
          newlist = gh_cons (gh_cons (key, alter), newlist);
        }
     }
+  return scm_reverse_x (newlist, SCM_EOL);
+}
+
+void
+Key_change_req::transpose (Pitch p)
+{
+  SCM pa = get_mus_property ("pitch-alist");
 
-  set_mus_property ("pitch-alist", gh_reverse (newlist));
+  set_mus_property ("pitch-alist", transpose_key_alist (pa, p.smobbed_copy()));
 }
 
 
index 2188dedb816152d8a66c552b0cc637df40f20fbc..ebae8d888c711bf46bfc5de8eea3307b57c801a3 100644 (file)
@@ -280,7 +280,7 @@ Completion_heads_engraver::stop_translation_timestep ()
   scratch_note_reqs_.clear();
 }
 
-Tie_req * tie_req = 0;
+Music * tie_req = 0;
 
 void
 Completion_heads_engraver::start_translation_timestep ()
@@ -294,7 +294,7 @@ Completion_heads_engraver::start_translation_timestep ()
   if (left_to_do_)
     {
       if (!tie_req)
-       tie_req = new Tie_req;
+       tie_req = make_music_by_name (ly_symbol2scm ("TieEvent"));
       
       bool succ = daddy_trans_->try_music (tie_req);
       if (!succ)
index f9bee640a1f7b0831a0641e32f2bd42a8a5a92ff..3386d69d2c8ba2ef18b3b08ba5592c7d62fb6f80 100644 (file)
@@ -33,7 +33,7 @@ public:
   static SCM add_above_tonic (SCM pitch, SCM pitches);
   static SCM add_below_tonic (SCM pitch, SCM pitches);
   static SCM tonic_add_sub_to_pitches (SCM tonic, SCM add, SCM sub);
-  static Simultaneous_music *get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur);
+  static Music *get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur);
 };
 
 #endif /* CHORD_HH */
index 434222fdc3530415d0f39f00a05ff3a227244f0f..db1f5500f57b44e6b52ec32824bbdfbbe56e1ae0 100644 (file)
@@ -62,5 +62,7 @@ protected:
   void transpose (Pitch  d);
 };
 
+SCM transpose_key_alist (SCM,SCM);
+
 #endif // COMMANDREQUEST_HH
 
index 84c40cc42fabb86d05e740a89e27e739a9046c77..13e79e65b3d9c19a322d7e0e25f38e941134f7da 100644 (file)
@@ -69,4 +69,7 @@ protected:
 
 DECLARE_UNSMOB(Music,music);
 
+Music* make_music_by_name (SCM sym);
+
+
 #endif // MUSIC_HH
index d52d563e6d3c6e15e5334cbe6adf68dbca52d482..66ca419f1e12dee08ba825ebda8e78a57952d09a 100644 (file)
@@ -64,10 +64,7 @@ Key_performer::create_audio_elements ()
       my_do.transpose (to_c);
       to_c.alteration_ -= my_do.alteration_;
 
-      Key_change_req *key = new Key_change_req;
-      key->set_mus_property ("pitch-alist", scm_list_copy (pitchlist));
-      ((Music*)key)->transpose (to_c);
-      SCM c_pitchlist = key->get_mus_property ("pitch-alist");
+      SCM c_pitchlist = transpose_key_alist (pitchlist, to_c.smobbed_copy());
       SCM major = gh_call1 (proc, c_pitchlist);
 
       audio_ = new Audio_key (gh_scm2int (acc), major == SCM_BOOL_T); 
index e1c72a5e9d7774fc9c58371f2503692e6bbe90d4..702ed023fb82aea4c5f0c1554135c5f2059911ac 100644 (file)
 /*
   Ugh, why static?
  */
-Busy_playing_req *busy_req;
-Melisma_req *melisma_start_req;
-Melisma_req *melisma_stop_req;
-Melisma_playing_req * melisma_playing_req;
+Music *busy_req;
+Music *melisma_start_req;
+Music *melisma_stop_req;
+Music *melisma_playing_req;
 
 Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
 {
   if (!busy_req)
     {
-      busy_req = new Busy_playing_req;
-      melisma_playing_req = new Melisma_playing_req;
-      melisma_stop_req = new Melisma_req;
-      melisma_start_req = new Melisma_req;      
-      melisma_start_req->set_span_dir (START);
-      melisma_stop_req->set_span_dir (STOP);
+      busy_req
+       = make_music_by_name (ly_symbol2scm ("BusyPlayingEvent"));
+      melisma_playing_req
+       = make_music_by_name (ly_symbol2scm ("MelismaPlayingEvent"));
+      melisma_stop_req
+       = make_music_by_name (ly_symbol2scm ("MelismaEvent"));
+      melisma_start_req
+       = make_music_by_name (ly_symbol2scm ("MelismaEvent"));
+
+      melisma_start_req->set_mus_property ("span-direction", gh_int2scm (START));
+      melisma_stop_req->set_mus_property ("span-direction", gh_int2scm (STOP));
     }
   
   music_iter_ =0;
index df0b9c11eba56643e65ffd5da447e496d9ebd8a3..d2c0105d8097d122087af85d86a57aee32bbfb9b 100644 (file)
@@ -262,27 +262,6 @@ LY_DEFINE(ly_set_mus_property,
 }
 
 
-// to do  property args 
-LY_DEFINE(ly_make_music,
-         "ly-make-music", 1, 0, 0,  (SCM type),
-         "
-Make a music object/expression of type @var{name}. Warning: this
-interface will likely change in the near future.
-
-
-
-Music is the data type that music expressions are stored in. The data
-type does not yet offer many manipulations.
-")
-{
-  SCM_ASSERT_TYPE(gh_string_p (type), type, SCM_ARG1, __FUNCTION__, "string");
-  
-  SCM s = make_music (ly_scm2string (type))->self_scm ();
-  scm_gc_unprotect_object (s);
-
-  return s;
-}
-
 LY_DEFINE(ly_music_name, "ly-music-name", 1, 0, 0, 
   (SCM mus),
   "Return the name of @var{music}.")
@@ -295,9 +274,10 @@ LY_DEFINE(ly_music_name, "ly-music-name", 1, 0, 0,
 }
 
 
+
 // to do  property args 
 LY_DEFINE(ly_extended_make_music,
-         "ly-extended-make-music", 2, 0, 0,  (SCM type, SCM props),
+         "ly-make-bare-music", 2, 0, 0,  (SCM type, SCM props),
          "
 Make a music object/expression of type @var{type}, init with
 @var{props}. Warning: this interface will likely change in the near
@@ -331,3 +311,21 @@ LY_DEFINE(ly_music_list_p,"music-list?", 1, 0, 0,
 }
 ADD_MUSIC(Music);
 
+
+SCM make_music_proc;
+
+
+Music*
+make_music_by_name (SCM sym)
+{
+  if (!make_music_proc)
+    make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music-by-name"));
+       
+  SCM rv = scm_call_1 (make_music_proc, sym);
+
+  /*
+    UGH.
+  */
+  scm_gc_protect_object (rv);
+  return unsmob_music (rv);
+}
index 4032b5ad8d2440543f1fc8de15e461fd21d584a1..1808045c879e18fed56b63915e66eeff55d84e78 100644 (file)
@@ -94,24 +94,8 @@ set_music_properties (Music *p, SCM a)
 }
 
 
-SCM make_music_proc;
 
-Music*
-parser_make_music (SCM sym)
-{
-       if (!make_music_proc)
-               make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music-by-name"));
-       
-       SCM rv = scm_call_1 (make_music_proc, sym);
-
-       /*
-       UGH.
-       */
-       scm_gc_protect_object (rv);
-       return unsmob_music (rv);
-}
-
-#define MY_MAKE_MUSIC(x)  parser_make_music (ly_symbol2scm (x))
+#define MY_MAKE_MUSIC(x)  make_music_by_name (ly_symbol2scm (x))
 
 Music* 
 set_property_music (SCM sym, SCM value)
@@ -156,7 +140,6 @@ of the parse stack onto the heap. */
     Scheme_hash_table *scmhash;
     Music_output_def * outputdef;
     SCM scm;
-    Tempo_req *tempo;
     int i;
 }
 %{
@@ -325,7 +308,7 @@ yylex (YYSTYPE *s,  void * v)
 %type <score>  score_block score_body
 
 %type <scm>    translator_spec_block translator_spec_body
-%type <tempo>  tempo_request
+%type <music>  tempo_request
 %type <scm> notenames_body notenames_block chordmodifiers_block
 %type <scm>    script_abbreviation
 
@@ -830,7 +813,7 @@ Simple_music:
 
 Composite_music:
        CONTEXT STRING Music    {
-       Music*csm =TYPED_MAKE_MUSIC("ContextSpeccedMusic");
+               Music*csm =MY_MAKE_MUSIC("ContextSpeccedMusic");
 
                csm->set_mus_property ("element", $3->self_scm ());
                scm_gc_unprotect_object ($3->self_scm ());
@@ -1994,7 +1977,7 @@ simple_element:
                $$= velt;
        }
        | chord {
-               Input i = THIS->pop_spot ();
+               THIS->pop_spot ();
 
                if (!THIS->lexer_->chord_state_b ())
                        THIS->parser_error (_ ("Have to be in Chord mode for chords"));
index 276e2f4271bfcc9e48fbfc7a23c63d45286548cc..8f38b48205a31d51ebf419cd4bbebf030742688f 100644 (file)
@@ -343,7 +343,7 @@ Part_combine_music_iterator::get_state (Moment)
   return state;
 }
 
-static Span_req* abort_req = NULL;
+static Music* abort_req = NULL;
 
 void
 Part_combine_music_iterator::process (Moment m)
@@ -394,7 +394,7 @@ s      Consider thread switching: threads "one", "two" and "both".
 
   if (!abort_req)
     {
-      abort_req = new Span_req;
+      abort_req = make_music_by_name (ly_symbol2scm ("SpanEvent"));
       abort_req->set_mus_property ("span-type", scm_makfrom0str ("abort"));
     }