A Python wrapper for GGWave – data-over-sound communication
Project description
GGWave Python Wrapper
A Python wrapper for GGWave, a data-over-sound communication library.
This Python library is built on top of the existing Python bindings from the official GGWave repository. However, the original bindings are minimal and lack usability features, so this wrapper provides a more user-friendly API with enum support, streamlined encoding/decoding, and optional PyAudio integration.
📌 Features
- Encode and decode messages using sound waves.
- Support for multiple transmission protocols.
- Optional real-time audio transmission and reception via PyAudio.
🚀 Installation
Basic installation
pip install ggwave_python
With audio support (PyAudio)
pip install ggwave_python[audio]
🔧 Usage
Encoding and decoding messages
from ggwave_python import GGWave, ProtocolId
gg = GGWave()
try:
waveform = gg.encode("Hello, world!", ProtocolId.AUDIBLE_FAST, volume=20)
decoded = gg.decode(waveform)
print(decoded.decode("utf-8")) # "Hello, world!"
finally:
gg.free()
Real-time audio transmission (requires PyAudio)
from ggwave_python import GGWave, ProtocolId, waveform_utils
gg = GGWave()
try:
waveform = gg.encode("Test message", ProtocolId.AUDIBLE_FAST, volume=20)
waveform_utils.play_waveform(waveform)
finally:
gg.free()
Real-time audio reception
from ggwave_python import GGWave, waveform_utils
gg = GGWave()
try:
for message in waveform_utils.listen():
print("Received:", message.decode("utf-8"))
finally:
gg.free()
WAV Tools
On how to convert waveforms into WAV-format and back, please see WAV Example.
More examples
For more examples please see Examples.
⚙️ Technical Details
GGWave transmits data using frequency-shift keying (FSK), allowing devices to communicate via sound. The transmission rate is 8-16 bytes/sec, depending on the selected protocol.
🛠️ Development and Code Formatting
This project follows strict code style and formatting rules, enforced via pre-commit hooks.
We use the following tools:
- Ruff → Linter, import sorting, and lightweight formatter.
- Black → Code auto-formatter.
- Pytest → For unit testing.
🔧 Setting Up the Development Environment
To ensure a consistent environment, use poetry shell instead of installing packages globally.
poetry shell # Activate the virtual environment
make init # Install all dependencies
✅ Linting and Formatting
Our project requires clean, formatted code. Use make check to validate your code.
Check code style (without modifying files)
make check
Fix code style issues automatically
make fix
🛠 Pre-Commit Hooks (Mandatory)
This project requires pre-commit hooks to ensure formatting and linting before commits.
You must install the pre-commit hook before making changes.
Install pre-commit hook
pre-commit install
Run pre-commit manually on all files
make pre-commit
Remove pre-commit hooks (if needed)
pre-commit uninstall
🧪 Running Tests
Tests are managed with pytest.
Run all tests
make tests
Run a specific test
pytest tests/test_ggwave.py -k test_encode_decode
📜 Makefile for Development Workflow
All development tasks can be executed via make commands.
| Command | Description |
|---|---|
make init |
Install dependencies inside the virtual environment |
make check |
Run Ruff & Black in check mode (without changes) |
make fix |
Auto-fix code style issues with Black & Ruff |
make tests |
Run all tests with Pytest |
make build |
Build the package using Poetry |
make pre-commit |
Run all pre-commit hooks manually |
make help |
Show all available make commands |
Now your development workflow is fully automated! 🚀
📝 License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ggwave_python-0.1.11.tar.gz.
File metadata
- Download URL: ggwave_python-0.1.11.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ae60122a030befc76baa1565e438532e526349f97fbfdc3bcd20b34bd9e6c1d
|
|
| MD5 |
bafef0ee37e1555c540c03b5371c5459
|
|
| BLAKE2b-256 |
220a3189ddfea0673c66686dbbfde206aa4abd7ee972e7ac35b2a30caa7d1c1e
|
File details
Details for the file ggwave_python-0.1.11-py3-none-any.whl.
File metadata
- Download URL: ggwave_python-0.1.11-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68721ba0ca93e17edd51618ca29993b799e9258fc0d863cdd2606e9f3fa09066
|
|
| MD5 |
c62c57512754fdb415d549b6da8e1d18
|
|
| BLAKE2b-256 |
d0f197e7e5a94935ea38f44271aa1ca72d97ae71e80445c1fbdd1e276f26d51e
|