{"id":18293456,"url":"https://github.com/archinetai/cqt-pytorch","last_synced_at":"2025-06-10T08:03:20.198Z","repository":{"id":64312727,"uuid":"563278388","full_name":"archinetai/cqt-pytorch","owner":"archinetai","description":"An invertible and differentiable implementation of the Constant-Q Transform (CQT).","archived":false,"fork":false,"pushed_at":"2022-12-09T09:11:49.000Z","size":1128,"stargazers_count":60,"open_issues_count":0,"forks_count":4,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-01T11:39:49.632Z","etag":null,"topics":["audio","cqt","deep-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archinetai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-08T09:29:12.000Z","updated_at":"2025-04-16T23:48:57.000Z","dependencies_parsed_at":"2023-01-15T11:30:43.187Z","dependency_job_id":null,"html_url":"https://github.com/archinetai/cqt-pytorch","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fcqt-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fcqt-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fcqt-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fcqt-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archinetai","download_url":"https://codeload.github.com/archinetai/cqt-pytorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archinetai%2Fcqt-pytorch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259033677,"owners_count":22795759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","cqt","deep-learning","pytorch"],"created_at":"2024-11-05T14:24:38.742Z","updated_at":"2025-06-10T08:03:20.157Z","avatar_url":"https://github.com/archinetai.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# CQT - PyTorch\n\n\nAn invertible and differentiable implementation of the Constant-Q Transform (CQT) using Non-stationary Gabor Transform (NSGT), in PyTorch.\n\n```bash\npip install cqt-pytorch\n```\n[![PyPI - Python Version](https://img.shields.io/pypi/v/cqt-pytorch?style=flat\u0026colorA=black\u0026colorB=black)](https://pypi.org/project/cqt-pytorch/)\n\n\n## Usage\n\n```python\nfrom cqt_pytorch import CQT\n\ntransform = CQT(\n    num_octaves = 8,\n    num_bins_per_octave = 64,\n    sample_rate = 48000,\n    block_length = 2 ** 18\n)\n\n# (Random) audio waveform tensor x\nx = torch.randn(1, 2, 2**18) # [1, 1, 262144] = [batch_size, channels, timesteps]\nz = transform.encode(x) # [1, 2, 512, 2839] = [batch_size, channels, frequencies, time]\ny = transform.decode(z) # [1, 1, 262144]\n```\n\n### Example CQT Magnitude Spectrogram (z)\n\u003cimg src=\"./IMAGE.png\"\u003e\u003c/img\u003e\n\n## TODO\n* [x] Power of 2 length (with `power_of_2_length` constructor arg).\n* [x] Understand why/if inverse window is necessary (it is necessary for perfect inversion).\n* [x] Allow variable audio lengths by chunking (now input can be a multiple of `block_length`)\n\n## Appreciation\nSpecial thanks to [Eloi Moliner](https://github.com/eloimoliner) for taking the time to help me understand how CQT works. Check out his own implementation with interesting features at [eloimoliner/CQT_pytorch](https://github.com/eloimoliner/CQT_pytorch).\n\n## Citations\n\n```bibtex\n@article{1210.0084,\nAuthor = {Nicki Holighaus and Monika Dörfler and Gino Angelo Velasco and Thomas Grill},\nTitle = {A framework for invertible, real-time constant-Q transforms},\nYear = {2012},\nEprint = {arXiv:1210.0084},\nDoi = {10.1109/TASL.2012.2234114},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchinetai%2Fcqt-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchinetai%2Fcqt-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchinetai%2Fcqt-pytorch/lists"}