mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:17:02 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into metavoxels
This commit is contained in:
commit
a90dbe314b
1 changed files with 5 additions and 5 deletions
|
@ -174,9 +174,8 @@ void linearResampling(int16_t* sourceSamples, int16_t* destinationSamples,
|
||||||
if (sourceAudioFormat == destinationAudioFormat) {
|
if (sourceAudioFormat == destinationAudioFormat) {
|
||||||
memcpy(destinationSamples, sourceSamples, numSourceSamples * sizeof(int16_t));
|
memcpy(destinationSamples, sourceSamples, numSourceSamples * sizeof(int16_t));
|
||||||
} else {
|
} else {
|
||||||
int destinationChannels = (destinationAudioFormat.channelCount() >= 2) ? 2 : destinationAudioFormat.channelCount();
|
|
||||||
float sourceToDestinationFactor = (sourceAudioFormat.sampleRate() / (float) destinationAudioFormat.sampleRate())
|
float sourceToDestinationFactor = (sourceAudioFormat.sampleRate() / (float) destinationAudioFormat.sampleRate())
|
||||||
* (sourceAudioFormat.channelCount() / (float) destinationChannels);
|
* (sourceAudioFormat.channelCount() / (float) destinationAudioFormat.channelCount());
|
||||||
|
|
||||||
// take into account the number of channels in source and destination
|
// take into account the number of channels in source and destination
|
||||||
// accomodate for the case where have an output with > 2 channels
|
// accomodate for the case where have an output with > 2 channels
|
||||||
|
@ -203,14 +202,15 @@ void linearResampling(int16_t* sourceSamples, int16_t* destinationSamples,
|
||||||
// upsample from 24 to 48
|
// upsample from 24 to 48
|
||||||
// for now this only supports a stereo to stereo conversion - this is our case for network audio to output
|
// for now this only supports a stereo to stereo conversion - this is our case for network audio to output
|
||||||
int sourceIndex = 0;
|
int sourceIndex = 0;
|
||||||
int destinationToSourceFactor = (1 / sourceToDestinationFactor);
|
|
||||||
int dtsSampleRateFactor = (destinationAudioFormat.sampleRate() / sourceAudioFormat.sampleRate());
|
int dtsSampleRateFactor = (destinationAudioFormat.sampleRate() / sourceAudioFormat.sampleRate());
|
||||||
|
int sampleShift = destinationAudioFormat.channelCount() * dtsSampleRateFactor;
|
||||||
|
int destinationToSourceFactor = (1 / sourceToDestinationFactor);
|
||||||
|
|
||||||
for (int i = 0; i < numDestinationSamples; i += destinationAudioFormat.channelCount() * dtsSampleRateFactor) {
|
for (int i = 0; i < numDestinationSamples; i += sampleShift) {
|
||||||
sourceIndex = (i / destinationToSourceFactor);
|
sourceIndex = (i / destinationToSourceFactor);
|
||||||
|
|
||||||
// fill the L/R channels and make the rest silent
|
// fill the L/R channels and make the rest silent
|
||||||
for (int j = i; j < i + (dtsSampleRateFactor * destinationAudioFormat.channelCount()); j++) {
|
for (int j = i; j < i + sampleShift; j++) {
|
||||||
if (j % destinationAudioFormat.channelCount() == 0) {
|
if (j % destinationAudioFormat.channelCount() == 0) {
|
||||||
// left channel
|
// left channel
|
||||||
destinationSamples[j] = sourceSamples[sourceIndex];
|
destinationSamples[j] = sourceSamples[sourceIndex];
|
||||||
|
|
Loading…
Reference in a new issue