New to Sonic-Pi. To learn basic syntax, I’m taking a piece of piano music I know how to play and converting it to code. Say I’m writing a function that represents a bar of music. Admittedly a lot of redundancy in the function below, but this arrangement is readable (at least to me) and it allows me to style specific notes, adding amp and release in certain places, but not others.
define :intro do
play [:d3, :a3, :f4], amp: 7
sleep 0.2
play [:f3, :d4], amp: 5
sleep 0.2
play [:a3, :f4], amp: 5
sleep 0.2
play [:f3, :d5], amp: 7, release: 2
sleep 0.2
play [:a3, :f4], amp: 5
sleep 0.2
play [:f3, :d4], amp: 5
sleep 0.2
end
I could write the same basic function more concisely using variables and play_pattern_timed, as in:
define :intro do
notes = [[:d3, :a3, :f4],[:f3, :d4],[:a3, :f4],[:f3, :d5],[:a3, :f4],[:f3, :d4]]
duration = 0.2
play_pattern_timed notes, duration
end
My questions: 1) is the more concise function necessarily better? and 2) if I went with the second more concise function, how I can use amp and release to style individual notes contained within the notes variable?
Thanks from a nOOb