Skip to main content

GGWave Python Wrapper

License: MIT Python 3.8+ CI PyPI Code Style: Black Linter: Ruff Pre-commit Tests

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.

Metadata

Release files for ggwave_python 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ggwave_python 0.1.11
File Size Uploaded
ggwave_python-0.1.11.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ggwave_python 0.1.11
File Interpreter ABI Platform
ggwave_python-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / ggwave_python-0.1.11.tar.gz

Download URL ggwave_python-0.1.11.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6ae60122a030befc76baa1565e438532e526349f97fbfdc3bcd20b34bd9e6c1d
BLAKE2b-256 checksum
How to use checksums
220a3189ddfea0673c66686dbbfde206aa4abd7ee972e7ac35b2a30caa7d1c1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release files / ggwave_python-0.1.11-py3-none-any.whl

Download URL ggwave_python-0.1.11-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68721ba0ca93e17edd51618ca29993b799e9258fc0d863cdd2606e9f3fa09066
BLAKE2b-256 checksum
How to use checksums
d0f197e7e5a94935ea38f44271aa1ca72d97ae71e80445c1fbdd1e276f26d51e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.10.16 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page