aboutsummaryrefslogtreecommitdiff
path: root/src/aoblipplayer.cpp
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2020-05-22 19:17:55 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2020-05-22 19:17:55 -0500
commitfd1855b8d0ecaa56ae3165ad5d8f3bd65ff77a64 (patch)
tree9c27d658dd8f19e649e1742b0fd39104a50a3ca6 /src/aoblipplayer.cpp
parent8928aa2718378bc42d20d5bbe6c17be68d65d6f3 (diff)
parent4617e3135ed14a28c4129154486022947fda9d82 (diff)
Merge KFO source unconditionally into AO2
Diffstat (limited to 'src/aoblipplayer.cpp')
-rw-r--r--src/aoblipplayer.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp
index 0355414d..39158fd2 100644
--- a/src/aoblipplayer.cpp
+++ b/src/aoblipplayer.cpp
@@ -9,13 +9,17 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
void AOBlipPlayer::set_blips(QString p_sfx)
{
- QString f_path = ao_app->get_sounds_path(p_sfx);
+ QString f_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx));
for (int n_stream = 0; n_stream < 5; ++n_stream) {
BASS_StreamFree(m_stream_list[n_stream]);
- m_stream_list[n_stream] = BASS_StreamCreateFile(
- FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
+ if (f_path.endsWith(".opus"))
+ m_stream_list[n_stream] = BASS_OPUS_StreamCreateFile(
+ FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
+ else
+ m_stream_list[n_stream] = BASS_StreamCreateFile(
+ FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
}
set_volume(m_volume);
@@ -23,6 +27,10 @@ void AOBlipPlayer::set_blips(QString p_sfx)
void AOBlipPlayer::blip_tick()
{
+ if (delay.isValid() && delay.elapsed() < max_blip_ms)
+ return;
+
+ delay.start();
int f_cycle = m_cycle++;
if (m_cycle == 5)
@@ -38,7 +46,9 @@ void AOBlipPlayer::set_volume(int p_value)
{
m_volume = p_value;
- float volume = p_value / 100.0f;
+void AOBlipPlayer::set_volume_internal(qreal p_value)
+{
+ float volume = static_cast<float>(p_value);
for (int n_stream = 0; n_stream < 5; ++n_stream) {
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
@@ -88,5 +98,7 @@ void AOBlipPlayer::set_blips(QString p_sfx) {}
void AOBlipPlayer::blip_tick() {}
-void AOBlipPlayer::set_volume(int p_value) {}
+void AOBlipPlayer::set_volume(qreal p_value) {}
+
+void AOBlipPlayer::set_volume_internal(qreal p_value) {}
#endif