Links and Course Material

TU Website

The official TU website with information on the schedule and assessment:

https://www.ak.tu-berlin.de/menue/lehre/sommersemester_2021/network_systems_for_music_interaction/

Download

The download area features papers, audio files and other materials used for this class. Users need a password to access this area.

Student Wiki

This Wiki can be used for sharing knowledge:

http://teaching-wiki.hvc.berlin

SPRAWL GIT Repository

The repository contains SHELL scripts, SuperCollider code and configuration files for the server and the clients of the SPRAWL system:

https://github.com/anwaldt/SPRAWL

JackTrip GIT Repository

Jacktrip is the open source audio over IP software used in the SPRAWL system:

https://github.com/jacktrip/jacktrip


Back to NSMI Contents

Using the Terminal for Doing Stuff

People working a lot with MAC or Linux systems might be used to doing things from the terminal or console. For novices, it usually appears more frightening than it actually is. Especially when working on remote servers - but also for embedded devices for audio processing - the terminal is the standard tool.


Directories

You can maneuver through the system's directories using the cd command. Changing to an absolute path /foo/bar can be done like this:

$ cd /foo/bar

New directories are created with the mkdir command. For creating a new directory mydir in your recent location, type:

$ mkdir mydir

The content of the recent directory can be listed with the ls command. The following arguments improve the results:

$ ls -lah

drwxrwxr-x  2 username group 4,0K Mar 25 12:25 .
drwxrwxr-x 16 username group 4,0K Mar 25 12:25 ..
-rwxrwxr-x  1 username group 9,1M Feb  3 17:47 jacktrip
-rwxrwxr-x  1 username group 334K Feb  3 17:47 sprawl-compositor

Exercise

Create a directory with your name in the student user home directory /home/student/students/YOURNAME.


Create and Edit Files

A file can be created by touching it:

$ touch filename

The default editor on most systems is nano. It is a minimal terminal based tool and does not require X forwarding. To edit an existing file or create a new file, type:

$ nano filename

Terminal Only

Inside nano, you have a lot of defined keystrokes for editing, file handling and other tasks. See the nano cheat sheet for a full list: https://www.nano-editor.org/dist/latest/cheatsheet.html

Exercise

Create a text file in your personal directory and fill it with some text.


GUI Based

When working with X forwarding, simple text editors with GUI features can be used. On the SPRAWL server, this includes mouspad or the minimal Python IDE idle.


Starting Applications

System wide binaries must be located in a directory that is listed in $PATH (see the final section on this page for details). They can be started by simply typing the name:

$ foo

A local binary named foo can be started with the following command:

$ ./foo

You can terminate your command with an ampersand (&) to run a process in the background. You can continue to work in the terminal, afterwards:

$ ./foo &
[1] 5459

If you start a command this way, it gives you an id of the background process in brackets and the actual process ID (PID).

You can get the process back into foreground with the fg command followed by the background process id:

$ fg 1

Check for Running Applications

At some point, users may want to know whether a process is running or which processes have been started. The command top lets you monitor the system processes with additional information on CPU and memory usage, updated with a fixed interval:

$ top

htop is a slightly polished version, using colored results:

$ htop

You can get a list of all running processes, including auxiliary ones, by typing:

$ ps aux

Usually, these are way to many results. If you want to check whether an instance of a specific program is running, you can use grep after the ps aux to filter the results:

$ ps aux | grep foo

Shell Variables

Sometimes it is convenient to store information in variables for later use. Some common variables that are used in Unix like operating systems like Linux, BSD or MacOS are for example PATH and DISPLAY.

Shell variables are usually uppercase. To get the content of a variable it is prefixed by a dollar sign. The command echo is used to print the content:

$ echo $PATH
/home/username/.local/bin:/home/username/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
$ echo $DISPLAY
:0

Defining a variable is done with an equal sign. It happens quite often that the program that should use the variable, opens another environment. To access the variable in that sub-environment, it has to be exported before:

$ NAME=username
$ echo $NAME
username
$ bash
$ echo $NAME

$ exit
exit
$ export NAME
$ bash
$ echo $NAME
username

Distortion Synthesis

