Skip to content
Browse files

Added drum kit parameter to constructor

  • Loading branch information...
1 parent 6f193e5 commit 93e2af47b70da6d8173f141f94456a3a6b31523a @rafadc committed
Showing with 9 additions and 9 deletions.
  1. +5 −6 README.md
  2. +4 −3 lib/drumkit.rb
View
11 README.md
@@ -22,10 +22,9 @@ You will be presented with a ruby console where you can start using the drum mac
For example if you type the following
- drums = Drumkit.new
- drums.load "gmkit"
- drums.pattern("kick",0,1)
- drums.pattern("tom_hi",2)
+ drums = Drumkit.new "gmkit"
+ drums.pattern("kick", 0, 1)
+ drums.pattern("tom_hi", 2)
drums.play 4
You'll here four times the pattern we just defined. The kick in the first and second beat and the tom in the third. The fourh beat will be on silence.
@@ -33,14 +32,14 @@ You'll here four times the pattern we just defined. The kick in the first and se
Then you can play with the tempo. If you do
drums.tempo = 200
- drums.play
+ drums.play 4
You'll hear your drums faster.
You can also change the lenght of a loop. If you do
drums.lenght = 2
- drums.play
+ drums.play 4
You'll only hear kicks all the way since the loop ends in the second beat.
View
7 lib/drumkit.rb
@@ -6,10 +6,11 @@ class Drumkit
attr_accessor :tempo, :lenght
- def initialize
+ def initialize(drumkit_name = nil, tempo = 180, lenght = 4)
@sounds = Hash.new
- @tempo = 80
- @lenght = 4
+ load drumkit_name unless drumkit_name.nil?
+ @tempo = tempo
+ @lenght = lenght
end
def load(drumkit_name)

0 comments on commit 93e2af4

Please sign in to comment.
Something went wrong with that request. Please try again.