Continuous key press effect for n beats without taking finger - piano

I want to make an effect of continuous key(note) press for three beats . Say key C4, Key D4 and Key E4 pressed for 3 beats simultaneously without taking finger from keys in piano/keyboard. How can I do it in spi.

Hi,

it is not really clear to me, what you mean. Maybe a (clustered) chord?

live_loop :custom_chord do
   play [:c, :d, :e], release: 3 # depending on what you want use attack, sustain and/or release
   sleep 3
end

An arpeggiated chord?

live_loop :an_arpeggio do
   play (ring :c, :d, :e).tick
   sleep 1
end

?

Here is the link:
Youtube video with Piano

This is what I mean

.
How to convert first few notes to spi.
Is there a detailed tutorial to understand the conversion.

Hi @vinodv,

Converting a single chord, where three or four notes are playing at the same time for a specific length, is fairly simple as Martin has demonstrated in the ‘custom chord’ example that he posted. That is one way of playing three notes at the same time, all with a specific release time.

If you haven’t already, I’d highly recommend working through the tutorial in the app (even if it’s a bit at a time). It’s great at demonstrating things like this, and it’s been designed to be very easy to go through. (Did you manage to have a look at the section introducing notes and melodies that I suggested in your other topic? (Mozart/Titan music Line 1))

Combining several chords and other notes into a semi-complex multi-voice piece with multiple melodies, such as the one you’re aiming for, is definitely possible - you just need to know how to play different melodies at the same time - which is where things like live_loop come in. That’s all explained in Chapter 9. (For example, maybe you’d have one loop for left hand and one for right hand, or maybe even more if the melodies are sufficiently complex…)

There is a section in the tutorial towards the end that takes a classical melody and walks through translating it into Sonic Pi code. (Appendix A.7, ‘Bizet Beats’). This may be helpful to you to some degree - depending on how familiar you are with Sonic Pi syntax you may need to jump back and work your way through earlier parts of the tutorial to make things clearer. (It’s designed to be ideal to work through start to finish). The Bizet Beats chapter doesn’t strictly deal with multiple melodies playing at the same time, but it may give you some of the idea of the translation process at least.

1 Like

Hi @vinodv,
Following on from Ethan’s reply I thought I’d post an example showing notes coded up from the beginning of Mozart’s Symphony. I’m not sure if you read music, but I used this section of score shown in the image below, and coded the first 12 bars. Essentially you produce a list of notes and corresponding list of the note durations required where 1 is the length of a crotchet, 0.5 the length of a quaver, 2 the length of a minim etc. You can then use the play_pattern_timed command from Sonic Pi to play these.
Further complications like two (or more) notes playing together in a chord can be included by putting these notes in their own sublist inside […]
It is a good idea to space the lists out in bar units, which helps checking and relating it to the printed score. There are further complications which need to be addressed for more complex music. For example in bar 13 (just after I stopped) You would actually have to introduce a third part to play the left hand part as the [:g3,:d4] chord lasting 2 beats overlaps the sequence :r, :g2,:bb2,:d3 each lasting 1 beat and would have to be played in separate parts as the notes change at different times.
It is a good exercise to code this by hand (as I did here). For more complex pieces I now use scripts to help me based a script by Hiroshi Tachibana but they are not for a beginner!

mozart25

#mozart symphony 25 piano reduction first 12 bars
#coded for Sonic Pi by Robin Newman, Dec 2020

