remove more bass dependencies

This commit is contained in:
gameboyprinter 2018-08-29 00:26:34 -05:00
parent 49db357082
commit 2fed94b2d1
4 changed files with 15 additions and 39 deletions

View File

@ -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));
}

View File

@ -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

View File

@ -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));
}

View File

@ -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