46 return std::numeric_limits<qint64>::max();
73 sink->setBufferSize(bufferSize);
83 ambisonicDecoder.reset();
101 std::unique_ptr<QAudioSink>
sink;
102 std::unique_ptr<QAmbisonicDecoder> ambisonicDecoder;
123 int nChannels = ambisonicDecoder ? ambisonicDecoder->nOutputChannels() : 2;
127 short *
fd = (
short *)
data;
128 qint64 frames =
len / nChannels /
sizeof(short);
151 const float *reverbBuffers[2];
153 Q_ASSERT(ambisonicDecoder->nOutputChannels() <= 8);
154 ambisonicDecoder->processBufferWithReverb(channels, reverbBuffers,
fd, nSamples);
173 const int bytesProcessed = ((
char *)
fd -
data);
174 m_pos += bytesProcessed;
175 return bytesProcessed;
204 sd->
sourceId = vraudio::ResonanceAudioApi::kInvalidSourceId;
223 sd->
sourceId = vraudio::ResonanceAudioApi::kInvalidSourceId;
248 bool roomDirty =
false;
249 for (
const auto &room :
rooms) {
262 float roomVolume = float(
qInf());
265 for (
auto *
r : std::as_const(
rooms)) {
267 float vol = dim2.
x()*dim2.y()*dim2.z();
268 if (vol > roomVolume)
272 dist =
r->rotation().rotatedVector(
dist);
301 for (
auto *
s : std::as_const(
sources)) {
305 sp->updateRoomEffects();
445 qWarning() <<
"Changing device on a running engine not implemented";
566 qWarning() <<
"QAudioEngine: Invalid distance scale.";
601#include "moc_qaudioengine.cpp"
602#include "qaudioengine.moc"
IOBluetoothDevice * device
static QAmbientSoundPrivate * get(T *soundSource)
static constexpr int maxAmbisonicChannels
The QAudioDevice class provides an information about audio devices and their functionality.
QAudioFormat::ChannelConfig channelConfiguration() const
Returns the channel configuration of the device.
QAudioFormat preferredFormat() const
Returns the default audio format settings for this device.
std::unique_ptr< QAudioOutputStream > outputStream
bool listenerPositionDirty
vraudio::ResonanceAudio * resonanceAudio
void addRoom(QAudioRoom *room)
void addStereoSound(QAmbientSound *sound)
QAtomicInteger< bool > paused
QVector3D listenerPosition() const
void removeRoom(QAudioRoom *room)
void addSpatialSound(QSpatialSound *sound)
QAudioEngine::OutputMode outputMode
QList< QAmbientSound * > stereoSources
QList< QSpatialSound * > sources
void removeStereoSound(QAmbientSound *sound)
void removeSpatialSound(QSpatialSound *sound)
QList< QAudioRoom * > rooms
QAudioListener * listener
static constexpr int bufferSize
OutputMode
\value Surround Map the sounds to the loudspeaker configuration of the output device.
void outputDeviceChanged()
QAudioDevice outputDevice
Sets or returns the device that is being used for playing the sound field.
void stop()
Stops the engine.
void setDistanceScale(float scale)
void setOutputDevice(const QAudioDevice &device)
void setOutputMode(OutputMode mode)
float distanceScale
Defines the scale of the coordinate system being used by the spatial audio engine.
int sampleRate() const
Returns the sample rate the engine has been configured with.
bool paused
Pauses the spatial audio engine.
OutputMode outputMode
Sets or retrieves the current output mode of the engine.
void distanceScaleChanged()
void setPaused(bool paused)
~QAudioEngine()
Destroys the spatial audio engine.
float masterVolume
Sets or returns volume being used to render the sound field.
void setMasterVolume(float volume)
void setRoomEffectsEnabled(bool enabled)
Enables room effects such as echos and reverb.
void start()
Starts the engine.
bool roomEffectsEnabled() const
Returns true if room effects are enabled.
void masterVolumeChanged()
QVector3D position() const
Returns the current position of the listener.
void setPaused(bool paused)
QAudioOutputStream(QAudioEnginePrivate *d)
qint64 readData(char *data, qint64 len) override
Reads up to maxSize bytes from the device into data, and returns the number of bytes read or -1 if an...
Q_INVOKABLE void restartOutput()
bool atEnd() const override
Returns true if the current read and write position is at the end of the device (i....
Q_INVOKABLE void stopOutput()
qint64 pos() const override
For random-access devices, this function returns the position that data is written to or read from.
bool isSequential() const override
Returns true if this device is sequential; otherwise returns false.
qint64 bytesAvailable() const override
Returns the number of bytes that are available for reading.
qint64 writeData(const char *, qint64) override
Writes up to maxSize bytes from data to the device.
Q_INVOKABLE void startOutput()
qint64 size() const override
For open random-access devices, this function returns the size of the device.
vraudio::ReflectionProperties reflections
static QAudioRoomPrivate * get(const QAudioRoom *r)
vraudio::ReverbProperties reverb
The QAudioSink class provides an interface for sending audio data to an audio output device.
T fetchAndStoreRelaxed(T newValue) noexcept
T loadRelaxed() const noexcept
\inmodule QtCore \reentrant
virtual bool open(QIODeviceBase::OpenMode mode)
Opens the device and sets its OpenMode to mode.
bool isEmpty() const noexcept
bool removeOne(const AT &t)
void append(parameter_type t)
void unlock() noexcept
Unlocks the mutex.
void lock() noexcept
Locks the mutex.
static QSpatialSoundPrivate * get(QSpatialSound *soundSource)
void start(Priority=InheritPriority)
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
The QVector3D class represents a vector or vertex in 3D space.
constexpr float x() const noexcept
Returns the x coordinate of this point.
int getAmbisonicOutput(const float *buffers[], const float *reverb[], int nChannels)
Combined button and popup list for selecting options.
@ BlockingQueuedConnection
QT_BEGIN_NAMESPACE const int bufferTimeMs
QAudioFormat::ChannelConfig channelConfig
constexpr T qAbs(const T &t)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf()
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLsizei GLenum GLboolean sink
GLenum GLenum GLenum GLenum GLenum scale
QRandomGenerator64 rd
[10]
std::uniform_real_distribution dist(1, 2.5)
[2]