music_theory 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90e22408edb41ccb659ba1fc6763a3cfb634dab4
4
- data.tar.gz: 58d8619d48f27e1edbcfe65cbe684eea0da72a09
3
+ metadata.gz: 0afeebdefed0000fc75bfb4ec149479ad838b770
4
+ data.tar.gz: 6b0192c14c44c991d83bad249e9714281c20720e
5
5
  SHA512:
6
- metadata.gz: c990897d7be49af0b28c18316931fd233499bde935f12936448c5ac5017147e171d41e3afb223565e4955529e068a6cd0876e512722a2c7bb8f569da51338449
7
- data.tar.gz: bd35d2b07a6b8acf3e2e4c1a138f46bdc784b03d06bf735675764f6bece46a0f550744de8af8156bd919f478a47aaf96fb573781b557999fce8a477549769990
6
+ metadata.gz: 477ac900a8dc3b002840dd291af75496205a6792fd82b2c30f44277e91c736bcd8a3fe5bd7160c8b41be9f257e3241c6990522c4480d2f814d00426f3715e1bf
7
+ data.tar.gz: 6ac2534757cfa2671f1d332cffe3a3e781a1f8e7431fa5209d254118068f97198662566bb58e45345c9c5801dd2827f64f8c1f7a878c05173bf667d07394bd33
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -7,14 +7,14 @@ module MusicTheory
7
7
  attr_accessor :third, :duration, :all_notes, :output_file_name
8
8
 
9
9
  def initialize(third, options = {})
10
- @duration = options[:duration] || 0.25
11
- @third = third
10
+ @duration = options[:duration] || 0.25
11
+ @third = third
12
12
  @output_file_name = options[:output_file_name] || 'chord' # File name to write (without extension)
13
13
  end
14
14
 
15
15
  def arpeggionate
16
16
  third.all_notes.each {|note| note.duration = duration}
17
- third.all_notes + [third.all_notes[2], third.all_notes[1], third.all_notes[0], third.all_notes[1]]
17
+ third.all_notes += [third.all_notes[2], third.all_notes[1], third.all_notes[0], third.all_notes[1]]
18
18
  end
19
19
 
20
20
  def samples
@@ -7,8 +7,8 @@ module MusicTheory
7
7
  attr_accessor :third, :duration, :all_notes, :output_file_name
8
8
 
9
9
  def initialize(third, options = {})
10
- @duration = options[:duration] || 2.0
11
- @third = third
10
+ @duration = options[:duration] || 2.0
11
+ @third = third
12
12
  @output_file_name = options[:output_file_name] || 'chord' # File name to write (without extension)
13
13
  end
14
14
 
@@ -1,14 +1,14 @@
1
1
  module MusicTheory
2
2
  class Modes
3
- S = 1
4
- T = 2
5
- I = [T, T, S, T, T, T, S]
6
- II = I.rotate
7
- III = I.rotate(2)
8
- IV = I.rotate(3)
9
- V = I.rotate(4)
10
- VI = I.rotate(5)
11
- VII = I.rotate(6)
3
+ S = 1
4
+ T = 2
5
+ I = [T, T, S, T, T, T, S]
6
+ II = I.rotate
7
+ III = I.rotate(2)
8
+ IV = I.rotate(3)
9
+ V = I.rotate(4)
10
+ VI = I.rotate(5)
11
+ VII = I.rotate(6)
12
12
  CHROMATIC = [S,S,S,S,S,S,S,S,S,S,S,S]
13
13
 
14
14
  # Map the music theory names as class methods
@@ -7,7 +7,7 @@ module MusicTheory
7
7
 
8
8
  def initialize(options = {})
9
9
  @frequency = options[:frequency] || 440.0 # Note frequency in Hz
10
- @frequency = @frequency.to_f
10
+ @frequency = @frequency.to_f
11
11
  @duration = options[:duration] || 1.0 # Number of seconds per note
12
12
  @distort = options[:distort] || false
13
13
  @output_file_name = options[:output_file_name] || 'note' # File name to write (without extension)
@@ -16,7 +16,7 @@ module MusicTheory
16
16
  def build_octave
17
17
  @all_notes = [ starting_note ]
18
18
  amount.to_i.times do
19
- new_note = all_notes.last.clone
19
+ new_note = all_notes.last.dup
20
20
  if direction == 'asc'
21
21
  new_note.frequency = all_notes.last.frequency * 2
22
22
  elsif direction == 'desc'
