SkillAgentSearch skills...

Handshaker

A lightweight and educational Python-based audio modem that converts text into sound using digital modulation techniques. This project demonstrates how to encode and transmit data via audio signals, exploring concepts like Frequency Shift Keying (FSK), signal smoothing, and robust transmission strategies.

Install / Use

/learn @andrea-shhz/Handshaker
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

🎧 Python Audio Modem

A lightweight and educational Python-based audio modem that converts text into sound using digital modulation techniques. This project demonstrates how to encode and transmit data via audio signals, exploring concepts like Frequency Shift Keying (FSK), signal smoothing, and robust transmission strategies.

📦 Installation

Set up your environment and install the required libraries:

python -m venv .venv
source .venv/bin/activate  # On Windows: .\.venv\Scripts\Activate.ps1
pip install --upgrade pip
pip install numpy scipy sounddevice

🛠 Features

  • Bit-wise and Byte-wise Encoding: Supports both granular bit-level and byte-level signal generation.
  • Hard vs. Smooth Transitions: Choose between raw signal transitions or smoothed ones using Hann windows.
  • Sync Sequence: Adds a synchronization sequence to improve decoding accuracy.
  • WAV Export: Automatically saves generated signals as .wav files with timestamped filenames.
  • Real-Time Playback: Play the generated signal directly through your audio device.

📡 Signal Transmission Techniques

To improve reliability and robustness, the following strategies are considered:

  1. Sync Sequence
    A known bit pattern (e.g., 10101010) is sent before the actual data to help the receiver align and synchronize.

  2. Advanced Modulation
    Beyond binary FSK, multi-frequency schemes (e.g., 4-level FSK for 2-bit symbols) can increase efficiency and resilience.

  3. Error Detection & Correction
    Add parity bits or implement error-correcting codes like Hamming or Reed-Solomon to detect and fix transmission errors.

  4. Bandpass Filtering
    Apply filters (e.g., 900 Hz to 2100 Hz) to isolate relevant frequencies and reduce ambient noise.

  5. Robust Windowing
    Use longer analysis windows and techniques like moving averages or cross-correlation to improve frequency detection.

  6. Preamble & Postamble
    Clearly mark the start and end of the signal to help the receiver extract the payload accurately.

  7. Adaptive Thresholding
    Use energy-based detection rather than fixed thresholds to handle variations in volume and recording quality.

🔍 Signal Preprocessing (Reception Side)

  • Amplitude normalization
  • DC offset removal
  • Hann window application to reduce edge effects

🧪 Decoding Improvements

  • Precomputed filters for efficient frequency isolation
  • Sync sequence detection via correlation
  • Frequency band energy analysis for bit decoding
  • Parity bits for error detection
  • Robust binary conversion handling

📁 Output Example

Generated audio files are saved with a timestamped filename:

modem_2025-09-23-18-57-48.wav

💡 Usage Tips

  • Test in environments with varying noise levels
  • Tune FREQ_0 and FREQ_1 based on your hardware
  • Increase SYNC_SEQUENCE length for better synchronization

📜 License

This project is licensed under the MIT License. Feel free to use, modify, and share it.


🔬 Perfect for learning about digital signal processing, audio-based data transmission, and Python's capabilities in real-time signal generation.

View on GitHub
GitHub Stars9
CategoryEducation
Updated5mo ago
Forks1

Languages

Python

Security Score

67/100

Audited on Nov 2, 2025

No findings