gitara 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +10 -0
- data/README.markdown +16 -19
- data/examples/tab.ly +6 -6
- data/lib/gitara.rb +1 -1
- data/lib/gitara/node/base.rb +5 -3
- data/lib/gitara/{id_as_word.rb → utilities.rb} +2 -2
- data/lib/gitara/version.rb +1 -1
- data/lib/gitara/voice.rb +4 -2
- data/spec/lib/gitara/node/base_spec.rb +16 -0
- data/spec/spec_helper.rb +0 -10
- metadata +6 -5
data/CHANGELOG.markdown
ADDED
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Gitara is a
|
1
|
+
Gitara is a Ruby DSL for generating Lilypond guitar tablatures
|
2
2
|
|
3
3
|
|
4
4
|
Installation
|
@@ -14,7 +14,7 @@ Usage
|
|
14
14
|
|
15
15
|
gitara export PATH [OPTIONS]...
|
16
16
|
|
17
|
-
This
|
17
|
+
This will generate a lilypond .ly file and then call lilypond to export the .ly file to pdf and midi. Please see `gitara help export` for the available options.
|
18
18
|
|
19
19
|
|
20
20
|
Syntax
|
@@ -44,13 +44,13 @@ Bars are the smallest expressions in Gitara, that is, a gitara file must have at
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
With Gitara, it's easier to write notes using [absolute note names](http://lilypond.org/doc/v2.12/Documentation/learning/absolute-note-names) instead of relative note names. This is because we'll be
|
47
|
+
With Gitara, it's easier to write notes using [absolute note names](http://lilypond.org/doc/v2.12/Documentation/learning/absolute-note-names) instead of relative note names. This is because we'll be reusing bars and other Gitara expressions (see Reusing bars below).
|
48
48
|
|
49
49
|
|
50
50
|
Multiple voices
|
51
51
|
---------------
|
52
52
|
|
53
|
-
|
53
|
+
Each line of notes in a bar is a [voice](http://lilypond.org/doc/v2.12/Documentation/user/lilypond-learning/Voices-contain-music):
|
54
54
|
|
55
55
|
Gitara.define do
|
56
56
|
bar do
|
@@ -59,8 +59,7 @@ If the bar has more than one note line, then each note line is a voice:
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
The tab above will play "c d e f g a b c" and "c' d' e' f' g' a' b' c'" simultaneously,
|
63
|
-
not sequentially.
|
62
|
+
The tab above will play "c d e f g a b c" and "c' d' e' f' g' a' b' c'" simultaneously, not sequentially.
|
64
63
|
|
65
64
|
|
66
65
|
Reusing bars
|
@@ -79,16 +78,13 @@ If you want to repeat a bar, you can name the bar and call it later:
|
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
|
-
This will generate a tab with two Intro bars. It's important to group the
|
83
|
-
two bars inside a score, because...
|
81
|
+
This will generate a tab with two Intro bars. It's important to group the two bars inside a score, because...
|
84
82
|
|
85
83
|
|
86
84
|
Only the last expression under Gitara.define will be generated
|
87
85
|
--------------------------------------------------------------
|
88
86
|
|
89
|
-
When writing a tab, oftentimes you want to generate only a part of the tab for
|
90
|
-
isolation and testing. Gitara makes this easy by generating a lilypond file
|
91
|
-
only for the last expression under Gitara.define. For example:
|
87
|
+
When writing a tab, oftentimes you want to generate only a part of the tab for testing purposes. Gitara makes this easy by processing only for the last expression under Gitara.define. For example:
|
92
88
|
|
93
89
|
Gitara.define do
|
94
90
|
bar do
|
@@ -100,8 +96,7 @@ only for the last expression under Gitara.define. For example:
|
|
100
96
|
end
|
101
97
|
end
|
102
98
|
|
103
|
-
This tab will generate only the second bar (notes "g a b c"). If you want Gitara
|
104
|
-
to generate both bars, group them inside a score.
|
99
|
+
This tab will generate only the second bar (notes "g a b c"). If you want Gitara to generate both bars, group them inside a score.
|
105
100
|
|
106
101
|
Gitara.define do
|
107
102
|
score do
|
@@ -133,7 +128,7 @@ If you want to generate a particular bar inside the score, you can copy it after
|
|
133
128
|
end
|
134
129
|
end
|
135
130
|
|
136
|
-
Or you define the bar to call later:
|
131
|
+
Or you can define the bar to call later:
|
137
132
|
|
138
133
|
Gitara.define do
|
139
134
|
bar :FirstBar do
|
@@ -171,15 +166,17 @@ You can group bars in a line:
|
|
171
166
|
|
172
167
|
Lines are manually breaked with [\\break](http://lilypond.org/doc/v2.12/Documentation/notation/line-breaking).
|
173
168
|
|
169
|
+
Like bars, lines can be named, reused, etc.
|
170
|
+
|
174
171
|
|
175
172
|
Notes with single quotes and backslashes
|
176
173
|
----------------------------------------
|
177
174
|
|
178
|
-
In Lilypond syntax, single quotes
|
175
|
+
In Lilypond syntax, single quotes refer to octaves while backslashes refer to string numbers. So, the c note in the second string is written as
|
179
176
|
|
180
177
|
c'\2
|
181
178
|
|
182
|
-
Since a Gitara file is a Ruby program, you have to be careful with backslashes when writing notes like the one above. Ruby provides two ways
|
179
|
+
Since a Gitara file is a Ruby program, you have to be careful with backslashes when writing notes like the one above. As far as I know, Ruby provides two ways to preserve the backslash in the note above:
|
183
180
|
|
184
181
|
notes %q|c'\2|
|
185
182
|
|
@@ -197,7 +194,7 @@ Prettier and easier to search and replace.
|
|
197
194
|
Workflow
|
198
195
|
--------
|
199
196
|
|
200
|
-
I'm no Lilypond expert (heh). When writing a tab, I use [TuxGuitar](http://tuxguitar.herac.com.ar) to transcribe a set of notes (usually just one bar). I then export the TuxGuitar tab to lilypond so that I can get the lilypond notes. I then place
|
197
|
+
I'm no Lilypond expert (heh). When writing a tab, I use [TuxGuitar](http://tuxguitar.herac.com.ar) to transcribe a set of notes (usually just one bar). I then export the TuxGuitar tab to lilypond so that I can get the lilypond notes. I then place these lilypond notes inside my Gitara tab. This workflow allows me to use TuxGuitar's GUI for transcribing notes while allowing me to use Gitara's features for naming expressions and reusing them.
|
201
198
|
|
202
199
|
|
203
200
|
To do
|
@@ -209,6 +206,6 @@ For version 1, I want to convert this lilypond file I wrote to Gitara format:
|
|
209
206
|
|
210
207
|
The remaining features are:
|
211
208
|
|
212
|
-
1. Properties like the title and authors
|
213
|
-
2. Stanza labels
|
209
|
+
1. Properties like the title and authors
|
210
|
+
2. Stanza labels
|
214
211
|
3. Chord labels
|
data/examples/tab.ly
CHANGED
@@ -29,23 +29,23 @@ vTwoBarYouGot = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
|
|
29
29
|
vOneLineVerseOneLineTwo = { \vOneBarYouGot \vOneBarWhatYouThought \vOneBarWhenYouFirst \vOneBarItThough \break }
|
30
30
|
vTwoLineVerseOneLineTwo = { \vTwoBarYouGot \vTwoBarWhatYouThought \vTwoBarWhenYouFirst \vTwoBarItThough \break }
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
vOneLineTabOneScoreOneLineOne = { \vOneBarItsNot \vOneBarWhatYouThought \vOneBarWhenYouFirst \vOneBarBeganIt \break }
|
33
|
+
vTwoLineTabOneScoreOneLineOne = { \vTwoBarItsNot \vTwoBarWhatYouThought \vTwoBarWhenYouFirst \vTwoBarBeganIt \break }
|
34
34
|
|
35
35
|
|
36
36
|
%-----------------------------------------------------------------------
|
37
37
|
% Scores
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
vOneScoreTabOneScoreOne = { \vOneLineTabOneScoreOneLineOne \vOneLineVerseOneLineTwo }
|
40
|
+
vTwoScoreTabOneScoreOne = { \vTwoLineTabOneScoreOneLineOne \vTwoLineVerseOneLineTwo }
|
41
41
|
|
42
42
|
|
43
43
|
%-----------------------------------------------------------------------
|
44
44
|
% Voices
|
45
45
|
|
46
|
-
vOne = { \
|
46
|
+
vOne = { \vOneScoreTabOneScoreOne }
|
47
47
|
|
48
|
-
vTwo = { \
|
48
|
+
vTwo = { \vTwoScoreTabOneScoreOne }
|
49
49
|
|
50
50
|
|
51
51
|
\score {
|
data/lib/gitara.rb
CHANGED
@@ -8,7 +8,6 @@ require "valuable"
|
|
8
8
|
|
9
9
|
require "gitara/app"
|
10
10
|
require "gitara/dsl"
|
11
|
-
require "gitara/id_as_word"
|
12
11
|
require "gitara/node/base"
|
13
12
|
require "gitara/node/base/voiced_node"
|
14
13
|
require "gitara/node/bar"
|
@@ -18,6 +17,7 @@ require "gitara/node/note_set"
|
|
18
17
|
require "gitara/node/score"
|
19
18
|
require "gitara/node/tab"
|
20
19
|
require "gitara/pow/base"
|
20
|
+
require "gitara/utilities"
|
21
21
|
require "gitara/version"
|
22
22
|
require "gitara/voice"
|
23
23
|
|
data/lib/gitara/node/base.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module Gitara
|
2
2
|
module Node
|
3
3
|
class Base < Valuable
|
4
|
-
include IdAsWord
|
5
|
-
|
6
4
|
has_value :name
|
7
5
|
has_value :id, :default => 1
|
8
6
|
has_value :parent
|
@@ -10,7 +8,7 @@ module Gitara
|
|
10
8
|
|
11
9
|
def add(child)
|
12
10
|
own_children << child
|
13
|
-
child.id = own_children.size
|
11
|
+
child.id = own_children.select{|c| c.is_a?(child.class)}.size
|
14
12
|
child.parent = self
|
15
13
|
end
|
16
14
|
|
@@ -40,6 +38,10 @@ module Gitara
|
|
40
38
|
self.is_a?(klass) && self.definition? ? [self] : self.own_children.map{|child| child.definitions(klass) }.flatten
|
41
39
|
end
|
42
40
|
|
41
|
+
def id_as_word
|
42
|
+
Utilities.id_as_word(id)
|
43
|
+
end
|
44
|
+
|
43
45
|
def name
|
44
46
|
attributes[:name] || "#{parent && parent.name}#{self.class.to_s.split('::').last}#{self.id_as_word}"
|
45
47
|
end
|
data/lib/gitara/version.rb
CHANGED
data/lib/gitara/voice.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Gitara
|
2
2
|
class Voice < Valuable
|
3
|
-
include IdAsWord
|
4
|
-
|
5
3
|
has_value :id
|
6
4
|
has_value :parent
|
7
5
|
|
@@ -13,6 +11,10 @@ module Gitara
|
|
13
11
|
"v#{id_as_word}"
|
14
12
|
end
|
15
13
|
|
14
|
+
def id_as_word
|
15
|
+
Utilities.id_as_word(id)
|
16
|
+
end
|
17
|
+
|
16
18
|
def stem_type
|
17
19
|
"\\voice#{id_as_word}"
|
18
20
|
end
|
@@ -47,6 +47,22 @@ describe Node::Base do
|
|
47
47
|
parent.children[1].id.should == 2
|
48
48
|
parent.children[1].parent.should == parent
|
49
49
|
end
|
50
|
+
|
51
|
+
it "should set the id based on existing siblings having the same class as the child" do
|
52
|
+
parent = Node::Base.new
|
53
|
+
|
54
|
+
bar_1 = Node::Bar.new
|
55
|
+
parent.add bar_1
|
56
|
+
bar_1.id.should == 1
|
57
|
+
|
58
|
+
line_1 = Node::Line.new
|
59
|
+
parent.add line_1
|
60
|
+
line_1.id.should == 1
|
61
|
+
|
62
|
+
bar_2 = Node::Bar.new
|
63
|
+
parent.add bar_2
|
64
|
+
bar_2.id.should == 2
|
65
|
+
end
|
50
66
|
end
|
51
67
|
|
52
68
|
describe "definition" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- George Mendoza
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: active_support
|
@@ -196,6 +196,7 @@ extra_rdoc_files: []
|
|
196
196
|
|
197
197
|
files:
|
198
198
|
- .gitignore
|
199
|
+
- CHANGELOG.markdown
|
199
200
|
- Gemfile
|
200
201
|
- Guardfile
|
201
202
|
- README.markdown
|
@@ -213,7 +214,6 @@ files:
|
|
213
214
|
- lib/gitara.rb
|
214
215
|
- lib/gitara/app.rb
|
215
216
|
- lib/gitara/dsl.rb
|
216
|
-
- lib/gitara/id_as_word.rb
|
217
217
|
- lib/gitara/node/bar.rb
|
218
218
|
- lib/gitara/node/bar/voiced_node.rb
|
219
219
|
- lib/gitara/node/base.rb
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/gitara/template/score.erb
|
229
229
|
- lib/gitara/template/tab.erb
|
230
230
|
- lib/gitara/template/voice.erb
|
231
|
+
- lib/gitara/utilities.rb
|
231
232
|
- lib/gitara/version.rb
|
232
233
|
- lib/gitara/voice.rb
|
233
234
|
- spec/lib/gitara/app_spec.rb
|