]> git.donarmstrong.com Git - lilypond.git/blob - lily/note-performer.cc
patch::: 0.1.1.jcn1: zachte pats
[lilypond.git] / lily / note-performer.cc
1 /*
2   note-performer.cc -- implement Note_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997 Jan Nieuwenhuizen <jan@digicash.com>
7  */
8
9 #include "note-performer.hh"
10 #include "translator.hh"
11 #include "input-translator.hh"
12 #include "musical-request.hh"
13 #include "audio-item.hh"
14 #include "debug.hh"
15
16 IMPLEMENT_IS_TYPE_B1(Note_performer,Performer);
17
18 ADD_THIS_PERFORMER(Note_performer);
19
20 Note_performer::Note_performer()
21 {
22     note_req_l_ = 0;
23     off_mom_ = 0;
24 }
25
26 Note_performer::~Note_performer()
27 {
28 }
29
30 void 
31 Note_performer::do_print() const
32 {
33 #ifndef NPRINT
34     if ( note_req_l_ ) {
35         note_req_l_->print();
36         mtor << ( off_mom_ ? "on" : "off" ) << "\n";
37     }
38 #endif
39 }
40
41 void 
42 Note_performer::process_requests() 
43 {
44     // this is _really_ braindead, but it generates some output
45     if ( !note_req_l_ || !note_req_l_->melodic()  || !note_req_l_->rhythmic() )
46         return;
47
48     // ugh! Midi specific
49     Moment mom = get_mom();
50     if ( !off_mom_ ) { // start note
51         off_mom_ = mom + note_req_l_->duration();
52         play( new Audio_note( note_req_l_, true ) );
53     }
54     else if ( mom == off_mom_ ) { // stop note
55         play( new Audio_note( note_req_l_, false ) );
56         note_req_l_ = 0;
57         off_mom_ = 0;
58     }
59 }
60
61 bool 
62 Note_performer::do_try_request( Request* req_l )
63 {
64     if ( note_req_l_ )
65         return false;
66     
67  // huh?
68 //    if (req_l->musical() && (req_l->musical()->note() || req_l->musical()->rest()))
69 //      note_req_l_ = req_l->musical()->rhythmic();
70     if ( req_l->musical() && req_l->musical()->note() )
71 // huh?
72         note_req_l_ = req_l->musical()->melodic();
73     else
74         return false;
75
76     return true;
77 }