GUIDOLib  1.7.7
Guido Engine Internal Documentation
GRTrillsLinker.h
1 /*
2  GUIDO Library
3  Copyright (C) 2017 Grame
4 
5  This Source Code Form is subject to the terms of the Mozilla Public
6  License, v. 2.0. If a copy of the MPL was not distributed with this
7  file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
10  research@grame.fr
11 
12 */
13 
14 #ifndef ___GRTrillLinker___
15 #define ___GRTrillLinker___
16 
17 #include <iostream>
18 #include <map>
19 #include "GRVisitor.h"
20 
21 class GRNote;
22 class GREvent;
23 class GRNotationElement;
24 
26 {
27  public:
28  typedef std::map<GRNote*, GRTrill*> TTrills;
29 
31  virtual ~ChordTrills() {}
32 
33  void add(GRNote* note, GRTrill* trill);
34  void check (ChordTrills& previous, GRBar* bar);
35  void check (GREvent* ev, GRBar* bar);
36  TTrills::iterator find (GRNote* note);
37  TTrills::iterator begin () { return fTrills.begin(); }
38  TTrills::iterator end () { return fTrills.end(); }
39  GRNote* firstNote() { return fFirstNote; }
40  void print(std::ostream &) const;
41 
42  private:
43  GRNotationElement* next(GREvent* note, GRBar* bar) const;
44  bool sameNote (GRNote* n1, GRNote* n2) const;
45 
46  TTrills fTrills;
47  GRNote* fFirstNote = 0;
48 };
49 std::ostream& operator << (std::ostream & os, const ChordTrills&);
50 
51 class GRTrillLinker : public GRVisitor
52 {
53  public:
55  virtual ~GRTrillLinker() { delete fPrevious; delete fCurrent; }
56 
57  virtual bool voiceMode () { return true; }
58 
59  virtual void visitStart (GRVoice* o);
60  virtual void visitEnd (GRVoice* o);
61 
62  virtual void visitStart (GRSingleNote* o);
63  virtual void visitStart (GRSingleRest* o);
64  virtual void visitStart (GREmpty* o);
65  virtual void visitStart (GRBar* o);
66  virtual void visitStart (GRTrill* o);
67 
68  private:
69  bool sameNote (GRNote* n1, GRNote* n2) const;
70  GRNotationElement* next(GRNotationElement* o) const;
71 
72  typedef std::map<GRNote*, GRTrill*> TActiveTrills;
73  TActiveTrills fCurrentTrills;
74  GRTrill* fLastTrill = 0;
75  GRBar* fLastBar = 0;
76  bool fInChord = false;
77 
78  ChordTrills* fPrevious = 0;
79  ChordTrills* fCurrent = 0;
80 };
81 
82 #endif
GRBar
Measure bar.
Definition: GRBar.h:29
ChordTrills
Definition: GRTrillsLinker.h:25
GRVisitor
Definition: GRVisitor.h:39
GRSingleNote
Graphical representation of a note event.
Definition: GRSingleNote.h:38
ChordTrills::begin
TTrills::iterator begin()
Definition: GRTrillsLinker.h:37
ChordTrills::~ChordTrills
virtual ~ChordTrills()
Definition: GRTrillsLinker.h:31
GRSingleRest
Graphical representation of a rest.
Definition: GRSingleRest.h:25
GRTrillLinker::GRTrillLinker
GRTrillLinker()
Definition: GRTrillsLinker.h:54
GRNotationElement
parent class for all notation elements.
Definition: GRNotationElement.h:54
ChordTrills::ChordTrills
ChordTrills()
Definition: GRTrillsLinker.h:30
GREvent
Graphical representation for an event (= has duration).
Definition: GREvent.h:61
ChordTrills::TTrills
std::map< GRNote *, GRTrill * > TTrills
Definition: GRTrillsLinker.h:28
GRNote
Graphical representation of a note.
Definition: GRNote.h:31
ChordTrills::print
void print(std::ostream &) const
GRTrillLinker::visitEnd
virtual void visitEnd(GRVoice *o)
GREmpty
An empty (invisible) event.
Definition: GREmpty.h:23
ChordTrills::find
TTrills::iterator find(GRNote *note)
GRTrillLinker::voiceMode
virtual bool voiceMode()
Definition: GRTrillsLinker.h:57
GRVoice
Graphical representation of a voice.
Definition: GRVoice.h:49
GRTrillLinker::visitStart
virtual void visitStart(GRVoice *o)
ChordTrills::firstNote
GRNote * firstNote()
Definition: GRTrillsLinker.h:39
operator<<
std::ostream & operator<<(std::ostream &os, const svgendl &eol)
ChordTrills::check
void check(ChordTrills &previous, GRBar *bar)
ChordTrills::end
TTrills::iterator end()
Definition: GRTrillsLinker.h:38
GRTrill
GRTrill tag.
Definition: GRTrill.h:32
ChordTrills::add
void add(GRNote *note, GRTrill *trill)
GRTrillLinker
Definition: GRTrillsLinker.h:51
GRTrillLinker::~GRTrillLinker
virtual ~GRTrillLinker()
Definition: GRTrillsLinker.h:55

Guido Project Copyright © 2019 Grame-CNCM