flac-detective 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flac_detective-0.6.0/PKG-INFO +305 -0
- flac_detective-0.6.0/README.md +269 -0
- flac_detective-0.6.0/pyproject.toml +155 -0
- flac_detective-0.6.0/setup.cfg +4 -0
- flac_detective-0.6.0/setup.py +5 -0
- flac_detective-0.6.0/src/flac_detective/__init__.py +8 -0
- flac_detective-0.6.0/src/flac_detective/analysis/__init__.py +9 -0
- flac_detective-0.6.0/src/flac_detective/analysis/analyzer.py +134 -0
- flac_detective-0.6.0/src/flac_detective/analysis/audio_cache.py +160 -0
- flac_detective-0.6.0/src/flac_detective/analysis/file_cache.py +171 -0
- flac_detective-0.6.0/src/flac_detective/analysis/metadata.py +96 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/__init__.py +57 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/artifacts.py +386 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/bitrate.py +147 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/calculator.py +352 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/constants.py +59 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/metadata.py +47 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/models.py +44 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/__init__.py +31 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/artifacts.py +54 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/bitrate.py +234 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/cassette.py +136 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/consistency.py +110 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/silence.py +178 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/rules/spectral.py +269 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/silence.py +327 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/silence_utils.py +205 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/strategies.py +167 -0
- flac_detective-0.6.0/src/flac_detective/analysis/new_scoring/verdict.py +28 -0
- flac_detective-0.6.0/src/flac_detective/analysis/quality.py +550 -0
- flac_detective-0.6.0/src/flac_detective/analysis/scoring.py +167 -0
- flac_detective-0.6.0/src/flac_detective/analysis/spectrum.py +385 -0
- flac_detective-0.6.0/src/flac_detective/analysis/window_cache.py +75 -0
- flac_detective-0.6.0/src/flac_detective/analyzer.py +8 -0
- flac_detective-0.6.0/src/flac_detective/colors.py +33 -0
- flac_detective-0.6.0/src/flac_detective/config.py +81 -0
- flac_detective-0.6.0/src/flac_detective/main.py +469 -0
- flac_detective-0.6.0/src/flac_detective/repair/__init__.py +9 -0
- flac_detective-0.6.0/src/flac_detective/repair/__main__.py +87 -0
- flac_detective-0.6.0/src/flac_detective/repair/encoding.py +73 -0
- flac_detective-0.6.0/src/flac_detective/repair/fixer.py +235 -0
- flac_detective-0.6.0/src/flac_detective/repair/metadata.py +108 -0
- flac_detective-0.6.0/src/flac_detective/repair.py +9 -0
- flac_detective-0.6.0/src/flac_detective/reporter.py +8 -0
- flac_detective-0.6.0/src/flac_detective/reporting/__init__.py +6 -0
- flac_detective-0.6.0/src/flac_detective/reporting/reporter.py +276 -0
- flac_detective-0.6.0/src/flac_detective/reporting/statistics.py +107 -0
- flac_detective-0.6.0/src/flac_detective/reporting/styles.py +55 -0
- flac_detective-0.6.0/src/flac_detective/reporting/text_reporter.py +214 -0
- flac_detective-0.6.0/src/flac_detective/tracker.py +109 -0
- flac_detective-0.6.0/src/flac_detective/utils.py +66 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/PKG-INFO +305 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/SOURCES.txt +64 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/dependency_links.txt +1 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/entry_points.txt +2 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/requires.txt +15 -0
- flac_detective-0.6.0/src/flac_detective.egg-info/top_level.txt +1 -0
- flac_detective-0.6.0/tests/test_new_scoring.py +392 -0
- flac_detective-0.6.0/tests/test_new_scoring_rules.py +300 -0
- flac_detective-0.6.0/tests/test_rule11.py +107 -0
- flac_detective-0.6.0/tests/test_rule4.py +121 -0
- flac_detective-0.6.0/tests/test_rule6.py +121 -0
- flac_detective-0.6.0/tests/test_rule7_vinyl.py +182 -0
- flac_detective-0.6.0/tests/test_rule8.py +83 -0
- flac_detective-0.6.0/tests/test_rule9.py +253 -0
- flac_detective-0.6.0/tests/test_scoring.py +77 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flac-detective
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Advanced FLAC authenticity analyzer - Detects MP3-to-FLAC transcodes with high precision
|
|
5
|
+
Author-email: Your Name <your.email@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: flac,audio,analysis,transcode,detection,mp3,quality,authenticity
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.8
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: numpy>=1.20.0
|
|
23
|
+
Requires-Dist: scipy>=1.7.0
|
|
24
|
+
Requires-Dist: mutagen>=1.45.0
|
|
25
|
+
Requires-Dist: openpyxl>=3.0.0
|
|
26
|
+
Requires-Dist: soundfile>=0.10.0
|
|
27
|
+
Requires-Dist: matplotlib>=3.3.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
33
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pylint>=2.17.0; extra == "dev"
|
|
36
|
+
|
|
37
|
+
# ๐ต FLAC Detective
|
|
38
|
+
|
|
39
|
+
**Advanced FLAC Authenticity Analyzer - Production Ready v0.5.0**
|
|
40
|
+
|
|
41
|
+
> "Every FLAC file tells a story... I find the truth."
|
|
42
|
+
|
|
43
|
+
FLAC Detective is a professional-grade tool for detecting MP3-to-FLAC transcodes with exceptional precision. Using advanced spectral analysis and multi-rule scoring, it achieves 79.2% authentic detection rate with less than 0.5% false positives.
|
|
44
|
+
|
|
45
|
+
[](https://www.python.org/downloads/)
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
[](https://github.com/GuillainM/FLAC_Detective)
|
|
48
|
+
|
|
49
|
+
## โจ Features
|
|
50
|
+
|
|
51
|
+
### ๐ฏ Advanced 12-Rule Detection System
|
|
52
|
+
|
|
53
|
+
- **Rule 1**: MP3 Spectral Signature Detection (CBR patterns)
|
|
54
|
+
- **Rule 2**: Cutoff Frequency Analysis vs Nyquist
|
|
55
|
+
- **Rule 3**: Source vs Container Bitrate Comparison
|
|
56
|
+
- **Rule 4**: Suspicious 24-bit File Detection
|
|
57
|
+
- **Rule 5**: High Variance Protection (VBR)
|
|
58
|
+
- **Rule 6**: High Quality Protection
|
|
59
|
+
- **Rule 7**: Silence & Vinyl Analysis (3 phases)
|
|
60
|
+
- Phase 1: Dither detection
|
|
61
|
+
- Phase 2: Vinyl surface noise
|
|
62
|
+
- Phase 3: Clicks & pops
|
|
63
|
+
- **Rule 8**: Nyquist Exception (95% & 90% thresholds)
|
|
64
|
+
- **Rule 9**: Compression Artifacts Detection
|
|
65
|
+
- Test A: Pre-echo (MDCT ghosting)
|
|
66
|
+
- Test B: High-frequency aliasing
|
|
67
|
+
- Test C: MP3 quantization noise
|
|
68
|
+
- **Rule 10**: Multi-Segment Consistency Analysis
|
|
69
|
+
|
|
70
|
+
### ๐ 4-Level Verdict System
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
Score โฅ 86 โ FAKE_CERTAIN โ (100% confidence)
|
|
74
|
+
Score 61-85 โ SUSPICIOUS โ ๏ธ (High confidence)
|
|
75
|
+
Score 31-60 โ WARNING โก (Manual review recommended)
|
|
76
|
+
Score โค 30 โ AUTHENTIC โ
(99.5% confidence)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### โก Performance Optimizations
|
|
80
|
+
|
|
81
|
+
- **80% faster** than baseline (10 hours โ 1h45 for 759 files)
|
|
82
|
+
- Smart short-circuits for obvious cases
|
|
83
|
+
- Parallel execution of expensive rules
|
|
84
|
+
- File read caching
|
|
85
|
+
- Progressive analysis (2โ5 segments when needed)
|
|
86
|
+
|
|
87
|
+
### ๐ฏ Production Metrics
|
|
88
|
+
|
|
89
|
+
| Metric | Result | Status |
|
|
90
|
+
|--------|--------|--------|
|
|
91
|
+
| **Authentic Rate** | 79.2% | โ
Excellent |
|
|
92
|
+
| **Fake Detection** | 2.2% | โ
Precise |
|
|
93
|
+
| **False Positives** | < 0.5% | โ
Minimal |
|
|
94
|
+
| **Performance** | +80% | โ
Optimized |
|
|
95
|
+
|
|
96
|
+
## ๐ ๏ธ Installation
|
|
97
|
+
|
|
98
|
+
### From PyPI (Recommended)
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install flac-detective
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### From Source
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Clone the repository
|
|
108
|
+
git clone https://github.com/GuillainM/FLAC_Detective.git
|
|
109
|
+
cd FLAC_Detective
|
|
110
|
+
|
|
111
|
+
# Create virtual environment
|
|
112
|
+
python -m venv venv
|
|
113
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
114
|
+
|
|
115
|
+
# Install in development mode
|
|
116
|
+
pip install -e .
|
|
117
|
+
|
|
118
|
+
# Install development dependencies
|
|
119
|
+
pip install -e ".[dev]"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## ๐ Usage
|
|
123
|
+
|
|
124
|
+
### Command Line
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Analyze current directory
|
|
128
|
+
flac-detective .
|
|
129
|
+
|
|
130
|
+
# Analyze specific directory
|
|
131
|
+
flac-detective /path/to/music
|
|
132
|
+
|
|
133
|
+
# Generate JSON report
|
|
134
|
+
flac-detective /path/to/music --format json
|
|
135
|
+
|
|
136
|
+
# Verbose output
|
|
137
|
+
flac-detective /path/to/music --verbose
|
|
138
|
+
|
|
139
|
+
# Custom output file
|
|
140
|
+
flac-detective /path/to/music --output report.txt
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Python API
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from flac_detective.analysis.new_scoring import new_calculate_score
|
|
147
|
+
from pathlib import Path
|
|
148
|
+
|
|
149
|
+
# Analyze a file
|
|
150
|
+
filepath = Path("/path/to/file.flac")
|
|
151
|
+
score, verdict, confidence, reasons = new_calculate_score(
|
|
152
|
+
cutoff_freq=20500,
|
|
153
|
+
metadata={"sample_rate": 44100, "bit_depth": 16, "channels": 2},
|
|
154
|
+
duration_check={"duration": 180.5},
|
|
155
|
+
filepath=filepath
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
print(f"Verdict: {verdict} (Score: {score}/150)")
|
|
159
|
+
print(f"Confidence: {confidence}")
|
|
160
|
+
print(f"Reasons: {reasons}")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## ๐ Documentation
|
|
164
|
+
|
|
165
|
+
- [**Release Notes**](RELEASE_NOTES_v0.5.0.md) - What's new in v0.5.0
|
|
166
|
+
- [**Changelog**](CHANGELOG.md) - Complete version history
|
|
167
|
+
- [**Technical Documentation**](docs/TECHNICAL_DOCUMENTATION.md) - Architecture and algorithms
|
|
168
|
+
- [**Rule Specifications**](docs/RULE_SPECIFICATIONS.md) - Detailed rule documentation
|
|
169
|
+
- [**Performance Guide**](docs/PERFORMANCE_OPTIMIZATIONS.md) - Optimization strategies
|
|
170
|
+
|
|
171
|
+
## ๐๏ธ Architecture
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
src/flac_detective/
|
|
175
|
+
โโโ analysis/
|
|
176
|
+
โ โโโ new_scoring/ # Advanced scoring system (v0.5.0)
|
|
177
|
+
โ โ โโโ rules.py # All 12 detection rules
|
|
178
|
+
โ โ โโโ calculator.py # Orchestration & optimization
|
|
179
|
+
โ โ โโโ bitrate.py # Bitrate calculations
|
|
180
|
+
โ โ โโโ silence.py # Silence & vinyl analysis
|
|
181
|
+
โ โ โโโ artifacts.py # Compression artifacts
|
|
182
|
+
โ โ โโโ verdict.py # Score interpretation
|
|
183
|
+
โ โโโ spectrum.py # Spectral analysis
|
|
184
|
+
โ โโโ audio_cache.py # File read optimization
|
|
185
|
+
โโโ reporting/ # Report generation
|
|
186
|
+
โโโ main.py # CLI entry point
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## ๐งช Testing
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Run all tests
|
|
193
|
+
pytest
|
|
194
|
+
|
|
195
|
+
# Run with coverage
|
|
196
|
+
pytest --cov=flac_detective --cov-report=html
|
|
197
|
+
|
|
198
|
+
# Run specific test
|
|
199
|
+
pytest tests/test_new_scoring_rules.py -v
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Test Coverage**: ~85% overall, 100% for critical rules
|
|
203
|
+
|
|
204
|
+
## ๐ How It Works
|
|
205
|
+
|
|
206
|
+
### Detection Process
|
|
207
|
+
|
|
208
|
+
1. **Spectral Analysis**: Extract frequency spectrum and detect cutoff
|
|
209
|
+
2. **Rule 8 (First)**: Apply Nyquist protection before other rules
|
|
210
|
+
3. **Fast Rules (R1-R6)**: Quick checks for obvious cases
|
|
211
|
+
4. **Short-Circuit**: Skip expensive rules if verdict is certain
|
|
212
|
+
5. **Expensive Rules (R7, R9)**: Deep analysis when needed
|
|
213
|
+
6. **Multi-Segment (R10)**: Validate consistency across file
|
|
214
|
+
7. **Verdict**: Interpret final score with confidence level
|
|
215
|
+
|
|
216
|
+
### Protection Hierarchy
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
LEVEL 1: Absolute Protection
|
|
220
|
+
โโ R8 (95-98% Nyquist): -30 to -50 pts
|
|
221
|
+
|
|
222
|
+
LEVEL 2: Targeted MP3 320k Protection
|
|
223
|
+
โโ R1 Exception (90% Nyquist): Skip 320k detection
|
|
224
|
+
|
|
225
|
+
LEVEL 3: High Quality Protection
|
|
226
|
+
โโ R5 (High Variance): -40 pts
|
|
227
|
+
โโ R6 (High Quality): -30 pts
|
|
228
|
+
โโ R7 (Vinyl/Silence): -50 to -100 pts
|
|
229
|
+
|
|
230
|
+
LEVEL 4: Dynamic Protection
|
|
231
|
+
โโ R10 (Segment Inconsistency): -20 to -30 pts
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## ๐ฏ Use Cases
|
|
235
|
+
|
|
236
|
+
### โ
Recommended For
|
|
237
|
+
|
|
238
|
+
- **Collection Cleaning**: Remove transcoded files from your library
|
|
239
|
+
- **Quality Verification**: Validate FLAC authenticity before archiving
|
|
240
|
+
- **Batch Processing**: Analyze large music libraries efficiently
|
|
241
|
+
- **Vinyl Rip Validation**: Confirm authentic vinyl sources
|
|
242
|
+
|
|
243
|
+
### โ Not Recommended For
|
|
244
|
+
|
|
245
|
+
- **Lossy Format Analysis**: Only works with FLAC files
|
|
246
|
+
- **Real-time Processing**: Designed for batch analysis
|
|
247
|
+
- **Subjective Quality**: Detects transcodes, not audio quality
|
|
248
|
+
|
|
249
|
+
## ๐ฎ Roadmap
|
|
250
|
+
|
|
251
|
+
### v0.6 (Planned)
|
|
252
|
+
|
|
253
|
+
- [ ] GUI interface for easier usage
|
|
254
|
+
- [ ] Configurable sensitivity presets (Strict/Normal/Aggressive)
|
|
255
|
+
- [ ] Per-rule enable/disable options
|
|
256
|
+
- [ ] Custom threshold configuration
|
|
257
|
+
- [ ] HTML reports with spectrograms
|
|
258
|
+
- [ ] Automatic file organization
|
|
259
|
+
|
|
260
|
+
### Future Considerations
|
|
261
|
+
|
|
262
|
+
- Support for other lossless formats (ALAC, WAV)
|
|
263
|
+
- Machine learning integration
|
|
264
|
+
- Cloud-based analysis API
|
|
265
|
+
- Music player integration
|
|
266
|
+
|
|
267
|
+
## ๐ค Contributing
|
|
268
|
+
|
|
269
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
270
|
+
|
|
271
|
+
1. Fork the repository
|
|
272
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
273
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
274
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
275
|
+
5. Open a Pull Request
|
|
276
|
+
|
|
277
|
+
## ๐ License
|
|
278
|
+
|
|
279
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
280
|
+
|
|
281
|
+
## ๐ Acknowledgments
|
|
282
|
+
|
|
283
|
+
- Audio analysis community for research on MP3 compression
|
|
284
|
+
- Contributors to NumPy, SciPy, and Soundfile libraries
|
|
285
|
+
- Beta testers who provided valuable feedback
|
|
286
|
+
|
|
287
|
+
## ๐ Support
|
|
288
|
+
|
|
289
|
+
- **Issues**: [GitHub Issues](https://github.com/GuillainM/FLAC_Detective/issues)
|
|
290
|
+
- **Discussions**: [GitHub Discussions](https://github.com/GuillainM/FLAC_Detective/discussions)
|
|
291
|
+
- **Documentation**: [Wiki](https://github.com/GuillainM/FLAC_Detective/wiki)
|
|
292
|
+
|
|
293
|
+
## ๐ Project Stats
|
|
294
|
+
|
|
295
|
+
- **Version**: 0.5.0 (Production Ready)
|
|
296
|
+
- **Status**: Beta
|
|
297
|
+
- **Python**: 3.8+
|
|
298
|
+
- **License**: MIT
|
|
299
|
+
- **Tested**: 759 files, 79.2% authentic rate
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
**Made with โค๏ธ for audio enthusiasts**
|
|
304
|
+
|
|
305
|
+
**FLAC Detective v0.5.0** - *Because your music deserves authenticity*
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# ๐ต FLAC Detective
|
|
2
|
+
|
|
3
|
+
**Advanced FLAC Authenticity Analyzer - Production Ready v0.5.0**
|
|
4
|
+
|
|
5
|
+
> "Every FLAC file tells a story... I find the truth."
|
|
6
|
+
|
|
7
|
+
FLAC Detective is a professional-grade tool for detecting MP3-to-FLAC transcodes with exceptional precision. Using advanced spectral analysis and multi-rule scoring, it achieves 79.2% authentic detection rate with less than 0.5% false positives.
|
|
8
|
+
|
|
9
|
+
[](https://www.python.org/downloads/)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://github.com/GuillainM/FLAC_Detective)
|
|
12
|
+
|
|
13
|
+
## โจ Features
|
|
14
|
+
|
|
15
|
+
### ๐ฏ Advanced 12-Rule Detection System
|
|
16
|
+
|
|
17
|
+
- **Rule 1**: MP3 Spectral Signature Detection (CBR patterns)
|
|
18
|
+
- **Rule 2**: Cutoff Frequency Analysis vs Nyquist
|
|
19
|
+
- **Rule 3**: Source vs Container Bitrate Comparison
|
|
20
|
+
- **Rule 4**: Suspicious 24-bit File Detection
|
|
21
|
+
- **Rule 5**: High Variance Protection (VBR)
|
|
22
|
+
- **Rule 6**: High Quality Protection
|
|
23
|
+
- **Rule 7**: Silence & Vinyl Analysis (3 phases)
|
|
24
|
+
- Phase 1: Dither detection
|
|
25
|
+
- Phase 2: Vinyl surface noise
|
|
26
|
+
- Phase 3: Clicks & pops
|
|
27
|
+
- **Rule 8**: Nyquist Exception (95% & 90% thresholds)
|
|
28
|
+
- **Rule 9**: Compression Artifacts Detection
|
|
29
|
+
- Test A: Pre-echo (MDCT ghosting)
|
|
30
|
+
- Test B: High-frequency aliasing
|
|
31
|
+
- Test C: MP3 quantization noise
|
|
32
|
+
- **Rule 10**: Multi-Segment Consistency Analysis
|
|
33
|
+
|
|
34
|
+
### ๐ 4-Level Verdict System
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
Score โฅ 86 โ FAKE_CERTAIN โ (100% confidence)
|
|
38
|
+
Score 61-85 โ SUSPICIOUS โ ๏ธ (High confidence)
|
|
39
|
+
Score 31-60 โ WARNING โก (Manual review recommended)
|
|
40
|
+
Score โค 30 โ AUTHENTIC โ
(99.5% confidence)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### โก Performance Optimizations
|
|
44
|
+
|
|
45
|
+
- **80% faster** than baseline (10 hours โ 1h45 for 759 files)
|
|
46
|
+
- Smart short-circuits for obvious cases
|
|
47
|
+
- Parallel execution of expensive rules
|
|
48
|
+
- File read caching
|
|
49
|
+
- Progressive analysis (2โ5 segments when needed)
|
|
50
|
+
|
|
51
|
+
### ๐ฏ Production Metrics
|
|
52
|
+
|
|
53
|
+
| Metric | Result | Status |
|
|
54
|
+
|--------|--------|--------|
|
|
55
|
+
| **Authentic Rate** | 79.2% | โ
Excellent |
|
|
56
|
+
| **Fake Detection** | 2.2% | โ
Precise |
|
|
57
|
+
| **False Positives** | < 0.5% | โ
Minimal |
|
|
58
|
+
| **Performance** | +80% | โ
Optimized |
|
|
59
|
+
|
|
60
|
+
## ๐ ๏ธ Installation
|
|
61
|
+
|
|
62
|
+
### From PyPI (Recommended)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install flac-detective
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### From Source
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Clone the repository
|
|
72
|
+
git clone https://github.com/GuillainM/FLAC_Detective.git
|
|
73
|
+
cd FLAC_Detective
|
|
74
|
+
|
|
75
|
+
# Create virtual environment
|
|
76
|
+
python -m venv venv
|
|
77
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
78
|
+
|
|
79
|
+
# Install in development mode
|
|
80
|
+
pip install -e .
|
|
81
|
+
|
|
82
|
+
# Install development dependencies
|
|
83
|
+
pip install -e ".[dev]"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## ๐ Usage
|
|
87
|
+
|
|
88
|
+
### Command Line
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Analyze current directory
|
|
92
|
+
flac-detective .
|
|
93
|
+
|
|
94
|
+
# Analyze specific directory
|
|
95
|
+
flac-detective /path/to/music
|
|
96
|
+
|
|
97
|
+
# Generate JSON report
|
|
98
|
+
flac-detective /path/to/music --format json
|
|
99
|
+
|
|
100
|
+
# Verbose output
|
|
101
|
+
flac-detective /path/to/music --verbose
|
|
102
|
+
|
|
103
|
+
# Custom output file
|
|
104
|
+
flac-detective /path/to/music --output report.txt
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Python API
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from flac_detective.analysis.new_scoring import new_calculate_score
|
|
111
|
+
from pathlib import Path
|
|
112
|
+
|
|
113
|
+
# Analyze a file
|
|
114
|
+
filepath = Path("/path/to/file.flac")
|
|
115
|
+
score, verdict, confidence, reasons = new_calculate_score(
|
|
116
|
+
cutoff_freq=20500,
|
|
117
|
+
metadata={"sample_rate": 44100, "bit_depth": 16, "channels": 2},
|
|
118
|
+
duration_check={"duration": 180.5},
|
|
119
|
+
filepath=filepath
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
print(f"Verdict: {verdict} (Score: {score}/150)")
|
|
123
|
+
print(f"Confidence: {confidence}")
|
|
124
|
+
print(f"Reasons: {reasons}")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## ๐ Documentation
|
|
128
|
+
|
|
129
|
+
- [**Release Notes**](RELEASE_NOTES_v0.5.0.md) - What's new in v0.5.0
|
|
130
|
+
- [**Changelog**](CHANGELOG.md) - Complete version history
|
|
131
|
+
- [**Technical Documentation**](docs/TECHNICAL_DOCUMENTATION.md) - Architecture and algorithms
|
|
132
|
+
- [**Rule Specifications**](docs/RULE_SPECIFICATIONS.md) - Detailed rule documentation
|
|
133
|
+
- [**Performance Guide**](docs/PERFORMANCE_OPTIMIZATIONS.md) - Optimization strategies
|
|
134
|
+
|
|
135
|
+
## ๐๏ธ Architecture
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
src/flac_detective/
|
|
139
|
+
โโโ analysis/
|
|
140
|
+
โ โโโ new_scoring/ # Advanced scoring system (v0.5.0)
|
|
141
|
+
โ โ โโโ rules.py # All 12 detection rules
|
|
142
|
+
โ โ โโโ calculator.py # Orchestration & optimization
|
|
143
|
+
โ โ โโโ bitrate.py # Bitrate calculations
|
|
144
|
+
โ โ โโโ silence.py # Silence & vinyl analysis
|
|
145
|
+
โ โ โโโ artifacts.py # Compression artifacts
|
|
146
|
+
โ โ โโโ verdict.py # Score interpretation
|
|
147
|
+
โ โโโ spectrum.py # Spectral analysis
|
|
148
|
+
โ โโโ audio_cache.py # File read optimization
|
|
149
|
+
โโโ reporting/ # Report generation
|
|
150
|
+
โโโ main.py # CLI entry point
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## ๐งช Testing
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Run all tests
|
|
157
|
+
pytest
|
|
158
|
+
|
|
159
|
+
# Run with coverage
|
|
160
|
+
pytest --cov=flac_detective --cov-report=html
|
|
161
|
+
|
|
162
|
+
# Run specific test
|
|
163
|
+
pytest tests/test_new_scoring_rules.py -v
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Test Coverage**: ~85% overall, 100% for critical rules
|
|
167
|
+
|
|
168
|
+
## ๐ How It Works
|
|
169
|
+
|
|
170
|
+
### Detection Process
|
|
171
|
+
|
|
172
|
+
1. **Spectral Analysis**: Extract frequency spectrum and detect cutoff
|
|
173
|
+
2. **Rule 8 (First)**: Apply Nyquist protection before other rules
|
|
174
|
+
3. **Fast Rules (R1-R6)**: Quick checks for obvious cases
|
|
175
|
+
4. **Short-Circuit**: Skip expensive rules if verdict is certain
|
|
176
|
+
5. **Expensive Rules (R7, R9)**: Deep analysis when needed
|
|
177
|
+
6. **Multi-Segment (R10)**: Validate consistency across file
|
|
178
|
+
7. **Verdict**: Interpret final score with confidence level
|
|
179
|
+
|
|
180
|
+
### Protection Hierarchy
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
LEVEL 1: Absolute Protection
|
|
184
|
+
โโ R8 (95-98% Nyquist): -30 to -50 pts
|
|
185
|
+
|
|
186
|
+
LEVEL 2: Targeted MP3 320k Protection
|
|
187
|
+
โโ R1 Exception (90% Nyquist): Skip 320k detection
|
|
188
|
+
|
|
189
|
+
LEVEL 3: High Quality Protection
|
|
190
|
+
โโ R5 (High Variance): -40 pts
|
|
191
|
+
โโ R6 (High Quality): -30 pts
|
|
192
|
+
โโ R7 (Vinyl/Silence): -50 to -100 pts
|
|
193
|
+
|
|
194
|
+
LEVEL 4: Dynamic Protection
|
|
195
|
+
โโ R10 (Segment Inconsistency): -20 to -30 pts
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## ๐ฏ Use Cases
|
|
199
|
+
|
|
200
|
+
### โ
Recommended For
|
|
201
|
+
|
|
202
|
+
- **Collection Cleaning**: Remove transcoded files from your library
|
|
203
|
+
- **Quality Verification**: Validate FLAC authenticity before archiving
|
|
204
|
+
- **Batch Processing**: Analyze large music libraries efficiently
|
|
205
|
+
- **Vinyl Rip Validation**: Confirm authentic vinyl sources
|
|
206
|
+
|
|
207
|
+
### โ Not Recommended For
|
|
208
|
+
|
|
209
|
+
- **Lossy Format Analysis**: Only works with FLAC files
|
|
210
|
+
- **Real-time Processing**: Designed for batch analysis
|
|
211
|
+
- **Subjective Quality**: Detects transcodes, not audio quality
|
|
212
|
+
|
|
213
|
+
## ๐ฎ Roadmap
|
|
214
|
+
|
|
215
|
+
### v0.6 (Planned)
|
|
216
|
+
|
|
217
|
+
- [ ] GUI interface for easier usage
|
|
218
|
+
- [ ] Configurable sensitivity presets (Strict/Normal/Aggressive)
|
|
219
|
+
- [ ] Per-rule enable/disable options
|
|
220
|
+
- [ ] Custom threshold configuration
|
|
221
|
+
- [ ] HTML reports with spectrograms
|
|
222
|
+
- [ ] Automatic file organization
|
|
223
|
+
|
|
224
|
+
### Future Considerations
|
|
225
|
+
|
|
226
|
+
- Support for other lossless formats (ALAC, WAV)
|
|
227
|
+
- Machine learning integration
|
|
228
|
+
- Cloud-based analysis API
|
|
229
|
+
- Music player integration
|
|
230
|
+
|
|
231
|
+
## ๐ค Contributing
|
|
232
|
+
|
|
233
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
234
|
+
|
|
235
|
+
1. Fork the repository
|
|
236
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
237
|
+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
|
238
|
+
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
|
239
|
+
5. Open a Pull Request
|
|
240
|
+
|
|
241
|
+
## ๐ License
|
|
242
|
+
|
|
243
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
244
|
+
|
|
245
|
+
## ๐ Acknowledgments
|
|
246
|
+
|
|
247
|
+
- Audio analysis community for research on MP3 compression
|
|
248
|
+
- Contributors to NumPy, SciPy, and Soundfile libraries
|
|
249
|
+
- Beta testers who provided valuable feedback
|
|
250
|
+
|
|
251
|
+
## ๐ Support
|
|
252
|
+
|
|
253
|
+
- **Issues**: [GitHub Issues](https://github.com/GuillainM/FLAC_Detective/issues)
|
|
254
|
+
- **Discussions**: [GitHub Discussions](https://github.com/GuillainM/FLAC_Detective/discussions)
|
|
255
|
+
- **Documentation**: [Wiki](https://github.com/GuillainM/FLAC_Detective/wiki)
|
|
256
|
+
|
|
257
|
+
## ๐ Project Stats
|
|
258
|
+
|
|
259
|
+
- **Version**: 0.5.0 (Production Ready)
|
|
260
|
+
- **Status**: Beta
|
|
261
|
+
- **Python**: 3.8+
|
|
262
|
+
- **License**: MIT
|
|
263
|
+
- **Tested**: 759 files, 79.2% authentic rate
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
**Made with โค๏ธ for audio enthusiasts**
|
|
268
|
+
|
|
269
|
+
**FLAC Detective v0.5.0** - *Because your music deserves authenticity*
|