Skip to content

Commit

Permalink
audio receive pipe line for mix mode (#325)
Browse files Browse the repository at this point in the history
JB, DTX, timescale
  • Loading branch information
olofkallander authored Oct 26, 2023
1 parent 2fd811e commit c20f274
Show file tree
Hide file tree
Showing 39 changed files with 3,827 additions and 31 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ set(FILES
codec/OpusEncoder.cpp
codec/OpusEncoder.h
codec/Vp8Header.h
codec/AudioTools.h
codec/AudioTools.cpp
codec/NoiseFloor.cpp
codec/AudioReceivePipeline.h
codec/AudioReceivePipeline.cpp
codec/SpscAudioBuffer.h
concurrency/EventSemaphore.cpp
concurrency/EventSemaphore.h
concurrency/LockFreeList.cpp
Expand Down Expand Up @@ -338,6 +344,12 @@ set(FILES
rtp/SendTimeDial.h
rtp/JitterTracker.h
rtp/JitterTracker.cpp
rtp/JitterEstimator.h
rtp/JitterEstimator.cpp
rtp/RtpDelayTracker.h
rtp/RtpDelayTracker.cpp
rtp/JitterBufferList.cpp
rtp/JitterBufferList.h
test/macros.h
transport/UdpEndpoint.h
transport/BaseUdpEndpoint.cpp
Expand Down Expand Up @@ -528,6 +540,8 @@ set(TEST_LIB_FILES
test/integration/emulator/FakeTcpServerEndpoint.h
test/integration/emulator/FakeTcpServerEndpoint.cpp
test/integration/emulator/Httpd.cpp
test/integration/emulator/JitterPacketSource.h
test/integration/emulator/JitterPacketSource.cpp
test/CsvWriter.h
test/CsvWriter.cpp
test/ResourceLoader.cpp
Expand Down Expand Up @@ -579,6 +593,7 @@ set(TEST_FILES
test/transport/SrtpTest.cpp
test/transport/Ipv6Test.cpp
test/transport/JitterTest.cpp
test/transport/AdaptiveJitterTest.cpp
test/integration/TimeTurnerTest.cpp
test/config/ConfigTest.cpp
test/codec/AudioProcessingTest.cpp
Expand Down Expand Up @@ -625,7 +640,8 @@ set(TEST_FILES
test/bridge/VideoNackReceiveJobTest.cpp
test/utils/LogSpamTest.cpp
test/utils/FunctionTest.cpp
test/bridge/RtpAudioRewriterTest.cpp)
test/bridge/RtpAudioRewriterTest.cpp
test/transport/JitterTest.cpp)


set(TEST_FILES2
Expand Down
61 changes: 61 additions & 0 deletions codec/AudioFader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once
#include <cstdint>
#include <math.h>

namespace codec
{

// fades in
class AudioLinearFade
{
public:
AudioLinearFade(uint32_t rampDurationInSamples) : _stepFactor(1.0 / rampDurationInSamples), _volume(0) {}

void fadeInStereo(const int16_t* srcData, int16_t* outData, size_t sampleCount)
{

for (size_t i = 0; i < sampleCount; ++i)
{
_volume = std::min(1.0, _volume + _stepFactor);
outData[i * 2] = srcData[i * 2] * _volume;
outData[i * 2 + 1] = srcData[i * 2 + 1] * _volume;
}
}

void fadeInStereo(int16_t* inOutData, size_t sampleCount)
{
return fadeInStereo(inOutData, inOutData, sampleCount);
}

void fadeOutStereo(const int16_t* srcData, int16_t* outData, size_t sampleCount)
{
for (size_t i = 0; i < sampleCount; ++i)
{
_volume = std::min(1.0, _volume + _stepFactor);
const auto amp = 1.0 - _volume;
outData[i * 2] = srcData[i * 2] * amp;
outData[i * 2 + 1] = srcData[i * 2 + 1] * amp;
}
}

void fadeOutStereo(int16_t* data, size_t sampleCount) { fadeOutStereo(data, data, sampleCount); }

double next()
{
if (_volume >= 1.0)
{
return 1.0;
}
_volume += _stepFactor;
return _volume;
}

void reset() { _volume = 0; }
double get() const { return _volume; }

private:
const double _stepFactor;
double _volume;
};

} // namespace codec
Loading

0 comments on commit c20f274

Please sign in to comment.