Skip to content

Instantly share code, notes, and snippets.

@jaemo
Forked from carltesta/sonic_pi_commands.rb
Created August 27, 2024 06:18
Show Gist options
  • Save jaemo/5197dd66bb6b7bc89fc4d07e2bbbd4ac to your computer and use it in GitHub Desktop.
Save jaemo/5197dd66bb6b7bc89fc4d07e2bbbd4ac to your computer and use it in GitHub Desktop.

Revisions

  1. @carltesta carltesta revised this gist Oct 13, 2020. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion sonic_pi_commands.rb
    Original file line number Diff line number Diff line change
    @@ -90,4 +90,14 @@
    use_synth :piano
    play (ring :c4, :g4, :e4, :a4, :d4, :b4).choose
    sleep (ring 0.25, 0.5, 0.75).tick
    end
    end

    #live_audio enables you to use your built-in microphone with Sonic Pi effects
    #Important! Run this with headphones plugged in
    with_fx :reverb, room: 1 do
    with_fx :echo, phase: 0.5, decay: 6 do
    live_audio :voice
    end
    end
    #if you have to stop an instance of live_audio you can use the parameter :stop
    live_audio :voice, :stop
  2. @carltesta carltesta revised this gist Oct 5, 2020. 1 changed file with 14 additions and 4 deletions.
    18 changes: 14 additions & 4 deletions sonic_pi_commands.rb
    Original file line number Diff line number Diff line change
    @@ -59,13 +59,13 @@
    end
    end

    #create a function with the define command to wrap some code into a name you can refer to
    #create a function with the define command to wrap some code into a name you can refer to
    #define name (symbol)
    #Usage:
    define :foo do #create function foo which plays back note 50 and waits for 1 beat
    play 50
    sleep 1
    end
    play 50
    sleep 1
    end

    foo

    @@ -81,3 +81,13 @@
    end
    sleep 1
    end

    #ring is a list that wraps back from the end to the beginning
    #Usage:
    (ring 0.25, 0.5, 1, 2)
    #if you use the command .tick on a ring it will keep playing from the end to the beginning
    live_loop :mel do
    use_synth :piano
    play (ring :c4, :g4, :e4, :a4, :d4, :b4).choose
    sleep (ring 0.25, 0.5, 0.75).tick
    end
  3. @carltesta carltesta revised this gist Oct 2, 2020. 1 changed file with 0 additions and 14 deletions.
    14 changes: 0 additions & 14 deletions sonic_pi_commands.rb
    Original file line number Diff line number Diff line change
    @@ -81,17 +81,3 @@
    end
    sleep 1
    end














  4. @carltesta carltesta revised this gist Oct 2, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sonic_pi_commands.rb
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@
    #live_loop name (symbol)
    #Usage:
    live_loop :loop do
    sample :loop_amen
    sleep sample_duration :loop_amen #use to return the length of the specified sample
    sample :loop_amen
    sleep sample_duration :loop_amen #use to return the length of the specified sample
    end

    #Change the synth currently in use with the use_synth command
  5. @carltesta carltesta created this gist Oct 2, 2020.
    97 changes: 97 additions & 0 deletions sonic_pi_commands.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,97 @@
    #Sonic Pi Command List
    #Copy and Paste from this command list into your sonic pi file

    #Use the command play to play a note using the default synth
    #play note (symbol_or_number)
    #Usage:
    play 60 #midinote 60 or middle c
    play :c4 #create a symbol by typing colon then the note name and an octave designation
    play :e5, release: 2, amp: 0.5 #you can add parameters as well

    #Use the command sleep to wait before executing the next command
    #sleep beats (number)
    #Usage:
    sleep 1 #wait for 1 beat before executing the next command (quarter note in 4/4)
    sleep 0.5 #wait for half a beat (eighth note in 4/4)
    sleep 0.25 #wait for a quarter of a beat (sixteenth note in 4/4)

    #use the sample command to play back some recorded audio
    #sample name_or_path (symbol_or_string)
    #Usage:
    sample :drum_bass_hard, rate: 0.5 #play the sample at half speed (pitch drops by an octave)
    sample :drum_bass_hard, rate: -1 #play the sample backwards!

    #Use the live_loop to loop a bit of code over and over, redefine it as many times as you want and it automatically updates
    #live_loop name (symbol)
    #Usage:
    live_loop :loop do
    sample :loop_amen
    sleep sample_duration :loop_amen #use to return the length of the specified sample
    end

    #Change the synth currently in use with the use_synth command
    #use_synth synth_name (symbol)
    #Usage:
    use_synth :dark_ambience
    play :d2, attack: 2, release: 4

    #use the chord command to play a chord
    #chord tonic (symbol), name (symbol)
    #Usage:
    play chord :c3, :minor7
    sleep 2
    play chord :g3, :dom7

    #scale tonic (symbol), name (symbol)
    #Usage:
    live_loop :scale do
    play (scale :a3, :hungarian_minor).tick
    sleep 1
    end

    #wrap some code in a special effect like reverb, echo, distortion, etc
    #with_fx fx_name (symbol)
    #Usage:
    live_loop :drums do
    with_fx :distortion, distort: 0.9 do
    sample :loop_amen
    sleep sample_duration :loop_amen
    end
    end

    #create a function with the define command to wrap some code into a name you can refer to
    #define name (symbol)
    #Usage:
    define :foo do #create function foo which plays back note 50 and waits for 1 beat
    play 50
    sleep 1
    end

    foo

    #use a conditional like one_in to let Sonic Pi flip a coin and choose which code to execut
    #one_in num (number)
    #Returns true or false with a specified probability - it will return true every one in num times where num is the param you specify
    #Usage:
    live_loop :condition do
    if one_in 2
    play 60 #if one_in returns true, play 60
    else
    play 72 #else if one_in returns false, play 72
    end
    sleep 1
    end