Audacity 3.2.0
AudioSegmentSampleView.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 @file AudioSegmentSampleView.h
7 @brief An audio segment is either a whole clip or the silence between clips.
8Views allow shared references to the same memory yet over instance-specific
9ranges.
10
11 Matthieu Hodgkinson
12
13**********************************************************************/
14#pragma once
15
16#include "SampleCount.h"
17
18#include <chrono>
19#include <fstream>
20#include <memory>
21#include <vector>
22
23using BlockSampleView = std::shared_ptr<std::vector<float>>;
24
25class STRETCHING_SEQUENCE_API AudioSegmentSampleView final
26{
27public:
38 std::vector<BlockSampleView> blockViews, size_t start, size_t length);
39
44 AudioSegmentSampleView(size_t length);
45
50 void Copy(float* buffer, size_t bufferSize) const;
51
56 void AddTo(float* buffer, size_t bufferSize) const;
57
61 size_t GetSampleCount() const;
62
63private:
64 void DoCopy(float* buffer, size_t bufferSize) const;
65 void DoAdd(float* buffer, size_t bufferSize) const;
66
67 const std::vector<BlockSampleView> mBlockViews;
68 const size_t mStart = 0;
69 const size_t mLength;
70 const bool mIsSilent;
71};
72
73using ChannelSampleView = std::vector<AudioSegmentSampleView>;
std::shared_ptr< std::vector< float > > BlockSampleView
std::vector< AudioSegmentSampleView > ChannelSampleView
const std::vector< BlockSampleView > mBlockViews