summaryrefslogtreecommitdiff
path: root/core/math/audio_frame.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/audio_frame.h')
-rw-r--r--core/math/audio_frame.h77
1 files changed, 52 insertions, 25 deletions
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index e4e93f34fa..dd43f48df4 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -31,9 +31,7 @@
#include "typedefs.h"
-
-static inline float undenormalise(volatile float f)
-{
+static inline float undenormalise(volatile float f) {
union {
uint32_t i;
float f;
@@ -46,42 +44,71 @@ static inline float undenormalise(volatile float f)
return (v.i & 0x7f800000) < 0x08000000 ? 0.0f : f;
}
-
struct AudioFrame {
//left and right samples
- float l,r;
+ float l, r;
- _ALWAYS_INLINE_ const float& operator[](int idx) const { return idx==0?l:r; }
- _ALWAYS_INLINE_ float& operator[](int idx) { return idx==0?l:r; }
+ _ALWAYS_INLINE_ const float &operator[](int idx) const { return idx == 0 ? l : r; }
+ _ALWAYS_INLINE_ float &operator[](int idx) { return idx == 0 ? l : r; }
- _ALWAYS_INLINE_ AudioFrame operator+(const AudioFrame& p_frame) const { return AudioFrame(l+p_frame.l,r+p_frame.r); }
- _ALWAYS_INLINE_ AudioFrame operator-(const AudioFrame& p_frame) const { return AudioFrame(l-p_frame.l,r-p_frame.r); }
- _ALWAYS_INLINE_ AudioFrame operator*(const AudioFrame& p_frame) const { return AudioFrame(l*p_frame.l,r*p_frame.r); }
- _ALWAYS_INLINE_ AudioFrame operator/(const AudioFrame& p_frame) const { return AudioFrame(l/p_frame.l,r/p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator+(const AudioFrame &p_frame) const { return AudioFrame(l + p_frame.l, r + p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator-(const AudioFrame &p_frame) const { return AudioFrame(l - p_frame.l, r - p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator*(const AudioFrame &p_frame) const { return AudioFrame(l * p_frame.l, r * p_frame.r); }
+ _ALWAYS_INLINE_ AudioFrame operator/(const AudioFrame &p_frame) const { return AudioFrame(l / p_frame.l, r / p_frame.r); }
- _ALWAYS_INLINE_ AudioFrame operator+(float p_sample) const { return AudioFrame(l+p_sample,r+p_sample); }
- _ALWAYS_INLINE_ AudioFrame operator-(float p_sample) const { return AudioFrame(l-p_sample,r-p_sample); }
- _ALWAYS_INLINE_ AudioFrame operator*(float p_sample) const { return AudioFrame(l*p_sample,r*p_sample); }
- _ALWAYS_INLINE_ AudioFrame operator/(float p_sample) const { return AudioFrame(l/p_sample,r/p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator+(float p_sample) const { return AudioFrame(l + p_sample, r + p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator-(float p_sample) const { return AudioFrame(l - p_sample, r - p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator*(float p_sample) const { return AudioFrame(l * p_sample, r * p_sample); }
+ _ALWAYS_INLINE_ AudioFrame operator/(float p_sample) const { return AudioFrame(l / p_sample, r / p_sample); }
- _ALWAYS_INLINE_ void operator+=(const AudioFrame& p_frame) { l+=p_frame.l; r+=p_frame.r; }
- _ALWAYS_INLINE_ void operator-=(const AudioFrame& p_frame) { l-=p_frame.l; r-=p_frame.r; }
- _ALWAYS_INLINE_ void operator*=(const AudioFrame& p_frame) { l*=p_frame.l; r*=p_frame.r; }
- _ALWAYS_INLINE_ void operator/=(const AudioFrame& p_frame) { l/=p_frame.l; r/=p_frame.r; }
+ _ALWAYS_INLINE_ void operator+=(const AudioFrame &p_frame) {
+ l += p_frame.l;
+ r += p_frame.r;
+ }
+ _ALWAYS_INLINE_ void operator-=(const AudioFrame &p_frame) {
+ l -= p_frame.l;
+ r -= p_frame.r;
+ }
+ _ALWAYS_INLINE_ void operator*=(const AudioFrame &p_frame) {
+ l *= p_frame.l;
+ r *= p_frame.r;
+ }
+ _ALWAYS_INLINE_ void operator/=(const AudioFrame &p_frame) {
+ l /= p_frame.l;
+ r /= p_frame.r;
+ }
- _ALWAYS_INLINE_ void operator+=(float p_sample) { l+=p_sample; r+=p_sample; }
- _ALWAYS_INLINE_ void operator-=(float p_sample) { l-=p_sample; r-=p_sample; }
- _ALWAYS_INLINE_ void operator*=(float p_sample) { l*=p_sample; r*=p_sample; }
- _ALWAYS_INLINE_ void operator/=(float p_sample) { l/=p_sample; r/=p_sample; }
+ _ALWAYS_INLINE_ void operator+=(float p_sample) {
+ l += p_sample;
+ r += p_sample;
+ }
+ _ALWAYS_INLINE_ void operator-=(float p_sample) {
+ l -= p_sample;
+ r -= p_sample;
+ }
+ _ALWAYS_INLINE_ void operator*=(float p_sample) {
+ l *= p_sample;
+ r *= p_sample;
+ }
+ _ALWAYS_INLINE_ void operator/=(float p_sample) {
+ l /= p_sample;
+ r /= p_sample;
+ }
_ALWAYS_INLINE_ void undenormalise() {
l = ::undenormalise(l);
r = ::undenormalise(r);
}
- _ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {l=p_l; r=p_r;}
- _ALWAYS_INLINE_ AudioFrame(const AudioFrame& p_frame) {l=p_frame.l; r=p_frame.r;}
+ _ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {
+ l = p_l;
+ r = p_r;
+ }
+ _ALWAYS_INLINE_ AudioFrame(const AudioFrame &p_frame) {
+ l = p_frame.l;
+ r = p_frame.r;
+ }
_ALWAYS_INLINE_ AudioFrame() {}
};