GUIDOLib  1.7.7
Guido Engine Internal Documentation
RProportional.h
1 /*
2  GUIDO Library
3  Copyright (C) 2015 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 __RProportional__
15 #define __RProportional__
16 
17 #include <stack>
18 
19 #include "ARMusic.h"
20 #include "PianoRoll.h"
21 #include "GUIDOEngine.h"
22 
23 /* \brief a class to create and configure a reduced proportional representation
24 */
25 class RProportional : public PianoRoll {
26 
27  int fNumStaves; // the number of staves
28  float fLineHeight; // a staff line height
29  bool fDrawDurationLine; // duration lines control
30  std::stack<VGColor> fFontColors; // the saved font colors stack
31 
32  float staffTopPos (int i) const; // gives a staff top y position
33  float staffBottomPos (int i) const; // gives a staff bottom y position
34  int pitch2staff (int midipitch) const; // gives the staff num for a given pitch
35  int pitch2staff (int midipitch, int& halfspaces, int& alter) const; // gives the staff + halspaces and alter
36  int diatonic (int midipitch, int& octave, int& alter) const; // gives the diatonic pitch of a midi pitch + octave and alter
37  float halfspaces2ypos (int halfspaces, int staff) const;
38  int halfSpaces2LedgerLines (int halfspaces) const;
39  float noteWidth () const { return fLineHeight * 1.8f; }
40 
41  void DrawHead(float x, float y, int alter, VGDevice* dev) const; // draw note head
42  void DrawLedgerLines(float x, float y, int count, VGDevice* dev) const; // draw ledger lines
43 
44  public:
45  RProportional(ARMusic *arMusic);
46  RProportional(const char *midiFileName);
47  virtual ~RProportional() {}
48 
49  virtual void onDraw(int width, int height, VGDevice *dev);
50  void SetDrawDurationLines(bool d) { fDrawDurationLine = d; }
51  bool GetDrawDurationLines() { return fDrawDurationLine; }
52 
53  protected:
54 
55  virtual void DrawGrid (DrawParams &drawParams) const;
56  virtual void DrawNote (int pitch, double date, double dur, const DrawParams& drawParams) const;
57  virtual void DrawMeasureBar(double date, const DrawParams& drawParams) const;
58  virtual void DrawStaff (int n, int width, VGDevice* dev) const;
59  virtual float pitch2ypos (int midipitch, const DrawParams& drawParams) const;
60  virtual float stepheight (int height) const { return fLineHeight / 3; }
61  virtual void setColor (VGDevice* dev, const VGColor& color);
62  virtual void popColor (VGDevice* dev);
63 };
64 
65 #endif
RProportional::setColor
virtual void setColor(VGDevice *dev, const VGColor &color)
RProportional::popColor
virtual void popColor(VGDevice *dev)
RProportional::DrawNote
virtual void DrawNote(int pitch, double date, double dur, const DrawParams &drawParams) const
RProportional::stepheight
virtual float stepheight(int height) const
Definition: RProportional.h:60
RProportional::DrawGrid
virtual void DrawGrid(DrawParams &drawParams) const
RProportional::DrawStaff
virtual void DrawStaff(int n, int width, VGDevice *dev) const
RProportional
Definition: RProportional.h:25
RProportional::~RProportional
virtual ~RProportional()
Definition: RProportional.h:47
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
VGColor
Generic class to manipulate device independant colors.
Definition: VGColor.h:34
RProportional::onDraw
virtual void onDraw(int width, int height, VGDevice *dev)
RProportional::DrawMeasureBar
virtual void DrawMeasureBar(double date, const DrawParams &drawParams) const
RProportional::RProportional
RProportional(ARMusic *arMusic)
RProportional::GetDrawDurationLines
bool GetDrawDurationLines()
Definition: RProportional.h:51
PianoRoll
Definition: PianoRoll.h:45
RProportional::pitch2ypos
virtual float pitch2ypos(int midipitch, const DrawParams &drawParams) const
RProportional::SetDrawDurationLines
void SetDrawDurationLines(bool d)
Definition: RProportional.h:50
ARMusic
Translation of a GUIDO Segment into a class.
Definition: ARMusic.h:31

Guido Project Copyright © 2019 Grame-CNCM