fix qaudio volume
This commit is contained in:
parent
2509cc5e0b
commit
4700902551
@ -21,15 +21,16 @@ public:
|
|||||||
|
|
||||||
void set_blips(QString p_sfx);
|
void set_blips(QString p_sfx);
|
||||||
void blip_tick();
|
void blip_tick();
|
||||||
void set_volume(int p_volume);
|
void set_volume(qreal p_volume);
|
||||||
|
void set_volume_internal(qreal p_volume);
|
||||||
|
|
||||||
int m_cycle = 0;
|
int m_cycle = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
qreal m_volume;
|
||||||
|
|
||||||
int m_volume;
|
|
||||||
#if defined(BASSAUDIO)
|
#if defined(BASSAUDIO)
|
||||||
HSTREAM m_stream_list[5];
|
HSTREAM m_stream_list[5];
|
||||||
#elif defined(QTAUDIO)
|
#elif defined(QTAUDIO)
|
||||||
|
@ -20,17 +20,19 @@ public:
|
|||||||
|
|
||||||
void play(QString p_sfx, QString p_char = "", QString shout = "");
|
void play(QString p_sfx, QString p_char = "", QString shout = "");
|
||||||
void stop();
|
void stop();
|
||||||
void set_volume(int p_volume);
|
void set_volume(qreal p_volume);
|
||||||
|
void set_volume_internal(qreal p_volume);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_parent;
|
QWidget *m_parent;
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
qreal m_volume = 0;
|
||||||
|
|
||||||
#if defined(BASSAUDIO)
|
#if defined(BASSAUDIO)
|
||||||
HSTREAM m_stream;
|
HSTREAM m_stream;
|
||||||
#elif defined(QTAUDIO)
|
#elif defined(QTAUDIO)
|
||||||
QSoundEffect m_sfx;
|
QSoundEffect m_sfx;
|
||||||
#endif
|
#endif
|
||||||
int m_volume = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AOSFXPLAYER_H
|
#endif // AOSFXPLAYER_H
|
||||||
|
@ -18,7 +18,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
|
|||||||
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_volume(m_volume);
|
set_volume_internal(m_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::blip_tick()
|
void AOBlipPlayer::blip_tick()
|
||||||
@ -34,11 +34,15 @@ void AOBlipPlayer::blip_tick()
|
|||||||
BASS_ChannelPlay(f_stream, false);
|
BASS_ChannelPlay(f_stream, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::set_volume(int p_value)
|
void AOBlipPlayer::set_volume(qreal p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
m_volume = p_value / 100;
|
||||||
|
set_volume_internal(m_volume);
|
||||||
|
}
|
||||||
|
|
||||||
float volume = p_value / 100.0f;
|
void AOBlipPlayer::set_volume_internal(qreal p_value)
|
||||||
|
{
|
||||||
|
float volume = p_value;
|
||||||
|
|
||||||
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
|
||||||
{
|
{
|
||||||
@ -61,7 +65,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
|
|||||||
m_blips.setSource(QUrl::fromLocalFile(f_path));
|
m_blips.setSource(QUrl::fromLocalFile(f_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
set_volume(m_volume);
|
set_volume_internal(m_volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::blip_tick()
|
void AOBlipPlayer::blip_tick()
|
||||||
@ -74,9 +78,14 @@ void AOBlipPlayer::blip_tick()
|
|||||||
m_blips.play();
|
m_blips.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::set_volume(int p_value)
|
void AOBlipPlayer::set_volume(qreal p_value)
|
||||||
|
{
|
||||||
|
m_volume = p_value / 100;
|
||||||
|
set_volume_internal(m_volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOBlipPlayer::set_volume_internal(qreal p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
|
||||||
m_blips.setVolume(m_volume);
|
m_blips.setVolume(m_volume);
|
||||||
}
|
}
|
||||||
#else //No audio
|
#else //No audio
|
||||||
@ -96,7 +105,12 @@ void AOBlipPlayer::blip_tick()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOBlipPlayer::set_volume(int p_value)
|
void AOBlipPlayer::set_volume(qreal p_value)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOBlipPlayer::set_volume_internal(qreal p_value)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,16 @@ void AOSfxPlayer::stop()
|
|||||||
BASS_ChannelStop(m_stream);
|
BASS_ChannelStop(m_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::set_volume(int p_value)
|
void AOSfxPlayer::set_volume(qreal p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
m_volume = p_value / 100;
|
||||||
float volume = p_value / 100.0f;
|
set_volume_internal(m_volume);
|
||||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
}
|
||||||
|
|
||||||
|
void AOSfxPlayer::set_volume_internal(qreal p_value)
|
||||||
|
{
|
||||||
|
float volume = p_value;
|
||||||
|
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||||
}
|
}
|
||||||
#elif defined(QTAUDIO) //Using Qt's QSoundEffect class
|
#elif defined(QTAUDIO) //Using Qt's QSoundEffect class
|
||||||
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
|
||||||
@ -83,7 +88,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
|
|||||||
{
|
{
|
||||||
m_sfx.setSource(QUrl::fromLocalFile(f_path));
|
m_sfx.setSource(QUrl::fromLocalFile(f_path));
|
||||||
|
|
||||||
set_volume(m_volume);
|
set_volume_internal(m_volume);
|
||||||
|
|
||||||
m_sfx.play();
|
m_sfx.play();
|
||||||
}
|
}
|
||||||
@ -94,9 +99,14 @@ void AOSfxPlayer::stop()
|
|||||||
m_sfx.stop();
|
m_sfx.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOSfxPlayer::set_volume(int p_value)
|
void AOSfxPlayer::set_volume(qreal p_value)
|
||||||
|
{
|
||||||
|
m_volume = p_value/100;
|
||||||
|
set_volume_internal(m_volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOSfxPlayer::set_volume_internal(qreal p_value)
|
||||||
{
|
{
|
||||||
m_volume = p_value;
|
|
||||||
m_sfx.setVolume(m_volume);
|
m_sfx.setVolume(m_volume);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user