Skip to content

Commit

Permalink
fix smoothing for template with length != 4
Browse files Browse the repository at this point in the history
  • Loading branch information
wizgrav committed Jan 31, 2017
1 parent cc3dd97 commit f51211e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
.DS_Store
.cache
.vscode
*.swp
build
gh-pages/
Expand Down
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

8 changes: 4 additions & 4 deletions README.md
@@ -1,7 +1,7 @@
clubber
========

A javascript library that analyzes the frequency data from an audio source and extracts the underlying rhythmic information. Instead of a linear distribution, frequency energies are collected in midi note bins which music theory suggests to be a better segregation for music audio. Several measurements are performed and a small collection of useful metrics are produced in a form suitable for direct use in webgl shaders, or any other context. This simple flow provides a powerful framework for the rapid development of visualisations that react pleasantly to the audio.
A javascript library to analyze the frequency data from audio sources and extract the underlying rhythmic information. Instead of a linear distribution, frequency energies are collected in midi note bins which music theory suggests to be a better segregation for music audio. A small collection of meaningful measurements are produced in a form suitable for direct use in webgl shaders, or any other context. This simple flow provides a powerful framework for the rapid development of visualisations that react pleasantly to the audio.

[ClubberToy](http://wizgrav.github.io/clubber/) - A collection of several rewired shadertoys as a vjing tool.

Expand Down Expand Up @@ -77,11 +77,11 @@ The output can be customized with the **template** property. This accepts a stri
* 8 - Adaptive low threshold relative to absolute limits
* 9 - Adaptive high threshold relative to absolute limits

If a **template** is not specified it defaults is **0123**, the first four measurements from the collection. The length of the string | array provided to template defines the size of the resulting vector and the internally used Float32Array.
If a **template** is not specified it defaults is **0123**, the first four measurements from the collection. The length of the string | array provided as the template defines the size of the resulting vector and the internally used Float32Array.

Bands also provide exponential smoothing for their output values which is controlled by the **smooth** option. This takes a 4 element array of normalized floats as factors for the smoothing of each respective measurement. A value of 1 means instant change and as it goes down to 0 it smooths more.
Bands also provide exponential smoothing for the measurements which is controlled by the **smooth** option. This takes an element array of normalized floats, same length as the template property, to use as factors for the smoothing of each respective measurement. A value of 1 means instant change and as it goes down to 0 it smooths more.

A negative value for an element activates the snap mode. In this mode when the energy rises it gets smoothed by the factor define as the **snap** option which should normally be fast (default is 0.33 which is pretty fast) and when falling, it instead uses the abs(value) as the factor. This comes in handy for eg kicks which you would want to rise fast but slowly fade down, so you would use something like -0.1 or something like that. There's a single **snap** factor for all measurements of the object and it can be overriden in the options.
A negative value for an element activates the snap mode. In this mode when the energy rises it gets smoothed by the factor defined as the **snap** option which should normally be fast (default is 0.33 which is pretty fast) and when falling, it instead uses the abs(value) as the factor. This comes in handy for eg kicks which you would want to rise fast but slowly fade down, so you would use something like -0.1 or something like that. There's a single **snap** factor for all measurements of the object and it can be overriden in the options.

```javascript
var band = clubber.band({ // clubber here is the instantiated object from above
Expand Down
3 changes: 2 additions & 1 deletion dist/clubber.js
Expand Up @@ -45,7 +45,7 @@
/***/ function(module, exports) {

/*
* clubber.js 1.4.2 Copyright (c) 2016-2017, Yannis Gravezas All Rights Reserved.
* clubber.js 1.4.3 Copyright (c) 2016-2017, Yannis Gravezas All Rights Reserved.
* Available via the MIT license. Check http://github.com/wizgrav/clubber for info.
*/

Expand Down Expand Up @@ -212,6 +212,7 @@
// Exponential smoothing. When negative: snap is used when value rises and abs(value) when falling.
function smoothFn (v, o, f, snap){
v = !v ? 0 : v;
f = f === undefined ? 0.1 : f;
f = Math.min(f, snap);
if (f < 0) { f = v > o ? Math.abs(snap) : -f; }
return f * v + (1 - f) * o;
Expand Down
2 changes: 1 addition & 1 deletion dist/clubber.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f51211e

Please sign in to comment.