From 4f6998ab33abce79c31a57e856ff137f9fb74a17 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 23 Jun 2024 05:19:20 +0200 Subject: [PATCH] Add audio settings information --- README.md | 10 ++++++++-- include/audio.hpp | 6 ++---- include/hw_defs.hpp | 2 +- source/audio.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 774e7f4..062a731 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The main goal is to offer the ability to use the Capture Card with a TV, via ful ## Features -- Performance-focused design, with low latency for both audio and video (measured to oscillate between 1 and 2 frames). +- Performance-focused design, with low latency for both audio and video (measured to oscillate between 1 and 2 frames on 120hz displays). - Option to split the screens in separate windows, to address them separately. - Make your game run in fullscreen mode. If you own multiple displays, you can even use one per-window. - Many builtin crop options for the screens. @@ -140,4 +140,10 @@ On Windows, the profiles can be found in the ".config/cc3dsfs" folder inside the xattr -c ./cc3dsfs.app ``` - It can also be achieved by opening a terminal, typing "xattr -c ", dragging the application to the terminal, and finally pressing Enter. - +- Certain TVs/Monitors may add some audio delay for the purpose of video/lip syncing. If you're experiencing too much audio delay when using this software, try checking in the TV/Monitor settings whether you can reduce that added delay. One of the names used for that setting is "Lip Sync", or something along that line. +- For the best audio latency and quality, it may be needed to change OpenAL's sound settings. Their location is OS-specific. On linux, you may use the "alsoft-config" command. In particular, the following parameters may help: +``` +frequency = 96000 +periods = 2 +period_size = 64 +``` diff --git a/include/audio.hpp b/include/audio.hpp index 63f0057..2bfc216 100755 --- a/include/audio.hpp +++ b/include/audio.hpp @@ -5,9 +5,6 @@ #include #include "audio_data.hpp" #include "utils.hpp" -#include "audio.hpp" -#include "capture_structs.hpp" -#include "hw_defs.hpp" struct Sample { Sample(sf::Int16 *bytes, std::size_t size, float time); @@ -24,6 +21,7 @@ public: ConsumerMutex samples_wait; Audio(AudioData *audio_data); + ~Audio(); void update_volume(); void start_audio(); void stop_audio(); @@ -33,7 +31,7 @@ private: int final_volume = -1; bool terminate; int num_consecutive_fast_seek; - sf::Int16 buffer[MAX_SAMPLES_IN]; + sf::Int16 *buffer; std::chrono::time_point clock_time_start; bool onGetData(sf::SoundStream::Chunk &data) override; diff --git a/include/hw_defs.hpp b/include/hw_defs.hpp index bd8f30c..8d37d85 100755 --- a/include/hw_defs.hpp +++ b/include/hw_defs.hpp @@ -2,7 +2,7 @@ #define __HW_DEFS_HPP #define AUDIO_CHANNELS 2 -#define SAMPLE_RATE 48000 +#define SAMPLE_RATE 96000 #define PITCH_RATE (67027964 / ((float)SAMPLE_RATE * 2048)) #define TOP_WIDTH_3DS 400 diff --git a/source/audio.cpp b/source/audio.cpp index 323f413..2b2b01f 100755 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -17,18 +17,18 @@ Sample::Sample(sf::Int16 *bytes, std::size_t size, float time) : bytes(bytes), s Audio::Audio(AudioData *audio_data) { this->audio_data = audio_data; // Consume old events + this->buffer = new sf::Int16[MAX_SAMPLES_IN]; this->audio_data->check_audio_restart_request(); sf::SoundStream::initialize(AUDIO_CHANNELS, SAMPLE_RATE); this->setPitch(PITCH_RATE); - #if (SFML_VERSION_MAJOR > 2) || ((SFML_VERSION_MAJOR == 2) && (SFML_VERSION_MINOR >= 6)) - // Since we receive data every 16.6 ms, this is useless, - // and only increases CPU load... (Default is 10 ms) - //sf::SoundStream::setProcessingInterval(sf::Time::Zero); - #endif start_audio(); setVolume(0); this->final_volume = 0; } + +Audio::~Audio() { + delete []this->buffer; +} void Audio::update_volume() { int new_final_volume = this->audio_data->get_final_volume();