Sonic Pi - Instrumentos

Podemos utilizar vários tipos de instrumentos (sintetizadores) para tocar notas musicais. Cada sintetizador possui seus próprios parâmetros de ajustes sonoros. Para utilizar um instrumento diferente do padrão, utilize o comando use_synth antes do comando play.

use_synth :tb303
play 64

sleep 1

use_synth :chipbass
play 64


Exemplos de código e sons de todos os sintetizadores disponíveis:

sintetizador :beep
Som de onda senoidal simples.


live_loop :notas do
  use_synth :beep
  play scale(:C3, :pelog).choose, attack: [0.01,0.01].choose, release: 1, amp: rrand(1,2)
  sleep 0.5
end

sintetizador :blade
Som elétrico com vibrato. Inspirado na trilha sonora do filme Blade Runner, do compositor grego Vangelis.


live_loop :notas do
  use_synth :blade
  play chord(scale(:D3, :chromatic).choose,:major),
    attack: [4,4,6].choose, release: [4,4,6].choose,
    vibrato_rate: [0.5,2,4].choose,
    vibrato_rate_slide: [0,1,2,4].choose,
    vibrato_depth: [0.1,0.25,0.333,0.5].choose,
    vibrato_depth_slide: [0.5,1,2,3].choose,
    vibrato_delay: rrand(0,0.5),
    vibrato_onset: rrand(0.5,2),
    pan: rrand(-0.4,0.4), pan_slide: [1,2,4].choose,
    amp: 4
  sleep 6
end

sintetizador :bnoise
Som de ruído.


live_loop :beat do
  use_synth :bnoise
  play 60, attack: 0.02, release: 0.02, amp: 2
  sleep 0.5
end

sintetizador :chipbass
Som de baixo, com timbre eletrônico de 8 bits.


live_loop :notas do
  use_synth :chipbass
  play_pattern [48,48,52,44], amp: 2, attack: 0.1, release: 0.3
end

sintetizador :chiplead
Som de de sintetizador com timbre eletrônico de 8 bits.


live_loop :notas do
  use_synth :chiplead
  play_pattern [50,50,42,54,42], amp: 2, attack: 0.05, release: 0.2
end

sintetizador :chipnoise
Som de ruído percursivo, com timbre eletrônico de 8 bits.


live_loop :notas do
  use_synth :chipnoise
  play 60, attack: 0.01, release: 0.5, amp: 1.5
  sleep 1
end

sintetizador :cnoise
Som de ruído. Útil para sons de percussão.


live_loop :notas do
  use_synth :cnoise
  play 60, attack: 0.01, release: 0.7, amp: 2
  sleep 1
end

sintetizador :dark_ambience
Som atmosférico.


live_loop :notas do
  use_synth :dark_ambience
  play rrand(30,70), amp: 5, attack: 3, sustain: 2, release: 5
  sleep 6
end

sintetizador :dpulse
Som de duas ondas de pulso, desafinadas por uma frequência especificada.


live_loop :pulso1 do
  use_synth :dpulse
  play rrand(30,60), detune: -12,
    amp: 0.9, attack: 2, sustain: 2, release: 3
  sleep 4
end

live_loop :pulso2 do
  use_synth :dpulse
  play rrand(64,68), detune: 6, pulse_width: rrand(0.1,0.9),
    amp: 0.4, attack: 0.01, sustain: 0.1, release: 0.01
  sleep 0.25
end

sintetizador :dsaw
Som de duas ondas de serra, desafinadas por uma frequência especificada.


live_loop :serra1 do
  use_synth :dsaw
  play chord(:d2, :m7).choose,
    detune: rrand_i(-16,-8),
    detune_slide: [1,2,4,8].choose,
    attack: 2, sustain: 2, release: [3.5].choose,
    amp: 0.9
  sleep 4
end

