coltrane 2.2.1 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +16 -1
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile.lock +25 -2
  5. data/README.md +3 -0
  6. data/bin/console +6 -2
  7. data/coltrane.gemspec +2 -1
  8. data/exe/coltrane +14 -224
  9. data/lib/coltrane.rb +3 -50
  10. data/lib/coltrane/commands.rb +14 -0
  11. data/lib/coltrane/commands/chords.rb +77 -0
  12. data/lib/coltrane/commands/command.rb +45 -0
  13. data/lib/coltrane/commands/common_chords.rb +33 -0
  14. data/lib/coltrane/commands/errors.rb +44 -0
  15. data/lib/coltrane/commands/find_progression.rb +28 -0
  16. data/lib/coltrane/commands/find_scale.rb +39 -0
  17. data/lib/coltrane/commands/notes.rb +44 -0
  18. data/lib/coltrane/commands/progression.rb +27 -0
  19. data/lib/{cli → coltrane/commands}/representation.rb +0 -0
  20. data/lib/coltrane/commands/scale.rb +46 -0
  21. data/lib/coltrane/renderers.rb +6 -0
  22. data/lib/coltrane/renderers/renderer.rb +42 -0
  23. data/lib/coltrane/renderers/text_renderer.rb +23 -0
  24. data/lib/coltrane/renderers/text_renderer/array_drawer.rb +45 -0
  25. data/lib/coltrane/renderers/text_renderer/base_drawer.rb +20 -0
  26. data/lib/coltrane/renderers/text_renderer/hash_drawer.rb +16 -0
  27. data/lib/coltrane/renderers/text_renderer/representation_guitar_chord_drawer.rb +95 -0
  28. data/lib/coltrane/renderers/text_renderer/representation_guitar_note_set_drawer.rb +76 -0
  29. data/lib/coltrane/renderers/text_renderer/representation_piano_note_set_drawer.rb +49 -0
  30. data/lib/coltrane/renderers/text_renderer/theory_chord_drawer.rb +14 -0
  31. data/lib/coltrane/renderers/text_renderer/theory_note_set_drawer.rb +17 -0
  32. data/lib/coltrane/renderers/text_renderer/theory_progression_drawer.rb +13 -0
  33. data/lib/coltrane/renderers/text_renderer/theory_progression_set_drawer.rb +22 -0
  34. data/lib/coltrane/renderers/text_renderer/theory_scale_drawer.rb +13 -0
  35. data/lib/coltrane/renderers/text_renderer/theory_scale_set_drawer.rb +27 -0
  36. data/lib/coltrane/representation.rb +12 -0
  37. data/lib/coltrane/representation/guitar.rb +34 -0
  38. data/lib/coltrane/representation/guitar/chord.rb +180 -0
  39. data/lib/coltrane/representation/guitar/note.rb +26 -0
  40. data/lib/coltrane/representation/guitar/note_set.rb +35 -0
  41. data/lib/coltrane/representation/guitar/string.rb +31 -0
  42. data/lib/coltrane/representation/guitar_like_instruments.rb +21 -0
  43. data/lib/coltrane/representation/piano.rb +36 -0
  44. data/lib/coltrane/representation/piano/note_set.rb +22 -0
  45. data/lib/{coltrane_synth.rb → coltrane/synth.rb.rb} +0 -0
  46. data/lib/{coltrane_synth → coltrane/synth}/base.rb +0 -0
  47. data/lib/{coltrane_synth → coltrane/synth}/synth.rb +0 -0
  48. data/lib/coltrane/theory.rb +54 -0
  49. data/lib/coltrane/theory/cadence.rb +9 -0
  50. data/lib/coltrane/{changes.rb → theory/changes.rb} +0 -0
  51. data/lib/coltrane/theory/chord.rb +101 -0
  52. data/lib/coltrane/theory/chord_quality.rb +113 -0
  53. data/lib/coltrane/theory/chord_substitutions.rb +11 -0
  54. data/lib/coltrane/theory/circle_of_fifths.rb +33 -0
  55. data/lib/coltrane/theory/classic_scales.rb +113 -0
  56. data/lib/coltrane/theory/diatonic_scale.rb +38 -0
  57. data/lib/coltrane/theory/errors.rb +97 -0
  58. data/lib/coltrane/theory/frequency.rb +52 -0
  59. data/lib/coltrane/theory/frequency_interval.rb +83 -0
  60. data/lib/coltrane/theory/interval.rb +209 -0
  61. data/lib/coltrane/theory/interval_class.rb +212 -0
  62. data/lib/coltrane/theory/interval_sequence.rb +157 -0
  63. data/lib/coltrane/theory/key.rb +18 -0
  64. data/lib/coltrane/{mode.rb → theory/mode.rb} +0 -0
  65. data/lib/coltrane/theory/notable_progressions.rb +30 -0
  66. data/lib/coltrane/theory/note.rb +104 -0
  67. data/lib/coltrane/theory/note_set.rb +101 -0
  68. data/lib/coltrane/theory/pitch.rb +94 -0
  69. data/lib/coltrane/theory/pitch_class.rb +154 -0
  70. data/lib/coltrane/theory/progression.rb +81 -0
  71. data/lib/coltrane/theory/progression_set.rb +18 -0
  72. data/lib/coltrane/{qualities.rb → theory/qualities.rb} +0 -0
  73. data/lib/coltrane/theory/roman_chord.rb +114 -0
  74. data/lib/coltrane/theory/scale.rb +161 -0
  75. data/lib/coltrane/theory/scale_search_result.rb +6 -0
  76. data/lib/coltrane/theory/scale_set.rb +40 -0
  77. data/lib/coltrane/theory/voicing.rb +41 -0
  78. data/lib/coltrane/version.rb +1 -1
  79. metadata +88 -63
  80. data/bin/rails +0 -17
  81. data/data/qualities.yml +0 -83
  82. data/db/cache.sqlite3 +0 -0
  83. data/db/cache_test.sqlite3 +0 -0
  84. data/db/config.yml +0 -11
  85. data/lib/cli.rb +0 -24
  86. data/lib/cli/bass_guitar.rb +0 -12
  87. data/lib/cli/chord.rb +0 -39
  88. data/lib/cli/config.rb +0 -39
  89. data/lib/cli/errors.rb +0 -46
  90. data/lib/cli/guitar.rb +0 -67
  91. data/lib/cli/guitar_chords.rb +0 -122
  92. data/lib/cli/notes.rb +0 -20
  93. data/lib/cli/piano.rb +0 -57
  94. data/lib/cli/scale.rb +0 -53
  95. data/lib/cli/text.rb +0 -16
  96. data/lib/cli/ukulele.rb +0 -14
  97. data/lib/coltrane/cache.rb +0 -43
  98. data/lib/coltrane/cadence.rb +0 -7
  99. data/lib/coltrane/chord.rb +0 -89
  100. data/lib/coltrane/chord_quality.rb +0 -111
  101. data/lib/coltrane/chord_substitutions.rb +0 -9
  102. data/lib/coltrane/circle_of_fifths.rb +0 -31
  103. data/lib/coltrane/classic_scales.rb +0 -94
  104. data/lib/coltrane/diatonic_scale.rb +0 -36
  105. data/lib/coltrane/errors.rb +0 -95
  106. data/lib/coltrane/frequency.rb +0 -50
  107. data/lib/coltrane/frequency_interval.rb +0 -81
  108. data/lib/coltrane/interval.rb +0 -208
  109. data/lib/coltrane/interval_class.rb +0 -210
  110. data/lib/coltrane/interval_sequence.rb +0 -155
  111. data/lib/coltrane/key.rb +0 -16
  112. data/lib/coltrane/notable_progressions.rb +0 -28
  113. data/lib/coltrane/note.rb +0 -98
  114. data/lib/coltrane/note_set.rb +0 -89
  115. data/lib/coltrane/pitch.rb +0 -92
  116. data/lib/coltrane/pitch_class.rb +0 -148
  117. data/lib/coltrane/progression.rb +0 -74
  118. data/lib/coltrane/roman_chord.rb +0 -112
  119. data/lib/coltrane/scale.rb +0 -154
  120. data/lib/coltrane/unordered_interval_class.rb +0 -7
  121. data/lib/coltrane/voicing.rb +0 -39
  122. data/lib/coltrane_game/question.rb +0 -7
  123. data/lib/coltrane_instruments.rb +0 -7
  124. data/lib/coltrane_instruments/guitar.rb +0 -10
  125. data/lib/coltrane_instruments/guitar/base.rb +0 -29
  126. data/lib/coltrane_instruments/guitar/chord.rb +0 -170
  127. data/lib/coltrane_instruments/guitar/note.rb +0 -24
  128. data/lib/coltrane_instruments/guitar/string.rb +0 -29
  129. data/lib/os.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73fefa27f1153e68849f503990c62b0f37d66a58f5979b6c8eca4292166ece20
