ggwave


Nameggwave JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://github.com/ggerganov/ggwave
SummaryTiny data-over-sound library.
upload_time2023-01-19 16:26:44
maintainer
docs_urlNone
authorGeorgi Gerganov
requires_python
licenseMIT
keywords data-over-sound fsk ecc serverless pairing qrcode ultrasound
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ======
ggwave
======

Tiny data-over-sound library.


.. code:: python

    # generate audio waveform for string "hello python"
    waveform = ggwave.encode("hello python")

    # decode audio waveform
    text = ggwave.decode(instance, waveform)


--------
Features
--------

* Audible and ultrasound transmissions available
* Bandwidth of 8-16 bytes/s (depending on the transmission protocol)
* Robust FSK modulation
* Reed-Solomon based error correction

------------
Installation
------------
::

    pip install ggwave

---
API
---

encode()
--------

.. code:: python

    encode(payload, [protocolId], [volume], [instance])

Encodes ``payload`` into an audio waveform.


Output of ``help(ggwave.encode)``:

.. code::

    built-in function encode in module ggwave
    
    encode(...)
        Encode payload into an audio waveform.
        @param {string} payload, the data to be encoded
        @return Generated audio waveform bytes representing 16-bit signed integer samples.
    

decode()
--------

.. code:: python

    decode(instance, waveform)

Analyzes and decodes ``waveform`` into to try and obtain the original payload.
A preallocated ggwave ``instance`` is required.


Output of ``help(ggwave.decode)``:

.. code::

    built-in function decode in module ggwave
    
    decode(...)
        Analyze and decode audio waveform to obtain original payload
        @param {bytes} waveform, the audio waveform to decode
        @return The decoded payload if successful.
    


-----
Usage
-----

* Encode and transmit data with sound:

.. code:: python

    import ggwave
    import pyaudio

    p = pyaudio.PyAudio()

    # generate audio waveform for string "hello python"
    waveform = ggwave.encode("hello python", protocolId = 1, volume = 20)

    print("Transmitting text 'hello python' ...")
    stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, output=True, frames_per_buffer=4096)
    stream.write(waveform, len(waveform)//4)
    stream.stop_stream()
    stream.close()

    p.terminate()

* Capture and decode audio data:

.. code:: python

    import ggwave
    import pyaudio

    p = pyaudio.PyAudio()

    stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, input=True, frames_per_buffer=1024)

    print('Listening ... Press Ctrl+C to stop')
    instance = ggwave.init()

    try:
        while True:
            data = stream.read(1024, exception_on_overflow=False)
            res = ggwave.decode(instance, data)
            if (not res is None):
                try:
                    print('Received text: ' + res.decode("utf-8"))
                except:
                    pass
    except KeyboardInterrupt:
        pass

    ggwave.free(instance)

    stream.stop_stream()
    stream.close()

    p.terminate()

----
More
----

Check out `<http://github.com/ggerganov/ggwave>`_ for more information about ggwave!

-----------
Development
-----------

