As @Eli claims i don’t post m u s i c, i propose this tune for beginners with a well-known tune Au clair de la lune in French, how you call it into your own country ?
I introduce an idea for futur : the use of json format to save parameters.
We can do with array yes we can.
# NLB - 25-03-2020
# Au clair de la lune -
# understand how to code a little tune
# use of json format for the hype (or not)
# use robert
require "json"
# json may be useful or not :-)
# See in the futur
# the idea : save into it parameters modified by knob of a midi device.
my_instruments = '
{
"piano":
{
"piano_01": {"a":0.01,"d":0.1,"s":0.8, "r":0.25, "cutoff":80},
"piano_02": {"a":0.01,"d":1,"s":0.1, "r":0.25, "cutoff":60}
},
"tb303":
{
"tb303_01": {"a":0.3,"d":0.8,"s":0.4, "r":0.5, "cutoff":120},
"tb303_02": {"a":0.1,"d":0.5,"s":0.25, "r":0.5, "cutoff":60},
"tb303_03": {"a":0.1,"d":0.3,"s":1, "r":1, "cutoff":80}
},
"pretty_bell":
{
"pretty_bell_01": {"a":0.1,"d":0.8,"s":0.4, "r":0.5, "cutoff":40},
"pretty_bell_02": {"a":0,"d":0.4,"s":0.5, "r":1, "cutoff":80}
}
}'
define :robert do | famille, num |
parsed = JSON.parse(my_instruments) # returns a hash
flavour = famille +"_"+num
foo = parsed[famille][flavour]
use_synth famille
use_synth_defaults attack: foo["a"],
decay: foo["d"],
sustain: foo["s"],
release: foo["r"],
cutoff: foo["cutoff"]
end
# set the tempo 190 beat per minute
use_bpm 120
# puzzle your whole tune into many pieces that will repeat themselves during the tune
# the notes "riff"
riff_A = [:c, :c, :c, :d, :e, :d]
# the length "l" for each note
l_A = [1, 1, 1, 1, 2, 2]
# do the same model for all the pieces
riff_B = [:c, :e, :d, :d,:c]
l_B = [1, 1, 1, 1, 4]
riff_C = [:d, :d, :d, :d,:a3, :a3, :d, :c, :b3, :a3, :g3]
l_C = [1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 4 ]
# define the structure of the whole tune
define :structure do
2.times do
play_pattern_timed riff_A, l_A
play_pattern_timed riff_B, l_B
end
play_pattern_timed riff_C, l_C
play_pattern_timed riff_A, l_A
play_pattern_timed riff_B, l_B
end
live_loop :metronome do
sleep 1
end
live_loop :first_voice, sync: :metronome do
robert "piano", '02'
with_fx :reverb, room: 0.5 do
with_fx :level, amp: 1.2 do
structure
end
end
end
# canon effect
# you can change the tb303 favour to 02 and run again,
# at the end of the structure, the change will be set
live_loop :second_voice, sync: :metronome, delay: 4 do
robert "tb303", '02'
with_fx :level, amp: 0.5 do
use_octave -1
structure
end
end
live_loop :drum, sync: :metronome do
with_fx :reverb, room: 0.5 do
sample :drum_tom_lo_soft, amp: 1, pan: -0.5
sample :drum_bass_hard, amp: 0.5, pan: 0.5
sleep [2, 0.5, 1.5, 3, 1].tick
end
end
live_loop :hh, sync: :metronome do
tick
sample :drum_cymbal_pedal, rate: 2, attack: 0, sustain: 0.2, amp: 0.4
if look==16
sample :drum_cymbal_soft, attack: 0, sustain: 1, amp: 0.4
tick_set 1
end
sleep 1
end
Voilà voilà