# Simple Waveguides in C++

Waveguides can be used to model acoustical oscillators, such as strings, pipes or drumheads. The theory of digital waveguides is covered in the sound synthesis introduction.

## The WaveGuide Class

The WaveGuide class implements all necessary components for a waveguide string emulation. Inside the class, the actual waveguide-buffers are realized as pointers to double arrays.

From WaveGuide.h:

/// length of the delay lines
int     l_delayLine;

/// leftward delay line
double  *dl_l;

/// rightward delay line
double  *dl_r;


The pointer arrays need to be initialized in the constructor of the WaveGuide class.

From WaveGuide.cpp:

dl_l = new double[l_delayLine];
dl_r = new double[l_delayLine];

for (int i=0; i<l_delayLine-1; i++)
{
dl_l[i] = 0.0;
dl_r[i] = 0.0;
}


## Plucking the String

The method void WaveGuide::excite(double pos, double shift) is called for plucking the string, respectively exciting it. It receives a plucking position and a shift parameter. In two loops, the method fills the two waveguides with the excitation function. In this example, a simple triangular function is chosen.

From WaveGuide.cpp:

// set positive slope until plucking index
for (int i=0; i<idx; i++)
{
dl_l[i] = 0.5* ((double) i / (double)(idx));
dl_r[i] = 0.5* ((double) i / (double)(idx));
}
// set negative slope from plucking index to end
for (int i=idx; i<l_delayLine; i++)
{
dl_l[i] = 0.5*(1.0 - ((double) i / (double) (l_delayLine-idx)));
dl_r[i] = 0.5*(1.0 - ((double) i / (double) (l_delayLine-idx)));
}


# Karplus-Strong in Faust

## White Tone Oscillator

As explained in the Sound Synthesis Introduction, the Karplus-Strong algorithm is based on a sequence of white noise. The following example uses a feedback structure to create a looped version of a white noise array:

Main components of the above example are the excitation and the resonator. The resonator is a feedback loop with an adjustable delay:

The excitation passes a random sequence to the resonator, once the gate is activated. It will oscillate until the gate is released.

Load the example in the Faust online IDE for a quick start:

// white_tone.dsp
//
// Henrik von Coler
// 2021-07-04

import("all.lib");

// Control parameters:
freq = hslider("freq Hz", 50, 20, 1000, 1) : si.smoo; // Hz
gate = button("gate");

