-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding GuidoGetPitchPos interface (in progress)
- Loading branch information
Showing
8 changed files
with
225 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
GUIDO Library | ||
Copyright (C) 2023 D. Fober | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include <iostream> | ||
|
||
#include "GRPitchYVisitor.h" | ||
|
||
#include "GuidoDefs.h" | ||
#include "GRClef.h" | ||
#include "GREmpty.h" | ||
#include "GROctava.h" | ||
#include "GREvent.h" | ||
#include "GRSingleNote.h" | ||
#include "GRSingleRest.h" | ||
#include "GRStaff.h" | ||
|
||
using namespace std; | ||
|
||
//------------------------------------------------------------------------------- | ||
NVPoint GRPitchYVisitor::getPitchPos (GRStaff* staff, int midipitch, TYPE_TIMEPOSITION date) | ||
{ | ||
fBasePitch = NOTE_G; | ||
fBaseLine = 3; | ||
fBaseOct = 1; | ||
fOctava = 0; | ||
fTargetDate = date; | ||
fLastDate = -1; | ||
fLastX = -1; | ||
fDone = false; | ||
staff->accept (*this); | ||
NVPoint p; | ||
if (fDone) { | ||
// convert midi pitch in pitch class and octava | ||
int oct = (midipitch / 12) - 4; | ||
int pitch = midipitch % 12; | ||
pitch = ((pitch < 5) ? (pitch / 2) : (pitch+1) / 2) + 2; | ||
cerr << "GRPitchYVisitor::getPitchPos " << pitch << " " << oct << " date: " << date << endl; | ||
float y = staff->getNotePosition ( pitch, oct, fBasePitch, fBaseLine, fBaseOct); | ||
p.x = fLastX; | ||
p.y = y; | ||
} | ||
cerr << " resultat : " << p << endl; | ||
return p; | ||
} | ||
|
||
//------------------------------------------------------------------------------- | ||
void GRPitchYVisitor::visitStart (GRSingleNote* o) | ||
{ | ||
if (fDone) return; | ||
cerr << "GRPitchYVisitor::visitStart GRSingleNote " << o << endl; | ||
TYPE_TIMEPOSITION date = o->getRelativeTimePosition(); | ||
if (date > fTargetDate) fDone = true; | ||
else fLastX = o->getPosition().x; | ||
} | ||
|
||
//------------------------------------------------------------------------------- | ||
void GRPitchYVisitor::visitStart (GREmpty* o) | ||
{ | ||
if (fDone) return; | ||
cerr << "GRPitchYVisitor::visitStart GREmpty " << o << endl; | ||
TYPE_TIMEPOSITION date = o->getRelativeTimePosition(); | ||
if (date > fTargetDate) fDone = true; | ||
else fLastX = o->getPosition().x; | ||
} | ||
|
||
//------------------------------------------------------------------------------- | ||
void GRPitchYVisitor::visitStart (GRSingleRest* o) | ||
{ | ||
if (fDone) return; | ||
cerr << "GRPitchYVisitor::visitStart GRSingleRest " << o << endl; | ||
TYPE_TIMEPOSITION date = o->getRelativeTimePosition(); | ||
if (date > fTargetDate) fDone = true; | ||
else fLastX = o->getPosition().x; | ||
} | ||
|
||
void GRPitchYVisitor::visitStart (GRClef* o) | ||
{ | ||
if (fDone) return; | ||
fBasePitch = o->getBasePitch(); | ||
fBaseOct = o->getBaseOct(); | ||
} | ||
|
||
void GRPitchYVisitor::visitStart (GROctava* o) | ||
{ | ||
if (fDone) return; | ||
fOctava = o->getOctava(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
GUIDO Library | ||
Copyright (C) 2023 D. Fober | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef ___GRPitchYVisitor___ | ||
#define ___GRPitchYVisitor___ | ||
|
||
#include "defines.h" | ||
#include "GUIDOEngine.h" | ||
#include "GRVisitor.h" | ||
#include "NVPoint.h" | ||
|
||
class GRPitchYVisitor : public GRVisitor | ||
{ | ||
int fBasePitch; | ||
int fBaseLine; | ||
int fBaseOct; | ||
int fOctava; | ||
float fLastX; | ||
TYPE_TIMEPOSITION fLastDate = 0; | ||
TYPE_TIMEPOSITION fTargetDate = 0; | ||
bool fDone = false; | ||
|
||
public: | ||
GRPitchYVisitor() {} | ||
virtual ~GRPitchYVisitor() {} | ||
|
||
NVPoint getPitchPos (GRStaff* staff, int pitch, TYPE_TIMEPOSITION date); | ||
|
||
virtual bool voiceMode () { return true; } | ||
|
||
virtual void visitStart (GRClef* o); | ||
virtual void visitStart (GROctava* o); | ||
virtual void visitStart (GRSingleNote* o); | ||
virtual void visitStart (GRSingleRest* o); | ||
virtual void visitStart (GREmpty* o); | ||
}; | ||
|
||
#endif |