How is Sporth – YaP for musical live-sessions

4 min


We devoted one of the previous materials to OpenMusic – a tool for writing music on OOP. We also talked about programming languages ​​tailored for creating audio compositions.

Today we decided to continue the topic and talk about the Sporth language. It was specially developed so that composers could write computer music during live performances.


A photo ichael pierce / Unsplash

What is Sporth

Often under the term “music programming»Understand the process of writing music using sequencers, synthesizers and software. But some artists turn to more “hardcore” tools – program code and specialized PL.

One such language is Sporth.

Sporth (short for SoundPipe fORTH) is stack programming languageimplemented in C. Its operators allow you to generate signals of different frequencies and keys, work with function tables for sequencers and implement parametric modulation.

The language was developed by engineer Paul Batchelor, who at one time labored over speakers with a team Google atap. He presented his project at the International Conference on Live Coding in 2018. Though source repository was created on GitHub much earlier – in 2016.

According to Paul, when designing Sporth, he was inspired by stack languages ​​such as Forth and PostScript. Forth supports many CPUs with a limited amount of computing resources at their disposal. For example, it was used in Jupiter ace with one kilobyte RAM. As for PostScript, its variation is present in PDF format, and its interpreter is built into many printers.

Language Features

Sporth uses the machine model of the stack to pass parameters. The programmer puts in it a set of interconnected signal generators (unit generators), which are responsible for reproducing sound. For example, the line below will form a sinusoid with a frequency of 440 Hz with an amplitude of 0.5 points (the instrument has its own scale).

440 0.5 sine

Signal generators can be combined using the “+” symbol. For example, the result of the list of commands below will be dual tone DTMF.

440 0.2 sine
350 0.2 sine
+ 

The language supports working with triggers – single impulses – which are formed by the metronome (metro). The following example shows how to use Sporth to build envelope generator:

4 metro 0.5 maytrig
0.001 0.01 0.01 tenvx
1000 0.5 sine *

Sporth allows you to work with variables, parametric modulation and directly stack operations. All operators used are concise and are executed in order.

This language structure increases the speed of writing code. This is one of the main reasons that it is used for live sessions – when a composer-programmer writes music in real time in front of a live audience. By the way, you can independently study all the operators and try it out in practice – the network has interactive environment on go.

Also on the site you can find several musical examples.


A photo Slim emcee / Unsplash

But residents with Hacker News celebratethat the language has rather scarce documentation, which is not suitable for beginner “music programmers.” Author promises to fix this drawback, but for now you can turn to the thematic cookbook’s and github specifications.

Sporth also has an API to integrate with third-party applications. It opens up features not available in an interactive environment, such as custom callback functions. In particular, Sporth already apply sound synthesis framework developers AudioKit under iOS.

Analogs

The number of Sporth analogues is quite extensive, but among them we can distinguish the language Chuck. It was developed by engineers Perry Cook (Perry Cook) and Guy Wong (Ge Wang) from Princeton University specifically for live performances. ChucK is a multi-paradigm language with strong data typing available for Windows, Linux and Mac OS X. It supports the parallel execution of several threads and allows you to modify the program directly at runtime.

Documentation with examples of implementation posted on the project website.

Besides ChucK there is Supercollider – This is not only a language, but also a medium for audio synthesis in real time. The tool makes it possible to write custom GUIs for working with sound: sliders, analyzers, and others. You can use MIDI devices and Hid.

Also worth noting are musical programming tools such as Csound, Pure Data and Importu. If you had to work with any other languages ​​of muses. programming, share your experience in the comments.


Further reading from our Hi-Fi World:

What is musical programming – who does it and why
How PC conquered the media industry with software: discussing Pro Tools and Media Composer
Like the crack of a fire, the creaking of doors and noise become music

“Everything you read will be used against you”: how rap music got into the courtroom
Video game music creators: some of the most prominent names
Where to get audio samples for your projects: a selection of nine thematic resources



0 Comments

Leave a Reply