4
- data.tar.gz: f83f2490b0402555ef13f7d04790c4982e7e7f8274fcfd9f4290e497d357b3ed
3
+ metadata.gz: 7b31feba198134bfc6fb460384f54e2ab64673195da1d8a49387b0330992d684
4
+ data.tar.gz: 0185a37862223cf82da552d1b93ba2b0423044cf788956fc2c3d66a8cc9cb19a
5
5
  SHA512:
6
- metadata.gz: 3aec21519141e0e6fd73a5bec77acbbc510cde319b16d1f6544a3fa256bb78d858dfa2525e049cd40b4d7f4acb5c480963906dd3aada7d3f6539f3ed5a14b7d1
7
- data.tar.gz: 2ded1ec625ec59cc2cfb519128806b45b9e953ef123bb1822268a7a74f87b83e66027d0771e5e1bbf5c7ce26e1d63b6e901725cc68df71b0404378082de83265
6
+ metadata.gz: ecdcbace2c6c7cf71c39acec0768728ac92fc46250310fecb046309e5b97a12b6f2f3c987be29a0a72e88e3c72781a3e867b56a781159db11d62f6110fb16a85
7
+ data.tar.gz: 3ddfd6129273dc69b6e20a176129cb86d079735ad47cdcb98a5b16c6706d12ea29414a834c0a488be1273b7dc73d3328416b2575064a6870c47a737a1086c9c7
data/.travis.yml CHANGED
@@ -1,10 +1,25 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=ef9987fd97eefaf4017a8b88e063e9376b408e93b170ad4610c8fce4370f4be2
4
+
1
5
  language: ruby
