From 69b1f5988af4944008fbfd93e6c6bef13a7bc6da Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 27 Jan 2006 22:22:31 +0000 Subject: [PATCH] From changelog: o The correct \k tag (\k, \kf, \ko, \K) is now kept when splitting/joining o When editing karaoke-timing for a line and not splitting/joining, all tags are kept intact, so only the \k tag timings are changed (BROKEN WITH \t TAGS ATM!) Reason for breakage with \t seems to be the override tag parser killing all the actual style overrides in the \t tag. Example: \t(100,200,\fscx200) -> \t(100,200,) All other tags seem unaffected, but not intensively tested. Originally committed to SVN as r31. --- core/audio_karaoke.cpp | 44 ++++++++++++++++++++++++++++++------------ core/audio_karaoke.h | 7 ++++++- core/changelog.txt | 5 ++++- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/core/audio_karaoke.cpp b/core/audio_karaoke.cpp index 25be3a196..22e2e4d93 100644 --- a/core/audio_karaoke.cpp +++ b/core/audio_karaoke.cpp @@ -52,8 +52,10 @@ KaraokeSyllable::KaraokeSyllable() { position = 0; display_w = 0; display_x = 0; + tag = _T('\\k'); pending_splits.clear(); selected = false; + original_tagdata = 0; } @@ -86,6 +88,7 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) { } // Split + must_rebuild = false; bool hasKar = ParseDialogue(diag); // No karaoke, autosplit @@ -102,14 +105,13 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) { /////////////////////////////// // Calculate length of karaoke -int AudioKaraoke::GetKaraokeLength(AssDialogueBlockOverride *block) { - AssOverrideTag *tag; +AssOverrideTag * AudioKaraoke::GetKaraokeLength(AssDialogueBlockOverride *block) { + AssOverrideTag *tag, *len = 0; size_t n = block->Tags.size(); - int len = -1; for (size_t i=0;iTags.at(i); if (tag->Name == _T("\\k") || tag->Name == _T("\\K") || tag->Name == _T("\\kf") || tag->Name == _T("\\ko")) { - len = tag->Params.at(0)->AsInt(); + len = tag; } } return len; @@ -132,12 +134,24 @@ void AudioKaraoke::Commit() { wxString finalText = _T(""); KaraokeSyllable *syl; size_t n = syllables.size(); - for (size_t i=0;ilength) + syl->contents; + if (must_rebuild) { + for (size_t i=0;itag, syl->length) + syl->contents; + } + diag->Text = finalText; + diag->ParseASSTags(); + } else { + wxLogDebug(_T("Updating karaoke without rebuild")); + for (size_t i = 0; i < n; i++) { + wxLogDebug(_T("Updating syllable %d"), i); + syl = &syllables.at(i); + wxLogDebug(_T("Syllable pointer: %p; tagdata pointer: %p; length: %d"), syl, syl->original_tagdata, syl->length); + syl->original_tagdata->SetInt(syl->length); + } + wxLogDebug(_T("Done updating syllables")); + diag->UpdateText(); } - diag->Text = finalText; - diag->ParseASSTags(); } @@ -166,6 +180,7 @@ void AudioKaraoke::AutoSplit() { } // Load + must_rebuild = true; AssDialogue newDiag(diag->data); newDiag.Text = newText; newDiag.ParseASSTags(); @@ -197,15 +212,17 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) { block = curDiag->Blocks.at(i); override = AssDialogueBlock::GetAsOverride(block); if (override) { - int len = GetKaraokeLength(override); - if (len != -1) { + AssOverrideTag *len = GetKaraokeLength(override); + if (len) { if (foundOne) syllables.push_back(temp); foundOne = true; foundBlock = true; pos += temp.length; - temp.length = len; + temp.length = len->Params.at(0)->AsInt(); temp.position = pos; temp.contents = _T(""); + temp.tag = len->Name; + temp.original_tagdata = len->Params.at(0); } } else { @@ -534,6 +551,7 @@ void AudioKaraoke::Join() { curSyllable = first; // Update + must_rebuild = true; display->NeedCommit = true; display->Update(); Refresh(false); @@ -571,6 +589,7 @@ void AudioKaraoke::EndSplit(bool commit) { // Update if (hasSplit) { + must_rebuild = true; display->NeedCommit = true; display->Update(); } @@ -607,6 +626,7 @@ int AudioKaraoke::SplitSyl (int n) { } temp.length = originalDuration * temp.contents.Length() / originalText.Length(); temp.position = curpos; + temp.tag = syllables[n].tag; curpos += temp.length; syllables.insert(syllables.begin()+n+i+1, temp); } diff --git a/core/audio_karaoke.h b/core/audio_karaoke.h index 1c0a4c463..cb3c5b5fc 100644 --- a/core/audio_karaoke.h +++ b/core/audio_karaoke.h @@ -48,6 +48,8 @@ // Prototypes class AssDialogue; class AssDialogueBlockOverride; +class AssOverrideTag; +class AssOverrideParameter; class AudioDisplay; class AudioBox; @@ -64,6 +66,8 @@ public: wxString tag; bool selected; + AssOverrideParameter *original_tagdata; + std::vector pending_splits; KaraokeSyllable(); @@ -81,11 +85,12 @@ class AudioKaraoke : public wxWindow { private: AssDialogue *diag; int startClickSyl; + bool must_rebuild; int split_cursor_syl; int split_cursor_x; - int GetKaraokeLength(AssDialogueBlockOverride *block); + AssOverrideTag *GetKaraokeLength(AssDialogueBlockOverride *block); wxString GetSyllableTag(AssDialogueBlockOverride *block,int n); void AutoSplit(); bool ParseDialogue(AssDialogue *diag); diff --git a/core/changelog.txt b/core/changelog.txt index 58c0bca7f..0c4c29466 100644 --- a/core/changelog.txt +++ b/core/changelog.txt @@ -11,7 +11,10 @@ Please visit http://aegisub.net to download latest version o Fixed bug, triggered when a line had a style not defined in the subs. A warning is now shown instead. - Fixed bug in parser that would cause Aegisub to crash if you had a \fn without parameters and tried to pick font. (AMZ) - Fixed crash when opening audio that appeared in 1.08 (Myrsloik) -- Implemented new graphical, mouse-controlled karaoke syllable splitter (jfs) +- Karaoke mode changes: (jfs) + o New syllable-splitter: Click "split" to enable splitting-mode, click in syllable view to set split-markers, then click commit to do the splitting + o The correct \k tag (\k, \kf, \ko, \K) is now kept when splitting/joining + o When editing karaoke-timing for a line and not splitting/joining, all tags are kept intact, so only the \k tag timings are changed (BROKEN WITH \t TAGS ATM!) = 1.09 beta - 2006.01.16 ===========================