# Using degree and scale_degree

Hello all.
Here’s a look at how to use degree and chord degree. Please point out anything unclear or sloppily worded, I plan to revise this.

Degree

In section 8.3, the notion of using a scale is introduced. A scale is a collection of notes, often 7, which together provide the key signature of all or part of a song. Sonic Pi provides a number of common and uncommon scales, from the familiar :major and :minor to the exotic :bhairav and :iwato that are stored as lists.

Using the scale function, we are easily able to ascend and descend through the scale by ticking through rings, or play a random note by choosing. By creating a pattern of index values for a scale, we can even create a more complex arpeggio.

``````loop do
i = [1, 3, 7, 2, 1, 3, 7, 5].ring.tick
play (scale, :c4, :major)[i], release: 0.15
sleep 0.25
end
``````

The degree command gives us another way to achieve the same thing using a musically inspired notation. The degree of a scale is typically represented by a Roman numeral, and Sonic Pi provides the labels :i, :ii, :iii, :iv, etc to represent that. Therefore, the above example could be represented by:

``````loop do
deg = [:i, :iii, :vii, :ii, :i, :iii, :vii, :v ].ring.tick
play degree(deg, :c4, :major), release: 0.15
sleep 0.25
end
``````

Note that if you use a number higher than the scale has notes, a :vii in a :major_pentatonic for example, you will hear silence.

Chord Degree

The chord_degree command is a real powerhouse of a tool, one that can grow your compositional options dramatically. Like degree, it uses a :i - :vii notation related to the notes within a scale, but generates the appropriate chord for each degree to stay in key.

``````loop do
use_synth :fm
deg = [:i, :iv, :i, :v ].ring.tick
play chord_degree(deg, :e4, :major, 3)
sleep 1
end
``````

The 3 after the scale name tells the command that we want 3 notes instead of the default 4.

Now we can get wild with parallel scales and key changes, allowing our composition to use complex techniques without needing to identify each chord independently. In this example, the chords have been broken apart into an arpeggio. The inner loop cycles between the 4 degrees and the outer loop switches between a parallel major and minor, alternating.

``````loop do
use_synth :fm
scl = [:major, :minor].ring.tick(:scl)
4.times do
deg = [:i, :iv, :i, :v ].ring.tick(:deg)
4.times do
play chord_degree(deg, :c4, scl, 3).ring.reverse.tick(:nt)
sleep 0.25
end
end
end
``````

Now let’s bring these two loops together and see how cohesive they sound even when we switch from a major to a minor key.

``````in_thread do
loop do
use_synth :fm
scl = [:major, :minor].ring.tick(:scl)
4.times do
deg = [:i, :iv, :i, :v ].ring.tick(:deg)
play chord_degree(deg, :c4, scl, 3)
sleep 2
end
end
end

loop do
scl = [:major, :minor].ring.tick(:scl)
32.times do
deg = [:i, :iii, :vii, :ii, :i, :iii, :vii, :v ].ring.tick
play degree(deg, :c4, scl), release: 0.25
sleep 0.25
end
end
``````
2 Likes