Using samples to play a chord sequence

Hello , new to sonic pi , i was using an inbuilt synth to generate the following chord sequence

use_bpm 120

#use_synth_defaults  amp: 0.7, cutoff: 60
#use_synth_defaults wave: 1, phase: 0.25, release: 1, cutoff: 66
#use_synth :tb303
#sample :bass_hit_c
use_synth :dpulse
8.times do
  play :D
  sleep 1
end
3.times do
  play :C
  sleep 1
end
3.times do
  play :B
  sleep 1
end
1.times do
  play :C
  sleep 1
end
8.times do
  play :D
  sleep 1
end
2.times do
  play :F
  sleep 1
end
2.times do
  play :C
  sleep 1
end
3.times do
  play :B
  sleep 1
end
1.times do
  play :C
  sleep 1
end

9.times do
  play :D
  sleep 1
end

3.times do
  play :C
  sleep 1
end

Instead of the synth , i wanted to use the sample sample :bass_hit_c to create a sound sequence in the above pattern. Is it not possible to manipulate samples just like synths ? ( I was trying to recreate the pattern of in motion soundtrack, as a context and the sample :bass_hit_c was perfect for one layer. Any idea would be appreciated

Maybe you can use the pitch parameter of the sample instruction. +12 to get an octave higher.
I haven’t tested it’s an idea maybe I am totally wrong :laughing:

Check if there is a pitch parameter not sure at all… right now far from a sonicpi to see

Pitch is a pitch-shifter effect, there is rpitch which changes the rate of the sample. Both work in semitones, I don’t know if you can give them note names.

sample :sample, rpitch [0,7,12).look

1 Like

Could you explain it a bit in this context ? If i want to start with a D note and do the manipulations

This will play a d major scale using the tom_lo_lhard sample which naturally sounds as a g The rpitch: value is the difference between the note required and the natural pitch of the sample. Find the natural pitch by playing the sample and a known note with a synth and adjust that note until they are the same.

define :ps do |n|
  sample :drum_tom_lo_hard,rpitch: n - note(:g2)
end

tune = scale(:d3,:major)

tune.each do |n|
  ps n
  sleep 0.25
end

Thanks , I am trying to understand it but i feel a bit lost (beginner level in prog). I am wondering how can i convert or map it to the below format.

8.times do
  play :D
  sleep 1
end
3.times do
  play :C
  sleep 1
end

The note :C is equivalent to :c4 (the c in octave 4). This is quite high for a drum, but you could play it like this.

8.times do
  sample :drum_tom_lo_hard,rpitch: :d4 - note(:g2)
  sleep 1
end
3.times do
  sample :drum_tom_lo_hard,rpitch: :c4- note(:g2)
  sleep 1
end

You may find it better down an octave, changing the :d4 and :c4 for :d3 and :c3

You can simplify the code by defining a function to play the sample by defining

define :playsample do |n|
  sample :drum_tom_lo_hard,rpitch: n - note(:g2)
end

you can then use this in the form
playsample :c4
This will substitute the paramter n with :c4, work out the difference in pitch between it and the natural pitch of note(:g2)and then play the sample using this as a relative pitch value eg up 4 semitones or down 2 semitones.

define :playsample do |n|
  sample :drum_tom_lo_hard,rpitch: n - note(:g2)
end

8.times do
  playsample :d4
  sleep 1
end
3.times do
 playsample :c4
  sleep 1
end
3 Likes