2
6
  git:
3
7
  depth: 1
8
+
4
9
  rvm:
5
10
  - 2.5.0
11
+
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
16
+
6
17
  script:
7
18
  - bin/rspec spec
19
+
20
+ after_script:
21
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
22
+
8
23
  deploy:
9
24
  provider: rubygems
10
25
  api_key:
@@ -14,4 +29,4 @@ deploy:
14
29
  repo: pedrozath/coltrane
15
30
  notifications:
16
31
  slack:
17
- secure: A4qliXrG8AgvMi9skLwfTfGgRxeVRBIBS8O6tIF2k0oLn+i0XRCEPWYnK4Xa1YufgCnMTFlGA144sxsvuf3spBuwCJkOefA7YhJJVhKQTCpmkSq0IPEaF8+KpwESI1W1hBJuEWmCAxwL1Z+tZa7CON2ELyKgHukxEtUTfQsbXMY1eeISRm7a73xi4DlfTM4UEV2Cfd/Rg9cpP4QGsWANowDsaNm33aQ611BIokfVSZtKf7A4IPAthZOrXkGqD0R4FjUxbDUtQEd5gg3tpcPmWrHIxunlvJow/XBXtv+/qDlbo8LzUUxtkElcGjj1g3hsQEZmevoNxZdGW/8/F5DMMLYYQRfph7Ot9Xm6dNYj3rIUcHjNob1qUNb0ON2pko4gcO6HiU8VZ/oQUsUtBBrB7ddf1htXVdO3jHH2josFTCWgFCzPwgxsCuyP71lieDBolyaKFOyWGaWj6cZhqGUfkSosLZNyDoUEWERkImOHyqvi5TQaPVteZvUeCDkD6ZtCTyEjZI8zXdyPKKweBLxRuGMjUgpsA5QEyo3dlIguLe7OYCLWyYYmEcF+2QjYLevEBFNM1rl6tK8VEF6aost0pa6Rq6/VHRNEEKn0ejYTqbiPGljmOiDOwWSCxQWhlJ9tw692wnpLN5/y0Cda40PQ87hi1tXyvcvLrrvETfYfXcU=
32
+ secure: Z1DrNRL47BvEB/PWyb+EsVlAwVsGapytLGCiyQeTlNBTK7iCfP3N57fkVZDyaMYWJ7oweCk16aTBxljnP6SPNaqQhKWilDXiwnX9s3uWxz06ONgg8TE46hGyplD5fmt/liIxQ/XeJoCA8C6qWJRAc94Y0b42yK23eFbCU3632ISt1wVwipOcuAyCD0TTjQUHRjWT4Zbg6gqytG+U3rsx2+wGUDbu2Nu5r6C90uU0vbmHyhcmf2S7V7is7Kpc24aDhPhBBrP44uWXLEXh8Hgthca95jVm2CoL2GVK+f6W/mAkQugkg0Rz//d8+9M5SJcHQiUBwNIXxfgEQKkVFSuiMcySdG0RFBh9dyPPem3AUWEO9HwNlF+juMkwP+Wavj9eoN3cWNeVJrT00mXaTzmPdxFKxvRKp/NSJQIKI7dzg74oggyzu5BSmTlth2YGgNzEhKbAjOGL+B2ClE5KeR4ZIUsEH7Z/KAoHH4EPERYqec+aSsbLuoAAQiuRIqul+MyZiz0ox/kA1hFVndbDg7avxqZUzBSBZ7f9nMzKxQeUGSJYS3f5XWYpIDCxEiub5LiLMkltaM2AGAzZfFhLYEC96J/HoyF7xxHZNWbEJiv+bLuQGcD8BUCTNfRZM15nQbaKNBpyx/lC0h4kRAGnaGAnfGYCuKHjHPWsSAc8jcmW3Bw=
data/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@
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.0.0]
9
+
10
+ ### Changes
11
+
12
+ - This is a huge architectural refactor. Hopefully the last big one. All code were redivided into the modules:
13
+
14
+ 1. Coltrane::Theory concentrates all music theory logic
15
+ 2. Coltrane::Representation contain musical instruments and any other needed musical-related abstract representations.
16
+ 3. Coltrane::Renderers right now contains the TextRenderer which has the ability of rendering Theory Objects, Representation Objects, etc
17
+ 4. Coltrane::Commands are ways of fetching Theory and Representation objects. They also glue Mercenary (the gem used for the CLI) into everything else.
18
+
8
19
  ## [2.2.0]
