SYNAESTHESIA v2.4 http://logarithmic.net/pfh/Synaesthesia
Synaesthesia is a program for representing sounds visually. It goes
beyond the usual oscilliscope style program by combining an FFT and
stereo positioning information to give a two dimensional display. Some
of the shapes I have observed are:
* Drums: clouds of color, fairly high
* Clean guitar: several horizontal lines, low down
* Rough guitar: a cloud, low down
* Trumpet: Lots of horizontal lines everywhere
* Flute: A single horizontal line, low down
* Voice: A vertical line with some internal structure
* Synthesizer: All kinds of weird shapes!
Synaesthesia represents frequency as the vertical position on screen,
and stereo position as the horizontal position. It can also understand
surround sound encoded music, and shows ambient noise in a different
Synaesthesia can run in a window in X, or full screen using SVGAlib,
or either using Simple DirectMedia Layer (SDL). Use of the SDL is
It can take input from a CD, line input, EsounD, or piped from another
program. As of version 2.2, EsounD support is much improved. For example,
Synaesthesia works well with XMMS if both use EsounD.
Synaesthesia should work on Linux and BSD systems. (Note: I don't have
access to a BSD system myself, I have to rely on patches -- if it doesn't
work, please tell me!)
For best results, first make sure you have installed the libraries and
the header files for these: (on most systems, this means installing the
appropriate "dev" packages)
* Simple DirectMedia Layer (SDL)
* EsounD (ESD)
Compile Synaesthesia by typing
then install it by typing
then you should be able to type
to run the program.
You will need to run Synaesthesia as root to run it full screen
with SVGAlib. Other varieties can be run by any user providing you
provide permissions on /dev/dsp, /dev/cdrom, and /dev/mixer.
Synaesthesia creates a configuration file named ~/.synaesthesia
to store settings such as brightness, color, and window size, as
well as which devices to use to control sound input.
BSD users will have to edit this file to set the CD-ROM device name
before using Synaesthesia in order to control the CD.
Run Synaesthesia with no parameters for further information on how to
Notes for code rippers
This program contains code that you may wish to use in your own projects.
If you want to, please do. (For example, you might want to add some
snazzy visual effects to your favourite MP3 or CD player)
The actual code to do the mapping from sound to visual display is
all in core.cc, it should be fairly easy to disentangle from other
parts of the program. It does make reference to some globals defined
in syna.h, namely the #defines LogSize (log2 of the sample size for each
frame) and Brightness, data (which stores the sound input), outputBmp,
lastOutputBmp and lastLastOutputBmp (which hold the output), outWidth
and outHeight (size of the bitmaps), and fadeMode, brightnessTwiddler,
starSize and pointsAreDiamonds (various parameters affecting the display).
The normal way to use it would be:
Call coreInit() to set up some look-up tables
Call setStarSize(starSize) to set up some more look-up tables
Put data into the data array
Call fade() to apply the fade/wave/heat effect to the output
Call coreGo() to add the next fragment of sound input to the output
Display contents of outputBmp to screen
There is a simple anti-aliased polygon drawing engine in the file
polygon.h. sound.cc contains code for driving the CD. xlib.c and
xlibwrap.cc contain code for setting up a window under X (originally
ripped from the Xaos fractal viewer program :-) ).
Feel free to email me me (Paul Harrison) at email@example.com with any
suggestions, bug-reports, or better yet, patches.
A number of other people have contributed to Synaesthesia:
Thanks to Asger Alstrup Nielsen for many great suggestions, and for
writing optimized 32 bit loops for fading and drawing to screen.
Thanks to Roger Knobbe for porting Synaesthesia to FreeBSD.
Thanks to Ben Gertzfield and Martin Mitchell for some small fixes to the
CD controlling code.
Thanks to Simon Budig for an improvement to the X code.
Thanks to Devin Carraway for fixing Synaesthesia to work with non-32-bit
Synaesthesia is distributed under the GPL.
1.1 - Added surround sound decoding.
1.2 - Fixed a bug in the ioctl calls to /dev/dsp.
1.3 - Asger Alstrup Nielsen's optimizations added.
Added X-Windows support.
More options, redesigned interface.
1.4 - Bug fixes, including a great reduction in
"Sound: Recording overrun" warnings.
New command line options: play lists and piping.
Support for SDL.
2.0 - Bug fixes: Fixed problem in xlib.c that caused occasional segfaults,
several endianness problems fixed.
New effects: Wave, heat, diamond shaped points.
Piping sound now longer requires the twiddle factor.
Yet another interface redesign.
Partial support for LinuxPPC (pipe mode only)
2.1 - Autoconf support.
Some code cleanup, now only makes one binary.
SDL version now sets title.
Bug fixes: Old versions of gcc can't cope with some of the stuff
I was doing with templates.
2.2 - Works on machines with non-32-bit words (patch by Devin Carraway)
Pipe and ESD modes greatly improved: it now syncs properly to the music
Resizable window with SDL
Fixes to autoconf of SDL
Clicking on window toggles full screen in SDL
Automatic brightness compensation
2.3 - Compiles with g++ 3.4
Tweaked sound code, should now work on fast computers
2.4 - Applied a patch by Aurelien Jarno that fixes some FreeBSD problems