mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Account for stereo audio in recorder
This commit is contained in:
parent
7121126e6f
commit
3a11ed0574
3 changed files with 14 additions and 12 deletions
|
@ -169,6 +169,8 @@ void Player::setupAudioThread() {
|
|||
_audioThread->setObjectName("Player Audio Thread");
|
||||
_options.position = _avatar->getPosition();
|
||||
_options.orientation = _avatar->getOrientation();
|
||||
_options.stereo = _recording->numberAudioChannel() == 2;
|
||||
|
||||
_injector.reset(new AudioInjector(_recording->getAudioData(), _options), &QObject::deleteLater);
|
||||
_injector->moveToThread(_audioThread);
|
||||
_audioThread->start();
|
||||
|
@ -349,15 +351,7 @@ void Player::setCurrentTime(int currentTime) {
|
|||
}
|
||||
}
|
||||
|
||||
_currentFrame = lowestBound;
|
||||
_timerOffset = _recording->getFrameTimestamp(lowestBound);
|
||||
|
||||
if (isPlaying()) {
|
||||
_timer.start();
|
||||
setAudioInjectorPosition();
|
||||
} else {
|
||||
_pausedFrame = lowestBound;
|
||||
}
|
||||
setCurrentFrame(lowestBound);
|
||||
}
|
||||
|
||||
void Player::setVolume(float volume) {
|
||||
|
@ -374,9 +368,7 @@ void Player::setAudioOffset(int audioOffset) {
|
|||
|
||||
void Player::setAudioInjectorPosition() {
|
||||
int MSEC_PER_SEC = 1000;
|
||||
int SAMPLE_SIZE = 2; // 16 bits
|
||||
int CHANNEL_COUNT = 1;
|
||||
int FRAME_SIZE = SAMPLE_SIZE * CHANNEL_COUNT;
|
||||
int FRAME_SIZE = sizeof(AudioConstants::AudioSample) * _recording->numberAudioChannel();
|
||||
int currentAudioFrame = elapsed() * FRAME_SIZE * (AudioConstants::SAMPLE_RATE / MSEC_PER_SEC);
|
||||
_injector->setCurrentSendPosition(currentAudioFrame);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,15 @@ const RecordingFrame& Recording::getFrame(int i) const {
|
|||
return _frames[i];
|
||||
}
|
||||
|
||||
|
||||
int Recording::numberAudioChannel() const {
|
||||
// Check for stereo audio
|
||||
int MSEC_PER_SEC = 1000;
|
||||
int channelLength = (getLength() / MSEC_PER_SEC) *
|
||||
AudioConstants::SAMPLE_RATE * sizeof(AudioConstants::AudioSample);
|
||||
return glm::round((float)channelLength / (float)getAudioData().size());
|
||||
}
|
||||
|
||||
void Recording::addFrame(int timestamp, RecordingFrame &frame) {
|
||||
_timestamps << timestamp;
|
||||
_frames << frame;
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
qint32 getFrameTimestamp(int i) const;
|
||||
const RecordingFrame& getFrame(int i) const;
|
||||
const QByteArray& getAudioData() const { return _audioData; }
|
||||
int numberAudioChannel() const;
|
||||
|
||||
protected:
|
||||
void addFrame(int timestamp, RecordingFrame& frame);
|
||||
|
|
Loading…
Reference in a new issue