Coder Social home page Coder Social logo

soundlink's Introduction

+------------------------+
 soundlink 声波通信代码库 
+------------------------+

原理概述
--------

soundlink 是一个 C 语言实现的声波通信代码库,可以通过声波发送和接收数据。

将 8000KHz 采样率的音频作为载波,200 个采样点为一个声音片段,或者说一秒
钟的音频被分为了 40 等分,每份 200 个采样点,时长 25ms.

对每一个声音片段进行频率调制编码,每个声音片段承载 4bit 的数据。接收端采
用了 128 点长度的 FFT 变换,在 64 个可分辨的频点中找到 16 个作为 4bit 数
据的编码频点,另外再找一个频点作为开始码的编码频点。因此总共需要 17 个可
编码的频点。


发送数据帧的定义为:
1 字节开始码 + 1 字节长度信息 + 最多 255 个字节的数据 + 2 字节的校验和


发送端的工作极为简单,只需要根据实际的字节数据,生成不同频率的音频片段即可。
接收端需要接收音频数据,分片段进行 FFT 变换,并分析每个音频片段的频率,分析
出开始码,然后解析出实际的数据帧,并检查校验和,如果一切正常,则认为接收到
正确的数据。


当前的设计,每秒可以发送 40 个声音片,每片承载 4bit 数据,也就是说理论的传
输速率为 20B/s. 实测在安静环境,或者 mic 靠近喇叭进行接收,成功率还算理想。
实际应用时可根据需求,修改采样率、音频片段长度、编码频点、增加纠错码等来优
化效果,增强抗干扰能力。



使用方法
--------

目前在 windows + msys2 编译通过,发送端支持生成的音频保存到文件或者播放到喇叭。
接收端支持从音频文件解析出数据帧,或者从 mic 录音实时接收数据帧。

发送:soundlink hello wavdev
将会发送 hello 到喇叭,wavdev 代表音频设备即喇叭和 MIC

发送:soundlink hello hello.wav
将会把音频保存到 hello.wav

接收:
运行 soundlink 后,敲入命令
recv_start wavdev
将会从 mic 实时接收数据帧

敲入命令
recv_start hello.wav
将会从 hello.wav 文件解析出数据帧



rockcarry
2021-6-4




soundlink's People

Contributors

rockcarry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.