Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 10 files). Show all
Unified · Split
| @@ -15,11 +15,11 @@ · 14 unmodified lines | |||
| 15 | #include <recording/Clip.h> | 15 | #include <recording/Clip.h> |
| 16 | #include <recording/Frame.h> | 16 | #include <recording/Frame.h> |
| 17 | #include <NumericalConstants.h> | 17 | #include <NumericalConstants.h> |
| 18 | // FiXME | ||
| 18 | //#include <AudioClient.h> | 19 | //#include <AudioClient.h> |
| 19 | #include <AudioConstants.h> | 20 | #include <AudioConstants.h> |
| 20 | #include <Transform.h> | 21 | #include <Transform.h> |
| 21 | //#include "avatar/AvatarManager.h" | 22 | |
| 22 | //#include "Application.h" | ||
| 23 | #include "ScriptEngineLogging.h" | 23 | #include "ScriptEngineLogging.h" |
| 24 | 24 | ||
| 25 | typedef int16_t AudioSample; | 25 | typedef int16_t AudioSample; |
| @@ -45,6 +45,7 @@ RecordingScriptingInterface::RecordingScriptingInterface() { · 19 unmodified lines | |||
| 45 | _player = DependencyManager::get<Deck>(); | 45 | _player = DependencyManager::get<Deck>(); |
| 46 | _recorder = DependencyManager::get<Recorder>(); | 46 | _recorder = DependencyManager::get<Recorder>(); |
| 47 | 47 | ||
| 48 | // FIXME : Disabling Sound | ||
| 48 | // auto audioClient = DependencyManager::get<AudioClient>(); | 49 | // auto audioClient = DependencyManager::get<AudioClient>(); |
| 49 | // connect(audioClient.data(), &AudioClient::inputReceived, this, &RecordingScriptingInterface::processAudioInput); | 50 | // connect(audioClient.data(), &AudioClient::inputReceived, this, &RecordingScriptingInterface::processAudioInput); |
| 50 | } | 51 | } |
| @@ -53,19 +54,19 @@ void RecordingScriptingInterface::setControlledAvatar(AvatarData* avatar) { · 2 unmodified lines | |||
| 53 | _controlledAvatar = avatar; | 54 | _controlledAvatar = avatar; |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | bool RecordingScriptingInterface::isPlaying() { | 57 | bool RecordingScriptingInterface::isPlaying() const { |
| 57 | return _player->isPlaying(); | 58 | return _player->isPlaying(); |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | bool RecordingScriptingInterface::isPaused() { | 61 | bool RecordingScriptingInterface::isPaused() const { |
| 61 | return _player->isPaused(); | 62 | return _player->isPaused(); |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | float RecordingScriptingInterface::playerElapsed() { | 65 | float RecordingScriptingInterface::playerElapsed() const { |
| 65 | return _player->position(); | 66 | return _player->position(); |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | float RecordingScriptingInterface::playerLength() { | 69 | float RecordingScriptingInterface::playerLength() const { |
| 69 | return _player->length(); | 70 | return _player->length(); |
| 70 | } | 71 | } |
| 71 | 72 | ||
| @@ -90,11 +91,10 @@ void RecordingScriptingInterface::startPlaying() { · 18 unmodified lines | |||
| 90 | QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection); | 91 | QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection); |
| 91 | return; | 92 | return; |
| 92 | } | 93 | } |
| 93 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 94 | |
| 94 | auto myAvatar = _controlledAvatar; | ||
| 95 | // Playback from the current position | 95 | // Playback from the current position |
| 96 | if (_playFromCurrentLocation) { | 96 | if (_playFromCurrentLocation && _controlledAvatar) { |
| 97 | _dummyAvatar.setRecordingBasis(std::make_shared<Transform>(myAvatar->getTransform())); | 97 | _dummyAvatar.setRecordingBasis(std::make_shared<Transform>(_controlledAvatar->getTransform())); |
| 98 | } else { | 98 | } else { |
| 99 | _dummyAvatar.clearRecordingBasis(); | 99 | _dummyAvatar.clearRecordingBasis(); |
| 100 | } | 100 | } |
| @@ -110,6 +110,10 @@ void RecordingScriptingInterface::setPlayerAudioOffset(float audioOffset) { · 9 unmodified lines | |||
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | void RecordingScriptingInterface::setPlayerTime(float time) { | 112 | void RecordingScriptingInterface::setPlayerTime(float time) { |
| 113 | if (QThread::currentThread() != thread()) { | ||
| 114 | QMetaObject::invokeMethod(this, "setPlayerTime", Qt::BlockingQueuedConnection, Q_ARG(float, time)); | ||
| 115 | return; | ||
| 116 | } | ||
| 113 | _player->seek(time); | 117 | _player->seek(time); |
| 114 | } | 118 | } |
| 115 | 119 | ||
| @@ -137,23 +141,27 @@ void RecordingScriptingInterface::setPlayerUseSkeletonModel(bool useSkeletonMode · 21 unmodified lines | |||
| 137 | _useSkeletonModel = useSkeletonModel; | 141 | _useSkeletonModel = useSkeletonModel; |
| 138 | } | 142 | } |
| 139 | 143 | ||
| 140 | void RecordingScriptingInterface::play() { | ||
| 141 | _player->play(); | ||
| 142 | } | ||
| 143 | |||
| 144 | void RecordingScriptingInterface::pausePlayer() { | 144 | void RecordingScriptingInterface::pausePlayer() { |
| 145 | if (QThread::currentThread() != thread()) { | ||
| 146 | QMetaObject::invokeMethod(this, "pausePlayer", Qt::BlockingQueuedConnection); | ||
| 147 | return; | ||
| 148 | } | ||
| 145 | _player->pause(); | 149 | _player->pause(); |
| 146 | } | 150 | } |
| 147 | 151 | ||
| 148 | void RecordingScriptingInterface::stopPlaying() { | 152 | void RecordingScriptingInterface::stopPlaying() { |
| 153 | if (QThread::currentThread() != thread()) { | ||
| 154 | QMetaObject::invokeMethod(this, "stopPlaying", Qt::BlockingQueuedConnection); | ||
| 155 | return; | ||
| 156 | } | ||
| 149 | _player->stop(); | 157 | _player->stop(); |
| 150 | } | 158 | } |
| 151 | 159 | ||
| 152 | bool RecordingScriptingInterface::isRecording() { | 160 | bool RecordingScriptingInterface::isRecording() const { |
| 153 | return _recorder->isRecording(); | 161 | return _recorder->isRecording(); |
| 154 | } | 162 | } |
| 155 | 163 | ||
| 156 | float RecordingScriptingInterface::recorderElapsed() { | 164 | float RecordingScriptingInterface::recorderElapsed() const { |
| 157 | return _recorder->position(); | 165 | return _recorder->position(); |
| 158 | } | 166 | } |
| 159 | 167 | ||
| @@ -170,29 +178,21 @@ void RecordingScriptingInterface::startRecording() { · 10 unmodified lines | |||
| 170 | 178 | ||
| 171 | _recordingEpoch = Frame::epochForFrameTime(0); | 179 | _recordingEpoch = Frame::epochForFrameTime(0); |
| 172 | 180 | ||
| 173 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 181 | if (_controlledAvatar) { |
| 174 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 182 | _controlledAvatar->setRecordingBasis(); |
| 175 | auto myAvatar = _controlledAvatar; | 183 | } |
| 176 | myAvatar->setRecordingBasis(); | 184 | |
| 177 | _recorder->start(); | 185 | _recorder->start(); |
| 178 | } | 186 | } |
| 179 | 187 | ||
| 180 | void RecordingScriptingInterface::stopRecording() { | 188 | void RecordingScriptingInterface::stopRecording() { |
| 181 | _recorder->stop(); | 189 | _recorder->stop(); |
| 182 | |||
| 183 | _lastClip = _recorder->getClip(); | 190 | _lastClip = _recorder->getClip(); |
| 184 | // post-process the audio into discreet chunks based on times of received samples | ||
| 185 | _lastClip->seek(0); | ||
| 186 | Frame::ConstPointer frame; | ||
| 187 | while (frame = _lastClip->nextFrame()) { | ||
| 188 | qDebug() << "Frame time " << frame->timeOffset << " size " << frame->data.size(); | ||
| 189 | } | ||
| 190 | _lastClip->seek(0); | 191 | _lastClip->seek(0); |
| 191 | 192 | ||
| 192 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 193 | if (_controlledAvatar) { |
| 193 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 194 | _controlledAvatar->clearRecordingBasis(); |
| 194 | auto myAvatar = _controlledAvatar; | 195 | } |
| 195 | myAvatar->clearRecordingBasis(); | ||
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | void RecordingScriptingInterface::saveRecording(const QString& filename) { | 198 | void RecordingScriptingInterface::saveRecording(const QString& filename) { |
| @@ -228,28 +228,32 @@ void RecordingScriptingInterface::loadLastRecording() { · 29 unmodified lines | |||
| 228 | void RecordingScriptingInterface::processAvatarFrame(const Frame::ConstPointer& frame) { | 228 | void RecordingScriptingInterface::processAvatarFrame(const Frame::ConstPointer& frame) { |
| 229 | Q_ASSERT(QThread::currentThread() == thread()); | 229 | Q_ASSERT(QThread::currentThread() == thread()); |
| 230 | 230 | ||
| 231 | if (!_controlledAvatar) { | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 231 | AvatarData::fromFrame(frame->data, _dummyAvatar); | 235 | AvatarData::fromFrame(frame->data, _dummyAvatar); |
| 232 | 236 | ||
| 233 | //auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 237 | |
| 234 | auto myAvatar = _controlledAvatar; | 238 | |
| 235 | if (_useHeadModel && _dummyAvatar.getFaceModelURL().isValid() && | 239 | if (_useHeadModel && _dummyAvatar.getFaceModelURL().isValid() && |
| 236 | (_dummyAvatar.getFaceModelURL() != myAvatar->getFaceModelURL())) { | 240 | (_dummyAvatar.getFaceModelURL() != _controlledAvatar->getFaceModelURL())) { |
| 237 | // FIXME | 241 | // FIXME |
| 238 | //myAvatar->setFaceModelURL(_dummyAvatar.getFaceModelURL()); | 242 | //myAvatar->setFaceModelURL(_dummyAvatar.getFaceModelURL()); |
| 239 | } | 243 | } |
| 240 | 244 | ||
| 241 | if (_useSkeletonModel && _dummyAvatar.getSkeletonModelURL().isValid() && | 245 | if (_useSkeletonModel && _dummyAvatar.getSkeletonModelURL().isValid() && |
| 242 | (_dummyAvatar.getSkeletonModelURL() != myAvatar->getSkeletonModelURL())) { | 246 | (_dummyAvatar.getSkeletonModelURL() != _controlledAvatar->getSkeletonModelURL())) { |
| 243 | // FIXME | 247 | // FIXME |
| 244 | //myAvatar->useFullAvatarURL() | 248 | //myAvatar->useFullAvatarURL() |
| 245 | } | 249 | } |
| 246 | 250 | ||
| 247 | if (_useDisplayName && _dummyAvatar.getDisplayName() != myAvatar->getDisplayName()) { | 251 | if (_useDisplayName && _dummyAvatar.getDisplayName() != _controlledAvatar->getDisplayName()) { |
| 248 | myAvatar->setDisplayName(_dummyAvatar.getDisplayName()); | 252 | _controlledAvatar->setDisplayName(_dummyAvatar.getDisplayName()); |
| 249 | } | 253 | } |
| 250 | 254 | ||
| 251 | myAvatar->setPosition(_dummyAvatar.getPosition()); | 255 | _controlledAvatar->setPosition(_dummyAvatar.getPosition()); |
| 252 | myAvatar->setOrientation(_dummyAvatar.getOrientation()); | 256 | _controlledAvatar->setOrientation(_dummyAvatar.getOrientation()); |
| 253 | 257 | ||
| 254 | // FIXME attachments | 258 | // FIXME attachments |
| 255 | // FIXME joints | 259 | // FIXME joints |