From: Han-Wen Nienhuys Date: Tue, 30 Jan 2007 01:03:21 +0000 (+0100) Subject: Fix #258 X-Git-Tag: release/2.11.15-1~17 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ff9bafb0ba6b03c5b07f400b12972470bb93a560;p=lilypond.git Fix #258 Decrease length of notes preceding grace. --- diff --git a/input/regression/midi-microtone-off.ly b/input/regression/midi-microtone-off.ly new file mode 100644 index 0000000000..653b97f2b3 --- /dev/null +++ b/input/regression/midi-microtone-off.ly @@ -0,0 +1,17 @@ +\header { + + texidoc = "Microtonal shifts should be corrected before the start of + the next (possibly grace) note. " +} + +\version "2.10.14" + +\score +{ + + \relative { + a geseh \acciaccatura a geseh + } + + \midi {} +} diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index c02eba58c1..81939867f3 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -11,11 +11,6 @@ #include "moment.hh" #include "pitch.hh" -/** - -Any piece of audio information. We need virtual constructors, let's -try decentralised factory for specific audio implemenations. -*/ class Audio_item : public Audio_element { public: diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 3d2d67a38e..9f9868c6a3 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -201,9 +201,6 @@ Midi_note::to_string () const // print warning if fine tuning was needed, HJJ if (get_fine_tuning () != 0) { - warning (_f ("experimental: temporarily fine tuning (of %d cents) a channel.", - get_fine_tuning ())); - finetune = PITCH_WHEEL_CENTER; // Move pitch wheel to a shifted position. // The pitch wheel range (of 4 semitones) is multiplied by the cents. @@ -217,7 +214,7 @@ Midi_note::to_string () const str += ::to_string ((char) status_byte); str += ::to_string ((char) (get_semitone_pitch () + c0_pitch_)); - str += ::to_string ((char)dynamic_byte_); + str += ::to_string ((char) dynamic_byte_); return str; } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index cef858c927..782c3e2932 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -70,6 +70,7 @@ void Midi_walker::do_start_note (Midi_note *note) { Audio_item *ptr = items_[index_]; + assert (note->audio_ == ptr); int stop_ticks = int (moment_to_real (note->audio_->length_mom_) * Real (384 * 4)) + ptr->audio_column_->ticks (); @@ -114,9 +115,6 @@ Midi_walker::do_start_note (Midi_note *note) } } -/** - Output note events for all notes which end before #max_mom# -*/ void Midi_walker::do_stop_notes (int max_ticks) { diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 12996b73c9..d6554bbdc8 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -15,9 +15,6 @@ #include "translator.icc" -/** - Convert evs to audio notes. -*/ class Note_performer : public Performer { public: @@ -31,63 +28,83 @@ protected: private: vector note_evs_; vector notes_; + + + vector last_notes_; + Moment last_start_; + }; void Note_performer::process_music () { - if (note_evs_.size ()) + if (!note_evs_.size ()) + return; + + Pitch transposing; + SCM prop = get_property ("instrumentTransposition"); + if (unsmob_pitch (prop)) + transposing = *unsmob_pitch (prop); + + for (vsize i = 0; i < note_evs_.size (); i ++) { - Pitch transposing; - SCM prop = get_property ("instrumentTransposition"); - if (unsmob_pitch (prop)) - transposing = *unsmob_pitch (prop); + Stream_event *n = note_evs_[i]; + SCM pit = n->get_property ("pitch"); - while (note_evs_.size ()) + if (Pitch *pitp = unsmob_pitch (pit)) { - Stream_event *n = note_evs_.back (); - note_evs_.pop_back (); - SCM pit = n->get_property ("pitch"); + SCM articulations = n->get_property ("articulations"); + Stream_event *tie_event = 0; + for (SCM s = articulations; + !tie_event && scm_is_pair (s); + s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) + continue; + + if (ev->in_event_class ("tie-event")) + tie_event = ev; + } - if (Pitch *pitp = unsmob_pitch (pit)) + Moment len = get_event_length (n); + if (now_mom ().grace_part_) { - SCM articulations = n->get_property ("articulations"); - Stream_event *tie_event = 0; - for (SCM s = articulations; - !tie_event && scm_is_pair (s); - s = scm_cdr (s)) - { - Stream_event *ev = unsmob_stream_event (scm_car (s)); - if (!ev) - continue; + len.grace_part_ = len.main_part_; + len.main_part_ = Rational (0); + } - if (ev->in_event_class ("tie-event")) - tie_event = ev; - } + Audio_note *p = new Audio_note (*pitp, len, + tie_event, transposing.negated ()); + Audio_element_info info (p, n); + announce_element (info); + notes_.push_back (p); - Moment len = get_event_length (n); - if (now_mom ().grace_part_) + /* + shorten previous note. + */ + if (now_mom ().grace_part_) + { + if (last_start_.grace_part_ == Rational (0)) { - len.grace_part_ = len.main_part_; - len.main_part_ = Rational (0); + for (vsize i = 0; i < last_notes_.size (); i++) + last_notes_[i]->length_mom_ += Moment (0, + now_mom().grace_part_); } - - Audio_note *p = new Audio_note (*pitp, len, - tie_event, transposing.negated ()); - Audio_element_info info (p, n); - announce_element (info); - notes_.push_back (p); } } - note_evs_.clear (); } } void Note_performer::stop_translation_timestep () { - // why don't grace notes show up here? - // --> grace notes effectively do not get delayed + if (note_evs_.size ()) + { + last_notes_ = notes_; + last_start_ = now_mom (); + } + notes_.clear (); note_evs_.clear (); }