9
20
 
10
21
  - Intervals were completely refactored according to [#11](https://github.com/pedrozath/coltrane/issues/11) and (https://github.com/pedrozath/coltrane/issues/12). Thanks [@art-of-dom](https://github.com/art-of-dom) for the valuable information. We now have new interval classes and new ways on how to deal with them.
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coltrane (2.2.1)
4
+ coltrane (3.0.0.pre)
5
5
  color (~> 1.8)
6
6
  dry-monads (~> 0.4)
7
- paint (~> 2.0)
7
+ paint (~> 2.0.1)
8
8
  pedrozath-mercenary (~> 0.3)
9
+ tty-prompt (~> 0.16.0)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -25,12 +26,14 @@ GEM
25
26
  dry-monads (0.4.0)
26
27
  dry-core (~> 0.3, >= 0.3.3)
27
28
  dry-equalizer
29
+ equatable (0.5.0)
28
30
  faraday (0.14.0)
29
31
  multipart-post (>= 1.2, < 3)
30
32
  gitlab (3.6.1)
31
33
  httparty
32
34
  terminal-table
33
35
  hike (1.2.3)
36
+ hitimes (1.2.6)
34
37
  httparty (0.16.1)
35
38
  multi_xml (>= 0.5.2)
36
39
  interception (0.5)
@@ -38,6 +41,7 @@ GEM
38
41
  method_source (0.9.0)
39
42
  multi_xml (0.6.0)
40
43
  multipart-post (2.0.0)
44
+ necromancer (0.4.0)
41
45
  octokit (4.8.0)
42
46
  sawyer (~> 0.8.0, >= 0.5.3)
43
47
  opal (0.10.5)
@@ -51,6 +55,9 @@ GEM
51
55
  parallel (1.12.1)
52
56
  parser (2.4.0.2)
53
57
  ast (~> 2.3)
58
+ pastel (0.7.2)
59
+ equatable (~> 0.5.0)
60
+ tty-color (~> 0.4.0)
54
61
  pedrozath-mercenary (0.3.6)
55
62
  powerpack (0.1.1)
56
63
  pronto (0.6.0)
@@ -112,7 +119,23 @@ GEM
112
119
  unicode-display_width (~> 1.1, >= 1.1.1)
113
120
  thor (0.19.4)
114
121
  tilt (2.0.8)
122
+ timers (4.1.2)
123
+ hitimes
124
+ tty-color (0.4.2)
125
+ tty-cursor (0.5.0)
126
+ tty-prompt (0.16.0)
127
+ necromancer (~> 0.4.0)
128
+ pastel (~> 0.7.0)
129
+ timers (~> 4.0)
130
+ tty-cursor (~> 0.5.0)
131
+ tty-reader (~> 0.2.0)
132
+ tty-reader (0.2.0)
133
+ tty-cursor (~> 0.5.0)
134
+ tty-screen (~> 0.6.4)
135
+ wisper (~> 2.0.0)
136
+ tty-screen (0.6.4)
115
137
  unicode-display_width (1.3.0)
138
+ wisper (2.0.0)
116
139
 
117
140
  PLATFORMS
118
141
  ruby
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  [![Build Status](https://travis-ci.org/pedrozath/coltrane.svg?branch=master)](https://travis-ci.org/pedrozath/coltrane)
2
+ [![Gem Version](https://badge.fury.io/rb/coltrane.svg)](https://badge.fury.io/rb/coltrane)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/pedrozath/coltrane/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/test_coverage)](https://codeclimate.com/github/pedrozath/coltrane/test_coverage)
2
5
 
3
6
  # Coltrane
4
7
 
data/bin/console CHANGED
@@ -3,10 +3,14 @@ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
3
3
 
4
4
  require "bundler/setup"
5
5
  require "coltrane"
6
- require "coltrane_instruments"
7
- # require "coltrane_synth"
6
+ require "coltrane/representation"
7
+ require "coltrane/renderers"
8
8
 
9
9
  require "pry"
10
10
 
11
11
  include Coltrane
12
+ include Coltrane::Theory
13
+ include Coltrane::Representation
14
+ include Coltrane::Renderers
15
+
12
16
  Pry.start
data/coltrane.gemspec CHANGED
@@ -32,8 +32,9 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
34
34
 
35
+ spec.add_runtime_dependency 'tty-prompt', '~> 0.16.0'
35
36
  spec.add_runtime_dependency 'dry-monads', '~> 0.4'
36
- spec.add_runtime_dependency 'paint', '~> 2.0'
37
+ spec.add_runtime_dependency 'paint', '~> 2.0.1'
37
38
  spec.add_runtime_dependency 'color', '~> 1.8'
38
39
  spec.add_runtime_dependency 'pedrozath-mercenary', '~> 0.3'
39
40
  spec.add_development_dependency "bundler", '~> 1.14'
data/exe/coltrane CHANGED
@@ -1,20 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # rubocop:disable Metrics/BlockLength
5
-
6
4
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
7
5
 
8
- require 'cli'
9
-
10
- full_color_terminals = %w[iTerm.app]
11
- safe_mode_terminals = %w[Unsupported]
6
+ require 'paint'
7
+ require 'color'
8
+ require 'mercenary'
9
+ require 'coltrane/commands'
10
+ require 'pry'
12
11
 
13
- if full_color_terminals.include?(ENV['TERM_PROGRAM'])
14
- Paint.mode = 0xFFFFFF
15
- elsif safe_mode_terminals.include?(ENV['TERM_PROGRAM'])
16
- Paint.mode = 0
17
- end
12
+ Paint.mode = 0xFFFFFF
18
13
 
19
14
  Mercenary.program(:Coltrane) do |p|
20
15
  p.version Coltrane::VERSION
@@ -22,226 +17,21 @@ Mercenary.program(:Coltrane) do |p|
22
17
  A music querying interface
23
18
  by Pedro Maciel (pedro@pedromaciel.com)
24
19
 
25
- Check the chat room for project discussion/help: https://gitter.im/coltrane-music/Lobby
20
+ Check the chat room for project help/discussion/contribution: https://coltrane-ruby.herokuapp.com
26
21
  DESC
27
22
  p.syntax 'coltrane <subcommand> [options]'
28
23
 
29
- @instrument_option = [
30
- :on,
31
- '--on guitar INSTRUMENT',
32
- 'Shows the notes on the given instrument/representation type. Can be piano, guitar, ukulele, bass or text'
33
- ]
34
-
35
- @flavor_option = [
36
- :flavor,
37
- '--flavor FLAVOR',
38
- 'Chooses which additional information to display: marks, notes, intervals or degrees'
39
- ]
40
-
41
- @sound_option = [
42
- :sound,
43
- '--sound',
44
- 'beta/macOS only: plays the sound of related notes/chords'
45
- ]
46
-
47
- p.command(:note) do |c|
48
- c.alias(:notes)
49
- c.syntax 'notes <notes separated by space> [--on <instrument>]'
50
- c.description 'Shows the given notes.'
51
- c.option(*@instrument_option)
52
- c.option(*@flavor_option)
53
- c.option(*@sound_option)
54
- c.action do |(notes), on: 'text', flavor: 'notes'|
55
- Coltrane::Cli.config do |c|
56
- c.on = on.to_sym
57
- c.flavor = flavor.to_sym
58
- end
59
-
60
- raise 'Provide some notes. Ex: coltrane notes C-D-Gb' if notes.empty?
61
- notes = Coltrane::NoteSet[*notes.split('-')]
62
- Coltrane::Cli::Notes.new(notes)
63
- end
64
- end
65
-
66
- p.command(:chord) do |c|
67
- c.alias(:chords)
68
- c.syntax 'chord <chord-name> [--on <instrument>]'
69
- c.description 'Shows the given chord. Ex: coltrane chord Cmaj7 --on piano'
70
- c.option(*@instrument_option)
71
- c.option(*@flavor_option)
72
- c.option(*@sound_option)
73
- c.option :notes, '--notes C-D-E', 'finds chords with those notes, provided they are separated by dashes'
74
- c.action do |(chords), notes: nil, on: 'text', flavor: 'notes', sound: nil|
75
- Coltrane::Cli.config do |c|
76
- c.on = on.to_sym
77
- c.flavor = flavor.to_sym
78
- c.sound = sound
79
- end
80
-
81
- chords = chords&.split('-')
82
- Coltrane::Cli::Chord.new(*chords, notes: notes&.split('-'))
83
- end
84
- end
85
-
86
- p.command(:scale) do |c|
87
- c.syntax 'scale <name of scale>-<root note> [--on <instrument>]'
88
- c.description 'Gives you information about a scale. Ex: coltrane scale natural-minor-Db --on guitar'
89
- c.option(*@instrument_option)
90
- c.option(*@flavor_option)
91
- c.option(*@sound_option)
92
- c.option :triads, '--triads', 'Outputs triads from the scale'
93
- c.option :sevenths, '--sevenths', 'Outputs seventh chords from the scale'
94
- c.option :pentads, '--pentads', 'Outputs pentad chords from the scale'
95
- c.option :tertians, '--tertians SIZE', 'Outputs all tertian chords from the given size from the scale'
96
- c.option :chords, '--chords [SIZE]', 'Outputs all chords from given size from the scale. Leave size empty to retrieve all'
97
- c.action do |(scale_str), flavor: 'degrees', on: 'text', sound: false, **options|
98
- Coltrane::Cli.config do |c|
99
- c.on = on.to_sym
100
- c.flavor = flavor.to_sym
101
- c.sound = sound
102
- end
103
-
104
- scale = Coltrane::Cli::Scale.parse(scale_str)
105
- if options.include?(:triads)
106
- chords = scale.triads
107
- Coltrane::Cli::Chord.new(*chords, **keyword_args)
108
- elsif options.include?(:sevenths)
109
- chords = scale.sevenths
110
- Coltrane::Cli::Chord.new(*chords, **keyword_args)
111
- elsif options.include?(:pentads)
112
- chords = scale.pentads
113
- Coltrane::Cli::Chord.new(*chords, **keyword_args)
114
- elsif options.include?(:tertians)
115
- chords = scale.tertians(options[:tertians].to_i)
116
- Coltrane::Cli::Chord.new(*chords, **keyword_args)
117
- elsif options.include?(:chords)
118
- chords = if options[:chords].nil?
119
- scale.all_chords
120
- else
121
- scale.chords(options[:chords])
122
- end
123
- Coltrane::Cli::Chord.new(*chords)
124
- else
125
- Coltrane::Cli::Scale.new(scale)
126
- end
127
- end
128
- end
129
-
130
- p.command(:progression) do |c|
131
- c.syntax 'progression <roman numeral notation> in <key> [--on <instrument>]'
132
- c.description 'Gives you chords of a progression in a key. Ex: coltrane progression I-IV-iv-V in Am --on guitar'
133
- c.option(*@instrument_option)
134
- c.option(*@flavor_option)
135
- c.option(*@sound_option)
136
- c.action do |(prog, _, key), on: 'text', flavor: 'notes', sound: nil|
137
- Coltrane::Cli.config do |c|
138
- c.on = on.symbolize
139
- c.flavor = flavor.symbolize
140
- c.sound = sound
141
- end
142
-
143
- possible_method = prog.tr('-', '_')
144
- progression = if Coltrane::Progression.respond_to?(possible_method)
145
- Coltrane::Progression.send(possible_method, key)
146
- else
147
- Coltrane::Progression.new(prog, key: key)
148
- end
149
-
150
- Coltrane::Cli::Chord.new(*progression.chords)
151
- end
24
+ Coltrane::Commands::Command.subclasses.each do |command|
25
+ command.mercenary_init(p)
152
26
  end
153
27
 
154
- p.command(:'find-progression') do |c|
155
- c.syntax 'find-progression <list of chords>'
156
- c.description 'Find progressions in scales. Ex: coltrane find-progression AM-DM-F#m-EM'
157
- c.action do |(chord_notation)|
158
- progressions = Coltrane::Progression.find(*chord_notation.split('-'))
159
- notation_width = progressions.map(&:notation).map(&:size).max
160
- progressions.each do |progression|
161
- puts "#{progression.notation.ljust(notation_width + 1, ' ')} in #{progression.scale} (#{progression.notes_out.size} notes out)"
162
- end
28
+ p.command(:about) do |c|
29
+ c.description 'Shows this screen'
30
+ c.action do
31
+ puts p
163
32
  end
164
33
  end
165
34
 
166
- p.command(:list) do |list|
167
- list.syntax 'list [scales, flavors, instruments (used in --on options), chord-qualities]'
168
- list.description 'List information.'
169
- list.action do |(arg)|
170
- puts case arg
171
- when 'scales' then Coltrane::Scale.known_scales
172
- when 'flavors' then %w[marks notes intervals degrees]
173
- when 'instruments' then %w[guitar bass ukulele piano text]
174
- when 'chords', 'chord-qualities' then Coltrane::ChordQuality.intervals_per_name.keys.join(' ')
175
- end
176
- end
177
- end
178
-
179
- p.command(:'find-scale') do |c|
180
- c.syntax 'find-scale --notes C-D-E-...] OR --chord Cmaj7-Db7'
181
- c.description 'finds scales with the provided --notes or --chord'
182
- c.option :notes, '--notes C-D-E', 'Find scales with those notes'
183
- c.option :chords, '--chords Cmaj7-D11', 'find scales with those chords'
184
- c.action do |(_arg), options|
185
- options[:notes] = (options[:notes]).to_s.split('-')
186
- options[:chords] = (options[:chords]).to_s.split('-')
187
- Coltrane::Cli::Scale.find(**options)
188
- end
189
- end
190
-
191
- p.command(:'common-chords') do |c|
192
- c.syntax 'common-chords <SCALE1 SCALE2 [SCALE3]>'
193
- c.description 'Finds chords that are shared between the given scales'
194
- c.option(*@instrument_option)
195
- c.option(*@flavor_option)
196
- c.action do |(*scale_strings), on: 'text', flavor: 'notes'|
197
- raise 'Provide at least 2 scales' if scale_strings.size < 2
198
- first_scale_str, *other_scales_strs = scale_strings
199
- first_scale = Coltrane::Cli::Scale.parse(first_scale_str)
200
- chords = other_scales_strs.reduce(first_scale.all_chords.map(&:name)) do |memo, scale_str|
201
- scale = Coltrane::Cli::Scale.parse(scale_str)
202
- memo & scale.all_chords.map(&:name)
203
- end
204
- raise 'No common chords were found' if chords.empty?
205
- Coltrane::Cli::Chord.new(*chords)
206
- end
207
- end
208
-
209
- p.command(:help) do |c|
210
- c.description 'May give you some help.'
211
- c.syntax 'help <command> [subcommand, sub-subcommand, ...]'
212
- c.action do |(*command_path), _options|
213
- if command_path.empty?
214
- puts p
215
- else
216
- puts begin
217
- command_path.reduce(p) do |memo, key|
218
- memo.commands.delete(key.to_sym)
219
- end || "\n Sorry, command found."
220
- end
221
- end
222
- end
223
- end
224
-
225
- # p.command(:start) do |c|
226
- # c.description 'Starts interactive mode'
227
- # c.action do
228
- # begin
229
- # Coltrane::Cli.erase_config
230
- # puts "\n"
231
- # print Paint['coltrane ', '#F88550']
232
- # cmd = gets.chomp
233
- # return if %w[exit exit q quit stop].include?(cmd)
234
- # puts "\n"
235
- # p.go(cmd.split(' '))
236
- # rescue Exception
237
- # ensure
238
- # p.instance_variable_set :'@config', {}
239
- # end
240
- # p.execute(['start'], {})
241
- # end
242
- # end
243
-
244
- # p.default_command(:start)
35
+ p.default_command(:about)
245
36
  end
246
37
 
247
- # rubocop:enable Metrics/BlockLength
data/lib/coltrane.rb CHANGED
@@ -1,58 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'coltrane/version'
4
+
3
5
  require 'json'
4
6
  require 'forwardable'
5
7
  require 'core_ext'
6
8
  require 'ostruct'
7
9
  require 'dry-monads'
8
10
 
9
- # The main module for working with Music Theory
10
- module Coltrane
11
- autoload :Frequency, 'coltrane/frequency'
12
-
13
- BASE_OCTAVE = 4
14
- BASE_PITCH_INTEGER = 9
15
-
16
- def self.tuning=(f)
17
- @base_tuning = Frequency[f].octave(-4)
18
- end
19
-
20
- def self.base_tuning
21
- @base_tuning
22
- end
23
-
24
- @base_tuning = Frequency[440].octave(-4)
25
-
26
- require 'coltrane/version'
27
- require 'coltrane/errors'
28
-
29
- autoload :Pitch, 'coltrane/pitch'
30
- autoload :Voicing, 'coltrane/voicing'
31
-
32
- autoload :PitchClass, 'coltrane/pitch_class'
33
- autoload :Note, 'coltrane/note'
34
- autoload :NoteSet, 'coltrane/note_set'
35
-
36
- autoload :FrequencyInterval, 'coltrane/frequency_interval'
37
- autoload :IntervalClass, 'coltrane/interval_class'
38
- autoload :Interval, 'coltrane/interval'
39
- autoload :UnorderedIntervalClass, 'coltrane/unordered_interval_class'
40
- autoload :IntervalSequence, 'coltrane/interval_sequence'
41
- autoload :Qualities, 'coltrane/qualities'
42
- autoload :ChordQuality, 'coltrane/chord_quality'
43
- autoload :Chord, 'coltrane/chord'
44
- autoload :ChordSubstitutions, 'coltrane/chord_substitutions'
45
- autoload :RomanChord, 'coltrane/roman_chord'
46
-
47
- autoload :ClassicScales, 'coltrane/classic_scales'
48
- autoload :Scale, 'coltrane/scale'
49
- autoload :CircleOfFifths, 'coltrane/circle_of_fifths'
50
- autoload :DiatonicScale, 'coltrane/diatonic_scale'
51
- autoload :Key, 'coltrane/key'
52
-
53
- autoload :NotableProgressions, 'coltrane/notable_progressions'
54
- autoload :Changes, 'coltrane/changes'
55
- autoload :Cadence, 'coltrane/cadence'
56
- autoload :Progression, 'coltrane/progression'
57
- autoload :Mode, 'coltrane/mode'
58
- end
11
+ require 'coltrane/theory'