add not-broken looping code using seconds instead of samples (#944)
This commit is contained in:
parent
3e42588b51
commit
ad93dd8238
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user