X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flaissez-vibrer-engraver.cc;h=d0eb46d13e4e209a831a5fd367307fa2cbdc8ac9;hb=ea4fdf1afa3e6bb9a7c586f5a533be93ff3312d3;hp=0c4c79367918c7e113e6e4c8febfd9e75354e515;hpb=aac9d755e493726942cc3f01ba0672afdae6fc97;p=lilypond.git diff --git a/lily/laissez-vibrer-engraver.cc b/lily/laissez-vibrer-engraver.cc index 0c4c793679..d0eb46d13e 100644 --- a/lily/laissez-vibrer-engraver.cc +++ b/lily/laissez-vibrer-engraver.cc @@ -1,10 +1,21 @@ /* - laissez-vibrer-engraver.cc -- implement Laissez_vibrer_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2011 Han-Wen Nienhuys - (c) 2005--2009 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "engraver.hh" @@ -18,7 +29,7 @@ class Laissez_vibrer_engraver : public Engraver { Stream_event *event_; Grob *lv_column_; - vector lv_ties_; + vector lv_ties_; void stop_translation_timestep (); DECLARE_ACKNOWLEDGER (note_head); @@ -52,19 +63,35 @@ Laissez_vibrer_engraver::listen_laissez_vibrer (Stream_event *ev) void Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf) { - if (!event_) + /* use the heard event_ for all note heads, or an individual event for just + * a single note head (attached as an articulation inside a chord) */ + Stream_event *tie_ev = event_; + Grob *head = inf.grob (); + Stream_event *note_ev = unsmob_stream_event (head->get_property ("cause")); + if (!tie_ev && note_ev && note_ev->in_event_class ("note-event")) + { + SCM articulations = note_ev->get_property ("articulations"); + for (SCM s = articulations; !tie_ev && scm_is_pair (s); s = scm_cdr (s)) + { + Stream_event *ev = unsmob_stream_event (scm_car (s)); + if (ev && ev->in_event_class ("laissez-vibrer-event")) + tie_ev = ev; + } + } + + if (!tie_ev) return; - SCM cause = event_->self_scm (); + SCM cause = tie_ev->self_scm (); if (!lv_column_) lv_column_ = make_item ("LaissezVibrerTieColumn", cause); Grob *lv_tie = make_item ("LaissezVibrerTie", cause); - lv_tie->set_object ("note-head", inf.grob ()->self_scm ()); + lv_tie->set_object ("note-head", head->self_scm ()); Pointer_group_interface::add_grob (lv_column_, ly_symbol2scm ("ties"), - lv_tie); + lv_tie); if (is_direction (unsmob_stream_event (cause)->get_property ("direction"))) { @@ -79,16 +106,16 @@ Laissez_vibrer_engraver::acknowledge_note_head (Grob_info inf) ADD_ACKNOWLEDGER (Laissez_vibrer_engraver, note_head); ADD_TRANSLATOR (Laissez_vibrer_engraver, - /* doc */ - "Create laissez vibrer items.", + /* doc */ + "Create laissez vibrer items.", - /* create */ - "LaissezVibrerTie " - "LaissezVibrerTieColumn ", + /* create */ + "LaissezVibrerTie " + "LaissezVibrerTieColumn ", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + );