Tied notes problem

How could I play this chord image

The basic idea here could be to split it into two groups, one for the top and middle two notes, (since they are the same duration as each other) and another for the bottom one.

Then it’s just a matter of knowing the note values and their durations. It’s been a little while since I’ve properly read music, but as far as I can tell, the top and middle two notes are an eighth note and half note tied together, and the bottom two are an eighth note and quarter note tied together. So, using (for example) this handy note length reference for translating those lengths into durations in Sonic Pi:

We’d be able to calculate the length of the top, middle and bottom tied notes.

Finally, it’d just be a matter of playing them. Because the timing between upper and lower notes is not even, we want to avoid timing difficulties by playing them in separate threads that can play simultaneously with their own particular timing. Whether or not to use plain in_thread, or a live_loop depends on your own preference or situation. (For this example, I’m just demonstrating it with in_thread).

in_thread do
  # top two notes as a note array, double amp because it's divided between each note
  play [top_note, middle_note], amp: 2, release: X
end
in_thread do
  play bottom_note, release: Y
end
1 Like

Ahhhh I understand now, but how could I do this from a function? Is there a way to call two threads at once

This is my code:

use_bpm = 114
use_synth :piano

quaver = 0.5
crotchet = 1
dottedcrotchet = 1.5
minim = 2
semibreve = 4
minimquaver = 2.5

in_thread do
rightHand
end

define :introRH do
play_chord [:F4, :D4, :Bb3]
sleep dottedcrotchet

end

define :rightHand do
introRH
end

And I have done the first notes but can’t get across this hurdle

image

The formatting on that paste went bad, heres a screenshot

You can create these threads inside functions just fine :+1: I’m not quite sure what you are thinking about for your potential code’s layout when you say ‘do this from a function’ though.

(Also, formatting is achieved by placing a blank line before and after your code snippet, and on these lines, placing three backticks each: ```)

The main issue is that you will need multiple threads to play that melody, so one way of writing this could be to change where you are using the threads - instead of wrapping rightHand in a thread, wrap the tied notes in threads like in my original example, and place these in :introRH.