X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpiano-pedal-performer.cc;h=4a24625e04b8160a8def7bccd35e796985b64c53;hb=5d84bfad4626892bcffd05adcced53c8a2329047;hp=323ee40cd372b450724c466498e0b12a8f0ef80a;hpb=2eb63c6977706ba261e4ee0674c734a34b3ee904;p=lilypond.git diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 323ee40cd3..4a24625e04 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -1,9 +1,20 @@ /* - piano-pedal-performer.cc -- implement Piano_pedal_performer + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2000--2015 Jan Nieuwenhuizen - (c) 2000--2007 Jan Nieuwenhuizen + 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 "performer.hh" @@ -15,7 +26,7 @@ #include "translator.icc" -typedef enum Pedal_type {SOSTENUTO, SUSTAIN, UNA_CORDA, NUM_PEDAL_TYPES}; +enum Pedal_type {SOSTENUTO, SUSTAIN, UNA_CORDA, NUM_PEDAL_TYPES}; /** perform Piano pedals @@ -37,15 +48,16 @@ protected: void process_music (); void stop_translation_timestep (); void start_translation_timestep (); - DECLARE_TRANSLATOR_LISTENER (sustain); - DECLARE_TRANSLATOR_LISTENER (una_corda); - DECLARE_TRANSLATOR_LISTENER (sostenuto); + void listen_sustain (Stream_event *); + void listen_una_corda (Stream_event *); + void listen_sostenuto (Stream_event *); private: - vector audios_; + vector audios_; Pedal_info info_alist_[NUM_PEDAL_TYPES]; }; -Piano_pedal_performer::Piano_pedal_performer () +Piano_pedal_performer::Piano_pedal_performer (Context *c) + : Performer (c) { } @@ -54,11 +66,11 @@ Piano_pedal_performer::pedal_type_str (int t) { switch (t) { - case SOSTENUTO: + case SOSTENUTO: return "Sostenuto"; case SUSTAIN: return "Sustain"; - case UNA_CORDA: + case UNA_CORDA: return "UnaCorda"; default: programming_error ("Unknown pedal type"); @@ -88,31 +100,31 @@ Piano_pedal_performer::process_music () { string pedal_type = pedal_type_str (i); if (p->event_drul_[STOP]) - { - if (!p->start_event_) - p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", pedal_type)); - else - { - Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = pedal_type; - a->dir_ = STOP; - audios_.push_back (a); + { + if (!p->start_event_) + p->event_drul_[STOP]->origin ()->warning (_f ("cannot find start of piano pedal: `%s'", pedal_type)); + else + { + Audio_piano_pedal *a = new Audio_piano_pedal; + a->type_string_ = pedal_type; + a->dir_ = STOP; + audios_.push_back (a); Audio_element_info info (a, p->event_drul_[STOP]); announce_element (info); - } - p->start_event_ = 0; - } + } + p->start_event_ = 0; + } if (p->event_drul_[START]) - { - p->start_event_ = p->event_drul_[START]; - Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = pedal_type; - a->dir_ = START; - audios_.push_back (a); + { + p->start_event_ = p->event_drul_[START]; + Audio_piano_pedal *a = new Audio_piano_pedal; + a->type_string_ = pedal_type; + a->dir_ = START; + audios_.push_back (a); Audio_element_info info (a, p->event_drul_[START]); announce_element (info); - } + } p->event_drul_[START] = 0; p->event_drul_[STOP] = 0; } @@ -135,7 +147,6 @@ Piano_pedal_performer::start_translation_timestep () } } -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sostenuto); void Piano_pedal_performer::listen_sostenuto (Stream_event *r) { @@ -143,7 +154,6 @@ Piano_pedal_performer::listen_sostenuto (Stream_event *r) info_alist_[SOSTENUTO].event_drul_[d] = r; } -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, sustain); void Piano_pedal_performer::listen_sustain (Stream_event *r) { @@ -151,7 +161,6 @@ Piano_pedal_performer::listen_sustain (Stream_event *r) info_alist_[SUSTAIN].event_drul_[d] = r; } -IMPLEMENT_TRANSLATOR_LISTENER (Piano_pedal_performer, una_corda); void Piano_pedal_performer::listen_una_corda (Stream_event *r) { @@ -159,16 +168,24 @@ Piano_pedal_performer::listen_una_corda (Stream_event *r) info_alist_[UNA_CORDA].event_drul_[d] = r; } +void +Piano_pedal_performer::boot () +{ + ADD_LISTENER (Piano_pedal_performer, sostenuto); + ADD_LISTENER (Piano_pedal_performer, sustain); + ADD_LISTENER (Piano_pedal_performer, una_corda); +} + ADD_TRANSLATOR (Piano_pedal_performer, - /* doc */ - "", + /* doc */ + "", - /* create */ - "", + /* create */ + "", - /* read */ - "", + /* read */ + "", - /* write */ - "" - ); + /* write */ + "" + );