use of com.xenoage.zong.core.music.chord.Accidental in project Zong by Xenoage.
the class ThreeAccidentals method compute.
@Override
AccidentalsNotation compute(Params p) {
float width, xBottom, xMiddle, xTop;
NoteDisplacement bottomNote = p.accsNote[0];
NoteDisplacement middleNote = p.accsNote[1];
NoteDisplacement topNote = p.accsNote[2];
Accidental bottomAcc = p.accs[0];
Accidental middleAcc = p.accs[1];
Accidental topAcc = p.accs[2];
float bottomWidth = p.chordWidths.get(bottomAcc);
float middleWidth = p.chordWidths.get(middleAcc);
float topWidth = p.chordWidths.get(topAcc);
float accToAccGap = p.chordWidths.accToAccGap;
float accToNoteGap = p.chordWidths.accToNoteGap;
// interval of at least a seventh?
if (topNote.lp - bottomNote.lp >= 6) {
// interval of at least a seventh. can be rule 1, 3 or 4
if (topNote.suspension == Right) {
// top note is suspended on the right side of the stem.
// this is rule 4. (same code as rule 1)
xBottom = xTop = middleWidth + accToAccGap;
xMiddle = 0;
width = xBottom + p.chordWidths.getMaxWidth(bottomAcc, topAcc) + accToNoteGap;
} else if (middleNote.suspension == Right) {
// middle note is suspended on the right side of the stem.
// (bottom note is never suspended on the right)
// this is rule 3.
xBottom = 0;
xMiddle = bottomWidth + accToAccGap + topWidth + accToAccGap;
xTop = bottomWidth + accToAccGap;
width = xMiddle + middleWidth + accToNoteGap;
} else {
// there are no accidental notes suspended on the right side of the stem.
// this is rule 1.
xBottom = xTop = middleWidth + accToAccGap;
xMiddle = 0f;
width = xBottom + p.chordWidths.getMaxWidth(bottomAcc, topAcc) + accToNoteGap;
}
} else {
// interval of less than a seventh. can be rule 2, 5 or 6
if (topNote.suspension == Right) {
// top note is suspended on the right side of the stem.
// this is rule 5. (same code as rule 2)
xBottom = middleWidth + accToAccGap;
xMiddle = 0f;
xTop = xBottom + bottomWidth + accToAccGap;
width = xTop + topWidth + accToNoteGap;
} else if (middleNote.suspension == Right) {
// middle note is suspended on the right side of the stem.
// (bottom note is never suspended on the right)
// this is rule 6. (same code as rule 3)
xBottom = 0f;
xMiddle = bottomWidth + accToAccGap + topWidth + accToAccGap;
xTop = bottomWidth + accToAccGap;
width = xMiddle + middleWidth + accToNoteGap;
} else {
// there are no accidental notes suspended on the right side of the stem.
// this is rule 2.
xBottom = middleWidth + accToAccGap;
xMiddle = 0f;
xTop = middleWidth + accToAccGap + bottomWidth + accToAccGap;
width = xTop + topWidth + accToNoteGap;
}
}
return create(p, width, xBottom, xMiddle, xTop);
}
use of com.xenoage.zong.core.music.chord.Accidental in project Zong by Xenoage.
the class TwoAccidentals method compute.
@Override
AccidentalsNotation compute(Params p) {
float width, xTop, xBottom;
NoteDisplacement bottomNote = p.accsNote[0];
NoteDisplacement topNote = p.accsNote[1];
Accidental bottomAcc = p.accs[0];
Accidental topAcc = p.accs[1];
float accToAccGap = p.chordWidths.accToAccGap;
// interval of at least a seventh?
if (topNote.lp - bottomNote.lp >= 6) {
// placed on the same horizontal position x = 0
xTop = xBottom = 0;
width = p.chordWidths.getMaxWidth(p.accs) + p.chordWidths.accToNoteGap;
} else {
// placed on different horizontal positions
// normally begin with the bottom accidental
boolean bottomFirst = true;
// is not, then the bottom accidental is nearer to the stem (Ross p.12, 3rd row)
if (bottomNote.suspension == Right && topNote.suspension != Right)
bottomFirst = false;
// is not, then the bottom accidental is nearer to the stem (Ross p.12, 4th row)
if (topNote.suspension == Left && bottomNote.suspension != Left)
bottomFirst = false;
// horizontal position
float bottomWidth = p.chordWidths.get(bottomAcc);
float topWidth = p.chordWidths.get(topAcc);
if (bottomFirst) {
// bottom accidental is leftmost
xBottom = 0;
xTop = bottomWidth + accToAccGap;
} else {
// top accidental is leftmost
xBottom = topWidth + accToAccGap;
xTop = 0;
}
// width
width = bottomWidth + accToAccGap + topWidth + p.chordWidths.accToNoteGap;
}
return create(p, width, xBottom, xTop);
}
Aggregations