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.
This commit is contained in:
Niels Martin Hansen 2006-01-27 22:22:31 +00:00
parent 360746e739
commit 69b1f5988a
3 changed files with 42 additions and 14 deletions

View file

@ -52,8 +52,10 @@ KaraokeSyllable::KaraokeSyllable() {
position = 0; position = 0;
display_w = 0; display_w = 0;
display_x = 0; display_x = 0;
tag = _T('\\k');
pending_splits.clear(); pending_splits.clear();
selected = false; selected = false;
original_tagdata = 0;
} }
@ -86,6 +88,7 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
} }
// Split // Split
must_rebuild = false;
bool hasKar = ParseDialogue(diag); bool hasKar = ParseDialogue(diag);
// No karaoke, autosplit // No karaoke, autosplit
@ -102,14 +105,13 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
/////////////////////////////// ///////////////////////////////
// Calculate length of karaoke // Calculate length of karaoke
int AudioKaraoke::GetKaraokeLength(AssDialogueBlockOverride *block) { AssOverrideTag * AudioKaraoke::GetKaraokeLength(AssDialogueBlockOverride *block) {
AssOverrideTag *tag; AssOverrideTag *tag, *len = 0;
size_t n = block->Tags.size(); size_t n = block->Tags.size();
int len = -1;
for (size_t i=0;i<n;i++) { for (size_t i=0;i<n;i++) {
tag = block->Tags.at(i); tag = block->Tags.at(i);
if (tag->Name == _T("\\k") || tag->Name == _T("\\K") || tag->Name == _T("\\kf") || tag->Name == _T("\\ko")) { 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; return len;
@ -132,12 +134,24 @@ void AudioKaraoke::Commit() {
wxString finalText = _T(""); wxString finalText = _T("");
KaraokeSyllable *syl; KaraokeSyllable *syl;
size_t n = syllables.size(); size_t n = syllables.size();
for (size_t i=0;i<n;i++) { if (must_rebuild) {
syl = &syllables.at(i); for (size_t i=0;i<n;i++) {
finalText += wxString::Format(_T("{\\k%i}"),syl->length) + syl->contents; syl = &syllables.at(i);
finalText += wxString::Format(_T("{%s%i}"), syl->tag, 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 // Load
must_rebuild = true;
AssDialogue newDiag(diag->data); AssDialogue newDiag(diag->data);
newDiag.Text = newText; newDiag.Text = newText;
newDiag.ParseASSTags(); newDiag.ParseASSTags();
@ -197,15 +212,17 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
block = curDiag->Blocks.at(i); block = curDiag->Blocks.at(i);
override = AssDialogueBlock::GetAsOverride(block); override = AssDialogueBlock::GetAsOverride(block);
if (override) { if (override) {
int len = GetKaraokeLength(override); AssOverrideTag *len = GetKaraokeLength(override);
if (len != -1) { if (len) {
if (foundOne) syllables.push_back(temp); if (foundOne) syllables.push_back(temp);
foundOne = true; foundOne = true;
foundBlock = true; foundBlock = true;
pos += temp.length; pos += temp.length;
temp.length = len; temp.length = len->Params.at(0)->AsInt();
temp.position = pos; temp.position = pos;
temp.contents = _T(""); temp.contents = _T("");
temp.tag = len->Name;
temp.original_tagdata = len->Params.at(0);
} }
} }
else { else {
@ -534,6 +551,7 @@ void AudioKaraoke::Join() {
curSyllable = first; curSyllable = first;
// Update // Update
must_rebuild = true;
display->NeedCommit = true; display->NeedCommit = true;
display->Update(); display->Update();
Refresh(false); Refresh(false);
@ -571,6 +589,7 @@ void AudioKaraoke::EndSplit(bool commit) {
// Update // Update
if (hasSplit) { if (hasSplit) {
must_rebuild = true;
display->NeedCommit = true; display->NeedCommit = true;
display->Update(); display->Update();
} }
@ -607,6 +626,7 @@ int AudioKaraoke::SplitSyl (int n) {
} }
temp.length = originalDuration * temp.contents.Length() / originalText.Length(); temp.length = originalDuration * temp.contents.Length() / originalText.Length();
temp.position = curpos; temp.position = curpos;
temp.tag = syllables[n].tag;
curpos += temp.length; curpos += temp.length;
syllables.insert(syllables.begin()+n+i+1, temp); syllables.insert(syllables.begin()+n+i+1, temp);
} }

View file

@ -48,6 +48,8 @@
// Prototypes // Prototypes
class AssDialogue; class AssDialogue;
class AssDialogueBlockOverride; class AssDialogueBlockOverride;
class AssOverrideTag;
class AssOverrideParameter;
class AudioDisplay; class AudioDisplay;
class AudioBox; class AudioBox;
@ -64,6 +66,8 @@ public:
wxString tag; wxString tag;
bool selected; bool selected;
AssOverrideParameter *original_tagdata;
std::vector<int> pending_splits; std::vector<int> pending_splits;
KaraokeSyllable(); KaraokeSyllable();
@ -81,11 +85,12 @@ class AudioKaraoke : public wxWindow {
private: private:
AssDialogue *diag; AssDialogue *diag;
int startClickSyl; int startClickSyl;
bool must_rebuild;
int split_cursor_syl; int split_cursor_syl;
int split_cursor_x; int split_cursor_x;
int GetKaraokeLength(AssDialogueBlockOverride *block); AssOverrideTag *GetKaraokeLength(AssDialogueBlockOverride *block);
wxString GetSyllableTag(AssDialogueBlockOverride *block,int n); wxString GetSyllableTag(AssDialogueBlockOverride *block,int n);
void AutoSplit(); void AutoSplit();
bool ParseDialogue(AssDialogue *diag); bool ParseDialogue(AssDialogue *diag);

View file

@ -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. 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 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) - 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 =========================== = 1.09 beta - 2006.01.16 ===========================