aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgameboyprinter <gameboyprinter@users.noreply.github.com>2018-08-29 00:26:34 -0500
committergameboyprinter <gameboyprinter@users.noreply.github.com>2018-08-29 00:26:34 -0500
commit2fed94b2d1e8f2c21c3b600a4bd8521da693a0da (patch)
tree9b1fe1160b7b06e93fdf4463f8b96b4529e2c045
parent49db357082bbef0b7a424ec07e5e656ab00e6335 (diff)
remove more bass dependencies
-rw-r--r--aoblipplayer.cpp27
-rw-r--r--aoblipplayer.h5
-rw-r--r--aosfxplayer.cpp18
-rw-r--r--aosfxplayer.h4
4 files changed, 15 insertions, 39 deletions
diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp
index 9e7d0e5d..089d428c 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 6b75ba28..22f58082 100644
--- a/aoblipplayer.h
+++ b/aoblipplayer.h
@@ -7,8 +7,7 @@
#include <QWidget>
#include <string.h>
#include <QDebug>
-
-const int BLIP_COUNT = 5;
+#include <QSoundEffect>
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 35c7c4e1..4a772e0c 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 4fd597c9..9fc7564c 100644
--- a/aosfxplayer.h
+++ b/aosfxplayer.h
@@ -1,12 +1,12 @@
#ifndef AOSFXPLAYER_H
#define AOSFXPLAYER_H
-#include "bass.h"
#include "aoapplication.h"
#include <QWidget>
#include <string.h>
#include <QDebug>
+#include <QSoundEffect>
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