From 904f2e87fc314da419ce59319f242cbff4031296 Mon Sep 17 00:00:00 2001 From: CelestialWalrus Date: Sun, 19 Apr 2015 04:45:33 -0400 Subject: [PATCH] Added FFT easing (Monstercat style) --- README.md | 12 ++++++++++-- cava.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 87ee6fe..b9b8194 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -C.A.V.A. -======== +C.A.V.A. - CW's fork +==================== **C**onsole-based **A**udio **V**isualizer for **A**LSA @@ -13,6 +13,7 @@ by [Karl Stavestrand](mailto:karl@stavestrand.no) Updates ------- +4/19/2015 - Added Monstercat style FFT easing. 9/22/2014 - Added support for mpd FIFO input. What it is @@ -26,6 +27,10 @@ This is my first published code. I am not a professional programmer so the sourc Any tips or comments would be much appreciated. +TODO +---- + +* make cava react to terminal resizing Build requirements ------------------ @@ -37,6 +42,9 @@ Debian/Raspbian users can install this with: apt-get install libfftw3-dev libasound2-dev +ArchLinux users can install this with: + + pacman -S base-devel fftw Getting started --------------- diff --git a/cava.c b/cava.c index 5564046..7b3a422 100644 --- a/cava.c +++ b/cava.c @@ -5,6 +5,10 @@ #include #include #define PI 3.14159265358979323846 +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) #include #include #include @@ -502,6 +506,17 @@ int main(int argc, char **argv) continue; } + /* MONSTERCAT STYLE EASING BY CW !aFrP90ZN26 */ + int z, m_y; + for (z = 0; z < bands; z++) { + for (m_y = z-1; m_y >= 0; m_y--) { + f[m_y] = max(f[z]/pow(2, z-m_y), f[m_y]); + } + for (m_y = z+1; m_y < bands; m_y++) { + f[m_y] = max(f[z]/pow(2, m_y-z), f[m_y]); + } + } + //**DRAWING**// -- put in function file maybe? if (debug == 0) { for (n = (height - 1); n >= 0; n--) {