# numm

For programmers familiar with python or matlab who are interested in
toying with the sounds and images around them; for artists, designers,
and composers seeking a deeper understanding of the numerical systems
that underlie modern media production.

numm is a minimalist media library that translates popular sound,
image, and video formats to and from numpy arrays. By coercing inputs
into common modes (eg. sample rate, bit depth), combining and mutating
these numpy arrays is greatly simplified.

The general strategy for these functions is to make any assumptions
necessary such that a single array of numbers provides sufficient
information with which to reconstruct a media file, without any
additional metadata. For example, width and height are contained in
the dimensions of an array, so they may be different image to image,
but framerate, samplerate, &c is not inherent to the data, so it
should be made uniform unless explicitly specified.

In the transition from an image to an array, the primary
considerations are resolution (wxh) and mode (RGB, RGBA, 8bit, 16bit,
&c). We choose not to provide any special API for resampling an
Image--this can be done with numpy if desired--and always return 8bit
RGB buffers.

image2np(path)
np2image(np, path)

In the case of audio, we choose to force all input to 44100Hz stereo.

sound2np(path)
np2sound(np, path)

Video is an array of wxhx3 arrays 30frames per second. Square pixels
are assumed.

video2np(path)
np2video(np, path)

Note that in particular in the case of video, these numpy buffers will
require a considerable amount of memory; preprocess accordingly (eg in
ffmpeg). We should also raise a NotEnoughMemory exception when RAM
will not hold our buffer.

The live interface is provided by numpy.run.run(), a function with
just a few input-output controls, communicated through function
passing.

## Requirements

 - PyGst
 - PIL

Recommended:

 - OpenCV (required for async display on Mac and Windows)

## Installation

Debian/Ubuntu:
1. sudo apt-get install python-numm

Mac OSX:

1. Install PIL
   % easy_install pip
   % pip install PIL
2. Install Homebrew
   https://github.com/mxcl/homebrew/wiki/installation
3. Add some extra "formulas"

curl -o $(brew --prefix)/Library/Formula/pycairo.rb \
    https://raw.github.com/jodal/homebrew/gst-python/Library/Formula/pycairo.rb
curl -o $(brew --prefix)/Library/Formula/pygobject.rb \
    https://raw.github.com/jodal/homebrew/gst-python/Library/Formula/pygobject.rb
curl -o $(brew --prefix)/Library/Formula/pygtk.rb \
    https://raw.github.com/jodal/homebrew/gst-python/Library/Formula/pygtk.rb
curl -o $(brew --prefix)/Library/Formula/gst-python.rb \
    https://raw.github.com/jodal/homebrew/gst-python/Library/Formula/gst-python.rb

(see http://docs.mopidy.com/en/latest/installation/gstreamer/)

4. brew install opencv gst-python gst-plugins-good gst-plugins-ugly
5. Install numm!

Windows:

1. Download and install the 32-bit version of Python 2.6
   http://www.python.org/download/releases/2.6.6/
2. Install the Python Imaging library
   http://www.pythonware.com/products/pil/
3. Install PyGTK from the all-in-one installer
   http://www.pygtk.org/downloads.html
4. Install an old version of Gstreamer from OSSBuilds
   http://code.google.com/p/ossbuild/downloads/list
  (GStreamer-WinBuilds-GPL-x86.msi & GStreamer-WinBuilds-SDK-GPL-x86.msi)
   http://gstreamer.com is promising, but I couldn't get it to work
5. Download and install the Numpy Superpack
   http://scipy.org/Download
6. Download OpenCV
   https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.0/
   extract to C:\opencv
   & get your hands dirty in the registry
   http://thompsonng.blogspot.nl/2011/09/python-install-opencv-231-for-window.html
   (I set both PATH and PYTHONPATH here)
7. Install numm!


## Licence

Copyright (C) 2011-2012, Dafydd Harries <daf@numm.org>
Copyright (C) 2011-2012, Robert Ochshorn <rmo@numm.org>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
