43 return std::numeric_limits<qint64>::max();
90 std::unique_ptr<QAudioSink>
sink;
114 short *
fd = (
short *)
data;
115 qint64 frames =
len / nChannels /
sizeof(short);
134 const float *reverbBuffers[2];
148 const int bytesProcessed = ((
char *)
fd -
data);
149 m_pos += bytesProcessed;
150 return bytesProcessed;
178 sd->
sourceId = vraudio::ResonanceAudioApi::kInvalidSourceId;
195 sd->
sourceId = vraudio::ResonanceAudioApi::kInvalidSourceId;
217 bool roomDirty =
false;
218 for (
const auto &room :
rooms) {
231 float roomVolume = float(
qInf());
234 for (
auto *
r : std::as_const(
rooms)) {
236 float vol = dim2.
x()*dim2.
y()*dim2.
z();
237 if (vol > roomVolume)
241 dist =
r->rotation().rotatedVector(
dist);
270 for (
auto *
s : std::as_const(
sources)) {
272 sp->updateRoomEffects();
412 qWarning() <<
"Changing device on a running engine not implemented";
533 qWarning() <<
"QAudioEngine: Invalid distance scale.";
560 f.setSampleRate(ep->sampleRate);
564 auto qrcFile = std::make_unique<QFile>(u
':' +
url.
path());
582 memset(
buf, 0, channels * nframes *
sizeof(
float));
584 int frames = nframes;
591 int toCopy =
qMin(
b.frameCount() -
bufPos, frames);
592 memcpy(ff,
f, toCopy*
sizeof(
float)*
nchannels);
597 if (
bufPos ==
b.frameCount()) {
604 qDebug() <<
"underrun" << frames <<
"frames when loading" <<
url;
605 memset(ff, 0, frames * channels *
sizeof(
float));
606 ff += frames * channels;
624void QAmbientSoundPrivate::bufferReady()
634void QAmbientSoundPrivate::finished()
660#include "moc_qaudioengine.cpp"
661#include "qaudioengine.moc"
IOBluetoothDevice * device
std::unique_ptr< QAudioDecoder > decoder
QAtomicInteger< bool > m_playing
static QAmbientSoundPrivate * get(T *soundSource)
QAtomicInteger< bool > m_autoPlay
void getBuffer(float *buf, int frames, int channels)
std::unique_ptr< QFile > sourceDeviceFile
static constexpr int maxAmbisonicChannels
const T * constData() const
The QAudioDecoder class implements decoding audio.
void bufferReady()
Signals that a new decoded audio buffer is available to be read.
void finished()
Signals that the decoding has finished successfully.
The QAudioDevice class provides an information about audio devices and their functionality.
QAudioFormat::ChannelConfig channelConfiguration() const
Returns the channel configuration of the 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)
std::unique_ptr< QAmbisonicDecoder > ambisonicDecoder
void addSpatialSound(QSpatialSound *sound)
QAudioEngine::OutputMode outputMode
static QAudioEnginePrivate * get(QAudioEngine *engine)
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 removeOne(const AT &t)
void append(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static QSpatialSoundPrivate * get(QSpatialSound *soundSource)
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
void start(Priority=InheritPriority)
bool wait(QDeadlineTimer deadline=QDeadlineTimer(QDeadlineTimer::Forever))
void setPriority(Priority priority)
QString scheme() const
Returns the scheme of the URL.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
The QVector3D class represents a vector or vertex in 3D space.
constexpr float y() const noexcept
Returns the y coordinate of this point.
constexpr float x() const noexcept
Returns the x coordinate of this point.
constexpr float z() const noexcept
Returns the z 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
constexpr const T & qMin(const T &a, const T &b)
constexpr T qAbs(const T &t)
Q_CORE_EXPORT Q_DECL_CONST_FUNCTION double qInf()
GLboolean GLboolean GLboolean b
GLuint const GLuint * buffers
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent