trriad 0.0.1 → 0.0.2.19
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.
- data/History.txt +13 -0
- data/Manifest.txt +2 -0
- data/README.txt +2 -0
- data/Rakefile +2 -2
- data/lib/trriad.rb +1 -0
- data/lib/trriad/chord.rb +33 -60
- data/lib/trriad/chord_data.rb +53 -0
- data/lib/trriad/core_ext.rb +1 -0
- data/lib/trriad/core_ext/string/chord.rb +6 -0
- data/lib/trriad/version.rb +1 -1
- data/spec/trriad_spec.rb +13 -0
- data/website/index.txt +13 -2
- data/website/template.rhtml +6 -1
- data/website/todo.txt +7 -0
- metadata +5 -2
data/History.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== 0.0.2.x 2007-xx-xx
|
2
|
+
|
3
|
+
* add "<key>".scale support, you can now do
|
4
|
+
"Bb".scale and get ["Bb", "C", "D", "Eb", "F", "G", "A"]
|
5
|
+
* add declarations for the following chord types:
|
6
|
+
maj,6,m6,maj7,m7,dim,+,9,7+5,7b5,m7b5,m9,9+5,9b5,
|
7
|
+
maj9,6add9,7b9,7sus4,7add6,11,11+,11b9,13 and 13b9
|
8
|
+
(m and 7 were already present in 0.0.1)
|
9
|
+
* documentation updates
|
10
|
+
* more code comments
|
11
|
+
* website
|
12
|
+
* readme
|
13
|
+
|
1
14
|
== 0.0.1 2007-05-30
|
2
15
|
|
3
16
|
* 1 major enhancement:
|
data/Manifest.txt
CHANGED
@@ -5,6 +5,7 @@ README.txt
|
|
5
5
|
Rakefile
|
6
6
|
lib/trriad.rb
|
7
7
|
lib/trriad/chord.rb
|
8
|
+
lib/trriad/chord_data.rb
|
8
9
|
lib/trriad/core_ext.rb
|
9
10
|
lib/trriad/core_ext/string.rb
|
10
11
|
lib/trriad/core_ext/string/chord.rb
|
@@ -18,3 +19,4 @@ website/index.txt
|
|
18
19
|
website/javascripts/rounded_corners_lite.inc.js
|
19
20
|
website/stylesheets/screen.css
|
20
21
|
website/template.rhtml
|
22
|
+
website/todo.txt
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -47,9 +47,9 @@ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
|
47
47
|
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
48
48
|
|
49
49
|
NAME = "trriad"
|
50
|
-
REV = nil
|
50
|
+
#REV = nil
|
51
51
|
# UNCOMMENT IF REQUIRED:
|
52
|
-
|
52
|
+
REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
53
53
|
VERS = Trriad::VERSION::STRING + (REV ? ".#{REV}" : "")
|
54
54
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
|
55
55
|
RDOC_OPTS = ['--quiet', '--title', 'trriad documentation',
|
data/lib/trriad.rb
CHANGED
data/lib/trriad/chord.rb
CHANGED
@@ -1,69 +1,42 @@
|
|
1
1
|
module Trriad
|
2
2
|
module Chord
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
NOTESFLAT = "C,Db,D,Eb,E,F,Gb,G,Ab,A,Bb,B".split(",")
|
11
|
-
|
12
|
-
DISTANCES = "2,2,1,2,2,2,1".split(",")
|
13
|
-
|
14
|
-
SHARPS = "G,D,A,E,F,C".split(",")
|
15
|
-
FLATS = "Bb,Eb,Ab,Db,Gb,Cb,Fb".split(",")
|
16
|
-
|
17
|
-
#puts CHORDS
|
18
|
-
#puts CHORDS["m"]
|
19
|
-
|
20
|
-
def self.valid_note(note)
|
21
|
-
NOTESSHARP.include?(note) ? true :
|
22
|
-
NOTESFLAT.include?(note) ? true :
|
23
|
-
false
|
24
|
-
end
|
25
|
-
|
26
|
-
def next_semi(root)
|
27
|
-
if NOTESSHARP.include?(root) then
|
28
|
-
at=NOTESSHARP.index(root)
|
29
|
-
tmp=NOTESSHARP + NOTESSHARP
|
30
|
-
at+=1
|
31
|
-
tmp[at]
|
32
|
-
else
|
33
|
-
if NOTESFLAT.include?(root) then
|
34
|
-
at=NOTESFLAT.index(root)
|
35
|
-
at+=1
|
36
|
-
NOTESFLAT[at]
|
4
|
+
# check if it's a valid note
|
5
|
+
# returns true of false
|
6
|
+
def self.valid_note(note)
|
7
|
+
NOTES[:sharp].include?(note) ? true :
|
8
|
+
NOTES[:flat].include?(note) ? true :
|
9
|
+
false
|
37
10
|
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_toonladder(root)
|
42
|
-
result="#{root}"
|
43
|
-
cur=root
|
44
|
-
DISTANCES.each { |distance|
|
45
|
-
1.upto(distance.to_i) {
|
46
|
-
cur=next_semi(cur)
|
47
|
-
}
|
48
|
-
result += ",#{cur}"
|
49
|
-
}
|
50
|
-
result
|
51
|
-
end
|
52
11
|
|
53
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
12
|
+
# get the next semi note
|
13
|
+
# return the note as a string
|
14
|
+
def self.next_semi(root, accidental = :sharp)
|
15
|
+
if NOTES[accidental].include?(root) then
|
16
|
+
at=NOTES[accidental].index(root)
|
17
|
+
tmp=NOTES[accidental] + NOTES[accidental]
|
18
|
+
at+=1
|
19
|
+
tmp[at]
|
20
|
+
end
|
21
|
+
end
|
60
22
|
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
23
|
+
# get the scale of a root note
|
24
|
+
# returns an array of strings with the scale notes
|
25
|
+
def self.get_scale(root)
|
26
|
+
accitental = nil
|
27
|
+
accidental = :flat if KEYS[:flat].include?(root)
|
28
|
+
accidental = :sharp if KEYS[:sharp].include?(root)
|
29
|
+
|
30
|
+
result="#{root}"
|
31
|
+
cur=root
|
32
|
+
DISTANCES.each { |distance|
|
33
|
+
1.upto(distance.to_i) {
|
34
|
+
cur=next_semi(cur,accidental)
|
35
|
+
}
|
36
|
+
result += ",#{cur}"
|
37
|
+
}
|
38
|
+
result.split(',')
|
39
|
+
end
|
67
40
|
|
68
41
|
end
|
69
42
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Trriad
|
2
|
+
module Chord
|
3
|
+
|
4
|
+
# all the different chord notations
|
5
|
+
CHORDS = {
|
6
|
+
"maj" => "1,3,5".split(','),
|
7
|
+
"m" => "1,3b,5".split(','),
|
8
|
+
"7" => "1,3,5,7b".split(','),
|
9
|
+
"6" => "1,3,5,6".split(','),
|
10
|
+
"m6" => "1,3b,5,6".split(','),
|
11
|
+
"maj7" => "1,3,5,7".split(','),
|
12
|
+
"m7" => "1,3b,5,7".split(','),
|
13
|
+
"dim" => "1,3b,5b,6".split(','),
|
14
|
+
"+" => "1,3,5#".split(','),
|
15
|
+
"9" => "1,3,5,7b,9".split(','),
|
16
|
+
"7+5" => "1,3,5#,7b".split(','),
|
17
|
+
"7b5" => "1,3,5b,7b".split(','),
|
18
|
+
"m7b5" => "1,3b,5b,7b".split(','),
|
19
|
+
"m9" => "1,3b,5,7b,9".split(','),
|
20
|
+
"9+5" => "1,3,5#,7b,9".split(','),
|
21
|
+
"9b5" => "1,3,5b,7b,9".split(','),
|
22
|
+
"maj9" => "1,3,5,7,9".split(','),
|
23
|
+
"6add9" => "1,3,5,6,9".split(','),
|
24
|
+
"7b9" => "1,3,5,7b,9b".split(','),
|
25
|
+
"7sus4" => "1,4,5,7b".split(','),
|
26
|
+
"7add6" => "1,3,5,6,7b".split(','),
|
27
|
+
"11" => "1,3,5,7b,9,11".split(','),
|
28
|
+
"11+" => "1,3,5,7b,9,11#".split(','),
|
29
|
+
"11b9" => "1,3,5,7b,9b,11".split(','),
|
30
|
+
"13" => "1,3,5,7b,9,11,13".split(','),
|
31
|
+
"13b9" => "1,3,5,7b,9b,11,13".split(','),
|
32
|
+
}
|
33
|
+
|
34
|
+
# sharp and flat available notes
|
35
|
+
NOTES = {
|
36
|
+
:sharp => "C,C#,D,D#,E,F,F#,G,G#,A,A#,B".split(","),
|
37
|
+
:flat => "C,Db,D,Eb,E,F,Gb,G,Ab,A,Bb,B".split(",")
|
38
|
+
}
|
39
|
+
|
40
|
+
#DISTANCES = "2,2,1,2,2,2,1".split(",")
|
41
|
+
# the semitone distances for a major key
|
42
|
+
DISTANCES = "2,2,1,2,2,2".split(",")
|
43
|
+
|
44
|
+
# differentiate the keys with sharps and flats
|
45
|
+
KEYS = {
|
46
|
+
# since we only have :sharp an :flat, I need to put "C" somewhere
|
47
|
+
# so it's in :sharp
|
48
|
+
:sharp => "C,G,D,A,E,B,F#,C#".split(","),
|
49
|
+
:flat => "Bb,Eb,Ab,Db,Gb,Cb,Fb".split(","),
|
50
|
+
}
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/trriad/core_ext.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module Trriad
|
2
2
|
module CoreExtensions
|
3
3
|
module String
|
4
|
+
#String extension module for chords
|
4
5
|
module Chord
|
6
|
+
#is this a valid note?
|
5
7
|
def is_valid_note()
|
6
8
|
Trriad::Chord::valid_note(self)
|
7
9
|
end
|
10
|
+
#get the of a root note
|
11
|
+
def scale()
|
12
|
+
Trriad::Chord::get_scale(self)
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
data/lib/trriad/version.rb
CHANGED
data/spec/trriad_spec.rb
CHANGED
@@ -29,3 +29,16 @@ describe "Invalid Note" do
|
|
29
29
|
!"Ebb".is_valid_note()
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
describe "Scale" do
|
34
|
+
it "C should be C,D,E,F,G,A,B" do
|
35
|
+
"C".scale == "C,D,E,F,G,A,B"
|
36
|
+
end
|
37
|
+
it "F# should be F#,G#,A#,B,C#,D#,E#" do
|
38
|
+
"F#".scale == "F#,G#,A#,B,C#,D#,E#"
|
39
|
+
end
|
40
|
+
it "Bb should be Bb,C,D,E,F,G,A" do
|
41
|
+
"Bb".scale == "Bb,C,D,E,F,G,A"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/website/index.txt
CHANGED
@@ -22,10 +22,21 @@ h2. Demonstration of usage
|
|
22
22
|
|
23
23
|
For now, trriad isn't able to much things... just the following:
|
24
24
|
|
25
|
-
|
25
|
+
h3. getting scales
|
26
26
|
|
27
|
-
"
|
27
|
+
"C".scale => ["C", "D", "E", "F", "G", "A", "B"]
|
28
28
|
|
29
|
+
"Bb".scale => ["Bb", "C", "D", "Eb", "F", "G", "A"]
|
30
|
+
|
31
|
+
h3. checking for valid notes
|
32
|
+
|
33
|
+
"C".is_valid_note -> true
|
34
|
+
|
35
|
+
"W".is_valid_note -> false
|
36
|
+
|
37
|
+
|
38
|
+
h2. Todo
|
39
|
+
"Todo":todo.html
|
29
40
|
|
30
41
|
h2. Forum
|
31
42
|
|
data/website/template.rhtml
CHANGED
@@ -42,7 +42,12 @@
|
|
42
42
|
</p>
|
43
43
|
</div>
|
44
44
|
|
45
|
-
|
45
|
+
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
46
|
+
</script>
|
47
|
+
<script type="text/javascript">
|
48
|
+
_uacct = "UA-68330-5";
|
49
|
+
urchinTracker();
|
50
|
+
</script>
|
46
51
|
|
47
52
|
</body>
|
48
53
|
</html>
|
data/website/todo.txt
ADDED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: trriad
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-05-
|
6
|
+
version: 0.0.2.19
|
7
|
+
date: 2007-05-31 00:00:00 +02:00
|
8
8
|
summary: Ruby gem for dealing with several musical items like describing notes, transposing notes, build chords, etc
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- lib/trriad.rb
|
38
38
|
- lib/trriad/chord.rb
|
39
|
+
- lib/trriad/chord_data.rb
|
39
40
|
- lib/trriad/core_ext.rb
|
40
41
|
- lib/trriad/core_ext/string.rb
|
41
42
|
- lib/trriad/core_ext/string/chord.rb
|
@@ -49,6 +50,7 @@ files:
|
|
49
50
|
- website/javascripts/rounded_corners_lite.inc.js
|
50
51
|
- website/stylesheets/screen.css
|
51
52
|
- website/template.rhtml
|
53
|
+
- website/todo.txt
|
52
54
|
test_files: []
|
53
55
|
|
54
56
|
rdoc_options:
|
@@ -60,6 +62,7 @@ extra_rdoc_files:
|
|
60
62
|
- Manifest.txt
|
61
63
|
- README.txt
|
62
64
|
- website/index.txt
|
65
|
+
- website/todo.txt
|
63
66
|
executables: []
|
64
67
|
|
65
68
|
extensions: []
|