From 555dffdc15b1bd1e8eafc488940fac3d4926bae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Siwi=C5=84ski?= Date: Thu, 8 Nov 2018 00:45:28 +0100 Subject: [PATCH 1/8] readme update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3d0edbf..8856eeb 100644 --- a/README.md +++ b/README.md @@ -12,5 +12,7 @@ Linux/Mac OS/Raspberry Pi Windows load_snippets('c:/dir/of/your/choice/sonic-pi-snippets') + +From that point snippets should be loaded automagically when Sonic Pi starts. ---- From 0067efcadf41c555196189481614dd09e7ac0bca Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 00:50:27 +0100 Subject: [PATCH 2/8] Drop riddles --- tutorial/tut03.sps | 1 - tutorial/tut10.sps | 13 ++----------- tutorial/tut13.sps | 3 --- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/tutorial/tut03.sps b/tutorial/tut03.sps index 05224e8..a167e44 100644 --- a/tutorial/tut03.sps +++ b/tutorial/tut03.sps @@ -3,7 +3,6 @@ # point_index: 0 # -- # TUT 03 ------------------------------------------------------ -# ZAGADKA NR. 1 play 60 play 64 diff --git a/tutorial/tut10.sps b/tutorial/tut10.sps index 8da4b52..04fc9df 100644 --- a/tutorial/tut10.sps +++ b/tutorial/tut10.sps @@ -3,18 +3,9 @@ # point_index: 0 # -- # TUT 10 --------------------------------------------- -# to też można zrobić łatwiej i wygodniej (gama C-dur) - - +# Gamę C-Dur można zagrać też na kilka innych sposobów play_pattern_timed scale(:c4, :major), 0.25 - - - -# sleep 1 -# ZAGADKA NR.2: jaki bedzie wynik uruchomienia ponizszej linii # play_pattern_timed scale(:c4, :major).reverse, 0.25 -# sleep 1 -# play_pattern_timed scale(:c4, :major).reverse, [0.125, 0.25] -# sleep 1 # play_pattern_timed scale(:c4, :major), [0.125, 0.25] +# play_pattern_timed scale(:c4, :major).reverse, [0.125, 0.25] diff --git a/tutorial/tut13.sps b/tutorial/tut13.sps index 643d093..e75ae10 100644 --- a/tutorial/tut13.sps +++ b/tutorial/tut13.sps @@ -5,9 +5,6 @@ # TUT 13 ------------------------------------------- # Sample mozemy modyfikowac, tak jak syntezatory -# ZAGADKA NR. 3 sample :loop_amen, rate: 0.5 - # sample :loop_amen, rate: 2.0 - # sample :loop_amen, rate: -1 From 3afaef9a5b9e8c1fd913c5db31c0f9cac27268f7 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 07:52:57 +0100 Subject: [PATCH 3/8] Snippets with patterns descriptions --- dp/desc_fm.sps | 13 +++++++++++++ dp/desc_str.sps | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 dp/desc_fm.sps create mode 100644 dp/desc_str.sps diff --git a/dp/desc_fm.sps b/dp/desc_fm.sps new file mode 100644 index 0000000..6855143 --- /dev/null +++ b/dp/desc_fm.sps @@ -0,0 +1,13 @@ +# key: desc fm +# point_line: 0 +# point_index: 0 +# -- + +puts "| -------------------------------------------------------------------|" +puts "| FACTORY METHOD (Metoda Fabrykująca): |" +puts "| -------------------------------------------------------------------|" +puts "| Wzorzec ten definiuje interfejs la tworzenia obiektu, ale pozwala |" +puts "| klasom implementującym na podjęcie decyzji o tym jakiej konkretnej |" +puts "| klasy obiekt utworzyć. Metoda fabrykująca powala oddelegować tę |" +puts "| czynność to klas implementujących jej interfejs. |" +puts "| -------------------------------------------------------------------|" \ No newline at end of file diff --git a/dp/desc_str.sps b/dp/desc_str.sps new file mode 100644 index 0000000..239551b --- /dev/null +++ b/dp/desc_str.sps @@ -0,0 +1,12 @@ +# key: desc str +# point_line: 0 +# point_index: 0 +# -- +puts "| -------------------------------------------------------------------|" +puts "| STRATEGIA (Strategy): |" +puts "| -------------------------------------------------------------------|" +puts "| Wzorzec strategia definiuje rodzinę algorytmów, hermetyzuje każdy |" +puts "| z nich w postaci klas. Ponadto jego zastosowanie sprawia, |" +puts "| że poczególne algorywmy mogą być używane zamiennie, niezależnie od |" +puts "| klas/klientów, którzy korzystają z tych algorytmów. |" +puts "| -------------------------------------------------------------------|" From 572b2161d48509206ae496fdc45d8c888b69fe02 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 07:56:42 +0100 Subject: [PATCH 4/8] Factory Method Snippets --- dp/dp_fac_3.sps | 18 ++++++++++- dp/dp_fac_3_bit.sps | 73 +++++++++++++++++++++++++++++++++++++++++++ dp/dp_fac_3_bit_a.sps | 17 ---------- dp/dp_fac_3_bit_b.sps | 19 ----------- dp/dp_fac_3_bit_c.sps | 18 ----------- dp/dp_fac_3_bit_d.sps | 18 ----------- dp/dp_fac_3_bit_e.sps | 19 ----------- dp/dp_fac_4.sps | 20 +++++++++--- dp/dp_fac_4_bit_a.sps | 40 ------------------------ dp/dp_fac_5.sps | 24 ++++++++++++++ dp/dp_fac_5_a.sps | 27 ++++++++++++++++ dp/dp_fac_6.sps | 27 ++++++++++++++++ dp/dp_fac_6_a.sps | 64 +++++++++++++++++++++++++++++++++++++ dp/dp_fac_7.sps | 30 ++++++++++++++++++ 14 files changed, 278 insertions(+), 136 deletions(-) create mode 100644 dp/dp_fac_3_bit.sps delete mode 100644 dp/dp_fac_3_bit_a.sps delete mode 100644 dp/dp_fac_3_bit_b.sps delete mode 100644 dp/dp_fac_3_bit_c.sps delete mode 100644 dp/dp_fac_3_bit_d.sps delete mode 100644 dp/dp_fac_3_bit_e.sps delete mode 100644 dp/dp_fac_4_bit_a.sps create mode 100644 dp/dp_fac_5.sps create mode 100644 dp/dp_fac_5_a.sps create mode 100644 dp/dp_fac_6.sps create mode 100644 dp/dp_fac_6_a.sps create mode 100644 dp/dp_fac_7.sps diff --git a/dp/dp_fac_3.sps b/dp/dp_fac_3.sps index cef1ff8..b5746a1 100644 --- a/dp/dp_fac_3.sps +++ b/dp/dp_fac_3.sps @@ -9,6 +9,8 @@ set_volume! 1 beat = ImpeachThePresident.new(ext_samples_path) # beat = FunkyDrummer.new(ext_samples_path) # beat = BigBeat.new(ext_samples_path) +# beat = HouseBeat.new(ext_samples_path) + live_loop :beat do use_bpm beat.bpm beat.steps.times do |step| @@ -17,4 +19,18 @@ live_loop :beat do end sleep 0.25 end -end \ No newline at end of file +end + +# https://www.youtube.com/watch?v=sVysHOfV8CI&t=5 +class BigBeat < BeatLoop + def initialize(samples_path) + @steps = 16 + @bpm = 127 + @loop = { + :drum_bass_hard => [1, 4, 7, 9], # KICK (stopa) + :drum_snare_hard => [5, 13], # SNARE (werbel) + "#{samples_path}/clap/clap707.wav" => [5, 13], # CLAP + } + end +end + diff --git a/dp/dp_fac_3_bit.sps b/dp/dp_fac_3_bit.sps new file mode 100644 index 0000000..dc9f5d0 --- /dev/null +++ b/dp/dp_fac_3_bit.sps @@ -0,0 +1,73 @@ +# key: dp fac 3 bit +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 3 BIT +# Our simple break bit wrapped into class + +# Base class +class BeatLoop + attr_reader :steps # amount of beats in pattern + attr_accessor :bpm + attr_reader :loop # pattern + def initialize(samples_path) + raise 'Use subclasses' + end +end + +# https://www.youtube.com/watch?v=dNP8tbDMZNE +class ImpeachThePresident < BeatLoop + def initialize(samples_path) + @steps = 16 + @bpm = 96 + @loop = { + :drum_bass_hard => [0, 7, 8, 14], # KICK (stopa) + :drum_snare_hard => [4, 12], # SNARE (werbel) + :drum_cymbal_closed => [0, 2, 4, 6, 7, 8, 12, 14], # CLOSED HI-HAT + :drum_cymbal_open => [10] # OPEN HI-HAT + } + end +end + +# https://www.youtube.com/watch?v=dNP8tbDMZNE +class FunkyDrummer < BeatLoop + def initialize(samples_path) + @steps = 16 + @bpm = 96 + @loop = { + :drum_bass_hard => [1, 3, 7, 11, 14], # KICK (stopa) + :drum_snare_hard => [5, 8, 10, 12, 13, 16], # SNARE (werbel) + :drum_cymbal_closed => [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16], # CLOSED HI-HAT + :drum_cymbal_open => [8, 14] # OPEN HI-HAT + } + end +end + +# https://www.youtube.com/watch?v=sVysHOfV8CI&t=5 +class BigBeat < BeatLoop + def initialize(samples_path) + @steps = 16 + @bpm = 127 + @loop = { + :drum_bass_hard => [1, 4, 7, 9], # KICK (stopa) + :drum_snare_hard => [5, 13], # SNARE (werbel) + "#{samples_path}/clap/clap707.wav" => [5, 13], # CLAP + } + end +end + + +# https://www.attackmagazine.com/technique/beat-dissected/rolling-deep-house/ +class HouseBeat < BeatLoop + def initialize(samples_path) + @steps = 16 + @bpm = 127 + @loop = { + :drum_tom_lo_soft => [3, 11], # TOM + :drum_cymbal_closed => [2, 6, 9, 10, 14], # OPEN HI-HAT + :drum_heavy_kick => [0, 4, 8, 12], # KICK + :perc_swash => [3, 11] # SHAKER + } + end +end + diff --git a/dp/dp_fac_3_bit_a.sps b/dp/dp_fac_3_bit_a.sps deleted file mode 100644 index 927e66d..0000000 --- a/dp/dp_fac_3_bit_a.sps +++ /dev/null @@ -1,17 +0,0 @@ -# key: dp fac 3 bit a -# point_line: 0 -# point_index: 0 -# -- -# DP FAC 3 BIT A -# Our simple break bit wrapped into class - -# Base class -class BeatLoop - attr_reader :steps # amount of beats in pattern - attr_reader :bpm - attr_reader :loop - def initialize(samples_path) - raise 'Use subclasses' - end -end - diff --git a/dp/dp_fac_3_bit_b.sps b/dp/dp_fac_3_bit_b.sps deleted file mode 100644 index 6bc9aad..0000000 --- a/dp/dp_fac_3_bit_b.sps +++ /dev/null @@ -1,19 +0,0 @@ -# key: dp fac 3 bit b -# point_line: 0 -# point_index: 0 -# -- -# DP FAC 3 BIT B -# https://www.youtube.com/watch?v=dNP8tbDMZNE -class ImpeachThePresident < BeatLoop - def initialize(samples_path) - @steps = 16 - @bpm = 96 - @loop = { - :drum_bass_hard => [0, 7, 8, 14], # KICK (stopa) - :drum_snare_hard => [4, 12], # SNARE (werbel) - :drum_cymbal_closed => [0, 2, 4, 6, 7, 8, 12, 14], # CLOSED HI-HAT - :drum_cymbal_open => [10] # OPEN HI-HAT - } - end -end - diff --git a/dp/dp_fac_3_bit_c.sps b/dp/dp_fac_3_bit_c.sps deleted file mode 100644 index 5b7f0c4..0000000 --- a/dp/dp_fac_3_bit_c.sps +++ /dev/null @@ -1,18 +0,0 @@ -# key: dp fac 3 bit c -# point_line: 0 -# point_index: 0 -# -- -# DP FAC 3 BIT C -# https://www.youtube.com/watch?v=dNP8tbDMZNE -class FunkyDrummer < BeatLoop - def initialize(samples_path) - @steps = 16 - @bpm = 96 - @loop = { - :drum_bass_hard => [1, 3, 7, 11, 14], # KICK (stopa) - :drum_snare_hard => [5, 8, 10, 12, 13, 16], # SNARE (werbel) - :drum_cymbal_closed => [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16], # CLOSED HI-HAT - :drum_cymbal_open => [8, 14] # OPEN HI-HAT - } - end -end diff --git a/dp/dp_fac_3_bit_d.sps b/dp/dp_fac_3_bit_d.sps deleted file mode 100644 index ff045f5..0000000 --- a/dp/dp_fac_3_bit_d.sps +++ /dev/null @@ -1,18 +0,0 @@ -# key: dp fac 3 bit d -# point_line: 0 -# point_index: 0 -# -- -# DP FAC 3 BIT D -# https://www.youtube.com/watch?v=sVysHOfV8CI&t=5 -class BigBeat < BeatLoop - def initialize(samples_path) - @steps = 16 - @bpm = 127 - @loop = { - :drum_bass_hard => [1, 4, 7, 9], # KICK (stopa) - :drum_snare_hard => [5, 13], # SNARE (werbel) - "#{samples_path}/clap/clap707.wav" => [5, 13], # CLAP - } - end -end - diff --git a/dp/dp_fac_3_bit_e.sps b/dp/dp_fac_3_bit_e.sps deleted file mode 100644 index e0e00f0..0000000 --- a/dp/dp_fac_3_bit_e.sps +++ /dev/null @@ -1,19 +0,0 @@ -# key: dp fac 3 bit e -# point_line: 0 -# point_index: 0 -# -- -# DP FAC 3 BIT E -# https://www.attackmagazine.com/technique/beat-dissected/rolling-deep-house/ -class HouseBeat < BeatLoop - def initialize(samples_path) - @steps = 16 - @bpm = 127 - @loop = { - :drum_tom_lo_soft => [3,11], # TOM - :drum_cymbal_closed => [2, 6, 9, 10, 14], # OPEN HI-HAT - :drum_heavy_kick => [0, 4, 8, 12], # KICK - :perc_swash => [3, 11] # SHAKER - } - end -end - diff --git a/dp/dp_fac_4.sps b/dp/dp_fac_4.sps index 021832b..3ed41d1 100644 --- a/dp/dp_fac_4.sps +++ b/dp/dp_fac_4.sps @@ -2,14 +2,26 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 4: Let's try to convert this simple loop -# into the the some kind'a more OOP loop +# DP FAC 4: In regular application You'll +# probably will have something like this: set_volume! 1 -use_bpm 96 # 127 +arg = 'Funky Drummer' + +if arg == 'Impeach The President' + beat = ImpeachThePresident.new(ext_samples_path) +elsif arg == 'Funky Drummer' + beat == FunkyDrummer.new(ext_samples_path) +elsif arg == 'Big Beat' + beat = BigBeat.new(ext_samples_path) +elsif arg == 'House Beat' + beat = HouseBeat.new(ext_samples_path) +else + beat = nil +end -beat = BigBeat.new live_loop :beat do + use_bpm beat.bpm beat.steps.times do |step| beat.loop.each do |s, pattern| sample s, amp: 0.5 if pattern.include? step diff --git a/dp/dp_fac_4_bit_a.sps b/dp/dp_fac_4_bit_a.sps deleted file mode 100644 index 2c874cb..0000000 --- a/dp/dp_fac_4_bit_a.sps +++ /dev/null @@ -1,40 +0,0 @@ -# key: dp fac 4 bit a -# point_line: 44 -# point_index: 0 -# -- -# DP FAC 4 BIT A -# Base Class -class BeatLoop - attr_reader :steps # amount of beats in pattern - attr_reader :loop -end - -# https://www.youtube.com/watch?v=dNP8tbDMZNE -class ImpeachThePresident < BeatLoop - def initialize - @steps = 16 - @bpm = 96 - @loop = { - :drum_bass_hard => [0, 7, 8, 14], # KICK (stopa) - :drum_snare_hard => [4, 12], # SNARE (werbel) - :drum_cymbal_closed => [0, 2, 4, 6, 7, 8, 12, 14], # CLOSED HI-HAT - :drum_cymbal_open => [10] # OPEN HI-HAT - } - end -end - -# https://www.youtube.com/watch?v=dNP8tbDMZNE -class FunkyDrummer < BeatLoop - def initialize - @steps = 16 - @bpm = 96 - @loop = { - :drum_bass_hard => [1, 3, 7, 11, 14], # KICK (stopa) - :drum_snare_hard => [5, 8, 10, 12, 13, 16], # SNARE (werbel) - :drum_cymbal_closed => [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16], # CLOSED HI-HAT - :drum_cymbal_open => [8, 14] # OPEN HI-HAT - } - end -end - - diff --git a/dp/dp_fac_5.sps b/dp/dp_fac_5.sps new file mode 100644 index 0000000..f0d2faa --- /dev/null +++ b/dp/dp_fac_5.sps @@ -0,0 +1,24 @@ +# key: dp fac 5 +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 5: Let's try to extract the logic of creating Beats to simple factory +set_volume! 1 + +arg = 'Impeach The President' +# arg = 'Funky Drummer' +# arg = 'Big Beat' +# arg = 'House Beat' + +beat_factory = SimpleBeatFactory.new(ext_samples_path) +beat = beat_factory.createBeat(arg) + +live_loop :beat do + use_bpm beat.bpm + beat.steps.times do |step| + beat.loop.each do |s, pattern| + sample s, amp: 0.5 if pattern.include? step + end + sleep 0.25 + end +end diff --git a/dp/dp_fac_5_a.sps b/dp/dp_fac_5_a.sps new file mode 100644 index 0000000..fdf6cee --- /dev/null +++ b/dp/dp_fac_5_a.sps @@ -0,0 +1,27 @@ +# key: dp fac 5 a +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 5 A: Simple Beat Factory implementation + +class SimpleBeatFactory + + def initialize(samples_path) + @samples_path = samples_path + + end + + def createBeat(beat_name) + if beat_name == 'Impeach The President' + ImpeachThePresident.new(@samples_path) + elsif beat_name == 'Funky Drummer' + FunkyDrummer.new(@samples_path) + elsif beat_name == 'Big Beat' + BigBeat.new(@samples_path) + elsif beat_name == 'House Beat' + HouseBeat.new(@samples_path) + else + nil + end + end +end diff --git a/dp/dp_fac_6.sps b/dp/dp_fac_6.sps new file mode 100644 index 0000000..ffaf11a --- /dev/null +++ b/dp/dp_fac_6.sps @@ -0,0 +1,27 @@ +# key: dp fac 6 +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 6: Let's try to create factories that produces beats with different tempo styles +set_volume! 1 + +arg = 'Impeach The President' +# arg = 'Funky Drummer' +# arg = 'Big Beat' +# arg = 'House Beat' + +moderato_bf = ModeratoBeatFactory.new(ext_samples_path) # BPM 88-92 +beat = moderato_bf.createBeat(arg) + +# allegro_bf = AllegroBeatFactory.new(ext_samples_path) # BPM 120-138 +# beat = allegro_bf.createBeat(arg) + +live_loop :beat do + use_bpm beat.bpm + beat.steps.times do |step| + beat.loop.each do |s, pattern| + sample s, amp: 0.5 if pattern.include? step + end + sleep 0.25 + end +end diff --git a/dp/dp_fac_6_a.sps b/dp/dp_fac_6_a.sps new file mode 100644 index 0000000..a3b853b --- /dev/null +++ b/dp/dp_fac_6_a.sps @@ -0,0 +1,64 @@ +# key: dp fac 6 a +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 6 A: Simple Beat Factory implementation + +class BeatFactoryMethod + + def initialize(samples_path) + raise 'Use one of sublasses' + end + + def createBeat(beat_name) + rais 'Unimplemented method' + end +end + +# BPM 88-92 +class ModeratoBeatFactory < BeatFactoryMethod + + def initialize(samples_path) + @samples_path = samples_path + @tempo = 92 + end + + def createBeat(beat_name) + beat = nil + if beat_name == 'Impeach The President' + beat = ImpeachThePresident.new(@samples_path) + elsif beat_name == 'Funky Drummer' + beat = FunkyDrummer.new(@samples_path) + elsif beat_name == 'Big Beat' + beat = BigBeat.new(@samples_path) + elsif beat_name == 'House Beat' + beat = HouseBeat.new(@samples_path) + end + beat.bpm = @tempo + beat + end +end + +# BPM around 120 – 138 +class AllegroBeatFactory < BeatFactoryMethod + + def initialize(samples_path) + @samples_path = samples_path + @tempo = 125 + end + + def createBeat(beat_name) + beat = nil + if beat_name == 'Impeach The President' + beat = ImpeachThePresident.new(@samples_path) + elsif beat_name == 'Funky Drummer' + beat = FunkyDrummer.new(@samples_path) + elsif beat_name == 'Big Beat' + beat = BigBeat.new(@samples_path) + elsif beat_name == 'House Beat' + beat = HouseBeat.new(@samples_path) + end + beat.bpm = @tempo + beat + end +end \ No newline at end of file diff --git a/dp/dp_fac_7.sps b/dp/dp_fac_7.sps new file mode 100644 index 0000000..edd6b12 --- /dev/null +++ b/dp/dp_fac_7.sps @@ -0,0 +1,30 @@ +# key: dp fac 7 +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 6: Let's try to create factories that produces beats with different tempo styles +set_volume! 1 + +arg = 'Impeach The President' +# arg = 'Funky Drummer' +# arg = 'Big Beat' +# arg = 'House Beat' + +# moderato_bf = ModeratoBeatFactory.new(ext_samples_path) # BPM 88-92 +# beat = moderato_bf.createBeat(arg) + +# allegro_bf = AllegroBeatFactory.new(ext_samples_path) # BPM 120-138 +# beat = allegro_bf.createBeat(arg) + +# presto_bf = PrestoBeatFactory.new(ext_samples_path) # BPM 120-138 +# beat = presto_bf.createBeat(arg) + +live_loop :beat do + use_bpm beat.bpm + beat.steps.times do |step| + beat.loop.each do |s, pattern| + sample s, amp: 0.5 if pattern.include? step + end + sleep 0.25 + end +end From 5a91fa7a2e41d5db9f5974766538b420746aa4e9 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 08:37:48 +0100 Subject: [PATCH 5/8] Extending Beat Factory with Presto style --- dp/dp_fac_6_a.sps | 2 +- dp/dp_fac_7.sps | 6 +++--- dp/dp_fac_7_a.sps | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 dp/dp_fac_7_a.sps diff --git a/dp/dp_fac_6_a.sps b/dp/dp_fac_6_a.sps index a3b853b..fc4bce3 100644 --- a/dp/dp_fac_6_a.sps +++ b/dp/dp_fac_6_a.sps @@ -2,7 +2,7 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 6 A: Simple Beat Factory implementation +# DP FAC 6 A: Beat Factory Method implementation class BeatFactoryMethod diff --git a/dp/dp_fac_7.sps b/dp/dp_fac_7.sps index edd6b12..937185a 100644 --- a/dp/dp_fac_7.sps +++ b/dp/dp_fac_7.sps @@ -2,7 +2,7 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 6: Let's try to create factories that produces beats with different tempo styles +# DP FAC 7: Let's try to create factories that produces beats with different tempo styles set_volume! 1 arg = 'Impeach The President' @@ -16,8 +16,8 @@ arg = 'Impeach The President' # allegro_bf = AllegroBeatFactory.new(ext_samples_path) # BPM 120-138 # beat = allegro_bf.createBeat(arg) -# presto_bf = PrestoBeatFactory.new(ext_samples_path) # BPM 120-138 -# beat = presto_bf.createBeat(arg) +presto_bf = PrestoBeatFactory.new(ext_samples_path) # BPM 168-199 +beat = presto_bf.createBeat(arg) live_loop :beat do use_bpm beat.bpm diff --git a/dp/dp_fac_7_a.sps b/dp/dp_fac_7_a.sps new file mode 100644 index 0000000..3a31f63 --- /dev/null +++ b/dp/dp_fac_7_a.sps @@ -0,0 +1,29 @@ +# key: dp fac 7 a +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 7 A: Add PrestoBeatFactory + +# BPM around 168 – 199 +class PrestoBeatFactory < BeatFactoryMethod + + def initialize(samples_path) + @samples_path = samples_path + @tempo = 175 + end + + def createBeat(beat_name) + beat = nil + if beat_name == 'Impeach The President' + beat = ImpeachThePresident.new(@samples_path) + elsif beat_name == 'Funky Drummer' + beat = FunkyDrummer.new(@samples_path) + elsif beat_name == 'Big Beat' + beat = BigBeat.new(@samples_path) + elsif beat_name == 'House Beat' + beat = HouseBeat.new(@samples_path) + end + beat.bpm = @tempo + beat + end +end \ No newline at end of file From 4bf7f7f506222a7c0158c9a8e93cc0120af5c720 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 08:38:25 +0100 Subject: [PATCH 6/8] WIP --- temp/dp_fac_8.sps | 32 ++++++++++++++++++++++++++++++++ temp/dp_fac_9.sps | 32 ++++++++++++++++++++++++++++++++ temp/dp_fac_9_a.sps | 27 +++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 temp/dp_fac_8.sps create mode 100644 temp/dp_fac_9.sps create mode 100644 temp/dp_fac_9_a.sps diff --git a/temp/dp_fac_8.sps b/temp/dp_fac_8.sps new file mode 100644 index 0000000..0423b2d --- /dev/null +++ b/temp/dp_fac_8.sps @@ -0,0 +1,32 @@ +# key: dp fac 8 +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 8 Let's try to create factories that produces beats with different tempo styles +set_volume! 1 + +arg = ['Impeach The President', 'moderato'] +# arg = ['Funky Drummer','allegro'] +# arg = ['Big Beat','presto'] +# arg = ['House Beat','moderato'] + +if tempo_name == 'moderato' + moderato_bf = ModeratoBeatFactory.new(ext_samples_path) + beat = moderato_bf.createBeat(arg[0]) +elsif tempo_name == 'allegro' + allegro_bf = AllegroBeatFactory.new(ext_samples_path) + beat = allegro_bf.createBeat(arg[0]) +elsif tempo_name == 'presto' + presto_bf = PrestoBeatFactory.new(ext_samples_path) + beat = presto_bf.createBeat(arg[0]) +end + +live_loop :beat do + use_bpm beat.bpm + beat.steps.times do |step| + beat.loop.each do |s, pattern| + sample s, amp: 0.5 if pattern.include? step + end + sleep 0.25 + end +end diff --git a/temp/dp_fac_9.sps b/temp/dp_fac_9.sps new file mode 100644 index 0000000..f30556f --- /dev/null +++ b/temp/dp_fac_9.sps @@ -0,0 +1,32 @@ +# key: dp fac 9 +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 8 Let's try to create factories that produces beats with different tempo styles +set_volume! 1 + +arg = ['Impeach The President', 'moderato'] +# arg = ['Funky Drummer','allegro'] +# arg = ['Big Beat','presto'] +# arg = ['House Beat','moderato'] + +tempo_factory = SimpleTempoFactory.new(ext_samples_path) + moderato_bf = ModeratoBeatFactory.new(ext_samples_path) + beat = moderato_bf.createBeat(arg[0]) +elsif tempo_name == 'allegro' + allegro_bf = AllegroBeatFactory.new(ext_samples_path) + beat = allegro_bf.createBeat(arg[0]) +elsif tempo_name == 'presto' + presto_bf = PrestoBeatFactory.new(ext_samples_path) + beat = presto_bf.createBeat(arg[0]) +end + +live_loop :beat do + use_bpm beat.bpm + beat.steps.times do |step| + beat.loop.each do |s, pattern| + sample s, amp: 0.5 if pattern.include? step + end + sleep 0.25 + end +end diff --git a/temp/dp_fac_9_a.sps b/temp/dp_fac_9_a.sps new file mode 100644 index 0000000..dbc9f7a --- /dev/null +++ b/temp/dp_fac_9_a.sps @@ -0,0 +1,27 @@ +# key: dp fac 6 a +# point_line: 0 +# point_index: 0 +# -- +# DP FAC 9 A: Beat Factory Method implementation + +class AbstractBeatFactory + + def initialize(samples_path) + raise 'Use one of sublasses' + @samples_path + end + + def createTempo(beat_name) + if tempo_name == 'moderato' + moderato_bf = ModeratoBeatFactory.new(@samples_path) + beat = moderato_bf.createBeat(tempo_name) + elsif tempo_name == 'allegro' + allegro_bf = AllegroBeatFactory.new(@samples_path) + beat = allegro_bf.createBeat(tempo_name) + elsif tempo_name == 'presto' + presto_bf = PrestoBeatFactory.new(@samples_path) + beat = presto_bf.createBeat(tempo_name) + end + end +end + From bc02f8f4b227f8714011147d7b54f2e22f838da7 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 08:57:58 +0100 Subject: [PATCH 7/8] Fixes --- dp/{desc_str.sps => desc_strategy.sps} | 2 +- dp/dp_fac_1.sps | 4 +++- dp/dp_fac_2_a.sps | 3 ++- dp/dp_fac_2_b.sps | 2 +- dp/dp_fac_2_c.sps | 7 ++++--- dp/dp_fac_3.sps | 14 -------------- dp/dp_fac_4.sps | 2 +- dp/dp_fac_5.sps | 4 +++- dp/dp_fac_6.sps | 4 +++- temp/dp_fac_9_a.sps | 2 +- 10 files changed, 19 insertions(+), 25 deletions(-) rename dp/{desc_str.sps => desc_strategy.sps} (96%) diff --git a/dp/desc_str.sps b/dp/desc_strategy.sps similarity index 96% rename from dp/desc_str.sps rename to dp/desc_strategy.sps index 239551b..b977f96 100644 --- a/dp/desc_str.sps +++ b/dp/desc_strategy.sps @@ -1,4 +1,4 @@ -# key: desc str +# key: desc strategy # point_line: 0 # point_index: 0 # -- diff --git a/dp/dp_fac_1.sps b/dp/dp_fac_1.sps index ad44bd8..b418ca3 100644 --- a/dp/dp_fac_1.sps +++ b/dp/dp_fac_1.sps @@ -2,7 +2,9 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 1: Our current beat loop isn't so flexible if we'd like to introduce different beat patterns +# DP FAC 1: +# Current beat sampling loop isn't so flexible if we'd like +# to introduce different beat patterns set_volume! 1 live_loop :beat do diff --git a/dp/dp_fac_2_a.sps b/dp/dp_fac_2_a.sps index 36d02d2..e9e9922 100644 --- a/dp/dp_fac_2_a.sps +++ b/dp/dp_fac_2_a.sps @@ -3,7 +3,8 @@ # point_index: 0 # -- # DP FAC 2 A -# This is a little bit more flexible solution, let's try add second beat... +# This is a little bit more flexible solution. +# Let's try add second beat... set_volume! 1 use_bpm 96 diff --git a/dp/dp_fac_2_b.sps b/dp/dp_fac_2_b.sps index 3bebda9..e5a4708 100644 --- a/dp/dp_fac_2_b.sps +++ b/dp/dp_fac_2_b.sps @@ -6,7 +6,7 @@ # That looks nice, but the code on the screen starts getting to much space on our screen... Let's add another one... set_volume! 1 -use_bpm 94 +use_bpm 96 # Impeach the president: https://www.youtube.com/watch?v=wqbEsS5kFb8 # beat_loop = { diff --git a/dp/dp_fac_2_c.sps b/dp/dp_fac_2_c.sps index 01a5ee6..548df60 100644 --- a/dp/dp_fac_2_c.sps +++ b/dp/dp_fac_2_c.sps @@ -3,9 +3,10 @@ # point_index: 0 # -- # DP FAC 2 C -# OK. This is the point, when we'd like to extract below beats to a separate configuration scripts. -# Apart of that it would be nice to have the possibility to store our beat patterns for later performances -# and make them easy to use. And You've probably noticed, that the BPM had changed. +# OK. This is the point, we'd like to extract below beats +# to a separate configuration scripts as it would be nice +# to have the possibility make them easy to reuse. +# And You've probably noticed, that the BPM had changed. set_volume! 1 use_bpm 127 diff --git a/dp/dp_fac_3.sps b/dp/dp_fac_3.sps index b5746a1..fd4b2ae 100644 --- a/dp/dp_fac_3.sps +++ b/dp/dp_fac_3.sps @@ -20,17 +20,3 @@ live_loop :beat do sleep 0.25 end end - -# https://www.youtube.com/watch?v=sVysHOfV8CI&t=5 -class BigBeat < BeatLoop - def initialize(samples_path) - @steps = 16 - @bpm = 127 - @loop = { - :drum_bass_hard => [1, 4, 7, 9], # KICK (stopa) - :drum_snare_hard => [5, 13], # SNARE (werbel) - "#{samples_path}/clap/clap707.wav" => [5, 13], # CLAP - } - end -end - diff --git a/dp/dp_fac_4.sps b/dp/dp_fac_4.sps index 3ed41d1..7865e52 100644 --- a/dp/dp_fac_4.sps +++ b/dp/dp_fac_4.sps @@ -11,7 +11,7 @@ arg = 'Funky Drummer' if arg == 'Impeach The President' beat = ImpeachThePresident.new(ext_samples_path) elsif arg == 'Funky Drummer' - beat == FunkyDrummer.new(ext_samples_path) + beat = FunkyDrummer.new(ext_samples_path) elsif arg == 'Big Beat' beat = BigBeat.new(ext_samples_path) elsif arg == 'House Beat' diff --git a/dp/dp_fac_5.sps b/dp/dp_fac_5.sps index f0d2faa..17b31b4 100644 --- a/dp/dp_fac_5.sps +++ b/dp/dp_fac_5.sps @@ -2,7 +2,9 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 5: Let's try to extract the logic of creating Beats to simple factory +# DP FAC 5: +# Let's try to extract the logic of creating Beats +# to simple factory set_volume! 1 arg = 'Impeach The President' diff --git a/dp/dp_fac_6.sps b/dp/dp_fac_6.sps index ffaf11a..9e846f5 100644 --- a/dp/dp_fac_6.sps +++ b/dp/dp_fac_6.sps @@ -2,7 +2,9 @@ # point_line: 0 # point_index: 0 # -- -# DP FAC 6: Let's try to create factories that produces beats with different tempo styles +# DP FAC 6: +# Let's try to create factories that produces +# beats with different tempo styles set_volume! 1 arg = 'Impeach The President' diff --git a/temp/dp_fac_9_a.sps b/temp/dp_fac_9_a.sps index dbc9f7a..657462f 100644 --- a/temp/dp_fac_9_a.sps +++ b/temp/dp_fac_9_a.sps @@ -1,4 +1,4 @@ -# key: dp fac 6 a +# key: dp fac 9 a # point_line: 0 # point_index: 0 # -- From 2232854ac9587fc2f9f684ba04d7476e2dbaa288 Mon Sep 17 00:00:00 2001 From: Lukasz Siwinski Date: Thu, 8 Nov 2018 11:03:55 +0100 Subject: [PATCH 8/8] Fix --- dp/dp_str_s0.sps | 1 - 1 file changed, 1 deletion(-) diff --git a/dp/dp_str_s0.sps b/dp/dp_str_s0.sps index b3bd485..eb71461 100644 --- a/dp/dp_str_s0.sps +++ b/dp/dp_str_s0.sps @@ -22,7 +22,6 @@ class BackgroundStrategy < IStrategy def initialize(sample_path) end end -end class MelodyStrategy < IStrategy def initialize(sample_path)