mirror of
https://github.com/microtherion/VocalEasel.git
synced 2025-01-22 01:53:59 +00:00
Store repeats inline in measures
This commit is contained in:
parent
ffaa1f8343
commit
e7ee4e301d
|
@ -61,6 +61,9 @@ def _chords
|
||||||
chords = REXML::Element.new('part')
|
chords = REXML::Element.new('part')
|
||||||
chords.add_attribute('id', 'HARM')
|
chords.add_attribute('id', 'HARM')
|
||||||
|
|
||||||
|
INPUT['measures'].each do |meas|
|
||||||
|
end
|
||||||
|
|
||||||
return chords
|
return chords
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,3 +94,6 @@ xml.add REXML::DocType.new(['score-partwise', 'PUBLIC',
|
||||||
xml.add_element(_score)
|
xml.add_element(_score)
|
||||||
xml.write($stdout, 0)
|
xml.write($stdout, 0)
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode:ruby
|
||||||
|
# End:
|
||||||
|
|
|
@ -33,8 +33,6 @@ protected:
|
||||||
|
|
||||||
NSArray * EncodeProperties(const std::vector<VLProperties> & properties);
|
NSArray * EncodeProperties(const std::vector<VLProperties> & properties);
|
||||||
NSDictionary * EncodeProperties(const VLProperties & properties);
|
NSDictionary * EncodeProperties(const VLProperties & properties);
|
||||||
NSArray * EncodeRepeats(const std::vector<VLRepeat> & repeats);
|
|
||||||
NSDictionary * EncodeRepeat(const VLRepeat & repeat);
|
|
||||||
|
|
||||||
NSMutableDictionary * fPlist;
|
NSMutableDictionary * fPlist;
|
||||||
NSMutableArray * fMeasures;
|
NSMutableArray * fMeasures;
|
||||||
|
@ -66,35 +64,6 @@ NSDictionary * VLPlistVisitor::EncodeProperties(const VLProperties & properties)
|
||||||
nil];
|
nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray * VLPlistVisitor::EncodeRepeats(const std::vector<VLRepeat> & repeats)
|
|
||||||
{
|
|
||||||
NSMutableArray * ra = [NSMutableArray arrayWithCapacity:repeats.size()];
|
|
||||||
|
|
||||||
for (std::vector<VLRepeat>::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<VLRepeat::Ending>::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)
|
void VLPlistVisitor::Visit(VLSong & song)
|
||||||
{
|
{
|
||||||
fSong = &song;
|
fSong = &song;
|
||||||
|
@ -102,7 +71,6 @@ void VLPlistVisitor::Visit(VLSong & song)
|
||||||
VisitMeasures(song, fPerfOrder);
|
VisitMeasures(song, fPerfOrder);
|
||||||
|
|
||||||
[fPlist setObject:EncodeProperties(song.fProperties) forKey:@"properties"];
|
[fPlist setObject:EncodeProperties(song.fProperties) forKey:@"properties"];
|
||||||
[fPlist setObject:EncodeRepeats(song.fRepeats) forKey:@"repeats"];
|
|
||||||
[fPlist setObject:fMeasures forKey:@"measures"];
|
[fPlist setObject:fMeasures forKey:@"measures"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,12 +82,39 @@ void VLPlistVisitor::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas)
|
||||||
VisitNotes(meas, p, true);
|
VisitNotes(meas, p, true);
|
||||||
VisitChords(meas);
|
VisitChords(meas);
|
||||||
|
|
||||||
NSDictionary * md =
|
NSMutableDictionary * md =
|
||||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
[NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithInt:m], @"measure",
|
[NSNumber numberWithInt:m], @"measure",
|
||||||
[NSNumber numberWithInt:meas.fPropIdx], @"properties",
|
[NSNumber numberWithInt:meas.fPropIdx], @"properties",
|
||||||
fNotes, @"melody", fChords, @"chords",
|
fNotes, @"melody", fChords, @"chords",
|
||||||
nil];
|
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];
|
[fMeasures addObject:md];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,18 +157,16 @@ void VLPlistVisitor::VisitChord(VLChord & c)
|
||||||
- (id)plistInPerformanceOrder:(BOOL)performanceOrder
|
- (id)plistInPerformanceOrder:(BOOL)performanceOrder
|
||||||
{
|
{
|
||||||
NSMutableDictionary * plist =
|
NSMutableDictionary * plist =
|
||||||
[NSMutableDictionary dictionaryWithCapacity:20];
|
[NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
[plist setObject:songTitle forKey:@"title"];
|
songTitle, @"title",
|
||||||
[plist setObject:songGroove forKey:@"groove"];
|
songGroove, @"groove", songTempo, @"tempo",
|
||||||
[plist setObject:songTempo forKey:@"tempo"];
|
songComposer, @"composer", songLyricist, @"lyricist",
|
||||||
[plist setObject:songComposer forKey:@"composer"];
|
[NSDate date], @"saved",
|
||||||
[plist setObject:songLyricist forKey:@"lyricist"];
|
[NSString stringWithFormat:@"VocalEasel %@",
|
||||||
[plist setObject:[NSDate date] forKey:@"saved"];
|
[[NSBundle mainBundle]
|
||||||
[plist setObject:
|
objectForInfoDictionaryKey:@"CFBundleVersion"]],
|
||||||
[NSString stringWithFormat:@"VocalEasel %@",
|
@"software",
|
||||||
[[NSBundle mainBundle]
|
nil];
|
||||||
objectForInfoDictionaryKey:@"CFBundleVersion"]]
|
|
||||||
forKey:@"software"];
|
|
||||||
|
|
||||||
VLPlistVisitor songWriter(plist, performanceOrder);
|
VLPlistVisitor songWriter(plist, performanceOrder);
|
||||||
songWriter.Visit(*song);
|
songWriter.Visit(*song);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user