/// Tests the Constructors /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseConstructor() { //------Last Checked------// // - Jan 4, 2005 // TEST CASE: Default Constructor { Barline barline; TEST(wxT("Default Constructor"), (barline.GetPosition() == Barline::DEFAULT_POSITION) && (barline.GetType() == Barline::bar) && (barline.GetRepeatCount() == 0) ); } // TEST CASE: Primary Constructor { Barline barline(14, Barline::repeatEnd, 12); TEST(wxT("Primary Constructor"), (barline.GetPosition() == 14) && (barline.GetType() == Barline::repeatEnd) && (barline.GetRepeatCount() == 12) ); } // TEST CASE: Copy Constructor { Barline barline(14, Barline::repeatEnd, 12); Barline barline2(barline); TEST(wxT("Copy Constructor"), (barline2 == barline) ); } return (true); }
/// Tests the Position Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCasePosition() { //------Last Checked------// // - Jan 4, 2005 Barline barline; // TEST CASE: IsValidPosition { wxUint32 i = 0; for (; i <= 256; i++) { TEST(wxString::Format(wxT("IsValidPosition - %d"), i), (Barline::IsValidPosition(i) == (i < 256)) ); } } // TEST CASE: SetPosition { wxUint32 i = 0; for (; i <= 256; i++) { TEST(wxString::Format(wxT("SetPosition - %d"), i), (barline.SetPosition(i) == (i < 256)) && ((i == 256) ? 1 : (barline.GetPosition() == i)) ); } } return (true); }
/// Tests the Serialization Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseSerialize() { //------Last Checked------// // - Jan 4, 2005 bool ok = false; TestStream testStream; PowerTabOutputStream streamOut(testStream.GetOutputStream()); // Write test data to stream Barline barlineOut(12, Barline::repeatEnd, 12); barlineOut.Serialize(streamOut); // Output must be OK before using input if (testStream.CheckOutputState()) { PowerTabInputStream streamIn(testStream.GetInputStream()); // Read test data back from stream Barline barlineIn; barlineIn.Deserialize(streamIn, PowerTabFileHeader::FILEVERSION_CURRENT); // Validate the data ok = ((barlineIn == barlineOut) && (streamIn.CheckState())); } TEST(wxT("Serialize"), ok); return (true); }
void PaeInput::convertMeasure(MeasureObject *measure ) { if ( measure->clef != NULL ) { m_layer->AddLayerElement(measure->clef); } if ( measure->key != NULL) { m_layer->AddLayerElement(measure->key); } if ( measure->meter != NULL ) { m_layer->AddLayerElement(measure->meter); } if ( measure->wholerest > 0 ) { MultiRest *mr = new MultiRest(); mr->SetNum(measure->wholerest); m_layer->AddLayerElement(mr); } m_nested_objects.clear(); for (unsigned int i=0; i<measure->notes.size(); i++) { NoteObject note = measure->notes[i]; parseNote(note); } // Set barLine // FIXME use flags for proper barLine identification Barline *bline = m_measure->GetRightBarline(); bline->SetRend( measure->barLine ); }
/// Tests the Rehearsal Sign Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseRehearsalSign() { //------Last Checked------// // - Jan 4, 2005 RehearsalSign rehearsalSign('Z', wxT("Test")); Barline barline; barline.SetRehearsalSign(rehearsalSign); TEST(wxT("SetRehearsalSign"), (barline.GetRehearsalSignConstRef() == rehearsalSign) ); return (true); }
/// Tests the Time Signature Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseTimeSignature() { //------Last Checked------// // - Jan 4, 2005 TimeSignature timeSignature(12,8); Barline barline; barline.SetTimeSignature(timeSignature); TEST(wxT("SetTimeSignature"), (barline.GetTimeSignatureConstRef() == timeSignature) ); return (true); }
/// Tests the Key Signature Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseKeySignature() { //------Last Checked------// // - Jan 4, 2005 KeySignature keySignature(KeySignature::minorKey, KeySignature::fiveSharps); Barline barline; barline.SetKeySignature(keySignature); TEST(wxT("SetKeySignature"), (barline.GetKeySignatureConstRef() == keySignature) ); return (true); }
/// Tests the Barline Data Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseBarlineData() { //------Last Checked------// // - Jan 4, 2005 Barline barline; bool ok = barline.SetBarlineData(Barline::repeatEnd, 14); wxByte type = 0, repeatCount = 0; barline.GetBarlineData(type, repeatCount); TEST(wxT("SetBarlineData"), (ok) && (type == Barline::repeatEnd) && (repeatCount == 14) ); return (true); }
/// Tests the Repeat Count Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseRepeatCount() { //------Last Checked------// // - Jan 4, 2005 // TEST CASE: IsValidRepeatCount { TEST(wxT("IsValidRepeatCount - 0"), Barline::IsValidRepeatCount(0)); wxByte i = Barline::MIN_REPEAT_COUNT - 1; for (; i <= (Barline::MAX_REPEAT_COUNT + 1); i++) { TEST(wxString::Format(wxT("IsValidRepeatCount - %d"), i), (Barline::IsValidRepeatCount(i) == ((i >= Barline::MIN_REPEAT_COUNT) && (i <= Barline::MAX_REPEAT_COUNT))) ); } } // TEST CASE: SetRepeatCount { Barline barline; TEST(wxT("SetRepeatCount - 0"), (barline.SetRepeatCount(0) && (barline.GetRepeatCount() == 0))); wxByte i = Barline::MIN_REPEAT_COUNT - 1; for (; i <= (Barline::MAX_REPEAT_COUNT + 1); i++) { TEST(wxString::Format(wxT("SetRepeatCount - %d"), i), (barline.SetRepeatCount(i) == ((i >= Barline::MIN_REPEAT_COUNT) && (i <= Barline::MAX_REPEAT_COUNT))) && (((i < Barline::MIN_REPEAT_COUNT) || (i > Barline::MAX_REPEAT_COUNT)) ? 1 : (barline.GetRepeatCount() == i)) ); } } return (true); }
/// Tests the Type Functions /// @return True if all tests were executed, false if not bool BarlineTestSuite::TestCaseType() { //------Last Checked------// // - Jan 4, 2005 // TEST CASE: IsValidType { wxByte i = Barline::bar; for (; i <= (Barline::doubleBarFine + 1); i++) { TEST(wxString::Format(wxT("IsValidType - %d"), i), (Barline::IsValidType(i) == (i <= Barline::doubleBarFine)) ); } } // TEST CASE: SetType { Barline barline; wxByte i = Barline::bar; for (; i <= (Barline::doubleBarFine + 1); i++) { TEST(wxString::Format(wxT("SetType - %d"), i), (barline.SetType(i) == (i <= Barline::doubleBarFine)) && ((i > Barline::doubleBarFine) ? 1 : ((barline.GetType() == i)) && (barline.IsBar() == (i == Barline::bar)) && (barline.IsDoubleBar() == (i == Barline::doubleBar)) && (barline.IsFreeTimeBar() == (i == Barline::freeTimeBar)) && (barline.IsRepeatStart() == (i == Barline::repeatStart)) && (barline.IsRepeatEnd() == (i == Barline::repeatEnd)) && (barline.IsDoubleBarFine() == (i == Barline::doubleBarFine))) ); } } return (true); }
void PowerTabOldImporter::convert(const PowerTabDocument::Barline &oldBar, Barline &bar) { bar.setPosition(oldBar.GetPosition()); bar.setBarType(static_cast<Barline::BarType>(oldBar.GetType())); bar.setRepeatCount(oldBar.GetRepeatCount()); if (oldBar.GetRehearsalSign().IsSet()) { RehearsalSign sign; convert(oldBar.GetRehearsalSign(), sign); bar.setRehearsalSign(sign); } KeySignature key; convert(oldBar.GetKeySignature(), key); bar.setKeySignature(key); TimeSignature time; convert(oldBar.GetTimeSignature(), time); bar.setTimeSignature(time); }
void PowerTabOldImporter::convert(const PowerTabDocument::Score &oldScore, PowerTabDocument::Score::SystemConstPtr oldSystem, System &system) { // Ensure that there are a reasonable number of positions in the staff // so that things aren't too stretched out. int lastPosition = 30; // Import barlines. Barline &startBar = system.getBarlines()[0]; convert(*oldSystem->GetStartBar(), startBar); Barline &endBar = system.getBarlines()[1]; convert(*oldSystem->GetEndBar(), endBar); for (size_t i = 0; i < oldSystem->GetBarlineCount(); ++i) { Barline bar; convert(*oldSystem->GetBarline(i), bar); system.insertBarline(bar); lastPosition = std::max(lastPosition, bar.getPosition()); // Copy the key and time signature of the last bar into the end bar, // since the v2.0 file format expects this. if (i == oldSystem->GetBarlineCount() - 1) { KeySignature key = bar.getKeySignature(); key.setVisible(false); system.getBarlines().back().setKeySignature(key); TimeSignature time = bar.getTimeSignature(); time.setVisible(false); system.getBarlines().back().setTimeSignature(time); } } // Import tempo markers. std::vector<std::shared_ptr<PowerTabDocument::TempoMarker>> tempos; oldScore.GetTempoMarkersInSystem(tempos, oldSystem); for (auto &tempo : tempos) { TempoMarker marker; convert(*tempo, marker); system.insertTempoMarker(marker); } // Import alternate endings. std::vector<std::shared_ptr<PowerTabDocument::AlternateEnding>> endings; oldScore.GetAlternateEndingsInSystem(endings, oldSystem); for (auto &ending : endings) { AlternateEnding newEnding; convert(*ending, newEnding); system.insertAlternateEnding(newEnding); } // Import directions. for (size_t i = 0; i < oldSystem->GetDirectionCount(); ++i) { Direction direction; convert(*oldSystem->GetDirection(i), direction); system.insertDirection(direction); } // Import chord text symbols. for (size_t i = 0; i < oldSystem->GetChordTextCount(); ++i) { ChordText chord; convert(*oldSystem->GetChordText(i), chord); system.insertChord(chord); } std::vector<PowerTabDocument::Score::DynamicPtr> dynamics; oldScore.GetDynamicsInSystem(dynamics, oldSystem); // Import staves. for (size_t i = 0; i < oldSystem->GetStaffCount(); ++i) { // Dynamics are now stored in the staff instead of the system. std::vector<PowerTabDocument::Score::DynamicPtr> dynamicsInStaff; for (auto &dynamic : dynamics) { if (dynamic->GetStaff() == i) dynamicsInStaff.push_back(dynamic); } Staff staff; int lastPosInStaff = convert(*oldSystem->GetStaff(i), dynamicsInStaff, staff); system.insertStaff(staff); lastPosition = std::max(lastPosition, lastPosInStaff); } system.getBarlines().back().setPosition(lastPosition + 1); }
/// Performs deserialization for the class /// @param stream Power Tab input stream to load from /// @param version File version /// @return True if the object was deserialized, false if not bool System::DoDeserialize(PowerTabInputStream& stream, wxWord version) { //------Last Checked------// // - Jan 14, 2005 // Version 1.0 and 1.0.2 if (version == PowerTabFileHeader::FILEVERSION_1_0 || version == PowerTabFileHeader::FILEVERSION_1_0_2) { wxByte key; wxWord endBar; stream.ReadMFCRect(m_rect); wxCHECK(stream.CheckState(), false); stream >> key >> endBar >> m_positionSpacing >> m_rhythmSlashSpacingAbove >> m_rhythmSlashSpacingBelow >> m_extraSpacing; wxCHECK(stream.CheckState(), false); // Update the key signature at start of section (always shown) wxByte keyType = (wxByte)((key >> 4) & 0xf); wxByte keyAccidentals = (wxByte)(key & 0xf); m_startBar.GetKeySignatureRef().Show(); // Cancellation if (keyType > 2) m_startBar.GetKeySignatureRef().SetCancellation(); keyType = (wxByte)(((keyType % 2) == 1) ? KeySignature::majorKey : KeySignature::minorKey); m_startBar.GetKeySignatureRef().SetKey(keyType, keyAccidentals); // Update the ending bar wxByte barType = HIBYTE(endBar); wxByte repeatCount = LOBYTE(endBar); m_endBar.SetBarlineData(barType, repeatCount); //SetEndBar(barType, repeatCount); m_directionArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_chordTextArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_rhythmSlashArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_staffArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); m_barlineArray.Deserialize(stream, version); wxCHECK(stream.CheckState(), false); // Any barline at position zero is now stored in the section m_startBar if (GetBarlineCount() > 0) { Barline* barline = m_barlineArray[0]; if (barline != NULL) { if (barline->GetPosition() == 0) { m_startBar = *barline; delete barline; m_barlineArray.RemoveAt(0); } } } // Update key signs that aren't show to match active key sign KeySignature* activeKeySignature = m_startBar.GetKeySignaturePtr(); size_t i = 0; size_t count = m_barlineArray.GetCount(); for (; i < count; i++) { KeySignature& keySignature = m_barlineArray[i]->GetKeySignatureRef(); // Key on bar doesn't match active if (keySignature != *activeKeySignature) { // Key isn't shown, update key to match if (!keySignature.IsShown()) { keySignature = *activeKeySignature; keySignature.Hide(); keySignature.SetCancellation(false); } // Update active key activeKeySignature = m_barlineArray[i]->GetKeySignaturePtr(); } } }
/// Command Events ///< This code demonstrates how to parse a loaded Power Tab document ///< You could also load a document directly using Load void PowerTabView::OnTestParseFile(wxCommandEvent& event) { // Menu Test -> Parse File //------Last Checked------// // - Jan 25, 2005 WXUNUSED(event); // Get the active document PowerTabDocument* document = (PowerTabDocument*)GetDocument(); wxCHECK2(document != NULL, return); wxLongLong startTime = ::wxGetLocalTimeMillis(); // Get the header PowerTabFileHeader& header = document->GetHeaderRef(); // File version that the file was saved as; the document automatically // converts to the latest version during deserialization wxWord version = header.GetVersion(); // In Power Tab Editor v1.7, most of the header data is accessable via the Song Property Sheet: // Menu View -> File Information // Menu View -> Performance Notes // Menu View -> Lyrics // File is a song if (header.IsSong()) { wxByte contentType = header.GetSongContentType(); wxString title = header.GetSongTitle(); wxString artist = header.GetSongArtist(); wxByte releaseType = header.GetSongReleaseType(); // Audio release if (releaseType == PowerTabFileHeader::RELEASETYPE_PUBLIC_AUDIO) { wxByte releaseType = header.GetSongAudioReleaseType(); wxString releaseTitle = header.GetSongAudioReleaseTitle(); wxWord year = header.GetSongAudioReleaseYear(); bool live = header.IsSongAudioReleaseLive(); } // Video release else if (releaseType == PowerTabFileHeader::RELEASETYPE_PUBLIC_VIDEO) { wxString releaseTitle = header.GetSongVideoReleaseTitle(); bool live = header.IsSongVideoReleaseLive(); } // Bootleg else if (releaseType == PowerTabFileHeader::RELEASETYPE_BOOTLEG) { wxString releaseTitle = header.GetSongBootlegTitle(); wxDateTime bootlegDate = header.GetSongBootlegDate(); } // Not released else if (releaseType == PowerTabFileHeader::RELEASETYPE_NOTRELEASED) { // no extra data for this data } // If author is known, get the composer and lyricist; otherwise, song is traditional if (header.GetSongAuthorType() == PowerTabFileHeader::AUTHORTYPE_AUTHORKNOWN) { wxString composer = header.GetSongComposer(); wxString lyricist = header.GetSongLyricist(); } wxString arranger = header.GetSongArranger(); wxString guitarScoreTranscriber = header.GetSongGuitarScoreTranscriber(); wxString bassScoreTranscriber = header.GetSongBassScoreTranscriber(); wxString copyright = header.GetSongCopyright(); wxString lyrics = header.GetSongLyrics(); wxString guitarScoreNotes = header.GetSongGuitarScoreNotes(); wxString bassScoreNotes = header.GetSongBassScoreNotes(); } // File is a lesson else if (header.IsLesson()) { wxString title = header.GetLessonTitle(); wxString subtitle = header.GetLessonSubtitle(); wxWord musicStyle = header.GetLessonMusicStyle(); wxByte level = header.GetLessonLevel(); wxString author = header.GetLessonAuthor(); wxString notes = header.GetLessonNotes(); wxString copyright = header.GetLessonCopyright(); } wxUint8 scoreIndex = 0; // There are two scores in each document: // 1) Guitar score // 2) Bass score for (; scoreIndex < 2; scoreIndex++) { // Get the score Score* score = NULL; if (scoreIndex == 0) score = document->GetGuitarScore(); else score = document->GetBassScore(); wxCHECK2(score != NULL, continue); // Parse the guitars in the score // In Power Tab Editor v1.7, the guitar data can be accessed via the Guitar Property Sheet: // Menu Guitar -> Setup wxUint32 guitarIndex = 0; wxUint32 guitarCount = score->GetGuitarCount(); for (; guitarIndex < guitarCount; guitarIndex++) { Guitar* guitar = score->GetGuitar(guitarIndex); wxCHECK2(guitar != NULL, continue); wxByte number = guitar->GetNumber(); wxString description = guitar->GetDescription(); wxByte preset = guitar->GetPreset(); wxByte initialVolume = guitar->GetInitialVolume(); wxByte pan = guitar->GetPan(); wxByte reverb = guitar->GetReverb(); wxByte chorus = guitar->GetChorus(); wxByte tremolo = guitar->GetTremolo(); wxByte phaser = guitar->GetPhaser(); wxByte capo = guitar->GetCapo(); const Tuning& tuning = guitar->GetTuning(); wxString name = tuning.GetName(); wxInt8 musicNotationOffset = tuning.GetMusicNotationOffset(); bool usesSharps = tuning.UsesSharps(); // Get the MIDI note pitch for each string, starting with the highest string // Highest string = High E on standard guitar tuning size_t string = 0; size_t stringCount = tuning.GetStringCount(); for (; string < stringCount; string++) { // MIDI note pitch (see MIDI_NOTE_xx constants in generalmidi.h) wxByte note = tuning.GetNote(string); } } // Parse the chord diagrams in the score // In Power Tab Editor v1.7, chord diagrams can be accessed via the Guitar Property Sheet: // Menu Guitar -> Chord Diagram List // The chord diagrams appear in the Chord Diagram List in the order they are stored in the chord diagram // array in the score wxUint32 chordDiagramIndex = 0; wxUint32 chordDiagramCount = score->GetChordDiagramCount(); for (; chordDiagramIndex < chordDiagramCount; chordDiagramIndex++) { ChordDiagram* chordDiagram = score->GetChordDiagram(chordDiagramIndex); wxCHECK2(chordDiagram != NULL, continue); // In Power Tab Editor v1.7, chord name data can be accessed via the Chord Name dialog: // Menu Text -> Chord Name const ChordName& chordName = chordDiagram->GetChordNameConstRef(); wxByte tonicKey = 0; wxByte tonicKeyVariation = 0; chordName.GetTonic(tonicKey, tonicKeyVariation); wxByte bassNoteKey = 0; wxByte bassNoteKeyVariation = 0; chordName.GetBassNote(bassNoteKey, bassNoteKeyVariation); wxByte formula = chordName.GetFormula(); bool brackets = chordName.HasBrackets(); bool noChord = chordName.IsNoChord(); wxWord formulaModificationFlag = ChordName::extended9th; for (; formulaModificationFlag <= ChordName::suspended4th; formulaModificationFlag *= 2) { if (chordName.IsFormulaModificationFlagSet(formulaModificationFlag)) { } // Block overflow if (formulaModificationFlag == ChordName::suspended4th) break; } if (chordName.IsFretPositionUsed()) { wxByte fretPosition = chordName.GetFretPosition(); } if (chordName.IsTypeUsed()) { wxByte type = chordName.GetType(); } wxByte topFret = chordDiagram->GetTopFret(); size_t string = 0; size_t stringCount = chordDiagram->GetStringCount(); for (; string < stringCount; string++) { wxByte fretNumber = chordDiagram->GetFretNumber(string); } } // Parse the floating text items in the score // In Power Tab Editor v1.7, floating text items are created using: // Menu Text -> Insert // Floating text items are stored in the array by order of their rect.top and // rect.left values // i.e. An item at left = 40, top = 100 is stored prior to left = 10, top = 120 wxUint32 floatingTextIndex = 0; wxUint32 floatingTextCount = score->GetFloatingTextCount(); for (; floatingTextIndex < floatingTextCount; floatingTextIndex++) { FloatingText* floatingText = score->GetFloatingText(floatingTextIndex); wxCHECK2(floatingText != NULL, continue); wxString text = floatingText->GetText(); wxRect rect = floatingText->GetRect(); wxByte alignment = floatingText->GetAlignment(); bool border = floatingText->HasBorder(); // Font setting for the text const FontSetting& fontSetting = floatingText->GetFontSettingConstRef(); wxString faceName = fontSetting.GetFaceName(); wxInt32 pointSize = fontSetting.GetPointSize(); wxInt32 weight = fontSetting.GetWeight(); bool italic = fontSetting.IsItalic(); bool underline = fontSetting.IsUnderline(); bool strikeOut = fontSetting.IsStrikeOut(); wxColor color = fontSetting.GetColor(); } // Parse the guitar ins in the score // In Power Tab Editor v1.7, guitar ins can be accessed via the Guitar In dialog: // Menu Guitar -> Guitar In // Guitar Ins are stored in the array by order of their system, position and // staff values wxUint32 guitarInIndex = 0; wxUint32 guitarInCount = score->GetGuitarInCount(); for (; guitarInIndex < guitarInCount; guitarInIndex++) { GuitarIn* guitarIn = score->GetGuitarIn(guitarInIndex); wxCHECK2(guitarIn != NULL, continue); wxWord system = guitarIn->GetSystem(); wxByte staff = guitarIn->GetStaff(); wxByte position = guitarIn->GetPosition(); if (guitarIn->HasStaffGuitarsSet()) { wxByte staffGuitars = guitarIn->GetStaffGuitars(); } if (guitarIn->HasRhythmSlashGuitarsSet()) { wxByte rhythmSlashGuitars = guitarIn->GetRhythmSlashGuitars(); } } // Parse the tempo markers in the score // In Power Tab Editor v1.7, tempo markers can be accessed via the Tempo Marker dialog: // Menu Music Symbols -> Tempo Marker // and the Alteration of Pace dialog: // Menu Music Symbols -> Alteration of Pace // Tempo Markers are stored in the array by order of their system, position and // staff values wxUint32 tempoMarkerIndex = 0; wxUint32 tempoMarkerCount = score->GetTempoMarkerCount(); for (; tempoMarkerIndex < tempoMarkerCount; tempoMarkerIndex++) { TempoMarker* tempoMarker = score->GetTempoMarker(tempoMarkerIndex); wxCHECK2(tempoMarker != NULL, continue); if (tempoMarker->IsStandardMarker()) { wxByte beatType = tempoMarker->GetBeatType(); wxUint32 beatsPerMinute = tempoMarker->GetBeatsPerMinute(); } else if (tempoMarker->IsListesso()) { wxByte beatType = tempoMarker->GetBeatType(); wxByte listessoBeatType = tempoMarker->GetBeatType(); } else if (tempoMarker->IsAlterationOfPace()) { if (tempoMarker->IsAccelerando()) { } else if (tempoMarker->IsRitardando()) { } } if (tempoMarker->HasTripletFeel()) { wxByte tripletFeelType = tempoMarker->GetTripletFeelType(); } wxString description = tempoMarker->GetDescription(); } // Parse the dynamics in the score // In Power Tab Editor v1.7, dynamics can be accessed via the Dynamic dialog: // Menu Music Symbols -> Dynamic // Dynamics are stored in the array by order of their system, position and // staff values wxUint32 dynamicIndex = 0; wxUint32 dynamicCount = score->GetDynamicCount(); for (; dynamicIndex < dynamicCount; dynamicIndex++) { Dynamic* dynamic = score->GetDynamic(dynamicIndex); wxCHECK2(dynamic != NULL, continue); wxWord system = dynamic->GetSystem(); wxByte staff = dynamic->GetStaff(); wxByte position = dynamic->GetPosition(); // Staff volume is set if (dynamic->IsStaffVolumeSet()) { wxByte staffVolume = dynamic->GetStaffVolume(); } // Rhythm slash volume is set if (dynamic->IsRhythmSlashVolumeSet()) { wxByte rhythmSlashVolume = dynamic->GetRhythmSlashVolume(); } } // Parse the alternate endings in the score // In Power Tab Editor v1.7, alternate endings can be accessed via the Repeat Ending dialog: // Menu Music Symbols -> Repeat Ending // Alternate endings are stored in the array by order of their system and // position values wxUint32 alternateEndingIndex = 0; wxUint32 alternateEndingCount = score->GetAlternateEndingCount(); for (; alternateEndingIndex < alternateEndingCount; alternateEndingIndex++) { AlternateEnding* alternateEnding = score->GetAlternateEnding(alternateEndingIndex); wxCHECK2(alternateEnding != NULL, continue); wxWord system = alternateEnding->GetSystem(); wxByte position = alternateEnding->GetPosition(); // Determine which numbers are set wxWord number = 1; for (; number <= AlternateEnding::dalSegnoSegno; number++) { if (alternateEnding->IsNumberSet(number)) { // Number is set } } } // Parse the systems in the score // In Power Tab Editor v1.7, systems can be accessed via the Section menu: // Menu Section -> New Section // Systems are stored in the array by order they are drawn in the score wxUint32 systemIndex = 0; wxUint32 systemCount = score->GetSystemCount(); for (; systemIndex < systemCount; systemIndex++) { System* system = score->GetSystem(systemIndex); wxCHECK2(system != NULL, continue); wxRect rect = system->GetRect(); wxByte positionSpacing = system->GetPositionSpacing(); // Parse the directions in the system // In Power Tab Editor v1.7, directions can be accessed via the Musical Direction dialog: // Menu Music Symbols -> Musical Direction wxUint32 directionIndex = 0; wxUint32 directionCount = system->GetDirectionCount(); for (; directionIndex < directionCount; directionIndex++) { Direction* direction = system->GetDirection(directionIndex); wxCHECK2(direction != NULL, continue); wxUint32 position = direction->GetPosition(); // There may be up to 3 symbols per object size_t symbolIndex = 0; size_t symbolCount = direction->GetSymbolCount(); for (; symbolIndex < symbolCount; symbolIndex++) { wxByte symbolType = 0; wxByte activeSymbol = 0; wxByte repeatNumber = 0; direction->GetSymbol(symbolIndex, symbolType, activeSymbol, repeatNumber); } } // Parse the chord text items in the system // In Power Tab Editor v1.7, chord text/chord name data can be accessed via the Chord Name dialog: // Menu Text -> Chord Name wxUint32 chordTextIndex = 0; wxUint32 chordTextCount = system->GetChordTextCount(); for (; chordTextIndex < chordTextCount; chordTextIndex++) { ChordText* chordText = system->GetChordText(chordTextIndex); wxCHECK2(chordText != NULL, continue); wxUint32 positon = chordText->GetPosition(); const ChordName& chordName = chordText->GetChordNameConstRef(); wxByte tonicKey = 0; wxByte tonicKeyVariation = 0; chordName.GetTonic(tonicKey, tonicKeyVariation); wxByte bassNoteKey = 0; wxByte bassNoteKeyVariation = 0; chordName.GetBassNote(bassNoteKey, bassNoteKeyVariation); wxByte formula = chordName.GetFormula(); bool brackets = chordName.HasBrackets(); bool noChord = chordName.IsNoChord(); wxWord formulaModificationFlag = ChordName::extended9th; for (; formulaModificationFlag <= ChordName::suspended4th; formulaModificationFlag *= 2) { if (chordName.IsFormulaModificationFlagSet(formulaModificationFlag)) { } // Block overflow if (formulaModificationFlag == ChordName::suspended4th) break; } if (chordName.IsFretPositionUsed()) { wxByte fretPosition = chordName.GetFretPosition(); } if (chordName.IsTypeUsed()) { wxByte type = chordName.GetType(); } } // Parse the rhythm slashes in the system // In Power Tab Editor v1.7, rhythm slash data can be accessed via the Rhy. Slashes menu wxUint32 rhythmSlashIndex = 0; wxUint32 rhythmSlashCount = system->GetRhythmSlashCount(); for (; rhythmSlashIndex < rhythmSlashCount; rhythmSlashIndex++) { RhythmSlash* rhythmSlash = system->GetRhythmSlash(rhythmSlashIndex); wxCHECK2(rhythmSlash != NULL, continue); wxUint32 position = rhythmSlash->GetPosition(); wxByte durationType = rhythmSlash->GetDurationType(); wxByte previousDurationType = rhythmSlash->GetPreviousBeamDurationType(); bool beamStart = rhythmSlash->IsBeamStart(); bool fractionalBeam = rhythmSlash->HasFractionalBeam(); bool beamEnd = rhythmSlash->IsBeamEnd(); bool tripletStart = rhythmSlash->IsTripletStart(); bool tripletMiddle = rhythmSlash->IsTripletMiddle(); bool tripletEnd = rhythmSlash->IsTripletEnd(); bool dotted = rhythmSlash->IsDotted(); bool doubleDotted = rhythmSlash->IsDoubleDotted(); bool rest = rhythmSlash->IsRest(); bool tied = rhythmSlash->IsTied(); bool muted = rhythmSlash->IsMuted(); bool staccato = rhythmSlash->IsStaccato(); bool pickstrokeUp = rhythmSlash->HasPickStrokeUp(); bool pickstrokeDown = rhythmSlash->HasPickStrokeDown(); bool arpeggioUp = rhythmSlash->HasArpeggioUp(); bool arpeggioDown = rhythmSlash->HasArpeggioDown(); bool tripletFeel1st = rhythmSlash->IsTripletFeel1st(); bool tripletFeel2nd = rhythmSlash->IsTripletFeel2nd(); bool marcato = rhythmSlash->HasMarcato(); bool sforzando = rhythmSlash->HasSforzando(); bool slideIntoFromAbove = rhythmSlash->HasSlideIntoFromAbove(); bool slideIntoFromBelow = rhythmSlash->HasSlideIntoFromBelow(); bool slideOutOfDownwards = rhythmSlash->HasSlideOutOfDownwards(); bool slideOutOfUpwards = rhythmSlash->HasSlideOutOfUpwards(); // TODO: If has single note { wxByte stringNumber = 0; wxByte fretNumber = 0; rhythmSlash->GetSingleNoteData(stringNumber, fretNumber); } } // Parse the barline at the start of the system { const Barline& startBar = system->GetStartBarConstRef(); wxByte type = startBar.GetType(); if (startBar.IsRepeatEnd()) { wxUint32 repeatCount = startBar.GetRepeatCount(); } const KeySignature& keySignature = startBar.GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = startBar.GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = startBar.GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the barlines within the system wxUint32 barlineIndex = 0; wxUint32 barlineCount = system->GetBarlineCount(); for (; barlineIndex < barlineCount; barlineIndex++) { Barline* barline = system->GetBarline(barlineIndex); wxCHECK2(barline != NULL, continue); wxUint32 position = barline->GetPosition(); const KeySignature& keySignature = barline->GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = barline->GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = barline->GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the barline at the end of the system { const Barline& endBar = system->GetEndBarConstRef(); wxByte type = endBar.GetType(); if (endBar.IsRepeatEnd()) { wxUint32 repeatCount = endBar.GetRepeatCount(); } const KeySignature& keySignature = endBar.GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = endBar.GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = endBar.GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the staves in the system // In Power Tab Editor v1.7, staves can be accessed via the Section menu: // Menu Section -> Attach Staff // and by clicking the clef on the standard notation standard staff and // by clicking the "TAB" clef on the tablature staff wxUint32 staffIndex = 0; wxUint32 staffCount = system->GetStaffCount(); for (; staffIndex < staffCount; staffIndex++) { Staff* staff = system->GetStaff(staffIndex); wxCHECK2(staff != NULL, continue); wxByte clef = staff->GetClef(); wxByte tablatureStaffType = staff->GetTablatureStaffType(); // Parse the positions in each voice wxUint32 voice = 0; for (; voice < NUM_STAFF_VOICES; voice++) { wxUint32 positionIndex = 0; wxUint32 positionCount = staff->GetPositionCount(voice); for (; positionIndex < positionCount; positionIndex++) { Position* position = staff->GetPosition(voice, positionIndex); wxCHECK2(position != NULL, continue); wxUint32 positionIndex = 0; wxUint32 positionCount = staff->GetPositionCount(voice); for (; positionIndex < positionCount; positionIndex++) { Position* position = staff->GetPosition(voice, positionIndex); wxCHECK2(position != NULL, continue); wxUint32 position2 = position->GetPosition(); wxByte durationType = position->GetDurationType(); if (position->HasIrregularGroupingTiming()) { wxByte notesPlayed = 0; wxByte notesPlayedOver = 0; position->GetIrregularGroupingTiming(notesPlayed, notesPlayedOver); } wxByte previousBeamDurationType = position->GetPreviousBeamDurationType(); bool beamStart = position->IsBeamStart(); bool fractionalLeftBeam = position->HasFractionalLeftBeam(); bool fractionalRightBeam = position->HasFractionalRightBeam(); bool beamEnd = position->IsBeamEnd(); bool dotted = position->IsDotted(); bool doubleDotted = position->IsDoubleDotted(); bool rest = position->IsRest(); bool vibrato = position->HasVibrato(); bool wideVibrato = position->HasWideVibrato(); bool arpeggioUp = position->HasArpeggioUp(); bool arpeggioDown = position->HasArpeggioDown(); bool pickstrokeUp = position->HasPickStrokeUp(); bool pickstrokeDown = position->HasPickStrokeDown(); bool staccato = position->IsStaccato(); bool marcato = position->HasMarcato(); bool sforzando = position->HasSforzando(); bool tremoloPicking = position->HasTremoloPicking(); bool palmMuting = position->HasPalmMuting(); bool tap = position->HasTap(); bool acciaccatura = position->IsAcciaccatura(); bool tripletFeel1st = position->IsTripletFeel1st(); bool tripletFeel2nd = position->IsTripletFeel2nd(); bool letRing = position->HasLetRing(); bool fermata = position->HasFermata(); bool irregularGroupingStart = position->IsIrregularGroupingStart(); bool irregularGroupingMiddle = position->IsIrregularGroupingMiddle(); bool irregularGroupingEnd = position->IsIrregularGroupingEnd(); if (position->HasVolumeSwell()) { wxByte startVolume = 0; wxByte endVolume = 0; wxByte duration = 0; position->GetVolumeSwell(startVolume, endVolume, duration); } if (position->HasTremoloBar()) { wxByte type = 0; wxByte duration = 0; wxByte pitch = 0; position->GetTremoloBar(type, duration, pitch); } // Parse the notes // In Power Tab Editor v1.7, note data can be accessed via the Notes menu, as well as // the Tab Symbols menu wxUint32 noteIndex = 0; wxUint32 noteCount = position->GetNoteCount(); for (; noteIndex < noteCount; noteIndex++) { Note* note = position->GetNote(noteIndex); wxCHECK2(note != NULL, continue); wxUint32 string = note->GetString(); wxUint32 fretNumber = note->GetFretNumber(); bool tied = note->IsTied(); bool muted = note->IsMuted(); bool tieWrap = note->HasTieWrap(); bool hammerOn = note->HasHammerOn(); bool hammerOnFromNowhere = note->HasHammerOnFromNowhere(); bool pullOff = note->HasPullOff(); bool pullOffToNowhere = note->HasPullOffToNowhere(); bool naturalHarmonic = note->IsNaturalHarmonic(); bool ghostNote = note->IsGhostNote(); bool octave8va = note->IsOctave8va(); bool octave15ma = note->IsOctave15ma(); bool octave8vb = note->IsOctave8vb(); bool octave15mb = note->IsOctave15mb(); if (note->HasSlideInto()) { wxByte type = 0; note->GetSlideInto(type); } if (note->HasSlideOutOf()) { wxByte type = 0; wxInt8 steps = 0; note->GetSlideOutOf(type, steps); } if (note->HasBend()) { wxByte type = 0; wxByte bentPitch = 0; wxByte releasePitch = 0; wxByte duration = 0; wxByte drawStartPoint = 0; wxByte drawEndPoint = 0; note->GetBend(type, bentPitch, releasePitch, duration, drawStartPoint, drawEndPoint); } if (note->HasTappedHarmonic()) { wxByte tappedFretNumber = 0; note->GetTappedHarmonic(tappedFretNumber); } if (note->HasTrill()) { wxByte trilledFretNumber = 0; note->GetTrill(trilledFretNumber); } if (note->HasArtificialHarmonic()) { wxByte key = 0; wxByte keyVariation = 0; wxByte octave = 0; note->GetArtificialHarmonic(key, keyVariation, octave); } } } } } } } } // In Power Tab Editor v1.7, font settings can be accessed via the Song Property Sheet: // Menu View -> Fonts { const FontSetting& chordNameFontSetting = document->GetChordNameFontSettingConstRef(); wxString faceName = chordNameFontSetting.GetFaceName(); wxInt32 pointSize = chordNameFontSetting.GetPointSize(); wxInt32 weight = chordNameFontSetting.GetWeight(); bool italic = chordNameFontSetting.IsItalic(); bool underline = chordNameFontSetting.IsUnderline(); bool strikeOut = chordNameFontSetting.IsStrikeOut(); wxColor color = chordNameFontSetting.GetColor(); } { const FontSetting& tablatureNumbersFontSetting = document->GetTablatureNumbersFontSettingConstRef(); wxString faceName = tablatureNumbersFontSetting.GetFaceName(); wxInt32 pointSize = tablatureNumbersFontSetting.GetPointSize(); wxInt32 weight = tablatureNumbersFontSetting.GetWeight(); bool italic = tablatureNumbersFontSetting.IsItalic(); bool underline = tablatureNumbersFontSetting.IsUnderline(); bool strikeOut = tablatureNumbersFontSetting.IsStrikeOut(); wxColor color = tablatureNumbersFontSetting.GetColor(); } // In Power Tab Editor v1.7, tablature line spacing values can be accessed via the Line Height submenu // on the Section menu wxUint32 tablatureStaffLineSpacing = document->GetTablatureStaffLineSpacing(); // In Power Tab Editor v1.7, fade values can be accessed via the Fade dialog: // Menu Music Symbols -> Fade wxUint32 fadeIn = document->GetFadeIn(); wxUint32 fadeOut = document->GetFadeOut(); wxLongLong totalTime = ::wxGetLocalTimeMillis() - startTime; double milliseconds = ((double)totalTime.ToLong()) / 1000.0; wxMessageBox(wxString::Format(wxT("File parsed in %.3f seconds."), milliseconds), wxTheApp->GetAppName(), wxICON_INFORMATION); }