Audacity 3.2.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
FloatVectorClip Class Reference

#include <FloatVectorClip.h>

Inheritance diagram for FloatVectorClip:
[legend]
Collaboration diagram for FloatVectorClip:
[legend]

Public Member Functions

 FloatVectorClip (int sampleRate, const std::vector< std::vector< float > > &audio)
 
 FloatVectorClip (int sampleRate, const std::vector< float > &audio, size_t numChannels)
 
AudioSegmentSampleView GetSampleView (size_t iChannel, sampleCount start, size_t len, bool mayThrow) const override
 
sampleCount GetVisibleSampleCount () const override
 
size_t NChannels () const override
 
int GetRate () const override
 
double GetPlayStartTime () const override
 
double GetPlayEndTime () const override
 
sampleCount TimeToSamples (double time) const override
 
double GetStretchRatio () const override
 
int GetCentShift () const override
 
Observer::Subscription SubscribeToCentShiftChange (std::function< void(int)> cb) const override
 
PitchAndSpeedPreset GetPitchAndSpeedPreset () const override
 
Observer::Subscription SubscribeToPitchAndSpeedPresetChange (std::function< void(PitchAndSpeedPreset)> cb) const override
 
- Public Member Functions inherited from ClipInterface
 ~ClipInterface () override
 
virtual AudioSegmentSampleView GetSampleView (size_t iChannel, sampleCount start, size_t length, bool mayThrow=true) const =0
 
virtual size_t NChannels () const =0
 
virtual int GetCentShift () const =0
 
virtual Observer::Subscription SubscribeToCentShiftChange (std::function< void(int)> cb) const =0
 
virtual PitchAndSpeedPreset GetPitchAndSpeedPreset () const =0
 
virtual Observer::Subscription SubscribeToPitchAndSpeedPresetChange (std::function< void(PitchAndSpeedPreset)> cb) const =0
 
- Public Member Functions inherited from ClipTimes
virtual ~ClipTimes ()
 
virtual sampleCount GetVisibleSampleCount () const =0
 
virtual int GetRate () const =0
 
virtual double GetPlayStartTime () const =0
 
virtual double GetPlayEndTime () const =0
 
virtual sampleCount TimeToSamples (double time) const =0
 
virtual double GetStretchRatio () const =0
 

Public Attributes

double stretchRatio = 1.
 
double playStartTime = 0.
 

Private Member Functions

double GetPlayDuration () const
 

Private Attributes

const int mSampleRate
 
const std::vector< std::vector< float > > mAudio
 

Detailed Description


Audacity: A Digital Audio Editor

FloatVectorClip.h

Matthieu Hodgkinson

Definition at line 15 of file FloatVectorClip.h.

Constructor & Destructor Documentation

◆ FloatVectorClip() [1/2]

FloatVectorClip::FloatVectorClip ( int  sampleRate,
const std::vector< std::vector< float > > &  audio 
)

Audacity: A Digital Audio Editor

FloatVectorClip.cpp

Matthieu Hodgkinson

Definition at line 15 of file FloatVectorClip.cpp.

18 , mAudio { audio }
19{
20}
MockedAudio audio
const int mSampleRate
const std::vector< std::vector< float > > mAudio

◆ FloatVectorClip() [2/2]

FloatVectorClip::FloatVectorClip ( int  sampleRate,
const std::vector< float > &  audio,
size_t  numChannels 
)

Definition at line 34 of file FloatVectorClip.cpp.

37{
38}
FloatVectorClip(int sampleRate, const std::vector< std::vector< float > > &audio)
std::vector< std::vector< float > > Duplicate(const std::vector< float > &audio, size_t numChannels)

Member Function Documentation

◆ GetCentShift()

int FloatVectorClip::GetCentShift ( ) const
inlineoverridevirtual

Implements ClipInterface.

Definition at line 52 of file FloatVectorClip.h.

53 {
54 return 0;
55 }

◆ GetPitchAndSpeedPreset()

PitchAndSpeedPreset FloatVectorClip::GetPitchAndSpeedPreset ( ) const
inlineoverridevirtual

Implements ClipInterface.

Definition at line 63 of file FloatVectorClip.h.

References Default.

◆ GetPlayDuration()

double FloatVectorClip::GetPlayDuration ( ) const
private

Definition at line 71 of file FloatVectorClip.cpp.

72{
73 return stretchRatio * mAudio[0].size() / mSampleRate;
74}

References mAudio, mSampleRate, and stretchRatio.

Referenced by GetPlayEndTime().

