One of the many powerful features of SuperCollider is it’s ability to render sounds offline. This is called Non-Realtime Synthesis (NRT). NRT is for example useful for fast, offline processing of sounds, doing sound analysis or rendering generative compositions.
NRT works like this (normally): First you write a list of server OSC messages (stored in a Score usually) which will tell the (offline) server what to do at what point in time when you decide to render it. These are in the format [beat, [osc_command]]. An example: Making a Synth using synthdef \boring_sine at beat number 2 looks like this in such a OSC form: [2.0, [\s_new, \boring_sine, 1001, 0, 0]]
All of the possible server osc message commands are documented here: Server Command Reference
Creating such a list manually is naturally time consuming and does not feel very smart. It is also a very awkward way of writing music.
Fortunately, there are ways of doing this in a more efficient and musical way.
Recording event patterns
One of my favourite techniques is to simply convert Event Patterns (such as Pbind, Pmono, etc.) to scores using the .asScore method.
The process can be divided into the following steps:
Make a SynthDef and store it on your system using .store
Write an event pattern
Convert the event pattern to a Score object using .asScore
Render the Score to a sound file on your system
First step is to make a SynthDef. SynthDefs are sort of recipes for sound patches that the server uses to make sound. In this case, it will be a very boring sine, aptly named \boring_sine. Note the use of the .store method here. This will save the synthdef as a file on your system and make it available to the NRT process later on.
We will keep the pattern super simple: Random scale degrees played using our \boring_sine synth, each of which a quarter of beat in duration.
The total duration of the pattern will be infinite for now (the length of this will automatically be truncated by the Score conversion process).
And now, let us convert this to a score:
Finally, we render the score
Lets make this interesting: Iteration
Rendering one random melody is quite nice, but let us exploit the fact that our pattern chooses random scale degrees every time we play it and combine that functionality with iteration to make 10 (or any number) of rendered random melodies.
First, let us wrap what we wrote up until this point in a function that we can call as often as we want.
Let us keep the pattern as is
And then render 10 versions of it