mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
commit
948ced81ce
5 changed files with 18 additions and 16 deletions
|
@ -812,7 +812,7 @@ void AudioClient::handleAudioInput() {
|
|||
}
|
||||
|
||||
emit inputReceived(QByteArray(reinterpret_cast<const char*>(networkAudioSamples),
|
||||
AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL));
|
||||
AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * sizeof(AudioConstants::AudioSample)));
|
||||
|
||||
} else {
|
||||
// our input loudness is 0, since we're muted
|
||||
|
|
|
@ -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();
|
||||
|
@ -309,7 +311,7 @@ void Player::setCurrentFrame(int currentFrame) {
|
|||
|
||||
if (isPlaying()) {
|
||||
_timer.start();
|
||||
setAudionInjectorPosition();
|
||||
setAudioInjectorPosition();
|
||||
} else {
|
||||
_pausedFrame = _currentFrame;
|
||||
}
|
||||
|
@ -349,15 +351,7 @@ void Player::setCurrentTime(int currentTime) {
|
|||
}
|
||||
}
|
||||
|
||||
_currentFrame = lowestBound;
|
||||
_timerOffset = _recording->getFrameTimestamp(lowestBound);
|
||||
|
||||
if (isPlaying()) {
|
||||
_timer.start();
|
||||
setAudionInjectorPosition();
|
||||
} else {
|
||||
_pausedFrame = lowestBound;
|
||||
}
|
||||
setCurrentFrame(lowestBound);
|
||||
}
|
||||
|
||||
void Player::setVolume(float volume) {
|
||||
|
@ -372,11 +366,9 @@ void Player::setAudioOffset(int audioOffset) {
|
|||
_audioOffset = audioOffset;
|
||||
}
|
||||
|
||||
void Player::setAudionInjectorPosition() {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ private:
|
|||
void setupAudioThread();
|
||||
void cleanupAudioThread();
|
||||
void loopRecording();
|
||||
void setAudionInjectorPosition();
|
||||
void setAudioInjectorPosition();
|
||||
bool computeCurrentFrame();
|
||||
|
||||
AvatarData* _avatar;
|
||||
|
|
|
@ -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