diff options
| author | in1tiate <32779090+in1tiate@users.noreply.github.com> | 2024-04-10 19:29:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-10 19:29:03 -0500 |
| commit | ad93dd82388c071a1ca5cdb2bff072e96c44265a (patch) | |
| tree | af8f0531e861e096ac245832a3845d4cdc95f2ca /src/aomusicplayer.cpp | |
| parent | 3e42588b51d979db81e639c173701552d6362a23 (diff) | |
add not-broken looping code using seconds instead of samples (#944)
Diffstat (limited to 'src/aomusicplayer.cpp')
| -rw-r--r-- | src/aomusicplayer.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 1bbcf5ad..b8c6dc60 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -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); @@ -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") |
