Skip to content

Instantly share code, notes, and snippets.

@nicoder
Created December 19, 2021 07:57
Show Gist options
  • Select an option

  • Save nicoder/50a858114ed36471e49c4bbeb0e48237 to your computer and use it in GitHub Desktop.

Select an option

Save nicoder/50a858114ed36471e49c4bbeb0e48237 to your computer and use it in GitHub Desktop.

Revisions

  1. nicoder created this gist Dec 19, 2021.
    40 changes: 40 additions & 0 deletions 20211219_sonic_pi.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # adapted from robin newman:
    # https://in-thread.sonic-pi.net/t/record-vocal-and-playback-with-effects/6202/5

    use_bpm 60
    use_real_time
    i = 0
    buffers = []
    duration = 8

    4.times do
    play 84, release: 0.2, amp: 0.3
    sleep 1
    end

    live_loop :a do
    puts "record";play 84,release: 0.2, amp: 0.3
    b = buffers[i] = buffer('buff' + i.to_s, 8)
    puts "buffer beats #{b.duration}"
    with_fx :record, buffer: b do
    with_fx :level, amp: 2 do
    live_audio :mic
    sleep b.duration
    #sleep rt(5)
    end
    end
    i = i + 1
    end

    live_loop :b do
    #sync :a
    with_fx :reverb, room: 0.8 do #apply some reverb as an example
    buffers.each do |b|
    sample b, rate: 1
    end
    sleep duration
    end
    puts "ended"
    puts "wait"
    # sleep rt(5)
    end