From: Han-Wen Nienhuys Date: Wed, 31 Jan 2007 21:46:04 +0000 (+0100) Subject: Fix #258 X-Git-Tag: release/2.10.15-1~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ba0b43e18342fc1f8b627982b894cc165e007189;p=lilypond.git Fix #258 Decrease length of notes preceding grace. Conflicts: lily/midi-item.cc lily/note-performer.cc --- 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 69a0ae78d1..89df364f11 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 b69c134819..d634f46944 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -273,9 +273,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. @@ -287,9 +284,9 @@ Midi_note::to_string () const str += ::to_string ((char) (0x00)); } - str += ::to_string ((char)status_byte); + str += ::to_string ((char) status_byte); str += ::to_string ((char) (get_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 26b10292fb..0fbbc973fe 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -69,6 +69,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 (); @@ -111,9 +112,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 b21d96935d..2fef3589b7 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,64 +28,83 @@ protected: private: vector note_evs_; vector notes_; + + + vector last_notes_; + Moment last_start_; + }; void Note_performer::process_music () { - if (note_evs_.size ()) - { - int transposing = 0; + if (!note_evs_.size ()) + return; - SCM prop = get_property ("instrumentTransposition"); - if (unsmob_pitch (prop)) - transposing = unsmob_pitch (prop)->semitone_pitch (); + int transposing = 0; + SCM prop = get_property ("instrumentTransposition"); + if (unsmob_pitch (prop)) + transposing = unsmob_pitch (prop)->semitone_pitch (); - while (note_evs_.size ()) - { - Stream_event *n = note_evs_.back (); - note_evs_.pop_back (); - SCM pit = n->get_property ("pitch"); + for (vsize i = 0; i < note_evs_.size (); i ++) + { + Stream_event *n = note_evs_[i]; + SCM pit = n->get_property ("pitch"); - if (Pitch *pitp = unsmob_pitch (pit)) + if (Pitch *pitp = unsmob_pitch (pit)) + { + 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)) { - 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; + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (!ev) + continue; - if (ev->in_event_class ("tie-event")) - tie_event = ev; - } + if (ev->in_event_class ("tie-event")) + tie_event = ev; + } - Moment len = get_event_length (n); - if (now_mom().grace_part_) + Moment len = get_event_length (n); + if (now_mom ().grace_part_) + { + len.grace_part_ = len.main_part_; + len.main_part_ = Rational (0); + } + + Audio_note *p = new Audio_note (*pitp, len, + tie_event, -transposing); + Audio_element_info info (p, n); + announce_element (info); + notes_.push_back (p); + + /* + 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); - 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 (); }