Audacity 3.2.0
StretchingSequence.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 StretchingSequence.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "AudioIOSequences.h"
14#include "PlaybackDirection.h"
15
16#include <memory>
17#include <optional>
18#include <vector>
19
20class AudioSegment;
22class ClipInterface;
23using ClipHolders = std::vector<std::shared_ptr<ClipInterface>>;
24
25// For now this class assumes forward reading, which will be sufficient for the
26// first goal of allowing export and rendering.
27class STRETCHING_SEQUENCE_API StretchingSequence final : public PlayableSequence
28{
29public:
30 static std::shared_ptr<StretchingSequence>
31 Create(const PlayableSequence&, const ClipHolders& clips);
32
34 const PlayableSequence&, int sampleRate, size_t numChannels,
35 std::unique_ptr<AudioSegmentFactoryInterface>);
36
37 // WideSampleSequence
38 size_t NChannels() const override;
39 float GetChannelGain(int channel) const override;
40 double GetStartTime() const override;
41 double GetEndTime() const override;
42 double GetRate() const override;
43 sampleFormat WidestEffectiveFormat() const override;
44 bool HasTrivialEnvelope() const override;
46 double* buffer, size_t bufferLen, double t0,
47 bool backwards) const override;
48 bool DoGet(
49 size_t iChannel, size_t nBuffers, const samplePtr buffers[],
50 sampleFormat format, sampleCount start, size_t len, bool backwards,
51 fillFormat fill = FillFormat::fillZero, bool mayThrow = true,
52 sampleCount* pNumWithinClips = nullptr) const override;
53
54 // PlayableSequence
55 const ChannelGroup *FindChannelGroup() const override;
56 bool GetSolo() const override;
57 bool GetMute() const override;
58
59 // AudioGraph::Channel
61
62 // class methods
63 bool GetFloats(
64 float* buffers[], sampleCount start, size_t len, bool backwards) const;
65
66private:
67 using AudioSegments = std::vector<std::shared_ptr<AudioSegment>>;
68
69 void ResetCursor(double t, PlaybackDirection);
70 bool GetNext(float *const buffers[], size_t numChannels, size_t numSamples);
71 bool MutableGet(
72 size_t iChannel, size_t nBuffers, const samplePtr buffers[],
73 sampleFormat format, sampleCount start, size_t len, bool backwards);
74
76 const std::unique_ptr<AudioSegmentFactoryInterface> mAudioSegmentFactory;
78 AudioSegments::const_iterator mActiveAudioSegmentIt = mAudioSegments.end();
79 std::optional<sampleCount> mExpectedStart;
81};
std::vector< std::shared_ptr< ClipInterface > > ClipHolders
PlaybackDirection
sampleFormat
The ordering of these values with operator < agrees with the order of increasing bit width.
Definition: SampleFormat.h:30
char * samplePtr
Definition: SampleFormat.h:57
enum FillFormat fillFormat
A generalization for audio segments, whether clips or silence between clips.
Definition: AudioSegment.h:23
AudioSegments mAudioSegments
const PlayableSequence & mSequence
const std::unique_ptr< AudioSegmentFactoryInterface > mAudioSegmentFactory
std::optional< sampleCount > mExpectedStart
std::vector< std::shared_ptr< AudioSegment > > AudioSegments
virtual float GetChannelGain(int channel) const =0
virtual bool HasTrivialEnvelope() const =0
virtual double GetStartTime() const =0
virtual void GetEnvelopeValues(double *buffer, size_t bufferLen, double t0, bool backwards) const =0
virtual sampleFormat WidestEffectiveFormat() const =0
virtual bool DoGet(size_t iChannel, size_t nBuffers, const samplePtr buffers[], sampleFormat format, sampleCount start, size_t len, bool backward, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const =0
virtual double GetEndTime() const =0
bool GetFloats(size_t iChannel, size_t nBuffers, float *const buffers[], sampleCount start, size_t len, bool backwards=false, fillFormat fill=FillFormat::fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
virtual size_t NChannels() const =0
A constant property.
virtual double GetRate() const =0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
ChannelType
Mutually exclusive channel classifications.
virtual ChannelType GetChannelType() const =0
Classify this channel.
virtual const ChannelGroup * FindChannelGroup() const =0
Find associated ChannelGroup if any.
virtual bool GetSolo() const =0
May vary asynchronously.
virtual bool GetMute() const =0
May vary asynchronously.