Audacity 3.2.0
Public Member Functions | List of all members
WideSampleSequence Class Referenceabstract

#include <WideSampleSequence.h>

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

Public Member Functions

virtual ~WideSampleSequence ()
 
virtual size_t NChannels () const =0
 A constant property. More...
 
virtual float GetChannelVolume (int channel) 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 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 GetStartTime () const =0
 
virtual double GetEndTime () const =0
 
virtual double GetRate () const =0
 
sampleCount TimeToLongSamples (double t0) const
 
double LongSamplesToTime (sampleCount pos) const
 
double SnapToSample (double t) const
 
virtual sampleFormat WidestEffectiveFormat () const =0
 
virtual bool HasTrivialEnvelope () const =0
 
virtual void GetEnvelopeValues (double *buffer, size_t bufferLen, double t0, bool backwards) const =0
 
- Public Member Functions inherited from AudioGraph::Channel
virtual ~Channel ()
 
virtual ChannelType GetChannelType () const =0
 Classify this channel. More...
 

Detailed Description

An interface for random-access fetches from a collection of streams of samples, associated with the same time; also defines an envelope that applies to all the streams.

Definition at line 22 of file WideSampleSequence.h.

Constructor & Destructor Documentation

◆ ~WideSampleSequence()

WideSampleSequence::~WideSampleSequence ( )
virtualdefault

Member Function Documentation

◆ DoGet()

virtual bool WideSampleSequence::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
pure virtual

Retrieve samples of one of the channels from a sequence in a specified format

Parameters
formatsample format of the destination buffer
backwardretrieves samples from start (inclusive) to start + len if false, else from start (exclusive) to start - len in reverse order.
Returns
whether successful; if not, assume nothing about buffer contents

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by GetFloats().

Here is the caller graph for this function:

◆ GetChannelVolume()

virtual float WideSampleSequence::GetChannelVolume ( int  channel) const
pure virtual

Extra gain factor to apply to a channel when mixing, may change asynchronously

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by SequenceDownmixSource::GetChannelGain(), and StretchingSequence::GetChannelVolume().

Here is the caller graph for this function:

◆ GetEndTime()

virtual double WideSampleSequence::GetEndTime ( ) const
pure virtual

Implemented in SampleTrack, StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by StretchingSequence::GetEndTime().

Here is the caller graph for this function:

◆ GetEnvelopeValues()

virtual void WideSampleSequence::GetEnvelopeValues ( double *  buffer,
size_t  bufferLen,
double  t0,
bool  backwards 
) const
pure virtual

Fetch envelope values corresponding to uniformly separated sample times starting at the given time

Parameters
backwardsif true, fetch values in reverse order, from t0 to t0 - bufferLen / rate

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by StretchingSequence::GetEnvelopeValues().

Here is the caller graph for this function:

◆ GetFloats()

bool WideSampleSequence::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

Retrieve samples from a sequence in floating-point format, regardless of the storage format

Parameters
iChannelindex of first channel to fetch
nBufferscounts buffers
buffersreceive the samples
startstarting sample, relative to absolute time zero
lenhow many samples to get. buffers are assumed sufficiently large
fillhow to assign values for sample positions between clips
mayThrowif false, fill buffer with zeros when there is failure to retrieve samples; else throw
[out]pNumWithinClipsReport how many samples were copied from within clips, rather than filled according to fillFormat; but these were not necessarily one contiguous range.
Precondition
iChannel + nBuffers <= NChannels()
Returns
false when mayThrow is false and not all samples could be retrieved
Postcondition
if return value is false, buffers are zero-filled

Definition at line 30 of file WideSampleSequence.cpp.

34{
35 // Cast the pointers to pass them to DoGet() which handles multiple
36 // destination formats
37 const auto castBuffers = reinterpret_cast<const samplePtr*>(buffers);
38 const auto result = DoGet(
39 iChannel, nBuffers, castBuffers,
40 floatSample, start, len, backwards, fill, mayThrow, pNumWithinClips);
41 if (!result)
42 while (nBuffers--)
43 ClearSamples(castBuffers[nBuffers], floatSample, 0, len);
44 return result;
45}
void ClearSamples(samplePtr dst, sampleFormat format, size_t start, size_t len)
char * samplePtr
Definition: SampleFormat.h:57
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

References ClearSamples(), DoGet(), floatSample, and anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel.

Referenced by WideSampleSource::Acquire(), and WaveChannel::GetFloats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRate()

virtual double WideSampleSequence::GetRate ( ) const
pure virtual

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, WaveTrack, and WritableSampleTrack.

Referenced by MixerSource::Acquire(), StretchingSequence::Create(), StretchingSequence::GetRate(), LongSamplesToTime(), StretchingSequence::MutableGet(), and TimeToLongSamples().

Here is the caller graph for this function:

◆ GetStartTime()