In contrast to subtractive synthesis, where timbre is controlled by shaping the spectra of waveforms with a many spectral components, distortion methods shape the sound by adding overtones with different principles. Quasi parallel to Bob Moog, Don Buchla invented his own system of analog sound synthesis in the 1960s, based on distortion, modulation and additive principles. This approach is also entitled West Coast Synthesis.

The Buchla 100 was released in 1965, and was used by Morton Subotnick for his 1967 experimental work Silver Apples of the Moon.

Past Projects - Sound Synthesis in C++

The following projects have been realized within the Sound Synthesis seminar in the past.

Wave Digital Filter (WDF) Tonestack

Audio Programming in C++

C++ is the standard for programming professional, efficient audio software. Most of the languages and environments introduced in the Computer Music Basics class are programmed in C++ themselves. When adding low level components, such as UGens in SuperCollider, objects in Pure Data or VST plugins for Digital Audio Workstations (DAW), these are programmed in C++, based on the respective API. These APIs take over the communication with the hardware and offer convenient features for control and communication.

JUCE

JUCE is the most widely used framework for developing commercial audio software, such as VST plugins and standalone applications.

JACK

JACK offers a simple API for developing audio software on Linux, Mac and Windows systems.

Getting Started with Web Audio

The Web Audio API is a JavaScript based API for sound synthesis and processing in web applications. It is compatible to most browsers and can thus be used on almost any device. This makes it a powerful tool in many areas. In the scope of this introduction it is introduced as a means for data sonification with web-based data APIs and for interactive sound examples. Read the W3C Candidate Recommendation for an in-depth documentation.


The Sine Example

The following Web Audio example features a simple sine wave oscillator with frequency control and a mute button:

Sine Example

Sine Example.

Frequency


Code

Building Web Audio projects involves three components:

  • HTML for control elements and website layout

  • CSS for website appearance

  • JavaScript for audio processing

Since HTML is kept minimal, the code is compact but the GUI is very basic.

/media/anwaldt/ANWALDT_2TB/WORK/TEACHING/Computer_Music_Basics/webaudio/sine_example/sine_example.html (Source)

<!doctype html>
<html>

<head>
  <title>Sine Example</title>

  <!-- embedded CSS for slider appearance -------------------------------------->

  <style>
  /* The slider look */
  .minmalslider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 25px;
    background: #d3d3d3;
    outline: none;
  }
  </style>
</head>

<!-- HTML control elements  --------------------------------------------------->

<blockquote style="border: 2px solid #122; padding: 10px; background-color: #ccc;">

  <body>
    <p>Sine Example.</p>
    <p>
      <button onclick="play()">Play</button>
      <button onclick="stop()">Stop</button>
      <span>
        <input  class="minmalslider"  id="pan" type="range" min="10" max="1000" step="1" value="440" oninput="frequency(this.value);">
        Frequency
      </span>
    </p>
  </body>

</blockquote>


<!-- JavaScript for audio processing ------------------------------------------>

  <script>

    var audioContext = new window.AudioContext
    var oscillator = audioContext.createOscillator()
    var gainNode = audioContext.createGain()

    gainNode.gain.value = 0

    oscillator.connect(gainNode)
    gainNode.connect(audioContext.destination)

    oscillator.start(0)

    // callback functions for HTML elements
    function play()
    {
      gainNode.gain.value = 1
    }
    function stop()
    {
      gainNode.gain.value = 0
    }
    function frequency(y)
    {
      oscillator.frequency.value = y
    }

  </script>
</html>

Class Outline

Sessions & Topics

Theory

Practical

1

History, Signals & Systems, Environments and Languages

1

Getting started with PD, SuperCollider, WebAudio, Faust

2

Theory: Additive, Modulation, Distortion

2

Implement: Additive, Modulation, Distortion

3

Theory: Subtractive, Processed Recording, Physical Modeling

3

Implement: Subtractive, Processed Recording, Physical Modeling

4

Theory: Spatialization & Network Systems

4

Working with a network performance system.

OSC: Open Sound Control

