spectralaudit 0.1.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.
Files changed (42) hide show
  1. spectralaudit-0.1.0/CHANGELOG.md +12 -0
  2. spectralaudit-0.1.0/CITATION.cff +23 -0
  3. spectralaudit-0.1.0/CITING.md +31 -0
  4. spectralaudit-0.1.0/CONTRIBUTING.md +9 -0
  5. spectralaudit-0.1.0/LICENSE +202 -0
  6. spectralaudit-0.1.0/MANIFEST.in +3 -0
  7. spectralaudit-0.1.0/NOTICE +12 -0
  8. spectralaudit-0.1.0/PKG-INFO +115 -0
  9. spectralaudit-0.1.0/README.md +79 -0
  10. spectralaudit-0.1.0/REFERENCES.md +35 -0
  11. spectralaudit-0.1.0/docs/algorithms.md +57 -0
  12. spectralaudit-0.1.0/docs/installation.md +18 -0
  13. spectralaudit-0.1.0/docs/limitations.md +22 -0
  14. spectralaudit-0.1.0/docs/mastering-comparison.md +12 -0
  15. spectralaudit-0.1.0/docs/pypi-release.md +80 -0
  16. spectralaudit-0.1.0/docs/quickstart.md +27 -0
  17. spectralaudit-0.1.0/docs/scientific-background.md +14 -0
  18. spectralaudit-0.1.0/docs/validation.md +21 -0
  19. spectralaudit-0.1.0/examples/synthetic_demo.py +21 -0
  20. spectralaudit-0.1.0/pyproject.toml +49 -0
  21. spectralaudit-0.1.0/setup.cfg +4 -0
  22. spectralaudit-0.1.0/src/spectralaudit/__init__.py +44 -0
  23. spectralaudit-0.1.0/src/spectralaudit/__main__.py +3 -0
  24. spectralaudit-0.1.0/src/spectralaudit/audio.py +51 -0
  25. spectralaudit-0.1.0/src/spectralaudit/cli.py +73 -0
  26. spectralaudit-0.1.0/src/spectralaudit/comb.py +53 -0
  27. spectralaudit-0.1.0/src/spectralaudit/confounders.py +24 -0
  28. spectralaudit-0.1.0/src/spectralaudit/mastering.py +105 -0
  29. spectralaudit-0.1.0/src/spectralaudit/models.py +92 -0
  30. spectralaudit-0.1.0/src/spectralaudit/plotting.py +38 -0
  31. spectralaudit-0.1.0/src/spectralaudit/spectrum.py +79 -0
  32. spectralaudit-0.1.0/src/spectralaudit/temporal.py +34 -0
  33. spectralaudit-0.1.0/src/spectralaudit.egg-info/PKG-INFO +115 -0
  34. spectralaudit-0.1.0/src/spectralaudit.egg-info/SOURCES.txt +40 -0
  35. spectralaudit-0.1.0/src/spectralaudit.egg-info/dependency_links.txt +1 -0
  36. spectralaudit-0.1.0/src/spectralaudit.egg-info/entry_points.txt +2 -0
  37. spectralaudit-0.1.0/src/spectralaudit.egg-info/requires.txt +13 -0
  38. spectralaudit-0.1.0/src/spectralaudit.egg-info/top_level.txt +1 -0
  39. spectralaudit-0.1.0/tests/test_cli.py +26 -0
  40. spectralaudit-0.1.0/tests/test_mastering.py +25 -0
  41. spectralaudit-0.1.0/tests/test_plotting.py +12 -0
  42. spectralaudit-0.1.0/tests/test_spectral.py +79 -0
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] - 2026-10-13
4
+
5
+ Initial implementation of offline spectral diagnostics: WAV/FLAC ingestion,
6
+ Welch PSD and Nyquist-aware frequency bands, candidate cutoff heuristic,
7
+ periodic spectral peak heuristic, temporal summaries, conventional confounder
8
+ flags, premaster/master comparison, JSON/HTML export, CLI, tests, and packaging.
9
+
10
+ No validated AI-origin classification is offered.
11
+
12
+ Initial public release: clarified README and research citation, fixed missing-directory batch input handling, and added release tag/version checks and tests to the publishing workflow.
@@ -0,0 +1,23 @@
1
+ cff-version: 1.2.0
2
+ message: >-
3
+ If you use SpectralAudit in scientific research, academic publications,
4
+ datasets, benchmarks, or technical reports, please cite Eduardo J. Barrios
5
+ using the citation provided by this file and identify the software version.
6
+ type: software
7
+ title: 'SpectralAudit: Explainable Spectral Forensics for Music and Mastered Audio'
8
+ authors:
9
+ - family-names: Barrios
10
+ given-names: Eduardo J.
11
+ version: 0.1.0
12
+ license: Apache-2.0
13
+ repository-code: https://github.com/edujbarrios/spectralaudit
14
+ url: https://github.com/edujbarrios/spectralaudit
15
+ keywords:
16
+ - music information retrieval
17
+ - digital signal processing
18
+ - audio forensics
19
+ - synthetic music artifacts
20
+ - mastering
21
+ abstract: >-
22
+ Open-source Python software for offline, reproducible spectral measurements,
23
+ heuristic periodicity analysis, and comparative audio mastering diagnostics.
@@ -0,0 +1,31 @@
1
+ # Cite SpectralAudit in research
2
+
3
+ If this software is used in a paper, dissertation, benchmark, or other scholarly
4
+ output, **please cite the software and credit its author, Eduardo J. Barrios**.
5
+ GitHub displays a **Cite this repository** control from the root `CITATION.cff`.
6
+
7
+ Suggested reference (adapt year and version to the *actually used release*):
8
+
9
+ > Barrios, E. J. (2026). *SpectralAudit: Explainable Spectral Forensics for Music and
10
+ > Mastered Audio* (Version 0.1.0) [Computer software].
11
+ > https://github.com/edujbarrios/spectralaudit
12
+
13
+ Suggested BibTeX:
14
+
15
+ ```bibtex
16
+ @software{barrios_spectralaudit_2026,
17
+ author = {Barrios, Eduardo J.},
18
+ title = {SpectralAudit: Explainable Spectral Forensics for Music and Mastered Audio},
19
+ year = {2026},
20
+ version = {0.1.0},
21
+ url = {https://github.com/edujbarrios/spectralaudit}
22
+ }
23
+ ```
24
+
25
+ The Apache-2.0 license *requires preservation of applicable notices on redistribution*;
26
+ it does **not** legally compel every research publication to cite the software. This
27
+ citation is an academic request and a responsible scholarly practice, not an extra
28
+ restrictive licensing term. Do not claim otherwise.
29
+
30
+ A citable archived DOI can be added after the first release via Zenodo's GitHub
31
+ integration, if the author chooses to enable it. Do not invent a DOI.
@@ -0,0 +1,9 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome. Open an issue before substantial design changes.
4
+ Install `python -m pip install -e '.[dev]'`, then run `pytest -q` and `ruff check .`.
5
+
6
+ Add numerical tests for each DSP change and provide references for new methods.
7
+ Do not copy code from projects with incompatible/non-commercial licenses.
8
+ Include SPDX-consistent copyright/attribution notices when appropriate.
9
+ All submitted changes are offered under the repository's Apache-2.0 license.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include LICENSE NOTICE CITATION.cff CITING.md REFERENCES.md CHANGELOG.md CONTRIBUTING.md
2
+ recursive-include docs *.md
3
+ recursive-include examples *.py
@@ -0,0 +1,12 @@
1
+ SpectralAudit
2
+ Copyright 2026 Eduardo J. Barrios
3
+ https://github.com/edujbarrios/spectralaudit
4
+
5
+ Licensed under the Apache License, Version 2.0. See LICENSE.
6
+ When distributing the software or derivative distributions, retain the
7
+ applicable copyright, attribution, and NOTICE material as required by the license.
8
+
9
+ Academic citation request (not an additional license restriction):
10
+ If SpectralAudit informs a research paper, thesis, dataset, or scientific report,
11
+ please cite Eduardo J. Barrios and identify the used software version as described
12
+ in CITATION.cff and CITING.md.
@@ -0,0 +1,115 @@
1
+ Metadata-Version: 2.4
2
+ Name: spectralaudit
3
+ Version: 0.1.0
4
+ Summary: Explainable, offline DSP for spectral audio forensics and mastering comparisons
5
+ Author: Eduardo J. Barrios
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/edujbarrios/spectralaudit
8
+ Project-URL: Source, https://github.com/edujbarrios/spectralaudit
9
+ Project-URL: Issues, https://github.com/edujbarrios/spectralaudit/issues
10
+ Keywords: audio,music,spectral-analysis,forensics,dsp,mastering
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
14
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Operating System :: OS Independent
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: NOTICE
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: scipy>=1.11
26
+ Requires-Dist: soundfile>=0.12
27
+ Provides-Extra: plot
28
+ Requires-Dist: matplotlib>=3.8; extra == "plot"
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=8; extra == "dev"
31
+ Requires-Dist: ruff>=0.6; extra == "dev"
32
+ Requires-Dist: build>=1.2; extra == "dev"
33
+ Requires-Dist: twine>=5; extra == "dev"
34
+ Requires-Dist: cffconvert>=2.0; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # SpectralAudit
38
+
39
+ **Offline spectral analysis for music and final masters.** A Python library by **Eduardo J. Barrios**.
40
+
41
+ [![CI](https://github.com/edujbarrios/spectralaudit/actions/workflows/ci.yml/badge.svg)](https://github.com/edujbarrios/spectralaudit/actions/workflows/ci.yml)
42
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
43
+
44
+ SpectralAudit measures **high-frequency energy, spectral cutoffs and regularly spaced spectral peaks** in WAV/FLAC audio. It also compares a premaster and final master to reveal measurable differences between versions. Processing runs **locally** with NumPy and SciPy: no LLMs, AI models or external APIs.
45
+
46
+ **Important:** SpectralAudit is **not a validated detector of AI-generated music**. Frequencies above 17 kHz, low-pass cutoffs and periodic peaks do **not** prove AI origin. Results are measurements with stated limitations.
47
+
48
+ ## Install
49
+
50
+ Requires Python 3.11+.
51
+
52
+ ```bash
53
+ pip install spectralaudit
54
+ ```
55
+
56
+ Before the first PyPI release, install from the repository:
57
+
58
+ ```bash
59
+ pip install git+https://github.com/edujbarrios/spectralaudit.git
60
+ ```
61
+
62
+ ## Quick start
63
+
64
+ Analyze a master and export an HTML and JSON report:
65
+
66
+ ```bash
67
+ spectralaudit analyze final_master.wav --html report.html --json report.json
68
+ ```
69
+
70
+ Inspect frequency bands, compare two versions, or analyze a folder:
71
+
72
+ ```bash
73
+ spectralaudit spectrum final_master.wav
74
+ spectralaudit compare premaster.wav final_master.wav --html comparison.html
75
+ spectralaudit batch ./music --json batch.json
76
+ ```
77
+
78
+ Python API:
79
+
80
+ ```python
81
+ from spectralaudit import analyze, compare_masters
82
+
83
+ report = analyze("final_master.wav")
84
+ print(report.findings["high_frequency"]["candidate_cutoff"])
85
+ print(report.findings["spectral_comb"]["candidate_periodicity"])
86
+ print(report.interpretation) # Origin inconclusive: ...
87
+ report.to_html("report.html")
88
+
89
+ comparison = compare_masters("premaster.wav", "final_master.wav")
90
+ print(comparison.spectral_changes)
91
+ ```
92
+
93
+ ## What it measures
94
+
95
+ - **Frequency bands:** Welch power spectrum, relative band energy and candidate high-frequency cutoff, respecting the file's Nyquist limit.
96
+ - **Periodic peaks:** spacing of narrow spectral peaks; also possible in conventional harmonic music.
97
+ - **Time:** persistence of candidate patterns in successive audio windows.
98
+ - **Alternative explanations:** flags for sample-rate and processing-related ambiguities.
99
+ - **Master comparison:** estimated time offset, gain and band-level spectral differences.
100
+
101
+ The same inputs and settings produce deterministic analyses. Detection thresholds are **exploratory heuristics**, not calibrated AI-origin probabilities. Large files are read into memory; input audio is never modified. See [Methods](docs/algorithms.md) and [Limitations](docs/limitations.md).
102
+
103
+ ## Research, citation and license
104
+
105
+ If you use SpectralAudit in research, **please cite Eduardo J. Barrios and the version used**. See [CITATION.cff](CITATION.cff) and [how to cite](CITING.md).
106
+
107
+ Selected scientific references:
108
+
109
+ - Afchar et al. (2025), *A Fourier Explanation of AI-music Artifacts* ([paper](https://arxiv.org/abs/2506.19108)).
110
+ - Cros Vila et al. (2025), *The AI Music Arms Race* ([DOI](https://doi.org/10.5334/tismir.254)).
111
+ - Welch (1967), *The Use of Fast Fourier Transform for the Estimation of Power Spectra* ([DOI](https://doi.org/10.1109/TAU.1967.1161901)).
112
+
113
+ Full bibliography and implementation distinctions: [REFERENCES.md](REFERENCES.md).
114
+
115
+ **Copyright © 2026 Eduardo J. Barrios.** Open source under the [Apache License 2.0](LICENSE); see [NOTICE](NOTICE). Redistribution must preserve applicable notices. Academic citation is requested, not an additional legal condition of the license.
@@ -0,0 +1,79 @@
1
+ # SpectralAudit
2
+
3
+ **Offline spectral analysis for music and final masters.** A Python library by **Eduardo J. Barrios**.
4
+
5
+ [![CI](https://github.com/edujbarrios/spectralaudit/actions/workflows/ci.yml/badge.svg)](https://github.com/edujbarrios/spectralaudit/actions/workflows/ci.yml)
6
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
7
+
8
+ SpectralAudit measures **high-frequency energy, spectral cutoffs and regularly spaced spectral peaks** in WAV/FLAC audio. It also compares a premaster and final master to reveal measurable differences between versions. Processing runs **locally** with NumPy and SciPy: no LLMs, AI models or external APIs.
9
+
10
+ **Important:** SpectralAudit is **not a validated detector of AI-generated music**. Frequencies above 17 kHz, low-pass cutoffs and periodic peaks do **not** prove AI origin. Results are measurements with stated limitations.
11
+
12
+ ## Install
13
+
14
+ Requires Python 3.11+.
15
+
16
+ ```bash
17
+ pip install spectralaudit
18
+ ```
19
+
20
+ Before the first PyPI release, install from the repository:
21
+
22
+ ```bash
23
+ pip install git+https://github.com/edujbarrios/spectralaudit.git
24
+ ```
25
+
26
+ ## Quick start
27
+
28
+ Analyze a master and export an HTML and JSON report:
29
+
30
+ ```bash
31
+ spectralaudit analyze final_master.wav --html report.html --json report.json
32
+ ```
33
+
34
+ Inspect frequency bands, compare two versions, or analyze a folder:
35
+
36
+ ```bash
37
+ spectralaudit spectrum final_master.wav
38
+ spectralaudit compare premaster.wav final_master.wav --html comparison.html
39
+ spectralaudit batch ./music --json batch.json
40
+ ```
41
+
42
+ Python API:
43
+
44
+ ```python
45
+ from spectralaudit import analyze, compare_masters
46
+
47
+ report = analyze("final_master.wav")
48
+ print(report.findings["high_frequency"]["candidate_cutoff"])
49
+ print(report.findings["spectral_comb"]["candidate_periodicity"])
50
+ print(report.interpretation) # Origin inconclusive: ...
51
+ report.to_html("report.html")
52
+
53
+ comparison = compare_masters("premaster.wav", "final_master.wav")
54
+ print(comparison.spectral_changes)
55
+ ```
56
+
57
+ ## What it measures
58
+
59
+ - **Frequency bands:** Welch power spectrum, relative band energy and candidate high-frequency cutoff, respecting the file's Nyquist limit.
60
+ - **Periodic peaks:** spacing of narrow spectral peaks; also possible in conventional harmonic music.
61
+ - **Time:** persistence of candidate patterns in successive audio windows.
62
+ - **Alternative explanations:** flags for sample-rate and processing-related ambiguities.
63
+ - **Master comparison:** estimated time offset, gain and band-level spectral differences.
64
+
65
+ The same inputs and settings produce deterministic analyses. Detection thresholds are **exploratory heuristics**, not calibrated AI-origin probabilities. Large files are read into memory; input audio is never modified. See [Methods](docs/algorithms.md) and [Limitations](docs/limitations.md).
66
+
67
+ ## Research, citation and license
68
+
69
+ If you use SpectralAudit in research, **please cite Eduardo J. Barrios and the version used**. See [CITATION.cff](CITATION.cff) and [how to cite](CITING.md).
70
+
71
+ Selected scientific references:
72
+
73
+ - Afchar et al. (2025), *A Fourier Explanation of AI-music Artifacts* ([paper](https://arxiv.org/abs/2506.19108)).
74
+ - Cros Vila et al. (2025), *The AI Music Arms Race* ([DOI](https://doi.org/10.5334/tismir.254)).
75
+ - Welch (1967), *The Use of Fast Fourier Transform for the Estimation of Power Spectra* ([DOI](https://doi.org/10.1109/TAU.1967.1161901)).
76
+
77
+ Full bibliography and implementation distinctions: [REFERENCES.md](REFERENCES.md).
78
+
79
+ **Copyright © 2026 Eduardo J. Barrios.** Open source under the [Apache License 2.0](LICENSE); see [NOTICE](NOTICE). Redistribution must preserve applicable notices. Academic citation is requested, not an additional legal condition of the license.
@@ -0,0 +1,35 @@
1
+ # Scientific references and implementation boundaries
2
+
3
+ The algorithms in SpectralAudit are original Python implementations of conventional
4
+ DSP ideas. A detected artifact is not proof of AI generation. No code or weights
5
+ are taken from the Deezer research implementation.
6
+
7
+ 1. Afchar, D., Meseguer-Brocal, G., Akesbi, K., & Hennequin, R. (2025).
8
+ **A Fourier Explanation of AI-music Artifacts**. Proceedings of the 26th
9
+ International Society for Music Information Retrieval Conference, 739–746.
10
+ https://doi.org/10.5281/zenodo.17811475 . Motivates investigating periodic
11
+ spectral structure, but the present heuristic is not their published detector.
12
+ 2. Cros Vila, L., Sturm, B. L. T., Casini, L., & Dalmazzo, D. (2025).
13
+ **The AI Music Arms Race: On the Detection of AI-Generated Music**.
14
+ *Transactions of the International Society for Music Information Retrieval*, 8(1).
15
+ https://doi.org/10.5334/tismir.254 . Motivates explicit confounders and
16
+ robustness warnings.
17
+ 3. Welch, P. D. (1967). **The Use of Fast Fourier Transform for the Estimation
18
+ of Power Spectra: A Method Based on Time Averaging Over Short, Modified
19
+ Periodograms**. *IEEE Transactions on Audio and Electroacoustics*, 15(2),
20
+ 70–73. https://doi.org/10.1109/TAU.1967.1161901 . Basis of Welch PSD.
21
+ 4. Harris, F. J. (1978). **On the use of windows for harmonic analysis with the
22
+ discrete Fourier transform**. *Proceedings of the IEEE*, 66(1), 51–83.
23
+ https://doi.org/10.1109/PROC.1978.10837 . Basis for Hann windowing.
24
+
25
+ ## Licensing / research provenance
26
+
27
+ Deezer's publication-related repository is CC BY-NC 4.0 and reports patent
28
+ applications: https://github.com/deezer/ismir25-ai-music-detector . We have
29
+ not copied its implementation. Independent implementation does not automatically
30
+ resolve patent concerns; obtain professional review before relying on this
31
+ software commercially for provenance detection.
32
+
33
+ The peak detection and cutoff estimation included here are exploratory
34
+ measurements without empirical provenance calibration. They must not be reported
35
+ as reproducing the published detection rates.
@@ -0,0 +1,57 @@
1
+ # Numerical algorithms (v0.1.0)
2
+
3
+ These are reproducible **measurements**, not AI-origin classifications.
4
+
5
+ ## Welch PSD and band energy
6
+
7
+ For real-valued waveform samples, Welch PSD uses Hann-windowed modified
8
+ periodograms averaged over overlapping windows (`scipy.signal.welch`). PSD
9
+ units are amplitude-squared per Hz. Band energy is approximated by trapezoid
10
+ integration, and relative band power is normalized by the full-band integral.
11
+
12
+ A band is **unavailable** when its upper boundary exceeds the Nyquist
13
+ frequency; unavailable is not a zero-valued observation. If there is no signal
14
+ power, relative band fractions are `null`.
15
+
16
+ ## Spectral cutoff heuristic
17
+
18
+ We divide the log-PSD above 3 kHz into 150 Hz bins, take the median of each bin,
19
+ apply a 5-bin median filter, and compute the frequency derivative in dB/kHz.
20
+ The steepest negative derivative is a *candidate* knee only when it is below
21
+ -35 dB/kHz, an **uncalibrated heuristic**. Test frequencies, averaging, bins,
22
+ and signal content strongly affect this value. It is not a codec or origin detector.
23
+
24
+ ## Periodic peak heuristic
25
+
26
+ We estimate the spectral envelope by Gaussian smoothing the log-PSD (smoothing
27
+ scale ~180 Hz). Narrow peaks in the residual are found using prominence and
28
+ frequency-separation thresholds. For consecutive peak spacings `d_i`, the
29
+ reported central spacing is `median(d_i)` and irregularity is
30
+ `median(|d_i - median(d_i)|) / median(d_i)`.
31
+
32
+ `candidate_periodicity=True` requires at least five peaks and an irregularity
33
+ below 0.20. This flag is **not** a published synthetic-music detection method:
34
+ ordinary harmonic music, oscillators, and other tonal signals can produce a
35
+ similar effect. Peak spacing may be poorly estimated when intermediate peaks
36
+ are absent. Treat it as an exploratory diagnostic only.
37
+
38
+ ## Temporal summary
39
+
40
+ Nonoverlapping 5-second windows (up to 48 uniformly spaced representatives)
41
+ measure candidate cutoff and peak-spacing flags. Persistence is the fraction
42
+ of analyzed windows flagged, not evidence of AI provenance.
43
+
44
+ ## Mastering comparison
45
+
46
+ A mono short excerpt is decimated and cross-correlated to estimate a sample
47
+ offset between source and processed audio. Longer signals are then trimmed to
48
+ their overlapping region. Gain is estimated as `dot(x,y)/dot(x,x)`; residual
49
+ RMS is measured after removing that linear gain. Welch PSD band ratios describe
50
+ spectral changes. Large edits, pitch shifts, compression and stereo changes
51
+ may defeat linear alignment, so results must be independently verified.
52
+
53
+ ## References
54
+
55
+ See [REFERENCES.md](../REFERENCES.md) for sources, attribution and the Deezer
56
+ code licensing notice. All DSP implementations are independent; the project
57
+ makes no claim to reproduce a published classifier or its accuracy.
@@ -0,0 +1,18 @@
1
+ # Installation
2
+
3
+ Requirements: Python 3.11+, NumPy, SciPy, and SoundFile. No LLM or GPU needed.
4
+
5
+ ```bash
6
+ python -m venv .venv
7
+ source .venv/bin/activate
8
+ python -m pip install -U pip
9
+ python -m pip install -e '.[dev]'
10
+ python -m pytest -q
11
+ spectralaudit --help
12
+ ```
13
+
14
+ Windows PowerShell activation: `.venv\Scripts\Activate.ps1`.
15
+
16
+ After a confirmed PyPI publication, use `python -m pip install spectralaudit`.
17
+ Audio support relies on the libsndfile build supplied by your SoundFile
18
+ installation; WAV/FLAC availability may vary by platform.
@@ -0,0 +1,22 @@
1
+ # Scope, interpretation and limitations
2
+
3
+ **No binary detection or model-based AI attribution is implemented.** The
4
+ program is an offline DSP measurement tool. Use `report.interpretation` rather
5
+ than inferring AI-origin probabilities from heuristic findings.
6
+
7
+ - A spectral cutoff at 17 kHz has many non-generative explanations.
8
+ - Repeated peaks can originate from harmonically rich instruments or synthesis.
9
+ - In a 32 kHz file, frequencies above 16 kHz cannot be observed.
10
+ - Prior codecs, resampling, filtering, and mastering can obscure provenance.
11
+ - The original encoding chain cannot be recovered from one processed WAV.
12
+ - The current implementation loads entire files into memory, which may be
13
+ expensive for long songs or high sample rates.
14
+ - Peak spacing and cutoff heuristics lack real-dataset sensitivity and
15
+ specificity evaluation; v0.1 makes no accuracy claims.
16
+ - Master comparison assumes sufficiently similar waveforms, gain and time
17
+ alignment; remixes, extensive time-stretching and nonlinear editing can fail.
18
+ - HTML reports include a lightweight PSD figure when the source audio remains
19
+ available; they do not show a full STFT spectrogram or interactive plots.
20
+
21
+ If decisions affect artists' livelihoods, intellectual property disputes or
22
+ platform enforcement, **do not use SpectralAudit alone** as evidence of provenance.
@@ -0,0 +1,12 @@
1
+ # MasteringDiff: comparing premaster and master
2
+
3
+ `compare_masters(original, master)` measures sample offset, linear gain,
4
+ residual RMS and frequency-band changes after alignment. It does not infer
5
+ which plugin or process caused a change. See `docs/algorithms.md`.
6
+
7
+ For a multi-stage sequence, supply an insertion-ordered `dict` to
8
+ `audit_pipeline`, which compares consecutive versions.
9
+
10
+ Significant pitch shifts, time stretching, different arrangements,
11
+ nonlinear compression and sample rate conversion can confound the alignment.
12
+ Always inspect the signal pair independently if alignment quality is poor.