Check out `ggwave python package on Github <https://github.com/ggerganov/ggwave/tree/master/bindings/python>`_.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ggerganov/ggwave",
    "name": "ggwave",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "data-over-sound fsk ecc serverless pairing qrcode ultrasound",
    "author": "Georgi Gerganov",
    "author_email": "ggerganov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a4/18/a8b2204590a4f7f12a38398f50a9b7618b18f345428c478edf53acc30b7d/ggwave-0.4.2.tar.gz",
    "platform": null,
    "description": "======\nggwave\n======\n\nTiny data-over-sound library.\n\n\n.. code:: python\n\n    # generate audio waveform for string \"hello python\"\n    waveform = ggwave.encode(\"hello python\")\n\n    # decode audio waveform\n    text = ggwave.decode(instance, waveform)\n\n\n--------\nFeatures\n--------\n\n* Audible and ultrasound transmissions available\n* Bandwidth of 8-16 bytes/s (depending on the transmission protocol)\n* Robust FSK modulation\n* Reed-Solomon based error correction\n\n------------\nInstallation\n------------\n::\n\n    pip install ggwave\n\n---\nAPI\n---\n\nencode()\n--------\n\n.. code:: python\n\n    encode(payload, [protocolId], [volume], [instance])\n\nEncodes ``payload`` into an audio waveform.\n\n\nOutput of ``help(ggwave.encode)``:\n\n.. code::\n\n    built-in function encode in module ggwave\n    \n    encode(...)\n        Encode payload into an audio waveform.\n        @param {string} payload, the data to be encoded\n        @return Generated audio waveform bytes representing 16-bit signed integer samples.\n    \n\ndecode()\n--------\n\n.. code:: python\n\n    decode(instance, waveform)\n\nAnalyzes and decodes ``waveform`` into to try and obtain the original payload.\nA preallocated ggwave ``instance`` is required.\n\n\nOutput of ``help(ggwave.decode)``:\n\n.. code::\n\n    built-in function decode in module ggwave\n    \n    decode(...)\n        Analyze and decode audio waveform to obtain original payload\n        @param {bytes} waveform, the audio waveform to decode\n        @return The decoded payload if successful.\n    \n\n\n-----\nUsage\n-----\n\n* Encode and transmit data with sound:\n\n.. code:: python\n\n    import ggwave\n    import pyaudio\n\n    p = pyaudio.PyAudio()\n\n    # generate audio waveform for string \"hello python\"\n    waveform = ggwave.encode(\"hello python\", protocolId = 1, volume = 20)\n\n    print(\"Transmitting text 'hello python' ...\")\n    stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, output=True, frames_per_buffer=4096)\n    stream.write(waveform, len(waveform)//4)\n    stream.stop_stream()\n    stream.close()\n\n    p.terminate()\n\n* Capture and decode audio data:\n\n.. code:: python\n\n    import ggwave\n    import pyaudio\n\n    p = pyaudio.PyAudio()\n\n    stream = p.open(format=pyaudio.paFloat32, channels=1, rate=48000, input=True, frames_per_buffer=1024)\n\n    print('Listening ... Press Ctrl+C to stop')\n    instance = ggwave.init()\n\n    try:\n        while True:\n            data = stream.read(1024, exception_on_overflow=False)\n            res = ggwave.decode(instance, data)\n            if (not res is None):\n                try:\n                    print('Received text: ' + res.decode(\"utf-8\"))\n                except:\n                    pass\n    except KeyboardInterrupt:\n        pass\n\n    ggwave.free(instance)\n\n    stream.stop_stream()\n    stream.close()\n\n    p.terminate()\n\n----\nMore\n----\n\nCheck out `<http://github.com/ggerganov/ggwave>`_ for more information about ggwave!\n\n-----------\nDevelopment\n-----------\n\nCheck out `ggwave python package on Github <https://github.com/ggerganov/ggwave/tree/master/bindings/python>`_.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tiny data-over-sound library.",
    "version": "0.4.2",
    "split_keywords": [
        "data-over-sound",
        "fsk",
        "ecc",
        "serverless",
        "pairing",
        "qrcode",
        "ultrasound"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a418a8b2204590a4f7f12a38398f50a9b7618b18f345428c478edf53acc30b7d",
                "md5": "2ac82c8aa61d4d2d81be45cce25538ce",
                "sha256": "f1451b636695675cdd9b92d8cf2ce3d3246b31a6e79cf63164c7d255db795124"
            },
            "downloads": -1,
            "filename": "ggwave-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2ac82c8aa61d4d2d81be45cce25538ce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 76932,
            "upload_time": "2023-01-19T16:26:44",
            "upload_time_iso_8601": "2023-01-19T16:26:44.045871Z",
            "url": "https://files.pythonhosted.org/packages/a4/18/a8b2204590a4f7f12a38398f50a9b7618b18f345428c478edf53acc30b7d/ggwave-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-19 16:26:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ggerganov",
    "github_project": "ggwave",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ggwave"
}
        
Elapsed time: 0.03186s