note-transpose 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -0
- data/bin/note-transpose +3 -1
- data/lib/note-transpose.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34d45237ed688088cea474edda1664dd711f07ef1faef0de6b7d43fedb5c8935
|
4
|
+
data.tar.gz: 5e6f510857dafd65c8df058b9c58dcd6a9ab9e1c7e07a4c3f7dacfc04b509448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f514f4d0e3a5e9a470247c095c2d888d14e2aebbab59cf533e9a7da8d236cce68cacb51bb6d2c60c03d0c713d4750adb579f5c376c766c8915bbd14ea760bff
|
7
|
+
data.tar.gz: 90d79c48f039580910e7251f0383781dec1811057ef40cc5754e5b5f6c7368c94e3a2cb5483d974a7e598a63f8ec941e872ccfac2c55e7ce1b624ce7f3efbac5
|
data/README.md
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Note Transpose
|
2
|
+
|
3
|
+
A CLI tool to transpose notes by half steps
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [Install](#install)
|
8
|
+
- [Usage](#usage)
|
9
|
+
- [Support](#support)
|
10
|
+
- [Contributing](#contributing)
|
11
|
+
|
12
|
+
## Install
|
13
|
+
|
14
|
+
❯ gem install note-transpose
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
❯ note-transpose --help
|
19
|
+
|
20
|
+
Usage: note-transpose [-]<number half steps> <notes> [--pref-flat]
|
21
|
+
--pref-flat Always uses flat notes in output instead of sharp ones
|
22
|
+
|
23
|
+
Examples:
|
24
|
+
❯ note-transpose +1 C G F Am
|
25
|
+
=> Db Ab Gb Bbm
|
26
|
+
|
27
|
+
❯ note-transpose 2 C G F Am
|
28
|
+
=> D A G Bm
|
29
|
+
|
30
|
+
❯ note-transpose -2 D# G7 F Am7 Cadd7
|
31
|
+
=> C# F7 Eb Gm7 Bbadd7
|
32
|
+
|
33
|
+
❯ note-transpose -2 D# G7 F Am7 Cadd7 --pref-flat
|
34
|
+
=> Db F7 Eb Gm7 Bbadd7
|
35
|
+
|
36
|
+
You can even include the module in your code if you need that for some reason:
|
37
|
+
|
38
|
+
require 'note-transpose'
|
39
|
+
|
40
|
+
NoteTranspose.transpose(-3, "C", "F", "Am", "G")
|
41
|
+
# => ["A", "D", "Gbm", "E"]
|
42
|
+
|
43
|
+
## Support
|
44
|
+
|
45
|
+
Please [open an issue](https://github.com/vyder/note-transpose/issues/new) for support.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Please contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/vyder/note-transpose/compare/).
|
data/bin/note-transpose
CHANGED
@@ -37,7 +37,9 @@ end
|
|
37
37
|
|
38
38
|
pref_flat = !input.delete(PREF_FLAT_OPT).nil?
|
39
39
|
|
40
|
+
result = NoteTranspose.transpose(half_steps, input, pref_flat: pref_flat)
|
41
|
+
|
40
42
|
puts <<EOF
|
41
43
|
|
42
|
-
=> #{
|
44
|
+
=> #{result.join(' ')}
|
43
45
|
EOF
|
data/lib/note-transpose.rb
CHANGED
@@ -34,7 +34,7 @@ module NoteTranspose
|
|
34
34
|
note.downcase!
|
35
35
|
begin
|
36
36
|
m = note.match /^[a-g](#|b)?/
|
37
|
-
actual_note = m[0]
|
37
|
+
actual_note = m[0]
|
38
38
|
|
39
39
|
index = NOTES[:flat].find_index(actual_note)
|
40
40
|
|
@@ -57,14 +57,13 @@ module NoteTranspose
|
|
57
57
|
transposed_note = source[index]
|
58
58
|
end
|
59
59
|
|
60
|
-
transposed_notes << note.gsub(actual_note
|
60
|
+
transposed_notes << note.gsub(actual_note, transposed_note).capitalize
|
61
61
|
rescue
|
62
62
|
puts "'#{note.capitalize}' is not a valid note!"
|
63
63
|
exit 1
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
transposed_notes.join ' '
|
67
|
+
transposed_notes
|
69
68
|
end
|
70
69
|
end
|