D♭ Tutorial: DYNAMICS and TRANSITIONS

In the previous tutorial on keys and modes we worked with scales and different modes to enrich the harmonies. Now we will add dynamics.

Gain and Velocity

Already in some of the first tutorials you encountered the velocity attribute of entities which controls how strong a note is played. It is not only a matter of loudness, also the quality of the tone changes accross different velocities. Lower velocities sound softer, more calm and uniform. While velocity is an audio engineering term, traditional musicians rather use dynamics.

If you wish to play a tone of a certain quality with a different volume, it is very hard to achieve with a real instrument. However, on a computer you can simply amplify the respective channel. This can be achieved by changing the gain. It acts as a pure post-processing effect multiplying the volume by the selected gain factor. The default value of gain = 1 means there is no change.

0
C-1
Code Editor
0.000
0
C-1
Code Editor
0.000

Since velocity has a far more natural effect, we will not use gain further in this tutorial. Here comes a more musical example for the dynamics. It plays a simple waltz with accents on the first beat.

0
C-1
Code Editor
0.000

Piani and Forti

For computer scientists it is common to represent everything with nubmers. If you feel more comfortable with musical markings, there is a set of predefined constants following standard musical notation: ppppp, pppp, ppp, pp, p, mp, mf, f, ff, fff, ffff. They reside in the Dynamics enum. Note that velocities below ppp and above fff are rarely used.

0
C-1
Code Editor
0.000

The default velocity corresponds to Dynamics.mf.

Crescendi and Decrescendi

D♭ also offers smooth transitions between different velocities. Some instruments are built so that they support velocity changes during the playback of a single note, e.g. violins, oboes or trombones. Others like all the percussion, piano or accustic guitar do not.

Let us demonstrate the dynamic transitions with a frech horn. The following example will keep the first note silent while the second will be very loud. There is no gradual change within the single notes yet.

0
C-1
Code Editor
0.000

Crescendo (gradually louder) and decrescendo (gradually more silent) transitions can be activated for entities to produce a gradual change in dynamics. The corresponding attribute is called transitions. It works in a different way than other attributes. First of all, it only applies to entities from a single track (see the very last example in this tutorial). A dynamic transition covers all upcoming entities in the track until terminated. Transitions are terminated implicitly when:

  • velocity changes, or

  • the dynamics flag is removed from transitions or

  • the track ends.

Let us activate a dynamic transition for the previous example. The transition attribute is a set of flags for different transitions (see following tutorials). Enabling dynamics transition means adding it to the set. The safest way is to use the += operator which also preserves any other active transitions.

0
C-1
Code Editor
0.000

The first note is now gradually louder until it reaches the full strength at the second note. If you wish to keep getting louder at the second note as well, you will need a little hack, since dynamic transitions stop at the begnning of the note that defines a new velocity. So let us shift the @velocity = 1 to a third note that will be just a rest, yet it will convey the dynamics information needed.

0
C-1
Code Editor
0.000

Notice that @velocity = 0.1 for both tones, since the transition is evaluated once the velocity changes. If we would assign a different velocity to the second note, the transition would cover only the first note and the second one would be constant. The result would sound like the previous example.

D♭ transitions have a simple correction mechanism. If you happen to assign the velocity just for the first note of a transition and keep the rest untouched, for the purposes of the transition it is recognized as if the velocity would be equal to the first tone. Same holds for the transition mode itself. The recognition of the unassigned state in connection with a linear propagation of the last assigned value in time only works with respect to transitions.

0
C-1
Code Editor
0.000

A dynamics transition may be stopped by removing the flag from the set of active transitions. Just as with adding, it is recommended to use the -= operator to preserve other active transitions.

The following example contains two crescendos separated by a constant part. The velocity values are set only for the first and for the very last note. Therefore, removing the dynamics flag only pauses the transition. It reached half the intensity at the second note, keeps it constant and then picks up at the third note to reach the maximum intensity at the end.

0
C-1
Code Editor
0.000

Dynamics is always scoped within a track of an instrument. If you wish to have two sections of the same instrument playing different dynamic transitions, make sure to separate them in individual tracks.

0
C-1
Code Editor
0.000

Legato

The first part of this tutorial was concerned with dynamics transitions. Now we will look at pitch transitions which are associated with different articulations. The most common is called legato. It is denoted by slurs over the respective notes. The corresponding D♭ flag is called Transition.Legato.

0
C-1
Code Editor
0.000

While dynamics flags have effect on the whole sequence that follows, a legato flag only affects the entitiy it is applied to. So to switch off legato for a whole sequence, it must be deactivated for all of them.

0
C-1
Code Editor
0.000

Legato is on by default. So in the previous example it needs to be explicitly switched off for the second part. Legato is automatically interrupted:

  • at a rest or when there is a gap between notes

  • at a repeating note

  • at a non-sustained articulation.

Legato always relates to the previous note, so the flag has no effect for the very first note in a phrase or after an interruption. The previous example can be altered to feature an interruption, resulting in two separated legato sequences. For example, making a note slightly shorter already tiggers an interruption of the legato.

0
C-1
Code Editor
0.000

The second type of interruption can be demonstrated by changing the melody so that a repeated note occurs. For example, by a modulo setting the last degree back to 0;

0
C-1
Code Editor
0.000

Repeating notes actually need a tie instead of a slur. The interruption triggered at a repeating note can be overriden by manually setting the Legato flag Without too much effort, adding it to the whole phrase will do the job.

0
C-1
Code Editor
0.000

The D♭ sampler supports legato only for instruments that also support dynamic transitions, so there is no legato for a piano, but bowed strings, woodwinds and brass support it. The legato support is in fact bound to the articulations. Legato is deactivated for staccato, pizzicato and similar.

0
C-1
Code Editor
0.000

The next tutorial will introduce the exciting world of musical instruments including the aforementioned articulations.