mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 13:23:36 +02:00
Fix recorder.js playback in interface
This commit is contained in:
parent
5c782deb4d
commit
13b2b6086f
8 changed files with 71 additions and 49 deletions
|
@ -148,13 +148,22 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
|||
auto player = DependencyManager::get<Deck>();
|
||||
auto recorder = DependencyManager::get<Recorder>();
|
||||
connect(player.data(), &Deck::playbackStateChanged, [=] {
|
||||
if (player->isPlaying()) {
|
||||
bool isPlaying = player->isPlaying();
|
||||
if (isPlaying) {
|
||||
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
|
||||
if (recordingInterface->getPlayFromCurrentLocation()) {
|
||||
setRecordingBasis();
|
||||
}
|
||||
} else {
|
||||
clearRecordingBasis();
|
||||
useFullAvatarURL(_fullAvatarURLFromPreferences, _fullAvatarModelName);
|
||||
}
|
||||
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
audioIO->setPlayingBackRecording(isPlaying);
|
||||
|
||||
if (_rig) {
|
||||
_rig->setEnableAnimations(!isPlaying);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -180,8 +189,8 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
|||
|
||||
if (recordingInterface->getPlayerUseSkeletonModel() && dummyAvatar.getSkeletonModelURL().isValid() &&
|
||||
(dummyAvatar.getSkeletonModelURL() != getSkeletonModelURL())) {
|
||||
// FIXME
|
||||
//myAvatar->useFullAvatarURL()
|
||||
|
||||
setSkeletonModelURL(dummyAvatar.getSkeletonModelURL());
|
||||
}
|
||||
|
||||
if (recordingInterface->getPlayerUseDisplayName() && dummyAvatar.getDisplayName() != getDisplayName()) {
|
||||
|
@ -204,6 +213,11 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
|||
// head orientation
|
||||
_headData->setLookAtPosition(headData->getLookAtPosition());
|
||||
}
|
||||
|
||||
auto jointData = dummyAvatar.getRawJointData();
|
||||
if (jointData.length() > 0 && _rig) {
|
||||
_rig->copyJointsFromJointData(jointData);
|
||||
}
|
||||
});
|
||||
|
||||
connect(rig.get(), SIGNAL(onLoadComplete()), this, SIGNAL(onLoadComplete()));
|
||||
|
@ -472,7 +486,9 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
{
|
||||
PerformanceTimer perfTimer("joints");
|
||||
// copy out the skeleton joints from the model
|
||||
_rig->copyJointsIntoJointData(_jointData);
|
||||
if (_rigEnabled) {
|
||||
_rig->copyJointsIntoJointData(_jointData);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -486,6 +486,7 @@ private:
|
|||
std::unordered_set<int> _headBoneSet;
|
||||
RigPointer _rig;
|
||||
bool _prevShouldDrawHead;
|
||||
bool _rigEnabled { true };
|
||||
|
||||
bool _enableDebugDrawDefaultPose { false };
|
||||
bool _enableDebugDrawAnimPose { false };
|
||||
|
|
|
@ -483,6 +483,10 @@ void Rig::setEnableInverseKinematics(bool enable) {
|
|||
_enableInverseKinematics = enable;
|
||||
}
|
||||
|
||||
void Rig::setEnableAnimations(bool enable) {
|
||||
_enabledAnimations = enable;
|
||||
}
|
||||
|
||||
AnimPose Rig::getAbsoluteDefaultPose(int index) const {
|
||||
if (_animSkeleton && index >= 0 && index < _animSkeleton->getNumJoints()) {
|
||||
return _absoluteDefaultPoses[index];
|
||||
|
@ -907,7 +911,7 @@ void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform) {
|
|||
|
||||
setModelOffset(rootTransform);
|
||||
|
||||
if (_animNode) {
|
||||
if (_animNode && _enabledAnimations) {
|
||||
PerformanceTimer perfTimer("handleTriggers");
|
||||
|
||||
updateAnimationStateHandlers();
|
||||
|
|
|
@ -210,6 +210,7 @@ public:
|
|||
void computeAvatarBoundingCapsule(const FBXGeometry& geometry, float& radiusOut, float& heightOut, glm::vec3& offsetOut) const;
|
||||
|
||||
void setEnableInverseKinematics(bool enable);
|
||||
void setEnableAnimations(bool enable);
|
||||
|
||||
const glm::mat4& getGeometryToRigTransform() const { return _geometryToRigTransform; }
|
||||
|
||||
|
@ -314,6 +315,7 @@ protected:
|
|||
int32_t _numOverrides { 0 };
|
||||
bool _lastEnableInverseKinematics { true };
|
||||
bool _enableInverseKinematics { true };
|
||||
bool _enabledAnimations { true };
|
||||
|
||||
mutable uint32_t _jointNameWarningCount { 0 };
|
||||
|
||||
|
|
|
@ -39,13 +39,10 @@
|
|||
#include <plugins/CodecPlugin.h>
|
||||
#include <plugins/PluginManager.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PositionalAudioStream.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
#include <Transform.h>
|
||||
|
||||
#include "PositionalAudioStream.h"
|
||||
#include "AudioClientLogging.h"
|
||||
#include "AudioLogging.h"
|
||||
|
||||
|
@ -151,17 +148,17 @@ static inline float convertToFloat(int16_t sample) {
|
|||
AudioClient::AudioClient() :
|
||||
AbstractAudioInterface(),
|
||||
_gate(this),
|
||||
_audioInput(NULL),
|
||||
_audioInput(nullptr),
|
||||
_desiredInputFormat(),
|
||||
_inputFormat(),
|
||||
_numInputCallbackBytes(0),
|
||||
_audioOutput(NULL),
|
||||
_audioOutput(nullptr),
|
||||
_desiredOutputFormat(),
|
||||
_outputFormat(),
|
||||
_outputFrameSize(0),
|
||||
_numOutputCallbackBytes(0),
|
||||
_loopbackAudioOutput(NULL),
|
||||
_loopbackOutputDevice(NULL),
|
||||
_loopbackAudioOutput(nullptr),
|
||||
_loopbackOutputDevice(nullptr),
|
||||
_inputRingBuffer(0),
|
||||
_localInjectorsStream(0),
|
||||
_receivedAudioStream(RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES),
|
||||
|
@ -179,9 +176,9 @@ AudioClient::AudioClient() :
|
|||
_isNoiseGateEnabled(true),
|
||||
_reverb(false),
|
||||
_reverbOptions(&_scriptReverbOptions),
|
||||
_inputToNetworkResampler(NULL),
|
||||
_networkToOutputResampler(NULL),
|
||||
_localToOutputResampler(NULL),
|
||||
_inputToNetworkResampler(nullptr),
|
||||
_networkToOutputResampler(nullptr),
|
||||
_localToOutputResampler(nullptr),
|
||||
_localAudioThread(this),
|
||||
_audioLimiter(AudioConstants::SAMPLE_RATE, OUTPUT_CHANNEL_COUNT),
|
||||
_outgoingAvatarAudioSequenceNumber(0),
|
||||
|
@ -294,12 +291,12 @@ QString friendlyNameForAudioDevice(IMMDevice* pEndpoint) {
|
|||
IPropertyStore* pPropertyStore;
|
||||
pEndpoint->OpenPropertyStore(STGM_READ, &pPropertyStore);
|
||||
pEndpoint->Release();
|
||||
pEndpoint = NULL;
|
||||
pEndpoint = nullptr;
|
||||
PROPVARIANT pv;
|
||||
PropVariantInit(&pv);
|
||||
HRESULT hr = pPropertyStore->GetValue(PKEY_Device_FriendlyName, &pv);
|
||||
pPropertyStore->Release();
|
||||
pPropertyStore = NULL;
|
||||
pPropertyStore = nullptr;
|
||||
deviceName = QString::fromWCharArray((wchar_t*)pv.pwszVal);
|
||||
if (!IsWindows8OrGreater()) {
|
||||
// Windows 7 provides only the 31 first characters of the device name.
|
||||
|
@ -313,9 +310,9 @@ QString friendlyNameForAudioDevice(IMMDevice* pEndpoint) {
|
|||
QString AudioClient::friendlyNameForAudioDevice(wchar_t* guid) {
|
||||
QString deviceName;
|
||||
HRESULT hr = S_OK;
|
||||
CoInitialize(NULL);
|
||||
IMMDeviceEnumerator* pMMDeviceEnumerator = NULL;
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pMMDeviceEnumerator);
|
||||
CoInitialize(nullptr);
|
||||
IMMDeviceEnumerator* pMMDeviceEnumerator = nullptr;
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pMMDeviceEnumerator);
|
||||
IMMDevice* pEndpoint;
|
||||
hr = pMMDeviceEnumerator->GetDevice(guid, &pEndpoint);
|
||||
if (hr == E_NOTFOUND) {
|
||||
|
@ -325,7 +322,7 @@ QString AudioClient::friendlyNameForAudioDevice(wchar_t* guid) {
|
|||
deviceName = ::friendlyNameForAudioDevice(pEndpoint);
|
||||
}
|
||||
pMMDeviceEnumerator->Release();
|
||||
pMMDeviceEnumerator = NULL;
|
||||
pMMDeviceEnumerator = nullptr;
|
||||
CoUninitialize();
|
||||
return deviceName;
|
||||
}
|
||||
|
@ -396,9 +393,9 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
|||
}
|
||||
} else {
|
||||
HRESULT hr = S_OK;
|
||||
CoInitialize(NULL);
|
||||
IMMDeviceEnumerator* pMMDeviceEnumerator = NULL;
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pMMDeviceEnumerator);
|
||||
CoInitialize(nullptr);
|
||||
IMMDeviceEnumerator* pMMDeviceEnumerator = nullptr;
|
||||
CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pMMDeviceEnumerator);
|
||||
IMMDevice* pEndpoint;
|
||||
hr = pMMDeviceEnumerator->GetDefaultAudioEndpoint(mode == QAudio::AudioOutput ? eRender : eCapture, eMultimedia, &pEndpoint);
|
||||
if (hr == E_NOTFOUND) {
|
||||
|
@ -408,7 +405,7 @@ QAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode) {
|
|||
deviceName = friendlyNameForAudioDevice(pEndpoint);
|
||||
}
|
||||
pMMDeviceEnumerator->Release();
|
||||
pMMDeviceEnumerator = NULL;
|
||||
pMMDeviceEnumerator = nullptr;
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
|
@ -968,8 +965,7 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) {
|
|||
}
|
||||
|
||||
void AudioClient::handleAudioInput() {
|
||||
|
||||
if (!_inputDevice) {
|
||||
if (!_inputDevice || _playingBackRecording) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1358,10 +1354,10 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn
|
|||
// That in turn causes it to be disconnected (see for example
|
||||
// http://stackoverflow.com/questions/9264750/qt-signals-and-slots-object-disconnect).
|
||||
_audioInput->stop();
|
||||
_inputDevice = NULL;
|
||||
_inputDevice = nullptr;
|
||||
|
||||
delete _audioInput;
|
||||
_audioInput = NULL;
|
||||
_audioInput = nullptr;
|
||||
_numInputCallbackBytes = 0;
|
||||
|
||||
_inputAudioDeviceName = "";
|
||||
|
@ -1370,7 +1366,7 @@ bool AudioClient::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceIn
|
|||
if (_inputToNetworkResampler) {
|
||||
// if we were using an input to network resampler, delete it here
|
||||
delete _inputToNetworkResampler;
|
||||
_inputToNetworkResampler = NULL;
|
||||
_inputToNetworkResampler = nullptr;
|
||||
}
|
||||
|
||||
if (!inputDeviceInfo.isNull()) {
|
||||
|
@ -1465,29 +1461,29 @@ bool AudioClient::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDevice
|
|||
_audioOutput->stop();
|
||||
|
||||
delete _audioOutput;
|
||||
_audioOutput = NULL;
|
||||
_audioOutput = nullptr;
|
||||
|
||||
_loopbackOutputDevice = NULL;
|
||||
_loopbackOutputDevice = nullptr;
|
||||
delete _loopbackAudioOutput;
|
||||
_loopbackAudioOutput = NULL;
|
||||
_loopbackAudioOutput = nullptr;
|
||||
|
||||
delete[] _outputMixBuffer;
|
||||
_outputMixBuffer = NULL;
|
||||
_outputMixBuffer = nullptr;
|
||||
|
||||
delete[] _outputScratchBuffer;
|
||||
_outputScratchBuffer = NULL;
|
||||
_outputScratchBuffer = nullptr;
|
||||
|
||||
delete[] _localOutputMixBuffer;
|
||||
_localOutputMixBuffer = NULL;
|
||||
_localOutputMixBuffer = nullptr;
|
||||
}
|
||||
|
||||
if (_networkToOutputResampler) {
|
||||
// if we were using an input to network resampler, delete it here
|
||||
delete _networkToOutputResampler;
|
||||
_networkToOutputResampler = NULL;
|
||||
_networkToOutputResampler = nullptr;
|
||||
|
||||
delete _localToOutputResampler;
|
||||
_localToOutputResampler = NULL;
|
||||
_localToOutputResampler = nullptr;
|
||||
}
|
||||
|
||||
if (!outputDeviceInfo.isNull()) {
|
||||
|
|
|
@ -145,6 +145,8 @@ public:
|
|||
void setPositionGetter(AudioPositionGetter positionGetter) { _positionGetter = positionGetter; }
|
||||
void setOrientationGetter(AudioOrientationGetter orientationGetter) { _orientationGetter = orientationGetter; }
|
||||
|
||||
void setPlayingBackRecording(bool playingBackRecording) { _playingBackRecording = playingBackRecording; }
|
||||
|
||||
Q_INVOKABLE void setAvatarBoundingBoxParameters(glm::vec3 corner, glm::vec3 scale);
|
||||
|
||||
void checkDevices();
|
||||
|
@ -326,14 +328,14 @@ private:
|
|||
// for local audio (used by audio injectors thread)
|
||||
float _localMixBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_STEREO];
|
||||
int16_t _localScratchBuffer[AudioConstants::NETWORK_FRAME_SAMPLES_AMBISONIC];
|
||||
float* _localOutputMixBuffer { NULL };
|
||||
float* _localOutputMixBuffer { nullptr };
|
||||
AudioInjectorsThread _localAudioThread;
|
||||
Mutex _localAudioMutex;
|
||||
|
||||
// for output audio (used by this thread)
|
||||
int _outputPeriod { 0 };
|
||||
float* _outputMixBuffer { NULL };
|
||||
int16_t* _outputScratchBuffer { NULL };
|
||||
float* _outputMixBuffer { nullptr };
|
||||
int16_t* _outputScratchBuffer { nullptr };
|
||||
|
||||
AudioLimiter _audioLimiter;
|
||||
|
||||
|
@ -367,13 +369,16 @@ private:
|
|||
QVector<QString> _inputDevices;
|
||||
QVector<QString> _outputDevices;
|
||||
|
||||
bool _hasReceivedFirstPacket = false;
|
||||
bool _hasReceivedFirstPacket { false };
|
||||
|
||||
QVector<AudioInjector*> _activeLocalAudioInjectors;
|
||||
|
||||
bool _playingBackRecording { false };
|
||||
|
||||
CodecPluginPointer _codec;
|
||||
QString _selectedCodecName;
|
||||
Encoder* _encoder { nullptr }; // for outbound mic stream
|
||||
Encoder* _playbackEncoder { nullptr };
|
||||
|
||||
QThread* _checkDevicesThread { nullptr };
|
||||
};
|
||||
|
|
|
@ -91,4 +91,4 @@ void injectorOptionsFromScriptValue(const QScriptValue& object, AudioInjectorOpt
|
|||
qCWarning(audio) << "Unknown audio injector option:" << it.name();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
debugger;
|
||||
//
|
||||
// Recorder.js
|
||||
// examples
|
||||
|
@ -12,14 +13,14 @@
|
|||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
Script.include("/~/system/libraries/toolBars.js");
|
||||
|
||||
var recordingFile = "recording.rec";
|
||||
var recordingFile = "recording.hfr";
|
||||
|
||||
function setPlayerOptions() {
|
||||
Recording.setPlayFromCurrentLocation(true);
|
||||
Recording.setPlayerUseDisplayName(false);
|
||||
Recording.setPlayerUseAttachments(false);
|
||||
Recording.setPlayerUseHeadModel(false);
|
||||
Recording.setPlayerUseSkeletonModel(false);
|
||||
Recording.setPlayerUseSkeletonModel(true);
|
||||
}
|
||||
|
||||
var windowDimensions = Controller.getViewportDimensions();
|
||||
|
@ -142,7 +143,6 @@ function setupTimer() {
|
|||
backgroundAlpha: 1.0,
|
||||
visible: true
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function updateTimer() {
|
||||
|
@ -272,7 +272,7 @@ function mousePressEvent(event) {
|
|||
}
|
||||
} else if (loadIcon === toolBar.clicked(clickedOverlay)) {
|
||||
if (!Recording.isRecording() && !Recording.isPlaying()) {
|
||||
recordingFile = Window.browse("Load recorcding from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
||||
recordingFile = Window.browse("Load recording from file", ".", "Recordings (*.hfr *.rec *.HFR *.REC)");
|
||||
if (!(recordingFile === "null" || recordingFile === null || recordingFile === "")) {
|
||||
Recording.loadRecording(recordingFile);
|
||||
}
|
||||
|
@ -345,5 +345,3 @@ Script.scriptEnding.connect(scriptEnding);
|
|||
|
||||
// Should be called last to put everything into position
|
||||
moveUI();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue