Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Fix test alert sound
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Oct 23, 2023
1 parent 4c0c0cd commit a68fb58
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/modals/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
namespace vector_audio::modals {
class Settings {
public:
static void render(afv_native::api::atcClient* mClient);
static void render(afv_native::api::atcClient* mClient, const std::function<void()>& playAlertSound);
};
}
1 change: 1 addition & 0 deletions include/shared.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <afv-native/hardwareType.h>
#include <chrono>
Expand Down
2 changes: 1 addition & 1 deletion src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void App::render_frame()
}
style::pop_disabled_on(mClient_->IsAPIConnected());

vector_audio::modals::Settings::render(mClient_);
vector_audio::modals::Settings::render(mClient_, [this]() -> void { playErrorSound(); });

{
ImGui::SetNextWindowSize(ImVec2(300, -1));
Expand Down
19 changes: 4 additions & 15 deletions src/modals/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "imgui.h"
#include "util.h"

void vector_audio::modals::Settings::render(afv_native::api::atcClient* mClient)
void vector_audio::modals::Settings::render(afv_native::api::atcClient* mClient, const std::function<void()>& playAlertSound)
{
// Settings modal definition
if (ImGui::BeginPopupModal("Settings Panel")) {
Expand Down Expand Up @@ -399,21 +399,10 @@ void vector_audio::modals::Settings::render(afv_native::api::atcClient* mClient)
1 - (vector_audio::shared::mPeak / -40.F), ImVec2(-1.F, 7.F),
ImColor(0, 200, 100), ImColor(219, 201, 0));

ImGui::NewLine();

if (ImGui::Button("Test alert sound")) {
sf::SoundBuffer disconnect_warning_soundbuffer;
sf::Sound sound_player;

auto sound_path = Configuration::get_resource_folder()
/ std::filesystem::path("disconnect.wav");

if (!disconnect_warning_soundbuffer.loadFromFile(sound_path)) {
disconnect_warning_sound_available = false;
spdlog::error("Could not load warning sound file, "
"disconnection will be silent");
} else {
sound_player.setBuffer(disconnect_warning_soundbuffer);
sound_player.play();
}
playAlertSound();
}
ImGui::SameLine();
vector_audio::util::HelpMarker(
Expand Down

0 comments on commit a68fb58

Please sign in to comment.