diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp index 9e7d0e5..089d428 100644 --- a/aoblipplayer.cpp +++ b/aoblipplayer.cpp @@ -2,44 +2,27 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { + m_sfxplayer = new QSoundEffect; m_parent = parent; ao_app = p_ao_app; } void AOBlipPlayer::set_blips(QString p_sfx) { + m_sfxplayer->stop(); QString f_path = ao_app->get_sounds_path() + p_sfx.toLower(); - - for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++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); - } - + m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); } void AOBlipPlayer::blip_tick() { - int f_cycle = m_cycle++; - - if (m_cycle == BLIP_COUNT) - m_cycle = 0; - - HSTREAM f_stream = m_stream_list[f_cycle]; - - BASS_ChannelPlay(f_stream, false); + m_sfxplayer->play(); } void AOBlipPlayer::set_volume(int p_value) { m_volume = p_value; - float volume = p_value / 100.0f; - - for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream) - { - BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); - } + m_sfxplayer->setVolume(qreal(volume)); } diff --git a/aoblipplayer.h b/aoblipplayer.h index 6b75ba2..22f5808 100644 --- a/aoblipplayer.h +++ b/aoblipplayer.h @@ -7,8 +7,7 @@ #include #include #include - -const int BLIP_COUNT = 5; +#include class AOBlipPlayer { @@ -24,9 +23,9 @@ public: private: QWidget *m_parent; AOApplication *ao_app; + QSoundEffect *m_sfxplayer; int m_volume; - HSTREAM m_stream_list[BLIP_COUNT]; }; #endif // AOBLIPPLAYER_H diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp index 35c7c4e..4a772e0 100644 --- a/aosfxplayer.cpp +++ b/aosfxplayer.cpp @@ -2,41 +2,35 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { + m_sfxplayer = new QSoundEffect; m_parent = parent; ao_app = p_ao_app; } void AOSfxPlayer::play(QString p_sfx, QString p_char) { - BASS_ChannelStop(m_stream); - + m_sfxplayer->stop(); p_sfx = p_sfx.toLower(); - QString f_path; - if (p_char != "") f_path = ao_app->get_character_path(p_char) + p_sfx; else f_path = ao_app->get_sounds_path() + p_sfx; - m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); - + m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); - BASS_ChannelPlay(m_stream, false); + m_sfxplayer->play(); } void AOSfxPlayer::stop() { - BASS_ChannelStop(m_stream); + m_sfxplayer->stop(); } void AOSfxPlayer::set_volume(int p_value) { m_volume = p_value; - float volume = p_value / 100.0f; - - BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume); - + m_sfxplayer->setVolume(qreal(volume)); } diff --git a/aosfxplayer.h b/aosfxplayer.h index 4fd597c..9fc7564 100644 --- a/aosfxplayer.h +++ b/aosfxplayer.h @@ -1,12 +1,12 @@ #ifndef AOSFXPLAYER_H #define AOSFXPLAYER_H -#include "bass.h" #include "aoapplication.h" #include #include #include +#include class AOSfxPlayer { @@ -20,9 +20,9 @@ public: private: QWidget *m_parent; AOApplication *ao_app; + QSoundEffect *m_sfxplayer; int m_volume = 0; - HSTREAM m_stream; }; #endif // AOSFXPLAYER_H