]> git.donarmstrong.com Git - lilypond.git/blob - lily/key-performer.cc
release: 0.0.77.jcn1
[lilypond.git] / lily / key-performer.cc
1 /*
2   key-performer.cc -- implement Key_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7 */
8
9 #include "key-performer.hh"
10 #include "command-request.hh"
11 #include "midi-item.hh"
12
13
14
15 IMPLEMENT_IS_TYPE_B1(Key_performer,Performer);
16 ADD_THIS_PERFORMER(Key_performer);
17
18 Key_performer::Key_performer()
19 {
20     key_req_l_ = 0;
21 }
22
23 Key_performer::~Key_performer()
24 {
25 }
26
27 void 
28 Key_performer::do_print() const
29 {
30 #ifndef NPRINT
31     if ( key_req_l_ )
32         key_req_l_->print();
33 #endif
34 }
35
36 void
37 Key_performer::process_requests()
38 {
39     if ( key_req_l_ ) {
40         int sharps_i = key_req_l_->sharps_i();
41         int flats_i = key_req_l_->flats_i();
42         // midi cannot handle non-conventional keys
43         if ( !( flats_i && sharps_i ) ) {
44             Midi_key k( sharps_i - flats_i, key_req_l_->minor_b() );
45             play_event( &k );
46         }
47         key_req_l_ = 0;
48     }
49 }
50
51 bool
52 Key_performer::do_try_request( Request* req_l )
53 {
54     if ( key_req_l_ )
55         return false;
56
57     if ( req_l->command() )
58         key_req_l_ = req_l->command()->keychange();
59
60     if ( key_req_l_ )
61         return true;
62
63     return false;
64 }
65