Audacity 3.2.0
WideSampleSequence.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WideSampleSequence.cpp
6
7Paul Licameli split from SampleFrame.cpp
8
9**********************************************************************/
10#include "WideSampleSequence.h"
11#include <cmath>
12
14
16{
17 return sampleCount(floor(t0 * GetRate() + 0.5));
18}
19
21{
22 return pos.as_double() / GetRate();
23}
24
26{
28}
29
30bool WideSampleSequence::GetFloats(size_t iChannel, size_t nBuffers,
31 float *const buffers[], sampleCount start, size_t len,
32 bool backwards, fillFormat fill,
33 bool mayThrow, sampleCount* pNumWithinClips) const
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
enum FillFormat fillFormat
double LongSamplesToTime(sampleCount pos) const
sampleCount TimeToLongSamples(double t0) 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 ~WideSampleSequence()
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
double SnapToSample(double t) const
virtual double GetRate() const =0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
double as_double() const
Definition: SampleCount.h:46