Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
staffpad::SamplesFloat< T > Class Template Reference

#include <SamplesFloat.h>

Inheritance diagram for staffpad::SamplesFloat< T >:
[legend]
Collaboration diagram for staffpad::SamplesFloat< T >:
[legend]

Public Member Functions

 ~SamplesFloat ()
 
void setSize (int32_t numChannels, int32_t samples)
 
int32_t getNumChannels () const
 
int32_t getNumSamples () const
 
float ** getPtrs ()
 
T * getPtr (int32_t channel)
 
const T * getPtr (int32_t channel) const
 
void assignSamples (int32_t channel, const T *input)
 
void assignSamples (const SamplesFloat &rhs)
 
void zeroOut ()
 

Private Member Functions

void alloc (int32_t channel, int32_t samples)
 
void dealloc (int32_t channel)
 

Private Attributes

int32_t num_channels {0}
 
int32_t num_samples {0}
 
std::vector< T * > data
 

Detailed Description

template<typename T = float>
class staffpad::SamplesFloat< T >

Definition at line 12 of file SamplesFloat.h.

Constructor & Destructor Documentation

◆ ~SamplesFloat()

template<typename T = float>
staffpad::SamplesFloat< T >::~SamplesFloat ( )
inline

Definition at line 15 of file SamplesFloat.h.

16 {
17 for (int ch = 0; ch < num_channels; ch++)
18 dealloc(ch);
19 }
void dealloc(int32_t channel)
Definition: SamplesFloat.h:101

References staffpad::SamplesFloat< T >::dealloc(), and staffpad::SamplesFloat< T >::num_channels.

Here is the call graph for this function:

Member Function Documentation

◆ alloc()

template<typename T = float>
void staffpad::SamplesFloat< T >::alloc ( int32_t  channel,
int32_t  samples 
)
inlineprivate

Definition at line 91 of file SamplesFloat.h.

92 {
93 assert(channel < num_channels);
94 if (data[channel])
95 {
96 dealloc(channel);
97 }
98 data[channel] = (T*)audio::simd::aligned_malloc(samples * sizeof(T), 64);
99 }
std::vector< T * > data
Definition: SamplesFloat.h:89
void * aligned_malloc(size_t required_bytes, size_t alignment)
reserve aligned memory. Needs to be freed with aligned_free()
Definition: SimdTypes.h:29

References staffpad::audio::simd::aligned_malloc(), staffpad::SamplesFloat< T >::data, staffpad::SamplesFloat< T >::dealloc(), and staffpad::SamplesFloat< T >::num_channels.

Referenced by staffpad::SamplesFloat< T >::setSize().

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

◆ assignSamples() [1/2]

template<typename T = float>
void staffpad::SamplesFloat< T >::assignSamples ( const SamplesFloat< T > &  rhs)
inline

Definition at line 69 of file SamplesFloat.h.

70 {
71 assert(num_channels == rhs.num_channels);
72 assert(num_samples == rhs.num_samples);
73 for (int ch = 0; ch < num_channels; ch++)
74 {
75 assert(data[ch]);
76 vo::copy(rhs.getPtr(ch), getPtr(ch), num_samples);
77 }
78 }
T * getPtr(int32_t channel)
Definition: SamplesFloat.h:48
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40

References staffpad::vo::copy(), staffpad::SamplesFloat< T >::data, staffpad::SamplesFloat< T >::getPtr(), staffpad::SamplesFloat< T >::num_channels, and staffpad::SamplesFloat< T >::num_samples.

Here is the call graph for this function:

◆ assignSamples() [2/2]

template<typename T = float>
void staffpad::SamplesFloat< T >::assignSamples ( int32_t  channel,
const T *  input 
)
inline

Definition at line 62 of file SamplesFloat.h.

63 {
64 assert(channel < num_channels);
65 assert(data[channel]);
66 vo::copy(input, data[channel], num_samples);
67 }

References staffpad::vo::copy(), staffpad::SamplesFloat< T >::data, staffpad::SamplesFloat< T >::num_channels, and staffpad::SamplesFloat< T >::num_samples.

Referenced by staffpad::audio::FourierTransform::inverseReal().

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

◆ dealloc()

template<typename T = float>
void staffpad::SamplesFloat< T >::dealloc ( int32_t  channel)
inlineprivate

Definition at line 101 of file SamplesFloat.h.

102 {
103 assert(channel < num_channels);
104 if (data[channel])
105 {
107 data[channel] = nullptr;
108 }
109 }
void aligned_free(void *p)
free memory allocated with aligned_malloc
Definition: SimdTypes.h:43

