LMMS
Loading...
Searching...
No Matches
juce_AudioDataConverters.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
36{
37public:
38 //==============================================================================
39 // These types can be used as the SampleFormat template parameter for the AudioData::Pointer class.
40
41 class Int8;
42 class UInt8;
43 class Int16;
44 class Int24;
45 class Int32;
46 class Float32;
47
48 //==============================================================================
49 // These types can be used as the Endianness template parameter for the AudioData::Pointer class.
50
51 class BigEndian;
52 class LittleEndian;
53 class NativeEndian;
54
55 //==============================================================================
56 // These types can be used as the InterleavingType template parameter for the AudioData::Pointer class.
57
58 class NonInterleaved;
59 class Interleaved;
60
61 //==============================================================================
62 // These types can be used as the Constness template parameter for the AudioData::Pointer class.
63
64 class NonConst;
65 class Const;
66
67 #ifndef DOXYGEN
68 //==============================================================================
70 {
71 public:
72 template <class SampleFormatType> static float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatBE(); }
73 template <class SampleFormatType> static void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatBE (newValue); }
74 template <class SampleFormatType> static int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32BE(); }
75 template <class SampleFormatType> static void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32BE (newValue); }
76 template <class SourceType, class DestType> static void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromBE (source); }
77 enum { isBigEndian = 1 };
78 };
79
81 {
82 public:
83 template <class SampleFormatType> static float getAsFloat (SampleFormatType& s) noexcept { return s.getAsFloatLE(); }
84 template <class SampleFormatType> static void setAsFloat (SampleFormatType& s, float newValue) noexcept { s.setAsFloatLE (newValue); }
85 template <class SampleFormatType> static int32 getAsInt32 (SampleFormatType& s) noexcept { return s.getAsInt32LE(); }
86 template <class SampleFormatType> static void setAsInt32 (SampleFormatType& s, int32 newValue) noexcept { s.setAsInt32LE (newValue); }
87 template <class SourceType, class DestType> static void copyFrom (DestType& dest, SourceType& source) noexcept { dest.copyFromLE (source); }
88 enum { isBigEndian = 0 };
89 };
90
91 #if JUCE_BIG_ENDIAN
92 class NativeEndian : public BigEndian {};
93 #else
94 class NativeEndian : public LittleEndian {};
95 #endif
96
97 //==============================================================================
98 class Int8
99 {
100 public:
101 inline Int8 (void* d) noexcept : data (static_cast<int8*> (d)) {}
102
103 inline void advance() noexcept { ++data; }
104 inline void skip (int numSamples) noexcept { data += numSamples; }
105 inline float getAsFloatLE() const noexcept { return (float) (*data * (1.0 / (1.0 + (double) maxValue))); }
106 inline float getAsFloatBE() const noexcept { return getAsFloatLE(); }
107 inline void setAsFloatLE (float newValue) noexcept { *data = (int8) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + (double) maxValue))); }
108 inline void setAsFloatBE (float newValue) noexcept { setAsFloatLE (newValue); }
109 inline int32 getAsInt32LE() const noexcept { return (int) (*((uint8*) data) << 24); }
111 inline void setAsInt32LE (int newValue) noexcept { *data = (int8) (newValue >> 24); }
112 inline void setAsInt32BE (int newValue) noexcept { setAsInt32LE (newValue); }
113 inline void clear() noexcept { *data = 0; }
114 inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
115 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
116 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
117 inline void copyFromSameType (Int8& source) noexcept { *data = *source.data; }
118
120 enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 };
121 };
122
123 class UInt8
124 {
125 public:
126 inline UInt8 (void* d) noexcept : data (static_cast<uint8*> (d)) {}
127
128 inline void advance() noexcept { ++data; }
129 inline void skip (int numSamples) noexcept { data += numSamples; }
130 inline float getAsFloatLE() const noexcept { return (float) ((*data - 128) * (1.0 / (1.0 + (double) maxValue))); }
131 inline float getAsFloatBE() const noexcept { return getAsFloatLE(); }
132 inline void setAsFloatLE (float newValue) noexcept { *data = (uint8) jlimit (0, 255, 128 + roundToInt (newValue * (1.0 + (double) maxValue))); }
133 inline void setAsFloatBE (float newValue) noexcept { setAsFloatLE (newValue); }
134 inline int32 getAsInt32LE() const noexcept { return (int) (((uint8) (*data - 128)) << 24); }
136 inline void setAsInt32LE (int newValue) noexcept { *data = (uint8) (128 + (newValue >> 24)); }
137 inline void setAsInt32BE (int newValue) noexcept { setAsInt32LE (newValue); }
138 inline void clear() noexcept { *data = 128; }
139 inline void clearMultiple (int num) noexcept { memset (data, 128, (size_t) num) ;}
140 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
141 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
142 inline void copyFromSameType (UInt8& source) noexcept { *data = *source.data; }
143
145 enum { bytesPerSample = 1, maxValue = 0x7f, resolution = (1 << 24), isFloat = 0 };
146 };
147
148 class Int16
149 {
150 public:
151 inline Int16 (void* d) noexcept : data (static_cast<uint16*> (d)) {}
152
153 inline void advance() noexcept { ++data; }
154 inline void skip (int numSamples) noexcept { data += numSamples; }
155 inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int16) ByteOrder::swapIfBigEndian (*data)); }
156 inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int16) ByteOrder::swapIfLittleEndian (*data)); }
157 inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint16) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + (double) maxValue)))); }
158 inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint16) jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + (double) maxValue)))); }
161 inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint16) (newValue >> 16)); }
162 inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint16) (newValue >> 16)); }
163 inline void clear() noexcept { *data = 0; }
164 inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
165 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
166 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
167 inline void copyFromSameType (Int16& source) noexcept { *data = *source.data; }
168
170 enum { bytesPerSample = 2, maxValue = 0x7fff, resolution = (1 << 16), isFloat = 0 };
171 };
172
173 class Int24
174 {
175 public:
176 inline Int24 (void* d) noexcept : data (static_cast<char*> (d)) {}
177
178 inline void advance() noexcept { data += 3; }
179 inline void skip (int numSamples) noexcept { data += 3 * numSamples; }
180 inline float getAsFloatLE() const noexcept { return (float) (ByteOrder::littleEndian24Bit (data) * (1.0 / (1.0 + (double) maxValue))); }
181 inline float getAsFloatBE() const noexcept { return (float) (ByteOrder::bigEndian24Bit (data) * (1.0 / (1.0 + (double) maxValue))); }
182 inline void setAsFloatLE (float newValue) noexcept { ByteOrder::littleEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + (double) maxValue))), data); }
183 inline void setAsFloatBE (float newValue) noexcept { ByteOrder::bigEndian24BitToChars (jlimit ((int) -maxValue, (int) maxValue, roundToInt (newValue * (1.0 + (double) maxValue))), data); }
184 inline int32 getAsInt32LE() const noexcept { return (int32) (((unsigned int) ByteOrder::littleEndian24Bit (data)) << 8); }
185 inline int32 getAsInt32BE() const noexcept { return (int32) (((unsigned int) ByteOrder::bigEndian24Bit (data)) << 8); }
186 inline void setAsInt32LE (int32 newValue) noexcept { ByteOrder::littleEndian24BitToChars (newValue >> 8, data); }
187 inline void setAsInt32BE (int32 newValue) noexcept { ByteOrder::bigEndian24BitToChars (newValue >> 8, data); }
188 inline void clear() noexcept { data[0] = 0; data[1] = 0; data[2] = 0; }
189 inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
190 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
191 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
192 inline void copyFromSameType (Int24& source) noexcept { data[0] = source.data[0]; data[1] = source.data[1]; data[2] = source.data[2]; }
193
194 char* data;
195 enum { bytesPerSample = 3, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 };
196 };
197
198 class Int32
199 {
200 public:
201 inline Int32 (void* d) noexcept : data (static_cast<uint32*> (d)) {}
202
203 inline void advance() noexcept { ++data; }
204 inline void skip (int numSamples) noexcept { data += numSamples; }
205 inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); }
206 inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); }
207 inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) (int32) ((double) maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
208 inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) (int32) ((double) maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
211 inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue); }
212 inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue); }
213 inline void clear() noexcept { *data = 0; }
214 inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
215 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
216 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
217 inline void copyFromSameType (Int32& source) noexcept { *data = *source.data; }
218
220 enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = 1, isFloat = 0 };
221 };
222
224 class Int24in32 : public Int32
225 {
226 public:
227 inline Int24in32 (void* d) noexcept : Int32 (d) {}
228
229 inline float getAsFloatLE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int32) ByteOrder::swapIfBigEndian (*data)); }
230 inline float getAsFloatBE() const noexcept { return (float) ((1.0 / (1.0 + (double) maxValue)) * (int32) ByteOrder::swapIfLittleEndian (*data)); }
231 inline void setAsFloatLE (float newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) ((double) maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
232 inline void setAsFloatBE (float newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) ((double) maxValue * jlimit (-1.0, 1.0, (double) newValue))); }
235 inline void setAsInt32LE (int32 newValue) noexcept { *data = ByteOrder::swapIfBigEndian ((uint32) newValue >> 8); }
236 inline void setAsInt32BE (int32 newValue) noexcept { *data = ByteOrder::swapIfLittleEndian ((uint32) newValue >> 8); }
237 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsInt32LE (source.getAsInt32()); }
238 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsInt32BE (source.getAsInt32()); }
239 inline void copyFromSameType (Int24in32& source) noexcept { *data = *source.data; }
240
241 enum { bytesPerSample = 4, maxValue = 0x7fffff, resolution = (1 << 8), isFloat = 0 };
242 };
243
245 {
246 public:
247 inline Float32 (void* d) noexcept : data (static_cast<float*> (d)) {}
248
249 inline void advance() noexcept { ++data; }
250 inline void skip (int numSamples) noexcept { data += numSamples; }
251 #if JUCE_BIG_ENDIAN
252 inline float getAsFloatBE() const noexcept { return *data; }
253 inline void setAsFloatBE (float newValue) noexcept { *data = newValue; }
254 inline float getAsFloatLE() const noexcept { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; }
255 inline void setAsFloatLE (float newValue) noexcept { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); }
256 #else
257 inline float getAsFloatLE() const noexcept { return *data; }
258 inline void setAsFloatLE (float newValue) noexcept { *data = newValue; }
259 inline float getAsFloatBE() const noexcept { union { uint32 asInt; float asFloat; } n; n.asInt = ByteOrder::swap (*(uint32*) data); return n.asFloat; }
260 inline void setAsFloatBE (float newValue) noexcept { union { uint32 asInt; float asFloat; } n; n.asFloat = newValue; *(uint32*) data = ByteOrder::swap (n.asInt); }
261 #endif
262 inline int32 getAsInt32LE() const noexcept { return (int32) roundToInt (jlimit (-1.0, 1.0, (double) getAsFloatLE()) * (double) maxValue); }
263 inline int32 getAsInt32BE() const noexcept { return (int32) roundToInt (jlimit (-1.0, 1.0, (double) getAsFloatBE()) * (double) maxValue); }
264 inline void setAsInt32LE (int32 newValue) noexcept { setAsFloatLE ((float) (newValue * (1.0 / (1.0 + (double) maxValue)))); }
265 inline void setAsInt32BE (int32 newValue) noexcept { setAsFloatBE ((float) (newValue * (1.0 / (1.0 + (double) maxValue)))); }
266 inline void clear() noexcept { *data = 0; }
267 inline void clearMultiple (int num) noexcept { zeromem (data, (size_t) (num * bytesPerSample)) ;}
268 template <class SourceType> inline void copyFromLE (SourceType& source) noexcept { setAsFloatLE (source.getAsFloat()); }
269 template <class SourceType> inline void copyFromBE (SourceType& source) noexcept { setAsFloatBE (source.getAsFloat()); }
270 inline void copyFromSameType (Float32& source) noexcept { *data = *source.data; }
271
272 float* data;
273 enum { bytesPerSample = 4, maxValue = 0x7fffffff, resolution = (1 << 8), isFloat = 1 };
274 };
275
276 //==============================================================================
278 {
279 public:
280 inline NonInterleaved() = default;
281 inline NonInterleaved (const NonInterleaved&) = default;
282 inline NonInterleaved (const int) noexcept {}
283 inline void copyFrom (const NonInterleaved&) noexcept {}
284 template <class SampleFormatType> inline void advanceData (SampleFormatType& s) noexcept { s.advance(); }
285 template <class SampleFormatType> inline void advanceDataBy (SampleFormatType& s, int numSamples) noexcept { s.skip (numSamples); }
286 template <class SampleFormatType> inline void clear (SampleFormatType& s, int numSamples) noexcept { s.clearMultiple (numSamples); }
287 template <class SampleFormatType> static int getNumBytesBetweenSamples (const SampleFormatType&) noexcept { return SampleFormatType::bytesPerSample; }
288
290 };
291
293 {
294 public:
296 inline Interleaved (const Interleaved& other) = default;
297 inline Interleaved (const int numInterleavedChans) noexcept : numInterleavedChannels (numInterleavedChans) {}
298 inline void copyFrom (const Interleaved& other) noexcept { numInterleavedChannels = other.numInterleavedChannels; }
299 template <class SampleFormatType> inline void advanceData (SampleFormatType& s) noexcept { s.skip (numInterleavedChannels); }
300 template <class SampleFormatType> inline void advanceDataBy (SampleFormatType& s, int numSamples) noexcept { s.skip (numInterleavedChannels * numSamples); }
301 template <class SampleFormatType> inline void clear (SampleFormatType& s, int numSamples) noexcept { while (--numSamples >= 0) { s.clear(); s.skip (numInterleavedChannels); } }
302 template <class SampleFormatType> inline int getNumBytesBetweenSamples (const SampleFormatType&) const noexcept { return numInterleavedChannels * SampleFormatType::bytesPerSample; }
304 enum { isInterleavedType = 1 };
305 };
306
307 //==============================================================================
309 {
310 public:
311 using VoidType = void;
312 static void* toVoidPtr (VoidType* v) noexcept { return v; }
313 enum { isConst = 0 };
314 };
315
316 class Const
317 {
318 public:
319 using VoidType = const void;
320 static void* toVoidPtr (VoidType* v) noexcept { return const_cast<void*> (v); }
321 enum { isConst = 1 };
322 };
323 #endif
324
325 //==============================================================================
350 template <typename SampleFormat,
351 typename Endianness,
352 typename InterleavingType,
353 typename Constness>
354 class Pointer : private InterleavingType // (inherited for EBCO)
355 {
356 public:
357 //==============================================================================
362 Pointer (typename Constness::VoidType* sourceData) noexcept
363 : data (Constness::toVoidPtr (sourceData))
364 {
365 // If you're using interleaved data, call the other constructor! If you're using non-interleaved data,
366 // you should pass NonInterleaved as the template parameter for the interleaving type!
367 static_assert (InterleavingType::isInterleavedType == 0, "Incorrect constructor for interleaved data");
368 }
369
373 Pointer (typename Constness::VoidType* sourceData, int numInterleaved) noexcept
374 : InterleavingType (numInterleaved), data (Constness::toVoidPtr (sourceData))
375 {
376 }
377
379 Pointer (const Pointer& other) noexcept
380 : InterleavingType (other), data (other.data)
381 {
382 }
383
384 Pointer& operator= (const Pointer& other) noexcept
385 {
386 InterleavingType::operator= (other);
387 data = other.data;
388 return *this;
389 }
390
391 //==============================================================================
396 inline float getAsFloat() const noexcept { return Endianness::getAsFloat (data); }
397
405 inline void setAsFloat (float newValue) noexcept
406 {
407 // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
408 static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
409 Endianness::setAsFloat (data, newValue);
410 }
411
418 inline int32 getAsInt32() const noexcept { return Endianness::getAsInt32 (data); }
419
423 inline void setAsInt32 (int32 newValue) noexcept
424 {
425 // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
426 static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
427 Endianness::setAsInt32 (data, newValue);
428 }
429
431 inline Pointer& operator++() noexcept { advance(); return *this; }
432
434 inline Pointer& operator--() noexcept { this->advanceDataBy (data, -1); return *this; }
435
437 Pointer& operator+= (int samplesToJump) noexcept { this->advanceDataBy (data, samplesToJump); return *this; }
438
442 void convertSamples (Pointer source, int numSamples) const noexcept
443 {
444 // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
445 static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
446
447 for (Pointer dest (*this); --numSamples >= 0;)
448 {
449 dest.data.copyFromSameType (source.data);
450 dest.advance();
451 source.advance();
452 }
453 }
454
458 template <class OtherPointerType>
459 void convertSamples (OtherPointerType source, int numSamples) const noexcept
460 {
461 // trying to write to a const pointer! For a writeable one, use AudioData::NonConst instead!
462 static_assert (Constness::isConst == 0, "Attempt to write to a const pointer");
463
464 Pointer dest (*this);
465
466 if (source.getRawData() != getRawData() || source.getNumBytesBetweenSamples() >= getNumBytesBetweenSamples())
467 {
468 while (--numSamples >= 0)
469 {
470 Endianness::copyFrom (dest.data, source);
471 dest.advance();
472 ++source;
473 }
474 }
475 else // copy backwards if we're increasing the sample width..
476 {
477 dest += numSamples;
478 source += numSamples;
479
480 while (--numSamples >= 0)
481 Endianness::copyFrom ((--dest).data, --source);
482 }
483 }
484
486 void clearSamples (int numSamples) const noexcept
487 {
488 Pointer dest (*this);
489 dest.clear (dest.data, numSamples);
490 }
491
493 Range<float> findMinAndMax (size_t numSamples) const noexcept
494 {
495 if (numSamples == 0)
496 return Range<float>();
497
498 Pointer dest (*this);
499
500 if (isFloatingPoint())
501 {
502 float mn = dest.getAsFloat();
503 dest.advance();
504 float mx = mn;
505
506 while (--numSamples > 0)
507 {
508 const float v = dest.getAsFloat();
509 dest.advance();
510
511 if (mx < v) mx = v;
512 if (v < mn) mn = v;
513 }
514
515 return Range<float> (mn, mx);
516 }
517
518 int32 mn = dest.getAsInt32();
519 dest.advance();
520 int32 mx = mn;
521
522 while (--numSamples > 0)
523 {
524 const int v = dest.getAsInt32();
525 dest.advance();
526
527 if (mx < v) mx = v;
528 if (v < mn) mn = v;
529 }
530
531 return Range<float> ((float) mn * (float) (1.0 / (1.0 + (double) Int32::maxValue)),
532 (float) mx * (float) (1.0 / (1.0 + (double) Int32::maxValue)));
533 }
534
536 void findMinAndMax (size_t numSamples, float& minValue, float& maxValue) const noexcept
537 {
538 Range<float> r (findMinAndMax (numSamples));
539 minValue = r.getStart();
540 maxValue = r.getEnd();
541 }
542
544 static bool isFloatingPoint() noexcept { return (bool) SampleFormat::isFloat; }
545
547 static bool isBigEndian() noexcept { return (bool) Endianness::isBigEndian; }
548
550 static int getBytesPerSample() noexcept { return (int) SampleFormat::bytesPerSample; }
551
553 int getNumInterleavedChannels() const noexcept { return (int) this->numInterleavedChannels; }
554
556 int getNumBytesBetweenSamples() const noexcept { return InterleavingType::getNumBytesBetweenSamples (data); }
557
563 static int get32BitResolution() noexcept { return (int) SampleFormat::resolution; }
564
566 const void* getRawData() const noexcept { return data.data; }
567
568 private:
569 //==============================================================================
570 SampleFormat data;
571
572 inline void advance() noexcept { this->advanceData (data); }
573
574 Pointer operator++ (int); // private to force you to use the more efficient pre-increment!
575 Pointer operator-- (int);
576 };
577
578 //==============================================================================
588 {
589 public:
590 virtual ~Converter() = default;
591
593 virtual void convertSamples (void* destSamples, const void* sourceSamples, int numSamples) const = 0;
594
599 virtual void convertSamples (void* destSamples, int destSubChannel,
600 const void* sourceSamples, int sourceSubChannel, int numSamples) const = 0;
601 };
602
603 //==============================================================================
612 template <class SourceSampleType, class DestSampleType>
614 {
615 public:
616 ConverterInstance (int numSourceChannels = 1, int numDestChannels = 1)
617 : sourceChannels (numSourceChannels), destChannels (numDestChannels)
618 {}
619
620 void convertSamples (void* dest, const void* source, int numSamples) const override
621 {
622 SourceSampleType s (source, sourceChannels);
623 DestSampleType d (dest, destChannels);
624 d.convertSamples (s, numSamples);
625 }
626
627 void convertSamples (void* dest, int destSubChannel,
628 const void* source, int sourceSubChannel, int numSamples) const override
629 {
630 jassert (destSubChannel < destChannels && sourceSubChannel < sourceChannels);
631
632 SourceSampleType s (addBytesToPointer (source, sourceSubChannel * SourceSampleType::getBytesPerSample()), sourceChannels);
633 DestSampleType d (addBytesToPointer (dest, destSubChannel * DestSampleType::getBytesPerSample()), destChannels);
634 d.convertSamples (s, numSamples);
635 }
636
637 private:
639
641 };
642
643 //==============================================================================
649 template <typename DataFormatIn, typename EndiannessIn>
650 struct Format
651 {
652 using DataFormat = DataFormatIn;
653 using Endianness = EndiannessIn;
654 };
655
656private:
657 template <bool IsInterleaved, bool IsConst, typename...>
659
660 template <bool IsInterleaved, bool IsConst, typename DataFormat, typename Endianness>
662 {
663 using ElementType = std::remove_pointer_t<decltype (DataFormat::data)>;
664 using ChannelType = std::conditional_t<IsConst, const ElementType*, ElementType*>;
665 using DataType = std::conditional_t<IsInterleaved, ChannelType, ChannelType*>;
666 using PointerType = Pointer<DataFormat,
667 Endianness,
668 std::conditional_t<IsInterleaved, Interleaved, NonInterleaved>,
669 std::conditional_t<IsConst, Const, NonConst>>;
670 };
671
672 template <bool IsInterleaved, bool IsConst, typename DataFormat, typename Endianness>
679
680 template <bool IsInterleaved, bool IsConst, typename... Format>
682 {
683 using Subtypes = ChannelDataSubtypes<IsInterleaved, IsConst, Format...>;
684 using DataType = typename Subtypes::DataType;
685 using PointerType = typename Subtypes::PointerType;
686
689 };
690
691public:
692 //==============================================================================
694 template <typename... Format> using InterleavedSource = ChannelData<true, true, Format...>;
696 template <typename... Format> using InterleavedDest = ChannelData<true, false, Format...>;
698 template <typename... Format> using NonInterleavedSource = ChannelData<false, true, Format...>;
700 template <typename... Format> using NonInterleavedDest = ChannelData<false, false, Format...>;
701
719 template <typename... SourceFormat, typename... DestFormat>
722 int numSamples)
723 {
724 using SourceType = typename decltype (source)::PointerType;
725 using DestType = typename decltype (dest) ::PointerType;
726
727 for (int i = 0; i < dest.channels; ++i)
728 {
729 const DestType destType (addBytesToPointer (dest.data, i * DestType::getBytesPerSample()), dest.channels);
730
731 if (i < source.channels)
732 {
733 if (*source.data != nullptr)
734 {
735 destType.convertSamples (SourceType { *source.data }, numSamples);
736 ++source.data;
737 }
738 }
739 else
740 {
741 destType.clearSamples (numSamples);
742 }
743 }
744 }
745
763 template <typename... SourceFormat, typename... DestFormat>
766 int numSamples)
767 {
768 using SourceType = typename decltype (source)::PointerType;
769 using DestType = typename decltype (dest) ::PointerType;
770
771 for (int i = 0; i < dest.channels; ++i)
772 {
773 if (auto* targetChan = dest.data[i])
774 {
775 const DestType destType (targetChan);
776
777 if (i < source.channels)
778 destType.convertSamples (SourceType (addBytesToPointer (source.data, i * SourceType::getBytesPerSample()), source.channels), numSamples);
779 else
780 destType.clearSamples (numSamples);
781 }
782 }
783 }
784};
785
786//==============================================================================
787#ifndef DOXYGEN
797class [[deprecated]] JUCE_API AudioDataConverters
798{
799public:
800 //==============================================================================
801 static void convertFloatToInt16LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 2);
802 static void convertFloatToInt16BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 2);
803
804 static void convertFloatToInt24LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 3);
805 static void convertFloatToInt24BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 3);
806
807 static void convertFloatToInt32LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
808 static void convertFloatToInt32BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
809
810 static void convertFloatToFloat32LE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
811 static void convertFloatToFloat32BE (const float* source, void* dest, int numSamples, int destBytesPerSample = 4);
812
813 //==============================================================================
814 static void convertInt16LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 2);
815 static void convertInt16BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 2);
816
817 static void convertInt24LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 3);
818 static void convertInt24BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 3);
819
820 static void convertInt32LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
821 static void convertInt32BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
822
823 static void convertFloat32LEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
824 static void convertFloat32BEToFloat (const void* source, float* dest, int numSamples, int srcBytesPerSample = 4);
825
826 //==============================================================================
838
839 static void convertFloatToFormat (DataFormat destFormat,
840 const float* source, void* dest, int numSamples);
841
842 static void convertFormatToFloat (DataFormat sourceFormat,
843 const void* source, float* dest, int numSamples);
844
845 //==============================================================================
846 static void interleaveSamples (const float** source, float* dest,
847 int numSamples, int numChannels);
848
849 static void deinterleaveSamples (const float* source, float** dest,
850 int numSamples, int numChannels);
851
852private:
854};
855#endif
856
857} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
uint32_t uint32
Definition basics.h:90
static void littleEndian24BitToChars(int value, void *destBytes) noexcept
Definition ByteOrder.h:247
static uint16 swapIfLittleEndian(uint16 value) noexcept
Definition ByteOrder.h:227
static void bigEndian24BitToChars(int value, void *destBytes) noexcept
Definition ByteOrder.h:248
static uint16 swap(uint16 value) noexcept
Definition ByteOrder.h:151
static int littleEndian24Bit(const void *bytes) noexcept
Definition ByteOrder.h:245
static int bigEndian24Bit(const void *bytes) noexcept
Definition ByteOrder.h:246
static uint16 swapIfBigEndian(uint16 value) noexcept
Definition ByteOrder.h:218
Definition juce_AudioDataConverters.h:70
@ isBigEndian
Definition juce_AudioDataConverters.h:77
static void copyFrom(DestType &dest, SourceType &source) noexcept
Definition juce_AudioDataConverters.h:76
static int32 getAsInt32(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:74
static void setAsInt32(SampleFormatType &s, int32 newValue) noexcept
Definition juce_AudioDataConverters.h:75
static void setAsFloat(SampleFormatType &s, float newValue) noexcept
Definition juce_AudioDataConverters.h:73
static float getAsFloat(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:72
Definition juce_AudioDataConverters.h:317
@ isConst
Definition juce_AudioDataConverters.h:321
const void VoidType
Definition juce_AudioDataConverters.h:319
static void * toVoidPtr(VoidType *v) noexcept
Definition juce_AudioDataConverters.h:320
Definition juce_AudioDataConverters.h:588
virtual void convertSamples(void *destSamples, int destSubChannel, const void *sourceSamples, int sourceSubChannel, int numSamples) const =0
virtual void convertSamples(void *destSamples, const void *sourceSamples, int numSamples) const =0
virtual ~Converter()=default
Definition juce_AudioDataConverters.h:614
void convertSamples(void *dest, const void *source, int numSamples) const override
Definition juce_AudioDataConverters.h:620
const int destChannels
Definition juce_AudioDataConverters.h:640
const int sourceChannels
Definition juce_AudioDataConverters.h:640
void convertSamples(void *dest, int destSubChannel, const void *source, int sourceSubChannel, int numSamples) const override
Definition juce_AudioDataConverters.h:627
ConverterInstance(int numSourceChannels=1, int numDestChannels=1)
Definition juce_AudioDataConverters.h:616
Definition juce_AudioDataConverters.h:245
float * data
Definition juce_AudioDataConverters.h:272
void copyFromSameType(Float32 &source) noexcept
Definition juce_AudioDataConverters.h:270
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:262
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:260
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:269
void setAsInt32LE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:264
@ isFloat
Definition juce_AudioDataConverters.h:273
@ maxValue
Definition juce_AudioDataConverters.h:273
@ resolution
Definition juce_AudioDataConverters.h:273
@ bytesPerSample
Definition juce_AudioDataConverters.h:273
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:268
void clear() noexcept
Definition juce_AudioDataConverters.h:266
Float32(void *d) noexcept
Definition juce_AudioDataConverters.h:247
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:263
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:257
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:250
void setAsInt32BE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:265
void advance() noexcept
Definition juce_AudioDataConverters.h:249
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:267
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:258
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:259
Definition juce_AudioDataConverters.h:149
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:160
void setAsInt32BE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:162
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:155
@ isFloat
Definition juce_AudioDataConverters.h:170
@ bytesPerSample
Definition juce_AudioDataConverters.h:170
@ resolution
Definition juce_AudioDataConverters.h:170
@ maxValue
Definition juce_AudioDataConverters.h:170
void copyFromSameType(Int16 &source) noexcept
Definition juce_AudioDataConverters.h:167
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:154
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:156
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:165
void advance() noexcept
Definition juce_AudioDataConverters.h:153
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:166
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:158
uint16 * data
Definition juce_AudioDataConverters.h:169
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:164
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:159
void clear() noexcept
Definition juce_AudioDataConverters.h:163
void setAsInt32LE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:161
Int16(void *d) noexcept
Definition juce_AudioDataConverters.h:151
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:157
Definition juce_AudioDataConverters.h:174
void setAsInt32BE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:187
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:183
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:184
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:190
@ resolution
Definition juce_AudioDataConverters.h:195
@ bytesPerSample
Definition juce_AudioDataConverters.h:195
@ isFloat
Definition juce_AudioDataConverters.h:195
@ maxValue
Definition juce_AudioDataConverters.h:195
char * data
Definition juce_AudioDataConverters.h:194
void copyFromSameType(Int24 &source) noexcept
Definition juce_AudioDataConverters.h:192
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:180
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:189
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:182
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:179
Int24(void *d) noexcept
Definition juce_AudioDataConverters.h:176
void advance() noexcept
Definition juce_AudioDataConverters.h:178
void setAsInt32LE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:186
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:185
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:181
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:191
void clear() noexcept
Definition juce_AudioDataConverters.h:188
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:237
void setAsInt32LE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:235
Int24in32(void *d) noexcept
Definition juce_AudioDataConverters.h:227
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:231
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:233
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:232
void copyFromSameType(Int24in32 &source) noexcept
Definition juce_AudioDataConverters.h:239
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:230
@ isFloat
Definition juce_AudioDataConverters.h:241
@ bytesPerSample
Definition juce_AudioDataConverters.h:241
@ maxValue
Definition juce_AudioDataConverters.h:241
@ resolution
Definition juce_AudioDataConverters.h:241
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:229
void setAsInt32BE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:236
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:238
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:234
Definition juce_AudioDataConverters.h:199
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:207
void clear() noexcept
Definition juce_AudioDataConverters.h:213
void advance() noexcept
Definition juce_AudioDataConverters.h:203
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:208
void setAsInt32BE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:212
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:210
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:204
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:206
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:205
Int32(void *d) noexcept
Definition juce_AudioDataConverters.h:201
uint32 * data
Definition juce_AudioDataConverters.h:219
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:214
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:216
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:215
@ resolution
Definition juce_AudioDataConverters.h:220
@ bytesPerSample
Definition juce_AudioDataConverters.h:220
@ maxValue
Definition juce_AudioDataConverters.h:220
@ isFloat
Definition juce_AudioDataConverters.h:220
void setAsInt32LE(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:211
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:209
void copyFromSameType(Int32 &source) noexcept
Definition juce_AudioDataConverters.h:217
Definition juce_AudioDataConverters.h:99
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:105
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:110
void advance() noexcept
Definition juce_AudioDataConverters.h:103
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:108
Int8(void *d) noexcept
Definition juce_AudioDataConverters.h:101
@ resolution
Definition juce_AudioDataConverters.h:120
@ bytesPerSample
Definition juce_AudioDataConverters.h:120
@ maxValue
Definition juce_AudioDataConverters.h:120
@ isFloat
Definition juce_AudioDataConverters.h:120
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:106
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:114
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:109
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:104
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:116
void copyFromSameType(Int8 &source) noexcept
Definition juce_AudioDataConverters.h:117
void clear() noexcept
Definition juce_AudioDataConverters.h:113
void setAsInt32BE(int newValue) noexcept
Definition juce_AudioDataConverters.h:112
void setAsInt32LE(int newValue) noexcept
Definition juce_AudioDataConverters.h:111
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:115
int8 * data
Definition juce_AudioDataConverters.h:119
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:107
Definition juce_AudioDataConverters.h:293
int numInterleavedChannels
Definition juce_AudioDataConverters.h:303
Interleaved(const int numInterleavedChans) noexcept
Definition juce_AudioDataConverters.h:297
void advanceData(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:299
@ isInterleavedType
Definition juce_AudioDataConverters.h:304
int getNumBytesBetweenSamples(const SampleFormatType &) const noexcept
Definition juce_AudioDataConverters.h:302
Interleaved(const Interleaved &other)=default
void copyFrom(const Interleaved &other) noexcept
Definition juce_AudioDataConverters.h:298
Interleaved() noexcept
Definition juce_AudioDataConverters.h:295
void advanceDataBy(SampleFormatType &s, int numSamples) noexcept
Definition juce_AudioDataConverters.h:300
void clear(SampleFormatType &s, int numSamples) noexcept
Definition juce_AudioDataConverters.h:301
Definition juce_AudioDataConverters.h:81
@ isBigEndian
Definition juce_AudioDataConverters.h:88
static int32 getAsInt32(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:85
static void setAsInt32(SampleFormatType &s, int32 newValue) noexcept
Definition juce_AudioDataConverters.h:86
static void setAsFloat(SampleFormatType &s, float newValue) noexcept
Definition juce_AudioDataConverters.h:84
static void copyFrom(DestType &dest, SourceType &source) noexcept
Definition juce_AudioDataConverters.h:87
static float getAsFloat(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:83
Definition juce_AudioDataConverters.h:94
Definition juce_AudioDataConverters.h:309
@ isConst
Definition juce_AudioDataConverters.h:313
void VoidType
Definition juce_AudioDataConverters.h:311
static void * toVoidPtr(VoidType *v) noexcept
Definition juce_AudioDataConverters.h:312
Definition juce_AudioDataConverters.h:278
static int getNumBytesBetweenSamples(const SampleFormatType &) noexcept
Definition juce_AudioDataConverters.h:287
NonInterleaved(const int) noexcept
Definition juce_AudioDataConverters.h:282
void clear(SampleFormatType &s, int numSamples) noexcept
Definition juce_AudioDataConverters.h:286
void copyFrom(const NonInterleaved &) noexcept
Definition juce_AudioDataConverters.h:283
@ isInterleavedType
Definition juce_AudioDataConverters.h:289
@ numInterleavedChannels
Definition juce_AudioDataConverters.h:289
void advanceDataBy(SampleFormatType &s, int numSamples) noexcept
Definition juce_AudioDataConverters.h:285
NonInterleaved(const NonInterleaved &)=default
void advanceData(SampleFormatType &s) noexcept
Definition juce_AudioDataConverters.h:284
Definition juce_AudioDataConverters.h:355
void setAsInt32(int32 newValue) noexcept
Definition juce_AudioDataConverters.h:423
void clearSamples(int numSamples) const noexcept
Definition juce_AudioDataConverters.h:486
static int getBytesPerSample() noexcept
Definition juce_AudioDataConverters.h:550
void convertSamples(OtherPointerType source, int numSamples) const noexcept
Definition juce_AudioDataConverters.h:459
int getNumInterleavedChannels() const noexcept
Definition juce_AudioDataConverters.h:553
Pointer(const Pointer &other) noexcept
Definition juce_AudioDataConverters.h:379
void convertSamples(Pointer source, int numSamples) const noexcept
Definition juce_AudioDataConverters.h:442
int32 getAsInt32() const noexcept
Definition juce_AudioDataConverters.h:418
void setAsFloat(float newValue) noexcept
Definition juce_AudioDataConverters.h:405
Range< float > findMinAndMax(size_t numSamples) const noexcept
Definition juce_AudioDataConverters.h:493
Pointer & operator--() noexcept
Definition juce_AudioDataConverters.h:434
Pointer(typename Constness::VoidType *sourceData, int numInterleaved) noexcept
Definition juce_AudioDataConverters.h:373
Pointer & operator++() noexcept
Definition juce_AudioDataConverters.h:431
float getAsFloat() const noexcept
Definition juce_AudioDataConverters.h:396
Pointer(typename Constness::VoidType *sourceData) noexcept
Definition juce_AudioDataConverters.h:362
void findMinAndMax(size_t numSamples, float &minValue, float &maxValue) const noexcept
Definition juce_AudioDataConverters.h:536
static int get32BitResolution() noexcept
Definition juce_AudioDataConverters.h:563
static bool isBigEndian() noexcept
Definition juce_AudioDataConverters.h:547
Definition juce_AudioDataConverters.h:124
void setAsInt32LE(int newValue) noexcept
Definition juce_AudioDataConverters.h:136
void copyFromBE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:141
UInt8(void *d) noexcept
Definition juce_AudioDataConverters.h:126
int32 getAsInt32BE() const noexcept
Definition juce_AudioDataConverters.h:135
int32 getAsInt32LE() const noexcept
Definition juce_AudioDataConverters.h:134
void clearMultiple(int num) noexcept
Definition juce_AudioDataConverters.h:139
float getAsFloatLE() const noexcept
Definition juce_AudioDataConverters.h:130
void setAsInt32BE(int newValue) noexcept
Definition juce_AudioDataConverters.h:137
void copyFromSameType(UInt8 &source) noexcept
Definition juce_AudioDataConverters.h:142
void setAsFloatBE(float newValue) noexcept
Definition juce_AudioDataConverters.h:133
uint8 * data
Definition juce_AudioDataConverters.h:144
void skip(int numSamples) noexcept
Definition juce_AudioDataConverters.h:129
void copyFromLE(SourceType &source) noexcept
Definition juce_AudioDataConverters.h:140
float getAsFloatBE() const noexcept
Definition juce_AudioDataConverters.h:131
void advance() noexcept
Definition juce_AudioDataConverters.h:128
@ isFloat
Definition juce_AudioDataConverters.h:145
@ resolution
Definition juce_AudioDataConverters.h:145
@ bytesPerSample
Definition juce_AudioDataConverters.h:145
@ maxValue
Definition juce_AudioDataConverters.h:145
void clear() noexcept
Definition juce_AudioDataConverters.h:138
void setAsFloatLE(float newValue) noexcept
Definition juce_AudioDataConverters.h:132
static void convertFloatToInt16LE(const float *source, void *dest, int numSamples, int destBytesPerSample=2)
Definition juce_AudioDataConverters.cpp:29
static void convertFloatToInt24BE(const float *source, void *dest, int numSamples, int destBytesPerSample=3)
Definition juce_AudioDataConverters.cpp:104
static void convertFloatToInt32LE(const float *source, void *dest, int numSamples, int destBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:129
DataFormat
Definition juce_AudioDataConverters.h:828
@ float32LE
Definition juce_AudioDataConverters.h:835
@ int24BE
Definition juce_AudioDataConverters.h:832
@ int24LE
Definition juce_AudioDataConverters.h:831
@ int16BE
Definition juce_AudioDataConverters.h:830
@ float32BE
Definition juce_AudioDataConverters.h:836
@ int16LE
Definition juce_AudioDataConverters.h:829
@ int32LE
Definition juce_AudioDataConverters.h:833
@ int32BE
Definition juce_AudioDataConverters.h:834
static void convertFloat32LEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:366
static void convertInt32LEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:316
static void convertInt24BEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=3)
Definition juce_AudioDataConverters.cpp:291
static void convertFloatToInt16BE(const float *source, void *dest, int numSamples, int destBytesPerSample=2)
Definition juce_AudioDataConverters.cpp:54
static void convertFloatToInt24LE(const float *source, void *dest, int numSamples, int destBytesPerSample=3)
Definition juce_AudioDataConverters.cpp:79
static void convertFloatToInt32BE(const float *source, void *dest, int numSamples, int destBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:154
static void convertFloatToFloat32LE(const float *source, void *dest, int numSamples, int destBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:179
static void convertFloatToFloat32BE(const float *source, void *dest, int numSamples, int destBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:197
static void convertFloat32BEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:383
static void convertInt16BEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=2)
Definition juce_AudioDataConverters.cpp:241
static void convertInt16LEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=2)
Definition juce_AudioDataConverters.cpp:216
static void convertInt32BEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=4)
Definition juce_AudioDataConverters.cpp:341
static void convertInt24LEToFloat(const void *source, float *dest, int numSamples, int srcBytesPerSample=3)
Definition juce_AudioDataConverters.cpp:266
Definition juce_AudioDataConverters.h:36
static void interleaveSamples(NonInterleavedSource< SourceFormat... > source, InterleavedDest< DestFormat... > dest, int numSamples)
Definition juce_AudioDataConverters.h:720
ChannelData< true, true, Format... > InterleavedSource
Definition juce_AudioDataConverters.h:694
ChannelData< true, false, Format... > InterleavedDest
Definition juce_AudioDataConverters.h:696
ChannelData< false, true, Format... > NonInterleavedSource
Definition juce_AudioDataConverters.h:698
ChannelData< false, false, Format... > NonInterleavedDest
Definition juce_AudioDataConverters.h:700
static void deinterleaveSamples(InterleavedSource< SourceFormat... > source, NonInterleavedDest< DestFormat... > dest, int numSamples)
Definition juce_AudioDataConverters.h:764
static constexpr uint16 swap(uint16 value) noexcept
Definition juce_ByteOrder.h:147
Definition juce_Range.h:40
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
JSAMPIMAGE data
Definition jpeglib.h:945
#define jassert(expression)
#define JUCE_DECLARE_NON_COPYABLE(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
unsigned short uint16
Definition juce_MathsFunctions.h:41
unsigned int uint32
Definition juce_MathsFunctions.h:45
signed short int16
Definition juce_MathsFunctions.h:39
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262
signed char int8
Definition juce_MathsFunctions.h:35
Type * addBytesToPointer(Type *basePointer, IntegerType bytes) noexcept
Definition juce_Memory.h:111
signed int int32
Definition juce_MathsFunctions.h:43
unsigned char uint8
Definition juce_MathsFunctions.h:37
int roundToInt(const FloatType value) noexcept
Definition juce_MathsFunctions.h:465
void zeromem(void *memory, size_t numBytes) noexcept
Definition juce_Memory.h:28
Definition juce_AudioDataConverters.h:682
typename Subtypes::DataType DataType
Definition juce_AudioDataConverters.h:684
int channels
Definition juce_AudioDataConverters.h:688
DataType data
Definition juce_AudioDataConverters.h:687
typename Subtypes::PointerType PointerType
Definition juce_AudioDataConverters.h:685
ChannelDataSubtypes< IsInterleaved, IsConst, Format... > Subtypes
Definition juce_AudioDataConverters.h:683
std::remove_pointer_t< decltype(DataFormat::data)> ElementType
Definition juce_AudioDataConverters.h:663
std::conditional_t< IsInterleaved, ChannelType, ChannelType * > DataType
Definition juce_AudioDataConverters.h:665
Pointer< DataFormat, Endianness, std::conditional_t< IsInterleaved, Interleaved, NonInterleaved >, std::conditional_t< IsConst, Const, NonConst > > PointerType
Definition juce_AudioDataConverters.h:666
std::conditional_t< IsConst, const ElementType *, ElementType * > ChannelType
Definition juce_AudioDataConverters.h:664
typename Subtypes::PointerType PointerType
Definition juce_AudioDataConverters.h:677
ChannelDataSubtypes< IsInterleaved, IsConst, DataFormat, Endianness > Subtypes
Definition juce_AudioDataConverters.h:675
typename Subtypes::DataType DataType
Definition juce_AudioDataConverters.h:676
Definition juce_AudioDataConverters.h:658
Definition juce_AudioDataConverters.h:651
EndiannessIn Endianness
Definition juce_AudioDataConverters.h:653
DataFormatIn DataFormat
Definition juce_AudioDataConverters.h:652
int n
Definition crypt.c:458
int r
Definition crypt.c:458
typedef int(UZ_EXP MsgFn)()
#define void
Definition unzip.h:396
#define const
Definition zconf.h:137