Audacity 3.2.0
ClipMirAudioReader.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 ClipMirAudioReader.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "AcidizerTags.h"
15#include "MirTypes.h"
16#include "WaveTrack.h"
17
18#include <array>
19#include <optional>
20
21class ClipInterface;
22
24{
25public:
27 std::optional<LibFileFormats::AcidizerTags> tags, std::string filename,
28 WaveTrack& singleClipWaveTrack);
29
30 const std::optional<LibFileFormats::AcidizerTags> tags;
31 const std::string filename;
33
34 double GetSampleRate() const override;
35 long long GetNumSamples() const override;
36
41 void
42 ReadFloats(float* buffer, long long where, size_t numFrames) const override;
43
44private:
45 void AddChannel(
46 size_t iChannel, float* buffer, sampleCount start, size_t len) const;
47
48 const std::shared_ptr<const ClipInterface> mClip;
49
50 // An array with two entries because maybe two channels, and each channel has
51 // two caches to cope with back-and-forth access between beginning and end
52 // of clip data, in case samples are queried circularly.
53 using ChannelCache = std::array<std::optional<AudioSegmentSampleView>, 2>;
54 mutable std::array<ChannelCache, 2> mCache;
55 mutable std::array<bool, 2> mUseFirst { true, true };
56};
An audio segment is either a whole clip or the silence between clips. Views allow shared references t...
const std::optional< LibFileFormats::AcidizerTags > tags
double GetSampleRate() const override
const std::string filename
const std::shared_ptr< const ClipInterface > mClip
void AddChannel(size_t iChannel, float *buffer, sampleCount start, size_t len) const
ClipMirAudioReader(std::optional< LibFileFormats::AcidizerTags > tags, std::string filename, WaveTrack &singleClipWaveTrack)
const WaveTrack::IntervalHolder clip
long long GetNumSamples() const override
std::array< bool, 2 > mUseFirst
std::array< ChannelCache, 2 > mCache
void ReadFloats(float *buffer, long long where, size_t numFrames) const override
std::array< std::optional< AudioSegmentSampleView >, 2 > ChannelCache
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
std::shared_ptr< Interval > IntervalHolder
Definition: WaveTrack.h:209
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19