References staffpad::audio::simd::aligned_free(), staffpad::SamplesFloat< T >::data, and staffpad::SamplesFloat< T >::num_channels.

Referenced by staffpad::SamplesFloat< T >::alloc(), staffpad::SamplesFloat< T >::setSize(), and staffpad::SamplesFloat< T >::~SamplesFloat().

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

◆ getNumChannels()

template<typename T = float>
int32_t staffpad::SamplesFloat< T >::getNumChannels ( ) const
inline

Definition at line 33 of file SamplesFloat.h.

34 {
35 return num_channels;
36 }

References staffpad::SamplesFloat< T >::num_channels.

Referenced by staffpad::audio::FourierTransform::forwardReal(), and staffpad::audio::FourierTransform::inverseReal().

Here is the caller graph for this function:

◆ getNumSamples()

template<typename T = float>
int32_t staffpad::SamplesFloat< T >::getNumSamples ( ) const
inline

Definition at line 38 of file SamplesFloat.h.

39 {
40 return num_samples;
41 }

References staffpad::SamplesFloat< T >::num_samples.

Referenced by staffpad::audio::FourierTransform::forwardReal(), and staffpad::audio::FourierTransform::inverseReal().

Here is the caller graph for this function:

◆ getPtr() [1/2]

template<typename T = float>
T * staffpad::SamplesFloat< T >::getPtr ( int32_t  channel)
inline

Definition at line 48 of file SamplesFloat.h.

49 {
50 assert(channel < num_channels);
51 assert(data[channel]);
52 return data[channel];
53 }

References staffpad::SamplesFloat< T >::data, and staffpad::SamplesFloat< T >::num_channels.

Referenced by staffpad::SamplesFloat< T >::assignSamples(), staffpad::audio::FourierTransform::forwardReal(), staffpad::audio::FourierTransform::inverseReal(), and FormantShifter::Process().

Here is the caller graph for this function:

◆ getPtr() [2/2]

template<typename T = float>
const T * staffpad::SamplesFloat< T >::getPtr ( int32_t  channel) const
inline

Definition at line 55 of file SamplesFloat.h.

56 {
57 assert(channel < num_channels);
58 assert(data[channel]);
59 return data[channel];
60 }

References staffpad::SamplesFloat< T >::data, and staffpad::SamplesFloat< T >::num_channels.

◆ getPtrs()

template<typename T = float>
float ** staffpad::SamplesFloat< T >::getPtrs ( )
inline

Definition at line 43 of file SamplesFloat.h.

44 {
45 return data.data();
46 }

References staffpad::SamplesFloat< T >::data.

◆ setSize()

template<typename T = float>
void staffpad::SamplesFloat< T >::setSize ( int32_t  numChannels,
int32_t  samples 
)
inline

Definition at line 21 of file SamplesFloat.h.

22 {
23 for (int ch = 0; ch < num_channels; ch++)
24 dealloc(ch);
25
26 num_channels = numChannels;
27 num_samples = samples;
28 data.resize(num_channels);
29 for (int ch = 0; ch < num_channels; ch++)
30 alloc(ch, num_samples);
31 }
void alloc(int32_t channel, int32_t samples)
Definition: SamplesFloat.h:91

References staffpad::SamplesFloat< T >::alloc(), staffpad::SamplesFloat< T >::data, staffpad::SamplesFloat< T >::dealloc(), staffpad::SamplesFloat< T >::num_channels, and staffpad::SamplesFloat< T >::num_samples.

Referenced by FormantShifter::Reset().

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

◆ zeroOut()

template<typename T = float>
void staffpad::SamplesFloat< T >::zeroOut ( )
inline

Definition at line 80 of file SamplesFloat.h.

81 {
82 for (int ch = 0; ch < num_channels; ch++)
84 }
void setToZero(T *dst, int32_t n)
Definition: VectorOps.h:81

References staffpad::SamplesFloat< T >::data, staffpad::SamplesFloat< T >::num_channels, staffpad::SamplesFloat< T >::num_samples, and staffpad::vo::setToZero().

Here is the call graph for this function:

Member Data Documentation

◆ data

template<typename T = float>
std::vector<T*> staffpad::SamplesFloat< T >::data
private

◆ num_channels

template<typename T = float>
int32_t staffpad::SamplesFloat< T >::num_channels {0}
private

◆ num_samples

template<typename T = float>
int32_t staffpad::SamplesFloat< T >::num_samples {0}
private

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