From 548c129d153ae8a2337625949980b4c308ac8266 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 12 Jan 2007 09:02:57 +0000 Subject: [PATCH] Fix adding measures, loading rests --- Sources/VLXMLDocument.mm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/VLXMLDocument.mm b/Sources/VLXMLDocument.mm index e4e7234..b215167 100644 --- a/Sources/VLXMLDocument.mm +++ b/Sources/VLXMLDocument.mm @@ -569,8 +569,17 @@ int8_t sStepToPitch[] = { int m = [[[measure attributeForName:@"number"] stringValue] intValue]-1; - if (m >= song->CountMeasures()) - song->fMeasures.resize(m); + if (m >= song->CountMeasures()) { + size_t oldSz = song->fMeasures.size(); + song->fMeasures.resize(m+1); + VLLyricsNote rest = VLLyricsNote(VLRest(prop.fTime)); + VLChord rchord; + rchord.fDuration = prop.fTime; + for (size_t i=oldSz; i<=m; ++i) { + song->fMeasures[i].fChords.push_back(rchord); + song->fMeasures[i].fMelody.push_back(rest); + } + } [self readBarlines:[measure elementsForName:@"barline"] measure:m repeat:&repeat inRepeat:&inRepeat error:outError]; @@ -579,8 +588,7 @@ int8_t sStepToPitch[] = { for (NSXMLElement * note; note = [n nextObject]; ) { VLLyricsNote n = [self readNote:note withUnit:unit]; - if (n.fPitch != VLNote::kNoPitch) - song->AddNote(n, m, at); + song->AddNote(n, m, at); at += n.fDuration; } }