


Detailed explanation of web cross-device ultrasonic communication solution based on HTML5:
Foreword: Chirp The iPhone launched the prelude to audio file transfer. We no longer need MMS, Bluetooth pairing, or IM to transfer data. It shares data through the chirping of birds, which is simple and interesting, and can quickly achieve one-to-many sharing.
##In addition, Alipay has tried to promote "sound wave payment", using the mobile phone to send ultrasonic waves to the terminal as a transaction password to further complete the transaction. However, Alipay's technology is currently only used for payment, and it requires specific vending machines that can accept sonic payments before it can be used.
" advanced sound for game and interactive apps -webaudio api ##" Web's web with HTML5 with HTML5 Audio API implements an ultrasonic interconnection solution based on Web. In this way, there is no need to install any client, nor does Bluetooth or # With the support of ##NFC, you can connect two devices that use browsers to access the Internet and transfer pictures, music, videos and other files. This idea is cool and helps us take a big step forward in the functionality and application level of Web (Maybe you have this idea. Unthinkable, unheard of), let’s take a look at the specific principles and implementation process. ……………………………………✄……………………………………
Gorgeous separation LineThe phone in your pocket is a cool, beautiful tool with many functions. But when it wants to talk to other devices, such as a TV or laptop, the user experience drops significantly.
Bill BuxtonThere is a very infectious speech on this topic, describing the three stages of high-tech evolution:
1,Equipment work: functional integrity and stability## 2,
Device smoothness: good user experience##3.
Many devices working togetherWe have officially entered the
2stage with the release of iPhone , but connecting devices is a pain. There are many ways to achieve this: Bluetooth, BluetoothLE, WiFi direct, via localWiFi Network discovery and more. This article tackles the problem from a completely unexpected angle: using ultrasound to broadcast and send data between adjacent devices. Most importantly, this approach uses the Web Audio API, making connection with pure Web possible. Demo video
The Tower of Babel of Equipment
##Airplay and Chromecast is a great way to solve connectivity issues with devices within the same ecosystem (e.g. Apple or Google) , but common problems are still difficult to solve.
Because there are many possible technical approaches, it may happen that there is no common method among the devices you want to connect to. Even if two devices have Bluetooth, one may need to be configured, but the other does not, or supports a different version of the standard. Now this is especially common with Bluetooth, many devices support Bluetooth 4.0 (aka BTLE) on hardware, but many devices don't This latest protocol is not supported for various reasons. ##
This situation is even worse onWeb because of the low level device connectionAPIIt is not provided due to security sandbox reasons. And since the development of Web is very slow, it is difficult to imagine that this situation can be solved in a short time.
Transmitting data in interesting ways Electric Imp The provided
Blinkupis an interesting way to communicate across terminals. It uses a series of flashes of light to light up a smartphone and the Imp - a device that looks like a small SD card and has a light sensor. transfer data between. Dial-up modems do something similar. They encode and decode digital data on analog telephone lines. Remember those annoying connection noises? The dial-up modem will turn on the speaker to let the user know that a handshake is taking place. If you forget these, you can review them here. Even in today's analog phones, the sound you hear when you press a number key on a keypad is equivalent to the frequency that the phone system uses for analog-to-digital conversion. This conversion uses Dual Tone Multi-frequency signal (DTMF).
Your phone and many other devices around you have speakers and microphones. Both pieces of hardware can use sound to send and receive data, similar to what a modem does on a phone line. Even better, if the operating system supports sending and receiving at a high enough frequency, we can create a silent data channel. Transmitting data using sound
## I should have noticed Encoding data through sound is not new. Audio Watermark
The idea is to encode the signature into the music, which the listener cannot recognize through human means, but can be understood by another device. This is a smart way to prevent piracy. # Most ordinary speakers can produce the sound of # 44.1khz ## (This leads to the highest frequency of 22KHz - According to Shannon Sampling Theorem). This allows us to encode data not just into sound, but also to produce audio that adults cannot hear. However, children and animals may still hear it :) ## Technically, it should be noted that microphones are sometimes not compatible with speakers, especially on mobile phones , because they are often optimized for people talking on the phone, using a lower sampling rate to make the sound better. In other cases, even if the hardware is compatible, the firmware needs to run at a lower sampling rate to ensure power supply. If this is the case, the device will not be able to receive sound waves, and sound-based connections will only work in one direction. SONICNET.JS, an implementation of Web Audio To illustrate these concepts, I built a JavaScript library for sending and receiving via sound data. My approach does not require learning complicated audio watermarking technology, and it is even simpler than DTMF. Basically, you specify how often a range is used, and the set of letters that can be transmitted. The spectrum is divided into ranges corresponding to the specified start and end letters, with each letter / code corresponding to a portion of the entire frequency range. The sending end converts each character that needs to be sent into the midpoint value of the corresponding frequency range, and sends the frequency within a time interval. The receiving end will perform a discontinuous Fourier transform on the signal (Yu Jie's note: My undergraduate major is information and communication engineering, friends who have studied digital signal processing should know this very well), and look for peaks within the specified frequency range. After finding a peak within a signal interval, it converts the frequency back into characters. This is basically a Single Tone Multi-Frequency Signal (STMF) scheme. There is a question of sending timing: on the sending end, how long should it take to send a character; on the receiving end, how long should it take to receive it? We used a simple scheme to avoid adjacent repeated characters. I designed a API## similar to socket #Used for acoustic communication. The client code looks like this: ##ssocket = new SonicSocket({alphabet: '0123456789'});
function onButton() {
ssocket.send('31415');
}
Service The end looks like this:
##sserver = new SonicServer({alphabet: '0123456789'});
sserver.on('message', function(message) {
//Expect message to be '31415'.
console.log(message);
});
sserver.start();
##
JS
Library support
github.
Of course, using it requires an implementation of Web Audio (mostly using OscillatorNode## on the sending side #, use AnalyserNode at the receiving end). I've tried Macbook on Chrome to Chrome, as well as Transfer case from Mac Chrome to Android Chrome.
I wrote a pair of examples to illustrate this idea. They appear in the video demonstrated at the beginning of this article. The first example allows you to send emoticons from one device to another. It uses a very small character set, including only 6 characters, each corresponding to 1 expressions. You can choose one of the 6 emoticons, and the corresponding character will be sent through the sonic network and received and displayed at the other end.
# Sonicnet.js The more realistic application is this chat Apply , generate a unique 5 digit token and use it to communicate between 2 devices Create connection. This is done with the help of a pairing server, which establishes a proxy connection between the two devices via WebSocket. Once the connection is established, the conversation itself is sent over WebSocket. Server-side code is hosted on nodejitsu.
Conclusion and expectations
## Web Audio APIIt has evolved to make such applications possible, which is a major progress. I'm obsessed with sonicnet.js implementation on the Internet of Things. This is pure Web technology that can be used to pair devices. The combination of ubiquitous browsers and audio hardware will be a huge win, and even at the hardware level, Webplatforms don't need to wait for Bluetooth or other near-field connectivity technologies at all Mature. If this article has piqued your interest, you can try to use sonicnet.js to write an application. As I mentioned before, receiving high frequency audio is not available on all devices due to hardware/firmware limitations, so I'd love to know which ones are available and which ones are not. Can't. My expectation is that most phones should only be able to send, while most laptops should be able to receive and send at the same time. If you tried the emoticon demo on your device, please fill out this form. At the time of writing this article, the Chrome Beta version on the Android platform does not support real-time input, so transferring data from mobile phone to laptop is the only option.
The above is the detailed content of Detailed explanation of web cross-device ultrasonic communication solution based on HTML5. For more information, please follow other related articles on the PHP Chinese website!

html5的div元素默认一行不可以放两个。div是一个块级元素,一个元素会独占一行,两个div默认无法在同一行显示;但可以通过给div元素添加“display:inline;”样式,将其转为行内元素,就可以实现多个div在同一行显示了。

html5中列表和表格的区别:1、表格主要是用于显示数据的,而列表主要是用于给数据进行布局;2、表格是使用table标签配合tr、td、th等标签进行定义的,列表是利用li标签配合ol、ul等标签进行定义的。

固定方法:1、使用header标签定义文档头部内容,并添加“position:fixed;top:0;”样式让其固定不动;2、使用footer标签定义尾部内容,并添加“position: fixed;bottom: 0;”样式让其固定不动。

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html5中不支持的标签有:1、acronym,用于定义首字母缩写,可用abbr替代;2、basefont,可利用css样式替代;3、applet,可用object替代;4、dir,定义目录列表,可用ul替代;5、big,定义大号文本等等。

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

html5是指超文本标记语言(HTML)的第五次重大修改,即第5代HTML。HTML5是Web中核心语言HTML的规范,用户使用任何手段进行网页浏览时看到的内容原本都是HTML格式的,在浏览器中通过一些技术处理将其转换成为了可识别的信息。HTML5由不同的技术构成,其在互联网中得到了非常广泛的应用,提供更多增强网络应用的标准机。

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
