makes all the bass stuff optional

This commit is contained in:
stonedDiscord 2019-03-12 00:26:40 +01:00
parent 2f759752b0
commit 49938eea0f
5 changed files with 30 additions and 4 deletions

View File

@ -12,9 +12,11 @@ void AOBlipPlayer::set_blips(QString p_sfx)
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{
#ifdef BASSAUDIO
BASS_StreamFree(m_stream_list[n_stream]);
m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
#endif
}
set_volume(m_volume);
@ -28,10 +30,11 @@ void AOBlipPlayer::blip_tick()
m_cycle = 0;
HSTREAM f_stream = m_stream_list[f_cycle];
#ifdef BASSAUDIO
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(f_stream, BASS_GetDevice());
BASS_ChannelPlay(f_stream, false);
#endif
}
void AOBlipPlayer::set_volume(int p_value)
@ -42,6 +45,8 @@ void AOBlipPlayer::set_volume(int p_value)
for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
{
#ifdef BASSAUDIO
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
#endif
}
}

View File

@ -8,11 +8,14 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
AOMusicPlayer::~AOMusicPlayer()
{
#ifdef BASSAUDIO
BASS_ChannelStop(m_stream);
#endif
}
void AOMusicPlayer::play(QString p_song)
{
#ifdef BASSAUDIO
BASS_ChannelStop(m_stream);
QString f_path = ao_app->get_music_path(p_song);
@ -24,11 +27,14 @@ void AOMusicPlayer::play(QString p_song)
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false);
#endif
}
void AOMusicPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = m_volume / 100.0f;
#ifdef BASSAUDIO
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
#endif
}

View File

@ -199,6 +199,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_callwords_layout->addWidget(ui_callwords_explain_lbl);
// The audio tab.
#ifdef BASSAUDIO
ui_audio_tab = new QWidget();
ui_settings_tabs->addTab(ui_audio_tab, tr("Audio"));
@ -218,7 +219,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_device_combobox = new QComboBox(ui_audio_widget);
// Let's fill out the combobox with the available audio devices.
// Let's fill out the combobox with the available audio devices. Or don't if there is no audio
int a = 0;
BASS_DEVICEINFO info;
@ -311,6 +312,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_blank_blips_cb->setChecked(p_ao_app->get_blank_blip());
ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb);
#endif
// The casing tab!
ui_casing_tab = new QWidget();

View File

@ -9,6 +9,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
{
#ifdef BASSAUDIO
BASS_ChannelStop(m_stream);
QString misc_path = "";
@ -36,16 +37,21 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false);
#endif
}
void AOSfxPlayer::stop()
{
#ifdef BASSAUDIO
BASS_ChannelStop(m_stream);
#endif
}
void AOSfxPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = p_value / 100.0f;
#ifdef BASSAUDIO
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
#endif
}

View File

@ -3,7 +3,7 @@
Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
{
ao_app = p_ao_app;
#ifdef BASSAUDIO
// Change the default audio output device to be the one the user has given
// in his config.ini file for now.
int a = 0;
@ -28,6 +28,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
}
}
}
#endif
keepalive_timer = new QTimer(this);
keepalive_timer->start(60000);
@ -3498,23 +3499,29 @@ Courtroom::~Courtroom()
delete blip_player;
}
#if (defined (_WIN32) || defined (_WIN64))
void Courtroom::load_bass_opus_plugin()
{
#ifdef BASSAUDIO
BASS_PluginLoad("bassopus.dll", 0);
#endif
}
#elif (defined (LINUX) || defined (__linux__))
void Courtroom::load_bass_opus_plugin()
{
#ifdef BASSAUDIO
BASS_PluginLoad("libbassopus.so", 0);
#endif
}
#elif defined __APPLE__
void Courtroom::load_bass_opus_plugin()
{
QString libpath = ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib";
QByteArray ba = libpath.toLocal8Bit();
#ifdef BASSAUDIO
BASS_PluginLoad(ba.data(), 0);
#endif
}
#else
#error This operating system is unsupported for bass plugins.