Bug description
Loading any Capella file (.capx / CapXML) that contains a rest fails with No compatible importer found for file.
With debug logging the Capella importer gets as far as Start Parsing score.xml, then gives up. The underlying exception is:
TypeError: Cannot read properties of undefined (reading 'beats')
at get isFullBarRest
at Beat._calculateDuration
at Beat.updateDurations
at CapellaParser._parseVoice
at CapellaParser._parseVoices
Cause
In CapellaParser._parseVoice, the rest case calls restBeat.updateDurations() before this._currentVoice.addBeat(restBeat). updateDurations() → _calculateDuration() reads isFullBarRest, which accesses this.voice.beats — but voice is not set yet, because the beat has not been added to a voice. (The chord case does the same, but there isRest is false, so the getter short-circuits before touching voice.)
case "rest":
const restBeat = this._parseRestDurations(c.findChildElement("duration"));
if (restBeat) {
this._initFromPreviousBeat(restBeat, this._currentVoice);
restBeat.updateDurations(); // <- voice is still undefined here
this._currentVoiceState.currentPosition += restBeat.playbackDuration;
this._currentVoice.addBeat(restBeat);
Possible fix
Either call addBeat before updateDurations for rests, or make the getter tolerant:
get isFullBarRest() {
return this.isRest && !!this.voice && this.voice.beats.length === 1 && this.duration === Duration.Whole;
}
With the guarded getter (applied as a runtime patch on our side) the affected file loads and renders completely (26 bars).
Environment
- alphaTab 1.8.4 (npm
@coderline/alphatab), browser (Chrome), useWorkers: false
- File: saved with capella 10 (
<score xmlns="http://www.capella.de/CapXML/5.4">), a simple single-staff melody with eighth/quarter rests. I can't attach the original (copyrighted melody), but any CapXML file with a <rest> inside <noteObjects> should reproduce it.
Thanks for alphaTab — it's great to work with!
Bug description
Loading any Capella file (
.capx/ CapXML) that contains a rest fails withNo compatible importer found for file.With debug logging the Capella importer gets as far as
Start Parsing score.xml, then gives up. The underlying exception is:Cause
In
CapellaParser._parseVoice, therestcase callsrestBeat.updateDurations()beforethis._currentVoice.addBeat(restBeat).updateDurations()→_calculateDuration()readsisFullBarRest, which accessesthis.voice.beats— butvoiceis not set yet, because the beat has not been added to a voice. (Thechordcase does the same, but thereisRestis false, so the getter short-circuits before touchingvoice.)Possible fix
Either call
addBeatbeforeupdateDurationsfor rests, or make the getter tolerant:With the guarded getter (applied as a runtime patch on our side) the affected file loads and renders completely (26 bars).
Environment
@coderline/alphatab), browser (Chrome),useWorkers: false<score xmlns="http://www.capella.de/CapXML/5.4">), a simple single-staff melody with eighth/quarter rests. I can't attach the original (copyrighted melody), but any CapXML file with a<rest>inside<noteObjects>should reproduce it.Thanks for alphaTab — it's great to work with!