Loading...
Searching...
No Matches
juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness > Class Template Reference

`#include <juce_AudioDataConverters.h>`

## Public Member Functions

| Pointer (typename Constness::VoidType *sourceData) noexcept
| Pointer (typename Constness::VoidType *sourceData, int numInterleaved) noexcept
| Pointer (const Pointer &other) noexcept
Pointer & | operator= (const Pointer &other) noexcept
float | getAsFloat () const noexcept
void | setAsFloat (float newValue) noexcept
int32 | getAsInt32 () const noexcept
void | setAsInt32 (int32 newValue) noexcept
Pointer & | operator++ () noexcept
Pointer & | operator-- () noexcept
Pointer & | operator+= (int samplesToJump) noexcept
Pointer | operator+ (int samplesToJump) const
void | convertSamples (Pointer source, int numSamples) const noexcept
template<class OtherPointerType>
void | convertSamples (OtherPointerType source, int numSamples) const noexcept
void | clearSamples (int numSamples) const noexcept
Range< float > | findMinAndMax (size_t numSamples) const noexcept
void | findMinAndMax (size_t numSamples, float &minValue, float &maxValue) const noexcept
int | getNumInterleavedChannels () const noexcept
int | getNumBytesBetweenSamples () const noexcept
const void * | getRawData () const noexcept

## Static Public Member Functions

static bool | isFloatingPoint () noexcept
static bool | isBigEndian () noexcept
static int | getBytesPerSample () noexcept
static int | get32BitResolution () noexcept

## Detailed Description

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>
class juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >

A pointer to a block of audio data with a particular encoding.

This object can be used to read and write from blocks of encoded audio samples. To create one, you specify the audio format as a series of template parameters, e.g.

// this creates a pointer for reading from a const array of 16-bit little-endian packed samples.
AudioData::Pointer <AudioData::Int16,
AudioData::LittleEndian,
AudioData::NonInterleaved,
AudioData::Const> pointer (someRawAudioData);
// These methods read the sample that is being pointed to
float firstSampleAsFloat = pointer.getAsFloat();
int32 firstSampleAsInt = pointer.getAsInt32();
++pointer; // moves the pointer to the next sample.
pointer += 3; // skips the next 3 samples.
juce::AudioData::Pointer
Definition juce_AudioDataConverters.h:355

The convertSamples() method lets you copy a range of samples from one format to another, automatically converting its format.

See also
  AudioData::Converter

Definition at line 354 of file juce_AudioDataConverters.h.

## Constructor & Destructor Documentation

## Pointer() [1/3]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::Pointer | ( | typename Constness::VoidType * | sourceData | ) |

inline noexcept

Creates a non-interleaved pointer from some raw data in the appropriate format. This constructor is only used if you've specified the AudioData::NonInterleaved option - for interleaved formats, use the constructor that also takes a number of channels.

Definition at line 362 of file juce_AudioDataConverters.h.

## Pointer() [2/3]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::Pointer | ( | typename Constness::VoidType * | sourceData,
|  | int | numInterleaved )

inline noexcept

Creates a pointer from some raw data in the appropriate format with the specified number of interleaved channels. For non-interleaved data, use the other constructor.

Definition at line 373 of file juce_AudioDataConverters.h.

## Pointer() [3/3]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::Pointer | ( | const Pointer< SampleFormat, Endianness, InterleavingType, Constness > & | other | ) |

inline noexcept

Creates a copy of another pointer.

Definition at line 379 of file juce_AudioDataConverters.h.

## Member Function Documentation

## clearSamples()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::clearSamples | ( | int | numSamples | ) | const

inline noexcept

Sets a number of samples to zero.

Definition at line 489 of file juce_AudioDataConverters.h.

## convertSamples() [1/2]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>
template<class OtherPointerType>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::convertSamples | ( | OtherPointerType | source,
|  | int | numSamples ) const

inline noexcept

Writes a stream of samples into this pointer from another pointer. This will copy the specified number of samples, converting between formats appropriately.

Definition at line 462 of file juce_AudioDataConverters.h.

## convertSamples() [2/2]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::convertSamples | ( | Pointer< SampleFormat, Endianness, InterleavingType, Constness > | source,
|  | int | numSamples ) const

inline noexcept

Writes a stream of samples into this pointer from another pointer. This will copy the specified number of samples, converting between formats appropriately.

Definition at line 445 of file juce_AudioDataConverters.h.

## findMinAndMax() [1/2]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Range< float > juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::findMinAndMax | ( | size_t | numSamples | ) | const

inline noexcept

Scans a block of data, returning the lowest and highest levels as floats

Definition at line 496 of file juce_AudioDataConverters.h.

## findMinAndMax() [2/2]

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::findMinAndMax | ( | size_t | numSamples,
|  | float & | minValue,
|  | float & | maxValue ) const

inline noexcept

Scans a block of data, returning the lowest and highest levels as floats

Definition at line 539 of file juce_AudioDataConverters.h.

## get32BitResolution()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

int juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::get32BitResolution | ( |  | ) |

