Skip to content

Issues with extraneous <forward> element. #43

Description

@p-groarke

While building some measures with 2 staves (treble & bass), 2 voices, I get an extraneous <forward> element at the beginning of the second measure. The export doesn't seem to know the "playhead" is already at the correct position.

I'm curious if there is something to watch out for when dealing with multiple staves/voices?

Snippets of the generating code based on your example, writing a test scale.

Adding notes to measures.

	int current_time = 0;
	for (const mx::NoteData& n : scale) {
		ret.back().staves[0].voices[treb_voice_id].notes.push_back(n);
		mx::NoteData bass_n = n;
		bass_n.pitchData.octave -= 1;
		ret.back().staves[1].voices[bass_voice_id].notes.push_back(bass_n);

		current_time += n.durationData.durationTimeTicks;

		if (current_time >= ret.back().timeSignature.beats
						* ret.back().timeSignature.beatType) {
			ret.push_back(build_measure());
			current_time = 0;
		}
	}

How the measure is built.

mx::MeasureData build_measure(bool first = false) {
	mx::MeasureData ret;
	mx::StaffData staff_treb;
	mx::StaffData staff_bass;

	ret.timeSignature.beats = qticks;
	ret.timeSignature.beatType = qticks;

	if (first) {
		ret.timeSignature.isImplicit = false;

		// set the clef
		mx::ClefData clef_treb;
		clef_treb.setTreble();
		staff_treb.clefs.push_back(clef_treb);

		mx::ClefData clef_bass;
		clef_bass.setBass();
		staff_bass.clefs.push_back(clef_bass);

		mx::KeyData key;
		key.fifths = 4; //test
		ret.keys.push_back(key);
	}


	// add a voice
	mx::VoiceData voice_treb;
	mx::VoiceData voice_bass;

	staff_treb.voices[treb_voice_id] = voice_treb;
	staff_bass.voices[bass_voice_id] = voice_bass;

	// add a staff
	ret.staves.push_back(staff_treb);
	ret.staves.push_back(staff_bass);

	return ret;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions