X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fnote-performer.cc;h=331e7cc60ff7ed4b9bfe710a23dbadfcf63b41d4;hb=31568c504806f35aac420a394c9eab07abd9faa7;hp=5f8923c284e48a70f38547b1aa1d1f0942c6b0c3;hpb=9efbad2d9487a05b04423e7e9f062968e8f8eaf4;p=lilypond.git diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 5f8923c284..331e7cc60f 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -3,60 +3,97 @@ source file of the GNU LilyPond music typesetter - (c) 1996, 1997--1998 Jan Nieuwenhuizen - */ + (c) 1996--2006 Jan Nieuwenhuizen +*/ -#include "note-performer.hh" -#include "musical-request.hh" +#include "performer.hh" #include "audio-item.hh" -#include "debug.hh" +#include "audio-column.hh" +#include "global-context.hh" +#include "warn.hh" +#include "music.hh" -IMPLEMENT_IS_TYPE_B1 (Note_performer,Performer); -ADD_THIS_TRANSLATOR (Note_performer); - -Note_performer::Note_performer () +/** + Convert evs to audio notes. +*/ +class Note_performer : public Performer { - note_req_l_ = 0; -} +public: + TRANSLATOR_DECLARATIONS (Note_performer); -void -Note_performer::do_print () const -{ -#ifndef NPRINT - if (note_req_l_) - note_req_l_->print (); -#endif -} +protected: + virtual bool try_music (Music *ev); -void -Note_performer::do_process_requests () + void stop_translation_timestep (); + void process_music (); + +private: + vector note_evs_; + vector notes_; +}; + +void +Note_performer::process_music () { - // this is _really_ braindead, but it generates some output - if (!note_req_l_ || !dynamic_cast (note_req_l_) || !dynamic_cast (note_req_l_)) - return; + if (note_evs_.size ()) + { + int transposing = 0; - int transposing_i = 0; - //urg - Scalar prop = get_property ("transposing"); - if (!prop.empty_b () && prop.isnum_b ()) - transposing_i = prop; + SCM prop = get_property ("instrumentTransposition"); + if (unsmob_pitch (prop)) + transposing = unsmob_pitch (prop)->semitone_pitch (); + while (note_evs_.size ()) + { + Music *n = note_evs_.back (); + note_evs_.pop_back (); + SCM pit = n->get_property ("pitch"); - play (new Audio_note (note_req_l_, transposing_i)); + if (Pitch *pitp = unsmob_pitch (pit)) + { + Audio_note *p = new Audio_note (*pitp, n->get_length (), - transposing); + Audio_element_info info (p, n); + announce_element (info); + notes_.push_back (p); + } + } + note_evs_.clear (); + } +} - note_req_l_ = 0; +void +Note_performer::stop_translation_timestep () +{ + // why don't grace notes show up here? + // --> grace notes effectively do not get delayed + Moment now = now_mom (); + for (vsize i = 0; i < notes_.size (); i++) + play_element (notes_[i]); + notes_.clear (); + note_evs_.clear (); } -bool -Note_performer::do_try_request (Request* req_l) +bool +Note_performer::try_music (Music *ev) { - if (note_req_l_) - return false; - - if (Note_req *nr = dynamic_cast (req_l)) + if (ev->is_mus_type ("note-event")) { - note_req_l_ = nr; + note_evs_.push_back (ev); return true; } + else if (ev->is_mus_type ("busy-playing-event")) + return note_evs_.size (); + return false; } + +#include "translator.icc" + +ADD_TRANSLATOR (Note_performer, "", "", + "note-event " + "busy-playing-event", + "", ""); + +Note_performer::Note_performer () +{ +}