|
12 | 12 | #include "util/performancetimer.h" |
13 | 13 | #include "util/sample.h" |
14 | 14 |
|
| 15 | +#ifdef DEBUG_PRINT_FINGERPRINT |
| 16 | +#include <QCryptographicHash> |
| 17 | +#endif |
| 18 | + |
15 | 19 | namespace |
16 | 20 | { |
17 | 21 |
|
@@ -53,6 +57,14 @@ QString calcFingerprint( |
53 | 57 | std::vector<SAMPLE> fingerprintSamples( |
54 | 58 | audioSourceProxy.getSignalInfo().frames2samples( |
55 | 59 | readableSampleFrames.frameLength())); |
| 60 | + |
| 61 | +#ifdef DEBUG_PRINT_FINGERPRINT |
| 62 | + SampleUtil::applyGain( |
| 63 | + sampleBuffer.data(), |
| 64 | + 1, |
| 65 | + sampleBuffer.size()); |
| 66 | +#endif |
| 67 | + |
56 | 68 | // Convert floating-point to integer |
57 | 69 | SampleUtil::convertFloat32ToS16( |
58 | 70 | &fingerprintSamples[0], |
@@ -83,14 +95,40 @@ QString calcFingerprint( |
83 | 95 | uint32_p fprint = nullptr; |
84 | 96 | int size = 0; |
85 | 97 | int ret = chromaprint_get_raw_fingerprint(ctx, &fprint, &size); |
| 98 | + |
| 99 | +#ifdef DEBUG_PRINT_FINGERPRINT |
| 100 | + uint32_t simHash; |
| 101 | + chromaprint_hash_fingerprint(fprint, size, &simHash); |
| 102 | + |
| 103 | + QByteArray hash = |
| 104 | + QCryptographicHash::hash(QByteArray(reinterpret_cast<char*>(fprint), |
| 105 | + size * sizeof(fprint[0])), |
| 106 | + QCryptographicHash::Md5) |
| 107 | + .toHex(); |
| 108 | + |
| 109 | + qDebug() << "Hash:" << hash; |
| 110 | + qDebug() << "SimHash:" << simHash; |
| 111 | + |
| 112 | + for (int i = 0; i < size; ++i) { |
| 113 | + QString item = QString::number(fprint[i], 2).replace('0', ' '); |
| 114 | + while (item.length() < 32) { |
| 115 | + item.prepend(' '); |
| 116 | + } |
| 117 | + qDebug() << item << i; |
| 118 | + } |
| 119 | +#endif |
| 120 | + |
86 | 121 | QByteArray fingerprint; |
87 | 122 | if (ret == 1) { |
88 | 123 | char_p encoded = nullptr; |
89 | 124 | int encoded_size = 0; |
90 | | - chromaprint_encode_fingerprint(fprint, size, |
91 | | - CHROMAPRINT_ALGORITHM_DEFAULT, |
92 | | - &encoded, |
93 | | - &encoded_size, 1); |
| 125 | + int base64 = 1; |
| 126 | + chromaprint_encode_fingerprint(fprint, |
| 127 | + size, |
| 128 | + CHROMAPRINT_ALGORITHM_DEFAULT, |
| 129 | + &encoded, |
| 130 | + &encoded_size, |
| 131 | + base64); |
94 | 132 |
|
95 | 133 | fingerprint.append(reinterpret_cast<char*>(encoded), encoded_size); |
96 | 134 |
|
@@ -123,10 +161,11 @@ QString ChromaPrinter::getFingerprint(TrackPointer pTrack) { |
123 | 161 | return QString(); |
124 | 162 | } |
125 | 163 |
|
| 164 | + const SINT startFrame = 2; |
126 | 165 | const auto fingerprintRange = intersect( |
127 | 166 | pAudioSource->frameIndexRange(), |
128 | 167 | mixxx::IndexRange::forward( |
129 | | - pAudioSource->frameIndexMin(), |
| 168 | + pAudioSource->frameIndexMin() + startFrame, |
130 | 169 | kFingerprintDuration * pAudioSource->getSignalInfo().getSampleRate())); |
131 | 170 | mixxx::AudioSourceStereoProxy audioSourceProxy( |
132 | 171 | pAudioSource, |
|
0 commit comments