<commit_before>C.A.V.A. 
====================

**C**onsole-based **A**udio **V**isualizer for **A**LSA

by [<NAME>](mailto:<EMAIL>)

![spectrum](https://cloud.githubusercontent.com/assets/5231746/7368413/7d7ca93e-ed9f-11e4-842f-61c54fc03dbe.gif "spectrum")

thanks to [anko](https://github.com/anko) for the gif, here is the [recipe]( http://unix.stackexchange.com/questions/113695/gif-screencastng-the-unix-way).

[Demo video](https://youtu.be/9PSp8VA6yjU)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [C.A.V.A. ](#cava)
  - [Updates](#updates)
  - [What it is](#what-it-is)
  - [Build requirements](#build-requirements)
  - [Getting started](#getting-started)
    - [Installing](#installing)
    - [Uninstalling](#uninstalling)
  - [Capturing audio](#capturing-audio)
    - [From loopback device](#from-loopback-device)
      - [PulseAudio (easy)](#pulseaudio-easy)
      - [ALSA (hard)](#alsa-hard)
    - [From mpd's fifo output](#from-mpds-fifo-output)
  - [Running via ssh](#running-via-ssh)
  - [Font notes](#font-notes)
    - [In ttys](#in-ttys)
    - [In terminal emulators](#in-terminal-emulators)
  - [Latency notes](#latency-notes)
  - [Usage](#usage)
    - [Controls](#controls)
  - [Configuration](#configuration)
    - [Example file:](#example-file)
    - [Sections:](#sections)
      - [[general]](#general)
      - [[input]](#input)
      - [[output]](#output)
      - [[color]](#color)
      - [[smoothing]](#smoothing)
      - [[eq]](#eq)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


Updates
-------

9/18/2015 - 0.3.5 - now in stereo!

8/25/2015 - 0.3.4 - added setting of bar width, bar spacing and frequency bandwidth to config file.

8/9/2015 - 0.3.3 - autodetection of alsa loopback interface

7/16/2015 - 0.3.2 - added legacy ouput mode 'noncurses', for people experiencing issues with ncurses

7/15/2015 - 0.3.1 - added config file

7/12/2015 - 0.3.0 - Modular source code

5/23/2015 - 0.2.0 - Switched to ncurses

4/23/2015 - Fixed terminal window resizing, added smoothing 

4/19/2015 - Added Monstercat style FFT easing (by [CelestialWalrus)](https://github.com/CelestialWalrus).

9/22/2014 - Added support for mpd FIFO input.

What it is
----------

C.A.V.A. is a bar spectrum analyzer for audio using ALSA for input. Its frequency range is limited to 50-10,000Hz. I know that the human ear can hear from 20 up to 20,000 Hz (and probably "sense" even higher frequencies), but the frequencies between 50-10,000Hz seem to me to be the most distinguishable. (I believe telephones used to be limited to as low as 8kHz.)

This program is not intended for scientific use.

This is my first published code. I am not a professional programmer so the source code is probably, by all conventions, a complete mess. Please excuse all the typos as I am both dyslexic and foreign.

Any tips or comments would be much appreciated.


Build requirements
------------------

* [ALSA dev files](http://alsa-project.org/)
* [FFTW](http://www.fftw.org/)
* [ncursesw dev files](http://www.gnu.org/software/ncurses/) (bundled in ncurses in arch)

This can be installed easily in all major distros:

Debian/Raspbian:

    apt-get install libfftw3-dev libasound2-dev libncursesw5-dev

ArchLinux:

    pacman -S base-devel fftw ncurses

openSUSE:

    zypper install alsa-devel ncurses-devel fftw3-devel


Getting started
---------------

    make

You can use the following for compilation options, value in *italic style* is the default value:

| Name | Value | Description |
| ---- | ----- | ----------- |
| `debug` | *0* or 1 | Debugging message switch |

For example, turning on debugging messages:

    make debug=1

### Installing manually

Install `cava` to default `/usr/local`:

    make install

Or you can change `PREFIX`, for example:

    make PREFIX=$HOME/.local install

### Uninstalling

    make uninstall

Or:

    make PREFIX=$HOME/.local uninstall

### openSUSE

On openSUSE you need to add jubalh's home repository to install cava via zypper. For example for Tumbleweed do:

    zypper ar -f http://download.opensuse.org/repositories/home:/jubalh/openSUSE_Tumbleweed/home:jubalh.repo
	zypper in cava

If you use 13.2 or 13.1 just replace *openSUSE_Tumbleweed* with *openSUSE_13.2*, adjust it to your version.

Capturing audio
---------------

### From loopback device

If you want to capture audio straight fom the output (not just mic or line-in), you must create an ALSA loopback interface, then output the audio simultaneously to both the loopback and your normal interface.

To create a loopback interface simply run:

`sudo modprobe snd_aloop`

Hopefully your `aplay -l` should now contain a loopback interface.

To make it presistent across boot add the line `snd-aloop` to "/etc/modules". To keep it form beeing loaded as the first soundcard add the line `options snd-aloop index=1` to "/etc/modprobe.d/alsa-base.conf", this will load it at '1' which is what cava uses as default. You can replace '1' with whatever makes most senes in your audio setup, but then cava must be specified to use that index. Simply pass the -d argument or alter the config file with the loopback interface index.

Playing the audio through your Loopback interface makes it possible for cava to to capture it, but there will be no sound in your speakers. :(

Not to worry! There are (at least) two ways of sending the audio output to the loopback *and* your actual audio interface at the same time:

#### PulseAudio (easy)

First create the loopback device as explained in the section above.

To `/etc/pulse/default.pa`, add the line `load-module module-combine-sink` (in PulseAudio versions <1.0, the module was only called `module-combine`). Then restart PulseAudio. For some reason, I had to turn off realtime scheduling for this to work on a Raspberry Pi (set `realtime-scheduling = no` in `/etc/pulse/daemon.conf`).
<commit_msg>added build requirements for Fedoare to resolve #77<commit_after>C.A.V.A. 
====================

**C**onsole-based **A**udio **V**isualizer for **A**LSA

by [<NAME>](mailto:<EMAIL>)

![spectrum](https://cloud.githubusercontent.com/assets/5231746/7368413/7d7ca93e-ed9f-11e4-842f-61c54fc03dbe.gif "spectrum")

thanks to [anko](https://github.com/anko) for the gif, here is the [recipe]( http://unix.stackexchange.com/questions/113695/gif-screencastng-the-unix-way).

[Demo video](https://youtu.be/9PSp8VA6yjU)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [C.A.V.A. ](#cava)
  - [Updates](#updates)
  - [What it is](#what-it-is)
  - [Build requirements](#build-requirements)
  - [Getting started](#getting-started)
    - [Installing](#installing)
    - [Uninstalling](#uninstalling)
  - [Capturing audio](#capturing-audio)
    - [From loopback device](#from-loopback-device)
      - [PulseAudio (easy)](#pulseaudio-easy)
      - [ALSA (hard)](#alsa-hard)
    - [From mpd's fifo output](#from-mpds-fifo-output)
  - [Running via ssh](#running-via-ssh)
  - [Font notes](#font-notes)
    - [In ttys](#in-ttys)
    - [In terminal emulators](#in-terminal-emulators)
  - [Latency notes](#latency-notes)
  - [Usage](#usage)
    - [Controls](#controls)
  - [Configuration](#configuration)
    - [Example file:](#example-file)
    - [Sections:](#sections)
      - [[general]](#general)
      - [[input]](#input)
      - [[output]](#output)
      - [[color]](#color)
      - [[smoothing]](#smoothing)
      - [[eq]](#eq)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


Updates
-------

9/18/2015 - 0.3.5 - now in stereo!

8/25/2015 - 0.3.4 - added setting of bar width, bar spacing and frequency bandwidth to config file.

8/9/2015 - 0.3.3 - autodetection of alsa loopback interface

7/16/2015 - 0.3.2 - added legacy ouput mode 'noncurses', for people experiencing issues with ncurses

7/15/2015 - 0.3.1 - added config file

7/12/2015 - 0.3.0 - Modular source code

5/23/2015 - 0.2.0 - Switched to ncurses

4/23/2015 - Fixed terminal window resizing, added smoothing 

4/19/2015 - Added Monstercat style FFT easing (by [CelestialWalrus)](https://github.com/CelestialWalrus).

9/22/2014 - Added support for mpd FIFO input.

What it is
----------

C.A.V.A. is a bar spectrum analyzer for audio using ALSA for input. Its frequency range is limited to 50-10,000Hz. I know that the human ear can hear from 20 up to 20,000 Hz (and probably "sense" even higher frequencies), but the frequencies between 50-10,000Hz seem to me to be the most distinguishable. (I believe telephones used to be limited to as low as 8kHz.)

This program is not intended for scientific use.

This is my first published code. I am not a professional programmer so the source code is probably, by all conventions, a complete mess. Please excuse all the typos as I am both dyslexic and foreign.

Any tips or comments would be much appreciated.


Build requirements
------------------

* [ALSA dev files](http://alsa-project.org/)
* [FFTW](http://www.fftw.org/)
* [ncursesw dev files](http://www.gnu.org/software/ncurses/) (bundled in ncurses in arch)

This can be installed easily in all major distros:

Debian/Raspbian:

    apt-get install libfftw3-dev libasound2-dev libncursesw5-dev

ArchLinux:

    pacman -S base-devel fftw ncurses

openSUSE:

    zypper install alsa-devel ncurses-devel fftw3-devel

Fedora:

    dnf install alsa-lib-devel ncurses-devel fftw3-devel
   

Getting started
---------------

    make

You can use the following for compilation options, value in *italic style* is the default value:

| Name | Value | Description |
| ---- | ----- | ----------- |
| `debug` | *0* or 1 | Debugging message switch |
| `SYSTEM_INIPARSER` | *0* or 1 | Allow use of system-wide iniparser |

For example, turning on debugging messages:

    make debug=1
    
System-wide iniparser is available for at least Arch, Fedore and Gentoo

### Installing manually

Install `cava` to default `/usr/local`:

    make install

Or you can change `PREFIX`, for example:

    make PREFIX=$HOME/.local install

### Uninstalling

    make uninstall

Or:

    make PREFIX=$HOME/.local uninstall

### openSUSE

On openSUSE you need to add jubalh's home repository to install cava via zypper. For example for Tumbleweed do:

    zypper ar -f http://download.opensuse.org/repositories/home:/jubalh/openSUSE_Tumbleweed/home:jubalh.repo
	zypper in cava

If you use 13.2 or 13.1 just replace *openSUSE_Tumbleweed* with *openSUSE_13.2*, adjust it to your version.

### Fedora

[RPM spec file](https://gist.github.com/sedrubal/617d40deb7452a25d004#file-cava-spec)

### Arch

Cava is in [AUR](https://aur.archlinux.org/packages/cava/), but is as of November 2015 slightly out of date.

    yaourt -S cava




Capturing audio
---------------

### From loopback device

If you want to capture audio straight fom the output (not just mic or line-in), you must create an ALSA loopback interface, then output the audio simultaneously to both the loopback and your normal interface.

To create a loopback interface simply run:

`sudo modprobe snd_aloop`

Hopefully your `aplay -l` should now contain a loopback interface.

To make it presistent across boot add the line `snd-aloop` to "/etc/modules". To keep it form beeing loaded as the first soundcard add the line `options snd-aloop index=1` to "/etc/modprobe.d/alsa-base.conf", this will load it at '1' which is what cava uses as default. You can replace '1' with whatever makes most senes in your audio setup, but then cava must be specified to use that index. Simply pass the -d argument or alter the config file with the loopback interface index.

Playing the audio through your Loopback interface makes it possible for cava to to capture it, but there will be no sound in your speakers. :(

Not to worry! There are (at least) two ways of sending the audio output to the loopback *and* your actual audio interface at the same time:

#### PulseAudio (easy)

First create the loopback device as explained in the section above.

To `/etc/pulse/default.pa`, add the line `load-module module-combine-sink` (in PulseAudio versions <1.0, the module was only called `module-combine`). Then restart PulseAudio. For some reason, I had to turn off realtime scheduling for this to work on a Raspberry Pi (set `realtime-scheduling = no` in `/etc/pulse/daemon.conf`).

{'fraction_non_alphanumeric': 0.1262258778867447, 'fraction_numerical': 0.029183802594115786, 'mean_word_length': 3.488817891373802, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 12, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '388115', 'n_tokens_mistral': 4443, 'n_tokens_neox': 3991, 'n_words': 1461}