live_loop :serra2 do
  use_synth :dsaw
  play chord([:d4,:d5].choose, :major).choose,
    cutoff: rrand(90,120),
    cutoff_slide: [0.1,0.2,0.25,0.5].choose,
    detune: rrand_i(4,8),
    detune_slide: [0.01,0.02,0.03].choose,
    attack: 0.01, sustain: 0.08, release: 0.02,
    amp: 0.333
  sleep 0.2
end

live_loop :amen_break do #by ‏@aday_net_au
  sample :loop_amen, beat_stretch: 3, amp: 0.9
  sleep 3
end

sintetizador :dtri
Som de duas ondas de triângulo, desafinadas por uma frequência especificada.


live_loop :notas do
  use_synth :dtri
  play chord(:c2, :m11).choose,
    detune: [rrand(-2,2),rrand(-4,4),rrand_i(-8,8)].choose,
    detune_slide: [1,2,4,8].choose,
    cutoff: rrand(40,110),
    cutoff_slide: [1,2,4].choose,
    attack: [4,2].choose,
    release: [2.4].choose,
    pan: rrand(-0.5,0.5),
    pan_slide: [1,2,4].choose,
    sustain: 2, amp: 0.8
  sleep 1
end

sintetizador :dull_bell
Som de sino.


live_loop :notas do
  use_synth :dull_bell
  play chord([:e2,:e3,:e4].choose, [:m7,:m11].choose).choose,
    attack: [0.01,0.1,0.5,1,2].choose,
    release: [3,4,6,8].choose,
    env_curve: [1,2,3,4,6,7].choose,
    pan: rrand(-0.2,0.2),
    pan_slide: [0.5,1,2,3].choose,
    amp: 1.2
  sleep 4
end

sintetizador :fm
Som.


live_loop :notas do
  use_synth :fm
  play chord([:a1,:a2].choose, [:minor,:major].choose).choose,
    attack: [0.5,1,2,4,8].choose,
    release: [3,4,6,8,10,12,16,32,64].choose,
    env_curve: [1,3,4,6,7].choose,
    pan: rrand(-0.3,0.3),
    pan_slide: [0.5,1,2,3].choose,
    divisor: [2,3,4,8,16,32].choose,
    depth: [2,4,8,16,32,64].choose,
    depth_slide: [0.5,1,2,4,8,12,16,32].choose
  sleep 3
end

sintetizador :gnoise
Som de ruído, com ênfase nas frequências mais graves. Útil para sons percussivos, vento e ondas.


live_loop :notas do
  use_synth :gnoise
  play rrand(40,80),
    attack: rrand(4,8),
    sustain: rrand(2,4),
    release: rrand(4,16),
    cutoff: rrand(80,110),
    cutoff_slide: [2,4].choose,
    res: rrand(0,0.99),
    res_slide: [2,4,6].choose,
    amp: rrand(0.1,0.15),
    amp_slide: [2,4].choose
  sleep [1,2,3,4,6].choose
end

sintetizador :growl
Som.


live_loop :notas do
  use_synth :growl
  play rrand(30,90),
    attack: rrand(4,16),
    sustain: rrand(2,4),
    release: rrand(4,24),
    cutoff: rrand(62,112),
    cutoff_slide: [2,4,8,12].choose,
    res: rrand(0,0.99),
    res_slide: [2,4,6].choose,
    pan: rrand(-0.4,0.4),
    pan_slide: [1,2,4,6,8].choose,
    amp: rrand(0.222,0.333),
    amp_slide: [1,2,2,4,4,4,8].choose,
    slide_shape: 3
  sleep [1,2,3,4,6].choose
end

sintetizador :hollow
Som construído a partir de diversos tipos de ruído. Lembra o som do mar ou de respiração.


live_loop :notas do
  use_synth :hollow
  play rrand(30,90),
    attack: rrand_i(8,16),
    sustain: rrand_i(4,8),
    release: rrand_i(8,24),
    cutoff: rrand(50,112),
    cutoff_slide: [2,4,8].choose,
    res: rrand(0.33,0.99),
    res_slide: [2,4,6].choose,
    pan: rrand(-0.9,0.9),
    pan_slide: [1,2,4,6,8].choose,
    amp: rrand(0.111,0.222),
    amp_slide: [1,2,4,8].choose,
    noise: [0,1,2,3,4].choose
  sleep [2,4,6].choose
