Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/aomusicplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,19 @@ QString AOMusicPlayer::play(QString p_song, int channel, bool loop,
if (loop && file_exists(d_path)) // Contains loop/etc. information file
{
QStringList lines = ao_app->read_file(d_path).split("\n");
bool seconds_mode = false;
foreach (QString line, lines) {
QStringList args = line.split("=");
if (args.size() < 2)
continue;
QString arg = args[0].trimmed();
if (arg == "seconds") {
if (args[1].trimmed() == "true") {
seconds_mode = true; // Use new epic behavior
continue;
}
continue;
}

float sample_rate;
BASS_ChannelGetAttribute(newstream, BASS_ATTRIB_FREQ, &sample_rate);
Expand All @@ -77,8 +85,15 @@ QString AOMusicPlayer::play(QString p_song, int channel, bool loop,
int num_channels = 2;

// Calculate the bytes for loop_start/loop_end to use with the sync proc
QWORD bytes = static_cast<QWORD>(args[1].trimmed().toUInt() *
sample_size * num_channels);
QWORD bytes;
if (seconds_mode) {
bytes =
BASS_ChannelSeconds2Bytes(newstream, args[1].trimmed().toDouble());
}
else {
bytes = static_cast<QWORD>(args[1].trimmed().toUInt() * sample_size *
num_channels);
}
if (arg == "loop_start")
loop_start[channel] = bytes;
else if (arg == "loop_length")
Expand Down