示例#1
0
void Lyrics::Clear()
{
   mSyllables.Clear();
   mText = wxT("");

   // Add two dummy syllables at the beginning
   mSyllables.Add(Syllable());
   mSyllables[0].t = -2.0;
   mSyllables.Add(Syllable());
   mSyllables[1].t = -1.0;

   mHighlightTextCtrl->Clear();
}
示例#2
0
void Lyrics::Finish(double finalT)
{
   // Add 3 dummy syllables at the end
   int i = mSyllables.GetCount();
   mSyllables.Add(Syllable());
   mSyllables[i].t = finalT + 1.0;
   mSyllables.Add(Syllable());
   mSyllables[i+1].t = finalT + 2.0;
   mSyllables.Add(Syllable());
   mSyllables[i+2].t = finalT + 3.0;

   // Mark measurements as invalid
   mMeasurementsDone = false; // only for drawn text
   mCurrentSyllable = 0;
   mHighlightTextCtrl->ShowPosition(0);
}
示例#3
0
Syllables syllabify(std::string word) {
    // syllabify the word
    SILP silp;
    FSXSTRING fsxWord(asWStr(word));
    size_t n = silp.silbita(&fsxWord);
    silp.silbivalted();

    // create the wrapper data structure
    Syllables syllables;
    syllables.reserve(n);

    // copy results
    for (int idx=0 ; idx<n ; ++idx) {
        const SILBISTR *silbistr = silp.silbid[idx];
        syllables.push_back(Syllable(asString(silbistr->silp), silbistr->valde, silbistr->rohk));
    }
    return syllables;
}
示例#4
0
void Lyrics::Add(double t, wxString syllable, wxString &highlightText)
{
   int i = mSyllables.GetCount();

   {
      Syllable &prevSyllable = mSyllables[i - 1];

      if (prevSyllable.t == t) {
         // We can't have two syllables with the same time, so append
         // this to the end of the previous one if they're at the
         // same time.
         prevSyllable.text += syllable;
         prevSyllable.textWithSpace += syllable;
         prevSyllable.char1 += syllable.Length();
         return;
      }
   }

   mSyllables.Add(Syllable());
   Syllable &thisSyllable = mSyllables[i];
   thisSyllable.t = t;
   thisSyllable.text = syllable;

   thisSyllable.char0 = mText.Length();

   // Put a space between syllables unless the previous one
   // ended in a hyphen
   if (i > 0 &&
         // mSyllables[i-1].text.Length() > 0 &&
         mSyllables[i - 1].text.Right(1) != wxT("-"))
      thisSyllable.textWithSpace = wxT(" ") + syllable;
   else
      thisSyllable.textWithSpace = syllable;

   mText += thisSyllable.textWithSpace;
   thisSyllable.char1 = mText.Length();

   int nTextLen = thisSyllable.textWithSpace.Length();
   if ((nTextLen > 0) && (thisSyllable.textWithSpace.Right(1) == wxT("_")))
      highlightText += (thisSyllable.textWithSpace.Left(nTextLen - 1) + wxT("\n"));
   else
      highlightText += thisSyllable.textWithSpace;
}
示例#5
0
void AssKaraoke::AddSplit(size_t syl_idx, size_t pos) {
	syls.insert(syls.begin() + syl_idx + 1, Syllable());
	Syllable &syl = syls[syl_idx];
	Syllable &new_syl = syls[syl_idx + 1];

	// If the syl is empty or the user is adding a syllable past the last
	// character then pos will be out of bounds. Doing this is a bit goofy,
	// but it's sometimes required for complex karaoke scripts
	if (pos < syl.text.size()) {
		new_syl.text = syl.text.substr(pos);
		syl.text = syl.text.substr(0, pos);
	}

	if (new_syl.text.empty())
		new_syl.duration = 0;
	else if (syl.text.empty()) {
		new_syl.duration = syl.duration;
		syl.duration = 0;
	}
	else {
		new_syl.duration = (syl.duration * new_syl.text.size() / (syl.text.size() + new_syl.text.size()) + 5) / 10 * 10;
		syl.duration -= new_syl.duration;
	}

	assert(syl.duration >= 0);

	new_syl.start_time = syl.start_time + syl.duration;
	new_syl.tag_type = syl.tag_type;

	// Move all override tags after the split to the new syllable and fix the indices
	size_t text_len = syl.text.size();
	for (auto it = syl.ovr_tags.begin(); it != syl.ovr_tags.end(); ) {
		if (it->first < text_len)
			++it;
		else {
			new_syl.ovr_tags[it->first - text_len] = it->second;
			syl.ovr_tags.erase(it++);
		}
	}

	if (!no_announce) AnnounceSyllablesChanged();
}