Skip to main content

Ultrasonic data transmission package using OFDM and Reed-Solomon ECC

Project description

SonicTag

Ultrasonic Data Transmission over Audio

SonicTag is a Python package that enables data transmission between devices using ultrasonic audio signals (17kHz - 20kHz). It uses OFDM (Orthogonal Frequency-Division Multiplexing) and Reed-Solomon error correction to provide robust, near-audible data transfer through standard microphones and speakers.

License: MIT Python 3.10+ Version Tests

Features

  • OFDM Modulation: Uses 1024-point FFT with differential BPSK for robust data encoding.
  • Error Correction: Reed-Solomon ECC handles bursts of errors and acoustic noise.
  • Ultrasonic Band: Operates in the 17.5kHz - 20.5kHz range, making it mostly inaudible to adults.
  • Robust Sync: Chirp-based synchronization and robust header validation.
  • Cross-Platform: Works on any system with Python and audio hardware.

Installation

pip install sonictag

Or install from source:

git clone https://github.com/jillou35/SonicTag.git
cd SonicTag
pip install .

Quick Start

Transmitter

import sounddevice as sd
from sonictag import SonicTransmitter

tx = SonicTransmitter(sample_rate=48000)
payload = b"Hello, World!"
audio_frame = tx.create_audio_frame(payload)

# Play audio
sd.play(audio_frame, samplerate=48000)
sd.wait()

Receiver

import sounddevice as sd
from sonictag import SonicReceiver

rx = SonicReceiver(sample_rate=48000)

def audio_callback(indata, frames, time, status):
    # Process audio chunk
    decoded, consumed = rx.decode_frame(indata[:, 0])
    if decoded:
        print(f"Received: {decoded}")

with sd.InputStream(callback=audio_callback, channels=1, samplerate=48000):
    print("Listening...")

    while True:
        pass

Web App Demo

To run the full web application demo (Frontend + Backend):

1. Backend Setup

  1. Navigate to the backend directory:
    cd web_app/backend
  1. Install requirements:
    pip install -r requirements.txt
  1. Start the FastAPI server:
    uvicorn main:app --reload --host 0.0.0.0 --port 8000

2. Frontend Setup

  1. Navigate to the frontend directory:
    cd web_app/frontend
  1. Install dependencies:
    npm install
  1. Start the development server:
    npm run dev

3. Usage

  1. Open the URL shown in the frontend terminal (usually https://localhost:5173).
  2. Grant microphone permissions when prompted.
  3. Use the interface to transmit and receive data between devices or tabs.

Scripts

Acoustic Loopback Test

The scripts/acoustic_loopback.py script verifies the entire acoustic chain (Speaker -> Microphone) on your local machine. It creates a signal, plays it, records it immediately, and attempts to decode it.

Usage:

python scripts/acoustic_loopback.py --fs 48000

Options:

  • --fs: Sample rate (default: 48000).
  • --device-in: Input device index (see python -m sounddevice).
  • --device-out: Output device index.

Architecture

  1. SonicDataHandler: Encodes raw bytes into packets with Length, CRC32, and Reed-Solomon parity.
  2. SonicOFDM: Maps bits to frequency subcarriers and generates time-domain OFDM symbols.
  3. SonicSync: Generates and detects linear chirps for frame synchronization.
  4. SonicTransceiver: Combines these modules to provide a high-level transmit / receive API.

Testing

Run the test suite with:

pip install .[test]
pytest tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sonictag-0.1.0.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonictag-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file sonictag-0.1.0.tar.gz.

File metadata

  • Download URL: sonictag-0.1.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for sonictag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fd2790512b6bdd635c35090a3d24172a1b223acb5c5a7df3e99013e04f29cef
MD5 838165b3e2a4a65d87c600ecbb8b78a6
BLAKE2b-256 963d66841b9461e54adb7d37e31a908825c449662ad9838667ffe172e1f3e2be

See more details on using hashes here.

File details

Details for the file sonictag-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sonictag-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for sonictag-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b05e4e1787b41a1d3d713a122f05c013be84cadb9e51e8202a6a52ff5162586
MD5 668e98e9eabbc1335fa808cadef2667b
BLAKE2b-256 9c1eec3b5b8acf58200fceb0a0db1f49ec240fcfc91f1cc4f208bfb1cdb84be7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page