mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 23:04:03 +02:00
220Hz tone injection option for easier audio quality checks
This commit is contained in:
parent
81d1eb7ed2
commit
7d12fcee9d
4 changed files with 30 additions and 4 deletions
|
@ -66,8 +66,10 @@ Audio::Audio(Oscilloscope* scope, int16_t initialJitterBufferSamples, QObject* p
|
||||||
_noiseGateSampleCounter(0),
|
_noiseGateSampleCounter(0),
|
||||||
_noiseGateOpen(false),
|
_noiseGateOpen(false),
|
||||||
_noiseGateEnabled(true),
|
_noiseGateEnabled(true),
|
||||||
|
_toneInjectionEnabled(false),
|
||||||
_noiseGateFramesToClose(0),
|
_noiseGateFramesToClose(0),
|
||||||
_totalPacketsReceived(0),
|
_totalPacketsReceived(0),
|
||||||
|
_totalInputAudioSamples(0),
|
||||||
_collisionSoundMagnitude(0.0f),
|
_collisionSoundMagnitude(0.0f),
|
||||||
_collisionSoundFrequency(0.0f),
|
_collisionSoundFrequency(0.0f),
|
||||||
_collisionSoundNoise(0.0f),
|
_collisionSoundNoise(0.0f),
|
||||||
|
@ -421,8 +423,10 @@ void Audio::handleAudioInput() {
|
||||||
const float DC_OFFSET_AVERAGING = 0.99f;
|
const float DC_OFFSET_AVERAGING = 0.99f;
|
||||||
const float CLIPPING_THRESHOLD = 0.90f;
|
const float CLIPPING_THRESHOLD = 0.90f;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check clipping, adjust DC offset, and check if should open noise gate
|
||||||
|
//
|
||||||
float measuredDcOffset = 0.f;
|
float measuredDcOffset = 0.f;
|
||||||
|
|
||||||
// Increment the time since the last clip
|
// Increment the time since the last clip
|
||||||
if (_timeSinceLastClip >= 0.0f) {
|
if (_timeSinceLastClip >= 0.0f) {
|
||||||
_timeSinceLastClip += (float) NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL / (float) SAMPLE_RATE;
|
_timeSinceLastClip += (float) NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL / (float) SAMPLE_RATE;
|
||||||
|
@ -489,6 +493,16 @@ void Audio::handleAudioInput() {
|
||||||
_lastInputLoudness = 0;
|
_lastInputLoudness = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
// Add tone injection if enabled
|
||||||
|
//
|
||||||
|
const float TONE_FREQ = 220.f / SAMPLE_RATE * TWO_PI;
|
||||||
|
const float QUARTER_VOLUME = 8192.f;
|
||||||
|
if (_toneInjectionEnabled) {
|
||||||
|
for (int i = 0; i < NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; i++) {
|
||||||
|
monoAudioSamples[i] = QUARTER_VOLUME * sinf(TONE_FREQ * (float)(i + _proceduralEffectSample));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add input data just written to the scope
|
// add input data just written to the scope
|
||||||
QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection,
|
QMetaObject::invokeMethod(_scope, "addSamples", Qt::QueuedConnection,
|
||||||
|
@ -683,7 +697,9 @@ void Audio::toggleAudioNoiseReduction() {
|
||||||
_noiseGateEnabled = !_noiseGateEnabled;
|
_noiseGateEnabled = !_noiseGateEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::toggleToneInjection() {
|
||||||
|
_toneInjectionEnabled = !_toneInjectionEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
// Take a pointer to the acquired microphone input samples and add procedural sounds
|
// Take a pointer to the acquired microphone input samples and add procedural sounds
|
||||||
void Audio::addProceduralSounds(int16_t* monoInput, int numSamples) {
|
void Audio::addProceduralSounds(int16_t* monoInput, int numSamples) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ public slots:
|
||||||
void reset();
|
void reset();
|
||||||
void toggleMute();
|
void toggleMute();
|
||||||
void toggleAudioNoiseReduction();
|
void toggleAudioNoiseReduction();
|
||||||
|
void toggleToneInjection();
|
||||||
|
|
||||||
virtual void handleAudioByteArray(const QByteArray& audioByteArray);
|
virtual void handleAudioByteArray(const QByteArray& audioByteArray);
|
||||||
|
|
||||||
|
@ -135,8 +136,10 @@ private:
|
||||||
int _noiseGateSampleCounter;
|
int _noiseGateSampleCounter;
|
||||||
bool _noiseGateOpen;
|
bool _noiseGateOpen;
|
||||||
bool _noiseGateEnabled;
|
bool _noiseGateEnabled;
|
||||||
|
bool _toneInjectionEnabled;
|
||||||
int _noiseGateFramesToClose;
|
int _noiseGateFramesToClose;
|
||||||
int _totalPacketsReceived;
|
int _totalPacketsReceived;
|
||||||
|
int _totalInputAudioSamples;
|
||||||
|
|
||||||
float _collisionSoundMagnitude;
|
float _collisionSoundMagnitude;
|
||||||
float _collisionSoundFrequency;
|
float _collisionSoundFrequency;
|
||||||
|
|
|
@ -360,6 +360,12 @@ Menu::Menu() :
|
||||||
false,
|
false,
|
||||||
appInstance->getAudio(),
|
appInstance->getAudio(),
|
||||||
SLOT(toggleMute()));
|
SLOT(toggleMute()));
|
||||||
|
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioToneInjection,
|
||||||
|
0,
|
||||||
|
false,
|
||||||
|
appInstance->getAudio(),
|
||||||
|
SLOT(toggleToneInjection()));
|
||||||
|
|
||||||
|
|
||||||
addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel,
|
addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel,
|
||||||
Qt::CTRL | Qt::SHIFT | Qt::Key_V,
|
Qt::CTRL | Qt::SHIFT | Qt::Key_V,
|
||||||
|
|
|
@ -242,6 +242,7 @@ namespace MenuOption {
|
||||||
const QString FilterSixense = "Smooth Sixense Movement";
|
const QString FilterSixense = "Smooth Sixense Movement";
|
||||||
const QString Enable3DTVMode = "Enable 3DTV Mode";
|
const QString Enable3DTVMode = "Enable 3DTV Mode";
|
||||||
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
||||||
|
const QString AudioToneInjection = "Inject Test Tone";
|
||||||
const QString EchoServerAudio = "Echo Server Audio";
|
const QString EchoServerAudio = "Echo Server Audio";
|
||||||
const QString EchoLocalAudio = "Echo Local Audio";
|
const QString EchoLocalAudio = "Echo Local Audio";
|
||||||
const QString MuteAudio = "Mute Microphone";
|
const QString MuteAudio = "Mute Microphone";
|
||||||
|
|
Loading…
Reference in a new issue