// processing elements for excitation:
diffgtz(x) = (x-x') > 0;
decay(n,x) = x - (x>0)/n;
release(n) = + ~ decay(n);
trigger(n) = diffgtz : release(n) : > (0.0);

P = SR/freq;

// Resonator:
resonator = (+ : delay(4096, P) * gate) ~ _;

// processing function:
process = noise : *(gate : trigger(P)): resonator <: _,_;


## Karplus-Strong in Faust

The Karplus-Strong algorithm for plucked string sounds is explained in detail in the Sound Synthesis Introduction. That implementation is based on a ring buffer with a moving average filter. For the Faust implementation, this example has been adjusted, slightly (Smith, 2007).

### Exercise

Exercise

Extend the White Tone example with a filter in the feedback to turn it into a Karplus-Strong synthesis.

# Spatializing Rhythmic Music

Spatialization of rhythmic music is quite different from working with experimental content. Movements need to be synced to the rhythmic rhythmic structure. For techno and related genres it is even more restrictive, since movements and signal alteration through rendering algorithms must not degrade the bass structure and the transients. The music must not lose its energy and spatial effects have to be used carefully. Kick and bass are usually not spatialized at all, making it as tight as possible.

## Garbicz 2019

### Setup

A surround system with a diameter of ~22 m, featuring 6 Funktion One Resolution 2 and 4 Res9 (and many subs), was installed at Garbicz Festival 2019. Ambisonics rendering was performed with IRCAM's PanoramixApp.

### Software

PD was used to perform beat-tracking and real-time feature extraction, as well as for generating synced source movements. An Ableton Push could be used with the PD patches for controlling the source movements with a simple, intuitive interface. The patch allows the spatialization of multiple mono sources for live acts and the treatment of stereo sources through MS processing for DJs.

## Movement Demo

This video shows beat-aligned source movements and free rotations for a multi track spatialization. It is created with GEM (Pure Data), which is also used for visualizing the source movements during operation of the system. This example is only a mockup - the audio is not rendered from these movements but the standard stereo mix is used.

Demonstration of source movements with 'Combination 03' by JPLS

# 2020-2021 Class

## Concept

For the first online edition of the SPRAWL class, all students were equipped with the original Access Points, used for the original approach. The concept relied on irregular weekend sessions with additional meetings during the week.

In each session, the SPRAWL System was used for audio connections. Video and additional talkback for trouble shooting was realized with a parallel Zoom session, as shown in the figure below. For leave streams, as in the closing concert, the audio from the Jacktrip connections is merged with the video from the Zoom meeting, by means of OBS on an additional Acess Point dedicated to straming.

## Scores and Compositions

Several conepts were explored during the semester, including graphic scores, text-based compositions and configuration-based improvisations.

### Graphic Scores

Graphic scores are a simple but effective means for guiding improvisations in network performances. They can be distributed to all participants via screen sharing to ensure a decent synchronization.

### Blodgett

Blodgett is a text-based score by Robert Stokowy, comissioned by the EOC in 2019:

https://robertstokowy.bandcamp.com/track/blodgett-i

The score gives precise instructions on the spatial behavior of the sound sources. In the SPRAWL System, each participant takes control of his/her own source position, thus sharing the task of spatialization. Focusing on simple properties like proximity/distance and movement/stillness, each student programmed a Pure Data patch, allowing a GUI-based control on the default Access Points' touch screen.

### Granular Confusion

Granular Confusion is a concept by Mario Hillenbrand, developed for the SPRAWL System. The Access Points are devided into sound generators and processors:

• Generators can use any means for sound generation.

• Processors are all running the same granular patch.

The Access Points are statically connected, as shown in the figure below. An additional sound director takes care of spatialization and manages the start/stop procedure of the configuration. A minimal timeline is used to guide the iprovisation, telling the generators when to be active.

Back to NSMI Contents

# Compiling JackTrip

The SPRAWL System needs some additional features that are missing from the main branch of Jacktrip. To build the correct JackTrip version, the Jacktrip git repository must be cloned and checked out to the correct branch.

Therefor git must be installed. On MacOS git is often already installed. Linux users should install git through their package manager. Windows users download the installer from git-scm.

## Getting the JackTrip Source Code

Now the JackTrip source code can be downloaded from the official JackTrip repository.

git clone https://github.com/jacktrip/jacktrip.git
git checkout nils


Changes in the remote repository have to get pulled.

git pull


Afterwards you can follow the official build instructions.

# Moving Files with SCP

SCP (Secure copy protocol) is an SSH-based tool for transferring files between machines in local and wide area networks. It is a safe and quick way to exchange data.

## Copying to a Remote Machine

The following command copies the file testfile.html from the local machine to the home directory of the user student on the server with the address specified address 11.22.33. Instead of the home directory (~/), any other target can be specified:

$scp testfile.html student@11.22.33:~/  Add the -r flag to copy a directory recursively: $ scp -r /foo/bar student@11.22.33:~/

Select or create a short WAV file on your local machine and copy it to your personal directory on the server using SCP.


## Copying From a Remote Machine

To copy a file from a remote server, the arguments' order needs to be swapped. The dot (.) copies the data to the recent directory. Any other path can be used as target.

\$ scp student@85.214.78.6:~/WebAudioFreqGain.html .


Exercise

Create a text file in your personal directory on the server. Copy it to your local machine using the SCP command from your local machine.

# Waveshaping Example

The following interactive example offers control over the pre-gain to add overtones to the sinusoidal source signal:

Pitch (Hz):

Pre-Gain:

Output Gain:

Time Domain:

Frequency Domain: