diff options
author | Jan Holthuis <jholthuis@mixxx.org> | 2021-07-08 21:32:41 +0200 |
---|---|---|
committer | Jan Holthuis <jholthuis@mixxx.org> | 2021-07-08 21:36:14 +0200 |
commit | 309c04e5c09aa9a11f2c2b07e53766b9b534ca11 (patch) | |
tree | a6f5b1c34e743d0be254f4c1d49a7add12c80d50 /src/audio | |
parent | 7cc4e0f3d03defcfbf2aad209709a5b0f403ef42 (diff) |
SampleRate: Add operator for dividing by another sample rate
This is a follow up to PR #4085.
Diffstat (limited to 'src/audio')
-rw-r--r-- | src/audio/types.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio/types.h b/src/audio/types.h index ef05204bd1..a3f80ee87d 100644 --- a/src/audio/types.h +++ b/src/audio/types.h @@ -165,12 +165,21 @@ class SampleRate { return SampleRate(static_cast<value_t>(value)); } + constexpr double toDouble() { + return static_cast<double>(value()); + } + private: value_t m_value; }; QDebug operator<<(QDebug dbg, SampleRate arg); +/// Division of a SampleRate by another SampleRate returns a ratio as double. +inline double operator/(SampleRate sampleRate1, SampleRate sampleRate2) { + return sampleRate1.toDouble() / sampleRate2.toDouble(); +} + // The bitrate is measured in kbit/s (kbps) and provides information // about the level of compression for lossily encoded audio streams. // |