Is there a way to delay a note in a chord?
for example:
#this code:
play_chord [:c, :e, :g], attack: 0.05, amp: 2, release: 2
sleep 3
#into this:
play :c, release: 2
sleep 0.1
play :e, release: 2
sleep 0.1
play :g, release: 2
#but better of course...
c = (chord :c4, :major)
use_synth_defaults release: 2
for n in c
tick(:delay)
time_warp (line 0,1).look
play n
end
end
Just a starting point, needs some tweaking.
2 Likes
Hi
“better” is debatable, your solution works ok. I don’t think you can arpeggiate the play_chord function, but this works:
crd = chord(:c4, :major)
puts crd
3.times do
play crd.tick, release: 0.5
sleep 0.1
end
PD-Pi
1 Like
This is a bit more flexible, allowing you to specify different times per note in an array:
define :arpeggiate do |thesenotes, thesedelays|
(1..thesenotes.length).each do |i|
play thesenotes.ring[i-1]
sleep thesedelays.ring[i-1]
end #loop
end #define
arpeggiate (chord :c4, "m7"), [0.125, 0.25, 0.375, 0.5]
1 Like
This is great @HarryLeBlanc . I took the liberty of simplifying this - for both myself and OP - and added the built in rotate and invert methods
define :arpej do |notes, rel=0.3, del=0.2|
notes.length.times do |i|
play notes[i], release: rel
sleep del
end
end
arpej (chord :c4, :maj, invert: 1).rotate(2)
PD-Pi
1 Like
I like!
But why don’t you run into an off-by-1 problem with this? Isn’t the first array element 0?
Yes, you’re right, but it’s because I’m using n.length.times. Your example is more sophisticated, using a range (1…thesenotes.length).each, which starts counting at 1. My arg i initialises at zero, as normal. For comparison:
define :arpeggiate do |thesenotes, thesedelays|
(0..thesenotes.length-1).each do |i|
puts i
play thesenotes.ring[i], release: 0.4
sleep thesedelays.ring[i]
end #loop
end #define
arpeggiate (chord :c4, '6*9'), [0.125]
Sorry for muddying the waters
PD-Pi
No, on the contrary, you cleared away some underbrush. You’re right, that’s so much simpler.
Ruby is slick!
1 Like
Woah, these are all such cool and interesting ways to think about this problem!! Thanks so much everyone