Audacity 3.2.0
MockSampleBlockFactory.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 MockSampleBlockFactory.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "MockSampleBlock.h"
14#include <numeric> // std::iota
15
17{
19 {
20 std::vector<long long> ids(blockIdCount);
21 std::iota(ids.begin(), ids.end(), 1LL);
22 return { ids.begin(), ids.end() };
23 }
24
26 constSamplePtr src, size_t numsamples, sampleFormat srcformat) override
27 {
28 return std::make_shared<MockSampleBlock>(
29 blockIdCount++, src, numsamples, srcformat);
30 }
31
33 DoCreateSilent(size_t numsamples, sampleFormat srcformat) override
34 {
35 std::vector<char> silence(numsamples * SAMPLE_SIZE(srcformat));
36 return std::make_shared<MockSampleBlock>(
37 blockIdCount++, silence.data(), numsamples, srcformat);
38 }
39
41 DoCreateFromXML(sampleFormat srcformat, const AttributesList& attrs) override
42 {
43 return nullptr;
44 }
45
47 DoCreateFromId (sampleFormat srcformat, SampleBlockID id) override
48 {
49 return nullptr;
50 }
51
52 long long blockIdCount = 0;
53};
std::shared_ptr< SampleBlock > SampleBlockPtr
Definition: CloudSyncDTO.h:25
long long SampleBlockID
Definition: CloudSyncDTO.h:26
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
#define SAMPLE_SIZE(SampleFormat)
Definition: SampleFormat.h:52
const char * constSamplePtr
Definition: SampleFormat.h:58
std::vector< Attribute > AttributesList
Definition: XMLTagHandler.h:40
SampleBlockPtr DoCreateFromId(sampleFormat srcformat, SampleBlockID id) override
SampleBlockPtr DoCreateSilent(size_t numsamples, sampleFormat srcformat) override
SampleBlockIDs GetActiveBlockIDs() override
SampleBlockPtr DoCreate(constSamplePtr src, size_t numsamples, sampleFormat srcformat) override
SampleBlockPtr DoCreateFromXML(sampleFormat srcformat, const AttributesList &attrs) override
abstract base class with methods to produce SampleBlock objects
Definition: SampleBlock.h:117
std::unordered_set< SampleBlockID > SampleBlockIDs
Definition: SampleBlock.h:147