Here is the caller graph for this function:

◆ GetPlayEndTime()

double FloatVectorClip::GetPlayEndTime ( ) const
inlineoverridevirtual

Implements ClipTimes.

Definition at line 40 of file FloatVectorClip.h.

41 {
43 }
double GetPlayDuration() const

References GetPlayDuration(), and playStartTime.

Here is the call graph for this function:

◆ GetPlayStartTime()

double FloatVectorClip::GetPlayStartTime ( ) const
inlineoverridevirtual

Implements ClipTimes.

Definition at line 35 of file FloatVectorClip.h.

36 {
37 return playStartTime;
38 }

References playStartTime.

◆ GetRate()

int FloatVectorClip::GetRate ( ) const
overridevirtual

Implements ClipTimes.

Definition at line 61 of file FloatVectorClip.cpp.

62{
63 return mSampleRate;
64}

References mSampleRate.

Referenced by TimeToSamples().

Here is the caller graph for this function:

◆ GetSampleView()

AudioSegmentSampleView FloatVectorClip::GetSampleView ( size_t  iChannel,
sampleCount  start,
size_t  len,
bool  mayThrow 
) const
overridevirtual

Implements ClipInterface.

Definition at line 40 of file FloatVectorClip.cpp.

42{
43 std::vector<BlockSampleView> blockViews {
44 std::make_shared<std::vector<float>>(mAudio[iChannel])
45 };
46 // todo(mhodgkinson) review argument types.
48 std::move(blockViews), start.as_size_t(), len);
49}
size_t as_size_t() const
Definition: SampleCount.cpp:16

References sampleCount::as_size_t(), anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, and mAudio.

Here is the call graph for this function:

◆ GetStretchRatio()

double FloatVectorClip::GetStretchRatio ( ) const
inlineoverridevirtual

Implements ClipTimes.

Definition at line 47 of file FloatVectorClip.h.

48 {
49 return stretchRatio;
50 }

References stretchRatio.

◆ GetVisibleSampleCount()

sampleCount FloatVectorClip::GetVisibleSampleCount ( ) const
overridevirtual

The number of raw audio samples not hidden by trimming.

Implements ClipTimes.

Definition at line 51 of file FloatVectorClip.cpp.

52{
53 return mAudio[0].size();
54}

References mAudio.

◆ NChannels()

size_t FloatVectorClip::NChannels ( ) const
overridevirtual

Implements ClipInterface.

Definition at line 56 of file FloatVectorClip.cpp.

57{
58 return mAudio.size();
59}

References mAudio.

◆ SubscribeToCentShiftChange()

Observer::Subscription FloatVectorClip::SubscribeToCentShiftChange ( std::function< void(int)>  cb) const
inlineoverridevirtual

Implements ClipInterface.

Definition at line 58 of file FloatVectorClip.h.

59 {
60 return {};
61 }

◆ SubscribeToPitchAndSpeedPresetChange()

Observer::Subscription FloatVectorClip::SubscribeToPitchAndSpeedPresetChange ( std::function< void(PitchAndSpeedPreset)>  cb) const
inlineoverridevirtual

Implements ClipInterface.

Definition at line 68 of file FloatVectorClip.h.

70 {
71 return {};
72 }

◆ TimeToSamples()

sampleCount FloatVectorClip::TimeToSamples ( double  time) const
overridevirtual

Implements ClipTimes.

Definition at line 66 of file FloatVectorClip.cpp.

67{
68 return sampleCount(floor(time * GetRate() + 0.5));
69}
int GetRate() const override
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References GetRate().

Here is the call graph for this function:

Member Data Documentation

◆ mAudio

const std::vector<std::vector<float> > FloatVectorClip::mAudio
private

Definition at line 82 of file FloatVectorClip.h.

Referenced by GetPlayDuration(), GetSampleView(), GetVisibleSampleCount(), and NChannels().

◆ mSampleRate

const int FloatVectorClip::mSampleRate
private

Definition at line 81 of file FloatVectorClip.h.

Referenced by GetPlayDuration(), and GetRate().

◆ playStartTime

double FloatVectorClip::playStartTime = 0.

Definition at line 76 of file FloatVectorClip.h.

Referenced by GetPlayEndTime(), and GetPlayStartTime().

◆ stretchRatio

double FloatVectorClip::stretchRatio = 1.

Definition at line 75 of file FloatVectorClip.h.

Referenced by GetPlayDuration(), and GetStretchRatio().


The documentation for this class was generated from the following files: