76 template <
class SampleFormatType>
static inline float getAsFloat (
SampleFormatType&
s)
noexcept {
return s.getAsFloatBE(); }
77 template <
class SampleFormatType>
static inline void setAsFloat (
SampleFormatType&
s,
float newValue)
noexcept {
s.setAsFloatBE (newValue); }
78 template <
class SampleFormatType>
static inline int32 getAsInt32 (
SampleFormatType&
s)
noexcept {
return s.getAsInt32BE(); }
79 template <
class SampleFormatType>
static inline void setAsInt32 (
SampleFormatType&
s,
int32 newValue)
noexcept {
s.setAsInt32BE (newValue); }
80 template <
class SourceType,
class DestType>
static inline void copyFrom (DestType& dest, SourceType& source)
noexcept { dest.copyFromBE (source); }
81 enum { isBigEndian = 1 };
87 template <
class SampleFormatType>
static inline float getAsFloat (
SampleFormatType&
s)
noexcept {
return s.getAsFloatLE(); }
88 template <
class SampleFormatType>
static inline void setAsFloat (
SampleFormatType&
s,
float newValue)
noexcept {
s.setAsFloatLE (newValue); }
89 template <
class SampleFormatType>
static inline int32 getAsInt32 (
SampleFormatType&
s)
noexcept {
return s.getAsInt32LE(); }
90 template <
class SampleFormatType>
static inline void setAsInt32 (
SampleFormatType&
s,
int32 newValue)
noexcept {
s.setAsInt32LE (newValue); }
91 template <
class SourceType,
class DestType>
static inline void copyFrom (DestType& dest, SourceType& source)
noexcept { dest.copyFromLE (source); }
92 enum { isBigEndian = 0 };
107 inline void advance()
noexcept { ++data; }
108 inline void skip (
int numSamples)
noexcept { data += numSamples; }
109 inline float getAsFloatLE()
const noexcept {
return (
float) (*data * (1.0 / (1.0 + maxValue))); }
111 inline void setAsFloatLE (
float newValue)
noexcept { *data = (
int8) jlimit ((
int) -maxValue, (
int) maxValue, roundToInt (newValue * (1.0 + maxValue))); }
115 inline void setAsInt32LE (
int newValue)
noexcept { *data = (
int8) (newValue >> 24); }
117 inline void clear()
noexcept { *data = 0; }
119 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
120 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
132 inline void advance()
noexcept { ++data; }
133 inline void skip (
int numSamples)
noexcept { data += numSamples; }
134 inline float getAsFloatLE()
const noexcept {
return (
float) ((*data - 128) * (1.0 / (1.0 + maxValue))); }
136 inline void setAsFloatLE (
float newValue)
noexcept { *data = (
uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + maxValue))); }
140 inline void setAsInt32LE (
int newValue)
noexcept { *data = (
uint8) (128 + (newValue >> 24)); }
142 inline void clear()
noexcept { *data = 128; }
144 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
145 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
157 inline void advance()
noexcept { ++data; }
158 inline void skip (
int numSamples)
noexcept { data += numSamples; }
159 inline float getAsFloatLE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int16) ByteOrder::swapIfBigEndian (*data)); }
160 inline float getAsFloatBE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int16) ByteOrder::swapIfLittleEndian (*data)); }
161 inline void setAsFloatLE (
float newValue)
noexcept { *data = ByteOrder::swapIfBigEndian ((
uint16) jlimit ((
int) -maxValue, (
int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); }
162 inline void setAsFloatBE (
float newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint16) jlimit ((
int) -maxValue, (
int) maxValue, roundToInt (newValue * (1.0 + maxValue)))); }
165 inline void setAsInt32LE (
int32 newValue)
noexcept { *data = ByteOrder::swapIfBigEndian ((
uint16) (newValue >> 16)); }
166 inline void setAsInt32BE (
int32 newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint16) (newValue >> 16)); }
167 inline void clear()
noexcept { *data = 0; }
169 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
170 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
180 inline Int24 (
void* d)
noexcept : data (
static_cast<char*
> (d)) {}
182 inline void advance()
noexcept { data += 3; }
183 inline void skip (
int numSamples)
noexcept { data += 3 * numSamples; }
184 inline float getAsFloatLE()
const noexcept {
return (
float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + maxValue))); }
185 inline float getAsFloatBE()
const noexcept {
return (
float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + maxValue))); }
186 inline void setAsFloatLE (
float newValue)
noexcept { ByteOrder::littleEndian24BitToChars (jlimit ((
int) -maxValue, (
int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); }
187 inline void setAsFloatBE (
float newValue)
noexcept { ByteOrder::bigEndian24BitToChars (jlimit ((
int) -maxValue, (
int) maxValue, roundToInt (newValue * (1.0 + maxValue))), data); }
188 inline int32 getAsInt32LE()
const noexcept {
return (
int32) (((
unsigned int) ByteOrder::littleEndian24Bit (data)) << 8); }
190 inline void setAsInt32LE (
int32 newValue)
noexcept { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); }
191 inline void setAsInt32BE (
int32 newValue)
noexcept { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); }
192 inline void clear()
noexcept { data[0] = 0; data[1] = 0; data[2] = 0; }
194 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
195 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
207 inline void advance()
noexcept { ++data; }
208 inline void skip (
int numSamples)
noexcept { data += numSamples; }
209 inline float getAsFloatLE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int32) ByteOrder::swapIfBigEndian (*data)); }
210 inline float getAsFloatBE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int32) ByteOrder::swapIfLittleEndian (*data)); }
211 inline void setAsFloatLE (
float newValue)
noexcept { *data = ByteOrder::swapIfBigEndian ((
uint32) (
int32) (maxValue * jlimit (-1.0, 1.0, (
double) newValue))); }
212 inline void setAsFloatBE (
float newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint32) (
int32) (maxValue * jlimit (-1.0, 1.0, (
double) newValue))); }
216 inline void setAsInt32BE (
int32 newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint32) newValue); }
217 inline void clear()
noexcept { *data = 0; }
219 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
220 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
233 inline float getAsFloatLE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int32) ByteOrder::swapIfBigEndian (*data)); }
234 inline float getAsFloatBE()
const noexcept {
return (
float) ((1.0 / (1.0 + maxValue)) * (
int32) ByteOrder::swapIfLittleEndian (*data)); }
235 inline void setAsFloatLE (
float newValue)
noexcept { *data = ByteOrder::swapIfBigEndian ((
uint32) (maxValue * jlimit (-1.0, 1.0, (
double) newValue))); }
236 inline void setAsFloatBE (
float newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint32) (maxValue * jlimit (-1.0, 1.0, (
double) newValue))); }
239 inline void setAsInt32LE (
int32 newValue)
noexcept { *data = ByteOrder::swapIfBigEndian ((
uint32) newValue >> 8); }
240 inline void setAsInt32BE (
int32 newValue)
noexcept { *data = ByteOrder::swapIfLittleEndian ((
uint32) newValue >> 8); }
241 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsInt32LE (source.getAsInt32()); }
242 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsInt32BE (source.getAsInt32()); }
253 inline void advance()
noexcept { ++data; }
254 inline void skip (
int numSamples)
noexcept { data += numSamples; }
256 inline float getAsFloatBE()
const noexcept {
return *data; }
257 inline void setAsFloatBE (
float newValue)
noexcept { *data = newValue; }
261 inline float getAsFloatLE()
const noexcept {
return *data; }
262 inline void setAsFloatLE (
float newValue)
noexcept { *data = newValue; }
270 inline void clear()
noexcept { *data = 0; }
272 template <
class SourceType>
inline void copyFromLE (SourceType& source)
noexcept {
setAsFloatLE (source.getAsFloat()); }
273 template <
class SourceType>
inline void copyFromBE (SourceType& source)
noexcept {
setAsFloatBE (source.getAsFloat()); }
290 template <
class SampleFormatType>
inline void clear (
SampleFormatType&
s,
int numSamples)
noexcept {
s.clearMultiple (numSamples); }
291 template <
class SampleFormatType>
inline static int getNumBytesBetweenSamples (
const SampleFormatType&)
noexcept {
return SampleFormatType::bytesPerSample; }
356 typename InterleavingType,
371 static_assert (InterleavingType::isInterleavedType == 0,
"Incorrect constructor for interleaved data");
390 InterleavingType::operator= (
other);
412 static_assert (Constness::isConst == 0,
"Attempt to write to a const pointer");
413 Endianness::setAsFloat (data, newValue);
430 static_assert (Constness::isConst == 0,
"Attempt to write to a const pointer");
431 Endianness::setAsInt32 (data, newValue);
449 static_assert (Constness::isConst == 0,
"Attempt to write to a const pointer");
451 for (
Pointer dest (*
this); --numSamples >= 0;)
453 dest.
data.copyFromSameType (source.data);
462 template <
class OtherPo
interType>
466 static_assert (Constness::isConst == 0,
"Attempt to write to a const pointer");
470 if (source.getRawData() != getRawData() || source.getNumBytesBetweenSamples() >= getNumBytesBetweenSamples())
472 while (--numSamples >= 0)
474 Endianness::copyFrom (dest.data, source);
482 source += numSamples;
484 while (--numSamples >= 0)
485 Endianness::copyFrom ((--dest).data, --source);
493 dest.clear (dest.data, numSamples);
504 if (isFloatingPoint())
510 while (--numSamples > 0)
526 while (--numSamples > 0)
535 return Range<float> (
mn * (
float) (1.0 / (1.0 + Int32::maxValue)),
536 mx * (
float) (1.0 / (1.0 + Int32::maxValue)));
540 void findMinAndMax (
size_t numSamples,
float& minValue,
float& maxValue)
const noexcept
543 minValue = r.getStart();
544 maxValue = r.getEnd();
616 template <
class SourceSampleType,
class DestSampleType>
624 void convertSamples (
void* dest,
const void* source,
int numSamples)
const override
628 d.convertSamples (
s, numSamples);
638 d.convertSamples (
s, numSamples);
644 const int sourceChannels, destChannels;