remove more bass dependencies
This commit is contained in:
parent
49db357082
commit
2fed94b2d1
@ -2,44 +2,27 @@
|
|||||||
|
|
||||||
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
|
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||||
{
|
{
|
||||||
|
m_sfxplayer = new QSoundEffect;
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
ao_app = p_ao_app;
|
ao_app = p_ao_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::set_blips(QString p_sfx)
|
void AOBlipPlayer::set_blips(QString p_sfx)
|
||||||
{
|
{
|
||||||
|
m_sfxplayer->stop();
|
||||||
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
|
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
|
||||||
|
m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
set_volume(m_volume);
|
set_volume(m_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::blip_tick()
|
void AOBlipPlayer::blip_tick()
|
||||||
{
|
{
|
||||||
int f_cycle = m_cycle++;
|
m_sfxplayer->play();
|
||||||
|
|
||||||
if (m_cycle == BLIP_COUNT)
|
|
||||||
m_cycle = 0;
|
|
||||||
|
|
||||||
HSTREAM f_stream = m_stream_list[f_cycle];
|
|
||||||
|
|
||||||
BASS_ChannelPlay(f_stream, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::set_volume(int p_value)
|
void AOBlipPlayer::set_volume(int p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
m_volume = p_value;
|
||||||
|
|
||||||
float volume = p_value / 100.0f;
|
float volume = p_value / 100.0f;
|
||||||
|
m_sfxplayer->setVolume(qreal(volume));
|
||||||
for (int n_stream = 0 ; n_stream < BLIP_COUNT ; ++n_stream)
|
|
||||||
{
|
|
||||||
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QSoundEffect>
|
||||||
const int BLIP_COUNT = 5;
|
|
||||||
|
|
||||||
class AOBlipPlayer
|
class AOBlipPlayer
|
||||||
{
|
{
|
||||||
@ -24,9 +23,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
QSoundEffect *m_sfxplayer;
|
||||||
|
|
||||||
int m_volume;
|
int m_volume;
|
||||||
HSTREAM m_stream_list[BLIP_COUNT];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AOBLIPPLAYER_H
|
#endif // AOBLIPPLAYER_H
|
||||||
|
@ -2,41 +2,35 @@
|
|||||||
|
|
||||||
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||||
{
|
{
|
||||||
|
m_sfxplayer = new QSoundEffect;
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
ao_app = p_ao_app;
|
ao_app = p_ao_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::play(QString p_sfx, QString p_char)
|
void AOSfxPlayer::play(QString p_sfx, QString p_char)
|
||||||
{
|
{
|
||||||
BASS_ChannelStop(m_stream);
|
m_sfxplayer->stop();
|
||||||
|
|
||||||
p_sfx = p_sfx.toLower();
|
p_sfx = p_sfx.toLower();
|
||||||
|
|
||||||
QString f_path;
|
QString f_path;
|
||||||
|
|
||||||
if (p_char != "")
|
if (p_char != "")
|
||||||
f_path = ao_app->get_character_path(p_char) + p_sfx;
|
f_path = ao_app->get_character_path(p_char) + p_sfx;
|
||||||
else
|
else
|
||||||
f_path = ao_app->get_sounds_path() + p_sfx;
|
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);
|
set_volume(m_volume);
|
||||||
|
|
||||||
BASS_ChannelPlay(m_stream, false);
|
m_sfxplayer->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::stop()
|
void AOSfxPlayer::stop()
|
||||||
{
|
{
|
||||||
BASS_ChannelStop(m_stream);
|
m_sfxplayer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::set_volume(int p_value)
|
void AOSfxPlayer::set_volume(int p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
m_volume = p_value;
|
||||||
|
|
||||||
float volume = p_value / 100.0f;
|
float volume = p_value / 100.0f;
|
||||||
|
m_sfxplayer->setVolume(qreal(volume));
|
||||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#ifndef AOSFXPLAYER_H
|
#ifndef AOSFXPLAYER_H
|
||||||
#define AOSFXPLAYER_H
|
#define AOSFXPLAYER_H
|
||||||
|
|
||||||
#include "bass.h"
|
|
||||||
#include "aoapplication.h"
|
#include "aoapplication.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QSoundEffect>
|
||||||
|
|
||||||
class AOSfxPlayer
|
class AOSfxPlayer
|
||||||
{
|
{
|
||||||
@ -20,9 +20,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
QSoundEffect *m_sfxplayer;
|
||||||
|
|
||||||
int m_volume = 0;
|
int m_volume = 0;
|
||||||
HSTREAM m_stream;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AOSFXPLAYER_H
|
#endif // AOSFXPLAYER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user