From 0929beb54aa137762162fe73ab69b7868b6ee618 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sun, 21 Jan 2007 11:31:17 +0000 Subject: [PATCH] Represent codas (incorrectly) --- Sources/VLXMLDocument.mm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/VLXMLDocument.mm b/Sources/VLXMLDocument.mm index b215167..d67999d 100644 --- a/Sources/VLXMLDocument.mm +++ b/Sources/VLXMLDocument.mm @@ -263,6 +263,14 @@ const char * sSteps = "C DbD EbE F GbG AbA BbB "; return identification; } +- (NSXMLElement *) soundElt:(NSString *)title +{ + NSXMLElement * sound = [NSXMLNode elementWithName:@"sound"]; + [sound addAttribute: [NSXMLNode attributeWithName:title + stringValue:@"A"]]; + return sound; +} + - (NSData *)XMLDataWithError:(NSError **)outError { NSXMLElement * work = [NSXMLNode elementWithName:@"work"]; @@ -386,10 +394,15 @@ const char * sSteps = "C DbD EbE F GbG AbA BbB "; [melMeas addChild:barline]; } + if (song->fCoda == measure) + [melMeas addChild:[self soundElt:@"coda"]]; [self addNotes:&song->fMeasures[measure].fMelody toMeasure:melMeas]; [self addChords:&song->fMeasures[measure].fChords toMeasure:harMeas]; + if (song->fGoToCoda == measure+1) + [melMeas addChild:[self soundElt:@"tocoda"]]; + [melody addChild:melMeas]; [chords addChild:harMeas]; } @@ -583,7 +596,10 @@ int8_t sStepToPitch[] = { [self readBarlines:[measure elementsForName:@"barline"] measure:m repeat:&repeat inRepeat:&inRepeat error:outError]; - + if ([measure nodeForXPath:@".//sound[@coda=\"A\"]" error:outError]) + song->fCoda = m; + if ([measure nodeForXPath:@".//sound[@tocoda=\"A\"]" error:outError]) + song->fGoToCoda = m+1; NSEnumerator * n = [[measure elementsForName:@"note"] objectEnumerator]; for (NSXMLElement * note; note = [n nextObject]; ) {