And here is the example in code. Please have a look at the scales. The first 4 scales belong to key F major, while the last 4 scales belong to key C major. If you want the last 4 scales to belong to key F, you should use:
D aeolian (instead of D dorian)
C mixolydian (instead of C ionian)
G dorian (instead of G mixolydian)
It is these choices that modulate the key from F to C.
use_bpm 70
chords = [chord(:F2, :major7),
chord(:G2, :minor7),
chord(:C3, :dom7),
chord(:F2, :major7),
chord(:D3, :minor7),
chord(:C3, :major7),
chord(:G2, :dom7, inverse: 1),
chord(:C3, :major7),
]
with_synth :piano do
live_loop :piano do
play chords.tick, hard: 0.6, sustain: 2, release: 0.5, amp: 1.5
sleep 2
end
end
scales = [scale(:F2, :ionian),
scale(:G2, :dorian),
scale(:C3, :mixolydian),
scale(:F2, :ionian),
scale(:D3, :dorian),
scale(:C3, :ionian),
scale(:G2, :mixolydian),
scale(:C3, :ionian),
]
with_synth :pulse do
live_loop :melody do
sca = scales.tick
num_notes = 6
sca[0, num_notes].each do |n|
play n, release: 2.0/num_notes, amp: 0.5
sleep 2.0/num_notes
end
end
end