From fc1e8277c70fbfbce3eb4a02adb08bc26099d0ff Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Thu, 24 Jan 2008 00:57:58 +0000 Subject: [PATCH] Implement groove changes in MMA documents --- Sources/VLMMADocument.mm | 4 ---- Sources/VLMMAWriter.cpp | 17 +++++++++++++++-- Sources/VLMMAWriter.h | 18 ++++++++++-------- Sources/VLPListDocument.mm | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Sources/VLMMADocument.mm b/Sources/VLMMADocument.mm index f45e67e..760cc9c 100644 --- a/Sources/VLMMADocument.mm +++ b/Sources/VLMMADocument.mm @@ -42,10 +42,6 @@ // Can't handle these yet break; } - sprintf(buf, "Groove %s\n", [songGroove UTF8String]); - mmaFile += buf; - sprintf(buf, "KeySig %d%c\n", labs(prop.fKey), prop.fKey>=0 ? '#' : '&'); - mmaFile += buf; if (!(playElements & kVLPlayAccompaniment)) mmaFile += "AllTracks Off\nSolo On\n"; if (!(playElements & kVLPlayMelody)) diff --git a/Sources/VLMMAWriter.cpp b/Sources/VLMMAWriter.cpp index 5e1cefe..dd337fd 100644 --- a/Sources/VLMMAWriter.cpp +++ b/Sources/VLMMAWriter.cpp @@ -16,16 +16,29 @@ void VLMMAWriter::Visit(VLSong & song) fMeas = 0; fInitial= true; fMeasures.clear(); + fKey = -999; + fGroove = ""; VisitMeasures(song, true); } void VLMMAWriter::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas) { - char buf[8]; + char buf[64]; + + if (p.fKey != fKey) { + fKey = p.fKey; + sprintf(buf, "KeySig %d%c\n", labs(fKey), fKey>=0 ? '#' : '&'); + fMeasures += buf; + } + if (p.fGroove != fGroove) { + fGroove = p.fGroove; + fMeasures += "Groove " + fGroove + '\n'; + } + sprintf(buf, "%-3d", ++fMeas); - fUseSharps = p.fKey >= 0; + fUseSharps = fKey >= 0; // // Generate chords diff --git a/Sources/VLMMAWriter.h b/Sources/VLMMAWriter.h index ad12170..6270f91 100644 --- a/Sources/VLMMAWriter.h +++ b/Sources/VLMMAWriter.h @@ -21,15 +21,17 @@ public: const std::string & Measures() const { return fMeasures; } private: - std::string fMeasures; + std::string fMeasures; - VLSong * fSong; - bool fUseSharps; - bool fTied; - bool fInitial; - int fMeas; - size_t fLastDur; - std::string fAccum; + VLSong * fSong; + bool fUseSharps; + bool fTied; + bool fInitial; + int fMeas; + size_t fLastDur; + std::string fAccum; + int fKey; + std::string fGroove; }; // Local Variables: diff --git a/Sources/VLPListDocument.mm b/Sources/VLPListDocument.mm index 5a97c80..fee13f2 100644 --- a/Sources/VLPListDocument.mm +++ b/Sources/VLPListDocument.mm @@ -517,4 +517,4 @@ advanceAt: return [self readFromPlist:outPlist error:outError]; } -@end \ No newline at end of file +@end