Sending data using sound with Chirp

Joe Todd
Joe Todd
Aug 2, 2018 · 3 min read

Chirp SDKs make sending data with audio incredibly straightforward for developers. Data is provided to the SDKs as an array of bytes. This means that any arbitrary data can be sent in its existing form without the SDK requiring any complicated conversions of data types or esoteric schema.

Transmission of the data can be via audible or inaudible ultrasonic audio depending on the configuration of your Chirp SDK. And you can get started with both the ultrasound and standard protocols for free in minutes.

Here are some of examples of sending string data using sound on different platforms.

iOS

In iOS SDK’s, payloads have the NSData type.

// Objective-C
NSString *identifier = [NSString stringWithUTF8String:@"parrotbill"];
NSData *payload = [identifier dataUsingEncoding:NSUTF8StringEncoding];
// Swift
let identifier: String = "parrotbill"
let payload: Data = identifier.data(using: .utf8)

Android

On Android, payloads are simply byte arrays.

String identifier = "parrotbill";
byte[] payload = identifier.getBytes(Charset.forName("UTF-8"));

JavaScript

In JavaScript, payloads are Uint8Arrays.

var identifier = 'parrotbill';
var arr = [...s].map(s => s.charCodeAt());
var payload = new Uint8Array(arr);

Python

In Python, payloads inherit from the built in type — bytearray.

identifier = 'parrotbill'
payload = [ord(ch) for ch in identifier]

The Chirp payload type in Python has some handy overloaded methods, to convert back to a list or a hexadecimal string.

def on_received(self, payload):
data = list(payload) # array of bytes
hexstring = str(payload) # hexadecimal string representation

It is sometimes useful to represent the payload as a hexadecimal string rather than an array of bytes or an ASCII string, for instance with the Audio API. To retrieve an MP3 of a Chirp payload using the Audio API, simply convert the data to a hexadecimal string, and use your Chirp application key and secret as basic auth parameters.

string = 'parrotbill'
arr = [112, 97, 114, 114, 111, 116, 98, 105, 108, 108]
hex = '706172726f7462696c6c'
curl https://audio.chirp.io/v3/default/706172726f7462696c6c -u <key>:<secret> -o chirp.mp3

Not only has this simplified sending data, but it has also passed on total control of the data to the user. This means that encryption methods can be added on top of the payload to secure any private data. AES and RSA are some implementations that could be used. Chirp does not store any payload data on a database or on the device itself, and no audio is recorded by the SDK or sent off-device in any form.

As well as this, many different protocols can be used with SDKs, including protocols which enable inaudible ultrasonic data transfer, faster data rates and environment-optimised audio frequencies. Standard audible data-over-sound and ultrasonic data transfer protocols are available for free to startups.

Chirp also designs custom protocols to fit your specific use case — just get in touch if you have specific requirements for your sonic data transfer application.

To try out Chirp SDKs for all of the above platforms, sign up at admin.chirp.io. Further documentation for each of the SDKs can be found at developers.chirp.io.

joe@chirp.io

Chirp is a technology company enabling a seamless transfer of digital information via soundwaves, using a device’s loudspeaker and microphone only. The transmission uses audible or inaudible ultrasound tones and takes place with no network connection. To learn more visit chirp.io and start sending data with sound today.

Chirp

Written by the team at Chirp, the world's most trusted data-over-sound technology used by the leading brands in over 90 countries. Find out more at www.chirp.io

Thanks to Chirp and Daniel Jones

Joe Todd

Written by

Joe Todd

Chirp

Chirp

Written by the team at Chirp, the world's most trusted data-over-sound technology used by the leading brands in over 90 countries. Find out more at www.chirp.io

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade