Personal tools
Namespaces

Variants
Actions

Libvisual

From NiftyWiki
Jump to: navigation, search
Home Documentation Download Support Showroom Links

Using niftyled with libvisual for LED audio visualization. While we could develop a custom application that takes graphics generated by libvisual and feed it into niftyled in order to put it onto a LED setup, we'll take a shortcut by using ledcat and lv-tool.


lv-tool

Libvisual comes with "lv-tool", a commandline utility that acts as minimal libvisual application:

# lv-tool --help
lv-tool - libvisual-0.5.0 (35d1d56) commandline tool - http://libvisual.org
Usage: lv-tool [options]

Valid options:
	--help              -h          This help text
	--plugin-help       -p          List of installed plugins + information
	--verbose           -v          Increase verbosity (use multiple times for more effect)
	--dimensions <wxh>  -D <wxh>    Request dimensions from display driver (no guarantee) [320x200]
	--depth <depth>     -c <depth>  Set output colour depth (automatic by default)
	--driver <driver>   -d <driver> Use this output driver [sdl]
	--input <input>     -i <input>  Use this input plugin [debug]
	--actor <actor>     -a <actor>  Use this actor plugin [lv_analyzer]
	--morph <morph>     -m <morph>  Use this morph plugin [slide_left]
	--seed <seed>       -s <seed>   Set random seed
	--fps <n>           -f <n>      Limit output to n frames per second (if display driver supports it) [30]
	--framecount <n>    -F <n>      Output n frames, then exit.
	--exclude <actors>  -x <actors> Provide a list of actors to exclude.

Available output drivers:
	sdl
	stdout_sdl
	stdout


ledcat

Ledcat takes graphic data and uses libniftyled to display it on an LED setup:

Send image to LED hardware - http://wiki.niftylight.de/ledcat
Usage: ledcat [options] <file(s)>

Choose "-" as <file> to read from stdin

Valid options:
	--help                  -h          This help text
	--plugin-help           -p          List of installed plugins + information
	--config <file>         -c <file>   Load this prefs file [~/.ledcat.xml]
	--no-cache              -n          Don't use frame cache [off]
	--dimensions <w>x<h>    -d <w>x<h>  Define width and height of input frames. [auto]
	--big-endian            -b          RAW data is big-endian ordered [off]
	--loop                  -L          Don't exit after last file but start over with first [off]
	--fps <n>               -F <n>      Framerate to play multiple frames at. (Ignored when --signal is used) [25]
	--raw                   -r          Treat input files as raw-files (false)
	--format <format>       -f <format> Pixelformat of raw frame - doesn't have effect without --raw. (s. http://gegl.org/babl/ for supported formats)
	--loglevel <level>      -l <level>  Only show messages with loglevel <level> (info)


Valid loglevels:
	verynoisy noisy debug verbose info notice warning error 


config

For this example, we'll use a small 8x8 pixel setup to keep it simple. The LED-setup_XML in our case looks like this:


Niftyconf 8x8.png


