mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:09:05 +02:00
inject lobby music at a random starting point
This commit is contained in:
parent
03bfaa4869
commit
81c5f9ba5a
2 changed files with 27 additions and 4 deletions
|
@ -39,13 +39,15 @@ var ORB_SHIFT = { x: 0, y: -1.4, z: -0.8};
|
||||||
|
|
||||||
var HELMET_ATTACHMENT_URL = HIFI_PUBLIC_BUCKET + "models/attachments/IronManMaskOnly.fbx"
|
var HELMET_ATTACHMENT_URL = HIFI_PUBLIC_BUCKET + "models/attachments/IronManMaskOnly.fbx"
|
||||||
|
|
||||||
var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.raw")
|
var droneSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/drone.stereo.raw")
|
||||||
var currentDrone = null;
|
var currentDrone = null;
|
||||||
|
|
||||||
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.raw")
|
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw")
|
||||||
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.raw")
|
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw")
|
||||||
var currentMusak = null;
|
var currentMusak = null;
|
||||||
|
|
||||||
|
var firstMusakPlay = true;
|
||||||
|
|
||||||
function reticlePosition() {
|
function reticlePosition() {
|
||||||
var RETICLE_DISTANCE = 1;
|
var RETICLE_DISTANCE = 1;
|
||||||
return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE));
|
return Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), RETICLE_DISTANCE));
|
||||||
|
@ -137,7 +139,15 @@ function playRandomMusak() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chosenSound) {
|
if (chosenSound) {
|
||||||
currentMusak = Audio.playSound(chosenSound, { stereo: true, localOnly: true })
|
if (firstMusakPlay) {
|
||||||
|
// pick a random number of seconds from 0-10 to offset the muzak
|
||||||
|
var secondOffset = Math.random() * 10;
|
||||||
|
firstMusakPlay = false;
|
||||||
|
} else {
|
||||||
|
var secondOffset = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentMusak = Audio.playSound(chosenSound, { localOnly: true, secondOffset: secondOffset, volume: 0.5 })
|
||||||
} else {
|
} else {
|
||||||
currentMusak = null;
|
currentMusak = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,6 +94,19 @@ void AudioInjector::injectLocally() {
|
||||||
_localBuffer->open(QIODevice::ReadOnly);
|
_localBuffer->open(QIODevice::ReadOnly);
|
||||||
_localBuffer->setShouldLoop(_options.loop);
|
_localBuffer->setShouldLoop(_options.loop);
|
||||||
|
|
||||||
|
// check if we need to offset the sound by some number of seconds
|
||||||
|
if (_options.secondOffset > 0.0f) {
|
||||||
|
|
||||||
|
qDebug() << "injector wants a sound offset of" << _options.secondOffset;
|
||||||
|
// convert the offset into a number of bytes
|
||||||
|
int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f));
|
||||||
|
byteOffset *= sizeof(int16_t);
|
||||||
|
|
||||||
|
qDebug() << "that gives us" << byteOffset << "bytes";
|
||||||
|
|
||||||
|
// give that byte offset to our local buffer
|
||||||
|
_localBuffer->setCurrentOffset(byteOffset);
|
||||||
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector",
|
QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector",
|
||||||
Qt::BlockingQueuedConnection,
|
Qt::BlockingQueuedConnection,
|
||||||
|
|
Loading…
Reference in a new issue