Open Sound Control (OSC) is the standard for exchanging control data between audio applications in distributed systems and on local setups with multiple components. Almost any programming language and environment for computer music offers means for using OSC, usually builtin.

OSC is based on the UDP/IP protocol in a client-server paradigm. A server needs to be started for listening to incoming messages sent from a client. For bidirectional communication, each participant needs to implement both a server and a client. Servers start listening on a freely chosen port, whereas clients send their messages to an arbitrary IP address and port.

The ports 0 to 1023 are reserved for common TCP/IP applications and can thus not be used in most cases.


OSC Messages

A typical OSC message consists of a path and an arbitrary number of arguments. The following message sends a single floating point value, using the path /synthesizer/volume/:

/synthesizer/volume/ 0.5

The path can be any string with slash-separated sub-strings, as paths in an operating system. OSC receivers can sort the messages according to the path. Parameters can be integers, floats and strings. Unlike MIDI, OSC offers only the transport protocol but does not define a standard for musical parameters. Hence, the paths used for a certain software are completely arbitrary and can be defined by the developers.

First Sounds with SuperCollider

Boot a Server

Synthesis and processing happens inside an SC server. So the first thing to do when creating sound with SuperCollider is to boot a server. The ScIDE offers menu entries for doing that. However, using code for doing so increases the flexibility. In this first example we will boot the default server. It is per default associated with the global variable s:

// boot the server
s.boot;

A First Node

In the SC server, sound is generated and processed inside nodes. These nodes can later be manipulated, arranged and connected. A simple node can be defined inside a function curly brackets:

// play a sine wave
(
{
    // calculate a sine wave with frequency and amplitude
    var x = SinOsc.ar(1000);

    // send the signal to the output bus '0'
    Out.ar(0, x);

}.play;

)

In the ScIDE, there are several ways to get information on the active nodes on the SC server. The node tree can be visualized in the server menu options or printed from sclang, by evaluating:

s.queryAllNodes

After creating just the sine wave node, the server will show the following node state:

NODE TREE Group 0
   1 group
      1001 temp__1

The GUI version of the node tree looks as follows. This representation is updated in real time, when left open:

/images/basics/sc-nodes-1.png

Note

The server itself does not know any variable names but addresses all nodes by their ID. IDs are assigned in an ascending order. The sine wave node can be accessed with the ID 1001.


Removing Nodes

Any node can be removed from a server, provided its unique ID:

s.sendMsg("/n_free",1003)

All active nodes can be removed from the server at once. This can be very handy when experiments get out of hand or a simple sine wave does not quit. It is done by pressing Shift + . or evaluating:

// free all nodes from the server
s.freeAll

Running SC Files

SuperCollider code is written in text files with the extensions .sc or .scd. On Linux and Mac systems, a complete SC file can be executed in the terminal by calling the language with the file as argument:

$ sclang sine-example.sc

The program will then run in the terminal and still launch the included GUI elements.

Getting Started with Puredata

About

Puredate (PD) is the free and open source version of Max/MSP, also developed and maintained by Miller Puckette. PD is one of the best options for people new to computer music, due to the obvious signal flow. It is a very helpful for exploring the basics of sound synthesis and programming but can also be used for advanced applications: https://puredata.info/community/member-downloads/patches. In addition, PD offers simple and flexible means for creating control and GUI software. There are a lot of great tutorials and examples online. This one features almost anything to know: PD-Flossmanuals


The Sine Example

This very basic sine.pd example creates a sine wave oscillator. Its frequency can be controlled with a horizontal slider. Ann additional toggle object allows to switch the sine on and of, by means of multiplication. When used without arguments, the dac~ object has two inlets, which relate to the left and right channel of the audio interface. The additional message box with the bang can be used to activate the DSP. This is necessary for getting any sound and can also be done in the menu.

/images/basics/pd-sine.png

References

1997

  • Miller S. Puckette. Pure Data. In Proceedings of the International Computer Music Conference (ICMC). Thessaloniki, \\ Greece, 1997.
    [details] [BibTeX▼]

1988

  • Miller S. Puckette. The patcher. In Proceedings of the International Computer Music Conference (ICMC). Computer Music Association, 1988.
    [details] [BibTeX▼]