update clef implementation

This commit is contained in:
ws 2013-09-05 16:37:49 +02:00
parent 3630ec25e9
commit 517627a21f
40 changed files with 476 additions and 477 deletions

View file

@ -626,7 +626,6 @@ void Chord::addLedgerLines(int move)
delta = -1;
}
for (int i = from; i < n && i >=0 ; i += delta) {
bool accid;
const Note* note = _notes.at(i);
int l = note->line();
@ -644,7 +643,7 @@ void Chord::addLedgerLines(int move)
// Experimental:
// shorten ledger line to avoid collisions with accidentals
//
accid = (note->accidental() && note->line() >= (l-1) && note->line() <= (l+1) );
// bool accid = (note->accidental() && note->line() >= (l-1) && note->line() <= (l+1) );
//
// TODO : do something with this accid flag in the following code!
//

View file

@ -29,7 +29,7 @@ namespace Ms {
#define TR(a) QT_TRANSLATE_NOOP("clefTable", a)
// table must be in sync with enum ClefType
const ClefInfo clefTable[] = {
const ClefInfo ClefInfo::clefTable[] = {
// tag xmlName line oCh pOff|-lines for sharps---||---lines for flats--| name
{ "G", "G", 2, 0, 45, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Treble clef"), STANDARD_STAFF_GROUP },
{ "G8va", "G", 2, 1, 52, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Treble clef 8va"), STANDARD_STAFF_GROUP },
@ -40,21 +40,34 @@ const ClefInfo clefTable[] = {
{ "F15mb","F", 4, -2, 19, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("Bass clef 15mb"), STANDARD_STAFF_GROUP },
{ "F3", "F", 3, 0, 35, { 4, 0, 3,-1, 2, 5, 1, 1, 5, 2, 6, 3, 7, 4 }, TR("Baritone clef (F clef)"), STANDARD_STAFF_GROUP },
{ "F5", "F", 5, 0, 31, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Subbass clef"), STANDARD_STAFF_GROUP },
{ "C1", "C", 1, 0, 43, { 5, 1, 4, 0, 3,-1, 2, 2,-1, 3, 0, 4, 1, 5 }, TR("Soprano clef"), STANDARD_STAFF_GROUP }, // CLEF_C1
{ "C2", "C", 2, 0, 41, { 3, 6, 2, 5, 1, 4, 0, 0, 4, 1, 5, 2, 6, 3 }, TR("Mezzo-soprano clef"), STANDARD_STAFF_GROUP }, // CLEF_C2
{ "C3", "C", 3, 0, 39, { 1, 4, 0, 3, 6, 2, 5, 5, 2, 6, 3, 7, 4, 8 }, TR("Alto clef"), STANDARD_STAFF_GROUP }, // CLEF_C3
{ "C4", "C", 4, 0, 37, { 6, 2, 5, 1, 4, 0, 3, 3, 0, 4, 1, 5, 2, 6 }, TR("Tenor clef"), STANDARD_STAFF_GROUP }, // CLEF_C4
{ "C1", "C", 1, 0, 43, { 5, 1, 4, 0, 3,-1, 2, 2,-1, 3, 0, 4, 1, 5 }, TR("Soprano clef"), STANDARD_STAFF_GROUP }, // C1
{ "C2", "C", 2, 0, 41, { 3, 6, 2, 5, 1, 4, 0, 0, 4, 1, 5, 2, 6, 3 }, TR("Mezzo-soprano clef"), STANDARD_STAFF_GROUP }, // C2
{ "C3", "C", 3, 0, 39, { 1, 4, 0, 3, 6, 2, 5, 5, 2, 6, 3, 7, 4, 8 }, TR("Alto clef"), STANDARD_STAFF_GROUP }, // C3
{ "C4", "C", 4, 0, 37, { 6, 2, 5, 1, 4, 0, 3, 3, 0, 4, 1, 5, 2, 6 }, TR("Tenor clef"), STANDARD_STAFF_GROUP }, // C4
{ "TAB", "TAB", 5, 0, 0, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Tablature"), TAB_STAFF_GROUP },
{ "PERC", "percussion",2, 0, 45, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Percussion"), PERCUSSION_STAFF_GROUP},
{ "C5", "C", 5, 0, 35, { 4, 0, 3,-1, 2, 5, 1, 1, 5, 2, 6, 3, 7, 4 }, TR("Baritone clef (C clef)"), STANDARD_STAFF_GROUP }, // CLEF_C5
{ "G1", "G", 1, 0, 47, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("French violin clef"), STANDARD_STAFF_GROUP }, // CLEF_G4
{ "F8va", "F", 4, 1, 40, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("Bass clef 8va"), STANDARD_STAFF_GROUP }, // CLEF_F_8VA
{ "F15ma","F", 4, 2, 47, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("Bass clef 15ma"), STANDARD_STAFF_GROUP }, // CLEF_F_15MA
{ "PERC2","percussion",2, 0, 45, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Percussion"), PERCUSSION_STAFF_GROUP}, // CLEF_PERC2 placeholder
{ "C5", "C", 5, 0, 35, { 4, 0, 3,-1, 2, 5, 1, 1, 5, 2, 6, 3, 7, 4 }, TR("Baritone clef (C clef)"), STANDARD_STAFF_GROUP }, // C5
{ "G1", "G", 1, 0, 47, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("French violin clef"), STANDARD_STAFF_GROUP }, // G4
{ "F8va", "F", 4, 1, 40, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("Bass clef 8va"), STANDARD_STAFF_GROUP }, // F_8VA
{ "F15ma","F", 4, 2, 47, { 2, 5, 1, 4, 7, 3, 6, 6, 3, 7, 4, 8, 5, 9 }, TR("Bass clef 15ma"), STANDARD_STAFF_GROUP }, // F_15MA
{ "PERC2","percussion",2, 0, 45, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Percussion"), PERCUSSION_STAFF_GROUP}, // PERC2 placeholder
{ "TAB2", "TAB", 5, 0, 0, { 0, 3,-1, 2, 5, 1, 4, 4, 1, 5, 2, 6, 3, 7 }, TR("Tablature2"), TAB_STAFF_GROUP },
};
#undef TR
//---------------------------------------------------------
// tag2type
//---------------------------------------------------------
ClefType ClefInfo::tag2type(const QString& s)
{
for (unsigned i = 0; i < sizeof(ClefInfo::clefTable)/sizeof(*ClefInfo::clefTable); ++i) {
if (clefTable[i]._tag == s)
return ClefType(i);
}
return ClefType::G;
}
//---------------------------------------------------------
// Clef
//---------------------------------------------------------
@ -66,9 +79,9 @@ Clef::Clef(Score* s)
_showCourtesy = true;
_small = false;
_clefTypes._concertClef = CLEF_INVALID;
_clefTypes._transposingClef = CLEF_INVALID;
curClefType = CLEF_G;
_clefTypes._concertClef = ClefType::INVALID;
_clefTypes._transposingClef = ClefType::INVALID;
curClefType = ClefType::G;
curLines = -1;
curLineDist = 1.0;
}
@ -144,7 +157,7 @@ void Clef::layout()
if (staffType->group() == TAB_STAFF_GROUP) {
// if current clef type not compatible with tablature,
// set tab clef according to score style
if (clefTable[clefType()].staffGroup != TAB_STAFF_GROUP)
if (ClefInfo::staffGroup(clefType()) != TAB_STAFF_GROUP)
setClefType( ClefType(score()->styleI(ST_tabClef)) );
}
// all staff types: init values from staff type
@ -179,11 +192,11 @@ void Clef::layout1()
Symbol* symbol = new Symbol(score());
switch (curClefType) {
case CLEF_G: // G clef on 2nd line
case ClefType::G: // G clef on 2nd line
symbol->setSym(trebleclefSym);
yoff = 3.0 * curLineDist;
break;
case CLEF_G1: // G clef 8va on 2nd line
case ClefType::G1: // G clef 8va on 2nd line
{
symbol->setSym(trebleclefSym);
yoff = 3.0 * curLineDist;
@ -193,7 +206,7 @@ void Clef::layout1()
addElement(number, 1.0 * msp, -5.0 * msp + yoff * _spatium);
}
break;
case CLEF_G2: // G clef 15ma on 2nd line
case ClefType::G2: // G clef 15ma on 2nd line
{
symbol->setSym(trebleclefSym);
yoff = 3.0 * curLineDist;
@ -207,7 +220,7 @@ void Clef::layout1()
addElement(number, 1.4 * msp, -5.0 * msp + yoff * _spatium);
}
break;
case CLEF_G3: // G clef 8va bassa on 2nd line
case ClefType::G3: // G clef 8va bassa on 2nd line
{
symbol->setSym(trebleclefSym);
yoff = 3.0 * curLineDist;
@ -217,11 +230,11 @@ void Clef::layout1()
addElement(number, 1.0 * msp, 4.0 * msp + yoff * _spatium);
}
break;
case CLEF_F: // F clef on penultimate line
case ClefType::F: // F clef on penultimate line
symbol->setSym(bassclefSym);
yoff = 1.0 * curLineDist;
break;
case CLEF_F8: // F clef 8va bassa on penultimate line
case ClefType::F8: // F clef 8va bassa on penultimate line
{
symbol->setSym(bassclefSym);
yoff = 1.0 * curLineDist;
@ -231,7 +244,7 @@ void Clef::layout1()
addElement(number, .5* msp, 4.5 * msp + yoff * _spatium);
}
break;
case CLEF_F15: // F clef 15ma bassa on penultimate line
case ClefType::F15: // F clef 15ma bassa on penultimate line
{
symbol->setSym(bassclefSym);
yoff = 1.0 * curLineDist;
@ -245,54 +258,54 @@ void Clef::layout1()
addElement(number, 1.1 * msp, 4.5 * msp + yoff * _spatium);
}
break;
case CLEF_F_B: // baritone clef
case ClefType::F_B: // baritone clef
symbol->setSym(bassclefSym);
yoff = 2.0 * curLineDist;
break;
case CLEF_F_C: // subbass clef
case ClefType::F_C: // subbass clef
symbol->setSym(bassclefSym);
yoff = 0.0;
break;
case CLEF_C1: // C clef in 1st line
case ClefType::C1: // C clef in 1st line
symbol->setSym(altoclefSym);
yoff = 4.0 * curLineDist;
break;
case CLEF_C2: // C clef on 2nd line
case ClefType::C2: // C clef on 2nd line
symbol->setSym(altoclefSym);
yoff = 3.0 * curLineDist;
break;
case CLEF_C3: // C clef in 3rd line
case ClefType::C3: // C clef in 3rd line
symbol->setSym(altoclefSym);
yoff = 2.0 * curLineDist;
break;
case CLEF_C4: // C clef on 4th line
case ClefType::C4: // C clef on 4th line
symbol->setSym(altoclefSym);
yoff = 1.0 * curLineDist;
break;
case CLEF_C5: // C clef on 5th line
case ClefType::C5: // C clef on 5th line
symbol->setSym(altoclefSym);
yoff = 0.0;
break;
case CLEF_TAB: // TAB clef
case ClefType::TAB: // TAB clef
symbol->setSym(tabclefSym);
// on tablature, position clef at half the number of spaces * line distance
yoff = curLineDist * (curLines - 1) * .5;
break; // TAB clef alternate style
case CLEF_TAB2:
case ClefType::TAB2:
symbol->setSym(tabclef2Sym);
// on tablature, position clef at half the number of spaces * line distance
yoff = curLineDist * (curLines - 1) * .5;
break;
case CLEF_PERC: // percussion clefs
case CLEF_PERC2:
case ClefType::PERC: // percussion clefs
case ClefType::PERC2:
symbol->setSym(percussionclefSym);
yoff = curLineDist * (curLines - 1) * 0.5;
break;
case CLEF_G4: // G clef in 1st line
case ClefType::G4: // G clef in 1st line
symbol->setSym(trebleclefSym);
yoff = 4.0 * curLineDist;
break;
case CLEF_F_8VA: // F clef 8va on penultimate line
case ClefType::F_8VA: // F clef 8va on penultimate line
{
symbol->setSym(bassclefSym);
yoff = 1.0 * curLineDist;
@ -302,7 +315,7 @@ void Clef::layout1()
addElement(number, .5 * msp, -1.5 * msp + yoff * _spatium);
}
break;
case CLEF_F_15MA: // F clef 15ma on penultimate line
case ClefType::F_15MA: // F clef 15ma on penultimate line
{
symbol->setSym(bassclefSym);
yoff = 1.0 * curLineDist;
@ -316,8 +329,8 @@ void Clef::layout1()
addElement(number, 1.1 * msp, -1.5 * msp + yoff * _spatium);
}
break;
case CLEF_INVALID:
case CLEF_MAX:
case ClefType::INVALID:
case ClefType::MAX:
return;
}
@ -388,7 +401,7 @@ void Clef::setSmall(bool val)
{
if (val != _small) {
_small = val;
curClefType = CLEF_INVALID;
curClefType = ClefType::INVALID;
}
}
@ -413,8 +426,8 @@ void Clef::read(XmlReader& e)
}
if (score()->mscVersion() < 113)
setUserOff(QPointF());
if (clefType() == CLEF_INVALID)
setClefType(CLEF_G);
if (clefType() == ClefType::INVALID)
setClefType(ClefType::G);
}
//---------------------------------------------------------
@ -424,10 +437,10 @@ void Clef::read(XmlReader& e)
void Clef::write(Xml& xml) const
{
xml.stag(name());
if(_clefTypes._concertClef != CLEF_INVALID)
xml.tag("concertClefType", clefTable[_clefTypes._concertClef].tag);
if(_clefTypes._transposingClef != CLEF_INVALID)
xml.tag("transposingClefType", clefTable[_clefTypes._transposingClef].tag);
if(_clefTypes._concertClef != ClefType::INVALID)
xml.tag("concertClefType", ClefInfo::tag(_clefTypes._concertClef));
if(_clefTypes._transposingClef != ClefType::INVALID)
xml.tag("transposingClefType", ClefInfo::tag(_clefTypes._transposingClef));
if (!_showCourtesy)
xml.tag("showCourtesyClef", _showCourtesy);
Element::writeProperties(xml);
@ -450,9 +463,9 @@ int Clef::tick() const
void Clef::setClefType(const QString& s)
{
ClefType ct = clefType(s);
if (ct == CLEF_INVALID) {
if (ct == ClefType::INVALID) {
qDebug("Clef::setSubtype: unknown: <%s>\n", qPrintable(s));
ct = CLEF_G;
ct = ClefType::G;
}
setClefType(ct);
}
@ -463,7 +476,7 @@ void Clef::setClefType(const QString& s)
ClefType Clef::clefType(const QString& s)
{
ClefType ct = CLEF_G;
ClefType ct = ClefType::G;
bool ok;
int i = s.toInt(&ok);
if (ok) {
@ -472,37 +485,31 @@ ClefType Clef::clefType(const QString& s)
//
switch (i) {
default:
case 0: ct = CLEF_G; break;
case 1: ct = CLEF_G1; break;
case 2: ct = CLEF_G2; break;
case 3: ct = CLEF_G3; break;
case 4: ct = CLEF_F; break;
case 5: ct = CLEF_F8; break;
case 6: ct = CLEF_F15; break;
case 7: ct = CLEF_F_B; break;
case 8: ct = CLEF_F_C; break;
case 9: ct = CLEF_C1; break;
case 10: ct = CLEF_C2; break;
case 11: ct = CLEF_C3; break;
case 12: ct = CLEF_C4; break;
case 13: ct = CLEF_TAB; break;
case 14: ct = CLEF_PERC; break;
case 15: ct = CLEF_C5; break;
case 16: ct = CLEF_G4; break;
case 17: ct = CLEF_F_8VA; break;
case 18: ct = CLEF_F_15MA; break;
case 19: ct = CLEF_PERC2; break;
case 20: ct = CLEF_TAB2; break;
}
}
else {
for (unsigned i = 0; i < sizeof(clefTable)/sizeof(*clefTable); ++i) {
if (clefTable[i].tag == s) {
ct = ClefType(i);
break;
}
case 0: ct = ClefType::G; break;
case 1: ct = ClefType::G1; break;
case 2: ct = ClefType::G2; break;
case 3: ct = ClefType::G3; break;
case 4: ct = ClefType::F; break;
case 5: ct = ClefType::F8; break;
case 6: ct = ClefType::F15; break;
case 7: ct = ClefType::F_B; break;
case 8: ct = ClefType::F_C; break;
case 9: ct = ClefType::C1; break;
case 10: ct = ClefType::C2; break;
case 11: ct = ClefType::C3; break;
case 12: ct = ClefType::C4; break;
case 13: ct = ClefType::TAB; break;
case 14: ct = ClefType::PERC; break;
case 15: ct = ClefType::C5; break;
case 16: ct = ClefType::G4; break;
case 17: ct = ClefType::F_8VA; break;
case 18: ct = ClefType::F_15MA; break;
case 19: ct = ClefType::PERC2; break;
case 20: ct = ClefType::TAB2; break;
}
}
else
ct = ClefInfo::tag2type(s);
return ct;
}
@ -514,13 +521,13 @@ void Clef::setClefType(ClefType i)
{
if (score()->concertPitch()) {
_clefTypes._concertClef = i;
if (_clefTypes._transposingClef == CLEF_INVALID)
if (_clefTypes._transposingClef == ClefType::INVALID)
_clefTypes._transposingClef = i;
}
else {
_clefTypes._transposingClef = i;
if (_clefTypes._concertClef == CLEF_INVALID)
if (_clefTypes._concertClef == ClefType::INVALID)
_clefTypes._concertClef = i;
}
}

View file

@ -31,6 +31,36 @@ class Segment;
static const int NO_CLEF = -1000;
//---------------------------------------------------------
// ClefType
//---------------------------------------------------------
enum class ClefType : signed char {
INVALID = -1,
G = 0,
G1,
G2,
G3,
F,
F8,
F15,
F_B,
F_C,
C1,
C2,
C3,
C4,
TAB,
PERC,
C5,
G4,
F_8VA,
F_15MA,
PERC2,
TAB2,
MAX
};
//---------------------------------------------------------
// ClefTypeList
//---------------------------------------------------------
@ -50,18 +80,30 @@ struct ClefTypeList {
/// Info about a clef.
//---------------------------------------------------------
struct ClefInfo {
const char* tag; ///< comprehensive name for instruments.xml
const char* sign; ///< Name for musicXml.
int line; ///< Line for musicXml.
int octChng; ///< Octave change for musicXml.
int pitchOffset; ///< Pitch offset for line 0.
char lines[14];
const char* name;
StaffGroup staffGroup;
};
class ClefInfo {
public:
static const ClefInfo clefTable[];
extern const ClefInfo clefTable[];
const char* _tag; ///< comprehensive name for instruments.xml
const char* _sign; ///< Name for musicXml.
int _line; ///< Line for musicXml.
int _octChng; ///< Octave change for musicXml.
int _pitchOffset; ///< Pitch offset for line 0.
char _lines[14];
const char* _name;
StaffGroup _staffGroup;
public:
static const char* tag(ClefType t) { return clefTable[int(t)]._tag; }
static const char* sign(ClefType t) { return clefTable[int(t)]._sign; }
static int line(ClefType t) { return clefTable[int(t)]._line; }
static int octChng(ClefType t) { return clefTable[int(t)]._octChng; }
static int pitchOffset(ClefType t) { return clefTable[int(t)]._pitchOffset; }
static const char* lines(ClefType t) { return clefTable[int(t)]._lines; }
static const char* name(ClefType t) { return clefTable[int(t)]._name; }
static StaffGroup staffGroup(ClefType t) { return clefTable[int(t)]._staffGroup; }
static ClefType tag2type(const QString&);
};
//---------------------------------------------------------
// @@ Clef

View file

@ -40,36 +40,38 @@ bool ClefTypeList::operator!=(const ClefTypeList& t) const
ClefTypeList ClefList::clef(int tick) const
{
if (empty())
return ClefTypeList(CLEF_G, CLEF_G);
auto i = upperBound(tick);
if (i == begin())
return ClefTypeList(CLEF_G, CLEF_G);
auto i = upper_bound(tick);
if (i != begin())
--i;
return i.value();
return i->second;
}
//---------------------------------------------------------
// setClef
//---------------------------------------------------------
void ClefList::setClef(int tick, ClefTypeList idx)
void ClefList::setClef(int tick, ClefTypeList ctl)
{
replace(tick, idx);
auto i = find(tick);
if (i == end())
insert(std::pair<int, ClefTypeList>(tick, ctl));
else
i->second = ctl;
}
//---------------------------------------------------------
// ClefList::read
// only used for 1.3 scores
//---------------------------------------------------------
void ClefList::read(XmlReader& e, Score* cs)
{
insert(0, ClefTypeList(ClefType(0), ClefType(0)));
clear();
while (e.readNextStartElement()) {
if (e.name() == "clef") {
int tick = e.intAttribute("tick", 0);
ClefType ct = Clef::clefType(e.attribute("idx", "0"));
insert(cs->fileDivision(tick), ClefTypeList(ct, ct));
insert(std::pair<int, ClefTypeList>(cs->fileDivision(tick), ClefTypeList(ct, ct)));
e.readNext();
}
else

View file

@ -24,7 +24,7 @@ class Score;
// ClefList
//---------------------------------------------------------
class ClefList : public QMultiMap<int, ClefTypeList> {
class ClefList : public std::map<int, ClefTypeList> {
public:
ClefList() {}
ClefTypeList clef(int tick) const;

View file

@ -481,7 +481,7 @@ void Score::cmdAddInterval(int val, const QList<Note*>& nl)
int line = on->line() - valTmp;
int tick = chord->tick();
Staff* estaff = staff(on->staffIdx() + chord->staffMove());
int clef = estaff->clef(tick);
ClefType clef = estaff->clef(tick);
int key = estaff->key(tick).accidentalType();
npitch = line2pitch(line, clef, key);
ntpc = pitch2tpc(npitch, key, PREFER_NEAREST);
@ -1386,8 +1386,8 @@ void Score::changeAccidental(Note* note, Accidental::AccidentalType accidental)
Measure* measure = segment->measure();
int tick = segment->tick();
Staff* estaff = staff(chord->staffIdx() + chord->staffMove());
int clef = estaff->clef(tick);
int step = clefTable[clef].pitchOffset - note->line();
ClefType clef = estaff->clef(tick);
int step = ClefInfo::pitchOffset(clef) - note->line();
while (step < 0)
step += 7;
step %= 7;
@ -2318,9 +2318,9 @@ void Score::cmd(const QAction* a)
else if (cmd == "reset-beammode")
cmdResetBeamMode();
else if (cmd == "clef-violin")
cmdInsertClef(CLEF_G);
cmdInsertClef(ClefType::G);
else if (cmd == "clef-bass")
cmdInsertClef(CLEF_F);
cmdInsertClef(ClefType::F);
else if (cmd == "voice-x12")
cmdExchangeVoice(0, 1);
else if (cmd == "voice-x13")

View file

@ -114,8 +114,8 @@ InstrumentTemplate::InstrumentTemplate()
// useTablature = false;
for (int i = 0; i < MAX_STAVES; ++i) {
clefTypes[i]._concertClef = CLEF_G;
clefTypes[i]._transposingClef = CLEF_G;
clefTypes[i]._concertClef = ClefType::G;
clefTypes[i]._transposingClef = ClefType::G;
staffLines[i] = 5;
smallStaff[i] = false;
bracket[i] = NO_BRACKET;
@ -208,15 +208,15 @@ void InstrumentTemplate::write(Xml& xml) const
xml.tag("staves", staves);
for (int i = 0; i < staves; ++i) {
if (clefTypes[i]._concertClef == clefTypes[i]._transposingClef) {
QString tag = clefTable[clefTypes[i]._concertClef].tag;
QString tag = ClefInfo::tag(clefTypes[i]._concertClef);
if (i)
xml.tag(QString("clef staff=\"%1\"").arg(i+1), tag);
else
xml.tag("clef", tag);
}
else {
QString tag1 = clefTable[clefTypes[i]._concertClef].tag;
QString tag2 = clefTable[clefTypes[i]._transposingClef].tag;
QString tag1 = ClefInfo::tag(clefTypes[i]._concertClef);
QString tag2 = ClefInfo::tag(clefTypes[i]._transposingClef);
if (i) {
xml.tag(QString("concertClef staff=\"%1\"").arg(i+1), tag1);
xml.tag(QString("transposingClef staff=\"%1\"").arg(i+1), tag2);

View file

@ -120,7 +120,7 @@ void KeySig::layout()
keySymbols.clear();
// determine current clef for this staff
int clef = 0;
ClefType clef = ClefType::G;
if (staff())
clef = staff()->clef(segment());
@ -179,11 +179,13 @@ void KeySig::layout()
// naturals should go AFTER accidentals if they should not go before!
bool suffixNaturals = naturalsOn && !prefixNaturals;
const char* lines = ClefInfo::lines(clef);
// add prefixed naturals, if any
if (prefixNaturals) {
for (int i = 0; i < 7; ++i) {
if (naturals & (1 << i)) {
addLayout(naturalSym, xo, clefTable[clef].lines[i + coffset]);
addLayout(naturalSym, xo, lines[i + coffset]);
xo += 1.0;
}
}
@ -191,22 +193,23 @@ void KeySig::layout()
// add accidentals
static const qreal sspread = 1.0;
static const qreal fspread = 1.0;
switch(t1) {
case 7: addLayout(sharpSym, xo + 6.0 * sspread, clefTable[clef].lines[6]);
case 6: addLayout(sharpSym, xo + 5.0 * sspread, clefTable[clef].lines[5]);
case 5: addLayout(sharpSym, xo + 4.0 * sspread, clefTable[clef].lines[4]);
case 4: addLayout(sharpSym, xo + 3.0 * sspread, clefTable[clef].lines[3]);
case 3: addLayout(sharpSym, xo + 2.0 * sspread, clefTable[clef].lines[2]);
case 2: addLayout(sharpSym, xo + 1.0 * sspread, clefTable[clef].lines[1]);
case 1: addLayout(sharpSym, xo, clefTable[clef].lines[0]);
case 7: addLayout(sharpSym, xo + 6.0 * sspread, lines[6]);
case 6: addLayout(sharpSym, xo + 5.0 * sspread, lines[5]);
case 5: addLayout(sharpSym, xo + 4.0 * sspread, lines[4]);
case 4: addLayout(sharpSym, xo + 3.0 * sspread, lines[3]);
case 3: addLayout(sharpSym, xo + 2.0 * sspread, lines[2]);
case 2: addLayout(sharpSym, xo + 1.0 * sspread, lines[1]);
case 1: addLayout(sharpSym, xo, lines[0]);
break;
case -7: addLayout(flatSym, xo + 6.0 * fspread, clefTable[clef].lines[13]);
case -6: addLayout(flatSym, xo + 5.0 * fspread, clefTable[clef].lines[12]);
case -5: addLayout(flatSym, xo + 4.0 * fspread, clefTable[clef].lines[11]);
case -4: addLayout(flatSym, xo + 3.0 * fspread, clefTable[clef].lines[10]);
case -3: addLayout(flatSym, xo + 2.0 * fspread, clefTable[clef].lines[9]);
case -2: addLayout(flatSym, xo + 1.0 * fspread, clefTable[clef].lines[8]);
case -1: addLayout(flatSym, xo, clefTable[clef].lines[7]);
case -7: addLayout(flatSym, xo + 6.0 * fspread, lines[13]);
case -6: addLayout(flatSym, xo + 5.0 * fspread, lines[12]);
case -5: addLayout(flatSym, xo + 4.0 * fspread, lines[11]);
case -4: addLayout(flatSym, xo + 3.0 * fspread, lines[10]);
case -3: addLayout(flatSym, xo + 2.0 * fspread, lines[9]);
case -2: addLayout(flatSym, xo + 1.0 * fspread, lines[8]);
case -1: addLayout(flatSym, xo, lines[7]);
case 0:
break;
default:
@ -219,12 +222,12 @@ void KeySig::layout()
if(t1 > 0) { // after sharps, add a little more space
xo += 0.15;
// if last sharp (t1) is above next natural (t1+1)...
if (clefTable[clef].lines[t1] < clefTable[clef].lines[t1+1])
if (lines[t1] < lines[t1+1])
xo += 0.2; // ... add more space
}
for (int i = 0; i < 7; ++i) {
if (naturals & (1 << i)) {
addLayout(naturalSym, xo, clefTable[clef].lines[i + coffset]);
addLayout(naturalSym, xo, lines[i + coffset]);
xo += 1.0;
}
}

View file

@ -246,36 +246,6 @@ enum StaffGroup {
};
const int STAFF_GROUP_MAX = TAB_STAFF_GROUP + 1; // out of enum to avoid compiler complains about not handled switch cases
//---------------------------------------------------------
// ClefType
//---------------------------------------------------------
enum ClefType {
CLEF_INVALID = -1,
CLEF_G = 0,
CLEF_G1,
CLEF_G2,
CLEF_G3,
CLEF_F,
CLEF_F8,
CLEF_F15,
CLEF_F_B,
CLEF_F_C,
CLEF_C1,
CLEF_C2,
CLEF_C3,
CLEF_C4,
CLEF_TAB,
CLEF_PERC,
CLEF_C5,
CLEF_G4,
CLEF_F_8VA,
CLEF_F_15MA,
CLEF_PERC2,
CLEF_TAB2,
CLEF_MAX
};
//---------------------------------------------------------
// Text Style Type
// Enumerate the list of build in text styles.

View file

@ -108,6 +108,7 @@ ChordRest* prevChordRest(ChordRest* cr)
return 0;
}
#if 0
//---------------------------------------------------------
// noteLessThan
//---------------------------------------------------------
@ -116,6 +117,7 @@ static bool noteLessThan(const Note* n1, const Note* n2)
{
return n1->pitch() <= n2->pitch();
}
#endif
//---------------------------------------------------------
// upAlt

View file

@ -967,7 +967,7 @@ void Note::endDrag()
_lineOffset = 0;
// get note context
int tick = chord()->tick();
int clef = staff->clef(tick);
ClefType clef = staff->clef(tick);
int key = staff->key(tick).accidentalType();
// determine new pitch of dragged note
nPitch = line2pitch(nLine, clef, key);

View file

@ -166,7 +166,7 @@ static SymId resolveSymCompatibility(SymId i, QString programVersion)
// Staff::read114
//---------------------------------------------------------
void Staff::read114(XmlReader& e, ClefList& _clefList)
void Staff::read114(XmlReader& e)
{
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());
@ -179,7 +179,7 @@ void Staff::read114(XmlReader& e, ClefList& _clefList)
else if (tag == "slashStyle")
e.skipCurrentElement();
else if (tag == "cleflist")
_clefList.read(e, _score);
clefs.read(e, _score);
else if (tag == "keylist")
_keymap.read(e, _score);
else if (tag == "bracket") {
@ -209,9 +209,7 @@ void Part::read114(XmlReader& e)
Staff* staff = new Staff(_score, this, rstaff);
_score->staves().push_back(staff);
_staves.push_back(staff);
ClefList* cl = new ClefList;
e.clefListList().append(cl);
staff->read114(e, *cl);
staff->read114(e);
++rstaff;
}
else if (tag == "Instrument") {
@ -428,10 +426,9 @@ Score::FileError Score::read114(XmlReader& e)
s->setBarLineSpan(n - idx);
}
ClefList* cl = e.clefListList().at(idx);
for (auto i = cl->constBegin(); i != cl->constEnd(); ++i) {
int tick = i.key();
ClefType clefId = i.value()._concertClef;
for (auto i = s->clefList().cbegin(); i != s->clefList().cend(); ++i) {
int tick = i->first;
ClefType clefId = i->second._concertClef;
Measure* m = tick2measure(tick);
if (!m)
continue;
@ -475,7 +472,6 @@ Score::FileError Score::read114(XmlReader& e)
}
}
}
qDeleteAll(e.clefListList());
for (std::pair<int,Spanner*> p : spanner()) {
Spanner* s = p.second;

View file

@ -658,7 +658,7 @@ MeasureBase* Score::pos2measure(const QPointF& p, int* rst, int* pitch,
*rst = i;
if (pitch) {
Staff* s = _staves[i];
int clef = s->clef(segment->tick());
ClefType clef = s->clef(segment->tick());
*pitch = y2pitch(pppp.y() - sstaff->bbox().y(), clef, s->spatium());
}
if (offset)
@ -2256,7 +2256,7 @@ void Score::splitStaff(int staffIdx, int splitPoint)
m->cmdAddStaves(staffIdx+1, staffIdx+2, false);
Clef* clef = new Clef(this);
clef->setClefType(CLEF_F);
clef->setClefType(ClefType::F);
clef->setTrack((staffIdx+1) * VOICES);
Segment* seg = firstMeasure()->getSegment(Segment::SegClef, 0);
clef->setParent(seg);

View file

@ -96,6 +96,7 @@ struct PageContext;
class BarLine;
class Bracket;
enum class OttavaType;
enum class ClefType : signed char;
extern bool showRubberBand;

View file

@ -172,7 +172,7 @@ Staff::Staff(Score* s)
_barLineTo = (lines()-1)*2;
_updateKeymap = true;
_linkedStaves = 0;
_initialClef = ClefTypeList(CLEF_G, CLEF_G);
setClef(0, ClefType::G);
}
Staff::Staff(Score* s, Part* p, int rs)
@ -190,7 +190,7 @@ Staff::Staff(Score* s, Part* p, int rs)
_barLineTo = (lines()-1)*2;
_updateKeymap = true;
_linkedStaves = 0;
_initialClef = ClefTypeList(CLEF_G, CLEF_G);
setClef(0, ClefType::G);
}
//---------------------------------------------------------
@ -212,17 +212,7 @@ Staff::~Staff()
ClefTypeList Staff::clefTypeList(int tick) const
{
ClefTypeList ctl = _initialClef;
int track = idx() * VOICES;
for (Segment* s = score()->firstSegment(); s; s = s->next1()) {
if (s->tick() > tick)
break;
if (s->segmentType() != Segment::SegClef)
continue;
if (s->element(track) && !s->element(track)->generated())
ctl = static_cast<Clef*>(s->element(track))->clefTypeList();
}
return ctl;
return clefs.clef(tick);
}
//---------------------------------------------------------
@ -231,29 +221,13 @@ ClefTypeList Staff::clefTypeList(int tick) const
ClefType Staff::clef(int tick) const
{
auto i = clefs.upper_bound(tick);
if (i != clefs.begin())
--i;
if (i == clefs.end())
return score()->concertPitch() ? _initialClef._concertClef : _initialClef._transposingClef;
else
return i->second->clefType();
ClefTypeList c = clefs.clef(tick);
return score()->concertPitch() ? c._concertClef : c._transposingClef;
}
ClefType Staff::clef(Segment* segment) const
{
ClefType ct = score()->concertPitch() ? _initialClef._concertClef : _initialClef._transposingClef;
int track = idx() * VOICES;
for (;;) {
segment = segment->prev1(Segment::SegClef);
if (segment == 0)
break;
if (segment->element(track)) {
ct = static_cast<Clef*>(segment->element(track))->clefType();
break;
}
}
return ct;
return clef(segment->tick());
}
//---------------------------------------------------------
@ -266,6 +240,51 @@ Fraction Staff::timeStretch(int tick) const
return timesig == 0 ? Fraction(1,1) : timesig->stretch();
}
//---------------------------------------------------------
// addClef
//---------------------------------------------------------
void Staff::addClef(Clef* clef)
{
int tick = clef->segment()->tick();
if (tick == 0 || !clef->generated())
clefs.setClef(tick, clef->clefTypeList());
}
//---------------------------------------------------------
// setClef
//---------------------------------------------------------
void Staff::setClef(int tick, const ClefTypeList& ctl)
{
clefs.setClef(tick, ctl);
}
void Staff::setClef(int tick, ClefType ct)
{
setClef(tick, ClefTypeList(ct, ct));
}
//---------------------------------------------------------
// removeClef
//---------------------------------------------------------
void Staff::removeClef(Clef* clef)
{
if (clef->generated())
return;
int tick = clef->segment()->tick();
if (tick == 0) {
setClef(0, ClefType::G);
return;
}
auto i = clefs.find(tick);
if (i != clefs.end())
clefs.erase(i);
else
qDebug("Staff::removeClef: Clef at %d not found", tick);
}
//---------------------------------------------------------
// timeSig
// lookup time signature before or at tick
@ -295,23 +314,6 @@ const Groups& Staff::group(int tick) const
return Groups::endings(m->timesig());
}
//---------------------------------------------------------
// addClef
//---------------------------------------------------------
void Staff::addClef(Clef* clef)
{
if (clef->generated()) {
if (clef->segment()->tick() == 0)
_initialClef = clef->clefTypeList();
return;
}
if (clef->segment()->measure() == 0)
abort();
int tick = clef->segment()->tick();
clefs.insert(std::pair<int,Clef*>(tick, clef));
}
//---------------------------------------------------------
// addTimeSig
//---------------------------------------------------------
@ -321,33 +323,13 @@ void Staff::addTimeSig(TimeSig* timesig)
timesigs[timesig->segment()->tick()] = timesig;
}
//---------------------------------------------------------
// removeClef
//---------------------------------------------------------
void Staff::removeClef(Clef* clef)
{
if (clef->generated())
return;
int tick = clef->segment()->tick();
for (auto i = clefs.lower_bound(tick); i != clefs.upper_bound(tick); ++i) {
if (i->second == clef) {
clefs.erase(i);
return;
}
}
qDebug("Staff::removeClef: Clef at %d not found", tick);
// abort();
}
//---------------------------------------------------------
// removeTimeSig
//---------------------------------------------------------
void Staff::removeTimeSig(TimeSig* timesig)
{
int tick = timesig->segment()->tick();
timesigs.erase(tick);
timesigs.erase(timesig->segment()->tick());
}
//---------------------------------------------------------
@ -710,15 +692,15 @@ void Staff::setStaffType(StaffType* st)
// if necessary
//
ClefType ct = clef(0);
StaffGroup csg = clefTable[ct].staffGroup;
StaffGroup csg = ClefInfo::staffGroup(ct);
if (_staffType->group() != csg) {
switch(_staffType->group()) {
case TAB_STAFF_GROUP: ct = ClefType(score()->styleI(ST_tabClef)); break;
case STANDARD_STAFF_GROUP: ct = CLEF_G; break; // TODO: use preferred clef for instrument
case PERCUSSION_STAFF_GROUP: ct = CLEF_PERC; break;
case STANDARD_STAFF_GROUP: ct = ClefType::G; break; // TODO: use preferred clef for instrument
case PERCUSSION_STAFF_GROUP: ct = ClefType::PERC; break;
}
setInitialClef(ct);
clefs.setClef(0, ClefTypeList(ct, ct));
}
}
@ -731,11 +713,11 @@ void Staff::init(const InstrumentTemplate* t, const StaffType* staffType, int ci
// set staff-type-independent parameters
if (cidx > MAX_STAVES) {
setSmall(false);
setInitialClef(t->clefTypes[0]);
clefs.setClef(0, t->clefTypes[0]);
}
else {
setSmall(t->smallStaff[cidx]);
setInitialClef(t->clefTypes[cidx]); // initial clef will be fixed to staff-type clef by setStaffType()
clefs.setClef(0, t->clefTypes[cidx]); // initial clef will be fixed to staff-type clef by setStaffType()
setBracket(0, t->bracket[cidx]);
setBracketSpan(0, t->bracketSpan[cidx]);
setBarLineSpan(t->barlineSpan[cidx]);
@ -818,20 +800,6 @@ bool Staff::show() const
return _part->show();
}
//---------------------------------------------------------
// setInitialClef
//---------------------------------------------------------
void Staff::setInitialClef(const ClefTypeList& cl)
{
_initialClef = cl;
}
void Staff::setInitialClef(ClefType ct)
{
_initialClef = ClefTypeList(ct, ct);
}
//---------------------------------------------------------
// genKeySig
//---------------------------------------------------------

View file

@ -91,9 +91,7 @@ class Staff : public QObject {
Part* _part;
int _rstaff; ///< Index in Part.
ClefTypeList _initialClef; // used by new score wizard
std::multimap<int, Clef*> clefs;
ClefList clefs;
std::map<int,TimeSig*> timesigs;
KeyList _keymap;
@ -129,7 +127,7 @@ class Staff : public QObject {
int idx() const;
void setRstaff(int n) { _rstaff = n; }
void read(XmlReader&);
void read114(XmlReader&, ClefList&);
void read114(XmlReader&);
void write(Xml& xml) const;
Part* part() const { return _part; }
void setPart(Part* p) { _part = p; }
@ -148,9 +146,8 @@ class Staff : public QObject {
ClefType clef(Segment*) const;
void addClef(Clef*);
void removeClef(Clef*);
void setInitialClef(const ClefTypeList& cl);
void setInitialClef(ClefType ct);
ClefTypeList initialClef() const { return _initialClef; }
void setClef(int, const ClefTypeList&);
void setClef(int, ClefType);
void addTimeSig(TimeSig*);
void removeTimeSig(TimeSig*);
@ -211,6 +208,7 @@ class Staff : public QObject {
void spatiumChanged(qreal /*oldValue*/, qreal /*newValue*/);
bool genKeySig();
bool showLedgerLines();
const ClefList& clefList() const { return clefs; }
};
} // namespace Ms

View file

@ -21,6 +21,7 @@
#include "chordlist.h"
#include "page.h"
#include "mscore.h"
#include "clef.h"
namespace Ms {
@ -568,7 +569,7 @@ StyleData::StyleData()
{ ST_ottavaLineWidth, QVariant(.1) },
{ ST_ottavaLineStyle, QVariant(int(Qt::DashLine)) },
{ ST_ottavaNumbersOnly, true },
{ ST_tabClef, QVariant(int(CLEF_TAB2)) },
{ ST_tabClef, QVariant(int(ClefType::TAB2)) },
{ ST_tremoloWidth, QVariant(1.2) }, // tremolo stroke width: note head width
{ ST_tremoloBoxHeight, QVariant(0.65) },
{ ST_tremoloStrokeWidth, QVariant(0.35) },

View file

@ -483,11 +483,8 @@ void Score::undoChangeClef(Staff* ostaff, Segment* seg, ClefType st)
foreach(Staff* staff, staffList) {
Score* score = staff->score();
if (staff->staffType()->group() != clefTable[st].staffGroup) {
qDebug("Staff::changeClef(%d): invalid staff group, src %d, dst %d",
st, clefTable[st].staffGroup, staff->staffType()->group());
if (staff->staffType()->group() != ClefInfo::staffGroup(st))
continue;
}
int tick = seg->tick();
Measure* measure = score->tick2measure(tick);
if (!measure) {

View file

@ -75,6 +75,7 @@ class Box;
class Accidental;
class Spanner;
class BarLine;
enum class ClefType : signed char;
// #define DEBUG_UNDO

View file

@ -287,7 +287,7 @@ int pitchKeyAdjust(int step, int key)
// y2pitch
//---------------------------------------------------------
int y2pitch(qreal y, int clef, qreal _spatium)
int y2pitch(qreal y, ClefType clef, qreal _spatium)
{
int l = lrint(y / _spatium * 2.0);
return line2pitch(l, clef, 0);
@ -298,9 +298,9 @@ int y2pitch(qreal y, int clef, qreal _spatium)
// key -7 ... +7
//---------------------------------------------------------
int line2pitch(int line, int clef, int key)
int line2pitch(int line, ClefType clef, int key)
{
int l = clefTable[clef].pitchOffset - line;
int l = ClefInfo::pitchOffset(clef) - line;
int octave = 0;
while (l < 0) {
l += 7;
@ -712,7 +712,7 @@ int absStep(int pitch)
int absStep(int line, ClefType clef)
{
return clefTable[clef].pitchOffset - line;
return ClefInfo::pitchOffset(clef) - line;
}
//---------------------------------------------------------
@ -724,7 +724,7 @@ int absStep(int line, ClefType clef)
int relStep(int line, ClefType clef)
{
return clefTable[clef].pitchOffset - line;
return ClefInfo::pitchOffset(clef) - line;
}
int relStep(int pitch, int tpc, ClefType clef)

View file

@ -35,13 +35,14 @@ class Segment;
class System;
class Element;
class Note;
enum class ClefType : signed char;
extern QRectF handleRect(const QPointF& pos);
extern int getStaff(System* system, const QPointF& p);
extern int pitchKeyAdjust(int note, int key);
extern int line2pitch(int line, int clef, int key);
extern int y2pitch(qreal y, int clef, qreal spatium);
extern int line2pitch(int line, ClefType clef, int key);
extern int y2pitch(qreal y, ClefType clef, qreal spatium);
extern int quantizeLen(int, int);
extern void selectNoteMessage();
extern void selectNoteRestMessage();
@ -71,6 +72,7 @@ extern Note* searchTieNote114(Note* note);
extern int absStep(int pitch);
extern int absStep(int tpc, int pitch);
extern int absStep(int line, ClefType clef);
extern int relStep(int line, ClefType clef);
extern int relStep(int pitch, int tpc, ClefType clef);

View file

@ -37,7 +37,6 @@ class XmlReader : public QXmlStreamReader {
int _track;
QList<Beam*> _beams;
QList<Tuplet*> _tuplets;
QList<ClefList*> _clefListList; // used reading 1.2 scores
public:
XmlReader(QFile*);
@ -81,7 +80,6 @@ class XmlReader : public QXmlStreamReader {
QList<Tuplet*>& tuplets() { return _tuplets; }
QList<Beam*>& beams() { return _beams; }
QList<ClefList*>& clefListList() { return _clefListList; }
};
//---------------------------------------------------------

View file

@ -460,27 +460,27 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick,
break;
}
s->add(chord);
int clef = score->staff(staffIdx)->clef(tick);
ClefType clef = score->staff(staffIdx)->clef(tick);
int key = score->staff(staffIdx)->key(tick).accidentalType();
int off;
switch (clef) {
case CLEF_G: off = 0; break;
case CLEF_G1: off = 7; break;
case CLEF_G2: off = 14; break;
case CLEF_G3: off = -7; break;
case CLEF_F: off = -14; break;
case CLEF_F8: off = -21; break;
case CLEF_F15: off = -28; break;
case CLEF_F_B: off = -14; break;
case CLEF_F_C: off = -14; break;
case CLEF_C1: off = -7; break;
case CLEF_C2: off = -7; break;
case CLEF_C3: off = -7; break;
case CLEF_C4: off = -7; break;
case CLEF_C5: off = -7; break;
case CLEF_G4: off = 0; break;
case CLEF_F_8VA: off = -7; break;
case CLEF_F_15MA: off = 0; break;
case ClefType::G: off = 0; break;
case ClefType::G1: off = 7; break;
case ClefType::G2: off = 14; break;
case ClefType::G3: off = -7; break;
case ClefType::F: off = -14; break;
case ClefType::F8: off = -21; break;
case ClefType::F15: off = -28; break;
case ClefType::F_B: off = -14; break;
case ClefType::F_C: off = -14; break;
case ClefType::C1: off = -7; break;
case ClefType::C2: off = -7; break;
case ClefType::C3: off = -7; break;
case ClefType::C4: off = -7; break;
case ClefType::C5: off = -7; break;
case ClefType::G4: off = 0; break;
case ClefType::F_8VA: off = -7; break;
case ClefType::F_15MA: off = 0; break;
default: off = 0; qDebug("clefType %d not implemented", clef);
}
// qDebug("clef %d off %d", clef, off);
@ -562,7 +562,7 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick,
CapClef* o = static_cast<CapClef*>(no);
ClefType nclef = o->clef();
qDebug("%d:%d <Clef> %s line %d oct %d clef %d", tick, staffIdx, o->name(), o->line, o->oct, o->clef());
if (nclef == CLEF_INVALID)
if (nclef == ClefType::INVALID)
break;
// staff(staffIdx)->setClef(tick, nclef);
Clef* clef = new Clef(score);
@ -1028,6 +1028,10 @@ void convertCapella(Score* score, Capella* cap, bool capxMode)
// score->connectSlurs();
score->connectTies();
score->fixTicks();
score->updateNotes();
score->setPlaylistDirty(true);
score->setLayoutAll(true);
score->addLayoutFlags(LAYOUT_FIX_TICKS | LAYOUT_FIX_PITCH_VELO);
}
//---------------------------------------------------------
@ -1996,28 +2000,28 @@ ClefType CapClef::clefType(FORM form, CLEF_LINE line, OCT oct)
{
int idx = form + (line << 3) + (oct << 5);
switch (idx) {
case FORM_G + (LINE_2 << 3) + (OCT_NULL << 5): return CLEF_G;
case FORM_G + (LINE_2 << 3) + (OCT_ALTA << 5): return CLEF_G1;
case FORM_G + (LINE_2 << 3) + (OCT_BASSA << 5): return CLEF_G3;
case FORM_G + (LINE_2 << 3) + (OCT_NULL << 5): return ClefType::G;
case FORM_G + (LINE_2 << 3) + (OCT_ALTA << 5): return ClefType::G1;
case FORM_G + (LINE_2 << 3) + (OCT_BASSA << 5): return ClefType::G3;
case FORM_C + (LINE_1 << 3) + (OCT_NULL << 5): return CLEF_C1;
case FORM_C + (LINE_2 << 3) + (OCT_NULL << 5): return CLEF_C2;
case FORM_C + (LINE_3 << 3) + (OCT_NULL << 5): return CLEF_C3;
case FORM_C + (LINE_4 << 3) + (OCT_NULL << 5): return CLEF_C4;
case FORM_C + (LINE_5 << 3) + (OCT_NULL << 5): return CLEF_C5;
case FORM_C + (LINE_1 << 3) + (OCT_NULL << 5): return ClefType::C1;
case FORM_C + (LINE_2 << 3) + (OCT_NULL << 5): return ClefType::C2;
case FORM_C + (LINE_3 << 3) + (OCT_NULL << 5): return ClefType::C3;
case FORM_C + (LINE_4 << 3) + (OCT_NULL << 5): return ClefType::C4;
case FORM_C + (LINE_5 << 3) + (OCT_NULL << 5): return ClefType::C5;
case FORM_F + (LINE_4 << 3) + (OCT_NULL << 5): return CLEF_F;
case FORM_F + (LINE_4 << 3) + (OCT_BASSA << 5): return CLEF_F8;
case FORM_F + (LINE_3 << 3) + (OCT_NULL << 5): return CLEF_F_B;
case FORM_F + (LINE_5 << 3) + (OCT_NULL << 5): return CLEF_F_C;
case FORM_F + (LINE_4 << 3) + (OCT_NULL << 5): return ClefType::F;
case FORM_F + (LINE_4 << 3) + (OCT_BASSA << 5): return ClefType::F8;
case FORM_F + (LINE_3 << 3) + (OCT_NULL << 5): return ClefType::F_B;
case FORM_F + (LINE_5 << 3) + (OCT_NULL << 5): return ClefType::F_C;
default:
if (form == FORM_NULL)
return CLEF_INVALID;
return ClefType::INVALID;
qDebug("unknown clef %d %d %d", form, line, oct);
break;
}
return CLEF_INVALID;
return ClefType::INVALID;
}
//---------------------------------------------------------

View file

@ -34,6 +34,7 @@ static const char* timeNames[] = { "1/1", "1/2", "1/4", "1/8", "1/16", "1/32", "
#endif
class Capella;
enum class ClefType : signed char;
enum CapellaNoteObjectType {
T_REST, T_CHORD, T_CLEF, T_KEY, T_METER, T_EXPL_BARLINE, T_IMPL_BARLINE,

View file

@ -2363,7 +2363,7 @@ void ClefView::setElement(Element* e)
Clef* c = static_cast<Clef*>(e);
ShowElementBase::setElement(e);
clef.clefType->setValue(c->clefType());
clef.clefType->setValue(int(c->clefType()));
clef.showCourtesy->setChecked(c->showCourtesy());
clef.small->setChecked(c->small());

View file

@ -31,6 +31,7 @@
#include "libmscore/harmony.h"
#include "libmscore/chordlist.h"
#include "libmscore/figuredbass.h"
#include "libmscore/clef.h"
namespace Ms {
@ -408,7 +409,7 @@ void EditStyle::getValues()
lstyle.set(ST_harmonyFretDist, Spatium(harmonyFretDist->value()));
lstyle.set(ST_minHarmonyDistance, Spatium(minHarmonyDistance->value()));
lstyle.set(ST_tabClef, clefTab1->isChecked() ? CLEF_TAB : CLEF_TAB2);
lstyle.set(ST_tabClef, int(clefTab1->isChecked() ? ClefType::TAB : ClefType::TAB2));
lstyle.set(ST_crossMeasureValues, crossMeasureValues->isChecked());
lstyle.set(ST_keySigNaturals, radioKeySigNatNone->isChecked() ? NAT_NONE :
@ -650,8 +651,8 @@ void EditStyle::setValues()
pedalLineWidth->setValue(lstyle.value(ST_pedalLineWidth).toDouble());
pedalLineStyle->setCurrentIndex(lstyle.value(ST_pedalLineStyle).toInt()-1);
clefTab1->setChecked(lstyle.value(ST_tabClef).toInt() == CLEF_TAB);
clefTab2->setChecked(lstyle.value(ST_tabClef).toInt() == CLEF_TAB2);
clefTab1->setChecked(lstyle.value(ST_tabClef).toInt() == int(ClefType::TAB));
clefTab2->setChecked(lstyle.value(ST_tabClef).toInt() == int(ClefType::TAB2));
crossMeasureValues->setChecked(lstyle.value(ST_crossMeasureValues).toBool());
// bool ??:

View file

@ -2322,22 +2322,22 @@ void ExportLy::writeClef(int clef)
{
out << "\\clef ";
switch(clef) {
case CLEF_G: out << "treble\n"; break;
case CLEF_F: out << "bass\n"; break;
case CLEF_G1: out << "\"treble^8\"\n"; break;
case CLEF_G2: out << "\"treble^15\"\n"; break;
case CLEF_G3: out << "\"treble_8\"\n"; break;
case CLEF_F8: out << "\"bass_8\"\n"; break;
case CLEF_F15: out << "\"bass_15\"\n"; break;
case CLEF_F_B: out << "bass\n"; break;
case CLEF_F_C: out << "bass\n"; break;
case CLEF_C1: out << "soprano\n"; break;
case CLEF_C2: out << "mezzo-soprano\n"; break;
case CLEF_C3: out << "alto\n"; break;
case CLEF_C4: out << "tenor\n"; break;
case CLEF_TAB2:
case CLEF_TAB: out << "tab\n"; break;
case CLEF_PERC: out << "percussion\n"; break;
case ClefType::G: out << "treble\n"; break;
case ClefType::F: out << "bass\n"; break;
case ClefType::G1: out << "\"treble^8\"\n"; break;
case ClefType::G2: out << "\"treble^15\"\n"; break;
case ClefType::G3: out << "\"treble_8\"\n"; break;
case ClefType::F8: out << "\"bass_8\"\n"; break;
case ClefType::F15: out << "\"bass_15\"\n"; break;
case ClefType::F_B: out << "bass\n"; break;
case ClefType::F_C: out << "bass\n"; break;
case ClefType::C1: out << "soprano\n"; break;
case ClefType::C2: out << "mezzo-soprano\n"; break;
case ClefType::C3: out << "alto\n"; break;
case ClefType::C4: out << "tenor\n"; break;
case ClefType::TAB2:
case ClefType::TAB: out << "tab\n"; break;
case ClefType::PERC: out << "percussion\n"; break;
}
}
@ -4169,37 +4169,37 @@ void ExportLy::writeScore()
relativ="";
switch(staff->clef(0))
{
case CLEF_G:
case ClefType::G:
relativ="'";
staffpitch=12*5;
break;
case CLEF_TAB:
case CLEF_PERC:
case CLEF_PERC2:
case CLEF_G3:
case CLEF_F:
case ClefType::TAB:
case ClefType::PERC:
case ClefType::PERC2:
case ClefType::G3:
case ClefType::F:
relativ="";
staffpitch=12*4;
break;
case CLEF_G1:
case CLEF_G2:
case ClefType::G1:
case ClefType::G2:
relativ="''";
staffpitch=12*6;
break;
case CLEF_F_B:
case CLEF_F_C:
case CLEF_F8:
case ClefType::F_B:
case ClefType::F_C:
case ClefType::F8:
relativ=",";
staffpitch=12*3;
break;
case CLEF_F15:
case ClefType::F15:
relativ=",,";
staffpitch=12*2;
break;
case CLEF_C1:
case CLEF_C2:
case CLEF_C3:
case CLEF_C4:
case ClefType::C1:
case ClefType::C2:
case ClefType::C3:
case ClefType::C4:
relativ="'";
staffpitch=12*5;
break;

View file

@ -268,7 +268,7 @@ class ExportMusicXml {
int findBracket(const TextLine* tl) const;
void chord(Chord* chord, int staff, const QList<Lyrics*>* ll, bool useDrumset);
void rest(Rest* chord, int staff);
void clef(int staff, int clef);
void clef(int staff, ClefType clef);
void timesig(TimeSig* tsig);
void keysig(int key, int staff = 0, bool visible = true);
void barlineLeft(Measure* m);
@ -1110,7 +1110,7 @@ void ExportMusicXml::pitch2xml(Note* note, char& c, int& alter, int& octave)
Staff* i = note->score()->staff(staffIdx);
ClefType clef = i->clef(tick);
int offset = clefTable[clef].pitchOffset - 45; // HACK
int offset = ClefInfo::pitchOffset(clef) - 45; // HACK
int step = (note->line() - offset + 700) % 7;
// step = 6 - ((absoluteStaffLine(note->line(), clef) + 3)%7));
@ -1132,7 +1132,7 @@ void ExportMusicXml::pitch2xml(Note* note, char& c, int& alter, int& octave)
// note->pitch() and note->line()
// note->line() is determined by drumMap
//
if (clef == CLEF_PERC || clef == CLEF_PERC2) {
if (clef == ClefType::PERC || clef == ClefType::PERC2) {
alter = 0;
pitch = line2pitch(note->line(), clef, 0);
octave = (pitch / 12) - 1;
@ -1184,7 +1184,7 @@ void ExportMusicXml::unpitch2xml(Note* note, char& step, int& octave)
Staff* st = note->staff();
ClefType ct = st->clef(tick);
// offset in lines between staff with current clef and with G clef
int clefOffset = clefTable[ct].pitchOffset - clefTable[CLEF_G].pitchOffset;
int clefOffset = ClefInfo::pitchOffset(ct) - ClefInfo::pitchOffset(ClefType::G);
// line note would be on on a five line staff with G clef
// note top line is line 0, bottom line is line 8
int line5g = note->line() - clefOffset;
@ -1427,7 +1427,7 @@ void ExportMusicXml::keysig(int key, int staff, bool visible)
// clef
//---------------------------------------------------------
void ExportMusicXml::clef(int staff, int clef)
void ExportMusicXml::clef(int staff, ClefType clef)
{
#ifdef DEBUG_CLEF
qDebug("ExportMusicXml::clef(staff %d, clef %d)", staff, clef);
@ -1437,12 +1437,12 @@ void ExportMusicXml::clef(int staff, int clef)
xml.stag(QString("clef number=\"%1\"").arg(staff));
else
xml.stag("clef");
QString sign = clefTable[clef].sign;
int line = clefTable[clef].line;
QString sign = ClefInfo::sign(clef);
int line = ClefInfo::line(clef);
xml.tag("sign", sign);
xml.tag("line", line);
if (clefTable[clef].octChng)
xml.tag("clef-octave-change", clefTable[clef].octChng);
if (ClefInfo::octChng(clef))
xml.tag("clef-octave-change", ClefInfo::octChng(clef));
xml.etag();
}
@ -2424,12 +2424,12 @@ void ExportMusicXml::rest(Rest* rest, int staff)
int oct = 0;
int stp = 0;
ClefType clef = rest->staff()->clef(rest->tick());
int po = clefTable[clef].pitchOffset;
int po = ClefInfo::pitchOffset(clef);
// Determine y position, but leave at zero in case of tablature staff
// as no display-step or display-octave should be written for a tablature staff,
if (clef != CLEF_TAB && clef != CLEF_TAB2) {
if (clef != ClefType::TAB && clef != ClefType::TAB2) {
double yOffsSp = rest->userOff().y() / rest->spatium(); // y offset in spatium (negative = up)
yOffsSt = -2 * int(yOffsSp > 0.0 ? yOffsSp + 0.5 : yOffsSp - 0.5); // same rounded to int (positive = up)
@ -3518,7 +3518,7 @@ void ExportMusicXml::work(const MeasureBase* /*measure*/)
xml.tag("movement-title", _score->metaTag("movementTitle"));
}
#if 0
//---------------------------------------------------------
// elementRighter // used for harmony order
//---------------------------------------------------------
@ -3527,6 +3527,7 @@ static bool elementRighter(const Element* e1, const Element* e2)
{
return e1->x() < e2->x();
}
#endif
//---------------------------------------------------------
// measureStyle -- write measure-style
@ -4200,10 +4201,10 @@ void ExportMusicXml::write(QIODevice* dev)
el = seg->element(st);
if (el && el->type() == Element::CLEF) {
Clef* cle = static_cast<Clef*>(el);
int ct = cle->clefType();
ClefType ct = cle->clefType();
int ti = cle->segment()->tick();
#ifdef DEBUG_CLEF
qDebug("exportxml: clef at start measure ti=%d ct=%d gen=%d", ti, ct, el->generated());
qDebug("exportxml: clef at start measure ti=%d ct=%d gen=%d", ti, int(ct), el->generated());
#endif
// output only clef changes, not generated clefs at line beginning
// exception: at tick=0, export clef anyway
@ -4327,7 +4328,7 @@ void ExportMusicXml::write(QIODevice* dev)
// at line beginning
// also ignore clefs at the start of a measure,
// these have already been output
int ct = ((Clef*)el)->clefType();
ClefType ct = ((Clef*)el)->clefType();
#ifdef DEBUG_CLEF
int ti = seg->tick();
qDebug("exportxml: clef in measure ti=%d ct=%d gen=%d", ti, ct, el->generated());

View file

@ -268,7 +268,7 @@ void MsScWriter::beginMeasure(const Bww::MeasureBeginFlags mbf)
if (measureNumber == 1) {
// clef
Ms::Clef* clef = new Ms::Clef(score);
clef->setClefType(Ms::CLEF_G);
clef->setClefType(Ms::ClefType::G);
clef->setTrack(0);
Ms::Segment* s = currentMeasure->getSegment(clef, tick);
s->add(clef);

View file

@ -1,21 +1,13 @@
//=============================================================================
// MusE Score
// Linux Music Score Editor
// $Id:$
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "importgtp.h"
@ -790,16 +782,16 @@ qDebug("BeginRepeat=============================================\n");
//
Staff* staff = score->staff(i);
int patch = channelDefaults[midiChannel].patch;
ClefType clefId = CLEF_G;
ClefType clefId = ClefType::G;
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = CLEF_PERC;
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = CLEF_G3;
clefId = ClefType::G3;
else if (patch >= 32 && patch < 40)
clefId = CLEF_F8;
clefId = ClefType::F8;
Measure* measure = score->firstMeasure();
Clef* clef = new Clef(score);
clef->setClefType(clefId);
@ -1270,16 +1262,16 @@ qDebug("BeginRepeat=============================================\n");
//
Staff* staff = score->staff(i);
int patch = channelDefaults[midiChannel].patch;
ClefType clefId = CLEF_G;
ClefType clefId = ClefType::G;
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = CLEF_PERC;
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = CLEF_G3;
clefId = ClefType::G3;
else if (patch >= 32 && patch < 40)
clefId = CLEF_F8;
clefId = ClefType::F8;
Measure* measure = score->firstMeasure();
Clef* clef = new Clef(score);
clef->setClefType(clefId);
@ -1788,16 +1780,16 @@ void GuitarPro4::read(QFile* fp)
//
Staff* staff = score->staff(i);
int patch = channelDefaults[midiChannel].patch;
ClefType clefId = CLEF_G;
ClefType clefId = ClefType::G;
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = CLEF_PERC;
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = CLEF_G3;
clefId = ClefType::G3;
else if (patch >= 32 && patch < 40)
clefId = CLEF_F8;
clefId = ClefType::F8;
Measure* measure = score->firstMeasure();
Clef* clef = new Clef(score);
clef->setClefType(clefId);
@ -2478,16 +2470,16 @@ void GuitarPro5::readTracks()
// determine clef
//
int patch = channelDefaults[midiChannel].patch;
ClefType clefId = CLEF_G;
ClefType clefId = ClefType::G;
if (midiChannel == GP_DEFAULT_PERCUSSION_CHANNEL) {
clefId = CLEF_PERC;
clefId = ClefType::PERC;
instr->setUseDrumset(true);
staff->setStaffType(score->staffType(PERC_DEFAULT_STAFF_TYPE));
}
else if (patch >= 24 && patch < 32)
clefId = CLEF_G3;
clefId = ClefType::G3;
else if (patch >= 32 && patch < 40)
clefId = CLEF_F8;
clefId = ClefType::F8;
Measure* measure = score->firstMeasure();
Clef* clef = new Clef(score);
clef->setClefType(clefId);

View file

@ -619,14 +619,14 @@ void createInstruments(Score *score, QList<MTrack> &tracks)
if (track.mtrack->drumTrack()) {
// drum track
s->setInitialClef(CLEF_PERC);
s->setClef(0, ClefType::PERC);
part->instr()->setDrumset(smDrumset);
part->instr()->setUseDrumset(true);
}
else {
const int avgPitch = MChord::findAveragePitch(track.chords.begin(),
track.chords.end());
s->setInitialClef(MidiClef::clefTypeFromAveragePitch(avgPitch));
s->setClef(0, MidiClef::clefTypeFromAveragePitch(avgPitch));
if (idx < (tracks.size() - 1) && idx >= 0
&& isPianoPart(tracks[idx], tracks[idx + 1])) {
// assume that the current track and the next track
@ -640,7 +640,7 @@ void createInstruments(Score *score, QList<MTrack> &tracks)
++idx;
const int avgPitch = MChord::findAveragePitch(tracks[idx].chords.begin(),
tracks[idx].chords.end());
ss->setInitialClef(MidiClef::clefTypeFromAveragePitch(avgPitch));
ss->setClef(0, MidiClef::clefTypeFromAveragePitch(avgPitch));
tracks[idx].staff = ss;
}
}

View file

@ -1,3 +1,15 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2013 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include "importmidi_clef.h"
#include "libmscore/score.h"
#include "libmscore/staff.h"
@ -135,7 +147,7 @@ class TieStateMachine
ClefType clefTypeFromAveragePitch(int averagePitch)
{
return averagePitch < midPitch() ? CLEF_F : CLEF_G;
return averagePitch < midPitch() ? ClefType::F : ClefType::G;
}
void createClef(ClefType clefType, Staff* staff, int tick, bool isSmall = false)
@ -214,7 +226,7 @@ Segment* enlargeSegToPrev(Segment *s, int strack, int counterLimit, int lPitch,
void createClefs(Staff *staff, int indexOfOperation, bool isDrumTrack)
{
ClefType currentClef = staff->initialClef()._concertClef;
ClefType currentClef = staff->clefTypeList(0)._concertClef;
createClef(currentClef, staff, 0);
const auto trackOpers = preferences.midiImportOperations.trackOperations(indexOfOperation);
@ -264,45 +276,45 @@ void createClefs(Staff *staff, int indexOfOperation, bool isDrumTrack)
&& tieState != TieStateMachine::State::TIED_BACK) {
if (avgPitch.pitch() < lowPitch) {
if (currentClef == CLEF_G) {
if (currentClef == ClefType::G) {
Segment *s = (counter > 0) ? prevSeg : seg;
currentClef = CLEF_F;
currentClef = ClefType::F;
s = enlargeSegToPrev(s, strack, counterLimit, midPitch, highPitch);
createSmallClef(currentClef, s, staff);
}
}
else if (avgPitch.pitch() >= lowPitch && avgPitch.pitch() < midPitch) {
if (currentClef == CLEF_G) {
if (currentClef == ClefType::G) {
if (counter < counterLimit) {
if (counter == 0)
prevSeg = seg;
++counter;
}
else {
currentClef = CLEF_F;
currentClef = ClefType::F;
auto s = enlargeSegToPrev(prevSeg, strack, counterLimit, midPitch, highPitch);
createSmallClef(currentClef, s, staff);
}
}
}
else if (avgPitch.pitch() >= midPitch && avgPitch.pitch() < highPitch) {
if (currentClef == CLEF_F) {
if (currentClef == ClefType::F) {
if (counter < counterLimit){
if (counter == 0)
prevSeg = seg;
++counter;
}
else {
currentClef = CLEF_G;
currentClef = ClefType::G;
auto s = enlargeSegToPrev(prevSeg, strack, counterLimit, lowPitch, midPitch);
createSmallClef(currentClef, s, staff);
}
}
}
else if (avgPitch.pitch() >= highPitch) {
if (currentClef == CLEF_F) {
if (currentClef == ClefType::F) {
Segment *s = (counter > 0) ? prevSeg : seg;
currentClef = CLEF_G;
currentClef = ClefType::G;
s = enlargeSegToPrev(s, strack, counterLimit, lowPitch, midPitch);
createSmallClef(currentClef, s, staff);
}

View file

@ -7,6 +7,7 @@
namespace Ms {
class Staff;
enum class ClefType : signed char;
namespace MidiClef {

View file

@ -401,62 +401,62 @@ void OveToMScore::convertGroups() {
}
ClefType OveClefToClef(OVE::ClefType type){
ClefType clef = CLEF_G;
ClefType clef = ClefType::G;
switch(type){
case OVE::Clef_Treble:{
clef = CLEF_G;
clef = ClefType::G;
break;
}
case OVE::Clef_Bass:{
clef = CLEF_F;
clef = ClefType::F;
break;
}
case OVE::Clef_Alto:{
clef = CLEF_C3;
clef = ClefType::C3;
break;
}
case OVE::Clef_UpAlto:{
clef = CLEF_C4;
clef = ClefType::C4;
break;
}
case OVE::Clef_DownDownAlto:{
clef = CLEF_C1;
clef = ClefType::C1;
break;
}
case OVE::Clef_DownAlto:{
clef = CLEF_C2;
clef = ClefType::C2;
break;
}
case OVE::Clef_UpUpAlto:{
clef = CLEF_C5;
clef = ClefType::C5;
break;
}
case OVE::Clef_Treble8va:{
clef = CLEF_G1;
clef = ClefType::G1;
break;
}
case OVE::Clef_Bass8va:{
clef = CLEF_F_8VA;
clef = ClefType::F_8VA;
break;
}
case OVE::Clef_Treble8vb:{
clef = CLEF_G3;
clef = ClefType::G3;
break;
}
case OVE::Clef_Bass8vb:{
clef = CLEF_F8;
clef = ClefType::F8;
break;
}
case OVE::Clef_Percussion1:{
clef = CLEF_PERC;
clef = ClefType::PERC;
break;
}
case OVE::Clef_Percussion2:{
clef = CLEF_PERC2;
clef = ClefType::PERC2;
break;
}
case OVE::Clef_TAB:{
clef = CLEF_TAB;
clef = ClefType::TAB;
break;
}
default:

View file

@ -4797,7 +4797,7 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
if (step != "" && 0 <= octave && octave <= 9) {
// qDebug("rest step=%s oct=%d", qPrintable(step), octave);
ClefType clef = cr->staff()->clef(loc_tick);
int po = clefTable[clef].pitchOffset;
int po = ClefInfo::pitchOffset(clef);
int istep = step[0].toLatin1() - 'A';
// qDebug(" clef=%d po=%d istep=%d", clef, po, istep);
if (istep < 0 || istep > 6) {
@ -4930,7 +4930,7 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
if (unpitched) {
// determine staff line based on display-step / -octave and clef type
ClefType clef = cr->staff()->clef(loc_tick);
int po = clefTable[clef].pitchOffset;
int po = ClefInfo::pitchOffset(clef);
int pitch = MusicXMLStepAltOct2Pitch(step[0].toLatin1(), 0, octave);
int line = po - absStep(pitch);
@ -5227,7 +5227,7 @@ void MusicXml::xmlHarmony(QDomElement e, int tick, Measure* measure, int staff)
int MusicXml::xmlClef(QDomElement e, int staffIdx, Measure* measure)
{
ClefType clef = CLEF_G;
ClefType clef = ClefType::G;
int res = STANDARD_STAFF_TYPE;
int clefno = e.attribute(QString("number"), "1").toInt() - 1;
QString c;
@ -5259,47 +5259,47 @@ int MusicXml::xmlClef(QDomElement e, int staffIdx, Measure* measure)
}
if (c == "G" && i == 0 && line == 2)
clef = CLEF_G;
clef = ClefType::G;
else if (c == "G" && i == 1 && line == 2)
clef = CLEF_G1;
clef = ClefType::G1;
else if (c == "G" && i == 2 && line == 2)
clef = CLEF_G2;
clef = ClefType::G2;
else if (c == "G" && i == -1 && line == 2)
clef = CLEF_G3;
clef = ClefType::G3;
else if (c == "G" && i == 0 && line == 1)
clef = CLEF_G4;
clef = ClefType::G4;
else if (c == "F" && i == 0 && line == 3)
clef = CLEF_F_B;
clef = ClefType::F_B;
else if (c == "F" && i == 0 && line == 4)
clef = CLEF_F;
clef = ClefType::F;
else if (c == "F" && i == 1 && line == 4)
clef = CLEF_F_8VA;
clef = ClefType::F_8VA;
else if (c == "F" && i == 2 && line == 4)
clef = CLEF_F_15MA;
clef = ClefType::F_15MA;
else if (c == "F" && i == -1 && line == 4)
clef = CLEF_F8;
clef = ClefType::F8;
else if (c == "F" && i == -2 && line == 4)
clef = CLEF_F15;
clef = ClefType::F15;
else if (c == "F" && i == 0 && line == 5)
clef = CLEF_F_C;
clef = ClefType::F_C;
else if (c == "C") {
if (line == 5)
clef = CLEF_C5;
clef = ClefType::C5;
else if (line == 4)
clef = CLEF_C4;
clef = ClefType::C4;
else if (line == 3)
clef = CLEF_C3;
clef = ClefType::C3;
else if (line == 2)
clef = CLEF_C2;
clef = ClefType::C2;
else if (line == 1)
clef = CLEF_C1;
clef = ClefType::C1;
}
else if (c == "percussion") {
clef = CLEF_PERC2;
clef = ClefType::PERC2;
res = PERC_DEFAULT_STAFF_TYPE;
}
else if (c == "TAB") {
clef = CLEF_TAB2;
clef = ClefType::TAB2;
res = TAB_DEFAULT_STAFF_TYPE;
}
else

View file

@ -59,7 +59,7 @@ StaffListItem::StaffListItem(PartListItem* li)
setPartIdx(0);
staffIdx = 0;
setLinked(false);
setClef(ClefTypeList(CLEF_G, CLEF_G));
setClef(ClefTypeList(ClefType::G, ClefType::G));
_staffTypeCombo = 0;
initStaffTypeCombo();
}
@ -71,7 +71,7 @@ StaffListItem::StaffListItem()
staff = 0;
setPartIdx(0);
staffIdx = 0;
setClef(ClefTypeList(CLEF_G, CLEF_G));
setClef(ClefTypeList(ClefType::G, ClefType::G));
setLinked(false);
_staffTypeCombo = 0;
}
@ -131,7 +131,7 @@ void StaffListItem::setPartIdx(int val)
void StaffListItem::setClef(const ClefTypeList& val)
{
_clef = val;
setText(2, qApp->translate("clefTable", clefTable[_clef._transposingClef].name));
setText(2, qApp->translate("clefTable", ClefInfo::name(_clef._transposingClef)));
}
//---------------------------------------------------------
@ -184,17 +184,17 @@ void StaffListItem::staffTypeChanged(int idx)
// check current clef matches new staff type
int staffTypeIdx = _staffTypeCombo->itemData(idx).toInt();
const StaffType* stfType = getListedStaffType(staffTypeIdx);
if (stfType->group() != clefTable[_clef._transposingClef].staffGroup) {
if (stfType->group() != ClefInfo::staffGroup(_clef._transposingClef)) {
ClefType clefType;
switch (stfType->group()) {
case STANDARD_STAFF_GROUP:
clefType = CLEF_G2;
clefType = ClefType::G2;
break;
case TAB_STAFF_GROUP:
clefType = CLEF_TAB2;
clefType = ClefType::TAB2;
break;
case PERCUSSION_STAFF_GROUP:
clefType = CLEF_PERC;
clefType = ClefType::PERC;
break;
}
setClef(ClefTypeList(clefType, clefType));
@ -945,7 +945,7 @@ void MuseScore::editInstrList()
staff->setRstaff(rstaff);
staff->init(t, sli->staffType(), cidx);
staff->setInitialClef(sli->clef());
staff->setClef(0, sli->clef());
rootScore->undoInsertStaff(staff, staffIdx + rstaff);
if (sli->linked()) {
@ -1000,7 +1000,7 @@ void MuseScore::editInstrList()
rootScore->adjustBracketsIns(staffIdx, staffIdx+1);
staff->initFromStaffType(sli->staffType());
staff->setInitialClef(sli->clef());
staff->setClef(0, sli->clef());
KeySigEvent nKey = part->staff(0)->key(0);
staff->setKey(0, nKey);

View file

@ -52,7 +52,7 @@ KeyCanvas::KeyCanvas(QWidget* parent)
a->setShortcut(Qt::Key_Delete);
addAction(a);
clef = new Clef(gscore);
clef->setClefType(CLEF_G);
clef->setClefType(ClefType::G);
connect(a, SIGNAL(triggered()), SLOT(deleteElement()));
}

View file

@ -626,16 +626,16 @@ Palette* MuseScore::newClefsPalette()
sp->setGrid(33, 60);
sp->setYOffset(1.0);
static const ClefType clefs[21] = {
CLEF_G, CLEF_G1, CLEF_G2, CLEF_G3, CLEF_G4,
CLEF_C1, CLEF_C2, CLEF_C3, CLEF_C4, CLEF_C5,
CLEF_F, CLEF_F_8VA, CLEF_F_15MA, CLEF_F8, CLEF_F15, CLEF_F_B, CLEF_F_C,
CLEF_PERC, CLEF_TAB, CLEF_TAB2, CLEF_PERC2
ClefType::G, ClefType::G1, ClefType::G2, ClefType::G3, ClefType::G4,
ClefType::C1, ClefType::C2, ClefType::C3, ClefType::C4, ClefType::C5,
ClefType::F, ClefType::F_8VA, ClefType::F_15MA, ClefType::F8, ClefType::F15, ClefType::F_B, ClefType::F_C,
ClefType::PERC, ClefType::TAB, ClefType::TAB2, ClefType::PERC2
};
for (int i = 0; i < 20; ++i) {
ClefType j = clefs[i];
Clef* k = new Ms::Clef(gscore);
k->setClefType(ClefTypeList(j, j));
sp->append(k, qApp->translate("clefTable", clefTable[j].name));
sp->append(k, qApp->translate("clefTable", ClefInfo::name(j)));
}
return sp;
}

View file

@ -88,13 +88,13 @@ void MuseData::musicalAttribute(QString s, Part* part)
}
staffIdx -= 1;
/* int clef = item.mid(col).toInt();
ClefType mscoreClef = CLEF_G;
ClefType mscoreClef = ClefType::G;
switch(clef) {
case 4: mscoreClef = CLEF_G; break;
case 22: mscoreClef = CLEF_F; break;
case 13: mscoreClef = CLEF_C3; break;
case 14: mscoreClef = CLEF_C2; break;
case 15: mscoreClef = CLEF_C1; break;
case 4: mscoreClef = ClefType::G; break;
case 22: mscoreClef = ClefType::F; break;
case 13: mscoreClef = ClefType::C3; break;
case 14: mscoreClef = ClefType::C2; break;
case 15: mscoreClef = ClefType::C1; break;
default:
qDebug("unknown clef %d\n", clef);
break;

View file

@ -208,7 +208,7 @@ void InstrumentWizard::on_addButton_clicked()
sli->setPartIdx(i);
sli->staffIdx = -1;
if (i > MAX_STAVES)
sli->setClef(ClefTypeList(CLEF_G, CLEF_G));
sli->setClef(ClefTypeList(ClefType::G, ClefType::G));
else
sli->setClef(it->clefTypes[i]);
sli->setStaffType(it->staffTypePreset);
@ -465,7 +465,7 @@ void InstrumentWizard::createInstruments(Score* cs)
++rstaff;
staff->init(t, sli->staffType(), cidx);
staff->setInitialClef(sli->clef());
staff->setClef(0, sli->clef());
if (sli->linked() && !part->staves()->isEmpty()) {
Staff* linkedStaff = part->staves()->back();