end

sintetizador :hoover
Som baseado em timbres de sintetizadores de rave dos anos 90.


live_loop :notas do
  use_synth :hoover
  play chord([:d3,:e2].choose,[:m7,:m9].choose).choose,
    attack: rrand_i(2,8),
    sustain: rrand_i(8,16),
    release: rrand_i(8,24),
    cutoff: rrand(70,120),
    cutoff_slide: [2,4,8].choose,
    res: rrand(0.33,0.99),
    res_slide: [2,4,6].choose,
    pan: rrand(-0.8,0.8),
    pan_slide: [1,2,4,6,8].choose,
    amp: rrand(0.2,0.25),
    amp_slide: [1,2,4].choose
  sleep [1,2,4,8].choose
end

sintetizador :mod_beep
Onda de seno distorcida por uma série de ondas de controle.


live_loop :notas do
  use_synth :mod_beep
  play [:As2,:Ab3].choose,
    attack: [1,2,4,8].choose,
    release: [1,2,4,8].choose,
    mod_range: [0,1,2,3,4,6,8,12].choose,
    mod_phase: [0.1,0.25,0.5,1,2].choose,
    mod_pulse_width: rrand(0.01,0.99),
    mod_pulse_width_slide: [1,2,4].choose,
    mod_wave: [0,1,2,3].choose,
    pan: rrand(-0.5,0.5),
    pan_slice: [0.5,1,2,4].choose,
    amp: rrand(0.7,0.9),
    amp_slide: [1,2,3,4].choose
  sleep [0.25,0.5,1,2,4].choose
end

sintetizador :mod_dsaw
Som de duas ondas em forma de serra, desafinadas entre si.


live_loop :notas do
  use_synth :mod_dsaw
  play [:Eb1,:Cs2].choose,
    attack: [2,4,8].choose,
    release: [2,4,8,16].choose,
    mod_range: [0,1,2,4,6,8,12].choose,
    mod_phase: [0.25,0.5,1,2,4,8].choose,
    mod_pulse_width: [0.1,0.2,0.25,0.5,0.75,0.99].choose,
    mod_pulse_width_slide: [2,4,8].choose,
    mod_wave: [0,1,2,3].choose,
    detune: [rrand(-2,2),rrand(-16,16)].choose,
    detune_slide: [2,4,8].choose,
    pan: rrand(-0.5,0.5),
    pan_slice: [2,4].choose,
    amp: rrand(0.6,0.7),
    amp_slide: [1,2,3,4].choose
  sleep [0.5,1,2,4,8].choose
end

sintetizador :mod_fm
Som.


live_loop :notas do
  use_synth :mod_fm
  with_fx :normaliser, mix: 0.4 do
  play [:Fb1,:Gs2].choose,
    attack: [2,4,8,12].choose,
    release: [2,4,8,12,16,18].choose,
    mod_range: [0,1,2,4,6,8,12,16].choose,
    mod_phase: [0.25,0.5,1,2,4,8].choose,
    mod_phase_slide: [1,2,4,8].choose,
    mod_pulse_width: [0.1,0.2,0.25,0.5,0.75,0.99].choose,
    mod_pulse_width_slide: [2,4,8].choose,
    mod_wave: [0,1,2,3].choose,
    detune: [rrand(-2,2),rrand(-16,16)].choose,
    detune_slide: [2,4,8].choose,
    pan: rrand(-0.8,0.8),
    pan_slide: [2,4].choose,
    amp: rrand(0.72,0.91),
    amp_slide: [1,2,3,4].choose,
    depth: [rrand(0,2,),rrand(0,16)].choose,
    depth_slide: [2,4,8].choose,
    divisor: [rrand(0,0.333),rrand(0,1),rrand(0,2)].choose,
    divisor_slide: [2,4,8].choose
    sleep [0.5,1,2,3,4,6,8,10,12].choose
  end
