use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class StretchMeasuresTest method createSystemWith1Measure.
/**
* Creates and returns a simple {@link SystemSpacing} with only one
* measure with a clef and two notes, using the given parameters.
* @param leadingWidth width of the leading spacing in mm
* @param offsetBeat0 offset of beat 1/4 in mm
* @param offsetBeat1 offset of beat 3/4 in mm
* @param offsetBeat2 width of the voice spacing in mm
*/
public static SystemSpacing createSystemWith1Measure(float leadingWidth, float offsetBeat0, float offsetBeat1, float offsetBeat2) {
Chord chord1 = chord(Companion.pi(0, 0, 4), Companion.fr(2, 4));
Chord chord2 = chord(Companion.pi(1, 0, 4), Companion.fr(2, 4));
Voice voice = new Voice(alist(chord1, chord2));
List<BeatOffset> beatOffsets = alist(new BeatOffset(Companion.fr(1, 4), offsetBeat0), new BeatOffset(Companion.fr(3, 4), offsetBeat1), new BeatOffset(Companion.fr(5, 4), offsetBeat2));
float is = 1;
List<VoiceSpacing> voiceSpacings = alist(new VoiceSpacing(voice, is, alist(new ChordSpacing(new ChordNotation(chord1), beatOffsets.get(0).getBeat(), beatOffsets.get(0).getOffsetMm()), new ChordSpacing(new ChordNotation(chord2), beatOffsets.get(1).getBeat(), beatOffsets.get(1).getOffsetMm()))));
MeasureSpacing measureSpacing = new MeasureSpacing(atMeasure(0, 0), is, voiceSpacings, empty, LeadingSpacingMock.createGClefSpacing(leadingWidth));
List<MeasureSpacing> measureSpacings = alist(measureSpacing);
ColumnSpacing mcs = new ColumnSpacing(-1, measureSpacings, beatOffsets, alist(new BeatOffset(Companion.fr(0, 4), 0), new BeatOffset(Companion.fr(6, 4), offsetBeat2)));
SystemSpacing system = new SystemSpacing(ilist(mcs), 0, 0, leadingWidth + offsetBeat2, null, 0);
return system;
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Base24c method getExpectedChords.
default Chord[] getExpectedChords() {
Chord[] ret = { ch(Companion.fr(2, 4), Companion.pi('E', 0, 5)), ch(Companion.fr(2, 4), Companion.pi('E', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('G', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('A', 0, 5)) };
new BeamAdd(Companion.beamFromChordsUnchecked(alist(ret[2], ret[3]))).execute();
return ret;
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Base24d method getExpectedChords.
default Chord[] getExpectedChords() {
Chord[] ret = { ch(Companion.fr(2, 4), Companion.pi('E', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('G', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('A', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('A', 0, 5)), ch(Companion.fr(2, 4), Companion.pi('E', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('G', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('A', 0, 5)) };
new BeamAdd(Companion.beamFromChordsUnchecked(alist(ret[4], ret[5]))).execute();
return ret;
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class Base24a method getExpectedChords.
static Chord[] getExpectedChords() {
// [b]eamed chords [s]tart and [e]nd
Chord b1s, b1e, b2s, b2e;
Chord[] expectedChords = new Chord[] { // measure 0
gr(Companion.fr(1, 16), false, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), b1s = gr(Companion.fr(1, 16), false, Companion.pi('E', 0, 5)), b1e = gr(Companion.fr(1, 16), false, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 8), false, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), // measure 1
gr(Companion.fr(1, 16), true, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), b2s = gr(Companion.fr(1, 16), false, Companion.pi('E', 0, 5)), b2e = gr(Companion.fr(1, 16), false, Companion.pi('D', 0, 5)), ch(Companion.fr(2, 4), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 16), true, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 8), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 16), true, Companion.pi('D', 0, 5)), ch(Companion.fr(1, 8), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 16), false, Companion.pi('E', 0, 5)), // measure 2
gr(Companion.fr(1, 16), false, Companion.pi('E', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('F', 0, 4), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 4), false, Companion.pi('D', 1, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), gr(Companion.fr(1, 4), false, Companion.pi('D', -1, 5)), gr(Companion.fr(1, 4), false, Companion.pi('A', -1, 4)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)), ch(Companion.fr(1, 4), Companion.pi('C', 0, 5)) };
new BeamAdd(Companion.beamFromChordsUnchecked(alist(b1s, b1e))).execute();
new BeamAdd(Companion.beamFromChordsUnchecked(alist(b2s, b2e))).execute();
return expectedChords;
}
use of com.xenoage.zong.core.music.chord.Chord in project Zong by Xenoage.
the class TupletStamper method createTupletStamping.
/**
* Computes the {@link TupletStamping} for the given {@link ChordStampings}
* and returns it.
*/
public TupletStamping createTupletStamping(Tuplet tuplet, OpenTupletsCache cache, SymbolPool symbolPool) {
StaffStamping ss = cache.getChord(tuplet.getChords().get(0), tuplet).staff;
// horizontal position of the bracket
float xDistance = ss.is / 4;
float x1Mm = cache.getChord(tuplet.getFirstChord(), tuplet).xMm - xDistance;
ChordStampings cs2 = cache.getChord(tuplet.getLastChord(), tuplet);
// TODO: notehead width!
float cs2Width = ss.is * 1.2f;
float x2Mm = cs2.xMm + cs2Width + xDistance;
// vertical position of the bracket (above or below) depends on the directions
// of the majority of the stems
int stemDir = 0;
for (Chord chord : tuplet.getChords()) {
ChordStampings cs = cache.getChord(chord, tuplet);
if (cs.stem != null) {
stemDir += cs.stem.direction.getSign();
}
}
// 1: above, -1: below
int placement = (stemDir < 0 ? 1 : -1);
// compute position of start and end point
// by default, the bracket is 1.5 IS away from the end of the stems
// when there is no stem, the innermost notehead is used
// TODO: if stems of inner chords are longer, correct!
float distanceLp = 1.5f * 2;
float y1Lp = computeBracketLP(cache.getChord(tuplet.getFirstChord(), tuplet), placement, distanceLp);
float y2Lp = computeBracketLP(cache.getChord(tuplet.getLastChord(), tuplet), placement, distanceLp);
// at least 2 IS over top barline / under bottom barline
if (// above staff
placement == 1) {
y1Lp = Math.max(y1Lp, (ss.linesCount - 1) * 2 + 4);
y2Lp = Math.max(y1Lp, (ss.linesCount - 1) * 2 + 4);
} else // below staff
{
y1Lp = Math.min(y1Lp, 0 - 4);
y2Lp = Math.min(y1Lp, 0 - 4);
}
// text
float fontSize = 10 * ss.is / 1.6f;
FormattedText text = createText(tuplet.getActualNotes(), fontSize, symbolPool);
// return result
return new TupletStamping(sp(x1Mm, y1Lp), sp(x2Mm, y2Lp), true, text, ss);
}
Aggregations