diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2019-01-02 09:40:38 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-02 09:40:38 -0600 |
| commit | 4d93f059c01664ad074cf467e79a63b85e86beb0 (patch) | |
| tree | 57b8a9760796937e66e393b3bc00f4bee4337bdf /src/aoblipplayer.cpp | |
| parent | 6f1bce5882676ea7affe717a2f5a00b8c3b7fe12 (diff) | |
| parent | ec1057b5d7e1d39963275bc2cbd79a53cf6f3f5c (diff) | |
Merge pull request #54 from OmniTroid/master
Restructuring + better cross-platform support
Diffstat (limited to 'src/aoblipplayer.cpp')
| -rw-r--r-- | src/aoblipplayer.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp new file mode 100644 index 00000000..74757c50 --- /dev/null +++ b/src/aoblipplayer.cpp @@ -0,0 +1,47 @@ +#include "aoblipplayer.h" + +AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) +{ + m_parent = parent; + ao_app = p_ao_app; +} + +void AOBlipPlayer::set_blips(QString p_sfx) +{ + QString f_path = ao_app->get_sounds_path(p_sfx); + + for (int n_stream = 0 ; n_stream < 5 ; ++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); +} + +void AOBlipPlayer::blip_tick() +{ + int f_cycle = m_cycle++; + + if (m_cycle == 5) + m_cycle = 0; + + HSTREAM f_stream = m_stream_list[f_cycle]; + + if (ao_app->get_audio_output_device() != "default") + BASS_ChannelSetDevice(f_stream, BASS_GetDevice()); + BASS_ChannelPlay(f_stream, false); +} + +void AOBlipPlayer::set_volume(int p_value) +{ + m_volume = p_value; + + float volume = p_value / 100.0f; + + for (int n_stream = 0 ; n_stream < 5 ; ++n_stream) + { + BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume); + } +} |