end

sintetizador :mod_pulse
Som.


live_loop :notas do
  use_synth :mod_pulse
  play scale([:F2,:Eb2].choose, [:minor,:major].choose).choose,
    attack: [2,4,6,8,12].choose,
    release: [2,4,6,8,12,16,18].choose,
    mod_range: [0,1,2,4,6,8,12,16].choose,
    mod_phase: [0.05,0.1,0.2,0.25,1.0/3,0.5,1,2,4,8].choose,
    mod_phase_slide: [1,2,4,8].choose,
    mod_phase_offset: rrand(0,0.1),
    mod_phase_offset_slide: [0.25,0.5,1,2,4,8].choose,
    mod_pulse_width: [0.1,0.2,0.25,0.5,0.75,0.99].choose,
    mod_pulse_width_slide: [0.5,1,2,4,8].choose,
    mod_wave: [0,1,2,3].choose,
    pan: [rrand(-0.2,0.2),rrand(-0.7,0.7)].choose,
    pan_slide: [0.5,1,2,4,8].choose,
    amp: rrand(0.8,0.95),
    amp_slide: [1,2,3,4].choose
  sleep [1,2,4,8].choose
end

sintetizador :mod_saw
Som.


use_bpm 12
live_loop :notas do
  use_synth :mod_saw
  play scale([:F1,:Eb1,:F2,:Eb2].choose, [:minor,:major].choose).choose,
    attack: ([0.5,1,2,4].choose) /[2.0,4.0].choose,
    release: ([1,2,4,8,16,32].choose) /[2.0,4.0].choose,
    mod_range: [0,1,2,4,6,8].choose,
    mod_phase: [0.5,1,2,4,8].choose,
    mod_phase_slide: [1,2,4,8].choose + rrand(-0.1,0.1),
    mod_phase_offset: rrand(0,0.333),
    mod_phase_offset_slide: [0.1,0.25,0.5,1,2,4,8].choose,
    mod_pulse_width: [0.1,0.2,0.25,0.5,0.75,0.99].choose,
    mod_pulse_width_slide: [0.5,1,2,4,8].choose,
    mod_wave: [0,1,2,3].choose,
    mod_invert_wave: [0,0,0,1].choose,
    cutoff: ring(60,80,60,90,80,90,40,92).tick,
    cutoff_slide: [0.25,0.5,1,2].choose,
    pan: [rrand(-1,-0.7),rrand(0.7,1)].choose,
    pan_slide: [0.1,0.2,0.25,0.5,1,2].choose,
    amp: rrand(0.5,0.7),
    amp_slide: [0.1,0.25,0.5,1,2].choose
  sleep 0.25
end

sintetizador :mod_sine
Onda de seno, modificada.


use_bpm 12
with_fx :normaliser, mix: 0.6 do
  live_loop :notas do
  use_synth :mod_sine
    play scale([:F1,:Eb1,:F2,:Eb2].choose, [:minor,:major].choose).choose,
      attack: ([0.5,1,2,4].choose) /[2.0,4.0].choose,
      release: ([1,2,4,8,16,32].choose) /[2.0,4.0].choose,
      mod_range: [0,1,2,4,6,8].choose,
      mod_phase: [0.5,1,2,4,8].choose,
      mod_phase_slide: [1,2,4,8].choose + rrand(-0.1,0.1),
      mod_phase_offset: rrand(0,0.333),
      mod_phase_offset_slide: [0.1,0.25,0.5,1,2,4,8].choose,
      mod_pulse_width: [0.1,0.2,0.25,0.5,0.75,0.99].choose,
      mod_pulse_width_slide: [0.5,1,2,4,8].choose,
      mod_wave: [0,1,2,3].choose,
      mod_invert_wave: [0,0,0,1].choose,
      cutoff: (ring(60,80,60,90,80,90,40,92).tick)+[0,12].choose,
      cutoff_slide: [0.1,0.25,0.5,1,2].choose,
      pan: [rrand(-0.8,-0.4),rrand(0.4,0.8)].choose,
      pan_slide: [0.1,0.2,0.25,0.5,1,2].choose,
      amp: rrand(0.5,0.6), amp_slide: [0.1,0.25,0.5,1,2].choose
    sleep 0.5
  end
