diff --git a/Filters/VLMusicXMLType.writer b/Filters/VLMusicXMLType.writer index 964cd1f..449249b 100644 --- a/Filters/VLMusicXMLType.writer +++ b/Filters/VLMusicXMLType.writer @@ -61,6 +61,9 @@ def _chords chords = REXML::Element.new('part') chords.add_attribute('id', 'HARM') + INPUT['measures'].each do |meas| + end + return chords end @@ -91,3 +94,6 @@ xml.add REXML::DocType.new(['score-partwise', 'PUBLIC', xml.add_element(_score) xml.write($stdout, 0) +# Local Variables: +# mode:ruby +# End: diff --git a/Sources/VLPListDocument.mm b/Sources/VLPListDocument.mm index 461c49d..f700c91 100644 --- a/Sources/VLPListDocument.mm +++ b/Sources/VLPListDocument.mm @@ -33,8 +33,6 @@ protected: NSArray * EncodeProperties(const std::vector & properties); NSDictionary * EncodeProperties(const VLProperties & properties); - NSArray * EncodeRepeats(const std::vector & repeats); - NSDictionary * EncodeRepeat(const VLRepeat & repeat); NSMutableDictionary * fPlist; NSMutableArray * fMeasures; @@ -66,35 +64,6 @@ NSDictionary * VLPlistVisitor::EncodeProperties(const VLProperties & properties) nil]; } -NSArray * VLPlistVisitor::EncodeRepeats(const std::vector & repeats) -{ - NSMutableArray * ra = [NSMutableArray arrayWithCapacity:repeats.size()]; - - for (std::vector::const_iterator i = repeats.begin(); - i != repeats.end(); ++i) - [ra addObject:EncodeRepeat(*i)]; - - return ra; -} - -NSDictionary * VLPlistVisitor::EncodeRepeat(const VLRepeat & repeat) -{ - NSMutableArray * ea = [NSMutableArray arrayWithCapacity:repeat.fEndings.size()]; - - for (std::vector::const_iterator i = repeat.fEndings.begin(); - i != repeat.fEndings.end(); ++i) - [ea addObject:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt: i->fBegin], @"begin", - [NSNumber numberWithInt: i->fEnd], @"end", - [NSNumber numberWithInt: i->fVolta], @"volta", - nil]]; - - return [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt: repeat.fTimes], @"times", - ea, @"endings", - nil]; -} - void VLPlistVisitor::Visit(VLSong & song) { fSong = &song; @@ -102,7 +71,6 @@ void VLPlistVisitor::Visit(VLSong & song) VisitMeasures(song, fPerfOrder); [fPlist setObject:EncodeProperties(song.fProperties) forKey:@"properties"]; - [fPlist setObject:EncodeRepeats(song.fRepeats) forKey:@"repeats"]; [fPlist setObject:fMeasures forKey:@"measures"]; } @@ -114,12 +82,39 @@ void VLPlistVisitor::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas) VisitNotes(meas, p, true); VisitChords(meas); - NSDictionary * md = - [NSDictionary dictionaryWithObjectsAndKeys: + NSMutableDictionary * md = + [NSMutableDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:m], @"measure", [NSNumber numberWithInt:meas.fPropIdx], @"properties", fNotes, @"melody", fChords, @"chords", nil]; + int times; + bool last; + size_t volta; + if (fSong->DoesBeginRepeat(m, ×)) + [md setObject: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt:times], @"times", nil] + forKey: @"begin-repeat"]; + if (fSong->DoesBeginEnding(m, &last, &volta)) + [md setObject: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:!last], @"last", + [NSNumber numberWithInt:volta], @"volta", + nil] + forKey: @"begin-ending"]; + if (fSong->DoesEndRepeat(m+1, ×)) + [md setObject: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt:times], @"times", nil] + forKey: @"end-repeat"]; + if (fSong->DoesEndEnding(m, &last, &volta)) + [md setObject: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:!last], @"last", + [NSNumber numberWithInt:volta], @"volta", + nil] + forKey: @"end-ending"]; [fMeasures addObject:md]; } @@ -162,18 +157,16 @@ void VLPlistVisitor::VisitChord(VLChord & c) - (id)plistInPerformanceOrder:(BOOL)performanceOrder { NSMutableDictionary * plist = - [NSMutableDictionary dictionaryWithCapacity:20]; - [plist setObject:songTitle forKey:@"title"]; - [plist setObject:songGroove forKey:@"groove"]; - [plist setObject:songTempo forKey:@"tempo"]; - [plist setObject:songComposer forKey:@"composer"]; - [plist setObject:songLyricist forKey:@"lyricist"]; - [plist setObject:[NSDate date] forKey:@"saved"]; - [plist setObject: - [NSString stringWithFormat:@"VocalEasel %@", - [[NSBundle mainBundle] - objectForInfoDictionaryKey:@"CFBundleVersion"]] - forKey:@"software"]; + [NSMutableDictionary dictionaryWithObjectsAndKeys: + songTitle, @"title", + songGroove, @"groove", songTempo, @"tempo", + songComposer, @"composer", songLyricist, @"lyricist", + [NSDate date], @"saved", + [NSString stringWithFormat:@"VocalEasel %@", + [[NSBundle mainBundle] + objectForInfoDictionaryKey:@"CFBundleVersion"]], + @"software", + nil]; VLPlistVisitor songWriter(plist, performanceOrder); songWriter.Visit(*song);