mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 02:53:43 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into 19483
This commit is contained in:
commit
f6927bae10
2 changed files with 22 additions and 2 deletions
|
@ -57,7 +57,7 @@ void AudioInjector::injectAudio() {
|
|||
currentPacketPosition += rfcSessionUUID.size();
|
||||
|
||||
// pick a random UUID to use for this stream
|
||||
QUuid randomStreamUUID;
|
||||
QUuid randomStreamUUID = QUuid::createUuid();
|
||||
QByteArray rfcStreamUUID = randomStreamUUID.toRfc4122();
|
||||
memcpy(currentPacketPosition, rfcStreamUUID, rfcStreamUUID.size());
|
||||
currentPacketPosition += rfcStreamUUID.size();
|
||||
|
|
|
@ -27,5 +27,25 @@ Sound::Sound(const QUrl& sampleURL, QObject* parent) :
|
|||
|
||||
void Sound::replyFinished(QNetworkReply* reply) {
|
||||
// replace our byte array with the downloaded data
|
||||
_byteArray = reply->readAll();
|
||||
QByteArray rawAudioByteArray = reply->readAll();
|
||||
|
||||
// assume that this was a RAW file and is now an array of samples that are
|
||||
// signed, 16-bit, 48Khz, mono
|
||||
|
||||
// we want to convert it to the format that the audio-mixer wants
|
||||
// which is signed, 16-bit, 24Khz, mono
|
||||
|
||||
_byteArray.resize(rawAudioByteArray.size() / 2);
|
||||
|
||||
int numSourceSamples = rawAudioByteArray.size() / sizeof(int16_t);
|
||||
int16_t* sourceSamples = (int16_t*) rawAudioByteArray.data();
|
||||
int16_t* destinationSamples = (int16_t*) _byteArray.data();
|
||||
|
||||
for (int i = 1; i < numSourceSamples; i += 2) {
|
||||
if (i + 1 >= numSourceSamples) {
|
||||
destinationSamples[(i - 1) / 2] = (sourceSamples[i - 1] / 2) + (sourceSamples[i] / 2);
|
||||
} else {
|
||||
destinationSamples[(i - 1) / 2] = (sourceSamples[i - 1] / 4) + (sourceSamples[i] / 2) + (sourceSamples[i + 1] / 4);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue