Fix reading of documents with multiple time values

This commit is contained in:
Matthias Neeracher 2008-01-26 10:53:24 +00:00
parent f9f2946bb8
commit b8dac8dd63
3 changed files with 23 additions and 3 deletions

View File

@ -558,12 +558,32 @@ void VLSong::AddMeasure()
VLChord rchord(dur);
VLMeasure meas;
meas.fPropIdx = fProperties.size()-1;
meas.fChords.push_back(rchord);
meas.fMelody.push_back(rest);
fMeasures.push_back(meas);
}
void VLSong::SetProperties(size_t measure, int propIdx)
{
VLFraction dur = fProperties[propIdx].fTime;
dur.Normalize();
VLLyricsNote rest(dur);
VLChord rchord(dur);
VLMeasure meas;
meas.fPropIdx = propIdx;
meas.fChords.push_back(rchord);
meas.fMelody.push_back(rest);
if (measure < fMeasures.size())
fMeasures[measure] = meas;
else
while (fMeasures.size() <= measure)
fMeasures.push_back(meas);
}
void VLSong::swap(VLSong & other)
{
fProperties.swap(other.fProperties);

View File

@ -377,6 +377,7 @@ public:
const VLProperties & Properties(size_t measure) const {
return fProperties[fMeasures[measure].fPropIdx];
}
void SetProperties(size_t measure, int propIdx);
bool DoesBeginSection(size_t measure) const;
void AddSection(size_t measure);

View File

@ -310,6 +310,8 @@ advanceAt:
) {
if (NSNumber * mNo = [mdict objectForKey:@"measure"])
measNo = static_cast<size_t>([mNo intValue]);
if (NSNumber * mPx = [mdict objectForKey:@"properties"])
song->SetProperties(measNo, [mPx intValue]);
[self readMelody:[mdict objectForKey:@"melody"] inMeasure:measNo onsets:onsets];
[self readChords:[mdict objectForKey:@"chords"] inMeasure:measNo];
@ -322,9 +324,6 @@ advanceAt:
song->fMeasures[measNo].fBreak |= VLMeasure::kNewSystem;
if ([[mdict objectForKey:@"new-page"] boolValue])
song->fMeasures[measNo].fBreak |= VLMeasure::kNewPage;
if (NSNumber * mPx = [mdict objectForKey:@"properties"])
song->fMeasures[measNo].fPropIdx=
static_cast<size_t>([mPx intValue]);
if (NSDictionary * beginRep = [mdict objectForKey:@"begin-repeat"]) {
VLRepeat rep;