From 50c44322ec787c75fd46143af492b96bb99036a9 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sat, 5 Jul 2008 13:55:41 +0000 Subject: [PATCH] Handle stanzas --- Sources/VLMIDIWriter.cpp | 8 ++++++-- Sources/VLMIDIWriter.h | 19 +++++++++++-------- Sources/VLSheetViewSelection.mm | 1 + VocalEasel.xcodeproj/project.pbxproj | 8 +++++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Sources/VLMIDIWriter.cpp b/Sources/VLMIDIWriter.cpp index 70df48c..543daa5 100644 --- a/Sources/VLMIDIWriter.cpp +++ b/Sources/VLMIDIWriter.cpp @@ -24,6 +24,7 @@ struct VLMetaEvent : MIDIMetaEvent { void VLMIDIWriter::Visit(VLSong & song) { + fVolta.clear(); MusicSequenceNewTrack(fMusic, &fTrack); VLMetaEvent meta("VocalEasel"); MusicTrackNewMetaEvent(fTrack, 0.0, &meta); @@ -33,8 +34,11 @@ void VLMIDIWriter::Visit(VLSong & song) void VLMIDIWriter::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas) { + if (fVolta.size() <= m) + fVolta.push_back(0); fTime = p.fTime; fMeasure = m; + fStanza = ++fVolta[m]; if (!m) fChordTime = fNoteTime = fCountIn*fTime.fNum; @@ -49,7 +53,7 @@ void VLMIDIWriter::VisitMeasure(size_t m, VLProperties & p, VLMeasure & meas) void VLMIDIWriter::VisitNote(VLLyricsNote & n) { if (n.fPitch != VLNote::kNoPitch && !(n.fTied & VLNote::kTiedWithPrev)) { - VLMIDIUserEvent event = {8, n.fPitch, fMeasure, fAt}; + VLMIDIUserEvent event = {8, n.fPitch, fStanza, fMeasure, fAt}; MusicTrackNewUserEvent(fTrack, fNoteTime, reinterpret_cast(&event)); } @@ -60,7 +64,7 @@ void VLMIDIWriter::VisitNote(VLLyricsNote & n) void VLMIDIWriter::VisitChord(VLChord & c) { if (c.fPitch != VLNote::kNoPitch) { - VLMIDIUserEvent event = {8, 0, fMeasure, fAt}; + VLMIDIUserEvent event = {8, 0, fStanza, fMeasure, fAt}; MusicTrackNewUserEvent(fTrack, fChordTime, reinterpret_cast(&event)); } diff --git a/Sources/VLMIDIWriter.h b/Sources/VLMIDIWriter.h index f37a563..14e1de2 100644 --- a/Sources/VLMIDIWriter.h +++ b/Sources/VLMIDIWriter.h @@ -15,6 +15,7 @@ struct VLMIDIUserEvent { uint32_t fLength; int8_t fPitch; // 0 -> Chord + uint8_t fStanza; int16_t fMeasure; VLFract fAt; }; @@ -29,14 +30,16 @@ public: virtual void VisitNote(VLLyricsNote & n); virtual void VisitChord(VLChord & c); private: - MusicSequence fMusic; - size_t fCountIn; - MusicTrack fTrack; - size_t fMeasure; - MusicTimeStamp fChordTime; - MusicTimeStamp fNoteTime; - VLFraction fAt; - VLFraction fTime; + MusicSequence fMusic; + size_t fCountIn; + MusicTrack fTrack; + size_t fMeasure; + size_t fStanza; + MusicTimeStamp fChordTime; + MusicTimeStamp fNoteTime; + VLFraction fAt; + VLFraction fTime; + std::vector fVolta; }; // Local Variables: diff --git a/Sources/VLSheetViewSelection.mm b/Sources/VLSheetViewSelection.mm index 8845b84..b5c69d8 100644 --- a/Sources/VLSheetViewSelection.mm +++ b/Sources/VLSheetViewSelection.mm @@ -51,6 +51,7 @@ fNotePitch = event->fPitch; fNoteMeasure = event->fMeasure; fNoteAt = event->fAt; + fStanza = event->fStanza; [fView highlightTextInStanza:fStanza measure:fNoteMeasure at:fNoteAt one:YES]; } else { fChordMeasure = event->fMeasure; diff --git a/VocalEasel.xcodeproj/project.pbxproj b/VocalEasel.xcodeproj/project.pbxproj index bf6c5d7..25aba52 100644 --- a/VocalEasel.xcodeproj/project.pbxproj +++ b/VocalEasel.xcodeproj/project.pbxproj @@ -173,7 +173,7 @@ 2A37F4C4FDCFA73011CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 2A37F4C5FDCFA73011CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; 32DBCF750370BD2300C91783 /* Vocalese_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Vocalese_Prefix.pch; path = Sources/Vocalese_Prefix.pch; sourceTree = ""; }; - 8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = ""; }; + 8D15AC360486D014006FF6A4 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = ""; }; 8D15AC370486D014006FF6A4 /* VocalEasel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VocalEasel.app; sourceTree = BUILT_PRODUCTS_DIR; }; 95003B400D4B9A5D00C9849C /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = ""; }; 95003B420D4B9A5D00C9849C /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/VLDocument.xib; sourceTree = ""; }; @@ -947,12 +947,14 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Sources/VocalEasel_Prefix.pch; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = Resources/Info.plist; INSTALL_PATH = "$(HOME)/Applications"; PREBINDING = NO; PRODUCT_NAME = VocalEasel; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; WRAPPER_EXTENSION = app; ZERO_LINK = YES; }; @@ -970,12 +972,14 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Sources/VocalEasel_Prefix.pch; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = Resources/Info.plist; INSTALL_PATH = "$(HOME)/Applications"; PREBINDING = NO; PRODUCT_NAME = VocalEasel; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; WRAPPER_EXTENSION = app; ZERO_LINK = NO; }; @@ -987,11 +991,13 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Sources/VocalEasel_Prefix.pch; + GCC_VERSION = 4.0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = Resources/Info.plist; INSTALL_PATH = "$(HOME)/Applications"; PRODUCT_NAME = VocalEasel; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; WRAPPER_EXTENSION = app; }; name = Default;