inline static noexcept

Returns the accuracy of this format when represented as a 32-bit integer. This is the smallest number above 0 that can be represented in the sample format, converted to a 32-bit range. E,g. if the format is 8-bit, its resolution is 0x01000000; if the format is 24-bit, its resolution is 0x100.

Definition at line 566 of file juce_AudioDataConverters.h.

## getAsFloat()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

float juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getAsFloat | ( |  | ) | const

inline noexcept

Returns the value of the first sample as a floating point value. The value will be in the range -1.0 to 1.0 for integer formats. For floating point formats, the value could be outside that range, although -1 to 1 is the standard range.

Definition at line 396 of file juce_AudioDataConverters.h.

Referenced by juce::AudioData::Pointer< DataFormat, Endianness, std::conditional_t< IsInterleaved, Interleaved, NonInterleaved >, std::conditional_t< IsConst, Const, NonConst > >::findMinAndMax().

## getAsInt32()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

int32 juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getAsInt32 | ( |  | ) | const

inline noexcept

Returns the value of the first sample as a 32-bit integer. The value returned will be in the range 0x80000000 to 0x7fffffff, and shorter values will be shifted to fill this range (e.g. if you're reading from 24-bit data, the values will be shifted up by 8 bits when returned here). If the source data is floating point, values beyond -1.0 to 1.0 will be clipped so that -1.0 maps onto -0x7fffffff and 1.0 maps to 0x7fffffff.

Definition at line 418 of file juce_AudioDataConverters.h.

Referenced by juce::AudioData::Pointer< DataFormat, Endianness, std::conditional_t< IsInterleaved, Interleaved, NonInterleaved >, std::conditional_t< IsConst, Const, NonConst > >::findMinAndMax().

## getBytesPerSample()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

int juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getBytesPerSample | ( |  | ) |

inline static noexcept

Returns the number of bytes in each sample (ignoring the number of interleaved channels).

Definition at line 553 of file juce_AudioDataConverters.h.

## getNumBytesBetweenSamples()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

int juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getNumBytesBetweenSamples | ( |  | ) | const

inline noexcept

Returns the number of bytes between the start address of each sample.

Definition at line 559 of file juce_AudioDataConverters.h.

## getNumInterleavedChannels()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

int juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getNumInterleavedChannels | ( |  | ) | const

inline noexcept

Returns the number of interleaved channels in the format.

Definition at line 556 of file juce_AudioDataConverters.h.

## getRawData()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

const void * juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::getRawData | ( |  | ) | const

inline noexcept

Returns a pointer to the underlying data.

Definition at line 569 of file juce_AudioDataConverters.h.

## isBigEndian()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

bool juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::isBigEndian | ( |  | ) |

inline static noexcept

Returns true if the format is big-endian.

Definition at line 550 of file juce_AudioDataConverters.h.

## isFloatingPoint()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

bool juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::isFloatingPoint | ( |  | ) |

inline static noexcept

Returns true if the pointer is using a floating-point format.

Definition at line 547 of file juce_AudioDataConverters.h.

## operator+()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Pointer juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::operator+ | ( | int | samplesToJump | ) | const

inline

Returns a new pointer with the specified offset from this pointer's position.

Definition at line 440 of file juce_AudioDataConverters.h.

## operator++()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Pointer & juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::operator++ | ( |  | ) |

inline noexcept

Moves the pointer along to the next sample.

Definition at line 431 of file juce_AudioDataConverters.h.

## operator+=()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Pointer & juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::operator+= | ( | int | samplesToJump | ) |

inline noexcept

Adds a number of samples to the pointer's position.

Definition at line 437 of file juce_AudioDataConverters.h.

## operator--()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Pointer & juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::operator-- | ( |  | ) |

inline noexcept

Moves the pointer back to the previous sample.

Definition at line 434 of file juce_AudioDataConverters.h.

## operator=()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

Pointer & juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::operator= | ( | const Pointer< SampleFormat, Endianness, InterleavingType, Constness > & | other | ) |

inline noexcept

Definition at line 384 of file juce_AudioDataConverters.h.

## setAsFloat()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::setAsFloat | ( | float | newValue | ) |

inline noexcept

Sets the value of the first sample as a floating point value.

(This method can only be used if the AudioData::NonConst option was used). The value should be in the range -1.0 to 1.0 - for integer formats, values outside that range will be clipped. For floating point formats, any value passed in here will be written directly, although -1 to 1 is the standard range.

Definition at line 405 of file juce_AudioDataConverters.h.

## setAsInt32()

template<typename SampleFormat, typename Endianness, typename InterleavingType, typename Constness>

void juce::AudioData::Pointer< SampleFormat, Endianness, InterleavingType, Constness >::setAsInt32 | ( | int32 | newValue | ) |

inline noexcept

Sets the value of the first sample as a 32-bit integer. This will be mapped to the range of the format that is being written - see getAsInt32().

Definition at line 423 of file juce_AudioDataConverters.h.

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

- juce_AudioDataConverters.h