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

shared-utils

v2.0.1

Published

contains useful utilities to read/write WAV file to/from a buffer, various float to int conversions, 32 bit float to 16 bit int conversion, random number generator for ints or floats in which optionally uses same random sequence across runs

Downloads

1,928

Readme

shared-utils

Contains useful utilities like random number generator for ints or floats in min - max range inclusive

Available at https://github.com/scottstensland/shared-utils

synthesize an audio buffer with random noise OR sinusoidal curve


// ------------  populate buffer with sin curve ------------  //

// var SIZE_BUFFER_SOURCE = 5;
var SIZE_BUFFER_SOURCE = 256;
// var SIZE_BUFFER_SOURCE = 4096;
// var SIZE_BUFFER_SOURCE = 16384;

var samples_per_cycle = 64;

var source_obj = {}; // we populate its buffer then save to output WAV file 
var target_obj = {}; // then read back WAV file to populate this target buffer then do curve diff to confirm curves match

source_obj = audio_utils.pop_audio_buffer(SIZE_BUFFER_SOURCE, samples_per_cycle);

synthesize an audio buffer with random noise


var shared_utils = require("shared-utils");
var path = require('path');

shared_utils.set_random_seed(17); // comment out if U want fresh random sequence for each run 
                                  // otherwise random sequence repeats across subsequent runs of this script

var SIZE_BUFFER_SOURCE = 256;

var source_obj = {}; // we populate its buffer with random float values then save to output WAV file 

source_obj.buffer = new Float32Array(SIZE_BUFFER_SOURCE);

var max_index = SIZE_BUFFER_SOURCE;

for (var index = 0; index < max_index; index++) {

    source_obj.buffer[index] = shared_utils.get_random_in_range_inclusive_float(-1.0, 1.0);

    // console.log(index, " pop_audio_buffer ", source_obj.buffer[index]);
}

write typed array 32 bit float buffer (Float32Array) to output file WAV format 16 bit precision


var output_dir = process.argv[2] || "/tmp";
var output_format = ".wav";
var source_wave = "source_wave_shared_utils_test";
var source_wave_filename = path.join(output_dir, source_wave + output_format);

shared_utils.write_32_bit_float_buffer_to_16_bit_wav_file(source_obj, source_wave_filename);