UPDATE: I dropped a print thisChord1 inside the loop, and discovered the chord isn’t actually changing. Which is good. It just sounds like it is.
So I threw a print count into the loop as well to see what was happening in each loop. Check it out:
{run: 1, time: 0.0, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.0, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.0, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.0, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.5, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.5, thread: :live_loop_channel16}
├─ (ring <SonicPi::Chord :Bb :7 [70, 74, 77, 80])
└─ 2
{run: 1, time: 0.5, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.5, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 0.5, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.0, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.0, thread: :live_loop_channel16}
├─ (ring <SonicPi::Chord :Bb :7 [70, 74, 77, 80])
└─ 3
{run: 1, time: 1.0, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.0, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.0, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.5, thread: :live_loop_channel16}
├─ (ring <SonicPi::Chord :Bb :7 [70, 74, 77, 80])
└─ 4
{run: 1, time: 1.5, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.5, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.5, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 1.5, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.0, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.0, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.0, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.0, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.0, thread: :live_loop_channel16}
├─ (ring <SonicPi::Chord :Bb :7 [70, 74, 77, 80])
└─ 5
=> Stopping all runs...
=> Stopping run 1
{run: 1, time: 2.5, thread: :live_loop_channel16}
└─ midi 80, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.5, thread: :live_loop_channel16}
└─ midi 74, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.5, thread: :live_loop_channel16}
└─ midi 70, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.5, thread: :live_loop_channel16}
└─ midi 77, 127, sustain: 1.0, port: "*", channel: 16
{run: 1, time: 2.5, thread: :live_loop_channel16}
├─ (ring <SonicPi::Chord :Bb :7 [70, 74, 77, 80])
└─ 6
The chord sounds different each time because the midi_chord function is handling/playing that chord’s notes so differently each time. It there something I can do to make it more consistent?
Here is the full code:
chords = [(chord :C, :minor7), (chord :Ab, :major7), (chord :Eb, :major7), (chord :Bb, "7")].ring
thisChord1 = chords.choose
theCount = 1
define :midi_chord do |notes, *args|
notes.each do |note|
midi note, *args
end
end
live_loop :channel16 do
midi_chord thisChord1, release: 0.6, channel: 16
sleep 0.5
print thisChord1
theCount = theCount+1
print theCount
end