├── examples ├── 2_loops_in_control.rb ├── drum_examples.rb ├── end_echo.rb ├── footsteps.rb ├── frere_jaques.rb ├── funk_bass.rb ├── saw_wave_additive.rb ├── sweeping_filters.rb ├── throb.rb ├── thx_sound.rb ├── timbre_part_1.rb ├── timbre_part_2.rb ├── timbre_part_3.rb ├── timbre_part_4.rb ├── timbre_part_5.rb ├── timbre_part_6.rb ├── timbre_part_7.rb └── timbre_part_8.rb ├── grooves ├── PPK.rb ├── ambient.rb ├── bits_and_bytes.rb ├── dirty_bass.rb ├── ff_prelude.rb ├── humming_samples.rb ├── moon_logic.rb ├── piano_and_strings.rb ├── smb_overland.rb └── stranger_rings.rb └── synthtober_2017 ├── 2017_10_02_chimes.rb ├── 2017_10_08_chimes_fm.rb ├── 2017_10_11_sfx_1.rb └── 2017_10_18_song.rb /examples/2_loops_in_control.rb: -------------------------------------------------------------------------------- 1 | use_synth_defaults attack: 0.2, sustain: 2.8, release: 0.2 2 | with_fx :ixi_techno, res: 0, cutoff_min: 30, cutoff_max: 120, phase: 32 do |fx| 3 | live_loop :c do 4 | at [16,0], [0,1] do |a,b| 5 | puts "set control to #{b}" 6 | control fx, mix: b, mix_slide: 0.2 7 | end 8 | sleep 32 9 | end 10 | live_loop :d do 11 | sample :loop_amen, beat_stretch: 2 12 | sleep 2 13 | end 14 | end -------------------------------------------------------------------------------- /examples/drum_examples.rb: -------------------------------------------------------------------------------- 1 | define :hat do 2 | with_bpm 60 do 3 | with_fx :rlpf, cutoff: [110,90,120].choose, res: [0.7,0.9].choose do |lfx| 4 | with_fx :rhpf, cutoff: [60,70,80].choose, res: 0.9, mix: 0.2 do |hfx| 5 | control lfx, res: 0.7, res_slide: 0.1 6 | control hfx, res: 0.4, res_slide: 0.1 7 | synth :noise, release: 0.1 8 | end 9 | end 10 | end 11 | end 12 | 13 | define :snare do |n=:c4| 14 | with_bpm 60 do 15 | with_fx :lpf, cutoff: 90 do |lpf| 16 | with_fx :hpf, cutoff: 70 do |hpf| 17 | s = synth :tri, note: n, release: 0.15 18 | control s, note: n-12, note_slide: 0.1 19 | synth :noise, amp: 3, release: 0.15 20 | control hpf, cutoff: 30, cutoff_slide: 0.05 21 | control lpf, cutoff: 40, cutoff_slide: 0.15 22 | end 23 | end 24 | end 25 | end 26 | 27 | live_loop :drum do 28 | use_bpm 200 29 | use_random_seed 90 30 | at [1,3,4,5,7.5,8] do 31 | snare :c4+rrand(-3,3) 32 | end 33 | at range(1,8,step:0.5) do 34 | hat 35 | end 36 | sleep 8 37 | end 38 | 39 | -------------------------------------------------------------------------------- /examples/end_echo.rb: -------------------------------------------------------------------------------- 1 | delay = 2 2 | echoes = 10 3 | sample :loop_amen, beat_stretch: delay, finish: 6.0/8.0 4 | sleep delay*6.0/8.0 5 | with_fx :echo, phase: delay*0.15, decay: echoes*delay*0.15 do 6 | sample :loop_amen, beat_stretch: delay, start: 6.0/8.0, finish: 7.0/8.0 7 | end -------------------------------------------------------------------------------- /examples/footsteps.rb: -------------------------------------------------------------------------------- 1 | use_bpm 60 2 | live_loop :curve do 3 | with_fx :hpf, cutoff: [40,60,80].choose do 4 | synth :cnoise, attack: 0.02, release: 0.01, decay: 0.02, sustain: 0.03, sustain_level: 0.1, env_curve: 6 5 | sleep 0.5 6 | end 7 | end -------------------------------------------------------------------------------- /examples/frere_jaques.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | use_octave -1 3 | 4 | define :jaques do 5 | 2.times do 6 | play_pattern [:c,:d,:e,:c] 7 | end 8 | 2.times do 9 | play_pattern [:e,:f,:g,:r] 10 | end 11 | 2.times do 12 | play_pattern_timed [:g,:a,:g,:f,:e,:r,:c,:r], 0.5 13 | end 14 | 2.times do 15 | play_pattern [:c,:g3,:c,:r] 16 | end 17 | end 18 | 19 | 3.times do |i| 20 | in_thread do 21 | use_synth [:beep,:saw,:square][i] 22 | jaques 23 | end 24 | sleep 8 25 | end -------------------------------------------------------------------------------- /examples/funk_bass.rb: -------------------------------------------------------------------------------- 1 | last_note = nil 2 | define :bass do |n,d| 3 | with_bpm 60 do 4 | with_fx :rhpf, cutoff: 40 do 5 | with_fx :rlpf, cutoff: 120, res: 0.5 do |fx| 6 | with_octave -3 do 7 | unless n == :r 8 | last_note ||= n 9 | s = synth :saw, note: last_note, attack: 0.1, sustain: d, release: 0.2 10 | control s, note: n, note_slide: 0.15 11 | with_cent_tuning 4 do 12 | s2 = synth :square, attack: 0.1, note: last_note, sustain: d, release: 0.2 13 | control s2, note: n, note_slide: 0.15 14 | end 15 | last_note = n; 16 | else 17 | last_note = nil; 18 | end 19 | end 20 | at [d] do 21 | control fx, cutoff: 80, cutoff_slide: 0.2 22 | end 23 | end 24 | end 25 | end 26 | end 27 | 28 | live_loop :funk do 29 | at [1, 1.5, 1.75, 2, 2.25, 2.5, 2.75] do |d,i| 30 | puts i 31 | bass [:e,:c5,:e,:d,:e,:c,:d,:e][i], 0.25 32 | end 33 | sleep 2 34 | end 35 | -------------------------------------------------------------------------------- /examples/saw_wave_additive.rb: -------------------------------------------------------------------------------- 1 | use_synth :saw 2 | play 60, amp: 1, pan: -1, attack: 0, release: 0, sustain: 1 3 | play 60, amp: 1, pan: 1, attack: 0, release: 0, sustain: 1 4 | 5 | sleep 1 6 | 20.times do |j| 7 | use_synth :saw 8 | play 60, amp: 1, pan: -1, attack: 0, release: 0, sustain: 0.25 9 | use_synth :beep 10 | (j+1).times do |i| 11 | hz = midi_to_hz(60)*(i+1.0) 12 | puts hz 13 | play hz_to_midi(hz), amp: 0.5/(i+1), pan: 1, attack: 0, release: 0, sustain: 0.25 14 | end 15 | sleep 0.25 16 | end 17 | 18 | sleep 1 19 | 20 | use_synth :saw 21 | play 60, amp: 1, pan: -1, attack: 0, release: 0, sustain: 2 22 | use_synth :beep 23 | 20.times do |i| 24 | hz = midi_to_hz(60)*(i+1.0) 25 | puts hz 26 | play hz_to_midi(hz), amp: 0.5/(i+1), pan: 1, attack: 0, release: 0, sustain: 2 27 | end -------------------------------------------------------------------------------- /examples/sweeping_filters.rb: -------------------------------------------------------------------------------- 1 | use_synth :saw 2 | 3 | define :lpf_sweep do |p| 4 | with_fx :lpf, cutoff: 0 do |fx| 5 | play 60, amp: 1, pan: p, attack: 0, release: 0, sustain: 10 6 | sleep 2 7 | control fx, cutoff: 130.999, cutoff_slide: 5 8 | end 9 | end 10 | 11 | define :hpf_sweep do |p| 12 | with_fx :hpf, cutoff: 0 do |fx| 13 | play 60, amp: 1, pan: p, attack: 0, release: 0, sustain: 10 14 | sleep 2 15 | control fx, cutoff: 130.999, cutoff_slide: 5 16 | end 17 | end 18 | 19 | define :bpf_sweep do |p| 20 | with_fx :bpf, centre: 0 do |fx| 21 | play 60, amp: 1, pan: p, attack: 0, release: 0, sustain: 10 22 | sleep 2 23 | control fx, centre: 130.999, centre_slide: 5 24 | end 25 | end 26 | 27 | #play 60, amp: 1, pan: -1, attack: 0, release: 0, sustain: 10 28 | in_thread do 29 | lpf_sweep(-1) 30 | end 31 | #sleep 10 32 | in_thread do 33 | #hpf_sweep(-1) 34 | end 35 | #sleep 10 36 | in_thread do 37 | bpf_sweep(1) 38 | end -------------------------------------------------------------------------------- /examples/throb.rb: -------------------------------------------------------------------------------- 1 | last_note = nil 2 | define :foo do |n| 3 | in_thread do 4 | return if rest? n 5 | last_note ||= n 6 | with_fx :rlpf, cutoff: 90, res: 0.7 do |lpf| 7 | control lpf, cutoff: 10, cutoff_slide: 0.5 8 | with_synth_defaults attack: 0.05, release: 0.05, sustain: 0.25 do 9 | with_cent_tuning 10 do 10 | s1 = synth :saw, note: n, amp: 0.8 11 | control s1, note: n-12, note_slide: 0.1 12 | end 13 | #last_note = n 14 | s2 = synth :fm, note: last_note, amp: 1, divisor: 2, depth: 10 15 | control s2, note: n, note_slide: 0.15 16 | last_note = n 17 | #control s2, note: n-12, note_slide: 0.2 18 | synth :pnoise, amp: 0.8, attack: 0.1, release: 0.1, sustain: 0.0 19 | end 20 | end 21 | end 22 | end 23 | 24 | live_loop :bass do 25 | with_octave -2 do 26 | with_fx :reverb, room: 0.6, damp: 1 do 27 | #foo %i[e r c5 r b a r d e f f e r a g d].ring.tick 28 | foo %i[e e e e e e f f e e e e e e d d].ring.tick 29 | sleep 0.25 30 | end 31 | end 32 | end -------------------------------------------------------------------------------- /examples/thx_sound.rb: -------------------------------------------------------------------------------- 1 | #THX Sound 2 | use_synth :saw 3 | 4 | define :rtone do 5 | hz_to_midi(rrand(200,400)) 6 | end 7 | 8 | define :thx_voice do |end_pitch| 9 | in_thread do 10 | n = play rtone, attack: 8, sustain: 12, release: 4, amp: 0.01 11 | at [0,6] do 12 | control n, note: rtone, note_slide: 6 13 | end 14 | at [8] do 15 | control n, note: end_pitch, note_slide: 6, amp: 0.25, amp_slide: 12 16 | end 17 | end 18 | end 19 | 20 | [:a2,:d3,:a3,:d,:a,:d5,:a5,:d6,:f6].each do |final| 21 | thx_voice final + 0.1 22 | thx_voice final - 0.1 23 | thx_voice final 24 | end 25 | 26 | [:d1,:d2].each do |final| 27 | thx_voice final 28 | thx_voice final 29 | end 30 | -------------------------------------------------------------------------------- /examples/timbre_part_1.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 1 4 | # By Adrian Cheater 5 | # 6 | # This series of code snippets are meant to demonstrate the effect of filters on different synths 7 | # in order to help better understand how different kinds of sound are produced. 8 | # 9 | # What is Timbre? 10 | # Timbre is the name we give to the way a sound 'sounds'. Different instruments, even when playing 11 | # the same note, sound different. This is why we can tell a trumpet from a piano or guitar. 12 | # 13 | # But how is Timbre produced? 14 | # Timbre is made when different amounts of harmonics are played along with the main note. 15 | # The main note, or 'fundamental frequency' is what we pass to the play function, like :c4 16 | # Harmonics are multiples of that fundamental frequency. So for example, the note :a3 is 110 Hertz (Hz) 17 | # That means that the wave shape we're using gets repeated 110 times per second. The harmonics 18 | # of :a3 are then found at 220, 330, 440, 550, 660, 770... Hz. 19 | # It is the use of some or all those harmonics that change how we perceive the timbre of the sound. 20 | # 21 | # In sonic pi, the building blocks of most sounds or synths are the sine, square, saw, and triangle waves. 22 | # Each of them have a different timbre which you can hear when the same note is played switching between the 23 | # different synths in 'compare_synths' 24 | 25 | define :compare_synths do 26 | 4.times do 27 | %i(sine saw square tri).each do |synth| 28 | use_synth synth 29 | play :c3 30 | sleep 1.0 31 | end 32 | end 33 | end 34 | compare_synths 35 | 36 | # If the different synths have different Timbre, then this means they must involve different kinds 37 | # of harmonics. In the next example, we'll look more closely at those different synths and how it 38 | # is that they get their Timbre. -------------------------------------------------------------------------------- /examples/timbre_part_2.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 2 4 | # By Adrian Cheater 5 | # 6 | # From the last example, we saw there are 4 kinds of waveforms that are used in almost all synths. 7 | # They are the sine, sawtooth, square, and triangular wave, each with their own sound. 8 | # But there's something special about the sine wave, and its relationship with the others. 9 | # 10 | # Sine waves 11 | # The documentation for Sonic Pi talks about sine synths as being 'pure' notes. 12 | # But what does that mean? It means that the wave form doesn't have any harmonics included. 13 | # What is a harmonic? A harmonic is a multiple of the frequency of the note you're trying to play. 14 | # That note is the value you pass to the play commands, and is also known as the 'fundamental frequency' 15 | # Harmonics are always higher frequency (higher pitched) versions of wave. 16 | # 17 | # So when you play a note with a sine synth, you are only hearing that fundamental frequency, nothing else. 18 | # All other waves can be made by mixing together several sine waves at different frequencies and strengths, 19 | # and each new sine wave added into the mix will change the note's timbre. 20 | # When you're trying to create a new sound by playing several sine waves at the same time, that's called 21 | # "Additive Synthisys", and is one way to make things sound new. Here's an example. 22 | 23 | define :add_sine do 24 | use_synth :sine 25 | 26 | 10.times do |i| 27 | use_random_seed 37 28 | base_freq = midi_to_hz(:c2) 29 | notes = range(2,11).shuffle 30 | 31 | play hz_to_midi(base_freq), sustain: 1.0, amp: 1.0 32 | i.times do |j| 33 | play hz_to_midi(base_freq*notes[j]), amp: 1.0/(j+2), sustain: 1.0, release: 0.1 34 | end 35 | sleep 1.5 36 | end 37 | end 38 | add_sine 39 | 40 | # When you listen to it, it's adding random harmonics at diminishing strengths 41 | # Even though the fundamental :c2 is the loudest single waveform, you can hear 42 | # how the timbre and sometimes even the perceived pitch changes as more waves 43 | # are introduced. Next time we'll look at some other waves that aren't produced 44 | # with additive synthisys, but who's shape contains many harmonics within them. 45 | 46 | -------------------------------------------------------------------------------- /examples/timbre_part_3.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 3 4 | # By Adrian Cheater 5 | # 6 | # Saw, Square, and Triangle waves 7 | # We've listened to the sound of single sine wave, and how adding multiple harmonics 8 | # together can change the timbre of a sound. But what about these other basic 9 | # synths? They are named for the shapes of their wave forms, and compared to the 10 | # smooth curvy shape of a sine wave, they look like they're much easier to generate. 11 | # But there's something very cool going on with those waveforms. 12 | # 13 | # While they're not actually made up of a bunch of sine waves, we can get very close to 14 | # re-creating their shape if we add up sine waves in certain patterns. Have a listen. 15 | 16 | define :saw_vs_sine do 17 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.7 18 | (10..120).step(5) do |t| 19 | puts "Approximating saw wave with #{t} sine waves" 20 | use_synth :saw 21 | play :c2 22 | sleep 0.7 23 | use_synth :sine 24 | note = midi_to_hz(:c2) 25 | (1..t).each do |i| 26 | play hz_to_midi(note*i), amp: 1.0/i.to_f 27 | end 28 | sleep 0.7 29 | end 30 | end 31 | saw_vs_sine 32 | 33 | # You might notice that around 100 or so sine waves in, the two wave forms might start to sound nearly or 34 | # entirely identical. We can keep playing more and more sine waves until they are inperceptively different 35 | # to the average person. But what does it mean if they sound the same? 36 | # 37 | # It means that the saw wave, while simple, sounds to our ears as if it is made up of hundreads of harmonics. 38 | # It is full of them, following a very specific pattern. A saw wave can be though of containing every 39 | # harmonic (multiple) of the fundamental (starting) frequency, with the volume decreasing as the harmonic 40 | # increases. So if you're playing a 220 Hz tone (:a3), at full volume, you also get 440 Hz at half volume, 41 | # 660 Hz at 1/3 volume, 880 Hz at 1/4, 1100 Hz at 1/5, etc... all for free, it's very easy for sonic pi 42 | # to give you a lot of harmonics without a lot of work this way. 43 | 44 | # Square waves are similar, have a listen 45 | 46 | define :square_vs_sine do 47 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.7 48 | (10..120).step(5) do |t| 49 | puts "Approximating square wave with #{t} sine waves" 50 | use_synth :square 51 | play :c2 52 | sleep 0.7 53 | use_synth :sine 54 | note = midi_to_hz(:c2) 55 | (1..t).step(2) do |i| 56 | play hz_to_midi(note*i), amp: 1.0/i.to_f 57 | end 58 | sleep 0.7 59 | end 60 | end 61 | square_vs_sine 62 | 63 | # Same system as the saw wave, but a different pattern, this time we're only using every other harmonic. 220 Hz, 64 | # 660 Hz, 1100 Hz, etc.. 65 | 66 | # And for triangle waves 67 | 68 | define :tri_vs_sine do 69 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.7 70 | (10..80).step(5) do |t| 71 | puts "Approximating triangle wave with #{t} sine waves" 72 | use_synth :tri 73 | play :c2 74 | sleep 0.7 75 | use_synth :sine 76 | note = midi_to_hz(:c2) 77 | (1..t).step(2) do |i| 78 | unless i % 4 == 0 79 | play hz_to_midi(note*i), amp: 1.0/(i*i).to_f 80 | else 81 | in_thread do 82 | sleep 2.0/(note*i) 83 | play hz_to_midi(note*i), amp: 1.0/(i*i).to_f 84 | end 85 | end 86 | end 87 | sleep 0.7 88 | end 89 | end 90 | tri_vs_sine 91 | 92 | # With triangle waves we don't need as many sine waves to get close to the same sound. The reason 93 | # for this is because the volume of each harmonic drops by the square of its value, so by the time 94 | # you're 10 harmonics in, you're already at 100th of the volume. Like square waves, we only use the 95 | # odd harmonics, but we also do something else, each 4th harmonic we have to play half way out 96 | # of phase, we do this by waiting half the wavelength (2.0/frequency) which causes the wave to move 97 | # in the opposite direction, we could also use a "cosine" waveform, if it existed, without needing to 98 | # sleep. 99 | 100 | # So sonic pi gives us 4 basic wave forms to work with, sine, saw, square, and triangle, and we can see 101 | # that the next three contain a great number of harmonics. So is there a way that we can create new 102 | # timbres from the saw, square, and triangle waves? As a matter of fact, there is. We use filters to 103 | # remove some of the harmonics to change the sound, rather than adding more sine waves. 104 | # Since we're taking harmonics away from the harmonically rich sounds of these synths, we call this 105 | # kind of synthesis, "Subtractive Synthesis" -------------------------------------------------------------------------------- /examples/timbre_part_4.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 4 4 | # By Adrian Cheater 5 | 6 | # So now we've seen how sine waves are the building blocks of sound. That we can create new timbres 7 | # by adding multiple sine waves together at the same time, and that the other basic wave forms 8 | # (Saw, Square, and Triangle) are effectively full of harmonics. 9 | # 10 | # If we want to remove harmonics, then we need to filter them out. In sonic pi, there are three 11 | # kinds of filters we can use, one filters out frequencies below a chosen point, 12 | # one filters out frequencies above a chosen point, and the 3rd filters out frequencies that are 13 | # too far above or below a chosen point. 14 | 15 | # In the case of the one that cuts out the frequencies below a chosen point, it can also be 16 | # said to allow frequencies above a certain point to pass through without adjustment. You can 17 | # therefore call it a low-cut, or a high-pass filter (sonic pi uses the latter) 18 | 19 | # So our other two filters are called a low-pass (high-cut) filter, and a band-pass filter. 20 | # That last one might sound a bit funny. When talking about frequencies, a "band" is just a range of 21 | # frequencies between two points, so from (:c3 to :c4) is a one octave band. 22 | 23 | # To see what exactly a filter does, let's try it out on our sine wave, there are no harmonics, so 24 | # it will help us to really hear what's going on. 25 | 26 | define :lpf_sine do 27 | use_synth :sine 28 | n = play :a3, note_slide: 8, sustain: 10 29 | control n, note: :a4 30 | sleep 10.5 31 | with_fx :lpf, cutoff: :a3 do 32 | n = play :a3, note_slide: 8, sustain: 10 33 | control n, note: :a4 34 | end 35 | sleep 10.5 36 | end 37 | lpf_sine 38 | 39 | # Did you notice how the volume got quieter as the note swept up, away from the low pass filter's cutoff of :a3? 40 | # That's because a low-pass filter is also a high-cut filter. So the higher the frequency is from the cutoff, the 41 | # quieter it gets. High-pass filters do the same thing. 42 | 43 | define :hpf_sine do 44 | use_synth :sine 45 | n = play :a3, note_slide: 8, sustain: 10 46 | control n, note: :a4 47 | sleep 10.5 48 | with_fx :hpf, cutoff: :a4 do 49 | n = play :a3, note_slide: 8, sustain: 10 50 | control n, note: :a4 51 | end 52 | sleep 10.5 53 | end 54 | hpf_sine 55 | 56 | # This time the filtered note started quieter and got louder as it approached the cutoff. After that point it 57 | # continues at full volume. And of course, band pass filters will make the sound quieter the farther it gets from 58 | # it's centre point (above or below). It's important to point out that whereas the lpf and hpf filters have a 'cutoff' 59 | # that controls the filter, the band pass filter has a 'centre' frequency that is loudest. 60 | 61 | define :bpf_sine do 62 | use_synth :sine 63 | n = play :c1, note_slide: 8, sustain: 10 64 | control n, note: :c5 65 | sleep 10.5 66 | with_fx :bpf, centre: :c3 do 67 | n = play :c1, note_slide: 8, sustain: 10 68 | control n, note: :c5 69 | end 70 | sleep 10.5 71 | end 72 | bpf_sine 73 | 74 | # So now that we understand how filters can be used to remove frequencies, let's see what happens when we use them 75 | # with our harmonically rich synths. -------------------------------------------------------------------------------- /examples/timbre_part_5.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 5 4 | # By Adrian Cheater 5 | 6 | # As we've seen in previous examples, the saw, triangle, and square waves are rich 7 | # with harmonics. And we've also seen that filters reduce the strength of frequencies 8 | # which are too far above, below, or outside the selected frequency of the 9 | # low, high, and band pass filters. So let's take a moment to listen to how 10 | # the timbre of a saw wave changes when we sweep these filters. 11 | 12 | # We can hear that the timbre changes as the filter sweeps, and that they all sound 13 | # a little different from the raw saw wave. One noticable problem however, is that the 14 | # notes which are very far from the cutoff or centre are barely audible. 15 | 16 | # If we wanted to hear those timbres a little more clearly, we could normalize 17 | # the signal, so that after it's been filtered, it gets amplified as much as needed 18 | # to bring the relative volume up to fill the 'normal' range of dynamics. 19 | 20 | # Try uncommenting the normalizer effect block and listen to the difference 21 | 22 | define :sweep_filter do |n,f| 23 | puts "Playing #{n} with filter #{f}" 24 | use_synth :saw 25 | play n, sustain: 4 26 | sleep 6 27 | 28 | with_fx f, cutoff: :c1, cutoff_slide: 16 do |fx| 29 | play n, sustain: 16 30 | control fx, cutoff: :c7 31 | end 32 | sleep 17 33 | end 34 | 35 | define :bpf_sweep do |n,f| 36 | puts "Playing #{n} with filter #{f}" 37 | use_synth :saw 38 | play n, sustain: 4 39 | sleep 6 40 | 41 | with_fx f, centre: :c1, centre_slide: 16 do |fx| 42 | play n, sustain: 16 43 | control fx, centre: :c7 44 | end 45 | sleep 17 46 | end 47 | 48 | #with_fx :normaliser do 49 | [:c4,:c6,:c2].each do |note| 50 | [:lpf,:hpf].each do |filter| 51 | sweep_filter note,filter 52 | end 53 | bpf_sweep note, :bpf 54 | end 55 | #end -------------------------------------------------------------------------------- /examples/timbre_part_6.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 6 4 | # By Adrian Cheater 5 | 6 | # We've now seen how various wave forms can be rich in harmonics, and how the low, high, 7 | # and band pass filters can affect them. Is there anything else we can do with filters? 8 | 9 | # As a matter of fact, there is! We've seen how filters reduce the sound energy the 10 | # farther you get from the cutoff or centre. However, we can also boost the sound energy 11 | # at that cutoff. This boosting is what we call resonance, and it's affected by the res 12 | # parameter of the resonating filters 13 | 14 | # In this case, we're cranking the resonance to a very high level, and using a normalizing 15 | # filter to help accentuate the resonated frequency. With this high level of resonance, 16 | # you can actually hear the sweep of the filter's cutoff as a secondary frequency. 17 | # You can still mostly hear the fundamental frequency we generated, but now there's a 18 | # sine like whistle present as well. We call these extra frequencies which stand out 19 | # "overtones" 20 | 21 | # Again, even though the cutoff value is resonated into an overtone, the signal is 22 | # still heavily reduced, so normalizing it will help to bring the sound out. 23 | # However, it's also useful to note that when not normalizing the signal, the sweep 24 | # overtone is more consistent with the c2 note, vs the c6 note, which fades in and out. 25 | # Also, the lower tones fade in and out more times. What's going on there? 26 | 27 | # Remember, the resonator can only amplify the amount of sound present at a given frequency 28 | # In the case of saw waves, we get all the harmonics, but those harmonics are still multiples 29 | # of the fundamental frequency. Inbetween those harmonics, there isn't any sound energy to 30 | # multiply, so the overtone drops out, and you go back to hearing the fundamental frquency. 31 | 32 | # So what would happen if we could play a sound that had every frequency? 33 | # What would that sound like? We'll explore that next time. 34 | 35 | define :sweep_filter do |n,f| 36 | puts "Playing #{n} with filter #{f}" 37 | use_synth :saw 38 | play n, sustain: 4 39 | sleep 6 40 | 41 | with_fx f, cutoff: :c1, res: 0.99, cutoff_slide: 16 do |fx| 42 | play n, sustain: 16 43 | control fx, cutoff: :c7 44 | end 45 | sleep 17 46 | end 47 | 48 | define :bpf_sweep do |n,f| 49 | puts "Playing #{n} with filter #{f}" 50 | use_synth :saw 51 | play n, sustain: 4 52 | sleep 6 53 | 54 | with_fx f, centre: :c1, res: 0.99, centre_slide: 16 do |fx| 55 | play n, sustain: 16 56 | control fx, centre: :c7 57 | end 58 | sleep 17 59 | end 60 | 61 | with_fx :normaliser do 62 | [:c4,:c6,:c2].each do |note| 63 | [:rlpf,:rhpf].each do |filter| 64 | sweep_filter note,filter 65 | end 66 | bpf_sweep note, :rbpf 67 | end 68 | end -------------------------------------------------------------------------------- /examples/timbre_part_7.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | use_synth :noise 3 | 4 | # Synths, Timbre and Filters Part 7 5 | # By Adrian Cheater 6 | 7 | # When you generate sound that contains energy at every frequency, not just a fundamenal and it's harmonics 8 | # you get what we call noise. There is no pitch for your ears to pick out, there're all present. 9 | # The downside is that you can't control pitch, every note with a noise generator sounds the same 10 | # The upside is that you have a very rich environment for subtractive synthasis. Liberal use of 11 | # resonance in this case can provide your fundamental frequency for you. 12 | 13 | # We start by playing three notes in rapid succession, so that you can hear they don't sound any different. 14 | # Then we do our filter sweep, and now you don't get that pusling effect you had with the saw waves. 15 | # However, this is also a place where the nature of low, high, and band pass filters really become apparent. 16 | # The rlpf filter keeps most of the noise out until the frequency climbs 17 | # Similarly, the rhpf keeps most of the noise initially and reduces it as it sweeps. 18 | # The rbpf has a fairly constant amount of noise present as it sweeps through the frequencies. 19 | 20 | # This does mean that you can "play" noise using a resonant filter, as demonstrated in 'noisy_jaques' 21 | 22 | define :sweep_filter do |n,f| 23 | puts "Playing #{n} with filter #{f}" 24 | with_fx f, cutoff: :c1, res: 0.99, cutoff_slide: 16 do |fx| 25 | play n, sustain: 16 26 | control fx, cutoff: :c7 27 | end 28 | sleep 17 29 | end 30 | 31 | define :bpf_sweep do |n,f| 32 | puts "Playing #{n} with filter #{f}" 33 | with_fx f, centre: :c1, res: 0.99, centre_slide: 16 do |fx| 34 | play n, sustain: 16 35 | control fx, centre: :c7 36 | end 37 | sleep 17 38 | end 39 | 40 | define :do_sweeps do 41 | [:c4,:c6,:c2].each do |note| 42 | puts "playing #{note}" 43 | play note, sustain: 2 44 | sleep 2.0 45 | end 46 | sweep_filter :c6,:rlpf 47 | sweep_filter :c6,:rhpf 48 | bpf_sweep :c6,:rbpf 49 | end 50 | 51 | define :noisy_jaques do 52 | notes = [:c,:d,:e,:c]*2 53 | with_fx :rbpf do |fx| 54 | notes.each do |n| 55 | control fx, centre: n, res: 0.95 56 | play :c1 57 | sleep 1.0 58 | end 59 | end 60 | end 61 | 62 | with_fx :normaliser do 63 | do_sweeps 64 | noisy_jaques 65 | end -------------------------------------------------------------------------------- /examples/timbre_part_8.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | # Synths, Timbre and Filters Part 8 4 | # By Adrian Cheater 5 | 6 | # In our last example we worked with the :noise synth, which is also known as 'white noise' 7 | # All noise sounds static-y, but the different noise generators work differently, and so 8 | # sound differently. 9 | 10 | # :cnoise and :noise both keep the strength of the noise roughly constant across 11 | # all frequencies, :gnoise genrates noise that favours the bass range, but can 12 | # still be pretty loud across the spectrum. 13 | # :pnoise and :bnoise work like they have builtin low pass filters, but the sound 14 | # energy drops by -3 and -6 dB per octave, so it creates a less harsh sound 15 | # with :bnoise having more standout bass than :pnoise 16 | 17 | synths = [:cnoise,:noise,:gnoise,:pnoise,:bnoise] 18 | 19 | synths.each do |synth| 20 | puts "This is #{synth}" 21 | use_synth synth 22 | play :c4, sustain: 6, attack: 0.1, release: 0.1 23 | sleep 7.0 24 | end -------------------------------------------------------------------------------- /grooves/PPK.rb: -------------------------------------------------------------------------------- 1 | define :a1 do 2 | use_synth :pretty_bell 3 | p2 = [:D6,:E6,:F6,:E6,:D6] 4 | t2 = [1.25, 0.25, 0.25, 0.25] 5 | with_fx :panslicer, phase: 8.0, wave: 3 do |pan| 6 | with_fx :echo, phase: 0.125, max_phase: 0.25, decay: 1.0 do 7 | play_pattern_timed p2, t2, release: 0.33 8 | 2.times { play_pattern_timed [:E6,:F6,:E6,:D6], 0.25, release: 0.33 } 9 | 2.times { play_pattern_timed [:E6,:F6,:E6,:D6], 0.25, release: 0.33 } 10 | sleep 0.25 11 | play_pattern_timed [:A5,:C6], 0.5, release: 0.33 12 | end 13 | end 14 | end 15 | 16 | define :a2 do |a=nil| 17 | use_synth :pretty_bell 18 | with_fx :panslicer, phase: 8.0, wave: 3 do |pan| 19 | with_fx :echo, phase: 0.125, max_phase: 0.25, decay: 1.0 do 20 | p1 = [:as5,:f6,:g6,:f6,:e6,:f6] 21 | t2 = [0.75, 0.5, 0.25, 0.25, 0.25, 1.25] 22 | play_pattern_timed p1, t2, release: 0.33 23 | 2.times do 24 | play_pattern_timed [:g6,:f6,:e6,:f6], 0.25, release: 0.33 25 | end 26 | 2.times do 27 | play_pattern_timed [:g6,:f6,:e6,:f6], 0.25, release: 0.33 28 | end 29 | sleep 0.25 30 | play_pattern_timed [:e6,:f6,:e6,:d6], [0.5, 0.125, 0.125, 1.75], release: 0.33 31 | play a, release: 0.33 if a 32 | end 33 | end 34 | end 35 | 36 | define :a3 do |a| 37 | use_synth :beep 38 | p1 = [:D,:A,:D5,:A] 39 | with_fx :reverb do 40 | cue :start 41 | a.each do |x| 42 | x[1].times do 43 | with_transpose x[0] do 44 | play_pattern_timed p1, 0.5, release: 0.5 45 | end 46 | end 47 | end 48 | end 49 | end 50 | 51 | define :h1 do 52 | in_thread do 53 | 2.times do 54 | a3 [[0,4], [-5,2]] 55 | end 56 | cue :end 57 | end 58 | 59 | 2.times do 60 | sync :start 61 | a1 62 | end 63 | end 64 | 65 | define :h2 do 66 | in_thread do 67 | a3 [[-7,4], [-4,2]] 68 | a3 [[-7,4], [-4,1], [-5,1]] 69 | cue :end 70 | end 71 | 72 | sync :start 73 | a2 74 | sync :start 75 | a2 :c6 76 | end 77 | 78 | use_bpm 75 79 | loop do 80 | h1 81 | sync :end 82 | h2 83 | sync :end 84 | end -------------------------------------------------------------------------------- /grooves/ambient.rb: -------------------------------------------------------------------------------- 1 | live_loop :foo do 2 | sample :loop_breakbeat, beat_stretch: 2, amp: 3 3 | sleep 2 4 | end 5 | 6 | live_loop :chords, sync: :foo do 7 | sync :foo 8 | with_fx :distortion do 9 | 4.times do 10 | sample :ambi_choir, beat_stretch: 8, amp: 0.5 11 | sleep 2 12 | end 13 | end 14 | end 15 | 16 | live_loop :bar, sync: :foo do 17 | sync :foo 18 | sample :ambi_soft_buzz, beat_stretch: 2, rate: 1, amp: 4 19 | sleep 8 20 | end 21 | 22 | live_loop :baz do 23 | sync :foo 24 | sample :ambi_glass_hum, beat_stretch: 16, cutoff: 80 25 | sleep 4 26 | end 27 | 28 | live_loop :phrase do 29 | sync :foo 30 | sleep 4 31 | end 32 | 33 | live_loop :notes do 34 | sync :phrase 35 | use_synth :dsaw 36 | use_synth_defaults detune: 4, attack: 0.01, release: 0.1 37 | sleep 0.45 38 | use_octave 1 39 | with_fx :ixi_techno, res: 0.5, phase: 4.5*0.125 do 40 | with_fx :echo, phase: 0.25, decay: 0.75 do 41 | play_pattern_timed [:a4,:r,:a4,:a4,:a4,:r,:g4,:r,:d4], 0.125 42 | end 43 | end 44 | end -------------------------------------------------------------------------------- /grooves/bits_and_bytes.rb: -------------------------------------------------------------------------------- 1 | #Bits and Bytes theme 2 | use_bpm 54 3 | 4 | puts Chord::CHORD 5 | 6 | uncomment do 7 | in_thread name: :rchords do 8 | use_synth :saw 9 | use_synth_defaults release: 0.25, amp: 0.75 10 | 8.times do 11 | play_chord chord(:e, :sus4) 12 | sleep 0.25 13 | end 14 | 2.times do 15 | 8.times do 16 | play_chord chord(:e, :major) 17 | sleep 0.25 18 | end 19 | 12.times do 20 | play_chord chord(:d, :major) 21 | sleep 0.25 22 | end 23 | 4.times do 24 | play_chord chord(:a, :major) 25 | sleep 0.25 26 | end 27 | 8.times do 28 | play_chord chord(:e, :major) 29 | sleep 0.25 30 | end 31 | end 32 | 8.times do 33 | play_chord chord(:e, :major) 34 | sleep 0.25 35 | end 36 | 8.times do 37 | play_chord chord(:a, :major) 38 | sleep 0.25 39 | end 40 | 8.times do 41 | play_chord chord(:e, :major) 42 | sleep 0.25 43 | end 44 | 4.times do 45 | play_chord chord(:d, :major) 46 | sleep 0.25 47 | end 48 | 4.times do 49 | play_chord chord(:a3, :major) 50 | sleep 0.25 51 | end 52 | 8.times do 53 | play_chord chord(:e, :major) 54 | sleep 0.25 55 | end 56 | 8.times do 57 | play_chord chord(:a, :major) 58 | sleep 0.25 59 | end 60 | 8.times do 61 | play_chord chord(:e, :major) 62 | sleep 0.25 63 | end 64 | 8.times do 65 | play_chord chord(:d, :major) 66 | sleep 0.25 67 | end 68 | 8.times do 69 | play_chord chord(:a3, :major) 70 | sleep 0.25 71 | end 72 | 16.times do 73 | play_chord chord(:e, :major) 74 | sleep 0.25 75 | end 76 | end 77 | end 78 | 79 | uncomment do 80 | sleep 3.0 81 | in_thread name: :melody do 82 | use_synth :square 83 | use_transpose 4 84 | use_synth_defaults release: 0.5 85 | 2.times do |x| 86 | puts x 87 | patterns = [[:c,:d,:e,nil,:f,nil],[:f,:f,:f,:g,:a,:g,nil]] 88 | timings = [knit(0.25,4,0.25,1,2.25,1),knit(0.25,4,0.5,2,2.5,1)] 89 | play_pattern_timed patterns[x], timings[x].to_a 90 | end 91 | play_pattern_timed [:c,:d,:e,nil,:f,nil], knit(0.25,4,0.25,1,2.25,1).to_a 92 | play_pattern_timed [:f,:f,:f,:g,:a,:a,nil,:g,:g,nil], knit(0.25,4,0.5,2,0.25,2,1.75,1).to_a 93 | 94 | sleep 1.0 95 | play_pattern_timed [:a,:a,:a,:a,:g,:e], knit(0.25,1,0.5,1,1.0,1,0.25,1).to_a 96 | sleep 1.25 97 | play_pattern_timed [:d,:d,:d,:c,:e], knit(0.25,1,0.75,1,0.5,1,0.25,1).to_a 98 | sleep 2.0 99 | play_pattern_timed [:a,:a,:a,:a,:c5,:g,:e,:c], [0.25,0.5,1.0,0.25,0.5,0.25,0.5,0.75] 100 | play_pattern_timed [:d,:d,:d,:c,:c,:g], knit(1.5,1,0.5,2,1.0,1,0.5,1).to_a 101 | end 102 | end 103 | 104 | uncomment do 105 | in_thread name: :ooohs do 106 | use_synth :tri 107 | use_transpose 4 108 | use_synth_defaults release: 1.0, attack: 0.25, amp: 0.5 109 | sleep 16 110 | play :c 111 | sleep 0.5 112 | play :g 113 | sleep 0.5 114 | play :c5, sustain: 6 115 | sleep 7 116 | play :c 117 | sleep 0.5 118 | play :g 119 | sleep 0.5 120 | play :c5, sustain: 6 121 | end 122 | end 123 | 124 | comment do 125 | in_thread name: :bass do 126 | use_synth :dull_bell 127 | play :c3 128 | sleep 1.0 129 | end 130 | end 131 | 132 | uncomment do 133 | in_thread name: :warble do 134 | 2.times do 135 | puts "loop warble" 136 | sleep 1.0 137 | use_transpose 2 138 | use_synth :saw 139 | use_synth_defaults release: 0.125 140 | play_pattern_timed [:c3,:d3,:c3,:d3,:c3,nil], knit(0.125,5,0.75-0.375,1).to_a 141 | with_transpose 14 do 142 | play_pattern_timed [:c3,:d3,:c3,:d3,:c3,nil], knit(0.125,5,0.75-0.375,1).to_a 143 | end 144 | sleep 2.0 145 | use_transpose 4 146 | play_pattern_timed [:c3,:d3,:c3,:d3,:c3,nil], knit(0.125,5,0.75-0.375,1).to_a 147 | with_transpose 16 do 148 | play_pattern_timed [:c3,:d3,:c3,:d3,:c3,nil], knit(0.125,5,0.75-0.375,1).to_a 149 | end 150 | play_pattern_timed [:c3,:d3,:c3,:d3,:c3,nil], knit(0.125,5,0.75-0.375,1).to_a 151 | end 152 | puts "bridge" 153 | sleep 32 154 | end 155 | end 156 | 157 | uncomment do 158 | sleep 1.0 159 | live_loop :beat do |x| 160 | sample :drum_heavy_kick, amp: 0.5 161 | sleep 0.5 162 | sample :drum_snare_hard, amp: 0.4 163 | sleep 0.5 164 | end 165 | end -------------------------------------------------------------------------------- /grooves/dirty_bass.rb: -------------------------------------------------------------------------------- 1 | use_bpm 140 2 | 3 | live_loop :kick do 4 | 2.times do 5 | sample :drum_bass_soft, rate: 1.05 6 | sleep 1.0 7 | sample :drum_snare_soft, pan: -0.3, rate: rrand(0.9,1.1) 8 | sleep 1.0 9 | 2.times { sample :drum_bass_soft; sleep 0.5 } 10 | sample :drum_snare_soft, pan: -0.3, rate: rrand(0.9,1.1) 11 | sleep 1.0 12 | end 13 | end 14 | 15 | live_loop :hat do 16 | use_sample_defaults amp: 0.6, pan: 0.5 17 | sync :kick 18 | 15.times do 19 | sample :drum_cymbal_closed 20 | sleep 0.5 21 | end 22 | sample :drum_cymbal_hard, rate: rrand(0.95,1.05), start: 0.1, finish: 0.25 23 | sleep 0.5 24 | end 25 | 26 | chords = knit( 27 | chord( :F, '6' ), 3, 28 | [nil], 1, 29 | chord( :C, '6' ), 3, 30 | [nil], 1, 31 | chord( :D, :m7 ), 4, 32 | chord( :G, :sus4 ), 3, 33 | chord( :G, :M ), 1 34 | ) 35 | 36 | live_loop :chords do 37 | with_fx :panslicer, phase: 0.5, mix: 1, wave: 3 do 38 | with_fx :ixi_techno do 39 | use_synth :subpulse 40 | use_transpose -12 41 | sync :kick 42 | chords.each do |c| 43 | play_chord c, sustain: 1, attack: 0.1, release: 0.1, amp: 1 44 | sleep 1.0 45 | end 46 | end 47 | end 48 | end 49 | 50 | live_loop :bass do 51 | use_synth :tb303 52 | use_synth_defaults res: 0.2, sustain: 0.5, attack: 0.01, release: 0.5 53 | use_transpose -24 54 | sync :chords 55 | with_fx :bitcrusher, sample_rate: 400, bits: 4, sample_rate_slide_shape: 1, sample_rate_slide: 8, bits_slide: 8 do |f| 56 | control f, sample_rate: 4000 57 | 1.times { 58 | knit(:d,2,:f,1,:es,1,:d,2,:e,1,:f,2,:g,1,:d,1,:c,1,:d,2).each do |n| 59 | play n 60 | sleep knit(2.0,1,0.5,3,1.0,3,0.5,2).tick 61 | end 62 | } 63 | end 64 | end 65 | 66 | def play_pattern_timed_smooth( notes, times, opts = {}) 67 | time_ring = times.ring 68 | notes.each_with_index do |note,i| 69 | dur = time_ring[i] 70 | play note, opts.merge(sustain: dur) 71 | sleep dur 72 | end 73 | end 74 | 75 | comment do 76 | live_loop :melody do 77 | use_synth :saw 78 | use_synth_defaults attack: 0.05, release: 0.1, amp: 0.5 79 | sync :chords 80 | play_pattern_timed_smooth [:a,:g,:f,:e,nil,:g,:f,:e,:d], [2.5,0.5,0.5,0.5,4,2.5,0.5,0.5,0.5], current_synth_defaults 81 | end 82 | end -------------------------------------------------------------------------------- /grooves/ff_prelude.rb: -------------------------------------------------------------------------------- 1 | use_bpm 60 2 | 3 | define :arppegio do |s,c| 4 | n=chord(s,c,num_octaves: 4) 5 | n+[s+48]+n.reverse[0..-2] 6 | end 7 | 8 | live_loop(:ff) do 9 | use_synth :sine 10 | use_synth_defaults attack: 0, release: 0.75 11 | with_fx :reverb do 12 | [[:c3,:add2],[:a2,:madd2],[:c3,:add2],[:a2,:madd2],[:a2,'m7+5'],[:b2,'m7+5'],[:af2,'M7'],[:bf2,'M7']].each do |s,c| 13 | play_pattern_timed (arppegio s,c), 0.25 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /grooves/humming_samples.rb: -------------------------------------------------------------------------------- 1 | live_loop :amb1 do 2 | sample :ambi_drone, beat_stretch: 8, lpf: 60 3 | sleep 8 4 | end 5 | 6 | live_loop :amb2 do 7 | sample :ambi_haunted_hum, beat_strech: 16 8 | sleep 16 9 | end 10 | 11 | live_loop :kick do 12 | sample :bd_sone 13 | sleep 1 14 | end 15 | 16 | live_loop :chords do 17 | sample :bass_voxy_c, beat_stretch: 4, lpf: 60 18 | sleep 2 19 | end 20 | 21 | live_loop :snare, sync: :kick do 22 | sleep 3.5 23 | sample :drum_snare_soft 24 | sleep 0.5 25 | end 26 | 27 | live_loop :notes do 28 | use_random_seed 500 29 | use_synth :fm 30 | use_synth_defaults attack: 0.01, release: 0.5, sustain: 0.1, divisor: 3 31 | notes = chord( :a2, 'm7', num_octaves: 2 ) 32 | 2.times do 33 | play_pattern_timed notes.shuffle, [0.25,0.25,0.25,1.5,1.0], depth: 0.2 34 | end 35 | end 36 | 37 | -------------------------------------------------------------------------------- /grooves/moon_logic.rb: -------------------------------------------------------------------------------- 1 | use_bpm 80 2 | 3 | define :bass_part_a do 4 | [:fs,:f,:ds,:cs,:b3,:c,:cs,:cs].each do |n| 5 | puts vt 6 | 8.times do 7 | play n 8 | sleep 0.25 9 | end 10 | end 11 | end 12 | 13 | define :bass_part_b do 14 | [:fs,:e,:ds,:d,:cs].each do |n| 15 | 8.times do 16 | play n 17 | sleep 0.25 18 | end 19 | end 20 | [:c,:cs].each do |n| 21 | 4.times do 22 | play n 23 | sleep 0.25 24 | end 25 | end 26 | play_pattern_timed [:d,:e,:fs], [0.75,0.75,0.5], sustain: 0.48 27 | c = play :fs3, note_slide: 2.0, sustain: 2.0 28 | control c, note: :fs 29 | sleep 2 30 | end 31 | 32 | define :bassline do 33 | use_synth :chipbass 34 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.23 35 | use_octave -1 36 | 37 | bass_part_a 38 | bass_part_b 39 | end 40 | 41 | define :lead_loop do 42 | use_synth :chiplead 43 | use_synth_defaults sustain: 0.2, attack: 0.01, release: 0.02 44 | n = %i(fs cs fs gs cs gs b cs b cs b as gs fs r r r r) 45 | d = [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25] 46 | play_pattern_timed n, d 47 | end 48 | 49 | define :main_part_a do 50 | n = %i(r e f g g r c5 b c5 d5 e5 c5 r c5 b c5 g5 c5 c5 r c5 d5 c5 c5 d5 c5 b r) 51 | d = [1, 0.25, 0.25, 0.25, 0.25, 0.5, 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 2.25, 0.25, 0.25, 0.25, 0.75, 0.25, 0.25, 2, 0.25, 0.25, 0.25, 1.25, 0.25, 0.25, 0.25, 2.0] 52 | play_pattern_timed n, d 53 | end 54 | 55 | define :main_part_b do 56 | n = %i(r e d c g r c5 d5 f5 e5 e5 r g5 f5 e5 f5 e5 c5 g r d5 c5 b a b r c5 c5 c5 r) 57 | d = [1, 0.25, 0.25, 0.25, 0.25, 1.0, 0.5, 0.5, 0.75, 0.25, 0.25, 1.75, 0.5, 0.5, 0.25, 0.25, 0.25, 0.5, 0.5, 0.5, 0.25, 0.25, 0.25, 0.25, 0.25, 0.5, 0.75, 0.75, 0.75, 1.75] 58 | play_pattern_timed n, d 59 | end 60 | 61 | define :main do 62 | use_synth :chiplead 63 | use_transpose 6 64 | main_part_a 65 | main_part_b 66 | end 67 | 68 | live_loop :main do 69 | main 70 | end 71 | live_loop :bass do 72 | bassline 73 | end 74 | 75 | live_loop :drums do 76 | stop 77 | use_synth :chipnoise 78 | with_fx :bpf, centre: :c2 do 79 | play :c, attack: 0.01, release: 0.01, sustain: 0.05 80 | sleep 0.5 81 | end 82 | with_fx :lpf, centre: 60 do 83 | play :e, attack: 0.0, release: 0.0, sustain: 0.01 84 | sleep 0.5 85 | end 86 | end -------------------------------------------------------------------------------- /grooves/piano_and_strings.rb: -------------------------------------------------------------------------------- 1 | use_synth :piano 2 | use_bpm 120 3 | live_loop :chords do 4 | [1, 3, 6, 4].each { |d| range(-3,3).each { |i| play_chord chord_degree d, :c, :major, 3, invert: i; sleep 0.5 } } 5 | end 6 | 7 | live_loop :strings do 8 | sync :chords 9 | use_synth :mod_saw 10 | with_fx :hpf, cutoff: 60 do |bpf| 11 | use_synth_defaults cutoff: 80, mod_range: 0.4, sustain: 2, mod_phase: 0.025, mod_wave: 3 12 | nd = [4,1.5,0.5,6]*2 + [4,1.5,0.5,5.5] + [0.5,1.5,0.5,1.5,1.5,0.5,0.5,6] 13 | np = [:g5,:e5,:d5,:c5, :g5,:e5,:g5,:a5, :g5,:e5,:d5,:c5, :d5,:e5,:f5,:e5,:d5,:c5,:b4,:c5,:d5] 14 | np.zip(nd).each do |p,d| 15 | #control bpf, cutoff: p 16 | play p, cutoff: 70, decay: d/2, sustain: d/2, attack: 0.25, sustain_level: 0.25, decay_level: 0.25, release: 0.1 17 | sleep d 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /grooves/smb_overland.rb: -------------------------------------------------------------------------------- 1 | use_bpm 200 2 | 3 | define :sq1 do 4 | use_synth :chiplead 5 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.48, width: 2, amp: 6.0/15.0 6 | play_pattern_timed [:e5,:e5,:r,:e5,:r,:c5,:e5,:r,:g5,:r,:r,:r,:r,:r,:r,:r,:r], 0.5 7 | end 8 | 9 | define :sq2 do 10 | use_synth :chiplead 11 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.48, width: 2, amp: 6.0/15.0 12 | play_pattern_timed [:fs,:fs,:r,:fs,:r,:fs,:fs,:r,:b,:r,:r,:r,:g,:r,:r,:r], 0.5 13 | end 14 | 15 | define :t1 do 16 | use_synth :chipbass 17 | use_synth_defaults attack: 0.01, release: 0.01, sustain: 0.48, amp: 1.0 18 | play_pattern_timed [:d4,:d4,:r,:d4,:r,:d4,:d4,:r,:g,:r,:r,:r,:g3,:r,:r,:r], 0.5 19 | end 20 | 21 | in_thread do 22 | sq1 23 | end 24 | in_thread do 25 | sq2 26 | end 27 | in_thread do 28 | t1 29 | end -------------------------------------------------------------------------------- /grooves/stranger_rings.rb: -------------------------------------------------------------------------------- 1 | use_bpm 160 2 | 3 | live_loop :arp do 4 | use_synth_defaults attack: 0.05, pulse_width: 0.3, dpulse_width: 0.4, release: 0.4, detune: -12.1, amp: 1 5 | notes = chord(:c2,:major7,num_octaves: 2).take(5).reflect.butlast 6 | with_fx :reverb do 7 | use_synth :dpulse 8 | with_fx :ixi_techno, res: 0.7, cutoff_min: :c5, cutoff_max: :c7, phase: 32 do 9 | 8.times { play_pattern_timed notes, 0.5 } 10 | end 11 | end 12 | end 13 | 14 | live_loop :heart do 15 | 2.times do 16 | sample :bd_808, amp: 10 17 | sleep 0.5 18 | end 19 | sleep 1 20 | end 21 | 22 | live_loop :pad do 23 | use_synth :dsaw 24 | use_synth_defaults attack: 0.25, decay: 0.1, sustain_level: 0.5, detune: 0.05, amp: 2, cutoff: 120 25 | steps = chord(:c2,:add2).take(3).reflect.butlast 26 | time = [14,2,14,2] 27 | 28 | steps.zip(time).each do |s,t| 29 | c = play s, release: t + 1 30 | control c, cutoff: 80, cutoff_slide: 14 31 | sleep t 32 | end 33 | end -------------------------------------------------------------------------------- /synthtober_2017/2017_10_02_chimes.rb: -------------------------------------------------------------------------------- 1 | c1 = [244,663,1272,2050] 2 | c2 = [278,753,1441,2314] 3 | c3 = [312,850,1625,2600] 4 | c4 = [330,890,1700,2712] 5 | c5 = [371,1000,3031,4351] 6 | notes = ring(c1,c2,c3,c4,c5) 7 | ni = 3 8 | use_random_seed 18 9 | vol = 1.0 10 | live_loop :chimes do 11 | with_fx :reverb, mix: 0.8, room: 0.6, damp: 1 do 12 | with_fx :lpf, cutoff: 30 do |fx| 13 | at [0, 0.05], [[110,0.005],[70,1]] do |c| 14 | control fx, cutoff: c[0], cutoff_slide: c[1] 15 | end 16 | use_octave 2.7 17 | use_synth :sine 18 | use_synth_defaults attack: 0.0, decay: 0.4, sustain_level: 0.7, release: 2 19 | notes[ni].each do |v| 20 | play hz_to_midi(v), amp: vol * 0.7 21 | end 22 | end 23 | slp = [0.2,0.3,0.9,1.0,1.5,2.0].choose 24 | if slp < 0.5 25 | ni += [-1,2].choose 26 | else 27 | ni += [3,3,2,-3,-3,-2].choose 28 | end 29 | vol /= 4 30 | vol += slp * 0.6 31 | vol = 0 if vol < 0 32 | vol = 1.0 if vol > 1 33 | sleep slp 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /synthtober_2017/2017_10_08_chimes_fm.rb: -------------------------------------------------------------------------------- 1 | notes = scale(:ds6,:minor_pentatonic) 2 | pan_v = ring(-0.5,-0.25,0,0.25,0.5) 3 | ni = 3 4 | use_random_seed 18 5 | vol = 0.8 6 | use_synth_defaults attack: 0.00, decay: 0.6, sustain_level: 0.3, release: 0.6 7 | use_synth :fm 8 | live_loop :chimes do 9 | vol = 0.8 if vol > 0.8 10 | with_fx :reverb, mix: 0.6, room: 0.4 do 11 | with_fx :lpf, cutoff: 90, mix: 1.0 do |fx| 12 | with_fx :hpf, cutoff: 90, mix: 1 do 13 | nc = play notes[ni], divisor: 0.6, depth: 0, pan: pan_v[ni], amp: vol 14 | control nc, depth: 6, depth_slide: 0.5 15 | end 16 | end 17 | slp = [0.4,0.5,0.9,1.0,1.1,1.2,1.5,1.4,1.6,1.65,2.0].choose 18 | if slp <= 0.5 19 | ni += [-1,2].choose 20 | else 21 | ni += [3,3,2,-3,-3,-2].choose 22 | end 23 | vol -= 0.6 24 | vol = 0 if vol < 0 25 | vol += (slp * 0.3) 26 | sleep slp 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /synthtober_2017/2017_10_11_sfx_1.rb: -------------------------------------------------------------------------------- 1 | define :death do 2 | use_octave -1 3 | use_synth :mod_saw 4 | n = play :c6, mod_phase: 0.05, mod_range: 5, mod_wave: 0, mod_pulse_width: 0.15, attack: 0.01, release: 1.5 5 | i = 10 6 | i.times do 7 | control n, note: ring(:c7,:c6).tick, note_slide: 1.5/i 8 | sleep 1.5/i 9 | end 10 | end 11 | 12 | define :laser do 13 | use_octave -2 14 | use_synth :mod_saw 15 | n = play :c6, mod_phase: 0.05, mod_range: 12, mod_wave: 0, mod_pulse_width: 0.5, attack: 0.01, sustain: 2, release: 0.1 16 | i = 10 17 | i.times do 18 | control n, note: ring(:c7,:g6).tick, note_slide: 2/i 19 | sleep 2/i 20 | end 21 | end 22 | 23 | define :warp_up do 24 | use_synth :dsaw 25 | n = play :c2, attack: 6, detune: 0.67, release: 2 26 | control n, note: :f5, note_slide: 4 27 | end 28 | 29 | define :air_raid do 30 | use_synth :dsaw 31 | n = play :c2, attack: 6, detune: 3, release: 3 32 | control n, note: :c6, note_slide: 4 33 | end 34 | 35 | warp_up 36 | sleep 9 37 | air_raid 38 | sleep 10 39 | laser 40 | sleep 3 41 | death -------------------------------------------------------------------------------- /synthtober_2017/2017_10_18_song.rb: -------------------------------------------------------------------------------- 1 | use_bpm 130 2 | live_loop :pads do 3 | use_synth :fm 4 | use_synth_defaults mod_range: 0.25, divisor: 4.0/2.0, attack: 0.1, sustain: 6, release: 2, amp: 0.5 5 | with_fx :distortion, distort: 0.9, mix: 0.1 do 6 | with_fx :ixi_techno, phase: 1, cutoff_min: 20, cutoff_max: 120, res: 0.3, mix: 0.5 do 7 | with_fx :flanger, phase: 8, mix: 1 do 8 | with_fx :reverb, mix: 1, room: 0.8 do 9 | with_fx :echo, mix: 1, phase: 2, decay: 16, max_phase: 16 do 10 | use_random_seed 10 11 | 4.times do 12 | c = chord_invert(chord_degree(ring(1,5,6,4).tick,:d,:minor,3),ring(1,-1,-1,0).look) 13 | play_chord c 14 | sleep 8 15 | end 16 | end 17 | end 18 | end 19 | end 20 | end 21 | end 22 | 23 | sleep 0.25 24 | live_loop :kick do 25 | use_sample_defaults amp: 7.0, beat_stretch: 0.75 26 | sample :bd_808 27 | sleep 3.5 28 | sample :bd_808 29 | sleep 0.5 30 | sample :bd_808 31 | sleep 1 32 | sample :bd_808 33 | sleep 3 34 | end 35 | 36 | live_loop :snare do 37 | sleep 3.0 38 | with_random_seed 2 do 39 | 8.times do 40 | sample :sn_zome, beat_stretch: 0.1 if one_in(2) 41 | sleep 0.125 42 | end 43 | end 44 | end --------------------------------------------------------------------------------