virtual double WideSampleSequence::GetStartTime ( ) const
pure virtual

Implemented in SampleTrack, StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by StretchingSequence::GetStartTime().

Here is the caller graph for this function:

◆ HasTrivialEnvelope()

virtual bool WideSampleSequence::HasTrivialEnvelope ( ) const
pure virtual
Returns
whether envelope values are all unit

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by StretchingSequence::HasTrivialEnvelope().

Here is the caller graph for this function:

◆ LongSamplesToTime()

double WideSampleSequence::LongSamplesToTime ( sampleCount  pos) const

Convert correctly between a number of samples and an (absolute) time in seconds.

Parameters
posThe time number of samples from the start of the sequence to convert
Returns
The time in seconds

Definition at line 20 of file WideSampleSequence.cpp.

21{
22 return pos.as_double() / GetRate();
23}
virtual double GetRate() const =0
double as_double() const
Definition: SampleCount.h:46

References sampleCount::as_double(), and GetRate().

Referenced by AUPImportFileHandle::AddSilence(), TruncSilenceBase::Analyze(), CompareAudioCommand::Apply(), AutoDuckBase::ApplyDuckFade(), TruncSilenceBase::DoRemoval(), TrackSpectrumTransformer::PostProcess(), AutoDuckBase::Process(), FindClippingBase::ProcessOne(), WaveTrackUtilities::Reverse(), and SnapToSample().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NChannels()

virtual size_t WideSampleSequence::NChannels ( ) const
pure virtual

A constant property.

Postcondition
result: result > 0

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, WaveTrack, and WritableSampleTrack.

Referenced by StretchingSequence::Create(), StretchingSequence::GetNext(), SequenceDownmixSource::NChannels(), StretchingSequence::NChannels(), and WideSampleSource::WideSampleSource().

Here is the caller graph for this function:

◆ SnapToSample()

double WideSampleSequence::SnapToSample ( double  t) const
Returns
LongSamplesToTime(TimeToLongSamples(t))

Definition at line 25 of file WideSampleSequence.cpp.

26{
28}
double LongSamplesToTime(sampleCount pos) const
sampleCount TimeToLongSamples(double t0) const

References LongSamplesToTime(), and TimeToLongSamples().

Referenced by anonymous_namespace{SampleHandle.cpp}::adjustTime(), WaveTrack::ApplyPitchAndSpeed(), WaveTrack::CanInsertClip(), WaveTrack::ClearAndPasteAtSameTempo(), TruncSilenceBase::DoRemoval(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), SBSMSBase::Finalize(), WaveTrack::HandleClear(), anonymous_namespace{EditMenus.cpp}::OnSplitNew(), and WaveTrackUtilities::Reverse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TimeToLongSamples()

sampleCount WideSampleSequence::TimeToLongSamples ( double  t0) const

Convert correctly between an (absolute) time in seconds and a number of samples.

This method will not give the correct results if used on a relative time (difference of two times). Each absolute time must be converted and the numbers of samples differenced: sampleCount start = sequence->TimeToLongSamples(t0); sampleCount end = sequence->TimeToLongSamples(t1); sampleCount len = (sampleCount)(end - start); NOT the likes of: sampleCount len = sequence->TimeToLongSamples(t1 - t0); See also WideSampleSequence::TimeToLongSamples().

Parameters
t0The time (floating point seconds) to convert
Returns
The number of samples from the start of the sequence which lie before the given time

Definition at line 15 of file WideSampleSequence.cpp.

16{
17 return sampleCount(floor(t0 * GetRate() + 0.5));
18}
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References GetRate().

Referenced by NormalizeBase::AnalyseTrackData(), TruncSilenceBase::Analyze(), CompareAudioCommand::Apply(), AutoDuckBase::ApplyDuckFade(), WaveTrack::Disjoin(), TruncSilenceBase::DoRemoval(), Effect::GetBounds(), WaveChannel::GetSampleView(), MixerSource::MixerSource(), anonymous_namespace{BrushHandle.cpp}::PositionToLongSample(), AutoDuckBase::Process(), Reverse::Process(), StereoToMono::Process(), PaulstretchBase::ProcessOne(), NormalizeBase::ProcessOne(), LoudnessBase::ProcessOne(), PerTrackEffect::ProcessPass(), MixerSource::Reposition(), StretchingSequence::ResetCursor(), WaveTrack::Silence(), SnapToSample(), and SelectHandle::StartSnappingFreqSelection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WidestEffectiveFormat()

virtual sampleFormat WideSampleSequence::WidestEffectiveFormat ( ) const
pure virtual
Returns
widest effective SampleFormat in any part of the track

Implemented in StretchingSequence, MockPlayableSequence, WaveChannel, and WaveTrack.

Referenced by StretchingSequence::WidestEffectiveFormat().

Here is the caller graph for this function:

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