احتمالا اسم خیلی از زبانای برنامه نویسی رو شنیدید آره ؟ پایتون ، سی ، سی پلاس پلاس ، روبی ، پرل ، لیسپ ، جاوا ، گو ، لوا و . اوووه تا صبح بگم بازم هستن .
ولی امروز میخوام یه زبان برنامه نویسی بهتون معرفی کنم قطعا قطعا خیلیاتون اسمشو نشنیدید تاحالا :) هه :)
بله یه زبان برنامه نویسی به نام سونیک پای (sonic pi) که مخصوص ساخت آهنگه ؟ یعنی چی ؟ یعنی با کد نویسی آهنگ بسازیم .
فکرشو بکن آهنگ های اوپن سورس :)))) . آهنگ هایی که سورسشون باز هست و میتونیم ببینیم .
خب بگم که یادگیری این زبان برنامه نویسی اصلا اصلا اصلا کار سختی نیست . من خودم یه سال پیش بود رو رزبری پای باهاش آشنا شدم تقریبا تو 1 روز بیشتر مفاهیم اصلیشو یاد گرفتم . زیاد مباحث سنگینی نداره مثل زبانای برنامه نویسی دیگه .
همینطور خود برنامه sonic pi هم یک آموزش کامل به زبان اصلی (ولی روان و قابل فهم) داره که من از همون یادش گرفتم .
برای برنامه نویسی به زبان سونیک پای باید اول برنامشو دانلود کنیم . میتونید از
توضیح بسه . بزارید بریم یکم باهاش آهنگ بزنیم .
خب برنامه رو که باز میکنیم با چنین صفحه ای رو به رو میشیم که داخلش کد مینویسیم و اونارو اجرا میکنیم (پخش میکنیم آهنگی که نوشتیم رو) :
حالا بزارید چند نمونه آهنگ که با سونیک پای نوشته شدن رو گوش کنیم . این آهنگ ها اوپن سورس هستند بنابراین سورسشون رو هم میبینیم . هر آهنگ رو اول سورس کدشو میزارم بعد خود اهنگشو که گوش کنید.
1 - آهنگ اول (از تو گیت هاب پیدا کردم سورسشو ):
# Chrono Trigger Soundtrack - Corridors of Time # plug this into http://sonic-pi.net/
# still needs synth pads
# global config use_bpm 112
def play_legato_note(note_value, duration) release_duration = duration if duration < 1 release_duration = 1 end play note_value, release: release_duration, amp: 0.65 sleep duration end
# arpeggio parts
def arp_d_2 play_pattern_timed [:d4, :fs4, :b4, :cs5, :fs5, :fs4, :b4, :cs5], [0.5], amp: 0.5 play_pattern_timed [:e5, :fs4, :b4, :cs5, :fs5, :fs4, :b4, :cs5], [0.5], amp: 0.5 end
def arp_fs_2 play_pattern_timed [:cs4, :e4, :b4, :cs5, :fs5, :fs4, :b4, :cs5], [0.5], amp: 0.5 play_pattern_timed [:e5, :fs4, :b4, :cs5, :fs5, :fs4, :b4, :cs5], [0.5], amp: 0.5 end
# bass parts
def bass_d play :d2, release: 1.5 sleep 1.5 play :d2, release: 1.5 sleep 1.5 play :a2 sleep 0.5 play :d3 sleep 0.5 end
def bass_fs_2 play :fs2, release: 1.5 sleep 1.5 play :fs2, release: 1.5 sleep 1.5 play :cs3 sleep 0.5 play :fs3 sleep 0.5 play :fs2, release: 1.5 sleep 1.5 play :fs2, release: 1.5 sleep 1.5 play :e2 sleep 1 end
def bass_cs_2 play :cs2, release: 1.5 sleep 1.5 play :cs2, release: 1.5 sleep 1.5 play :gs2 sleep 0.5 play :cs3 sleep 0.5 play :cs2, release: 1.5 sleep 1.5 play :cs2, release: 1.5 sleep 1.5 play :gs2 sleep 1 end
def bass_e play :e2, release: 1.5 sleep 1.5 play :e2, release: 1.5 sleep 1.5 play :b2 sleep 0.5 play :e3 sleep 0.5 end
# Workspace live_loop :arp do # intro arp_d_2 arp_d_2 # bass and drums enter arp_d_2 arp_fs_2 # all instruments loop do arp_d_2 arp_fs_2 end end
live_loop :bass do sleep 16 bass_d bass_d bass_fs_2 # start melody bass_d bass_d bass_cs_2 bass_d bass_d bass_fs_2 bass_d bass_d bass_cs_2 bass_d bass_e bass_fs_2 end
live_loop :kick_drum do sleep 16 loop do sample :drum_tom_lo_soft, rate: 0.5 sleep 0.75 sample :drum_tom_lo_soft sleep 0.75 sample :drum_tom_lo_soft sleep 1 sample :drum_tom_lo_soft sleep 1.5 end end
live_loop :snare_drum do sleep 16 loop do sleep 1 sample :drum_tom_hi_soft sleep 1 end end
live_loop :melody do use_synth :prophet sleep 32 # bar 1, 2 play_legato_note :gs4, 0.75 play_legato_note :gs4, 0.75 play_legato_note :fs4, 0.5 play_legato_note :fs4, 3.5 play_legato_note :fs4, 0.25 play_legato_note :gs4, 0.25 play_legato_note :a4, 0.75 play_legato_note :b4, 0.75 play_legato_note :a4, 0.25 play_legato_note :gs4, 0.25 # bar 3, 4 play_legato_note :fs4, 0.75 play_legato_note :fs4, 0.75 play_legato_note :e4, 0.5 play_legato_note :e4, 5.5 # pre-measure 1 play_legato_note :cs4, 0.5 # bar 5,6 play_legato_note :gs4, 0.75 play_legato_note :gs4, 0.75 play_legato_note :fs4, 0.5 play_legato_note :fs4, 3 sleep 0.5 play_legato_note :fs4, 0.5 play_legato_note :gs4, 0.75 play_legato_note :a4, 0.75 play_legato_note :b4, 0.5 play_legato_note :b4, 0.75 play_legato_note :cs5, 0.75 play_legato_note :cs5, 3.5 sleep 0.5 play_legato_note :cs5, 0.5 play_legato_note :e5, 0.75 play_legato_note :cs5, 0.75 play_legato_note :a4, 5.25 sleep 0.75 play_legato_note :a4, 0.5 play_legato_note :fs4, 1 play_legato_note :cs5, 1 # play_legato_note :b4, 0.75 play_legato_note :cs5, 0.75 play_legato_note :gs4, 1.5 play_legato_note :fs4, 0.5 play_legato_note :e4, 3 sleep 1 play_legato_note :e4, 0.5 # play_legato_note :fs4, 0.5 play_legato_note :a3, 0.5 play_legato_note :d4, 0.5 play_legato_note :e4, 0.5 play_legato_note :fs4, 0.75 play_legato_note :gs4, 0.75 play_legato_note :a4, 0.5 # play_legato_note :gs4, 0.5 play_legato_note :b3, 0.5 play_legato_note :e4, 0.5 play_legato_note :fs4, 0.5 play_legato_note :gs4, 0.75 play_legato_note :a4, 0.75 play_legato_note :gs4, 0.5 # play_legato_note :gs4, 3 play_legato_note :gs4, 0.5 play_legato_note :fs4, 0.5 # play_legato_note :fs4, 4 end
2 - آهنگ بازی Super Mario :
comment do # transcribed from the MML notation here: http://www.mmlshare.com/tracks/view/403 # # Sonic Pi currently has a size limit of about 9k which is a known issue (#102). # I've kept the comments up here to get around that as comment blocks don't get # sent to the interpreter. Some of the layout here is an exercise in reducing bytes. # I'm using Ruby's stabby lambda syntax ( -> { . } ) in case you want to google it :) # # THIS HAS ONLY BEEN TESTED ON A MAC - on an RaspberryPi you might want to change it to # use_bpm 60 # # Regarding the choice of an FM synth for drums: # You could use a noise synth here, but I think the NES sound # chip would have used something like this FM as the character # of the noise would change with different notes which I'm making # use of in drum_pattern_b end use_debug false # help RPi performance use_bpm 100 use_synth :pulse use_synth_defaults release: 0.2, mod_rate: 5, amp: 0.6 define :structure do |i,a,b,c,d| 1.times { i.call } loop do 2.times { a.call } 2.times { b.call } 1.times { c.call } 2.times { a.call } 2.times { d.call } 1.times { c.call } 1.times { d.call } end end
in_thread do intro = -> { play_pattern_timed([:e5,:e5,nil,:e5,nil,:c5,:e5,nil, :g5,nil,nil,nil,nil,nil,nil,nil], [0.25]) } theme_a = -> { play_pattern_timed([:c5,nil,nil,:g4,nil,nil,:e4,nil, nil,:a4,nil,:b4,nil,:Bb4,:a4,nil], [0.25]) play_pattern_timed([:g4,:e5,:g5], [1/3.0]) # minim triplets play_pattern_timed([:a5,nil,:f5,:g5, nil,:e5,nil,:c5, :d5,:b4,nil,nil], [0.25]) } theme_b = -> { play_pattern_timed([nil,nil,:g5,:fs5,:f5,:ds5,nil,:e5, nil,:gs4,:a4,:c5,nil,:a4,:c5,:d5, nil,nil,:g5,:fs5,:f5,:ds5,nil,:e5, nil,:c6,nil,:c6,:c6,nil,nil,nil, nil,nil,:g5,:fs5,:f5,:ds5,nil,:e5, nil,:gs4,:a4,:c5,nil,:a4,:c5,:d5, nil,nil,:ds5,nil,nil,:d5,nil,nil, :c5,nil,nil,nil,nil,nil,nil,nil], [0.25]) } theme_c = -> { play_pattern_timed([:c5,:c5,nil,:c5,nil,:c5,:d5,nil, :e5,:c5,nil,:a4,:g4,nil,nil,nil, :c5,:c5,nil,:c5,nil,:c5,:d5,:e5, nil,nil,nil,nil,nil,nil,nil,nil, :c5,:c5,nil,:c5,nil,:c5,:d5,nil, :e5,:c5,nil,:a4,:g4,nil,nil,nil, :e5,:e5,nil,:e5,nil,:c5,:e5,nil, :g5,nil,nil,nil,nil,nil,nil,nil], [0.25]) } theme_d = -> { play_pattern_timed([:e5,:c5,nil,:g4,nil,nil,:gs4,nil, :a4,:f5,nil,:f5,:a4,nil,nil,nil], [0.25]) play_pattern_timed([:b4,:a5,:a5, :a5,:g5,:f5], [1/3.0]) play_pattern_timed([:e5,:c5,nil,:a4,:g4,nil,nil,nil], [0.25]) play_pattern_timed([:e5,:c5,nil,:g4,nil,nil,:gs4,nil, :a4,:f5,nil,:f5,:a4,nil,nil,nil, :b4,:f5,nil,:f5], [0.25]) play_pattern_timed([:f5,:e5,:d5], [1/3.0]) play_pattern_timed([:g5,:e5,nil,:e5,:c5,nil,nil,nil], [0.25]) } structure(intro, theme_a, theme_b, theme_c, theme_d) end
in_thread do intro = -> { play_pattern_timed([:fs4,:fs4,nil,:fs4,nil,:fs4,:fs4,nil, :b4,nil,nil,nil,:g4,nil,nil,nil], [0.25]) } theme_a = -> { play_pattern_timed([:e4,nil,nil,:c4,nil,nil,:g3,nil, nil,:c4,nil,:d4,nil,:Db4,:c4,nil], [0.25]) play_pattern_timed([:c4,:g4,:b4], [1/3.0]) play_pattern_timed([:c5,nil,:a4,:b4, nil,:a4,nil,:e4, :f4,:d4,nil,nil], [0.25]) } theme_b = -> { play_pattern_timed([nil,nil,:e5,:ds5,:d5,:b4,nil,:c5, nil,:e4,:f4,:g4,nil,:c4,:e4,:f4, nil,nil,:e5,:ds5,:d5,:b4,nil,:c5, nil,:f5,nil,:f5,:f5,nil,nil,nil, nil,nil,:e5,:ds5,:d5,:b4,nil,:c5, nil,:e4,:f4,:g4,nil,:c4,:e4,:f4, nil,nil,:gs4,nil,nil,:f4,nil,nil, :e4,nil,nil,nil,nil,nil,nil,nil], [0.25]) } theme_c = -> { play_pattern_timed([:gs4,:gs4,nil,:gs4,nil,:gs4,:as4,nil, :g4,:e4,nil,:e4,:c4,nil,nil,nil, :gs4,:gs4,nil,:gs4,nil,:gs4,:as4,:g4, nil,nil,nil,nil,nil,nil,nil,nil, :gs4,:gs4,nil,:gs4,nil,:gs4,:as4,nil, :g4,:e4,nil,:e4,:c4,nil,nil,nil, :fs4,:fs4,nil,:fs4,nil,:fs4,:fs4,nil, :b4,nil,nil,nil,:g4,nil,nil,nil], [0.25]) } theme_d = -> { play_pattern_timed([:c5,:a4,nil,:e4,nil,nil,:e4,nil, :f4,:c5,nil,:c5,:f4,nil,nil,nil], [0.25]) play_pattern_timed([:g4,:f5,:f5, :f5,:e5,:d5], [1/3.0]) play_pattern_timed([:c5,:a4,nil,:f4,:e4,nil,nil,nil], [0.25]) play_pattern_timed([:c5,:a4,nil,:e4,nil,nil,:e4,nil, :f4,:c5,nil,:c5,:f4,nil,nil,nil, :g4,:d5,nil,:d5], [0.25]) play_pattern_timed([:d5,:c5,:b4], [1/3.0]) play_pattern_timed([:c5,nil,nil,nil,nil,nil,nil,nil], [0.25]) } structure(intro, theme_a, theme_b, theme_c, theme_d) end
in_thread do use_synth :tri use_synth_defaults attack: 0, sustain: 0.1, decay: 0.1, release: 0.1, amp: 0.4 intro = -> { play_pattern_timed([:D4,:D4,nil,:D4,nil,:D4,:D4,nil, :G3,nil,nil,nil,:G4,nil,nil,nil], [0.25]) } theme_a = -> { play_pattern_timed([:G4,nil,nil,:E4,nil,nil,:C4,nil, nil,:F4,nil,:G4,nil,:Gb4,:F4,nil], [0.25]) play_pattern_timed([:E4,:C4,:E4], [1/3.0]) play_pattern_timed([:F4,nil,:D4,:E4, nil,:C4,nil,:A3, :B3,:G3,nil,nil], [0.25]) } theme_b = -> { play_pattern_timed([:C3,nil,nil,:G3,nil,nil,:C3,nil, :F3,nil,nil,:C3,:C3,nil,:F3,nil, :C3,nil,nil,:E3,nil,nil,:G3,:C3, nil,:G2,nil,:G2,:G2,nil,:G4,nil, :C3,nil,nil,:G3,nil,nil,:C3,nil, :F3,nil,nil,:C3,:C3,nil,:F3,nil, :C3,nil,:Ab3,nil,nil,:Bb3,nil,nil, :C3,nil,nil,:G2,:G2,nil,:C3,nil], [0.25]) } theme_c = -> { 3.times { play_pattern_timed([:gs4,nil,nil,:ds4,nil,nil,:gs4,nil, :g4,nil,nil,:c4,nil,nil,:g4,nil], [0.25]) } play_pattern_timed([:D4,:D4,nil,:D4,nil,:D4,:D4,nil, :G3,nil,nil,nil,:G4,nil,nil,nil], [0.25]) } theme_d = -> { play_pattern_timed([:C3,nil,nil,:fs3,:g3,nil,:C3,nil, :F3,nil,:F3,nil,:C3,:C3,:F3,nil, :D3,nil,nil,:F3,:G3,nil,:B3,nil, :G3,nil,:G3,nil,:C3,:C3,:G3,nil, :C3,nil,nil,:fs3,:g3,nil,:C3,nil, :F3,nil,:F3,nil,:C3,:C3,:F3,nil, :G3,nil,nil,:G3], [0.25]) play_pattern_timed([:G3,:A3,:B3], [1/3.0]) play_pattern_timed([:C4,nil,:G3,nil,:C4,nil,nil,nil], [0.25]) } structure(intro, theme_a, theme_b, theme_c, theme_d) end
in_thread do use_synth :fm use_synth_defaults divisor: 1.6666, attack: 0.0, depth: 1500, sustain: 0.05, release: 0.0 ll = -> { play :a, sustain: 0.1; sleep 0.75 } l = -> { play :a, sustain: 0.1; sleep 0.5 } s = -> { play :a; sleep 0.25 } define :drum_pattern_a do [l,s,l,s,l,ll,l,s,s,s].map(&:call) end define :drum_pattern_b do play :b sleep 0.5 play :a6 sleep 0.3 play :a7 sleep 0.2 play :a, sustain: 0.1 sleep 0.5 play :a6 sleep 0.3 play :a7 sleep 0.2 end define :drum_pattern_c do [ll,s,l,l].map(&:call) end with_fx :level, amp: 0.5 do 1.times { drum_pattern_a } loop do 24.times { drum_pattern_b } 4.times { drum_pattern_a } 8.times { drum_pattern_b } 16.times { drum_pattern_c } 4.times { drum_pattern_a } 8.times { drum_pattern_b } end end end
3 - یه آهنگ دیگه (اینم از گیت هاب گرفتم ):
# Daft punk with code - Something about us # Coded by @luiscript with Sonic Pi
# If you enjoy PLEASE # like | follow | suscribe | star
# facebook.com/luiscript # twitter.com/luiscript # youtube.com/user/luiscript # github.com/luiscript
# Also consider support Sam Aaron on Patreon # patreon.com/samaaron
use_bpm 100 use_debug false
define :pianoMelody do use_synth :piano use_synth_defaults amp: 2, release: 4 play [:f2, :a2, :d3] sleep 4 play [:g2, :a2, :c3] sleep 4 play [:a2, :c3, :e3] sleep 4 play [:g2, :b2, :d3] sleep 4 play [:f2, :a2, :d3] sleep 4 play [:g2, :a2, :cs3] sleep 4 play [:a2, :d3, :g3] sleep 4 play [:a2, :d3, :f3] sleep 4 end
define :synth1 do use_synth :saw use_synth_defaults release: 0.25 sleep 0.5 play :d2 sleep 0.75 play :f2 sleep 0.75 play :d2 sleep 1 play :f2 sleep 0.5 play :a1 sleep 0.25 play :c2 sleep 0.75 play :d2 sleep 0.75 play :f2 sleep 0.75 play :d2 sleep 1 play :f2, release: 0.75 sleep 0.75 play :g2 sleep 0.25 end
define :synth2 do use_synth :pluck use_synth_defaults amp: 0.8 play :d3, release: 1 sleep 1 play :e3, release: 1 sleep 0.75 play :f3, release: 1.125 sleep 2.25 play [:c3, :e3], release: 1 sleep 1 play [:d3, :f3], release: 1 sleep 0.75 play [:e3, :g3], release: 1.125 sleep 2.25 play [:d3, :f3], release: 1 sleep 1 play [:e3, :g3], release: 1.125 sleep 0.75 play [:f3, :a3], release: 1.125 sleep 2.25 play [:f3, :a3], release: 0.25 sleep 0.25 play [:e3, :g3], release: 0.5 sleep 0.5 play [:e3, :g3], release: 0.5 sleep 0.5 play [:d3, :f3], release: 0.5 sleep 0.5 play [:d3, :f3], release: 1.5 sleep 2.25 end
define :bassDrum do sample :bd_fat, amp: 2 sleep 1 end
define :hiHat do sleep 0.5 sample :drum_cymbal_pedal sleep 0.5 end
define :snare do sleep 1 sample :sn_zome, amp: 0.5 sleep 1 end
live_loop :somethingAboutUs do 3.times do with_fx :lpf, cutoff: 80 do pianoMelody end end with_fx :reverb do 2.times do synth2 end end sample :daftVoice, amp: 0.8 sleep 64 with_fx :lpf, cutoff: 80 do pianoMelody end sample :daftSynth, amp: 0.7 sleep 96 stop end
with_fx :bitcrusher do live_loop :synth, delay: 32 do 24.times do synth1 end stop end end
live_loop :bassSample, delay: 32 do .times do sample :saub sleep 16 end stop end
live_loop :drum, delay: 32 do 128.times do bassDrum end sleep 16 142.times do bassDrum end stop end
live_loop :hh, delay: 48 do 112.times do hiHat end sleep 16 142.times do hiHat end stop end
live_loop :sn, delay: 48 do 56.times do snare end sleep 16 71.times do snare end stop end
4 - و اینم آهنگ معروف still dre همینجوری خودم زدم :
live_loop :chord do
use_synth :piano
sample :bd_haus
play :C5
play :E5
play :A5
sleep 0.3
play :C5
play :E5
play :A5
sleep 0.3
sample :bd_haus
sample :drum_snare_hard
play :C5
play :E5
play :A5
sleep 0.3
play :C5
play :E5
play :A5
sleep 0.3
sample :bd_haus
play :C5
play :E5
play :A5
sleep 0.3
play :C5
play :E5
play :A5
sleep 0.3
sample :bd_haus
sample :drum_snare_hard
play :C5
play :E5
play :A5
sleep 0.3
play :C5
play :E5
play :A5
sleep 0.3
sample :bd_haus
play :B4
play :E5
play :A5
sleep 0.3
play :B4
play :E5
play :A5
sleep 0.3
sample :bd_haus
sample :drum_snare_hard
play :B4
play :E5
play :A5
sleep 0.3
play :B4
play :E5
play :G5
sleep 0.3
sample :bd_haus
play :B4
play :E5
play :G5
sleep 0.3
play :B4
play :E5
play :G5
sleep 0.3
sample :bd_haus
sample :drum_snare_hard
play :B4
play :E5
play :G5
sleep 0.3
play :B4
play :E5
play :G5
sleep 0.3
end
خب تمام این سورس ها رو میتونید خودتون برنامشو نصب کنید و اجرا کنید و تست کنید ، تغییرشون بدید و آهنگ های جدید بسازید . در کل اگه وقت بزاری براش آهنگ های خوبی میشه باهاش درآورد . از این به بعد هر دفعه ای یه سری ملودی با این میسازم میزارم .
ولی خب این میتونه یه امکان فوق العاده برای یک برنامه نویس باشه . فرض کنید بعضی از صدا ها و آهنگ های نرم افزارتون رو خودتون بسازید !