Hi. This is in the process of a major redesign. Take this with a grain of salt.
Polysporth. Polyphonic Sporth.
Polysporth is a ugen written for Sporth, designed to address some of the natural shortcomings of the Sporth language: polyphony, events, and abstraction. The source code can be found on github.
Polysporth is spawned from inside of Sporth as a ugen. From there, PolySporth is able to be controlled via Scheme (tinyscheme). Sporthlets can be toggled on and off, and they scheduled using a notelist interface that slightly resembles a Csound/Music V score. Meta-notes also exist, which allow scheme functions to be called instead of sporthlet voices. Contiguous sporthlets can be grouped together to form voice groups, which can used to implement an efficient means of polyphony.
PolySporth has access to many under-the-hood features of soundplumber, Sporth's sound engine based on Soundpipe. Coupled with the Scheme language, this allows for abstractions not possible with Sporth alone, such as procedural code generation, parameterized functions, and reusable code.
Nothing special. Polysporth is now included inside of Sporth, and can be called as a standard ugen.
A simple example
A typical polysporth instance has a Sporth file and a Scheme file.
The Sporth code calls Polysporth (call this file simple.sp):
_in 1 zeros 0 0 4 _in _out "simple.scm" ps 0 4 _out ftsum
In the code above:
- zeros creates a table of size 1 called "in"
- ps instantiates Polysporth, taking in the following arguments (left to right): trigger, clock, input table, output table, scheme filename
- ftsum takes the output table of polysporth and sums them together. This mixes all the individual sporthlet voices together.
The Scheme code manages all the different chunks of Sporth code (call this file simple.scm):
(define sine0 "60 mtof 0.2 sine") (define sine1 "64 mtof 0.2 sine") (define sine2 "67 mtof 0.2 sine")
(ps-eval 0 sine0) (ps-eval 1 sine1) (ps-eval 2 sine2)
(ps-turnon 0 -1) (ps-turnon 1 -1) (ps-turnon 2 -1)
In the code above:
- define creates three sporth strings, each containing a sine wave generator of a particular frequency
- ps-eval evaluates the sporth code into sporthlet voice N.
- ps-turnon turns on sporthlet voice N. The -1 parameter turns them on indefinitely.
Execute the code by running:
If all goes well, it will generate a 5-second audio file called "test.wav".
Less simple examples
The Polysporth folder in the Sporth source tree contains a small examples, each demonstrating a particular feature of Polysporth. At the moment, they are the closest thing to documentation:
Future plans include:
- More scheme-based abstractoins
- Better integration with programs like Protrekkr