GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - adebiasi/SonicPi: This repo contains some code to practice with SonicPi.

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
DrumBeats
DrumBeats
 
 
GuitarBackingTrackGenerator
GuitarBackingTrackGenerator
 
 
README.md
README.md
 
 
example1.rb
example1.rb
 
 
example10.rb
example10.rb
 
 
example2.rb
example2.rb
 
 
example3.rb
example3.rb
 
 
example4.rb
example4.rb
 
 
example5.rb
example5.rb
 
 
example6.rb
example6.rb
 
 
example7.rb
example7.rb
 
 
example8.rb
example8.rb
 
 
example9.rb
example9.rb
 
 

Repository files navigation

SonicPi

This repo contains some code to practice with SonicPi.

Guitar BackingTrack Generator

Drum Beats

Drum beats samples taken from the following references:

drawing drawing

Basic exercises

Notes and chords

Play a note

play 60

Play 4 random notes

4.times do
  play rrand_i(60, 90)
  sleep 0.5
end

Play a major chord

play chord(60, :M)

Play a minor chord

play chord(60, :m)

Play an sequential arpeggio

loop do
  play chord(60, :M7).tick
  sleep 0.5
end

Play a chord with a random arpeggio

loop do
  play chord(60, :M7), release: 3
  16.times do # 16*0.25 = 4 beats
    play chord(60, :M7).choose
    sleep 0.25
  end
end

Play a shifting chord with a random arpeggio

start_notes = ring(60, 62, 63, 62)
loop do
  my_chord = chord(start_notes.tick, :M7)
  play my_chord, release: 2
  16.times do # 16*0.125 = 2 beats
    play my_chord.choose, release: 0.25
    sleep 0.125
  end
end

Play a shifting minor/major chord with a random arpeggio

notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
  my_chord = chord(notes.tick, chord_type.look)
  play my_chord, release: 2
  16.times do # 16*0.125 = 2 beats
    play my_chord.choose, release: 0.2
    sleep 0.125
  end
end

Play a shifting minor/major chord with a random arpeggio (with parameters)

notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
  my_chord = chord(notes.tick, chord_type.look)
  duration = 4.0
  play my_chord, release: duration
  num_arp_notes = 16
  num_arp_notes.times do
    play my_chord.choose, release: 0.2
    sleep duration/num_arp_notes
  end
end

Play a shifting minor/major chord with a sequential arpeggio (using play_pattern_timed)

notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)
loop do
  my_chord = chord(notes.tick, chord_type.look)
  duration = 4.0
  num_rep = 4
  play my_chord, release: duration
  num_rep.times do
    play_pattern_timed(my_chord.reflect,duration/(my_chord.length*num_rep))
  end
end

Play a shifting minor/major chord with a guitar style arpeggio (using play_pattern_timed)

notes = ring(:c5, :g4, :a4, :f4)
chord_type = ring(:M, :M, :m, :M)

loop do
  my_chord = chord(notes.tick, chord_type.look)
  duration = 4.0
  play my_chord, release: duration
  pattern = chord(notes.look, chord_type.look, num_octaves: 2).take(4).reflect.butlast.repeat(4)
  play_pattern_timed(pattern,duration/pattern.length)
end

Play a shifting minor/major chord with a guitar style arpeggio (using play_pattern_timed and chord_degree)

loop do
  duration = 4.0
  my_chord = chord_degree([8,5,6,4].tick, :c4, :major, 3)
  play my_chord, release: duration
  pattern = (my_chord+my_chord.map{|n| n+12}).take(4).reflect.butlast.repeat(4)
  play_pattern_timed(pattern,duration/pattern.length)
end

Play options

Change amp, same for sample

play 60, amp: 1
sleep 1
play 60, amp: 4
sleep 1
play 60, amp: 6
sleep 1

Change pan, same for sample

play 60, pan: 0
sleep 1
play 60, pan: -1
sleep 1
play 60, pan:1
sleep 1

Change attack, sustain, release

in_thread do
  play 60, attack: 2,sustain: 2,release: 0
  sleep 6
  play 60, attack: 2, sustain: 2,release: 2
  sleep 6
  play 60, attack: 0,sustain: 2,release: 2
  sleep 6
end

loop do
  sample :drum_bass_soft
  sleep 2
end

Samples

Play a sample

sample :drum_bass_hard

Play a simple drum beat

loop do
  sample :bd_haus
  sleep 0.5
end

Alternate kick and snare

loop do
  if tick.even?
    sample :bd_haus
  else
    sample :sn_dolf
  end
  sleep 0.5
end

Combine kick, snare and hi-hat

loop do
  sample :drum_cymbal_closed
  if tick.even?
    sample :bd_haus
  else
    sample :sn_dolf
  end
  sleep 0.25
  sample :drum_cymbal_closed
  sleep 0.25
end

Play a drum loop once

sample :loop_amen

Play a drum loop as a loop

loop do
  sample :loop_amen
  sleep sample_duration(:loop_amen)
end

Try to combine melody, harmony, rhythm (doesn't work)

loop do
  start_note = ring(60, 62, 63, 62).tick
  my_chord = chord(start_note, :M7)
  play my_chord, release: 2
  16.times do
    play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
    sleep 0.125
  end
end

loop do
  sample :loop_amen
  sleep sample_duration(:loop_amen)
end

A fix for Example 13, using threads (drums out of sync)

in_thread do
  loop do
    start_note = ring(60, 62, 63, 62).tick
    my_chord = chord(start_note, :M7)
    play my_chord, release: 2
    16.times do
      play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
      sleep 0.125
    end
  end
end

loop do
  sample :loop_amen
  sleep sample_duration(:loop_amen)
end

A fix for Example 14, drums now in sync

in_thread do
  loop do
    start_note = ring(60, 62, 63, 62).tick
    my_chord = chord(start_note, :M7)
    play my_chord, release: 2
    16.times do
      play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
      sleep 0.125
    end
  end
end

loop do
  sample :loop_amen, beat_stretch: 2
  sleep 2
end

A better way to thread

live_loop :beeps do
  start_note = ring(60, 62, 63, 62).tick
  my_chord = chord(start_note, :M7)
  play my_chord, release: 2
  16.times do
    play my_chord.choose, release: 0.25, amp: [0.75, 0.5, 0.25].choose
    sleep 0.125
  end
end

live_loop :drums do
  sample :loop_amen, beat_stretch: 2
  sleep 2
end

Use a different synth

use_synth :saw
loop do
  play scale(60, :major).choose
  sleep 0.25
end

A simple pattern to demo effects

play 50
sleep 0.5
sample :elec_plip
sleep 0.5
play 62

Adding reverb

with_fx :reverb do
  play 50
  sleep 0.5
  sample :elec_plip
  sleep 0.5
  play 62
end

Adding echo

with_fx :echo do
  play 50
  sleep 0.5
  sample :elec_plip
  sleep 0.5
  play 62
end

Adding reverb and echo together

with_fx :echo do
  with_fx :reverb do
    play 50
    sleep 0.5
    sample :elec_plip
    sleep 0.5
    play 62
  end
end

About

This repo contains some code to practice with SonicPi.

Topics

guitarmusicrubysonic-pi

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.