Audacity 3.2.0
ClipSegment.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 ClipSegment.h
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
13#include "AudioSegment.h"
15#include "Observer.h"
16#include "PlaybackDirection.h"
17#include <atomic>
18#include <memory>
19
20class ClipInterface;
22
24 std::function<void(std::function<void(double)>)>;
25
30class STRETCHING_SEQUENCE_API ClipSegment final : public AudioSegment
31{
32public:
34 double durationToDiscard, PlaybackDirection);
35 ~ClipSegment() override;
36
37 // AudioSegment
38 size_t GetFloats(float* const* buffers, size_t numSamples) override;
39 bool Empty() const override;
40 size_t NChannels() const override;
41
42private:
44 sampleCount mTotalNumSamplesProduced = 0;
48 std::atomic<bool> mUpdateFormantPreservation = false;
49 std::atomic<bool> mUpdateCentShift = false;
50 // Careful that this guy is constructed after `mSource`, which it refers to
51 // in its ctor.
52 // todo(mhodgkinson) make this safe.
53 std::unique_ptr<TimeAndPitchInterface> mStretcher;
56};
std::function< void(std::function< void(double)>)> PitchRatioChangeCbSubscriber
Definition: ClipSegment.h:24
PlaybackDirection
A generalization for audio segments, whether clips or silence between clips.
Definition: AudioSegment.h:23
virtual size_t GetFloats(float *const *buffers, size_t numSamples)=0
Fills buffers with as many as numSamples or the number of remaining samples, whichever is smaller.
virtual bool Empty() const =0
Whether the segment has no more samples to provide.
virtual size_t NChannels() const =0
The number of channels in the segment.
int mCentShift
Definition: ClipSegment.h:47
Observer::Subscription mOnSemitoneShiftChangeSubscription
Definition: ClipSegment.h:54
ClipTimeAndPitchSource mSource
Definition: ClipSegment.h:45
std::unique_ptr< TimeAndPitchInterface > mStretcher
Definition: ClipSegment.h:53
Observer::Subscription mOnFormantPreservationChangeSubscription
Definition: ClipSegment.h:55
bool mPreserveFormants
Definition: ClipSegment.h:46
const sampleCount mTotalNumSamplesToProduce
Definition: ClipSegment.h:43
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19