Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abr-xcorr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abr-xcorr

Cross correlation in JS

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by800%
Maintainers
1
Weekly downloads
 
Created
Source

xcorr

Cross correlation of two 16-bit buffers in JS. Uses Fourier transforms for fast calculation, as explained e.g. at http://mathworld.wolfram.com/Cross-CorrelationTheorem.html

Usage

See xcorr.test.js.

const sig = Buffer.from([0, 1, 0, 0]); // two 16-bit samples
Xcorr(sig, sig) === {
	xcorr: [1, 0], // raw cross-correlation profile
	xcorrMax: 1,   // max cross-correlation
	iMax: 0,       // index in first buffer at which cross-correlation is maxed
}

More about the sign of ìMax:

// two arrays of four 16-bit samples, rotated by one sample
const sig1 = Buffer.from([0, 1, 0, 0, 0, 4, 0, 2]);
const sig2 = Buffer.from([0, 2, 0, 1, 0, 0, 0, 4]);
Xcorr(sig1, sig2).iMax === -1
Xcorr(sig2, sig1).iMax === 1

If the input signals do not have a length equal to a power of 2 (2, 4, 8, 16…), they are padded with zeroes.

FAQs

Package last updated on 01 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc