It seems to work but not sure the code is very very good… Note that i meet an issue as the tempo is very hazardous. So kings of code, is you can test this, i will appreciate.
use_bpm 120
live_loop :sendChordsNotesViaOSC do
##| stop
notes = chord :c, :madd11
# we get a ring
puts notes
##| play_chord notes
##| sleep 4
##| notes.each do | n |
##| osc "/foo/notes", n
##| end
# we can' send a ring via osc maybe using an array ?
tab = Array.new
notes.each_with_index do |n, idx|
tab[idx] = n
end
##| puts tab
##| So no this does not work with array
##| osc "/foo/notes", tab
## so we send a string, each note separated by a space to split this string at the reception
puts notes_sent = notes.join(" ")
osc "/foo/notes", notes_sent
# just send a amp integer value
osc "/foo/notes/amp", [0.5, 1, 2].tick
sleep 4
end
live_loop :player do
use_real_time
msg = sync "/osc*/foo/notes"
# we get a string
puts msg[0]
# but play_chord wants an array...
# So how can i rebuilt an array from the string ?
foo = msg[0].split
puts foo
# but we need to convert into an integer
goo = Array.new
foo.each_with_index do |s, k|
goo[k]=s.to_i
end
puts goo
arrayNotes = [:c, :e, :a, :c5, :d5]
vol = sync "/osc*/foo/notes/amp"
synth :dsaw, attack: 0, amp: vol[0], notes: goo
# synth :dsaw, attack: 0, amp: vol[0], notes: arrayNotes
end
My reply there should give you at least a clue
The tricky bit however, is that if you want to send multiple values from a ring or array as a single parameter to osc, (rather than passing the osc function multiple data parameters as I describe in that thread) you need to lean into a trick of plain old Ruby: the splat operator
So the line would become something like:
Ah.
I hear an occasional silence as the chord sometimes doesn’t play for a beat.
If you add use_real_time to the :sendChordsNotesViaOSC loop, then it seems to me to play the chord every beat as expected. Does that help?