예제 #1
0
std::multimap<ReducedFraction, std::string>
extractLyricsFromTrack(const MidiTrack &lyricsTrack, int division)
      {
      std::multimap<ReducedFraction, std::string> lyrics;

      for (const auto &i: lyricsTrack.events()) {
            const auto& e = i.second;
            if (isLyricEvent(e)) {
                  const uchar* data = (uchar*)e.edata();
                  std::string text = MidiCharset::fromUchar(data);
                  if (isLyricText(text)) {
                        const auto tick = toMuseScoreTicks(i.first, division);
                                    // no charset handling here
                        lyrics.insert({tick, text});
                        }
                  }
            }
      return lyrics;
      }
bool isLyricsTrack(const MidiTrack &lyricsTrack)
      {
      bool lyricsFlag = false;

      for (const auto &i: lyricsTrack.events()) {
            const auto& e = i.second;
            if (isLyricEvent(e)) {
                  const uchar* data = (uchar*)e.edata();
                              // no charset handling here
                  std::string text = MidiCharset::fromUchar(data);
                  if (isLyricText(text)) {
                        if (!lyricsFlag)
                              lyricsFlag = true;
                        }
                  }
            else if (e.type() == ME_NOTE)
                  return false;
            }

      return lyricsFlag;
      }