Welcome to matriz’s documentation!

Contents:

Matriz

https://badge.fury.io/py/matriz.png

Matriz is a Networked Music Performance software. The intended use is allowing real time musical performance of artists in different locations through computer networks. The name “matriz” is portuguese for “matrix” and is inspired on the light and sound matrixes used in music and theater settings.

Why?

  • Tools like jacktrip are built to work in high bandwidth academic networks like the internet2 or GEANT networks. Matriz is built to offer the lowest latencies possible, while using the least bandwidth possible. This allows musicians to have low latency high quality music streaming using regular network connections.
  • For fun.

Features

What?

The software is composed of two components, the client and the configuration server. The client connects to the server over websockets and receives a list of all connected clients. After starting it’s own RTSP stream with audio from the sound card, it spawns an RTSP client for all connected clients, forming a P2P streaming network. For all connection or disconnection events, the client list is broadcasted to all connected clients, which open or close new RTSP clients as necessary. Audio is encoded with the OPUS codec, which allows for low bandwidth use and high quality sound, while keeping the latency to a minimum.

The system was used several times in live peformances, with three three groups of musicians. Distances between groups ranged from tens of meters (same building) to 150 to 400 km in the final performance. The hardware used was a Raspberry pi 2 with a Focusrite Scarlet 2i2 USB sound card. The resulting streams where broadcasted live at http://stress.fm. More information, including recordings of the performances, can be obtained at the project website: http://matriz.stress.fm. For any inquiries concerning the software or the project, contact us at info@stress.fm.

Installation

Prerequisites

In both cases external dependencies must be installed for the program to work. For the client:

  • Jack
  • GStreamer, including the gst-rtsp-server package and Pyhton bindings
  • Python bindings for gobject-introspection libraries

These can be installed in Debian or Rapsbian whith the following command:

$ echo "deb http://matriz.stress.fm/deb_repo jessie main" | sudo tee /etc/apt/sources.list.d/matriz.list
$ curl http://matriz.stress.fm/deb_repo/matriz_deb.gpg.asc | sudo apt-key add -
$ sudo apt-get update

$ sudo apt-get install -y python-pip\
                     jackd2 \
                     python-gst-1.0 \
                     python-gi \
                     libgstrtspserver-1.0-0 \
                     gstreamer1.0-plugins-bad \
                     libgstreamer-plugins-bad1.0 \
                     gir1.2-gst-rtsp-server-1.0 \
                     python-dev \
                     libffi-dev

# For the PI

$ curl https://raw.githubusercontent.com/stressfm/matriz/master/config/etc-dbus-1-system.d-matriz_jackd.conf | sudo tee /etc/dbus-1/system.d/matriz_jackd.conf >/dev/null
$ curl https://raw.githubusercontent.com/stressfm/matriz/master/config/boot-config.txt | sudo tee /boot/config.txt > /dev/null
$ curl https://raw.githubusercontent.com/stressfm/matriz/master/config/boot-cmdline.txt | sudo tee /boot/cmdline.txt >/dev/null
$ curl https://raw.githubusercontent.com/stressfm/matriz/master/config/supervisord.conf | sudo tee /etc/supervisord.conf >/dev/null
$ for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo -n performance | sudo tee $cpu/cpufreq/scaling_governor; done
$ sed -i "$(wc -l /etc/rc.local | cut -d' ' -f1)i for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo -n performance > $cpu/cpufreq/scaling_governor; done" /etc/rc.local
$ sed -i "$(wc -l /etc/rc.local | cut -d' ' -f1)i sudo mount -o remount,size=256M /dev/shm" /etc/rc.local
$ sudo pip install supervisor
$ sed -i "$(wc -l /etc/rc.local | cut -d' ' -f1)i supervisord -c /etc/supervisord.conf" /etc/rc.local
$ sudo reboot

For the server, if you want to stream the performance, you might want to install and configure:

  • liquidsoap (to receive and combine client streams)
  • icecast2 (to stream the combined audio from all clients)
  • GStreamer (to decode client streams)

Using PyPi

To install the program just to use the client:

$ pip install matriz

In the machine where the server will run, server dependencies must be explicitly installed:

$ pip install matriz[server]

Install Script for Raspberry Pi

Or simply run the following command which performs all the steps above (Raspberry Pi specific DO NOT use on other OS):

curl https://raw.githubusercontent.com/stressfm/matriz/master/scripts/install.sh | sudo bash -

Usage

Client

To use the client open a shell and just type:

$ matriz

without arguments, to start the client. The program will try to read configuration options from a file called client.json in the same directory where the program was invoked. If you want to use another filename, just give that as an argumento to the program:

$ matriz <filename>

An example configuration file is in config/client.json:

{
    "key": "key1",
    "name": "porto",
    "url": "ws://localhost:5000/config",
    "interface": "eth0",
    "port": 8554,
    "client_pem": "fake_client.pem",
    "client_crt": "fake_client.crt",
    "ca_crt": "fake_ca.crt"
}

key: supposed to be unique id for client name: some label identifying the client url: the configuration server url interface: network card to start de emitter on port: port for emitter to listen on client_pem: openssl key for secure websockets client_crt: openssl client certificate ca_crt: openssl server certificate

To get a list of command line arguments type:

$ matriz -h

Server

The configuration server is just a single file Flask app (matriz/config_server.py). For deployment instructions consult the Flask documentation at http://flask.pocoo.org. The server will try to read configuration options from the file given in the MATRIZ_CONFIG_FILE environment variable or, if not set, from a file called clients.json in the same directory where the program was invoked. An example configuration file can be found in config/clients.json:

{
  "client_keys": [
        {"name": "porto", "key": "key1"},
        {"name": "montemor", "key": "key2"},
        {"name": "lisboa", "key": "key3"},
        {"name": "marte", "key": "key666"}
  ],
  "monitor_key": {"name": "monitor", "key": "monitorkey"}
}

Misc

For the software to work ports 8554 (TCP) and 8600-8700 (UDP) must be able accept incoming connections. This means you have to configure the gateways if you intend to use the software across the internet.

Partners

  • Oficinas do Convento
  • Sonoscopia
  • Osso
  • Trienal de Arquitectura de Lisboa
  • Digitópia - Casa da Música
  • Câmara Municipal de Montemor-o-Novo.

Funding

  • Direção Geral das Artes.

Installation

At the command line:

$ easy_install matriz

Or, if you have virtualenvwrapper installed:

$ mkvirtualenv matriz
$ pip install matriz

Usage

To use matriz in a project:

import matriz

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/stressfm/matriz/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.

Write Documentation

matriz could always use more documentation, whether as part of the official matriz docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/stressfm/matriz/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up matriz for local development.

  1. Fork the matriz repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/matriz.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv matriz
    $ cd matriz/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 matriz tests
    $ python setup.py test
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/stressfm/matriz/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ python -m unittest tests.test_matriz

Credits

Core Developers

Contributors

None yet. Why not be the first?

History

0.1.0 (2016-05-19)

  • First release.

Indices and tables