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

Commit

Permalink
Deprecate VectorAudio, update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Apr 29, 2024
1 parent 858bbf9 commit d46f02c
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 70 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

A cross-platform Audio-For-VATSIM ATC Client for macOS, Windows and Linux support (audio only)

## NOTE

***GOING FORWARD, VECTORAUDIO WILL NOT BE ACTIVELY DEVELOPPED. HEAD OVER TO ITS REPLACEMENT, [TrackAudio](https://github.com/pierr3/TrackAudio) FOR FUTURE UPDATES AND AN IMPROVED EXPERIENCE WITH MORE FEATURES AND STABILITY.***

## Screenshot

![screengrab of application](https://raw.githubusercontent.com/pierr3/VectorAudio/main/splash.png)

## Releases
Expand Down
11 changes: 6 additions & 5 deletions include/shared.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "afv-native/atcClientWrapper.h"
#include "ns/station.h"
#include "semver.hpp"

Expand Down Expand Up @@ -41,9 +42,9 @@ const int kUnicomFrequency = 122800000;

inline unsigned int mAudioApi = -1;
inline std::string configAudioApi;
inline std::string configInputDeviceName;
inline std::string configOutputDeviceName;
inline std::string configSpeakerDeviceName;
inline std::string configInputDeviceId;
inline std::string configOutputDeviceId;
inline std::string configSpeakerDeviceId;
inline int headsetOutputChannel = 0;

inline bool capturePttFlag = false;
Expand Down Expand Up @@ -81,8 +82,8 @@ inline int radioGain = 100;

// Temp settings for config window
inline std::map<unsigned int, std::string> availableAudioAPI;
inline std::vector<std::string> availableInputDevices;
inline std::vector<std::string> availableOutputDevices;
inline std::vector<afv_native::api::AudioInterface> availableInputDevices;
inline std::vector<afv_native::api::AudioInterface> availableOutputDevices;

inline static std::mutex transmittingMutex;
inline static std::string currentlyTransmittingApiData;
Expand Down
54 changes: 31 additions & 23 deletions include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,37 +168,45 @@ inline static int findAudioAPIorDefault()
return -1;
}

inline static std::string findHeadsetInputDeviceOrDefault()
inline static bool disconnectWarningSoundAvailable = true;

inline static std::string findGenericDeviceOrDefault(
const std::vector<afv_native::api::AudioInterface>& deviceList,
const std::string& deviceId)
{
if (std::find(vector_audio::shared::availableInputDevices.begin(),
vector_audio::shared::availableInputDevices.end(),
vector_audio::shared::configInputDeviceName)
!= vector_audio::shared::availableInputDevices.end())
return vector_audio::shared::configInputDeviceName;
for (const auto& device : deviceList) {
if (device.id == deviceId)
return device.id;
}

return vector_audio::shared::availableInputDevices.front();
}
for (const auto& device : deviceList) {
if (device.isDefault)
return device.id;
}

inline static bool disconnectWarningSoundAvailable = true;
if (deviceList.empty())
return "";

inline static std::string findHeadsetOutputDeviceOrDefault()
return deviceList.front().id;
}

inline static std::string findHeadsetInputDeviceIdOrDefault()
{
if (std::find(vector_audio::shared::availableOutputDevices.begin(),
vector_audio::shared::availableOutputDevices.end(),
vector_audio::shared::configOutputDeviceName)
!= vector_audio::shared::availableOutputDevices.end())
return vector_audio::shared::configOutputDeviceName;
return findGenericDeviceOrDefault(
vector_audio::shared::availableInputDevices,
vector_audio::shared::configInputDeviceId);
}

return vector_audio::shared::availableOutputDevices.front();
inline static std::string findHeadsetOutputDeviceIdOrDefault()
{
return findGenericDeviceOrDefault(
vector_audio::shared::availableOutputDevices,
vector_audio::shared::configOutputDeviceId);
}