@@ -3,13 +3,14 @@ require 'music_theory/output'
3
3
  module MusicTheory
4
4
  class Play
5
5
  include MusicTheory::Output
6
-
7
6
  attr_accessor :samples, :output_file_name, :playable_music
7
+
8
8
  def initialize(playable_music = [], options = {} )
9
- @playable_music = playable_music
10
- @output_file_name = options[:output_file_name] || 'music'
9
+ @playable_music = playable_music
10
+ @output_file_name = options[:output_file_name] || 'music'
11
+ @play = options[:play] || true
11
12
  extract_samples
12
- play
13
+ play if play
13
14
  end
14
15
 
15
16
  def extract_samples
@@ -52,7 +52,7 @@ module MusicTheory
52
52
  end
53
53
 
54
54
  def third
55
- third ||= MusicTheory::Third.new self
55
+ third ||= MusicTheory::Third.new self.dup
56
56
  end
57
57
 
58
58
  def arpeggio
@@ -60,7 +60,7 @@ module MusicTheory
60
60
  end
61
61
 
62
62
  def chord
63
- third.chord
63
+ chord ||= third.chord
64
64
  end
65
65
 
66
66
  end
@@ -6,16 +6,15 @@ module MusicTheory
6
6
  attr_accessor :scale, :all_notes
7
7
 
8
8
  def initialize(scale)
9
- @scale = scale
10
- @all_notes = [scale.scale_notes.first]
11
- current = 0
9
+ @scale = scale
10
+ @all_notes = [scale.scale_notes.first]
11
+ current = 0
12
12
  double_scale_notes = scale.scale_notes * 2
13
13
  scale.mode.in_groups_of(2, false) do |group|
14
14
  current += group.sum
15
15
  all_notes << double_scale_notes[current]
16
16
  end
17
- all_notes.uniq! {|note| note.frequency}
18
- all_notes.sort_by! {|note| note.frequency}
17
+ all_notes.uniq! {|note| note.frequency}.sort_by! {|note| note.frequency}
19
18
  end
20
19
 
21
20
  def samples
@@ -23,11 +22,11 @@ module MusicTheory
23
22
  end
24
23
 
25
24
  def chord
26
- chord ||= MusicTheory::Chord.new self
25
+ chord ||= MusicTheory::Chord.new self.dup
27
26
  end
28
27
 
29
28
  def arpeggio
30
- arpeggio ||= MusicTheory::Arpeggio.new self
29
+ arpeggio ||= MusicTheory::Arpeggio.new self.dup
31
30
  end
32
31
 
33
32
  def output_file_name
@@ -1,3 +1,3 @@
1
1
  module MusicTheory
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/music_theory.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'wavefile'
2
- require 'active_support/all'
3
2
 
4
3
  require "music_theory/version"
5
4
  require "music_theory/note"
data/music_theory.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["beneggett@gmail.com"]
11
11
  spec.summary = %q{Music theory with ruby}
12
12
  spec.description = %q{Create music with pure ruby goodness}
13
- spec.homepage = ""
13
+ spec.homepage = "http://www.beneggett.com/#/ben-eggett"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "wavefile"
22
- spec.add_dependency "activesupport"
21
+ spec.add_runtime_dependency "wavefile", "~> 0"
23
22
 
24
- spec.add_development_dependency "pry"
23
+ spec.add_development_dependency "pry", "~> 0"
25
24
  spec.add_development_dependency "bundler", "~> 1.7"
26
25
  spec.add_development_dependency "rake", "~> 10.0"
27
26
  end
metadata CHANGED
@@ -1,55 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music_theory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Eggett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wavefile
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
17
+ - - "~>"
32
18
  - !ruby/object:Gem::Version
33
19
  version: '0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - ">="
24
+ - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - ">="
31
+ - - "~>"
46
32
  - !ruby/object:Gem::Version
47
33
  version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - ">="
38
+ - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
@@ -107,13 +93,12 @@ files:
107
93
  - lib/music_theory/transpose.rb
108
94
  - lib/music_theory/version.rb
109
95
  - music_theory.gemspec
110
- - note-charted.html
111
96
  - samples/arpeggios.rb
112
97
  - samples/demo.rb
113
98
  - samples/happy.rb
114
99
  - samples/simple_song.rb
115
100
  - samples/song.rb
116
- homepage: ''
101
+ homepage: http://www.beneggett.com/#/ben-eggett
117
102
  licenses:
118
103
  - MIT
119
104
  metadata: {}