ggwave Documentation
repository·master·Indexed 27 days ago
https://github.com/ggerganov/ggwaveA lightweight data-over-sound library for transmitting small amounts of data between air-gapped devices using FSK modulation. It provides raw waveform generation and analysis with a bandwidth rate of 8-16 bytes/sec. ggwave supports multiple platforms including C++, Python, Node.js, and WebAssembly, allowing developers to integrate audio hardware interfacing via their own backends.
What's inside ggwave
- ggwave is a tiny data-over-sound library that enables communication between air-gapped devices using sound. It implements an FSK-based (Frequency-Shift Keying) transmission protocol with a bandwidth rate of 8-16 bytes/sec. The library is responsible for generating and analyzing RAW waveforms; developers are expected to provide audio callbacks for queuing and dequeuing samples using any audio backend (e.g., PulseAudio, ALSA, Web Audio API).
Install ggwave via Python
masterYou can install the Python bindings for ggwave using pip.
pip install ggwaveUse ggwave JavaScript bindings
masterTo use
ggwavein a JavaScript environment, import the factory and initialize the library asynchronously. Once initialized, you can create an instance usingggwave.init(parameters), encode strings into audio waveforms usingggwave.encode(), and decode waveforms back into data usingggwave.decode().Note that
ggwave.decode()returns a buffer/array that typically needs to be decoded viaTextDecoderto retrieve the original string.var factory = require('ggwave') factory().then(function(ggwave) { // create ggwave instance with default parameters var parameters = ggwave.getDefaultParameters(); // Example: enable DSS (Digital Signature Scheme) mode parameters.operatingMode |= ggwave.GGWAVE_OPERATING_MODE_USE_DSS; var instance = ggwave.init(parameters); console.log('instance: ' + instance); var payload = 'hello js'; // generate audio waveform for string "hello js" var waveform = ggwave.encode(instance, payload, ggwave.ProtocolId.GGWAVE_PROTOCOL_AUDIBLE_FAST, 10); // decode the audio waveform back to text var res = ggwave.decode(instance, waveform); // Decode the resulting buffer back to a string if (new TextDecoder("utf-8").decode(res) != payload) { process.exit(1); } });Build ggwave from source (C++)
masterTo build the C++ library and its examples, use CMake. Ensure you have the dependencies installed for your platform (e.g.,
libsdl2-devon Ubuntu orsdl2via brew on macOS).# build git clone https://github.com/ggerganov/ggwave --recursive cd ggwave && mkdir build && cd build cmake .. make # running ./bin/ggwave-cliBuild ggwave with Emscripten
masterTo build the WebAssembly version of ggwave, use the Emscripten toolchain.
git clone https://github.com/ggerganov/ggwave --recursive cd ggwave mkdir build && cd build emcmake cmake .. makeClean ggwave build artifacts
masterTo remove all generated files and clean the build environment, runmake clean.make cleanInstall ggwave via pip
masterYou can install the ggwave Python bindings using pip.
pip install ggwaveInstall the Waver application
masterWaver is a GUI application for testing ggwave. It is available on various platforms:
- Linux (Snap):
sudo snap install waver sudo snap connect waver:audio-record :audio-record
- **macOS (Homebrew):** ```bash brew install ggerganov/ggerganov/waver- Mobile: Available on the App Store (iOS) and Google Play (Android).
- Linux (Snap):
Create a source distribution for ggwave
masterTo create a source distribution (tarball) located in the
dist/directory to verify the package structure before publishing, runmake sdist. You can test the resulting tarball by installing it locally usingpip:sudo pip install dist/ggwave-*.tar.gzmake sdistInstall ggwave via Node.js
masterYou can install the Node.js bindings for ggwave using npm.
npm install ggwavePublish ggwave to PyPI
masterBefore publishing, ensure you have updated the version in
setup.py.There are two ways to publish:
- Automatic: Create a tag and push it to GitHub. Travis CI will automatically create the
sdist, build wheels, and push them to PyPI. - Manual: Run
make publishto create a source distribution and upload it directly to PyPI.
make publish- Automatic: Create a tag and push it to GitHub. Travis CI will automatically create the
Build the ggwave Python extension module
masterTo build the ggwave extension module as a.sofile for local development and testing, runmake build. Once built, you can verify the installation by opening a Python interpreter in the same directory as the generated.sofile and runningimport ggwavefollowed byggwave.encode('test').make build