23 const std::vector<DynamicRangeProcessorOutputPacket>& packets)
31 const int numNewPackets = packets.size();
33 std::make_optional(
mSegments[0].back().time) :
36 const auto firstPacketToInsertIt =
37 std::find_if(packets.begin(), packets.end(), [&](
const auto& packet) {
38 return !lastPacketTime.has_value() ||
39 GetPacketTime(packet) > *lastPacketTime;
42 if (firstPacketToInsertIt == packets.end())
47 firstPacketToInsertIt->indexOfFirstSample ==
55 packets.back().indexOfFirstSample + packets.back().numSamples;
60 firstPacketToInsertIt, packets.end(), std::back_inserter(lastSegment),
61 [&](
const auto& packet) ->
Packet {
62 const auto t = GetPacketTime(packet);
63 return { t, packet.targetCompressionDb, packet.actualCompressionDb,
64 packet.inputDb, packet.outputDb };
71 const auto lastTime = lastSegment.back().time;
72 auto& firstSegment = mSegments.front();
73 const auto it = std::find_if(
74 firstSegment.begin(), firstSegment.end(),
75 [lastTime](
const Packet& packet) {
78 return lastTime - packet.time < maxTimeSeconds + 1.f;
80 firstSegment.erase(firstSegment.begin(), it);
82 if (firstSegment.empty())
83 mSegments.erase(mSegments.begin());
91const std::vector<DynamicRangeProcessorHistory::Segment>&
101 [](
const auto& segment) { return segment.empty(); });
std::vector< Segment > mSegments
void Push(const std::vector< DynamicRangeProcessorOutputPacket > &packets)
const std::vector< Segment > & GetSegments() const
std::optional< long long > mFirstPacketFirstSampleIndex
float GetPacketTime(const DynamicRangeProcessorOutputPacket &packet) const
DynamicRangeProcessorHistory(double sampleRate)
std::optional< long long > mExpectedNextPacketFirstSampleIndex
constexpr auto sampleRate
long long indexOfFirstSample