mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 21:06:27 +02:00
switch to next musak when finished
This commit is contained in:
parent
45450c4fe3
commit
987b75d8f7
4 changed files with 49 additions and 18 deletions
|
@ -44,7 +44,8 @@ var currentDrone = null;
|
||||||
|
|
||||||
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw")
|
var latinSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/latin.stereo.raw")
|
||||||
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw")
|
var elevatorSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Lobby/elevator.stereo.raw")
|
||||||
var currentMusak = null;
|
var currentMusakInjector = null;
|
||||||
|
var currentSound = null;
|
||||||
|
|
||||||
function reticlePosition() {
|
function reticlePosition() {
|
||||||
var RETICLE_DISTANCE = 1;
|
var RETICLE_DISTANCE = 1;
|
||||||
|
@ -125,23 +126,42 @@ function changeLobbyTextures() {
|
||||||
Overlays.editOverlay(panelWall, textureProp);
|
Overlays.editOverlay(panelWall, textureProp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var MUSAK_VOLUME = 0.5;
|
||||||
|
|
||||||
|
function playNextMusak() {
|
||||||
|
if (panelWall) {
|
||||||
|
print("PLAYING THE NEXT MUSAK!");
|
||||||
|
if (currentSound == latinSound) {
|
||||||
|
if (elevatorSound.downloaded) {
|
||||||
|
currentSound = elevatorSound;
|
||||||
|
}
|
||||||
|
} else if (currentSound == elevatorSound) {
|
||||||
|
if (latinSound.downloaded) {
|
||||||
|
currentSound = latinSound;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentMusakInjector = Audio.playSound(currentSound, { localOnly: true, volume: MUSAK_VOLUME });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function playRandomMusak() {
|
function playRandomMusak() {
|
||||||
chosenSound = null;
|
currentSound = null;
|
||||||
|
|
||||||
if (latinSound.downloaded && elevatorSound.downloaded) {
|
if (latinSound.downloaded && elevatorSound.downloaded) {
|
||||||
chosenSound = Math.random < 0.5 ? latinSound : elevatorSound;
|
currentSound = Math.random() < 0.5 ? latinSound : elevatorSound;
|
||||||
} else if (latinSound.downloaded) {
|
} else if (latinSound.downloaded) {
|
||||||
chosenSound = latinSound;
|
currentSound = latinSound;
|
||||||
} else if (elevatorSound.downloaded) {
|
} else if (elevatorSound.downloaded) {
|
||||||
chosenSound = elevatorSound;
|
currentSound = elevatorSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chosenSound) {
|
if (currentSound) {
|
||||||
// pick a random number of seconds from 0-10 to offset the muzak
|
// pick a random number of seconds from 0-10 to offset the musak
|
||||||
var secondOffset = Math.random() * 10;
|
var secondOffset = Math.random() * 10;
|
||||||
currentMusak = Audio.playSound(chosenSound, { localOnly: true, secondOffset: secondOffset, volume: 0.5 })
|
currentMusakInjector = Audio.playSound(currentSound, { localOnly: true, secondOffset: secondOffset, volume: MUSAK_VOLUME });
|
||||||
} else {
|
} else {
|
||||||
currentMusak = null;
|
currentMusakInjector = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,16 +170,16 @@ function cleanupLobby() {
|
||||||
Overlays.deleteOverlay(orbShell);
|
Overlays.deleteOverlay(orbShell);
|
||||||
Overlays.deleteOverlay(reticle);
|
Overlays.deleteOverlay(reticle);
|
||||||
|
|
||||||
Audio.stopInjector(currentDrone);
|
|
||||||
currentDrone = null;
|
|
||||||
|
|
||||||
Audio.stopInjector(currentMusak);
|
|
||||||
currentMusak = null;
|
|
||||||
|
|
||||||
panelWall = false;
|
panelWall = false;
|
||||||
orbShell = false;
|
orbShell = false;
|
||||||
reticle = false;
|
reticle = false;
|
||||||
|
|
||||||
|
Audio.stopInjector(currentDrone);
|
||||||
|
currentDrone = null;
|
||||||
|
|
||||||
|
Audio.stopInjector(currentMusakInjector);
|
||||||
|
currentMusakInjector = null;
|
||||||
|
|
||||||
locations = {};
|
locations = {};
|
||||||
toggleEnvironmentRendering(true);
|
toggleEnvironmentRendering(true);
|
||||||
|
|
||||||
|
@ -224,6 +244,11 @@ function update(deltaTime) {
|
||||||
Overlays.editOverlay(reticle, {
|
Overlays.editOverlay(reticle, {
|
||||||
position: reticlePosition()
|
position: reticlePosition()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// if the reticle is up then we may need to play the next musak
|
||||||
|
if (!Audio.isInjectorPlaying(currentMusakInjector)) {
|
||||||
|
playNextMusak();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,6 @@ void AudioInjector::injectAudio() {
|
||||||
int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f));
|
int byteOffset = (int) floorf(SAMPLE_RATE * _options.secondOffset * (_options.stereo ? 2.0f : 1.0f));
|
||||||
byteOffset *= sizeof(int16_t);
|
byteOffset *= sizeof(int16_t);
|
||||||
|
|
||||||
qDebug() << "Changing current send position to" << byteOffset;
|
|
||||||
|
|
||||||
_currentSendPosition = byteOffset;
|
_currentSendPosition = byteOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +115,8 @@ void AudioInjector::injectLocally() {
|
||||||
Q_ARG(qreal, _options.volume),
|
Q_ARG(qreal, _options.volume),
|
||||||
Q_ARG(AudioInjector*, this));
|
Q_ARG(AudioInjector*, this));
|
||||||
|
|
||||||
|
// if we're not looping and the buffer tells us it is empty then emit finished
|
||||||
|
connect(_localBuffer, &AudioInjectorLocalBuffer::bufferEmpty, this, &AudioInjector::stop);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qDebug() << "AudioInjector::injectLocally could not output locally via _localAudioInterface";
|
qDebug() << "AudioInjector::injectLocally could not output locally via _localAudioInterface";
|
||||||
|
|
|
@ -47,6 +47,11 @@ qint64 AudioInjectorLocalBuffer::readData(char* data, qint64 maxSize) {
|
||||||
_currentOffset += bytesRead;
|
_currentOffset += bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_shouldLoop && bytesRead == bytesToEnd) {
|
||||||
|
// we hit the end of the buffer, emit a signal
|
||||||
|
emit bufferEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
void setShouldLoop(bool shouldLoop) { _shouldLoop = shouldLoop; }
|
void setShouldLoop(bool shouldLoop) { _shouldLoop = shouldLoop; }
|
||||||
|
|
||||||
void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; }
|
void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; }
|
||||||
|
signals:
|
||||||
|
void bufferEmpty();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
qint64 recursiveReadFromFront(char* data, qint64 maxSize);
|
qint64 recursiveReadFromFront(char* data, qint64 maxSize);
|
||||||
|
|
Loading…
Reference in a new issue