inline static std::string findSpeakerOutputDeviceOrDefault()
{
if (std::find(vector_audio::shared::availableOutputDevices.begin(),
vector_audio::shared::availableOutputDevices.end(),
vector_audio::shared::configSpeakerDeviceName)
!= vector_audio::shared::availableOutputDevices.end())
return vector_audio::shared::configSpeakerDeviceName;

return vector_audio::shared::availableOutputDevices.front();
return findGenericDeviceOrDefault(
vector_audio::shared::availableOutputDevices,
vector_audio::shared::configSpeakerDeviceId);
}
27 changes: 15 additions & 12 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ App::App()
shared::mAudioApi = driver.first;
}

shared::configInputDeviceName = toml::find_or<std::string>(
shared::configInputDeviceId = toml::find_or<std::string>(
cfg::mConfig, "audio", "input_device", std::string(""));
shared::configOutputDeviceName = toml::find_or<std::string>(
shared::configOutputDeviceId = toml::find_or<std::string>(
cfg::mConfig, "audio", "output_device", std::string(""));
shared::configSpeakerDeviceName = toml::find_or<std::string>(
shared::configSpeakerDeviceId = toml::find_or<std::string>(
cfg::mConfig, "audio", "speaker_device", std::string(""));
shared::headsetOutputChannel
= toml::find_or<int>(cfg::mConfig, "audio", "headset_channel", 0);
Expand Down Expand Up @@ -118,7 +118,7 @@ App::App()

if (disconnectWarningSoundAvailable) {
shared::pDeviceId = SDL_OpenAudioDevice(
vector_audio::shared::configOutputDeviceName.c_str(), 0,
vector_audio::shared::configOutputDeviceId.c_str(), 0,
&shared::pDisconnectSoundWavSpec, NULL, 0);
if (shared::pDeviceId == 0) {
disconnectWarningSoundAvailable = false;
Expand Down Expand Up @@ -303,9 +303,10 @@ void App::eventCallback(
}

if (evt == afv_native::ClientEventType::AudioError) {
errorModal("Error starting audio devices.\nPlease check "
"your log file for details.\nCheck your audio config!");
disconnectAndCleanup();
spdlog::error("Error starting audio devices.");
// errorModal("Error starting audio devices.\nPlease check "
// "your log file for details.\nCheck your audio config!");
// disconnectAndCleanup();
}

if (evt == afv_native::ClientEventType::VoiceServerDisconnected) {
Expand Down Expand Up @@ -335,9 +336,11 @@ void App::eventCallback(
}

if (evt == afv_native::ClientEventType::AudioDeviceStoppedError) {
errorModal("The audio device " + *reinterpret_cast<std::string*>(data)
+ " has stopped working"
", check if it is still physically connected.");
spdlog::error("An audio device has stopped working");
// errorModal("The audio device " +
// *reinterpret_cast<std::string*>(data)
// + " has stopped working"
// ", check if it is still physically connected.");
disconnectAndCleanup();
playErrorSound();
}
Expand Down Expand Up @@ -535,9 +538,9 @@ void App::render_frame()
}

pClient->SetAudioApi(findAudioAPIorDefault());
pClient->SetAudioInputDevice(findHeadsetInputDeviceOrDefault());
pClient->SetAudioInputDevice(findHeadsetInputDeviceIdOrDefault());
pClient->SetAudioOutputDevice(
findHeadsetOutputDeviceOrDefault());
findHeadsetOutputDeviceIdOrDefault());
pClient->SetAudioSpeakersOutputDevice(
findSpeakerOutputDeviceOrDefault());
pClient->SetHardware(shared::hardware);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int, char**)

// Setup SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER
| SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK)
| SDL_INIT_EVENTS | SDL_INIT_JOYSTICK)
!= 0) {
printf("Error: %s\n", SDL_GetError());
return -1;
Expand Down
58 changes: 29 additions & 29 deletions src/ui/modals/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,19 @@ void vector_audio::ui::modals::Settings::render(

ImGui::PushItemWidth(-1.0F);
if (ImGui::BeginCombo("##Input Device",
vector_audio::shared::configInputDeviceName.c_str())) {
vector_audio::shared::configInputDeviceId.c_str())) {

auto mAudioDrivers
= vector_audio::shared::availableInputDevices;
for (const auto& driver : mAudioDrivers) {
if (ImGui::Selectable(driver.c_str(),
vector_audio::shared::configInputDeviceName
== driver)) {
vector_audio::shared::configInputDeviceName = driver;
for (const auto& interface : mAudioDrivers) {
if (ImGui::Selectable(interface.name.c_str(),
vector_audio::shared::configInputDeviceId
== interface.id)) {
vector_audio::shared::configInputDeviceId
= interface.id;
vector_audio::Configuration::mConfig["audio"]
["input_device"]
= vector_audio::shared::configInputDeviceName;
= vector_audio::shared::configInputDeviceId;
}
}

Expand All @@ -300,25 +301,26 @@ void vector_audio::ui::modals::Settings::render(

ImGui::PushItemWidth(-1.0F);
if (ImGui::BeginCombo("##Headset Device",
vector_audio::shared::configOutputDeviceName.c_str())) {
vector_audio::shared::configOutputDeviceId.c_str())) {

auto mAudioDrivers
= vector_audio::shared::availableOutputDevices;
for (const auto& driver : mAudioDrivers) {
if (ImGui::Selectable(driver.c_str(),
vector_audio::shared::configOutputDeviceName
== driver)) {
vector_audio::shared::configOutputDeviceName = driver;
for (const auto& interface : mAudioDrivers) {
if (ImGui::Selectable(interface.name.c_str(),
vector_audio::shared::configOutputDeviceId
== interface.id)) {
vector_audio::shared::configOutputDeviceId
= interface.id;
vector_audio::Configuration::mConfig["audio"]
["output_device"]
= vector_audio::shared::configOutputDeviceName;
= vector_audio::shared::configOutputDeviceId;

if (disconnectWarningSoundAvailable) {
if (shared::pDeviceId != 0) {
SDL_CloseAudioDevice(shared::pDeviceId);
}
shared::pDeviceId = SDL_OpenAudioDevice(
vector_audio::shared::configOutputDeviceName
vector_audio::shared::configOutputDeviceId
.c_str(),
0, &shared::pDisconnectSoundWavSpec, NULL, 0);
}
Expand Down Expand Up @@ -376,18 +378,19 @@ void vector_audio::ui::modals::Settings::render(

ImGui::PushItemWidth(-1.0F);
if (ImGui::BeginCombo("##Speaker Device",
vector_audio::shared::configSpeakerDeviceName.c_str())) {
vector_audio::shared::configSpeakerDeviceId.c_str())) {

auto mAudioDrivers
= vector_audio::shared::availableOutputDevices;
for (const auto& driver : mAudioDrivers) {
if (ImGui::Selectable(driver.c_str(),
vector_audio::shared::configSpeakerDeviceName
== driver)) {
vector_audio::shared::configSpeakerDeviceName = driver;
for (const auto& interface : mAudioDrivers) {
if (ImGui::Selectable(interface.name.c_str(),
vector_audio::shared::configSpeakerDeviceId
== interface.id)) {
vector_audio::shared::configSpeakerDeviceId
= interface.id;
vector_audio::Configuration::mConfig["audio"]
["speaker_device"]
= vector_audio::shared::configSpeakerDeviceName;
= vector_audio::shared::configSpeakerDeviceId;
}
}

Expand All @@ -406,13 +409,10 @@ void vector_audio::ui::modals::Settings::render(
if (mClient->IsAudioRunning()) {
mClient->StopAudio();
} else {
mClient->SetAudioApi(vector_audio::shared::mAudioApi);
mClient->SetAudioInputDevice(
vector_audio::shared::configInputDeviceName);
mClient->SetAudioOutputDevice(
vector_audio::shared::configOutputDeviceName);
mClient->SetAudioSpeakersOutputDevice(
vector_audio::shared::configSpeakerDeviceName);
mClient->SetAudioApi(-1);
mClient->SetAudioInputDevice("");
mClient->SetAudioOutputDevice("");
mClient->SetAudioSpeakersOutputDevice("");
mClient->StartAudio();
}
}
Expand Down

0 comments on commit d46f02c

Please sign in to comment.