Cool! I used your code to play along with my guitar and slightly modified it to change the key whenever I please:
# Tempo
use_bpm 40 #
# Tonalidade / Key
TONALIDADE = :fs # Define a tonalidade da música / Defines the song's key
ESCALA = scale(TONALIDADE, :major) # Gera a escala baseada na tonalidade / Generates the scale based on the key
# Função para calcular graus da escala com oitava
# Function to calculate scale degrees with octave
def grau(n, oitava = 4)
nota_base = ESCALA[n - 1] # Nota no grau da escala / Note in the scale degree
nota = nota_base + (oitava - 4) * 12 # Ajusta para a oitava desejada / Adjusts to the desired octave
end
# Função para construir acordes baseados nos graus e oitavas
# Function to build chords based on scale degrees and octaves
def acorde(grau, oitava, tipo = :major)
chord(grau(grau, oitava), tipo)
end
live_loop :back do
use_synth :prophet
play grau(1, 3), release: 20, cutoff: 60, amp: 1
sleep 20
end
live_loop :bass do
use_synth :fm
play acorde(1, 4, :major).choose, release: 0.25, cutoff: rrand(50, 80)
sleep [0.5, 0.25].choose
end
live_loop :drums do
sample :drum_heavy_kick
sleep 0.5
sample :drum_snare_hard
sleep 0.25
sample :drum_cymbal_closed
sleep 0.25
end
live_loop :melody do
use_synth :piano
play_pattern_timed [grau(1, 3), grau(1, 3), grau(6, 3), grau(7, 3), grau(6, 3)], [0.25, 2, 0.5, 0.25, 1]
play_pattern_timed [grau(2, 3), grau(5, 3), grau(4, 3), grau(5, 3), grau(5, 3)], [0.25, 2, 0.5, 0.25, 1]
play_pattern_timed [grau(4, 3), grau(4, 3), grau(5, 3), grau(6, 3), grau(7, 2), grau(1, 2)], [0.25, 2, 0.5, 0.25, 1, 4]
end
Your code is really cool! Thanks for sharing!