Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/sources/audiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

namespace mixxx {

/*static*/ constexpr AudioSignal::SampleLayout AudioSource::kSampleLayout;

/*static*/ constexpr SINT AudioSource::kFrameCountZero;
/*static*/ constexpr SINT AudioSource::kFrameCountDefault;

/*static*/ constexpr SINT AudioSource::kFrameIndexMin;

/*static*/ constexpr SINT AudioSource::kBitrateZero;
/*static*/ constexpr SINT AudioSource::kBitrateDefault;

void AudioSource::clampFrameInterval(
SINT* pMinFrameIndexOfInterval,
SINT* pMaxFrameIndexOfInterval,
Expand Down
12 changes: 6 additions & 6 deletions src/sources/audiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AudioSourceConfig;
// closed upon destruction.
class AudioSource: public UrlResource, public AudioSignal {
public:
static const SampleLayout kSampleLayout = SampleLayout::Interleaved;
static constexpr SampleLayout kSampleLayout = SampleLayout::Interleaved;

// Returns the total number of sample frames.
inline SINT getFrameCount() const {
Expand Down Expand Up @@ -199,14 +199,14 @@ class AudioSource: public UrlResource, public AudioSignal {
private:
friend class AudioSourceConfig;

static const SINT kFrameCountZero = 0;
static const SINT kFrameCountDefault = kFrameCountZero;
static constexpr SINT kFrameCountZero = 0;
static constexpr SINT kFrameCountDefault = kFrameCountZero;

// 0-based indexing of sample frames
static const SINT kFrameIndexMin = 0;
static constexpr SINT kFrameIndexMin = 0;

static const SINT kBitrateZero = 0;
static const SINT kBitrateDefault = kBitrateZero;
static constexpr SINT kBitrateZero = 0;
static constexpr SINT kBitrateDefault = kBitrateZero;

SINT m_frameCount;

Expand Down
2 changes: 1 addition & 1 deletion src/sources/mp3decoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace mixxx {
// for accurate seeking:
// http://www.mars.org/mailman/public/mad-dev/2002-May/000634.html
// Used by both SoundSourceMp3 and SoundSourceCoreAudio.
static const SINT kMp3SeekFramePrefetchCount = 29;
constexpr SINT kMp3SeekFramePrefetchCount = 29;

} // namespace mixxx

Expand Down
6 changes: 3 additions & 3 deletions src/sources/soundsourcemodplug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ QString getModPlugTypeFromUrl(QUrl url) {

} // anonymous namespace

const SINT SoundSourceModPlug::kChannelCount = AudioSource::kChannelCountStereo;
const SINT SoundSourceModPlug::kBitsPerSample = 16;
const SINT SoundSourceModPlug::kSamplingRate = 44100; // 44.1 kHz
/*static*/ constexpr SINT SoundSourceModPlug::kChannelCount;
/*static*/ constexpr SINT SoundSourceModPlug::kBitsPerSample;
/*static*/ constexpr SINT SoundSourceModPlug::kSamplingRate;

unsigned int SoundSourceModPlug::s_bufferSizeLimit = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/sources/soundsourcemodplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace mixxx {
// in RAM to allow seeking and smooth operation in Mixxx.
class SoundSourceModPlug: public mixxx::SoundSource {
public:
static const SINT kChannelCount;
static const SINT kSamplingRate;
static const SINT kBitsPerSample;
static constexpr SINT kChannelCount = kChannelCountStereo;
static constexpr SINT kSamplingRate = 44100;
static constexpr SINT kBitsPerSample = 16;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space indent.


// apply settings for decoding
static void configure(unsigned int bufferSizeLimit,
Expand Down
8 changes: 4 additions & 4 deletions src/sources/soundsourceopus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ const CSAMPLE SoundSourceOpus::kMaxDecodingError = 0.01f;
namespace {

// Decoded output of opusfile has a fixed sample rate of 48 kHz (fullband)
const SINT kSamplingRate = 48000;
constexpr SINT kSamplingRate = 48000;

// http://opus-codec.org
// - Sampling rate 48 kHz (fullband)
// - Frame sizes from 2.5 ms to 60 ms
// => Up to 48000 kHz * 0.06 s = 2880 sample frames per data frame
// Prefetching 2 * 2880 sample frames while seeking limits the decoding
// errors to kMaxDecodingError (see definition below) during our tests.
const SINT kNumberOfPrefetchFrames = 2 * 2880;
constexpr SINT kNumberOfPrefetchFrames = 2 * 2880;

// Parameter for op_channel_count()
// See also: https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/group__stream__info.html
const int kCurrentStreamLink = -1; // get ... of the current (stream) link
constexpr int kCurrentStreamLink = -1; // get ... of the current (stream) link

// Parameter for op_pcm_total() and op_bitrate()
// See also: https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/group__stream__info.html
const int kEntireStreamLink = -1; // get ... of the whole/entire stream
constexpr int kEntireStreamLink = -1; // get ... of the whole/entire stream

class OggOpusFileOwner {
public:
Expand Down
7 changes: 2 additions & 5 deletions src/track/bpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace mixxx {

// TODO(uklotzde): Replace 'const' with 'constexpr' and remove
// initialization after switching to Visual Studio 2015.

/*static*/ const double Bpm::kValueUndefined = 0.0;
/*static*/ const double Bpm::kValueMin = 0.0; // lower bound (exclusive)
/*static*/ constexpr double Bpm::kValueUndefined;
/*static*/ constexpr double Bpm::kValueMin;

double Bpm::valueFromString(const QString& str, bool* pValid) {
if (pValid) {
Expand Down
7 changes: 2 additions & 5 deletions src/track/bpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ namespace mixxx {
// DTO for storing BPM information.
class Bpm final {
public:
// TODO(uklotzde): Replace 'const' with 'constexpr'
// (and copy initialization from .cpp file) after switching to
// Visual Studio 2015 on Windows.
static const double kValueUndefined;
static const double kValueMin; // lower bound (exclusive)
static constexpr double kValueUndefined = 0.0;
static constexpr double kValueMin = 0.0; // lower bound (exclusive)

Bpm()
: Bpm(kValueUndefined) {
Expand Down
6 changes: 0 additions & 6 deletions src/track/keyutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@ class KeyUtils {
}

static inline double powerOf2ToOctaveChange(const double& power_of_2) {
// log2 is in the C99 standard, MSVC only supports C90.
#ifdef _MSC_VER
static const double lg2 = log(2.0);
return log(power_of_2) / lg2;
#else
return log2(power_of_2);
#endif
}

static inline double powerOf2ToSemitoneChange(const double& power_of_2) {
Expand Down
15 changes: 6 additions & 9 deletions src/track/replaygain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

namespace mixxx {

// TODO(uklotzde): Replace 'const' with 'constexpr' and remove
// initialization after switching to Visual Studio 2015.
/*static*/ constexpr double ReplayGain::kRatioUndefined;
/*static*/ constexpr double ReplayGain::kRatioMin;
/*static*/ constexpr double ReplayGain::kRatio0dB;

/*static*/ const double ReplayGain::kRatioUndefined = 0.0;
/*static*/ const double ReplayGain::kRatioMin = 0.0; // lower bound (exclusive)
/*static*/ const double ReplayGain::kRatio0dB = 1.0;

/*static*/ const CSAMPLE ReplayGain::kPeakUndefined = -CSAMPLE_PEAK;
/*static*/ const CSAMPLE ReplayGain::kPeakMin = CSAMPLE_ZERO; // lower bound (inclusive)
/*static*/ const CSAMPLE ReplayGain::kPeakClip = CSAMPLE_PEAK; // upper bound (inclusive) represents digital full scale without clipping;
/*static*/ constexpr CSAMPLE ReplayGain::kPeakUndefined;
/*static*/ constexpr CSAMPLE ReplayGain::kPeakMin;
/*static*/ constexpr CSAMPLE ReplayGain::kPeakClip;

namespace {

Expand Down
31 changes: 13 additions & 18 deletions src/track/replaygain.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,19 @@ namespace mixxx {
// as a string into file tags.
class ReplayGain final {
public:
// TODO(uklotzde): Replace 'const' with 'constexpr'
// (and copy initialization from .cpp file) after switching to
// Visual Studio 2015 on Windows.
static const double kRatioUndefined;
static const double kRatioMin; // lower bound (exclusive)
static const double kRatio0dB;

static const CSAMPLE kPeakUndefined;
static const CSAMPLE kPeakMin; // lower bound (inclusive)
static const CSAMPLE kPeakClip; // upper bound (inclusive) represents digital full scale without clipping

// TODO(uklotzde): Uncomment after switching to Visual Studio 2015
// on Windows.
//static_assert(ReplayGain::kPeakClip == 1.0,
// "http://wiki.hydrogenaud.io/index.php"
// "?title=ReplayGain_2.0_specification#Peak_amplitude: "
// "The maximum peak amplitude value is stored as a floating number, "
// "where 1.0 represents digital full scale");
static constexpr double kRatioUndefined = 0.0;
static constexpr double kRatioMin = 0.0; // lower bound (exclusive)
static constexpr double kRatio0dB = 1.0;

static constexpr CSAMPLE kPeakUndefined = -CSAMPLE_PEAK;
static constexpr CSAMPLE kPeakMin = CSAMPLE_ZERO; // lower bound (inclusive)
static constexpr CSAMPLE kPeakClip = CSAMPLE_PEAK; // upper bound (inclusive) represents digital full scale without clipping

static_assert(ReplayGain::kPeakClip == 1.0,
"http://wiki.hydrogenaud.io/index.php"
"?title=ReplayGain_2.0_specification#Peak_amplitude: "
"The maximum peak amplitude value is stored as a floating number, "
"where 1.0 represents digital full scale");

ReplayGain()
: ReplayGain(kRatioUndefined, kPeakUndefined) {
Expand Down
9 changes: 0 additions & 9 deletions src/track/trackid.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,8 @@

class TrackId: public DbId {
public:
#if defined(_MSC_VER) && (_MSC_VER < 1900)
// NOTE(uklotzde): Inheriting constructors are supported since VS2015.
// Use a default constructor and a single-argument constructor with
// perfect forwarding instead.
TrackId() {}
template<typename T>
explicit TrackId(T&& arg): DbId(std::forward<T>(arg)) {}
#else
// Inherit constructors from base class
using DbId::DbId;
#endif
};

Q_DECLARE_TYPEINFO(TrackId, Q_MOVABLE_TYPE);
Expand Down
2 changes: 1 addition & 1 deletion src/track/trackmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace mixxx {

/*static*/ const int TrackMetadata::kCalendarYearInvalid = 0;
/*static*/ constexpr int TrackMetadata::kCalendarYearInvalid;

int TrackMetadata::parseCalendarYear(QString year, bool* pValid) {
const QDateTime dateTime(parseDateTime(year));
Expand Down
4 changes: 2 additions & 2 deletions src/track/trackmetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace mixxx {

// DTO for track metadata properties. Must not be subclassed (no virtual destructor)!
class TrackMetadata {
class TrackMetadata final {
public:
TrackMetadata();

Expand Down Expand Up @@ -165,7 +165,7 @@ class TrackMetadata {
}

// Parse and format the calendar year (for simplified display)
static const int kCalendarYearInvalid;
static constexpr int kCalendarYearInvalid = 0;
static int parseCalendarYear(QString year, bool* pValid = 0);
static QString formatCalendarYear(QString year, bool* pValid = 0);

Expand Down
6 changes: 4 additions & 2 deletions src/track/tracknumbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include "track/tracknumbers.h"
#include "util/assert.h"

// static
const QString TrackNumbers::kSeparator("/");
/*static*/ constexpr int TrackNumbers::kValueUndefined;
/*static*/ constexpr int TrackNumbers::kValueMin;

/*static*/ const QString TrackNumbers::kSeparator("/");

//static
bool TrackNumbers::parseValueFromString(
Expand Down
5 changes: 2 additions & 3 deletions src/track/tracknumbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
// Both numbers are 1-based and 0 indicates an undefined value.
class TrackNumbers final {
public:
// TODO(uklotzde): Replace 'const' with 'constexpr'
static const int kValueUndefined = 0;
static const int kValueMin = 1; // lower bound (inclusive)
static constexpr int kValueUndefined = 0;
static constexpr int kValueMin = 1; // lower bound (inclusive)

// Separates the total number of tracks from the actual
// track number in the textual format.
Expand Down
36 changes: 16 additions & 20 deletions src/util/audiosignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@

namespace mixxx {

// Separate definitions of static class constants are only required
// for LLVM CLang. Otherwise the linker complains about undefined
// symbols!?
#if defined(__clang__)
const SINT AudioSignal::kChannelCountZero;
const SINT AudioSignal::kChannelCountDefault;
const SINT AudioSignal::kChannelCountMono;
const SINT AudioSignal::kChannelCountMin;
const SINT AudioSignal::kChannelCountStereo;
const SINT AudioSignal::kChannelCountMax;
const SINT AudioSignal::kSamplingRateZero;
const SINT AudioSignal::kSamplingRateDefault;
const SINT AudioSignal::kSamplingRateMin;
const SINT AudioSignal::kSamplingRate32kHz;
const SINT AudioSignal::kSamplingRateCD;
const SINT AudioSignal::kSamplingRate48kHz;
const SINT AudioSignal::kSamplingRate96kHz;
const SINT AudioSignal::kSamplingRate192kHz;
const SINT AudioSignal::kSamplingRateMax;
#endif
/*static*/ constexpr SINT AudioSignal::kChannelCountZero;
/*static*/ constexpr SINT AudioSignal::kChannelCountDefault;
/*static*/ constexpr SINT AudioSignal::kChannelCountMono;
/*static*/ constexpr SINT AudioSignal::kChannelCountMin;
/*static*/ constexpr SINT AudioSignal::kChannelCountStereo;
/*static*/ constexpr SINT AudioSignal::kChannelCountMax;

/*static*/ constexpr SINT AudioSignal::kSamplingRateZero;
/*static*/ constexpr SINT AudioSignal::kSamplingRateDefault;
/*static*/ constexpr SINT AudioSignal::kSamplingRateMin;
/*static*/ constexpr SINT AudioSignal::kSamplingRate32kHz;
/*static*/ constexpr SINT AudioSignal::kSamplingRateCD;
/*static*/ constexpr SINT AudioSignal::kSamplingRate48kHz;
/*static*/ constexpr SINT AudioSignal::kSamplingRate96kHz;
/*static*/ constexpr SINT AudioSignal::kSamplingRate192kHz;
/*static*/ constexpr SINT AudioSignal::kSamplingRateMax;

bool AudioSignal::verifyReadable() const {
bool result = true;
Expand Down
30 changes: 15 additions & 15 deletions src/util/audiosignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ class AudioSignal {
Interleaved
};

static const SINT kChannelCountZero = 0;
static const SINT kChannelCountDefault = kChannelCountZero;
static const SINT kChannelCountMono = 1;
static const SINT kChannelCountMin = kChannelCountMono; // lower bound
static const SINT kChannelCountStereo = 2;
static const SINT kChannelCountMax = 256; // upper bound (8-bit unsigned integer)
static constexpr SINT kChannelCountZero = 0;
static constexpr SINT kChannelCountDefault = kChannelCountZero;
static constexpr SINT kChannelCountMono = 1;
static constexpr SINT kChannelCountMin = kChannelCountMono; // lower bound
static constexpr SINT kChannelCountStereo = 2;
static constexpr SINT kChannelCountMax = 256; // upper bound (8-bit unsigned integer)

static bool isValidChannelCount(SINT channelCount) {
return (kChannelCountMin <= channelCount) && (kChannelCountMax >= channelCount);
}

static const SINT kSamplingRateZero = 0;
static const SINT kSamplingRateDefault = kSamplingRateZero;
static const SINT kSamplingRateMin = 8000; // lower bound (= minimum MP3 sampling rate)
static const SINT kSamplingRate32kHz = 32000;
static const SINT kSamplingRateCD = 44100;
static const SINT kSamplingRate48kHz = 48000;
static const SINT kSamplingRate96kHz = 96000;
static const SINT kSamplingRate192kHz = 192000;
static const SINT kSamplingRateMax = kSamplingRate192kHz; // upper bound
static constexpr SINT kSamplingRateZero = 0;
static constexpr SINT kSamplingRateDefault = kSamplingRateZero;
static constexpr SINT kSamplingRateMin = 8000; // lower bound (= minimum MP3 sampling rate)
static constexpr SINT kSamplingRate32kHz = 32000;
static constexpr SINT kSamplingRateCD = 44100;
static constexpr SINT kSamplingRate48kHz = 48000;
static constexpr SINT kSamplingRate96kHz = 96000;
static constexpr SINT kSamplingRate192kHz = 192000;
static constexpr SINT kSamplingRateMax = kSamplingRate192kHz; // upper bound

static bool isValidSamplingRate(SINT samplingRate) {
return (kSamplingRateMin <= samplingRate) && (kSamplingRateMax >= samplingRate);
Expand Down
7 changes: 0 additions & 7 deletions src/util/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ inline int roundUpToPowerOf2(int v) {
return power;
}

// MSVS 2013 (_MSC_VER 1800) introduced C99 support.
#if defined(__WINDOWS__) && _MSC_VER < 1800
inline int round(double x) {
return x < 0.0 ? ceil(x - 0.5) : floor(x + 0.5);
}
#endif

template <typename T>
inline const T ratio2db(const T a) {
return log10(a) * 20;
Expand Down
Loading