npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webaudio-modem

v1.3.0

Published

webaudio-modem

Downloads

31

Readme

Web Audio Modem

Encode and decode text using the Web Audio API, to allow offline data transfer between devices.

Live Demo

Original version

https://ryunosinfx.github.io/webaudio-modem/index.html

1 file version

https://ryunosinfx.github.io/webaudio-modem/WebAudioModem.html

Buffered version

8bit/1Code (Hamming code(7,4)+1ParityBit)

https://ryunosinfx.github.io/webaudio-modem/WebAudioModemBuffered.html

It is build as es modules.

When you try using Buffered version,You must prepare a http server and host this html files.

It dose not work load from html files.

Use as ES Modules

You can use Buffered version as a es module.

import { Oscillator, Reciver } from './WebAudioModemBufferedCore.js';
////////////////////Oscillator////////////////////////////////
/**
 * @constructor
 * @param {array} frequencies DTMFfrequencies as default.
 */
const oscillator = new Oscillator();

/**
 * The initialize method. call after user interaction.
 */
oscillator.init();

/**
 * The oscillator active duration time ms par a code.
 */
oscillator.activeDuration=40;

/**
 * The oscillator mute duration time ms after active time par a code.
 */
oscillator.pauseDuration=0;

/**
 * The oscillator call by active times and input oscilating progress 0-1.
 */
oscillator.onProgress=(progress)=>{
  console.log(progress)
};


/**
 * encode text to sound as modem.
 * @param {string, Uint8Array} text for encoding to sound.
 * @param {function} onComplete a callback function at called end. is nullable;
 * @param {function} onCompleteMute a callback function at called end of oscilations. is nullable;
 * @param {boolean} hasMuteTimeOnEnd has wait time as saame as oscilating duration after end of oscilations. default true;
 */
await oscillator.encode('hello world!', () => {
    alert('encoding is end!');
}, () => {
    alert('encoding is oscilating end!');
}),true);

////////////////////Reciver////////////////////////////////
/**
 * @constructor
 * @param {array} frequencies DTMFfrequencies as default.
 * @param {number}} fftSize 4096=44100hz/4096=10.7hz/1byte as default.
 * @param {number} smoothingTimeConstant 0.0 (max speed sampling rate) as default.
 * @param {number} minDecibels -68 (db) as default.
 */
const reciver = new Reciver();

/**
 * set signal volume theshold 0-255. 
 * @param {number} threshold 0-255.
 */
reciver.setBinVlueThreshold(200);

/**
 * The oscillator active duration time ms par a code. if you set pauseDuration>0, then contain with the duration.
 * @param {number} spanDuration duration time ms par a code.
 */
reciver.setSpanDuration(40);

/**
 * Unsharp mask to the Wave shape for bit change timing clarification.
 * @param {number} unsherpMaskGain 0:no effect. 2:Recommendation
 */
reciver.setUnsherpMaskGain(1);

/**
 * The output data type. Default output type is string.
 * @param {string} outputType text or Uint8Array.
 */
reciver.setOutputType("text" or "Uint8Array");

/**
 * set callbak funk for reciver recived text.
 * if recived codes is invalid, return nothing and this callback method is not called.
 */
reciver.onOutput=(textOrUint8Array)=>{
  alert(textOrUint8Array);
}

/**
 * set callbak funk for reciver state changed.
 * if recived state is changed, return new state(Reciver.state.STOP->(on start)Reciver.state.WAITING->Reciver.state.RECORDING->Reciver.state.PARSING->(on stop)Reciver.state.STOP)
 */
reciver.onStateChange=(newState)=>{
  alert(newState);
}
/**
 * start waiting for oscillator sounding codes.
 */
reciver.start();

/**
 * stop waiting for oscillator sounding codes.
 */
reciver.stop();