#This example shows in detail how you can transcribe a piano part to play in Sonic Pi
use_bpm 150 #set thetempo
use_synth :piano#set the synth
#make a list of the notes in the right hand
#notes have pitch plus octave number
#flat notes have an extra b, sharp notes an extra s added eg :bb4 or :fs3
#notes inside [..] play together as a chord
#the list is spaced in bars to make it easier to follow
n1=[:g5,:g5,:g5,:g5,:g5,
    :d5,:d5,:d5,:d5,:d5,
    :eb5,:eb5,:eb5,:eb5,:eb5,
    :fs4,:fs4,:fs4,:fs4,:fs4,
    :g4,:bb4,:d5,:g5,:bb5,:a5,:g5,:fs5,:g5,
    :g4,:bb4,:d5,:g5,:bb5,:a5,:g5,:fs5,:g5,
    :a4,:c5,:fs5,:a5,:c6,:bb5,:a5,:g5,:a5,
    :a4,:c5,:fs5,:a5,:c6,:bb5,:a5,:g5,:a5,
    :bb4,:d5,:g5,:bb5,:d6,:c6,:bb5,:a5,:bb5,
    :bb5,:a5,:g5,:fs5,:g5,:g5,:f5,:eb5,:d5,:eb5,:d5,:c5,:bb4,
    :c5,:c5,:bb4,:bb4,:a4,:a4,:g4,:g4,
    [:fs3,:fs4],[:d4,:d5],:r]
#make a list of the durations of the notes/chords in the right hand
#1 == crotched, 0.5 = quaver, 0.25 = semiquaver
#the list is spaced in bars to make it esier to follow
d1=[0.5,1,1,1,0.5,
    0.5,1,1,1,0.5,
    0.5,1,1,1,0.5,
    0.5,1,1,1,0.5,
    0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,1,
    0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,1,
    0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,1,
    0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,1,
    0.5,0.5,0.5,0.5,0.25,0.25,0.25,0.25,1,
    0.25,0.25,0.25,0.25,1,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,
    0.75,0.25,0.75,0.25,0.75,0.25,0.75,0.25,
    1,1,2]

#similar lists for the notes and durations in the left hand follow
n2=[[:g2,:g3],[:g2,:g3],[:g2,:g3],[:g2,:g3],
    [:d2,:d3],[:d2,:d3],[:d2,:d3],[:d2,:d3],
    [:eb2,:eb3],[:eb2,:eb3],[:eb2,:eb3],[:eb2,:eb3],
    [:fs1,:fs2],[:fs1,:fs2],[:fs1,:fs2],[:fs1,:fs2],
    [:g2,:g3],:r,:bb3,:a3,:g3,:fs3,:g3,
    [:g2,:g3],:r,:bb3,:a3,:g3,:fs3,:g3,
    [:a2,:a3],:r,:c4,:bb3,:a3,:g3,:a3,
    [:a2,:a3],:r,:c4,:bb3,:a3,:g3,:a3,
    [:bb2,:bb3],:r,:d4,:c4,:bb3,:a3,:bb3,
    :bb3,:a3,:g3,:fs3,:g3,:g4,:f4,:eb4,:d4,:eb4,:d4,:c4,:bb3,
    [:c3,:c4],[:bb2,:bb3],[:a2,:a3],[:g2,:g3],
    [:fs1,:fs2],[:d2,:d3],:r]
d2=[1,1,1,1,
    1,1,1,1,
    1,1,1,1,
    1,1,1,1,
    1,1,0.25,0.25,0.25,0.25,1,
    1,1,0.25,0.25,0.25,0.25,1,
    1,1,0.25,0.25,0.25,0.25,1,
    1,1,0.25,0.25,0.25,0.25,1,
    1,1,0.25,0.25,0.25,0.25,1,
    0.25,0.25,0.25,0.25,1,0.25,0.25,0.25,0.25,0.25,0.25,0.25,0.25,
    1,1,1,1,
    1,1,2]

#use the command play_pattern_timed to play the notes
#this is followed by two corresponding lists of notes and durations

#The right hand part is played inside a thread. This takes "zero" time to start
#and allows the play_pattern_timed command for the left had part to start at the same time
in_thread do
  play_pattern_timed n1,d1
end
play_pattern_timed n2,d2
2 Likes

This code is helpful for sheet music to spi conversion. I will try for the specific piece of music(which is coming somewhere in between) which I asked.