aboutsummaryrefslogtreecommitdiff
path: root/src/aoblipplayer.cpp
diff options
context:
space:
mode:
authorstonedDiscord <stoned@derpymail.org>2019-03-12 19:53:06 +0100
committerstonedDiscord <stoned@derpymail.org>2019-03-12 19:53:06 +0100
commit0b6f376f8f635bfcfd72f621a1077a35efc72342 (patch)
treedebbf65a980916c531d8bf3b6ef32d29aeaf5ce8 /src/aoblipplayer.cpp
parent6e93d6e1bea8fd539499625f2a980acd83ef424e (diff)
qt can play the blips just fine
Diffstat (limited to 'src/aoblipplayer.cpp')
-rw-r--r--src/aoblipplayer.cpp70
1 files changed, 64 insertions, 6 deletions
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp
index 0a8b4279..b95f32a0 100644
--- a/src/aoblipplayer.cpp
+++ b/src/aoblipplayer.cpp
@@ -1,5 +1,6 @@
#include "aoblipplayer.h"
+#if defined(BASSAUDIO) //Using bass.dll for the blips
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
@@ -12,11 +13,9 @@ void AOBlipPlayer::set_blips(QString p_sfx)
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{
- #ifdef BASSAUDIO
BASS_StreamFree(m_stream_list[n_stream]);
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
- #endif
}
set_volume(m_volume);
@@ -30,11 +29,9 @@ void AOBlipPlayer::blip_tick()
m_cycle = 0;
HSTREAM f_stream = m_stream_list[f_cycle];
- #ifdef BASSAUDIO
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
BASS_ChannelPlay(f_stream, false);
- #endif
}
void AOBlipPlayer::set_volume(int p_value)
@@ -45,8 +42,69 @@ void AOBlipPlayer::set_volume(int p_value)
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{
- #ifdef BASSAUDIO
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
- #endif
}
}
+#elif defined(QTAUDIO) //Using Qt's QSoundEffect class
+AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
+{
+ m_parent = parent;
+ ao_app = p_ao_app;
+}
+
+void AOBlipPlayer::set_blips(QString p_sfx)
+{
+ QString f_path = ao_app->get_sounds_path(p_sfx);
+
+ for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
+ {
+ m_blips.setSource(QUrl::fromLocalFile(f_path));
+ }
+
+ set_volume(m_volume);
+}
+
+void AOBlipPlayer::blip_tick()
+{
+ int f_cycle = m_cycle++;
+
+ if (m_cycle == 5)
+ m_cycle = 0;
+
+ //HSTREAM f_stream = m_stream_list[f_cycle];
+ //if (ao_app->get_audio_output_device() != "default")
+ //BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
+ //BASS_ChannelPlay(f_stream, false);
+ m_blips.play();
+}
+
+void AOBlipPlayer::set_volume(int p_value)
+{
+ m_volume = p_value;
+
+ float volume = p_value / 100.0f;
+
+ m_blips.setVolume(volume);
+}
+#else //No audio
+AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
+{
+ m_parent = parent;
+ ao_app = p_ao_app;
+}
+
+void AOBlipPlayer::set_blips(QString p_sfx)
+{
+
+}
+
+void AOBlipPlayer::blip_tick()
+{
+
+}
+
+void AOBlipPlayer::set_volume(int p_value)
+{
+
+}
+#endif