Before you start with D♭, please keep in mind that all tutorials assume that you know general programming concepts and basic C# syntax. Only additions and changes with respect to D♭ will be discussed.
Table of Contents
• •
A D♭ program consists of a set of functions, we will look at them in detail in the next tutorial.
Each program must contain a single function Main that is the entry point to the program.
The Main function creates the first default entity which is also called the axiom.
Even if you take just an empty Main function, the axiom entity that was created in
the background will sound according to its default parameters.
It will be a C4 played by a piano for 1s.
Try it out here. Press the left-most button to execute the program, then press play to hear the result.
function Main() {
//nothing here yet
}Each entity has a set of attributes. What makes every entity unique are its attribute values. Having just a single entity would be boring, so most of the time D♭ operates on collections of entities. The collection currently processed is called the scope.
The most distinctive feature of D♭ is how entities and their attributes are accessed. It always works with the whole scope at once, processing all of its entities at once (notice the similarity to L-Systems).
In order to read or write attributes of the entities in the scope,
use the @ prefix. It denotes a batch operation applied to all
entities of the scope at once. D♭ overrides its original C# meaning for this purpose.
function Main() {
@velocity = 0.3; //soft note (played quietly)
}function Main() {
@velocity = 1; //loud note
@octave +=1; //an octave up, so C5
}Create a single soft note below the default octave.
A little practice, a little music.
Edit the starter, run your code, and see how it sounds.
The previous snippets use velocity and octave which are native
attributes available for each entity. Note that the musical meaning of
velocity is how hard the instrument is hit. Higher velocity
produces not only a louder sound, its timbre changes as well. Please remember that
velocity is associated with dynamics, not with tempo.
You can add custom attributes to the entities anytime. They can be of any type and D♭ should be able handle them properly in the background without explicit typing. With just a single entity, it is impossible to come up with a meaningful custom attribute use case. So the following example is just a teaser for what will be frequently used in later tutorials and examples.
function Main() {
@composer = "Algorithmus Magnificus";
}Custom attributes are globally compiled into the common entity class.
Once a type is associated with an attribute name, like in the above example
it was string composer, it is not possible to use a different type for
the attribute elsewhere in the program. The following example illustrates a
situation that will fail even when a type collision during execution is not possible.
The compiler will complain that it can not assign an int to a string for composer.
function Main() {
@composer = "Algorithmus Magnificus";
@composer = 42; //error here
}This was the most boring tutorial. It is great that you managed to read so far. In the next one we will learn how to divide the axiom entity into several entities so that we can actually start doing music.
D♭ Tutorials — Basic
D♭ Tutorials — Intermediate
D♭ Reference
D♭ Examples
Links