audio8bit 0.0.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.
@@ -0,0 +1,143 @@
1
+ Copyright (c) 2026 Olya Pimenova
2
+
3
+ This software is free to use for NONCOMMERCIAL purposes under the PolyForm
4
+ Noncommercial License 1.0.0, reproduced in full below. COMMERCIAL USE REQUIRES
5
+ A SEPARATE, PAID LICENSE FROM THE AUTHOR — please contact the copyright holder
6
+ to arrange one.
7
+
8
+ Required Notice: Copyright (c) 2026 Olya Pimenova
9
+
10
+ --------------------------------------------------------------------------------
11
+
12
+ # PolyForm Noncommercial License 1.0.0
13
+
14
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
15
+
16
+ ## Acceptance
17
+
18
+ In order to get any license under these terms, you must agree
19
+ to them as both strict obligations and conditions to all
20
+ your licenses.
21
+
22
+ ## Copyright License
23
+
24
+ The licensor grants you a copyright license for the
25
+ software to do everything you might do with the software
26
+ that would otherwise infringe the licensor's copyright
27
+ in it for any permitted purpose. However, you may
28
+ only distribute the software according to [Distribution
29
+ License](#distribution-license) and make changes or new works
30
+ based on the software according to [Changes and New Works
31
+ License](#changes-and-new-works-license).
32
+
33
+ ## Distribution License
34
+
35
+ The licensor grants you an additional copyright license
36
+ to distribute copies of the software. Your license
37
+ to distribute covers distributing the software with
38
+ changes and new works permitted by [Changes and New Works
39
+ License](#changes-and-new-works-license).
40
+
41
+ ## Notices
42
+
43
+ You must ensure that anyone who gets a copy of any part of
44
+ the software from you also gets a copy of these terms or the
45
+ URL for them above, as well as copies of any plain-text lines
46
+ beginning with `Required Notice:` that the licensor provided
47
+ with the software. For example, if you make a change covered
48
+ by [Changes and New Works License](#changes-and-new-works-license)
49
+ and provide that change to someone else, you must include the
50
+ notices with that change.
51
+
52
+ ## Changes and New Works License
53
+
54
+ The licensor grants you an additional copyright license to
55
+ make changes and new works based on the software for any
56
+ permitted purpose.
57
+
58
+ ## Patent License
59
+
60
+ The licensor grants you a patent license for the software that
61
+ covers patent claims the licensor can license, or becomes able
62
+ to license, that you would infringe by using the software.
63
+
64
+ ## Noncommercial Purposes
65
+
66
+ Any noncommercial purpose is a permitted purpose.
67
+
68
+ ## Personal Uses
69
+
70
+ Personal use for research, experiment, and testing for
71
+ the benefit of public knowledge, personal study, private
72
+ entertainment, hobby projects, amateur pursuits, or religious
73
+ observance, without any anticipated commercial application,
74
+ is use for a permitted purpose.
75
+
76
+ ## Noncommercial Organizations
77
+
78
+ Use by any charitable organization, educational institution,
79
+ public research organization, public safety or health
80
+ organization, environmental protection organization,
81
+ or government institution is use for a permitted purpose
82
+ regardless of the source of funding or obligations resulting
83
+ from the funding.
84
+
85
+ ## Fair Use
86
+
87
+ You may have "fair use" rights for the software under the
88
+ law. These terms do not limit them.
89
+
90
+ ## No Other Rights
91
+
92
+ These terms do not allow you to sublicense or transfer any of
93
+ your licenses to anyone else, or prevent the licensor from
94
+ granting licenses to anyone else. These terms do not imply
95
+ any other licenses.
96
+
97
+ ## Patent Defense
98
+
99
+ If you make any written claim that the software infringes or
100
+ contributes to infringement of any patent, your patent license
101
+ for the software granted under these terms ends immediately. If
102
+ your company makes such a claim, your patent license ends
103
+ immediately for work on behalf of your company.
104
+
105
+ ## Violations
106
+
107
+ The first time you are notified in writing that you have
108
+ violated any of these terms, or done anything with the software
109
+ not covered by your licenses, your licenses can nonetheless
110
+ continue if you come into full compliance with these terms,
111
+ and take practical steps to correct past violations, within
112
+ 32 days of receiving notice. Otherwise, all your licenses
113
+ end immediately.
114
+
115
+ ## No Liability
116
+
117
+ ***As far as the law allows, the software comes as is, without
118
+ any warranty or condition, and the licensor will not be liable
119
+ to you for any damages arising out of these terms or the use
120
+ or nature of the software, under any kind of legal claim.***
121
+
122
+ ## Definitions
123
+
124
+ The **licensor** is the individual or entity offering these
125
+ terms, and the **software** is the software the licensor makes
126
+ available under these terms.
127
+
128
+ **You** refers to the individual or entity agreeing to these
129
+ terms.
130
+
131
+ **Your company** is any legal entity, sole proprietorship,
132
+ or other kind of organization that you work for, plus all
133
+ organizations that have control over, are under the control of,
134
+ or are under common control with that organization. **Control**
135
+ means ownership of substantially all the assets of an entity,
136
+ or the power to direct its management and policies by vote,
137
+ contract, or otherwise. Control can be direct or indirect.
138
+
139
+ **Your licenses** are all the licenses granted to you for the
140
+ software under these terms.
141
+
142
+ **Use** means anything you do with the software requiring one
143
+ of your licenses.
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.4
2
+ Name: audio8bit
3
+ Version: 0.0.0
4
+ Summary: Turn a song into an 8-bit / chiptune arrangement of its melody (vocal or instrumental)
5
+ Author: Olya Pimenova
6
+ License: Copyright (c) 2026 Olya Pimenova
7
+
8
+ This software is free to use for NONCOMMERCIAL purposes under the PolyForm
9
+ Noncommercial License 1.0.0, reproduced in full below. COMMERCIAL USE REQUIRES
10
+ A SEPARATE, PAID LICENSE FROM THE AUTHOR — please contact the copyright holder
11
+ to arrange one.
12
+
13
+ Required Notice: Copyright (c) 2026 Olya Pimenova
14
+
15
+ --------------------------------------------------------------------------------
16
+
17
+ # PolyForm Noncommercial License 1.0.0
18
+
19
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
20
+
21
+ ## Acceptance
22
+
23
+ In order to get any license under these terms, you must agree
24
+ to them as both strict obligations and conditions to all
25
+ your licenses.
26
+
27
+ ## Copyright License
28
+
29
+ The licensor grants you a copyright license for the
30
+ software to do everything you might do with the software
31
+ that would otherwise infringe the licensor's copyright
32
+ in it for any permitted purpose. However, you may
33
+ only distribute the software according to [Distribution
34
+ License](#distribution-license) and make changes or new works
35
+ based on the software according to [Changes and New Works
36
+ License](#changes-and-new-works-license).
37
+
38
+ ## Distribution License
39
+
40
+ The licensor grants you an additional copyright license
41
+ to distribute copies of the software. Your license
42
+ to distribute covers distributing the software with
43
+ changes and new works permitted by [Changes and New Works
44
+ License](#changes-and-new-works-license).
45
+
46
+ ## Notices
47
+
48
+ You must ensure that anyone who gets a copy of any part of
49
+ the software from you also gets a copy of these terms or the
50
+ URL for them above, as well as copies of any plain-text lines
51
+ beginning with `Required Notice:` that the licensor provided
52
+ with the software. For example, if you make a change covered
53
+ by [Changes and New Works License](#changes-and-new-works-license)
54
+ and provide that change to someone else, you must include the
55
+ notices with that change.
56
+
57
+ ## Changes and New Works License
58
+
59
+ The licensor grants you an additional copyright license to
60
+ make changes and new works based on the software for any
61
+ permitted purpose.
62
+
63
+ ## Patent License
64
+
65
+ The licensor grants you a patent license for the software that
66
+ covers patent claims the licensor can license, or becomes able
67
+ to license, that you would infringe by using the software.
68
+
69
+ ## Noncommercial Purposes
70
+
71
+ Any noncommercial purpose is a permitted purpose.
72
+
73
+ ## Personal Uses
74
+
75
+ Personal use for research, experiment, and testing for
76
+ the benefit of public knowledge, personal study, private
77
+ entertainment, hobby projects, amateur pursuits, or religious
78
+ observance, without any anticipated commercial application,
79
+ is use for a permitted purpose.
80
+
81
+ ## Noncommercial Organizations
82
+
83
+ Use by any charitable organization, educational institution,
84
+ public research organization, public safety or health
85
+ organization, environmental protection organization,
86
+ or government institution is use for a permitted purpose
87
+ regardless of the source of funding or obligations resulting
88
+ from the funding.
89
+
90
+ ## Fair Use
91
+
92
+ You may have "fair use" rights for the software under the
93
+ law. These terms do not limit them.
94
+
95
+ ## No Other Rights
96
+
97
+ These terms do not allow you to sublicense or transfer any of
98
+ your licenses to anyone else, or prevent the licensor from
99
+ granting licenses to anyone else. These terms do not imply
100
+ any other licenses.
101
+
102
+ ## Patent Defense
103
+
104
+ If you make any written claim that the software infringes or
105
+ contributes to infringement of any patent, your patent license
106
+ for the software granted under these terms ends immediately. If
107
+ your company makes such a claim, your patent license ends
108
+ immediately for work on behalf of your company.
109
+
110
+ ## Violations
111
+
112
+ The first time you are notified in writing that you have
113
+ violated any of these terms, or done anything with the software
114
+ not covered by your licenses, your licenses can nonetheless
115
+ continue if you come into full compliance with these terms,
116
+ and take practical steps to correct past violations, within
117
+ 32 days of receiving notice. Otherwise, all your licenses
118
+ end immediately.
119
+
120
+ ## No Liability
121
+
122
+ ***As far as the law allows, the software comes as is, without
123
+ any warranty or condition, and the licensor will not be liable
124
+ to you for any damages arising out of these terms or the use
125
+ or nature of the software, under any kind of legal claim.***
126
+
127
+ ## Definitions
128
+
129
+ The **licensor** is the individual or entity offering these
130
+ terms, and the **software** is the software the licensor makes
131
+ available under these terms.
132
+
133
+ **You** refers to the individual or entity agreeing to these
134
+ terms.
135
+
136
+ **Your company** is any legal entity, sole proprietorship,
137
+ or other kind of organization that you work for, plus all
138
+ organizations that have control over, are under the control of,
139
+ or are under common control with that organization. **Control**
140
+ means ownership of substantially all the assets of an entity,
141
+ or the power to direct its management and policies by vote,
142
+ contract, or otherwise. Control can be direct or indirect.
143
+
144
+ **Your licenses** are all the licenses granted to you for the
145
+ software under these terms.
146
+
147
+ **Use** means anything you do with the software requiring one
148
+ of your licenses.
149
+
150
+ Keywords: audio,8bit,chiptune,melody,transcription,cli,dsp,ffmpeg
151
+ Classifier: Environment :: Console
152
+ Classifier: License :: Other/Proprietary License
153
+ Classifier: Programming Language :: Python :: 3
154
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Conversion
155
+ Requires-Python: >=3.9
156
+ Description-Content-Type: text/markdown
157
+ License-File: LICENSE
158
+ Requires-Dist: numpy>=1.21
159
+ Requires-Dist: demucs>=4.0
160
+ Requires-Dist: librosa>=0.10
161
+ Requires-Dist: basic-pitch>=0.4
162
+ Dynamic: license-file
163
+
164
+ # audio8bit
165
+
166
+ [![CI](https://github.com/yumiaura/audio8bit/actions/workflows/ci.yml/badge.svg)](https://github.com/yumiaura/audio8bit/actions/workflows/ci.yml)
167
+ [![PyPI](https://img.shields.io/pypi/v/audio8bit.svg)](https://pypi.org/project/audio8bit/)
168
+ [![Downloads](https://img.shields.io/pypi/dm/audio8bit.svg)](https://pypi.org/project/audio8bit/)
169
+ [![Python](https://img.shields.io/pypi/pyversions/audio8bit.svg)](https://pypi.org/project/audio8bit/)
170
+
171
+ Turn any song into 8-bit, video-game-style music - right from your terminal.
172
+ audio8bit finds the song's melody (and its chords) and replays them with retro
173
+ "chiptune" sounds, like an old game console.
174
+
175
+ **[English](https://github.com/yumiaura/audio8bit/blob/main/README.md)** | [Español](https://github.com/yumiaura/audio8bit/blob/main/docs/README_ES.md) | [Português](https://github.com/yumiaura/audio8bit/blob/main/docs/README_PT.md) | [Français](https://github.com/yumiaura/audio8bit/blob/main/docs/README_FR.md) | [Deutsch](https://github.com/yumiaura/audio8bit/blob/main/docs/README_DE.md) | [Italiano](https://github.com/yumiaura/audio8bit/blob/main/docs/README_IT.md) | [Русский](https://github.com/yumiaura/audio8bit/blob/main/docs/README_RU.md) | [中文](https://github.com/yumiaura/audio8bit/blob/main/docs/README_ZH.md) | [日本語](https://github.com/yumiaura/audio8bit/blob/main/docs/README_JA.md) | [हिन्दी](https://github.com/yumiaura/audio8bit/blob/main/docs/README_HI.md) | [한국어](https://github.com/yumiaura/audio8bit/blob/main/docs/README_KR.md)
176
+
177
+ ## What it does
178
+
179
+ - Give it a song, get back a chiptune version of it.
180
+ - Works whether the song has **singing** or is **instrumental** - it picks the
181
+ tune automatically.
182
+ - Everything runs on your own computer; nothing is uploaded.
183
+
184
+ ## Before you start
185
+
186
+ You need two things:
187
+
188
+ - **Python 3.9 or newer**
189
+ - **ffmpeg** - a free tool for reading and writing audio. Install it with
190
+ `sudo apt install ffmpeg` (Linux) or `brew install ffmpeg` (macOS).
191
+
192
+ ## Install
193
+
194
+ ```bash
195
+ pip install audio8bit
196
+ ```
197
+
198
+ > **First run is slow:** it downloads a small AI model (about 80 MB) and can
199
+ > take a few minutes. That's normal - later runs are faster.
200
+
201
+ ## Use it
202
+
203
+ ```bash
204
+ audio8bit -i song.mp3
205
+ ```
206
+
207
+ This creates `output.mp3` in the current folder. That's it. Each run also
208
+ prints a short quality report so you can see the result came out clean.
209
+
210
+ Want something different? Here are the most common tweaks:
211
+
212
+ ```bash
213
+ audio8bit -i song.mp3 -V lead # just the main melody, no chords
214
+ audio8bit -i song.mp3 -s vocals # follow the singing
215
+ audio8bit -i song.mp3 -s instrumental # follow the instruments
216
+ audio8bit -i song.mp3 --transpose 5 # play it 5 semitones higher
217
+ audio8bit -i song.mp3 -f ogg # save as .ogg instead of .mp3
218
+ ```
219
+
220
+ ## All options
221
+
222
+ | Option | Default | What it does |
223
+ | ---------------- | ---------------- | --------------------------------------------- |
224
+ | `-i, --input` | required | The song to convert (mp3, wav, flac, ...) |
225
+ | `-o, --output` | `output.<type>` | Where to save the result |
226
+ | `-f, --format` | same as input | Save as a different type, e.g. `ogg`, `wav` |
227
+ | `-s, --source` | `auto` | Where to take the tune: `vocals`, `instrumental`, or `auto` |
228
+ | `-m, --method` | `transcribe` | How notes are found: `transcribe` (best) or `pitch` (faster, lighter) |
229
+ | `-V, --voices` | `chords` | `chords` (with harmony) or `lead` (one melody line) |
230
+ | `--transpose` | `0` | Shift the key, in semitones (e.g. `5` up, `-5` down) |
231
+ | `--bits` | `8` | Sound resolution, 1-8 (lower = crunchier) |
232
+ | `--rate` | `22050` | Sample rate in Hz (lower = more retro) |
233
+ | `--duty` | `0.25` | Tone colour of the pulse wave, 0-1 |
234
+
235
+ ## If something goes wrong
236
+
237
+ - **"ffmpeg not found"** - install ffmpeg (see *Before you start*).
238
+ - **The first run seems stuck** - it's downloading the AI model; give it a few
239
+ minutes. It only happens once.
240
+ - **It doesn't sound like the song** - try `-s vocals` or `-s instrumental` to
241
+ pick the right part, or `-V lead` for just the melody.
242
+
243
+ ## How it works (optional reading)
244
+
245
+ 1. Splits the song into parts (vocals, drums, bass, and the rest).
246
+ 2. Detects the actual notes being played in the part you chose.
247
+ 3. Replays those notes with simple 8-bit "chip" sounds and saves the file.
248
+
249
+ ## License
250
+
251
+ [Noncommercial](https://github.com/yumiaura/audio8bit/blob/main/LICENSE)
@@ -0,0 +1,88 @@
1
+ # audio8bit
2
+
3
+ [![CI](https://github.com/yumiaura/audio8bit/actions/workflows/ci.yml/badge.svg)](https://github.com/yumiaura/audio8bit/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/audio8bit.svg)](https://pypi.org/project/audio8bit/)
5
+ [![Downloads](https://img.shields.io/pypi/dm/audio8bit.svg)](https://pypi.org/project/audio8bit/)
6
+ [![Python](https://img.shields.io/pypi/pyversions/audio8bit.svg)](https://pypi.org/project/audio8bit/)
7
+
8
+ Turn any song into 8-bit, video-game-style music - right from your terminal.
9
+ audio8bit finds the song's melody (and its chords) and replays them with retro
10
+ "chiptune" sounds, like an old game console.
11
+
12
+ **[English](https://github.com/yumiaura/audio8bit/blob/main/README.md)** | [Español](https://github.com/yumiaura/audio8bit/blob/main/docs/README_ES.md) | [Português](https://github.com/yumiaura/audio8bit/blob/main/docs/README_PT.md) | [Français](https://github.com/yumiaura/audio8bit/blob/main/docs/README_FR.md) | [Deutsch](https://github.com/yumiaura/audio8bit/blob/main/docs/README_DE.md) | [Italiano](https://github.com/yumiaura/audio8bit/blob/main/docs/README_IT.md) | [Русский](https://github.com/yumiaura/audio8bit/blob/main/docs/README_RU.md) | [中文](https://github.com/yumiaura/audio8bit/blob/main/docs/README_ZH.md) | [日本語](https://github.com/yumiaura/audio8bit/blob/main/docs/README_JA.md) | [हिन्दी](https://github.com/yumiaura/audio8bit/blob/main/docs/README_HI.md) | [한국어](https://github.com/yumiaura/audio8bit/blob/main/docs/README_KR.md)
13
+
14
+ ## What it does
15
+
16
+ - Give it a song, get back a chiptune version of it.
17
+ - Works whether the song has **singing** or is **instrumental** - it picks the
18
+ tune automatically.
19
+ - Everything runs on your own computer; nothing is uploaded.
20
+
21
+ ## Before you start
22
+
23
+ You need two things:
24
+
25
+ - **Python 3.9 or newer**
26
+ - **ffmpeg** - a free tool for reading and writing audio. Install it with
27
+ `sudo apt install ffmpeg` (Linux) or `brew install ffmpeg` (macOS).
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pip install audio8bit
33
+ ```
34
+
35
+ > **First run is slow:** it downloads a small AI model (about 80 MB) and can
36
+ > take a few minutes. That's normal - later runs are faster.
37
+
38
+ ## Use it
39
+
40
+ ```bash
41
+ audio8bit -i song.mp3
42
+ ```
43
+
44
+ This creates `output.mp3` in the current folder. That's it. Each run also
45
+ prints a short quality report so you can see the result came out clean.
46
+
47
+ Want something different? Here are the most common tweaks:
48
+
49
+ ```bash
50
+ audio8bit -i song.mp3 -V lead # just the main melody, no chords
51
+ audio8bit -i song.mp3 -s vocals # follow the singing
52
+ audio8bit -i song.mp3 -s instrumental # follow the instruments
53
+ audio8bit -i song.mp3 --transpose 5 # play it 5 semitones higher
54
+ audio8bit -i song.mp3 -f ogg # save as .ogg instead of .mp3
55
+ ```
56
+
57
+ ## All options
58
+
59
+ | Option | Default | What it does |
60
+ | ---------------- | ---------------- | --------------------------------------------- |
61
+ | `-i, --input` | required | The song to convert (mp3, wav, flac, ...) |
62
+ | `-o, --output` | `output.<type>` | Where to save the result |
63
+ | `-f, --format` | same as input | Save as a different type, e.g. `ogg`, `wav` |
64
+ | `-s, --source` | `auto` | Where to take the tune: `vocals`, `instrumental`, or `auto` |
65
+ | `-m, --method` | `transcribe` | How notes are found: `transcribe` (best) or `pitch` (faster, lighter) |
66
+ | `-V, --voices` | `chords` | `chords` (with harmony) or `lead` (one melody line) |
67
+ | `--transpose` | `0` | Shift the key, in semitones (e.g. `5` up, `-5` down) |
68
+ | `--bits` | `8` | Sound resolution, 1-8 (lower = crunchier) |
69
+ | `--rate` | `22050` | Sample rate in Hz (lower = more retro) |
70
+ | `--duty` | `0.25` | Tone colour of the pulse wave, 0-1 |
71
+
72
+ ## If something goes wrong
73
+
74
+ - **"ffmpeg not found"** - install ffmpeg (see *Before you start*).
75
+ - **The first run seems stuck** - it's downloading the AI model; give it a few
76
+ minutes. It only happens once.
77
+ - **It doesn't sound like the song** - try `-s vocals` or `-s instrumental` to
78
+ pick the right part, or `-V lead` for just the melody.
79
+
80
+ ## How it works (optional reading)
81
+
82
+ 1. Splits the song into parts (vocals, drums, bass, and the rest).
83
+ 2. Detects the actual notes being played in the part you chose.
84
+ 3. Replays those notes with simple 8-bit "chip" sounds and saves the file.
85
+
86
+ ## License
87
+
88
+ [Noncommercial](https://github.com/yumiaura/audio8bit/blob/main/LICENSE)
@@ -0,0 +1,3 @@
1
+ """audio8bit: turn a song into an 8-bit chiptune arrangement of its melody."""
2
+
3
+ version = "0.0.0"
@@ -0,0 +1,119 @@
1
+ """Command-line interface for audio8bit."""
2
+
3
+ import argparse
4
+ import sys
5
+
6
+ from audio8bit import version
7
+ from audio8bit.converter import (
8
+ DEFAULT_BITS,
9
+ DEFAULT_DUTY,
10
+ DEFAULT_METHOD,
11
+ DEFAULT_RATE,
12
+ DEFAULT_SOURCE,
13
+ DEFAULT_TRANSPOSE,
14
+ DEFAULT_VOICES,
15
+ METHOD_CHOICES,
16
+ SOURCE_CHOICES,
17
+ VOICES_CHOICES,
18
+ ConversionError,
19
+ convert,
20
+ )
21
+
22
+
23
+ def build_parser():
24
+ parser = argparse.ArgumentParser(
25
+ prog="audio8bit",
26
+ description="Turn a song into an 8-bit chiptune arrangement: take a "
27
+ "melody (the sung vocal or the instrumental lead) with "
28
+ "Demucs, extract its notes, snap them to the song's beat, "
29
+ "transpose into a new key and replay them with a pulse "
30
+ "lead, triangle bass and echo — like an 80s game console.",
31
+ )
32
+ parser.add_argument(
33
+ "-i", "--input", required=True,
34
+ help="path to the input audio file (any format ffmpeg can read)",
35
+ )
36
+ parser.add_argument(
37
+ "-o", "--output",
38
+ help="output path (default: 'output.<ext>' using the input's format)",
39
+ )
40
+ parser.add_argument(
41
+ "-f", "--format",
42
+ help="output format/extension, e.g. ogg, mp3, wav "
43
+ "(default: keep the input's format)",
44
+ )
45
+ parser.add_argument(
46
+ "-s", "--source", choices=SOURCE_CHOICES, default=DEFAULT_SOURCE,
47
+ help="which melody to follow: 'vocals' (the sung line), "
48
+ "'instrumental' (the backing lead, drums and bass removed), or "
49
+ f"'auto' (default: {DEFAULT_SOURCE})",
50
+ )
51
+ parser.add_argument(
52
+ "-m", "--method", choices=METHOD_CHOICES, default=DEFAULT_METHOD,
53
+ help="how to find the notes: 'transcribe' (polyphonic note model; best "
54
+ "for chords/instrumentals) or 'pitch' (lighter pYIN tracker snapped "
55
+ f"to the beat) (default: {DEFAULT_METHOD})",
56
+ )
57
+ parser.add_argument(
58
+ "-V", "--voices", choices=VOICES_CHOICES, default=DEFAULT_VOICES,
59
+ help="with --method transcribe: 'chords' plays every note (harmony and "
60
+ "bass kept) or 'lead' plays a single melody line "
61
+ f"(default: {DEFAULT_VOICES})",
62
+ )
63
+ parser.add_argument(
64
+ "--transpose", type=int, default=DEFAULT_TRANSPOSE,
65
+ help="shift the melody into another key by this many semitones, "
66
+ f"negative allowed (default: +{DEFAULT_TRANSPOSE})",
67
+ )
68
+ parser.add_argument(
69
+ "--bits", type=int, default=DEFAULT_BITS,
70
+ help=f"bit depth to quantise to, 1-8 (default: {DEFAULT_BITS})",
71
+ )
72
+ parser.add_argument(
73
+ "--rate", type=int, default=DEFAULT_RATE,
74
+ help=f"output sample rate in Hz (default: {DEFAULT_RATE})",
75
+ )
76
+ parser.add_argument(
77
+ "--duty", type=float, default=DEFAULT_DUTY,
78
+ help=f"pulse-wave duty cycle, 0-1 (default: {DEFAULT_DUTY})",
79
+ )
80
+ parser.add_argument(
81
+ "--version", action="version", version=f"audio8bit {version}",
82
+ )
83
+ return parser
84
+
85
+
86
+ def main(argv=None):
87
+ parser = build_parser()
88
+ args = parser.parse_args(argv)
89
+ try:
90
+ output, quality_ok, report = convert(
91
+ args.input,
92
+ output_path=args.output,
93
+ format=args.format,
94
+ bits=args.bits,
95
+ rate=args.rate,
96
+ duty=args.duty,
97
+ transpose=args.transpose,
98
+ source=args.source,
99
+ method=args.method,
100
+ voices=args.voices,
101
+ )
102
+ except ConversionError as error:
103
+ print(f"audio8bit: {error}", file=sys.stderr)
104
+ return 1
105
+ print(f"Wrote {output}")
106
+ print("Quality report (anti-mush checks):")
107
+ for line in report:
108
+ print(f" {line}")
109
+ if not quality_ok:
110
+ print(
111
+ "audio8bit: warning: some quality checks failed - "
112
+ "the result may not sound musical",
113
+ file=sys.stderr,
114
+ )
115
+ return 0
116
+
117
+
118
+ if __name__ == "__main__":
119
+ sys.exit(main())