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

@ircam/sc-signal

v1.2.0

Published

Set of simple processing utilities

Downloads

1

Readme

@ircam/sc-signal

Simple signal processing utilities.

Install


npm install --save @ircam/sc-signal

API

Table of Contents

Clipper

Represents a Clipper object that limits the range of input values.

Parameters

  • $0 Object (optional, default {})

    • $0.min (optional, default -Infinity)
    • $0.max (optional, default Infinity)
  • options Object? The options object.

Examples

// clip to [0,1]
const clipper = new Clipper({
 min: 0,
 max: 1,
});

clipper.process(0.5); // 0.5
clipper.process(2); // 1
clipper.process(-1); // 0
// min only
const clipper = new Clipper({
  min: 0,
});

clipper.process(0.5); // 0.5
clipper.process(2); // 2
clipper.process(-1); // 0

set

Sets the attributes of the Clipper object.

Parameters

  • attributes Object The attributes to be set. Same as constructor options.

process

Processes the input value and returns the clipped value within the specified range.

Parameters

  • inputValue number The input value to be processed.

Returns number The clipped value within the specified range.

Hysteresis

Represents an Hysteresis filter.

Parameters

  • $0 Object (optional, default {})

    • $0.sampleRate (optional, default 2)
    • $0.lowpassFrequencyUp (optional, default 0.5)
    • $0.lowpassFrequencyDown (optional, default 0.5)
  • options Object? The options object.

Examples

// hysteresis with quick up and slow down
const hysteresis = new Hysteresis({
 sampleRate: 2, // normalised frequency
 lowpassFrequencyUp: 0.9,
 lowpassFrequencyDown: 0.1,
});

hysteresis.process(0); // 0
hysteresis.process(1); // 0.9
hyteresis.process(1); // 0.99
hysteresis.process(1); // 0.999
hysteresis.process(1); // 0.9999
hysteresis.process(1); // 0.99999
hysteresis.process(1); // 0.999999
hysteresis.process(0); // 0.899999
hysteresis.process(0); // 0.809999
hysteresis.process(0); // 0.728999
hysteresis.process(0); // 0.656099
hysteresis.process(0); // 0.590489

set

Sets the attributes of the Hysteresis filter.

Parameters

  • attributes Object The attributes to set. Same as constructor options.

init

Initializes the Hysteresis filter.

process

Processes the input value through the Hysteresis filter.

Parameters

  • inputValue number The input value to process.

Returns number The output value of the Hysteresis filter.

reset

Resets the Hysteresis filter.

Lowpass

Represents a Lowpass filter.

Parameters

  • $0 Object (optional, default {})

    • $0.sampleRate (optional, default 2)
    • $0.lowpassFrequency (optional, default 0.5)
  • options Object? The options object.

Examples

const lowpass = new Lowpass({
sampleRate: 2, // normalised frequency
lowpassFrequency: 0.9,
});

lowpass.process(0); // 0
lowpass.process(1); // 0.9
lowpass.process(1); // 0.99
lowpass.process(1); // 0.999
lowpass.process(1); // 0.9999
lowpass.process(1); // 0.99999
lowpass.process(1); // 0.999999

set

Sets the attributes of the Lowpass filter.

Parameters

  • attributes Object The attributes to set. Same as constructor options.

init

Initializes the Lowpass filter.

process

Processes the input value through the Lowpass filter.

Parameters

  • inputValue number The input value to process.

Returns number The filtered output value.

reset

Resets the Lowpass filter.

Scaler

Represents a Scaler that maps values from an input range to an output range.

Parameters

  • $0 Object (optional, default {})

    • $0.inputStart (optional, default 0)
    • $0.inputEnd (optional, default 1)
    • $0.outputStart (optional, default 0)
    • $0.outputEnd (optional, default 1)
    • $0.clip (optional, default false)
    • $0.type (optional, default 'linear')
    • $0.base (optional, default 1)
  • options Object? The options object.

Examples

// linear
const scaler = new Scaler({
  inputStart: 0,
  inputEnd: 10,
  outputStart: 0,
  outputEnd: 100,
});

scaler.process(5); // 50
scaler.process(0); // 0
scaler.process(10); // 100
// MIDI pitch to Hertz
const scaler = new Scaler({
  inputStart: 69,
  inputEnd: 81,
  outputStart: 440,
  outputEnd: 880,
  type: 'exponential',
  base: 2,
  clip: false,
});

scaler.process(69); // 440
scaler.process(81); // 880
scaler.process(72); // 523.251131
scaler.process(93); // 1760 (no clipping)
// decibel to amplitude
const scaler = new Scaler({
  inputStart: 0,
  inputEnd: 20,
  outputStart: 1,
  outputEnd: 10,
  type: 'exponential',
  base: 10,
  clip: false,
});

scaler.process(0); // 1
scaler.process(20); // 10
scaler.process(-20); // 0.1 (no clipping)

set

Set the scaler attributes.

Parameters

  • attributes Object The attributes to set. Same as constructor options.

init

Initialize the scaler.

process

Process the input value and return the scaled value.

Parameters

  • inputValue number The input value to scale.

Returns number The scaled output value.

License

BSD-3-Clause