sm808 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0da6fb6718ce4352bac3f03dd75498a6d84c8cc1
4
+ data.tar.gz: fc0fd1708c2d680d1786d5cce60c2e9a22b81395
5
+ SHA512:
6
+ metadata.gz: 214891d70bee594f228ef1c2429a3e3dc8f1929cada36b39a90313a025c591848f4c6058ec3c0247a2a9495b8d9a45d54da9ed6d8decc42aaa6a53b687150c50
7
+ data.tar.gz: bb219c906914b00a7dbf0539e7740c36ea93c2c20ce62f56730df2daaade088f9020454fd1fe336717595ee16b6b9eaff729c71af283af513f44928750b3599f
data/.byebug_history ADDED
@@ -0,0 +1,9 @@
1
+ continue
2
+ Music.kick_pattern
3
+ Cli.kick_pattern
4
+ ::kick_pattern
5
+ continue
6
+ Music.kick_pattern
7
+ Music.artii
8
+ self
9
+ self.artii
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.byebug_history/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at arbonap@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sm808 (0.1.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ artii (2.1.2)
10
+ byebug (10.0.2)
11
+ diff-lcs (1.3)
12
+ rake (10.5.0)
13
+ rspec-core (3.8.0)
14
+ rspec-support (~> 3.8.0)
15
+ rspec-expectations (3.8.0)
16
+ diff-lcs (>= 1.2.0, < 2.0)
17
+ rspec-support (~> 3.8.0)
18
+ rspec-mocks (3.8.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.8.0)
21
+ rspec-support (3.8.0)
22
+ thor (0.20.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ artii
29
+ bundler (~> 1.16)
30
+ byebug
31
+ rake (~> 10.0)
32
+ rspec-core
33
+ rspec-expectations
34
+ rspec-mocks
35
+ sm808!
36
+ thor (= 0.20.0)
37
+
38
+ BUNDLED WITH
39
+ 1.16.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Patricia Arbona
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Sm-808
2
+ - Programming a Sequencer for a Drum Machine: A Ruby Implementation of the famous "four on the floor" rhythm pattern
3
+
4
+
5
+ ## Setting up Sm-808
6
+
7
+ 1. Download the gem locally
8
+ 2. `gem install bundler`
9
+ 3. `bundle install`
10
+
11
+ ##
12
+
13
+ - Run `ruby lib/sm808/cli.rb` from the root directory to go through the interactive
14
+ terminal-based Drum Machine Sequencer
15
+ - For testing:
16
+ - run `rspec spec` for the entire test-suite
17
+ - run `rspec spec/music_spec.rb` to run `music_spec.rb` file
18
+
19
+ ## Development
20
+
21
+ To install this gem onto your local machine, run `bundle exec rake install`.
22
+
23
+ ## License
24
+
25
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ # If you want to make this the default task
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sm808"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/sm808 ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sm808/cli'
3
+
4
+ Sm808::CLI.start
data/lib/sm808/cli.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "byebug"
2
+ require_relative "music"
3
+ require_relative "pattern"
4
+ require_relative "score"
5
+ class Cli
6
+ extend Score
7
+ extend Pattern
8
+ kick = Pattern.kick
9
+
10
+ snare = Pattern.snare
11
+
12
+ hihat = Pattern.hihat
13
+ puts Music.welcome
14
+ puts "Welcome to SM808 Drum Machine Sequencer!"
15
+ puts "Let's implement the famous Four on the Floor rhythm pattern."
16
+
17
+ puts "What's the title of the song you'd like to compose?"
18
+ title = gets.chomp.to_s
19
+ puts "You've chose '#{title}' as your song title. Amazing!"
20
+ puts "What is the tempo (beats per minute) you want for your song? Enter an integer that is at least 30 BPM."
21
+ bpm = Score.validate_bpm
22
+ puts "You've chosen #{bpm} beats per minute in 4/4 time signature. Great!"
23
+ puts "How many measures of music (loops) would you like to play?"
24
+ num = Score.validate_measure
25
+ puts "You've chosen to loop #{num} times. Let's play!"
26
+ num.times { Score.calculate_music_measure(kick, snare, hihat, bpm) }
27
+ puts "Good-bye for now! Have a musical day. Ciao."
28
+ end
@@ -0,0 +1,7 @@
1
+ module Music
2
+ def self.welcome
3
+ # the artii gem creates ascii text
4
+ # this method shells it out
5
+ `artii Sm-808`
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ module Pattern
2
+ def self.snare
3
+ # this string represents one measure (or one line) of the snare pattern
4
+ # the 1 represents a snare beat
5
+ # the _ represents musical rests
6
+ '_|_|_|_|1|_|_|_|'
7
+ .split('|')
8
+ .map do |note|
9
+ note == "1" ? "snare": note
10
+ end
11
+ end
12
+
13
+ def self.hihat
14
+ # this string represents one measure (or one line) of the hihat pattern
15
+ # the 1 represents a hihat beat
16
+ # the _ represents musical rests
17
+ '_|_|1|_|_|_|1|_|'
18
+ .split('|')
19
+ .map do
20
+ |note| note == "1" ? "hihat": note
21
+ end
22
+ end
23
+
24
+ def self.kick
25
+ # this string represents one measure (or one line) of the kick pattern
26
+ # the 1 represents a kick beat
27
+ # the _ represents musical rests
28
+ '1|_|_|_|1|_|_|_|'
29
+ .split('|')
30
+ .map do |note|
31
+ note == '1' ? 'kick' : note
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,66 @@
1
+ # module that computes Musical Score output
2
+ module Score
3
+ def self.validate_bpm
4
+ # asks the user for the tempo (or BPM) of their music composition
5
+ # and provides some validation on the BPM they input
6
+ # prevents user from inputting a slow BPM, where the song must be at least 30 BPM
7
+ bpm = gets.chomp.to_i
8
+ if bpm.to_i < 30
9
+ puts "Your BPM has to be at least 30 BPM and cannot be 0. Let's try something else:"
10
+ # if the BPM isn't at least 30, recurse & give the user another chance
11
+ self.validate_bpm
12
+ end
13
+ bpm
14
+ end
15
+
16
+ def self.validate_measure
17
+ # asks the user for how many music measures they want in their music composition
18
+ # and provides some validation on the number of loops they input
19
+ # prevents user from inputting 0 or a negative number
20
+ measure_num = gets.chomp.to_i
21
+ if measure_num.to_i <= 0
22
+ puts "You must enter an integer atleast 1 or higher to create a music score:"
23
+ # if there isn't at least 1 music measure, recurse & give the user another chance
24
+ self.validate_measure
25
+ end
26
+ measure_num
27
+ end
28
+ def self.calculate_interval(bpm)
29
+ # calculate the amount of time each step in a pattern takes based on tempo
30
+ # must use Rational class to handle repeating decimals
31
+ # then finally convert the result into a float
32
+ # learn more here: https://ruby-doc.org/core-2.5.0/Rational.html
33
+ (((60r / bpm.to_r) * 4r) / 8r).to_f
34
+ end
35
+
36
+
37
+ def self.calculate_music_measure(kick, snare, hihat, bpm)
38
+ # .zip converts 3 arrays into a 2-D array of arrays
39
+ # with this shape:
40
+ # [
41
+ # ["kick", "_", "_"],
42
+ # ["_", "_", "_"],
43
+ # ["_", "_", "hihat"],
44
+ # ["_", "_", "_"],
45
+ # ["kick", "snare", "_"],
46
+ # ["_", "_", "_"],
47
+ # ["_", "_", "hihat"],
48
+ # ["_", "_", "_"]
49
+ # ]
50
+ kick.zip(snare, hihat)
51
+ .map(&:uniq)
52
+ .map(&:join)
53
+ .each do |note|
54
+ # delete any underscores if the array contains any music notes (besides rests)
55
+ note.gsub!("_",'') if note.size > 1
56
+ end
57
+ .map.with_index do |note, index|
58
+ # wait one beat before printing the music note or music rest
59
+ sleep self.calculate_interval(bpm)
60
+ print "|#{note}| "
61
+ # for every 8 music notes, begin a new line
62
+ # to represent each new measure ( or musical loop )
63
+ puts "\n" if index % 7 == 0 && index != 0
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module Sm808
2
+ VERSION = "0.1.2"
3
+ end
data/lib/sm808.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "sm808/version"
2
+ require "sm808/music"
data/sm808.gemspec ADDED
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sm808/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sm808"
8
+ spec.version = Sm808::VERSION
9
+ spec.authors = ["Anonymous Backend Splice Applicant"]
10
+ spec.email = ["anonymous@example.com"]
11
+
12
+ spec.summary = %q{Drum Machine Sequencer}
13
+ spec.description = %q{Implements sequence for the famous four on the floor rhythm pattern.}
14
+ spec.homepage = "https://github.com/arbonap/sm-808"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "thor", "0.20.0"
34
+ spec.add_development_dependency "rspec-core"
35
+ spec.add_development_dependency "rspec-mocks"
36
+ spec.add_development_dependency "rspec-expectations"
37
+ spec.add_development_dependency "byebug"
38
+ spec.add_development_dependency "artii"
39
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sm808
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Anonymous Backend Splice Applicant
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.20.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.20.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-core
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-mocks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-expectations
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: artii
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Implements sequence for the famous four on the floor rhythm pattern.
126
+ email:
127
+ - anonymous@example.com
128
+ executables:
129
+ - sm808
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".byebug_history"
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".travis.yml"
137
+ - CODE_OF_CONDUCT.md
138
+ - Gemfile
139
+ - Gemfile.lock
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - exe/sm808
146
+ - lib/sm808.rb
147
+ - lib/sm808/cli.rb
148
+ - lib/sm808/music.rb
149
+ - lib/sm808/pattern.rb
150
+ - lib/sm808/score.rb
151
+ - lib/sm808/version.rb
152
+ - sm808.gemspec
153
+ homepage: https://github.com/arbonap/sm-808
154
+ licenses:
155
+ - MIT
156
+ metadata:
157
+ allowed_push_host: https://rubygems.org
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.6.14
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Drum Machine Sequencer
178
+ test_files: []