techdj/README_PYQT5.md

144 lines
3.6 KiB
Markdown

# TechDJ PyQt5 - Native DJ Application
A lightweight native alternative to the web-based TechDJ panel, built with PyQt5.
## Features
**Lightweight** - Uses ~120-150MB RAM (vs ~400MB for Chrome)
**Local Audio Processing** - Downloads songs from Flask server and processes locally
**Low Latency** - Instant response to controls, perfect for live DJing
**Full DJ Features**:
- Dual decks with independent playback
- Crossfader mixing
- Waveform display
- Hot cues (4 per deck)
- Speed/pitch control
- Volume control per deck
- Real-time audio visualization
## Installation
1. Install dependencies:
```bash
pip install -r requirements.txt
```
Note: On Linux, you may also need to install PortAudio:
```bash
# Ubuntu/Debian
sudo apt-get install portaudio19-dev python3-pyqt5
# Fedora
sudo dnf install portaudio-devel python3-qt5
# Arch
sudo pacman -S portaudio python-pyqt5
```
## Usage
1. Start the Flask server (in one terminal):
```bash
python server.py
```
2. Launch the PyQt5 DJ app (in another terminal):
```bash
python techdj_qt.py
```
## How It Works
1. **Library Management**: Fetches song list from Flask server at `http://localhost:5000/library.json`
2. **Song Download**: Downloads MP3 files to local cache (`~/.techdj_cache/`) on first use
3. **Local Playback**: Uses `sounddevice` for efficient real-time audio processing
4. **Caching**: Songs are cached locally for instant loading on subsequent uses
## Architecture
```
┌─────────────────────┐
│ PyQt5 Native App │ (~150MB RAM)
│ │
│ • Fetches library │
│ • Downloads & caches│
│ • Local audio mix │
│ • Real-time DSP │
└─────────────────────┘
│ HTTP (library + downloads)
┌─────────────────────┐
│ Flask Server │
│ (port 5000/5001) │
│ │
│ • Serves library │
│ • Serves MP3 files │
│ • Handles streaming │
└─────────────────────┘
```
## Memory Comparison
| Version | RAM Usage | CPU Usage | Latency |
|---------|-----------|-----------|---------|
| **Chrome Web Panel** | ~400MB | High | ~50-100ms |
| **PyQt5 Native** | ~120-150MB | Low | <10ms |
## Keyboard Shortcuts
- **Space**: Play/Pause active deck
- **1-4**: Hot cues for Deck A
- **5-8**: Hot cues for Deck B
- **Q/W**: Volume Deck A/B
- **A/S**: Speed Deck A/B
## Cache Management
Songs are cached in `~/.techdj_cache/`. To clear the cache:
```bash
rm -rf ~/.techdj_cache/
```
## Troubleshooting
### Audio Issues
If you get audio errors, check your audio devices:
```python
import sounddevice as sd
print(sd.query_devices())
```
### Connection Issues
Make sure the Flask server is running on port 5000:
```bash
curl http://localhost:5000/library.json
```
## Comparison with Web Panel
| Feature | Web Panel | PyQt5 Native |
|---------|-----------|--------------|
| Memory Usage | ~400MB | ~150MB |
| Installation | None (browser) | Requires Python + deps |
| Mobile Support | Excellent | None |
| Remote Access | Easy | Requires VPN/SSH |
| Audio Latency | Higher | Lower |
| Offline Mode | No | Yes (cached songs) |
| Battery Impact | Higher | Lower |
## Future Enhancements
- [ ] Broadcast to Flask server for web listeners
- [ ] BPM detection
- [ ] Auto-sync between decks
- [ ] Effects (reverb, delay, etc.)
- [ ] Recording/export
- [ ] MIDI controller support
- [ ] Playlist management
## License
Same as TechDJ main project