coltrane 3.3.3 → 3.4.0

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
  SHA256:
3
- metadata.gz: d8bcc965c58bf6b15535fb68f68afae4d2c2bc80c4093fed74d2262832493ae1
4
- data.tar.gz: fbb8f333da624a0024cff3980393cf5b58d2072fc39f9f66cf7c5e90e974f8de
3
+ metadata.gz: 3461b7ccf37f1b56926dd7e97ae10e1bb05b72c7b431706dc9bcfe621f583d78
4
+ data.tar.gz: d1e3cb3b4735ba4a06bb5ec10232812d729d45918159b6574f7c6b310556ce86
5
5
  SHA512:
6
- metadata.gz: 5a3bbe886d212f9681fcee881062adf31f03420244d2a722768fadb7d3b13d6610afbc4ceb3411ffd83a86414aaa81e7723fda49279ee573bea3aba69733d5b1
7
- data.tar.gz: e4415544069e87173a94a784cace25eb51b57f18763d9ad4b331ce49ea3738c07729c7fdc7c6b9ef5f25489de933ed8c777705dce35c1821936d7f8ca9ee4134
6
+ metadata.gz: 0c4fed6840276e6c80e6ace57db61f66f69a69702792b98afadf72e8f59db135845e79fadd33a49f648e96d8dd2145e17ed99973780c76462b678d1a11a5629f
7
+ data.tar.gz: de98df40119044911a4e399e2ba4d985f4ba68ace17381fd3832f1db066b8600e01f0274b820aa5fdd146b2121d252eb1e240d6b83ab1f4be8adf6f1f9ea5fa8
@@ -5,6 +5,9 @@
5
5
  - Fix chords so that they generate a barre and a non-barre version and prevent
6
6
  barre chords from picking notes before the barre.
7
7
 
8
+ ## [3.4.0]
9
+ - Adds `find-guitar-chord` command. It allows discovering a guitar chord name.
10
+
8
11
  ## [3.3.3]
9
12
  - Fixes a bug in greek modes for accidental notes
10
13
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coltrane (3.3.3)
4
+ coltrane (3.4.0)
5
5
  color (~> 1.8)
6
6
  dry-monads (~> 0.4)
7
7
  paint (~> 2.0)
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
3
3
 
4
4
  require "bundler/setup"
5
5
  require "coltrane"
6
+ require "coltrane/commands"
6
7
  require "coltrane/representation"
7
8
  require "coltrane/renderers"
8
9
 
@@ -12,3 +12,4 @@ require 'coltrane/commands/progression'
12
12
  require 'coltrane/commands/common_chords'
13
13
  require 'coltrane/commands/find_scale'
14
14
  require 'coltrane/commands/find_progression'
15
+ require 'coltrane/commands/find_guitar_chord'
@@ -0,0 +1,25 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindGuitarChord < Command
4
+ attr_reader :notation
5
+
6
+ def initialize(notation)
7
+ @notation = notation
8
+ end
9
+
10
+ def representation
11
+ Representation::Guitar.find_chord_by_notation(notation)
12
+ end
13
+
14
+ def self.mercenary_init(program)
15
+ program.command(:'find-guitar-chord') do |c|
16
+ c.syntax 'find-guitar-chord x-2-2-4-5-x'
17
+ c.description 'find the chord name assuming the standard tuning (EADGBE)'
18
+ c.action do |(notation)|
19
+ new(notation).render
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -22,12 +22,18 @@ module Coltrane
22
22
  Guitar::NoteSet.new(notes, guitar: new)
23
23
  end
24
24
 
25
+ def self.find_chord_by_notation(chord_notation)
26
+ Guitar::Chord.find_by_notation(new, chord_notation)
27
+ end
28
+
25
29
  def initialize(tuning: nil, frets: nil, special_frets: nil)
26
30
  @tuning = tuning || %w[E2 A2 D3 G3 B3 E4]
27
31
  @special_frets = special_frets || [3, 5, 7, 9, 12, 15, 17, 19]
28
32
  @frets = frets || 23
29
33
 
30
- @strings = @tuning.map { |p| String.new(Theory::Pitch[p], guitar: self) }
34
+ @strings = @tuning.map do |p|
35
+ String.new(Theory::Pitch[p], guitar: self)
36
+ end
31
37
  end
32
38
  end
33
39
  end
@@ -17,6 +17,32 @@ module Coltrane
17
17
  .reverse
18
18
  end
19
19
 
20
+ def self.find_by_notation(guitar, chord_notation)
21
+ chord_notation
22
+ .split('-')
23
+ .map
24
+ .with_index do |n, i|
25
+ next if n == 'x'
26
+ n = Guitar::Note.new(guitar.strings[i], n.to_i).pitch.pitch_class
27
+ end
28
+ .yield_self do |notes|
29
+ notes
30
+ .map
31
+ .with_index do |note, index|
32
+ begin
33
+ Theory::Chord.new(notes: notes.rotate(index))
34
+ rescue Theory::ChordNotFoundError
35
+ next
36
+ end
37
+ end
38
+ .compact
39
+ .yield_self do |chords|
40
+ raise(Theory::ChordNotFoundError) if chords.empty?
41
+ chords.compact.uniq &:name
42
+ end
43
+ end
44
+ end
45
+
20
46
  def initialize(target_chord,
21
47
  guitar_notes: [],
22
48
  free_fingers: 4,
@@ -183,4 +209,4 @@ module Coltrane
183
209
  end
184
210
  end
185
211
  end
186
- end
212
+ end
@@ -76,16 +76,16 @@ module Coltrane
76
76
 
77
77
  def get_name
78
78
  find_chord(retrieve_chord_intervals.compact) ||
79
- find_chord(retrieve_chord_intervals(sus2_sequence).compact) ||
80
- find_chord(retrieve_chord_intervals(sus4_sequence).compact) ||
81
- raise(ChordNotFoundError)
79
+ find_chord(retrieve_chord_intervals(sus2_sequence).compact) ||
80
+ find_chord(retrieve_chord_intervals(sus4_sequence).compact) ||
81
+ raise(ChordNotFoundError)
82
82
  end
83
83
 
84
84
  def suspension_type
85
85
  if has_major_second?
86
86
  'sus2'
87
- else has_fourth?
88
- 'sus4'
87
+ elsif has_fourth?
88
+ 'sus4'
89
89
  end
90
90
  end
91
91
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coltrane
4
- VERSION = '3.3.3'
4
+ VERSION = '3.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coltrane
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Maciel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -179,6 +179,7 @@ files:
179
179
  - lib/coltrane/commands/command.rb
180
180
  - lib/coltrane/commands/common_chords.rb
181
181
  - lib/coltrane/commands/errors.rb
182
+ - lib/coltrane/commands/find_guitar_chord.rb
182
183
  - lib/coltrane/commands/find_progression.rb
183
184
  - lib/coltrane/commands/find_scale.rb
184
185
  - lib/coltrane/commands/notes.rb
@@ -265,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
266
  version: '0'
266
267
  requirements: []
267
268
  rubyforge_project:
268
- rubygems_version: 2.7.6
269
+ rubygems_version: 2.7.7
269
270
  signing_key:
270
271
  specification_version: 4
271
272
  summary: It deals with all sorts of calculations around music theory and allows for