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.
In iOS SDK’s, payloads have the NSData type.
NSString *identifier = [NSString stringWithUTF8String:@"parrotbill"];
NSData *payload = [identifier dataUsingEncoding:NSUTF8StringEncoding];// Swift
let identifier: String = "parrotbill"
let payload: Data = identifier.data(using: .utf8)
On Android, payloads are simply byte arrays.
String identifier = "parrotbill";
byte payload = identifier.getBytes(Charset.forName("UTF-8"));
var identifier = 'parrotbill';
var arr = [...s].map(s => s.charCodeAt());
var payload = new Uint8Array(arr);
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.
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.