3#include <qaudioroom_p.h>
10 return QVector3D(f[0], f[1], f[2]);
13inline void toFloats(
const QVector3D &v,
float *f)
23 return QQuaternion(f[3], f[0], f[1], f[2]);
26inline void toFloats(
const QQuaternion &q,
float *f)
43} occlusionAndDampening[] = {
74static_assert(QAudioRoom::LeftWall == 0);
75static_assert(QAudioRoom::RightWall == 1);
76static_assert(QAudioRoom::Floor == 2);
77static_assert(QAudioRoom::Ceiling == 3);
78static_assert(QAudioRoom::FrontWall == 4);
79static_assert(QAudioRoom::BackWall == 5);
81float QAudioRoomPrivate::wallOcclusion(QAudioRoom::Wall wall)
const
83 return m_wallOcclusion[wall] < 0 ? occlusionAndDampening[roomProperties.material_names[wall]].occlusion : m_wallOcclusion[wall];
86float QAudioRoomPrivate::wallDampening(QAudioRoom::Wall wall)
const
88 return m_wallDampening[wall] < 0 ? occlusionAndDampening[roomProperties.material_names[wall]].dampening : m_wallDampening[wall];
91void QAudioRoomPrivate::update()
95 reflections = vraudio::ComputeReflectionProperties(roomProperties);
96 reverb = vraudio::ComputeReverbProperties(roomProperties);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
122
123
124QAudioRoom::QAudioRoom(QAudioEngine *engine)
125 : d(
new QAudioRoomPrivate)
129 auto *ep = QAudioEnginePrivate::get(engine);
134
135
136QAudioRoom::~QAudioRoom()
138 auto *ep = QAudioEnginePrivate::get(d->engine);
140 ep->removeRoom(
this);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
176
177
178
179
180
181
182
183
184
185
186
190
191
192
193
194
195
196
197void QAudioRoom::setPosition(QVector3D pos)
199 auto *ep = QAudioEnginePrivate::get(d->engine);
200 pos *= ep->distanceScale;
201 if (toVector(d->roomProperties.position) == pos)
203 toFloats(pos, d->roomProperties.position);
205 emit positionChanged();
208QVector3D QAudioRoom::position()
const
210 auto *ep = QAudioEnginePrivate::get(d->engine);
211 auto pos = toVector(d->roomProperties.position);
212 pos /= ep->distanceScale;
217
218
219
220
221
222
223
224void QAudioRoom::setDimensions(QVector3D dim)
226 auto *ep = QAudioEnginePrivate::get(d->engine);
227 dim *= ep->distanceScale;
228 if (toVector(d->roomProperties.dimensions) == dim)
230 toFloats(dim, d->roomProperties.dimensions);
232 emit dimensionsChanged();
235QVector3D QAudioRoom::dimensions()
const
237 auto *ep = QAudioEnginePrivate::get(d->engine);
238 auto dim = toVector(d->roomProperties.dimensions);
239 dim /= ep->distanceScale;
244
245
246
247
248void QAudioRoom::setRotation(
const QQuaternion &q)
250 if (toQuaternion(d->roomProperties.rotation) == q)
252 toFloats(q, d->roomProperties.rotation);
254 emit rotationChanged();
257QQuaternion QAudioRoom::rotation()
const
259 return toQuaternion(d->roomProperties.rotation);
263
264
265
266
268
269
270
271
272
273
274
275void QAudioRoom::setWallMaterial(Wall wall, Material material)
277 static_assert(vraudio::kUniform ==
int(UniformMaterial));
278 static_assert(vraudio::kTransparent ==
int(Transparent));
280 if (d->roomProperties.material_names[
int(wall)] ==
int(material))
282 d->roomProperties.material_names[
int(wall)] = vraudio::MaterialName(
int(material));
288
289
290
291
292QAudioRoom::Material QAudioRoom::wallMaterial(Wall wall)
const
294 return Material(d->roomProperties.material_names[
int(wall)]);
298
299
300
301
302
303
304
305
306
307void QAudioRoom::setReflectionGain(
float factor)
311 if (d->roomProperties.reflection_scalar == factor)
313 d->roomProperties.reflection_scalar = factor;
315 emit reflectionGainChanged();
318float QAudioRoom::reflectionGain()
const
320 return d->roomProperties.reflection_scalar;
324
325
326
327
328
329
330
331
332
333void QAudioRoom::setReverbGain(
float factor)
337 if (d->roomProperties.reverb_gain == factor)
339 d->roomProperties.reverb_gain = factor;
341 emit reverbGainChanged();
344float QAudioRoom::reverbGain()
const
346 return d->roomProperties.reverb_gain;
350
351
352
353
354
355
356
357
358void QAudioRoom::setReverbTime(
float factor)
362 if (d->roomProperties.reverb_time == factor)
364 d->roomProperties.reverb_time = factor;
366 emit reverbTimeChanged();
369float QAudioRoom::reverbTime()
const
371 return d->roomProperties.reverb_time;
375
376
377
378
379
380
381
382
383void QAudioRoom::setReverbBrightness(
float factor)
385 if (d->roomProperties.reverb_brightness == factor)
387 d->roomProperties.reverb_brightness = factor;
389 emit reverbBrightnessChanged();
392float QAudioRoom::reverbBrightness()
const
394 return d->roomProperties.reverb_brightness;
399#include "moc_qaudioroom.cpp"
Combined button and popup list for selecting options.
QVector3D toVector(const float *f)
void toFloats(const QVector3D &v, float *f)
QQuaternion toQuaternion(const float *f)