X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fpiano-pedal-performer.cc;h=49ec0dd7feb042ea052de8a6b01069b59366187b;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=4048bb57a72ef522a54e0e8360e8b02fe3941ab0;hpb=b6a8afbd0a9a0b36b07c114503d81a7c420e09e7;p=lilypond.git diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 4048bb57a7..49ec0dd7fe 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--2006 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,10 +26,7 @@ #include "translator.icc" -#define SOSTENUTO 0 -#define SUSTAIN 1 -#define UNA_CORDA 2 -#define NUM_PEDAL_TYPES 3 +enum Pedal_type {SOSTENUTO, SUSTAIN, UNA_CORDA, NUM_PEDAL_TYPES}; /** perform Piano pedals @@ -44,7 +52,7 @@ protected: DECLARE_TRANSLATOR_LISTENER (una_corda); DECLARE_TRANSLATOR_LISTENER (sostenuto); private: - vector audios_; + vector audios_; Pedal_info info_alist_[NUM_PEDAL_TYPES]; }; @@ -57,11 +65,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"); @@ -89,32 +97,33 @@ Piano_pedal_performer::process_music () for (int i = 0; i < NUM_PEDAL_TYPES; i++, p++) { + string pedal_type = pedal_type_str (i); if (p->event_drul_[STOP]) - { - if (!p->start_event_) - p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", pedal_type_str (i))); - else - { - Audio_piano_pedal *a = new Audio_piano_pedal; - a->type_string_ = string (pedal_type_str (i)); - a->dir_ = STOP; - audios_.push_back (a); - Audio_element_info info(a, 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); + 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_ = string (pedal_type_str (i)); - a->dir_ = START; - audios_.push_back (a); - Audio_element_info info(a, 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); + Audio_element_info info (a, p->event_drul_[START]); announce_element (info); - } + } p->event_drul_[START] = 0; p->event_drul_[STOP] = 0; } @@ -123,8 +132,6 @@ Piano_pedal_performer::process_music () void Piano_pedal_performer::stop_translation_timestep () { - for (vsize i = 0; i < audios_.size (); i++) - play_element (audios_[i]); audios_.clear (); } @@ -163,6 +170,16 @@ Piano_pedal_performer::listen_una_corda (Stream_event *r) info_alist_[UNA_CORDA].event_drul_[d] = r; } -ADD_TRANSLATOR (Piano_pedal_performer, "", "", - "pedal-event", - "", ""); +ADD_TRANSLATOR (Piano_pedal_performer, + /* doc */ + "", + + /* create */ + "", + + /* read */ + "", + + /* write */ + "" + );