A modern C++ library for parsing common lyric file formats
- 📄 Multi-format support: Parse LRC, SRT, ESLyric, ASS and more
- ⚡ High performance: Optimized C++20 implementation
- 🧩 Extensible architecture: Easy to add new parsers
- 🏷️ Role assignment: Flexible lyric content role management
- 📊 Word-level timing: Support for karaoke-style word-by-word lyrics
| Format | Status | Parser | Modes Supported | Role Assignment |
|---|---|---|---|---|
| LRC | ✅ | lexy | Line & Word-by-word | ✅ |
| SRT | ✅ | lexy | Line-only | ✅ |
| ESLyric | ✅ | lexy | Line & Word-by-word | ✅ |
| ASS | ✅ | C++ | Line & Word-by-word | ❌ |
| KRC | ❌ | - | - | - |
| YRC | ❌ | - | - | - |
| QRC | ❌ | - | - | - |
| LYS | ❌ | - | - | - |
| TTML | ❌ | - | - | - |
| VTT | ❌ | - | - | - |
💡 Note: Missing sample files prevent development of certain formats. Contributions welcome!
- FProcess: Main entry point for parsing operations
- FLyricFile: Container for parsed lyrics and metadata
- FLyricGroup: Groups lyrics by time periods
- FLyricLine: Individual lyric lines with timing
- FLyricWord: Word-level timing data
- FLyricGroupRoleOption: Role assignment configuration
- IParser: Abstract parser interface
mermaid
graph TD
A[User Input: Format + Lyrics + Roles] --> B[FProcess::Process]
B --> C[Select Parser via GetParser]
C --> D[Parse Input String]
D --> E[Create FLyricGroups & Metadata]
E --> F[Process Individual Lines]
F --> G[Assign Roles via ApplyRole]
G --> H[Return FLyricFile]
FLyricFile
├── FLyricMetadata (key-value pairs)
└── std::vector<FLyricGroup>
└── FLyricGroup
├── Timestamps (start/end)
├── FLyricGroupRoleOption
└── std::vector<FLyricLine>
└── FLyricLine
├── Content & Timing
├── ELyricContentRole
├── word_by_word flag
└── std::vector<FLyricWord>
└── FLyricWord
├── Text content
└── Timestamps (start/end)
bash
# Clone the repository
git clone https://github.com/TypeDreamMoon/libdlp.git
cd libdlp
# Build using CMake
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
cpp
#include <dlp/Process.hpp>
#include <dlp/File.hpp>
// Define content roles
std::vector<dlp::ELyricContentRole> roles{
dlp::ELyricContentRole::Romanization, // First priority
dlp::ELyricContentRole::Lyric, // Second priority
dlp::ELyricContentRole::Translation // Third priority
};
// Create processor and parse
dlp::FProcess processor;
dlp::File::FLyricFile lyric_file = processor.Process(
dlp::EFileFormat::LRC, // File format
"Lyric content string...", // Input lyrics
{roles, dlp::ELyricContentRole::Lyric} // Role options
);
// Access parsed data
for (const auto& group : lyric_file.groups) {
for (const auto& line : group.parsed_lines) {
std::cout << "Role: " << static_cast<int>(line.role)
<< ", Content: " << line.lyric
<< ", Time: " << line.time_start.count()
<< std::endl;
}
}
cpp
// For karaoke-style lyrics with word-level timing
if (lyric_line.IsWordByWord()) {
for (const auto& word : lyric_line.parsed_words) {
std::cout << "Word: '" << word.word
<< "' starts at: " << word.time_start.count()
<< "ms, ends at: " << word.time_end.count()
<< "ms" << std::endl;
}
}
- C++20 compatible compiler (GCC 10+, Clang 10+, MSVC 19.28+)
- CMake 3.16+
- Git
bash
# Clone the repository
git clone https://github.com/TypeDreamMoon/libdlp.git
cd libdlp
# Configure and build
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
# Run tests (if available)
cd build && ./test_executable
We welcome contributions! Here are some ways you can help:
- Implement the
IParserinterface - Register your parser in
FProcess::GetParser - Update the format table in this README
Many formats are unimplemented due to lack of sample files. If you have sample lyric files for unsupported formats, please contribute them!
- Performance optimizations
- Better error handling
- Additional features
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter issues or have questions:
- Check the Issues section
- Open a new issue for bug reports or feature requests
- Contribute samples for unsupported formats
⭐ Star this repo if it helped you!
