]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.134
authorfred <fred>
Wed, 27 Mar 2002 00:56:58 +0000 (00:56 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:56:58 +0000 (00:56 +0000)
lily/audio-item.cc
lily/include/audio-item.hh
lily/include/performer-group-performer.hh
lily/key-performer.cc
lily/midi-item.cc
lily/staff-performer.cc
lily/time-signature-performer.cc
ly/performer.ly
scm/midi.scm

index fc225388207a3f4e12b25dc2b95a5de9351fa089..a35f1b42cfed62e1d111b5675f6b88791e145577 100644 (file)
@@ -40,9 +40,10 @@ Audio_note::tie_to (Audio_note* t)
 }
 
                    
-Audio_key::Audio_key () // Key_def const& k)
+Audio_key::Audio_key (int acc, bool major)
 {
-  //fixme.
+  accidentals_=acc;
+  major_=major;
 }
 
 Audio_dynamic::Audio_dynamic (Real volume)
index 04b876761fff6664d4182368b44a1fc80a8f349b..66246a074a2e65aa4e1466ed81b914913ab941fa 100644 (file)
@@ -46,8 +46,10 @@ public:
 class Audio_key : public Audio_item
 {
 public:
-  Audio_key (); //Newkey_def const& key);
-  // FIXME
+  Audio_key (int acc, bool major);
+
+  int accidentals_;
+  bool major_;
 };
 
 class Audio_instrument : public Audio_item
index 8101186210abefc2f85f3a1f00019158c9a28460..a516331ec7cc36fdaf80cb85d2ff3e679b4abe36 100644 (file)
@@ -25,9 +25,9 @@ public:
   virtual void announce_element (Audio_element_info);
 protected:
   Array<Audio_element_info> announce_info_arr_;
+  void create_audio_elements ();
 
 private:
-  void create_audio_elements ();
   void acknowledge_audio_elements ();
 };
 
index b379691f75691bb8230d7d8c218455036f7dbe81..65bcfba7b26692f3873150d10f6d4009e97bac7c 100644 (file)
@@ -6,6 +6,7 @@
   (c)  1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
+#include "lily-guile.hh"
 #include "command-request.hh"
 #include "audio-item.hh"
 #include "performer.hh"
@@ -43,10 +44,14 @@ Key_performer::~Key_performer ()
 void
 Key_performer::create_audio_elements ()
 {
-  if (key_req_l_ &&
-      gh_list_p (key_req_l_->get_mus_property ("pitch-alist")))
+  if (key_req_l_) 
     {
-      audio_p_ = new Audio_key (); // *key_req_l_->key_);
+      SCM pitchlist = key_req_l_->get_mus_property ("pitch-alist");
+      SCM proc = scm_eval2 (ly_symbol2scm ("accidentals-in-key"), SCM_EOL); 
+      SCM acc = gh_call1 (proc, pitchlist);
+      proc = scm_eval2 (ly_symbol2scm ("major-key"), SCM_EOL);
+      SCM major = gh_call1 (proc, pitchlist);
+      audio_p_ = new Audio_key (gh_scm2int(acc), major == SCM_BOOL_T); 
       Audio_element_info info (audio_p_, key_req_l_);
       announce_element (info);
       key_req_l_ = 0;
index 64aa262a260c83559f900b3bd26f77499fe80b52..e4cc8262f49c1e6e28b4550854c0457ea3fed35d 100644 (file)
@@ -357,24 +357,12 @@ Midi_key::Midi_key (Audio_key*a)
 String
 Midi_key::str () const
 {
-  // fxime.
-  int sharps_i = 0; //audio_l_->key_.sharps_i ();
-  int flats_i = 0; //audio_l_->key_.flats_i ();
-
-  // midi cannot handle non-conventional keys
-  if (flats_i && sharps_i)
-    {
-      String str = _f ("unconventional key: flats: %d, sharps: %d", flats_i, 
-        sharps_i);
-      flats_i = sharps_i = 0;
-    }
-  int accidentals_i = sharps_i - flats_i;
-
   String str = "ff5902";
-  str += String_convert::i2hex_str (accidentals_i, 2, '0');
-
-  // (int)audio_l_->key_.minor_b ()
-  str += String_convert::i2hex_str (0, 2, '0');
+  str += String_convert::i2hex_str (audio_l_->accidentals_, 2, '0');
+  if (audio_l_->major_)
+    str += String_convert::i2hex_str (0, 2, '0');
+  else
+    str += String_convert::i2hex_str (1, 2, '0');
   return String_convert::hex2bin_str (str);
 }
 
index 1b28a06336520b708a98edfc25cb06f64d992f56..c8baab0eddb113e309df9b443872e5f734ebbc8c 100644 (file)
@@ -85,6 +85,7 @@ Staff_performer::create_audio_elements ()
       instrument_p_ = new Audio_instrument (str);
       announce_element (Audio_element_info (instrument_p_, 0));
     }
+  Performer_group_performer::create_audio_elements ();
 }
 
 void
index d1f3599d78d214f5b94daa36bc0cfa01503bb110..0bcf5a4c40b0aaaffdec3581a0363506921e0d80 100644 (file)
@@ -49,6 +49,7 @@ Time_signature_performer::create_audio_elements ()
   if (gh_pair_p (fr)
       && scm_equal_p (fr, prev_fraction_) != SCM_BOOL_T)
     {
+      prev_fraction_ = fr;
       int b = gh_scm2int (gh_car (fr));
       int o = gh_scm2int (gh_cdr (fr));
       
index c3ba784beaa22be9395adbcc81ceb0514244cc6a..04456979a1d69ead25cca3e7880771fc017c5397 100644 (file)
@@ -7,8 +7,8 @@ StaffContext = \translator {
        \accepts Voice;
 
        \consists "Key_performer";
-       \consists "Time_signature_performer";
        \consists "Tempo_performer";
+       \consists "Time_signature_performer";
        dynamicStyle = #"dynamic"
 };
 \translator { \StaffContext }
index ed637bfd134d920d93f9704e90e0c21e4e08c311..c2cdabe9e871cdd6f108191a3becb8830c0d7d73 100644 (file)
 ;; 90 == 90/127 == 0.71 is supposed to be the default value
 ;; urg: we should set this at start of track
 (define dynamic-default-volume 0.71)
+
+;; Count number of sharps minus number of flats
+(define (accidentals-in-key pitch-list)
+  (apply + (map cdr pitch-list)))
+
+;; Characterise the key as major if the alteration of the 
+;; third scale note is the same as that of the main note
+;; Note: MIDI cannot handle other tonalities than major/minor.
+(define (major-key pitch-list)
+  (eq? (cdr (list-ref pitch-list 4)) (cdr (list-ref pitch-list 6))))