<?xml version="1.0" encoding="UTF-8"?>
<niftyled>
  <hardware name="niftylino01" plugin="niftylino" id="*" stride="16">
    <chain ledcount="192" pixel_format="BGR u8"/>
    <tile x="0" y="0" width="8" height="8" pivot_x="4,000000" pivot_y="4,000000" rotation="180,000000">
      <tile x="0" y="0" width="4" height="4" pivot_x="2,000000" pivot_y="2,000000" rotation="0,000000">
        <chain ledcount="48" pixel_format="RGB u8">
          <led x="1" y="3" gain="0" component="1"/>
          <led x="3" y="3" gain="0" component="1"/>
          <led x="2" y="2" gain="0" component="1"/>
          <led x="3" y="2" gain="0" component="1"/>
          <led x="3" y="1" gain="0" component="1"/>
          <led x="2" y="1" gain="0" component="1"/>
          <led x="3" y="0" gain="0" component="1"/>
          <led x="2" y="0" gain="0" component="1"/>
          <led x="1" y="0" gain="0" component="1"/>
          <led x="0" y="0" gain="0" component="1"/>
          <led x="1" y="1" gain="0" component="1"/>
          <led x="0" y="1" gain="0" component="1"/>
          <led x="0" y="2" gain="0" component="1"/>
          <led x="1" y="2" gain="0" component="1"/>
          <led x="0" y="3" gain="0" component="1"/>
          <led x="2" y="3" gain="0" component="1"/>
          <led x="1" y="3" gain="0" component="0"/>
          <led x="3" y="3" gain="0" component="0"/>
          <led x="2" y="2" gain="0" component="0"/>
          <led x="3" y="2" gain="0" component="0"/>
          <led x="3" y="1" gain="0" component="0"/>
          <led x="2" y="1" gain="0" component="0"/>
          <led x="3" y="0" gain="0" component="0"/>
          <led x="2" y="0" gain="0" component="0"/>
          <led x="1" y="0" gain="0" component="0"/>
          <led x="0" y="0" gain="0" component="0"/>
          <led x="1" y="1" gain="0" component="0"/>
          <led x="0" y="1" gain="0" component="0"/>
          <led x="0" y="2" gain="0" component="0"/>
          <led x="1" y="2" gain="0" component="0"/>
          <led x="0" y="3" gain="0" component="0"/>
          <led x="2" y="3" gain="0" component="0"/>
          <led x="1" y="3" gain="0" component="2"/>
          <led x="3" y="3" gain="0" component="2"/>
          <led x="2" y="2" gain="0" component="2"/>
          <led x="3" y="2" gain="0" component="2"/>
          <led x="3" y="1" gain="0" component="2"/>
          <led x="2" y="1" gain="0" component="2"/>
          <led x="3" y="0" gain="0" component="2"/>
          <led x="2" y="0" gain="0" component="2"/>
          <led x="1" y="0" gain="0" component="2"/>
          <led x="0" y="0" gain="0" component="2"/>
          <led x="1" y="1" gain="0" component="2"/>
          <led x="0" y="1" gain="0" component="2"/>
          <led x="0" y="2" gain="0" component="2"/>
          <led x="1" y="2" gain="0" component="2"/>
          <led x="0" y="3" gain="0" component="2"/>
          <led x="2" y="3" gain="0" component="2"/>
        </chain>
      </tile>
      <tile x="4" y="0" width="4" height="4" pivot_x="2,000000" pivot_y="2,000000" rotation="90,000000">
        <chain ledcount="48" pixel_format="RGB u8">
          <led x="1" y="3" gain="0" component="1"/>
          <led x="3" y="3" gain="0" component="1"/>
          <led x="2" y="2" gain="0" component="1"/>
          <led x="3" y="2" gain="0" component="1"/>
          <led x="3" y="1" gain="0" component="1"/>
          <led x="2" y="1" gain="0" component="1"/>
          <led x="3" y="0" gain="0" component="1"/>
          <led x="2" y="0" gain="0" component="1"/>
          <led x="1" y="0" gain="0" component="1"/>
          <led x="0" y="0" gain="0" component="1"/>
          <led x="1" y="1" gain="0" component="1"/>
          <led x="0" y="1" gain="0" component="1"/>
          <led x="0" y="2" gain="0" component="1"/>
          <led x="1" y="2" gain="0" component="1"/>
          <led x="0" y="3" gain="0" component="1"/>
          <led x="2" y="3" gain="0" component="1"/>
          <led x="1" y="3" gain="0" component="0"/>
          <led x="3" y="3" gain="0" component="0"/>
          <led x="2" y="2" gain="0" component="0"/>
          <led x="3" y="2" gain="0" component="0"/>
          <led x="3" y="1" gain="0" component="0"/>
          <led x="2" y="1" gain="0" component="0"/>
          <led x="3" y="0" gain="0" component="0"/>
          <led x="2" y="0" gain="0" component="0"/>
          <led x="1" y="0" gain="0" component="0"/>
          <led x="0" y="0" gain="0" component="0"/>
          <led x="1" y="1" gain="0" component="0"/>
          <led x="0" y="1" gain="0" component="0"/>
          <led x="0" y="2" gain="0" component="0"/>
          <led x="1" y="2" gain="0" component="0"/>
          <led x="0" y="3" gain="0" component="0"/>
          <led x="2" y="3" gain="0" component="0"/>
          <led x="1" y="3" gain="0" component="2"/>
          <led x="3" y="3" gain="0" component="2"/>
          <led x="2" y="2" gain="0" component="2"/>
          <led x="3" y="2" gain="0" component="2"/>
          <led x="3" y="1" gain="0" component="2"/>
          <led x="2" y="1" gain="0" component="2"/>
          <led x="3" y="0" gain="0" component="2"/>
          <led x="2" y="0" gain="0" component="2"/>
          <led x="1" y="0" gain="0" component="2"/>
          <led x="0" y="0" gain="0" component="2"/>
          <led x="1" y="1" gain="0" component="2"/>
          <led x="0" y="1" gain="0" component="2"/>
          <led x="0" y="2" gain="0" component="2"/>
          <led x="1" y="2" gain="0" component="2"/>
          <led x="0" y="3" gain="0" component="2"/>
          <led x="2" y="3" gain="0" component="2"/>
        </chain>
      </tile>
      <tile x="4" y="4" width="4" height="4" pivot_x="2,000000" pivot_y="2,000000" rotation="180,000000">
        <chain ledcount="48" pixel_format="RGB u8">
          <led x="1" y="3" gain="0" component="1"/>
          <led x="3" y="3" gain="0" component="1"/>
          <led x="2" y="2" gain="0" component="1"/>
          <led x="3" y="2" gain="0" component="1"/>
          <led x="3" y="1" gain="0" component="1"/>
          <led x="2" y="1" gain="0" component="1"/>
          <led x="3" y="0" gain="0" component="1"/>
          <led x="2" y="0" gain="0" component="1"/>
          <led x="1" y="0" gain="0" component="1"/>
          <led x="0" y="0" gain="0" component="1"/>
          <led x="1" y="1" gain="0" component="1"/>
          <led x="0" y="1" gain="0" component="1"/>
          <led x="0" y="2" gain="0" component="1"/>
          <led x="1" y="2" gain="0" component="1"/>
          <led x="0" y="3" gain="0" component="1"/>
          <led x="2" y="3" gain="0" component="1"/>
          <led x="1" y="3" gain="0" component="0"/>
          <led x="3" y="3" gain="0" component="0"/>
          <led x="2" y="2" gain="0" component="0"/>
          <led x="3" y="2" gain="0" component="0"/>
          <led x="3" y="1" gain="0" component="0"/>
          <led x="2" y="1" gain="0" component="0"/>
          <led x="3" y="0" gain="0" component="0"/>
          <led x="2" y="0" gain="0" component="0"/>
          <led x="1" y="0" gain="0" component="0"/>
          <led x="0" y="0" gain="0" component="0"/>
          <led x="1" y="1" gain="0" component="0"/>
          <led x="0" y="1" gain="0" component="0"/>
          <led x="0" y="2" gain="0" component="0"/>
          <led x="1" y="2" gain="0" component="0"/>
          <led x="0" y="3" gain="0" component="0"/>
          <led x="2" y="3" gain="0" component="0"/>
          <led x="1" y="3" gain="0" component="2"/>
          <led x="3" y="3" gain="0" component="2"/>
          <led x="2" y="2" gain="0" component="2"/>
          <led x="3" y="2" gain="0" component="2"/>
          <led x="3" y="1" gain="0" component="2"/>
          <led x="2" y="1" gain="0" component="2"/>
          <led x="3" y="0" gain="0" component="2"/>
          <led x="2" y="0" gain="0" component="2"/>
          <led x="1" y="0" gain="0" component="2"/>
          <led x="0" y="0" gain="0" component="2"/>
          <led x="1" y="1" gain="0" component="2"/>
          <led x="0" y="1" gain="0" component="2"/>
          <led x="0" y="2" gain="0" component="2"/>
          <led x="1" y="2" gain="0" component="2"/>
          <led x="0" y="3" gain="0" component="2"/>
          <led x="2" y="3" gain="0" component="2"/>
        </chain>
      </tile>
      <tile x="0" y="4" width="4" height="4" pivot_x="2,000000" pivot_y="2,000000" rotation="270,000000">
        <chain ledcount="48" pixel_format="RGB u8">
          <led x="1" y="3" gain="0" component="1"/>
          <led x="3" y="3" gain="0" component="1"/>
          <led x="2" y="2" gain="0" component="1"/>
          <led x="3" y="2" gain="0" component="1"/>
          <led x="3" y="1" gain="0" component="1"/>
          <led x="2" y="1" gain="0" component="1"/>
          <led x="3" y="0" gain="0" component="1"/>
          <led x="2" y="0" gain="0" component="1"/>
          <led x="1" y="0" gain="0" component="1"/>
          <led x="0" y="0" gain="0" component="1"/>
          <led x="1" y="1" gain="0" component="1"/>
          <led x="0" y="1" gain="0" component="1"/>
          <led x="0" y="2" gain="0" component="1"/>
          <led x="1" y="2" gain="0" component="1"/>
          <led x="0" y="3" gain="0" component="1"/>
          <led x="2" y="3" gain="0" component="1"/>
          <led x="1" y="3" gain="0" component="0"/>
          <led x="3" y="3" gain="0" component="0"/>
          <led x="2" y="2" gain="0" component="0"/>
          <led x="3" y="2" gain="0" component="0"/>
          <led x="3" y="1" gain="0" component="0"/>
          <led x="2" y="1" gain="0" component="0"/>
          <led x="3" y="0" gain="0" component="0"/>
          <led x="2" y="0" gain="0" component="0"/>
          <led x="1" y="0" gain="0" component="0"/>
          <led x="0" y="0" gain="0" component="0"/>
          <led x="1" y="1" gain="0" component="0"/>
          <led x="0" y="1" gain="0" component="0"/>
          <led x="0" y="2" gain="0" component="0"/>
          <led x="1" y="2" gain="0" component="0"/>
          <led x="0" y="3" gain="0" component="0"/>
          <led x="2" y="3" gain="0" component="0"/>
          <led x="1" y="3" gain="0" component="2"/>
          <led x="3" y="3" gain="0" component="2"/>
          <led x="2" y="2" gain="0" component="2"/>
          <led x="3" y="2" gain="0" component="2"/>
          <led x="3" y="1" gain="0" component="2"/>
          <led x="2" y="1" gain="0" component="2"/>
          <led x="3" y="0" gain="0" component="2"/>
          <led x="2" y="0" gain="0" component="2"/>
          <led x="1" y="0" gain="0" component="2"/>
          <led x="0" y="0" gain="0" component="2"/>
          <led x="1" y="1" gain="0" component="2"/>
          <led x="0" y="1" gain="0" component="2"/>
          <led x="0" y="2" gain="0" component="2"/>
          <led x="1" y="2" gain="0" component="2"/>
          <led x="0" y="3" gain="0" component="2"/>
          <led x="2" y="3" gain="0" component="2"/>
        </chain>
      </tile>
    </tile>
  </hardware>
</niftyled>


The file can be saved as ~/.ledcat.xml (or anything else when the -c option of ledcat is used to point to that file.)

put it all together

When all hardware is connected and ready to use, run:

lv-tool -c 24 -D 8x8 -d stdout_sdl -i alsa | ledcat -r -F 999 -c 8x8.xml -

to pipe lv-tool output into ledcat.


lv-tool options explained:

  • -c 24 since we want 24bpp in this case
  • -D 8x8 to tell lv-tool to generate 8x8 pixels
  • -d stdout_sdl to output raw data on stdout using SDL (this way, GL actors can also be used which is not possible with the "stdout" driver of lv-tool)
  • -i alsa to choose alsa as source of sound - don't forget to put your desired channel into recording mode using some mixer tool like alsamixer (you can also use different input plugins from libvisual like pulseaudio or jack etc.)


ledcat options explained:

  • -r to tell ledcat to interpret incoming data as RAW data
  • -F 999 since lv-tool controls the framerate, so ledcat doesn't need to do that (it would use its default value otherwise)
  • -c 8x8.xml This is the configuration file to use. We could also copy the file to ~/.ledcat.xml which ledcat tries to use by default.
  • - tells ledcat to read from stdin


demo videos

These are some examples of how it could look like: