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

clubberize

v1.2.0

Published

Converts clubber tool modulators from glsl to js.

Downloads

9

Readme

clubberize

A helper lib complementing Clubber Tool to enable easy use of Clubber in js apps, webgl or other. Think of it like a set of vibrating crystals that you can slot in and effortlessly animate your graphics to the tune of music.

Usage

Downloads

To embed this library in your project, include this file (after clubber.js):

For the unminified version for local development (with source maps), include this file:

Instructions

Clubber Tool tool can export its state using long urls that contain a full serialization of its config. Patches made with the tool provide up to 4 modulators using processors defined in the glsl fields. Glsl makes sense for applying the vectorization technique described in the clubber readme but limits the reuse of the modulators themselves.

Clubberize utilizes the awesome glsl-transpiler to convert the rhythm detecting glsl to pure js. A patch from the tool is wrapped in a closure that should be called every render frame to provide the current values of the 4 modulators for the patch in the form of a 4 element array of floats. These values can then be used in js apps, without the need for webgl.

You can check an example in codepen Another example


// Clubber itself is not part of clubberize so it needs to be setup on it's own.
var clubber = new Clubber();

clubber.listen(document.querySelector("audio"));

// The closure is instantiated by passing the whole state url obtained from clubber tool.
var mods = Clubberize(clubber, "https://wizgrav.github.io/clubber/tool/?tool=1&t0=6234&r0=3,36,64,128&s0=0.1,0.1,0.1,0.1...");

function render (time) {
  window.requestAnimationFrame(render);  

  // Clubber update is separate so we can have one parent and multiple modulator packs
  clubber.update();

  // Time is passed as seconds to simulate shadertoy's iGlobalTime uniform, in case it is used by modulators.
  var data = mods(time/1000);

  // The values from the 4 modulators will be contained in the data array.
  console.log(data);
}

render(0)

A closure generated from a clubber tool url is a parent closure. Further processing on top of the parent closure's modulators is possible. If a string is provided as the first argument when calling the parent closure, it will be interpreted as a glsl oneliner and a new child closure will be returned instead of the current modulator values.

Calling this closure will automatically update the parent closure's bands and modulator values. the oneliner can access these values as a vec4 "data" uniform( there's also a float "time" uniform available). The second argument specifies the type that the oneliner evaluates to. The type defaults to "float" (for when the oneliner returns a single number) but can, and should, be any glsl type that the oneliner evaluates to like "vec3" which will be returned as an array with 3 elements etc.

The child closures compute and return their oneliner's value instead of the original modulator values. As long as the time provided as the first argument remains the same, the internal clubber bands will only be computed once and cached for the parent and all its child closures.


// The closure is instantiated by passing the whole state url obtained from clubber tool.
var mods = Clubberize(clubber, "https://wizgrav.github.io/clubber/tool/?tool=1&t0=6234&r0=3,36,64,128&s0=0.1,0.1,0.1,0.1...");

// You can have multiple child closures all accessing the same modulators
var filtered1 = mods("mix(data.x, data.y, data.z)", "float");
var filtered2 = mods("vec2(sin(time + data.x), cos(time + data.y))", "vec2");

function render (time) {
  window.requestAnimationFrame(render);  

  // Clubber update is separate so we can have one parent and multiple modulator packs
  clubber.update();

  // No need to call the original as the child closure will automatically update the modulators. 
  // var data = mods(time/1000);

  var float1 = filtered1(time/1000);
  var array2 = filtered2(time/1000);

  console.log(float1, array2);
}

render(0)

License

This program is free software and is distributed under an MIT License.