From: fred Date: Wed, 27 Mar 2002 00:56:58 +0000 (+0000) Subject: lilypond-1.3.134 X-Git-Tag: release/1.5.59~888 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=64aa91766abe698ced59d429c54a4b8ac228d4c2;p=lilypond.git lilypond-1.3.134 --- diff --git a/lily/audio-item.cc b/lily/audio-item.cc index fc22538820..a35f1b42cf 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -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) diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index 04b876761f..66246a074a 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -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 diff --git a/lily/include/performer-group-performer.hh b/lily/include/performer-group-performer.hh index 8101186210..a516331ec7 100644 --- a/lily/include/performer-group-performer.hh +++ b/lily/include/performer-group-performer.hh @@ -25,9 +25,9 @@ public: virtual void announce_element (Audio_element_info); protected: Array announce_info_arr_; + void create_audio_elements (); private: - void create_audio_elements (); void acknowledge_audio_elements (); }; diff --git a/lily/key-performer.cc b/lily/key-performer.cc index b379691f75..65bcfba7b2 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -6,6 +6,7 @@ (c) 1997--2001 Jan Nieuwenhuizen */ +#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; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 64aa262a26..e4cc8262f4 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -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); } diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index 1b28a06336..c8baab0edd 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -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 diff --git a/lily/time-signature-performer.cc b/lily/time-signature-performer.cc index d1f3599d78..0bcf5a4c40 100644 --- a/lily/time-signature-performer.cc +++ b/lily/time-signature-performer.cc @@ -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)); diff --git a/ly/performer.ly b/ly/performer.ly index c3ba784bea..04456979a1 100644 --- a/ly/performer.ly +++ b/ly/performer.ly @@ -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 } diff --git a/scm/midi.scm b/scm/midi.scm index ed637bfd13..c2cdabe9e8 100644 --- a/scm/midi.scm +++ b/scm/midi.scm @@ -55,3 +55,13 @@ ;; 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))))