end

sintetizador :mod_tri
Som.


use_bpm 120
use_synth :mod_tri
with_fx :normaliser, mix: 0.8 do
  live_loop :notas do
    play scale(:C2, :minor).choose,
      attack: [2,4,8].choose,
      release: [2,4,8,16].choose,
      mod_range: [1,2,4,8,12].choose,
      mod_phase: [1,2,4].choose,
      mod_phase_slide: [1,2,4].choose + rrand(-0.1,0.1),
      mod_phase_offset: rrand(0,0.2),
      mod_phase_offset_slide: [0.5,1,2].choose,
      mod_pulse_width: [0.25,0.5,0.75].choose,
      mod_pulse_width_slide: [0.5,1,2,4,8].choose,
      mod_wave: [0,1,2,3].choose,
      mod_invert_wave: [0,0,0,1].choose,
      cutoff: ring(60,80,60,90,80,90,40,92).tick,
      cutoff_slide: [1,2,4].choose,
      pan: [rrand(-0.8,-0.4),rrand(0.4,0.8)].choose,
      pan_slide: [0.5,1,2].choose,
      amp: rrand(0.7,0.84), amp_slide: [0.25,0.5,1,2].choose
    sleep [0.25,1,2,4,8].choose
  end
end

sintetizador :noise
Som.


use_synth :noise
play 60

sintetizador :piano
Som.


live_loop :notas do
  use_synth :piano
  play scale(:e2,[:gong,:kumoi].choose,
  num_octaves: [1,2,2,3,4].choose).choose,
    vel: [0.3,0.35].choose-rand(0.05),
    hard: rrand(0.3,0.6),
    stereo_width: rand(1),
    stereo_width_slide: rand(2),
    release: [0.5,1,2,4].choose
  sleep 0.25
end

sintetizador :pluck
Som.


use_synth :pluck
play 60

sintetizador :pnoise
Som.


use_synth :pnoise
16.times do
  play 60, attack: 0.03, release: 0.1, amp: 2
  sleep 0.5
end

sintetizador :pretty_bell
Som.


use_synth :pretty_bell
play 60

sintetizador :prophet
Som.


use_synth :prophet
play 60

sintetizador :pulse
Som.


use_synth :pulse
play 60

sintetizador :saw
Som.


use_synth :saw
play 60

sintetizador :sine
Som.


use_synth :sine
play 60

sintetizador :square
Som.


use_synth :square
play 60

sintetizador :subpulse
Som.


use_synth :subpulse
play 60

sintetizador :supersaw
Som.


use_synth :supersaw
play 60

sintetizador :tb303
Som.


use_synth :tb303
play 60

sintetizador :tri
Som.


use_synth :tri
play 60

sintetizador :zawa
Som.


use_synth :zawa
play 60

O comando puts synth_names, seguindo do botão [RUN] exibe todos os sintetizadores disponíveis na janela de log:
:beep, :blade, :bnoise, :chipbass, :chiplead, :chipnoise, :cnoise, :dark_ambience, :dpulse, :dsaw, :dtri, :dull_bell, :fm, :gnoise, :growl, :hollow, :hoover, :mod_beep, :mod_dsaw, :mod_fm, :mod_pulse, :mod_saw, :mod_sine, :mod_tri, :noise, :piano, :pluck, :pnoise, :pretty_bell, :prophet, :pulse, :saw, :sine, :square, :subpulse, :supersaw, :tb303, :tri, :zawa

#toca uma nota com cada sintetizador
puts synth_names
loop do
  x = synth_names.tick
  puts x
  use_synth x
  play 60
  sleep 2
end