mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:38:27 +02:00
groundwork for better locally looped audio
This commit is contained in:
parent
dbc1ba7925
commit
d083e75d2d
5 changed files with 7 additions and 31 deletions
|
@ -1334,22 +1334,10 @@ void Audio::startDrumSound(float volume, float frequency, float duration, float
|
||||||
_drumSoundSample = 0;
|
_drumSoundSample = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::handleAudioByteArray(const QByteArray& audioByteArray, const AudioInjectorOptions& injectorOptions) {
|
QAudioOutput* Audio::newLocalOutputInterface(bool isStereo) {
|
||||||
if (audioByteArray.size() > 0) {
|
QAudioFormat localFormat = _outputFormat;
|
||||||
QAudioFormat localFormat = _outputFormat;
|
localFormat.setChannelCount(isStereo ? 2 : 1);
|
||||||
|
return new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName), localFormat);
|
||||||
if (!injectorOptions.isStereo()) {
|
|
||||||
localFormat.setChannelCount(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QAudioOutput* localSoundOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName), localFormat, this);
|
|
||||||
|
|
||||||
QIODevice* localIODevice = localSoundOutput->start();
|
|
||||||
qDebug() << "Writing" << audioByteArray.size() << "to" << localIODevice;
|
|
||||||
localIODevice->write(audioByteArray);
|
|
||||||
} else {
|
|
||||||
qDebug() << "Audio::handleAudioByteArray called with an empty byte array. Sound is likely still downloading.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::renderToolBox(int x, int y, bool boxed) {
|
void Audio::renderToolBox(int x, int y, bool boxed) {
|
||||||
|
|
|
@ -155,7 +155,7 @@ public slots:
|
||||||
void selectAudioFilterBassCut();
|
void selectAudioFilterBassCut();
|
||||||
void selectAudioFilterSmiley();
|
void selectAudioFilterSmiley();
|
||||||
|
|
||||||
virtual void handleAudioByteArray(const QByteArray& audioByteArray, const AudioInjectorOptions& options);
|
virtual QAudioOutput* newLocalOutputInterface(bool isStereo);
|
||||||
|
|
||||||
void sendDownstreamAudioStatsPacket();
|
void sendDownstreamAudioStatsPacket();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define hifi_AbstractAudioInterface_h
|
#define hifi_AbstractAudioInterface_h
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtMultimedia/qaudiooutput.h>
|
||||||
|
|
||||||
#include "AudioInjectorOptions.h"
|
#include "AudioInjectorOptions.h"
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ public:
|
||||||
virtual void startCollisionSound(float magnitude, float frequency, float noise, float duration, bool flashScreen) = 0;
|
virtual void startCollisionSound(float magnitude, float frequency, float noise, float duration, bool flashScreen) = 0;
|
||||||
virtual void startDrumSound(float volume, float frequency, float duration, float decay) = 0;
|
virtual void startDrumSound(float volume, float frequency, float duration, float decay) = 0;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void handleAudioByteArray(const QByteArray& audioByteArray, const AudioInjectorOptions& options) = 0;
|
virtual QAudioOutput* newLocalOutputInterface(bool isStereo) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(AbstractAudioInterface*)
|
Q_DECLARE_METATYPE(AbstractAudioInterface*)
|
||||||
|
|
|
@ -37,18 +37,6 @@ void AudioScriptingInterface::stopAllInjectors() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioScriptingInterface::playLocalSound(Sound* sound, const AudioInjectorOptions* injectorOptions) {
|
|
||||||
if (sound->isStereo()) {
|
|
||||||
const_cast<AudioInjectorOptions*>(injectorOptions)->setIsStereo(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// assume that localAudioInterface could be on a separate thread, use Qt::AutoConnection to handle properly
|
|
||||||
QMetaObject::invokeMethod(_localLoopbackInterface, "handleAudioByteArray",
|
|
||||||
Qt::AutoConnection,
|
|
||||||
Q_ARG(QByteArray, sound->getByteArray()),
|
|
||||||
Q_ARG(const AudioInjectorOptions&, *injectorOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions* injectorOptions) {
|
AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions* injectorOptions) {
|
||||||
|
|
||||||
if (sound->isStereo()) {
|
if (sound->isStereo()) {
|
||||||
|
|
|
@ -32,7 +32,6 @@ public slots:
|
||||||
|
|
||||||
static float getLoudness(AudioInjector* injector);
|
static float getLoudness(AudioInjector* injector);
|
||||||
|
|
||||||
void playLocalSound(Sound *sound, const AudioInjectorOptions* injectorOptions = NULL);
|
|
||||||
AudioInjector* playSound(Sound* sound, const AudioInjectorOptions* injectorOptions = NULL);
|
AudioInjector* playSound(Sound* sound, const AudioInjectorOptions* injectorOptions = NULL);
|
||||||
|
|
||||||
void stopInjector(AudioInjector* injector);
|
void stopInjector(AudioInjector* injector);
|
||||||
|
|
Loading…
Reference in a new issue