Skip to content

Commit ad1ecb6

Browse files
authored
Merge pull request #7 from yprez/codex/identify-codebase-improvement-opportunities
Entry point
2 parents 5d74d2b + 97b9b21 commit ad1ecb6

5 files changed

Lines changed: 106 additions & 83 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ uv sync
4646

4747
## Running
4848

49-
Run the synth with:
49+
Run the synth with the packaged GUI entry script:
50+
51+
```bash
52+
uv run qwertysynth
53+
```
54+
55+
You can also continue using the legacy entry point if you prefer:
5056

5157
```bash
5258
uv run python main.py
@@ -57,7 +63,7 @@ Then press keys on the keyboard to play or use the GUI controls. Press ESC to qu
5763
## Command line options
5864

5965
```bash
60-
uv run python main.py [OPTIONS]
66+
uv run qwertysynth [OPTIONS]
6167
```
6268

6369
- `--midi FILE` - Load MIDI file on startup
@@ -66,7 +72,7 @@ uv run python main.py [OPTIONS]
6672

6773
Example:
6874
```bash
69-
uv run python main.py --midi song.mid --play --patch "Bass"
75+
uv run qwertysynth --midi song.mid --play --patch "Bass"
7076
```
7177

7278
## Input methods

main.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,11 @@
1-
"""QWERTY Synth - A simple software synthesizer controlled by your keyboard."""
1+
"""Backward-compatible entry point for running the QWERTY Synth GUI."""
22

3-
import argparse
4-
5-
from qwerty_synth import gui_qt as gui
3+
from qwerty_synth.entry import main as _launch_gui
64

75

86
def main():
9-
"""Start the QWERTY Synth application."""
10-
parser = argparse.ArgumentParser(description='QWERTY Synth - Software synthesizer')
11-
parser.add_argument('--midi', type=str, help='MIDI file to load on startup')
12-
parser.add_argument('--play', action='store_true', help='Automatically play the MIDI file')
13-
parser.add_argument('--patch', type=str, help='Patch name to load on startup')
14-
args = parser.parse_args()
15-
16-
print('QWERTY Synth: Play keys A-K, W,E,T,Y,U,O,P etc.')
17-
print('Use Z / X to shift octave down / up')
18-
print('Press ESC to quit')
19-
20-
if args.midi:
21-
print(f'MIDI file will be loaded: {args.midi}')
22-
if args.play:
23-
print('Auto-play enabled')
24-
25-
if args.patch:
26-
print(f'Patch will be loaded: {args.patch}')
27-
28-
print('Starting GUI...')
29-
30-
# Start the GUI (which handles audio stream and keyboard input)
31-
gui.start_gui(midi_file=args.midi, auto_play=args.play, patch_name=args.patch)
7+
"""Launch the QWERTY Synth application."""
8+
_launch_gui()
329

3310

3411
if __name__ == "__main__":

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "qwerty-synth"
2+
name = "qwertysynth"
33
version = "0.1.0"
44
description = "A minimalist real-time synthesizer with QWERTY keyboard input"
55
readme = "README.md"
@@ -20,6 +20,12 @@ dependencies = [
2020
"soundfile>=0.13.1",
2121
]
2222

23+
[project.scripts]
24+
qwertysynth = "qwerty_synth.entry:main"
25+
26+
[tool.uv]
27+
package = true
28+
2329
[dependency-groups]
2430
dev = [
2531
"pytest>=8.3.5",

qwerty_synth/entry.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Entry point for launching the QWERTY Synth GUI."""
2+
3+
import argparse
4+
5+
from qwerty_synth import gui_qt as gui
6+
7+
8+
def main():
9+
"""Parse command-line arguments and start the synthesizer GUI."""
10+
parser = argparse.ArgumentParser(description='QWERTY Synth - Software synthesizer')
11+
parser.add_argument('--midi', help='MIDI file to load on startup')
12+
parser.add_argument('--play', action='store_true', help='Automatically play the MIDI file')
13+
parser.add_argument('--patch', help='Patch name to load on startup')
14+
args = parser.parse_args()
15+
16+
print('QWERTY Synth: Play keys A-K, W,E,T,Y,U,O,P etc.')
17+
print('Use Z / X to shift octave down / up')
18+
print('Press ESC to quit')
19+
20+
if args.midi:
21+
print(f'MIDI file will be loaded: {args.midi}')
22+
if args.play:
23+
print('Auto-play enabled')
24+
25+
if args.patch:
26+
print(f'Patch will be loaded: {args.patch}')
27+
28+
print('Starting GUI...')
29+
30+
gui.start_gui(midi_file=args.midi, auto_play=args.play, patch_name=args.patch)
31+
32+
33+
if __name__ == "__main__":
34+
main()

uv.lock

Lines changed: 52 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)