Skip to content

Commit

Permalink
Support for DSD sampling rates (http://bobtalks.co.uk/blog/mqa-philos…
Browse files Browse the repository at this point in the history
…ophy/mqa-authentication-and-quality/)

Signed-off-by: Stavros Avramidis <stavros9899@gmail.com>
  • Loading branch information
purpl3F0x committed Apr 6, 2020
1 parent de25dae commit ca6f2e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 17 additions & 3 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,30 @@
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>


#include "mqa_identifier.h"

namespace fs = std::filesystem;


auto getSampleRateString(const uint32_t fs) {
std::stringstream ss;
if (fs <= 768000)
ss << fs / 1000. << "K";
else if (fs % 44100 == 0)
ss << "DSD" << fs / 44100;
else
ss << "DSD" << fs / 48000 << "x48";

return ss.str();
}


/**
* @short Recurivly scan a directory for .flac files
* @short Recursively scan a directory for .flac files
* @param curDir directory to scan
* @param files vector to add the file paths
*/
Expand Down Expand Up @@ -76,7 +90,7 @@ int main(int argc, char *argv[]) {
auto id = MQA_identifier(file);
if (id.detect()) {
if (id.originalSampleRate())
std::cout << "MQA " << id.originalSampleRate() / 1000. << "K \t";
std::cout << "MQA " << getSampleRateString(id.originalSampleRate()) << "\t";
else
std::cout << "MQA\t\t";
std::cout << fs::path(file).filename().string() << "\n";
Expand Down
4 changes: 3 additions & 1 deletion mqa_identifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ uint32_t OriginalSampleRateDecoder(unsigned c) {
*/
const uint32_t base = (c & 1u) ? 48000 : 44100;

const uint32_t multiplier = 1u << (((c >> 3u) & 1u) | (((c >> 2u) & 1u) << 1u) | (((c >> 1u) & 1u) << 2u));
uint32_t multiplier = 1u << (((c >> 3u) & 1u) | (((c >> 2u) & 1u) << 1u) | (((c >> 1u) & 1u) << 2u));
// Double for DSD
if (multiplier > 16) multiplier *= 2;

return base * multiplier;
}
Expand Down

0 comments on commit ca6f2e7

Please sign in to comment.