Don't normalize syllable durations when parsing karaoke for automation

Originally committed to SVN as r6478.
This commit is contained in:
Thomas Goyne 2012-02-16 05:21:00 +00:00
parent 6339df3521
commit fc64bcaa36
3 changed files with 26 additions and 23 deletions

View file

@ -53,13 +53,13 @@ wxString AssKaraoke::Syllable::GetText(bool k_tag) const {
}
AssKaraoke::AssKaraoke(AssDialogue *line, bool auto_split)
AssKaraoke::AssKaraoke(AssDialogue *line, bool auto_split, bool normalize)
: no_announce(false)
{
if (line) SetLine(line, auto_split);
if (line) SetLine(line, auto_split, normalize);
}
void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
void AssKaraoke::SetLine(AssDialogue *line, bool auto_split, bool normalize) {
active_line = line;
line->ParseASSTags();
@ -133,6 +133,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
line->ClearBlocks();
if (normalize) {
// Normalize the syllables so that the total duration is equal to the line length
int end_time = active_line->End;
int last_end = syl.start_time + syl.duration;
@ -155,6 +156,7 @@ void AssKaraoke::SetLine(AssDialogue *line, bool auto_split) {
end_time = syls[i].start_time;
}
}
}
// Add karaoke splits at each space
if (auto_split && syls.size() == 1) {

View file

@ -65,10 +65,11 @@ public:
/// Constructor
/// @param line Initial line
/// @param auto_split Should the line automatically be split on spaces if there are no k tags?
AssKaraoke(AssDialogue *line = 0, bool auto_split = false);
/// @param normalize Should the total duration of the syllables be forced to equal the line duration?
AssKaraoke(AssDialogue *line = 0, bool auto_split = false, bool normalize = true);
/// Parse a dialogue line
void SetLine(AssDialogue *line, bool auto_split = false);
void SetLine(AssDialogue *line, bool auto_split = false, bool normalize = true);
/// Add a split before character pos in syllable syl_idx
void AddSplit(size_t syl_idx, size_t pos);

View file

@ -642,7 +642,7 @@ namespace Automation4 {
set_field(L, "text_stripped", "");
lua_rawseti(L, -2, idx++);
AssKaraoke kara(dia);
AssKaraoke kara(dia, false, false);
for (AssKaraoke::iterator it = kara.begin(); it != kara.end(); ++it) {
lua_newtable(L);
set_field(L, "duration", it->duration);