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;
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;i<n;i++) {
tag = block->Tags.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;i<n;i++) {
syl = &syllables.at(i);
finalText += wxString::Format(_T("{\\k%i}"),syl->length) + syl->contents;
if (must_rebuild) {
for (size_t i=0;i<n;i++) {
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
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);
}

View file

@ -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<int> 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);

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.
- 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 ===========================