fix qaudio volume
This commit is contained in:
parent
2509cc5e0b
commit
4700902551
@ -21,15 +21,16 @@ public:
|
||||
|
||||
void set_blips(QString p_sfx);
|
||||
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;
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
qreal m_volume;
|
||||
|
||||
int m_volume;
|
||||
#if defined(BASSAUDIO)
|
||||
HSTREAM m_stream_list[5];
|
||||
#elif defined(QTAUDIO)
|
||||
|
@ -20,17 +20,19 @@ public:
|
||||
|
||||
void play(QString p_sfx, QString p_char = "", QString shout = "");
|
||||
void stop();
|
||||
void set_volume(int p_volume);
|
||||
void set_volume(qreal p_volume);
|
||||
void set_volume_internal(qreal p_volume);
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
AOApplication *ao_app;
|
||||
qreal m_volume = 0;
|
||||
|
||||
#if defined(BASSAUDIO)
|
||||
HSTREAM m_stream;
|
||||
#elif defined(QTAUDIO)
|
||||
QSoundEffect m_sfx;
|
||||
QSoundEffect m_sfx;
|
||||
#endif
|
||||
int m_volume = 0;
|
||||
};
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
set_volume(m_volume);
|
||||
set_volume_internal(m_volume);
|
||||
}
|
||||
|
||||
void AOBlipPlayer::blip_tick()
|
||||
@ -34,11 +34,15 @@ void AOBlipPlayer::blip_tick()
|
||||
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)
|
||||
{
|
||||
@ -61,7 +65,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
|
||||
m_blips.setSource(QUrl::fromLocalFile(f_path));
|
||||
}
|
||||
|
||||
set_volume(m_volume);
|
||||
set_volume_internal(m_volume);
|
||||
}
|
||||
|
||||
void AOBlipPlayer::blip_tick()
|
||||
@ -74,9 +78,14 @@ void AOBlipPlayer::blip_tick()
|
||||
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);
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
||||
void AOSfxPlayer::set_volume(int p_value)
|
||||
void AOSfxPlayer::set_volume(qreal p_value)
|
||||
{
|
||||
m_volume = p_value;
|
||||
float volume = p_value / 100.0f;
|
||||
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
|
||||
m_volume = p_value / 100;
|
||||
set_volume_internal(m_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
|
||||
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));
|
||||
|
||||
set_volume(m_volume);
|
||||
set_volume_internal(m_volume);
|
||||
|
||||
m_sfx.play();
|
||||
}
|
||||
@ -94,9 +99,14 @@ void AOSfxPlayer::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);
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user