Skip to content

AudioSignJS allows the broadcasting/listening of an id (32-bits) to/from a device to another via sound (Ultrasound).

License

Notifications You must be signed in to change notification settings

khankuan/audiosign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AudioSignJS: Audio-based signature using WebAudio and WebRTC

AudioSignJS allows the broadcasting/listening of an id (default 64-bits) to/from a device to another via sound (Ultrasound). It uses WebAudio to generate a soundwave and loops it continuously while broadcasting. When listening, it uses WebRTC to listen from the mic and WebAudio to process the sound captured. Currently, only 1 device can broadcast at one location at the same time.

The library can be used for the purpose such as pairing devices, or transmitting codes, etc.

Setup

Include the library

<script src="audiosign.js"></script>

Basic Usage

Notes

  • Off mic cancellation if your device have it.
  • Remember to on volume and remove earpiece to be able to allow other devices to listen.
  • Distance is about 0-10 metres, depending on noise level, volume and environment.
  • Candidates found might not be extremely accurate. Do consider adding some failsafe mechanism to handle wrong ids.
  • IDs is appended with 8 bits CRC for correctness.

Listener

var listener = new AudioSign.AudioSignListener(options);  //  Create a new listener
listener.on('candidate', function(x){                     //  Callback when new candidate id (default 160-bit) is heard
  console.log(x);
});
listener.start();                                         //  Start listening
//  Do other stuff...
listener.stop();                                          //  Do not wish to listen anymore

Broadcaster

var broadcaster = new AudioSign.AudioSignBroadcaster(options);  //  Create a new broadcaster
broadcaster.start();                                      //  Start broadcasting
console.log(broadcaster.id);                              //  The id (default 160-bit) that the broadcaster is broadcasting
//  Do other stuff...
broadcaster.stop();                                       //  Do not wish to broadcast anymore

Advance Usage

Listener Options are available to configure certain settings:

  • size: Size of the id, Default 160-bits. As size increases, it becomes more unstable and audible.
  • step: Step size between each frequency for each bit. Default 15. Too small, more unstable. Too big, audio can be more noticable.
  • baseFrequency: Base frequency to start with. Default is 18600 - (size+8) * step. Lower frequency makes the audio more noticable.
  • Optional events: 'started', 'stopped'

Broadcaster Options are available to configure certain settings:

  • size: Size of the id, Default 160-bits. As size increases, it becomes more unstable.
  • step: Step size between each frequency for each bit. Default 15. Too small, more unstable. Too big, audio can be more noticable.
  • baseFrequency: Base frequency to start with. Default is 18600 - (size+8) * step. Lower frequency makes the audio more noticable.
  • blink: Blink mode emits the sound wave for an active period per cycle. Default: {cycle: 1000, active: 300}. This helps to reduce effect of mic cancellation.

About

AudioSignJS allows the broadcasting/listening of an id (32-bits) to/from a device to another via sound (Ultrasound).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published