A Monobloc program, using Monobloc Synth to create music. It's still early days for Monobloc and Synth. The music is not very sophisticated yet, and the code is too tedious and complicated for what it does.
Something went wrong. Try again.
monobloc-synth-2026-08-03.monobloc
· Created 2mo ago ·6.7 kB · 287 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288fn start => { | | sample_rate => sample_rate . 0.125 => volume . 240 => beats_per_minute . 32 => length_in_beats . -9 note => c4 . -8 note => c4♯ . c4♯ => d4♭ . -7 note => d4 . -6 note => d4♯ . d4♯ => e4♭ . -5 note => e4 . -4 note => f4 . -3 note => f4♯ . f4♯ => g4♭ . -2 note => g4 . -1 note => g4♯ . g4♯ => a4♭ . 0 note => a4 . 1 note => a4♯ . a4♯ => b4♭ . 2 note => b4 . c4 2 / => c3 . c4♯ 2 / => c3♯ . d4♭ 2 / => d3♭ . d4 2 / => d3 . d4♯ 2 / => d3♯ . e4♭ 2 / => e3♭ . e4 2 / => e3 . f4 2 / => f3 . f4♯ 2 / => f3♯ . g4♭ 2 / => g3♭ . g4 2 / => g3 . g4♯ 2 / => g3♯ . a4♭ 2 / => a3♭ . a4 2 / => a3 . a4♯ 2 / => a3♯ . b4♭ 2 / => b3♭ . b4 2 / => b3 . c3 2 / => c2 . c3♯ 2 / => c2♯ . d3♭ 2 / => d2♭ . d3 2 / => d2 . d3♯ 2 / => d2♯ . e3♭ 2 / => e2♭ . e3 2 / => e2 . f3 2 / => f2 . f3♯ 2 / => f2♯ . g3♭ 2 / => g2♭ . g3 2 / => g2 . g3♯ 2 / => g2♯ . a3♭ 2 / => a2♭ . a3 2 / => a2 . a3♯ 2 / => a2♯ . b3♭ 2 / => b2♭ . b3 2 / => b2 . global_timer_init => global_timer . osc_init => osc_a_timer osc_a_volume . osc_init => osc_b_timer osc_b_volume . osc_init => osc_c_timer osc_c_volume . global_timer osc_a_timer osc_a_volume osc_b_timer osc_b_volume osc_c_timer osc_c_volume loop}fn loop => global_timer osc_a_timer osc_a_volume osc_b_timer osc_b_volume osc_c_timer osc_c_volume{ | sample_rate volume beats_per_minute length_in_beats c2 c2♯ d2♭ d2 d2♯ e2♭ e2 f2 f2♯ g2♭ g2 g2♯ a2♭ a2 a2♯ b2♭ b2 c3 c3♯ d3♭ d3 d3♯ e3♭ e3 f3 f3♯ g3♭ g3 g3♯ a3♭ a3 a3♯ b3♭ b3 c4 c4♯ d4♭ d4 d4♯ e4♭ e4 f4 f4♯ g4♭ g4 g4♯ a4♭ a4 a4♯ b4♭ b4 | global_timer global_timer_to_beat => beat . global_timer global_timer_update => global_timer . osc_a_timer voice osc_a_volume * osc_b_timer voice osc_b_volume * + osc_c_timer voice osc_c_volume * + volume * push_sample osc_a_timer beat pattern_mid osc_update => osc_a_timer . osc_b_timer beat pattern_low osc_update => osc_b_timer . 0.75 => osc_a_volume . osc_c_timer beat pattern_low 2 / osc_update => osc_c_timer . 0.25 => osc_b_volume . global_timer osc_a_timer osc_a_volume osc_b_timer osc_b_volume osc_c_timer osc_c_volume loop}fn voice => osc { | return _ . | osc osc_saw return}fn pattern_low => beat { | c2 c2♯ d2♭ d2 d2♯ e2♭ e2 f2 f2♯ g2♭ g2 g2♯ a2♭ a2 a2♯ b2♭ b2 c3 c3♯ d3♭ d3 d3♯ e3♭ e3 f3 f3♯ g3♭ g3 g3♯ a3♭ a3 a3♯ b3♭ b3 c4 c4♯ d4♭ d4 d4♯ e4♭ e4 f4 f4♯ g4♭ g4 g4♯ a4♭ a4 a4♯ b4♭ b4 return _ . | beat 32 % match => beat if { | | beat 0 >= beat 12 < and } { | c3 | c3 } => beat if { | | beat 12 >= beat 16 < and } { | e3 | e3 } => beat if { | | beat 16 >= beat 28 < and } { | f3 | f3 } => beat if { | | beat 28 >= beat 32 < and } { | e3 | e3 } => _ { | | 0 } . return}fn pattern_mid => beat { | c2 c2♯ d2♭ d2 d2♯ e2♭ e2 f2 f2♯ g2♭ g2 g2♯ a2♭ a2 a2♯ b2♭ b2 c3 c3♯ d3♭ d3 d3♯ e3♭ e3 f3 f3♯ g3♭ g3 g3♯ a3♭ a3 a3♯ b3♭ b3 c4 c4♯ d4♭ d4 d4♯ e4♭ e4 f4 f4♯ g4♭ g4 g4♯ a4♭ a4 a4♯ b4♭ b4 return _ . | beat 32 % match => beat if { | | beat 0 >= beat 14 < and } { | c4 g4 e4 d4 | beat 8 % match => beat if { | | beat 0 >= beat 3 < and } { | c4 | c4 } => beat if { | | beat 3 >= beat 4 < and } { | g4 | g4 } => beat if { | | beat 4 >= beat 6 < and } { | e4 | e4 } => beat if { | | beat 6 >= beat 8 < and } { | d4 | d4 } . } => beat if { | | beat 14 >= beat 16 < and } { | d4♯ | d4♯ } => beat if { | | beat 16 >= beat 30 < and } { | d4 a4 f4 d4♯ | beat 8 % match => beat if { | | beat 0 >= beat 3 < and } { | d4 | d4 } => beat if { | | beat 3 >= beat 4 < and } { | a4 | a4 } => beat if { | | beat 4 >= beat 6 < and } { | f4 | f4 } => beat if { | | beat 6 >= beat 8 < and } { | d4♯ | d4♯ } . } => beat if { | | beat 30 >= beat 32 < and } { | e4 | e4 } => _ { | | 0 } . return}# Infrastructurefn note => distance_from_a4_in_half_steps { | return _ . | 2 distance_from_a4_in_half_steps 12 / pow 440 * return}fn global_timer_init => { | return _ . | 0 return}fn global_timer_to_beat => global_timer { | sample_rate beats_per_minute return _ . | global_timer sample_rate / beats_per_second * return}fn global_timer_update => timer { | sample_rate beats_per_minute length_in_beats return _ . | timer 1 + => timer . sample_rate beats_per_second / length_in_beats * => length_in_samples . timer length_in_samples >= match => done if { | | done 1 = } { | | exit } => _ { | timer | timer } . return}fn beats_per_second => { | beats_per_minute return _ . | beats_per_minute 60 / return}fn osc_init => { | return _ _ . | 0 => osc_timer . 1 => osc_volume . osc_timer osc_volume return}fn osc_update => osc_timer pitch { | sample_rate return _ . | pitch sample_rate / osc_timer + => osc_timer . osc_timer 1 >= match => must_wrap if { | | must_wrap 0 = } { | osc_timer | osc_timer } => must_wrap if { | | must_wrap 1 = } { | osc_timer | osc_timer 1 - } . return}fn osc_saw => osc_timer { | return _ . | osc_timer return}