gitara 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,10 @@
1
+ 0.5.0 - 2012-03-18
2
+ ------------------
3
+
4
+ * [#19] I should be able to specify alternate tunings.
5
+ * [#21] I should be able to specify the key signature.
6
+
7
+
1
8
  0.4.2 - 2012-03-17
2
9
  ------------------
3
10
 
data/README.markdown CHANGED
@@ -227,7 +227,9 @@ A gitara file can have the following optional properties:
227
227
  composer "Aimee Mann"
228
228
  arranger "Arranged by George Mendoza"
229
229
  instrument "Guitar (capo on second fret)"
230
+ key 'c \major'
230
231
  midi_instrument "acoustic guitar (nylon)"
232
+ string_tunings "#guitar-tuning"
231
233
  tempo "4 = 75"
232
234
  transposition "d"
233
235
  end
@@ -235,12 +237,13 @@ A gitara file can have the following optional properties:
235
237
  * arranger - tab's arranger
236
238
  * composer - song's composer
237
239
  * instrument - description of the instrument used on the tab
240
+ * key - [key signature](http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Displaying-pitches#Key-signature)
238
241
  * midi_instrument - the type of instrument played in the midi export of the tab. By default, "acoustic guitar (nylon)".
239
- * tempo - see [lilypond](http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Writing-parts#Metronome-marks) for the format.
242
+ * string_tunings - see [lilypond](http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Common-notation-for-fretted-strings#Custom-tablatures)
243
+ * tempo - see [lilypond](http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Writing-parts#Metronome-marks) for the format
240
244
  * title - title of the song
241
245
  * transposition - adjusts the pitch of the instrument. The default transposition is "c". If you set it to "d", then you have to play the tab two frets higher on the guitar (capo on second fret).
242
246
 
243
-
244
247
  Notes with single quotes and backslashes
245
248
  ----------------------------------------
246
249
 
@@ -0,0 +1,142 @@
1
+ \version "2.12.3"
2
+ \include "english.ly"
3
+
4
+ \paper {
5
+ indent = #0
6
+ }
7
+
8
+ \header {
9
+ title = ""
10
+ composer = ""
11
+ arranger = ""
12
+ instrument = ""
13
+ }
14
+
15
+ %-----------------------------------------------------------------------
16
+ % Chord Sets
17
+
18
+
19
+ %-----------------------------------------------------------------------
20
+ % Bars
21
+
22
+ vOneBarTabOneBarOne = { <d'\2 fs'\1 >4. <fs'\1 d'\2 >4 <fs'\1 d'\2 >8 \skip 4 }
23
+ vTwoBarTabOneBarOne = { <d,\6>4 <d\4>2 <d\4>8 <a,\5>8 }
24
+ cBarTabOneBarOne = { }
25
+ sBarTabOneBarOne = { r1 }
26
+
27
+
28
+ %-----------------------------------------------------------------------
29
+ % Lines
30
+
31
+
32
+ %-----------------------------------------------------------------------
33
+ % Stanzas
34
+
35
+
36
+ %-----------------------------------------------------------------------
37
+ % Scores
38
+
39
+
40
+ %-----------------------------------------------------------------------
41
+ % Voices
42
+
43
+ vOne = {
44
+ \transposition d''
45
+ \vOneBarTabOneBarOne
46
+ }
47
+
48
+ vTwo = {
49
+ \transposition d'
50
+ \vTwoBarTabOneBarOne
51
+ }
52
+
53
+
54
+ %-----------------------------------------------------------------------
55
+ % Stanza Headings
56
+
57
+ stanzaHeadings = { \sBarTabOneBarOne }
58
+
59
+ %-----------------------------------------------------------------------
60
+ % Chord Headings
61
+
62
+ chordHeadings = { \cBarTabOneBarOne }
63
+
64
+ %-----------------------------------------------------------------------
65
+
66
+ \score {
67
+ \new StaffGroup <<
68
+ \new Staff <<
69
+ \tempo 4 = 100
70
+
71
+ \clef "treble_8"
72
+
73
+ \new Voice \with { \remove Rest_engraver } {
74
+ \stanzaHeadings
75
+ }
76
+
77
+ \new Voice {
78
+ \voiceOne
79
+ \vOne
80
+ }
81
+ \new Voice {
82
+ \voiceTwo
83
+ \vTwo
84
+ }
85
+ >>
86
+
87
+ \new TabStaff <<
88
+ \set TabStaff.stringTunings = #'(4 -1 -5 -10 -15 -22)
89
+ \new TabVoice {
90
+ \slurUp
91
+ \vOne
92
+ }
93
+ \new TabVoice {
94
+ \slurUp
95
+ \vTwo
96
+ }
97
+ \new TabVoice {
98
+ \chordHeadings
99
+ }
100
+ >>
101
+ >>
102
+
103
+ \layout {
104
+ \context { \Staff
105
+ \override TimeSignature #'style = #'numbered
106
+ \override StringNumber #'transparent = ##t
107
+ }
108
+ \context { \TabStaff
109
+ \override TimeSignature #'style = #'numbered
110
+ }
111
+ \context { \Voice
112
+ \remove Slur_engraver
113
+ }
114
+ \context { \TabVoice
115
+ \remove Dots_engraver
116
+ \remove Stem_engraver
117
+ \remove Rest_engraver
118
+ }
119
+ }
120
+ }
121
+
122
+ % showLastLength = R1*4
123
+ \score {
124
+ \new Staff \with {midiInstrument = #"acoustic guitar (nylon)"} <<
125
+ \tempo 4 = 100
126
+
127
+ \clef "treble_8"
128
+
129
+ \new Voice {
130
+ \unfoldRepeats {
131
+ \vOne
132
+ }
133
+ }
134
+ \new Voice {
135
+ \unfoldRepeats {
136
+ \vTwo
137
+ }
138
+ }
139
+ >>
140
+
141
+ \midi {}
142
+ }
@@ -0,0 +1,10 @@
1
+ Gitara.define do
2
+ string_tunings "#'(4 -1 -5 -10 -15 -22)" # Drop D
3
+ tempo "4 = 100"
4
+ transposition "d"
5
+
6
+ bar do
7
+ notes "<d'/2 fs'/1 >4. <fs'/1 d'/2 >4 <fs'/1 d'/2 >8 /skip 4"
8
+ notes "<d,/6>4 <d/4>2 <d/4>8 <a,/5>8"
9
+ end
10
+ end
@@ -0,0 +1,132 @@
1
+ \version "2.12.3"
2
+ \include "english.ly"
3
+
4
+ \paper {
5
+ indent = #0
6
+ }
7
+
8
+ \header {
9
+ title = ""
10
+ composer = ""
11
+ arranger = ""
12
+ instrument = ""
13
+ }
14
+
15
+ %-----------------------------------------------------------------------
16
+ % Chord Sets
17
+ %-----------------------------------------------------------------------
18
+ % Bars
19
+
20
+ vOneBarTabOneBarOne = { <d'\2 fs'\1 >4. <fs'\1 d'\2 >4 <fs'\1 d'\2 >8 \skip 4 }
21
+ vTwoBarTabOneBarOne = { <d,\6>4 <d\4>2 <d\4>8 <a,\5>8 }
22
+ cBarTabOneBarOne = { }
23
+ sBarTabOneBarOne = { r1 }
24
+ %-----------------------------------------------------------------------
25
+ % Lines
26
+ %-----------------------------------------------------------------------
27
+ % Stanzas
28
+ %-----------------------------------------------------------------------
29
+ % Scores
30
+ %-----------------------------------------------------------------------
31
+ % Voices
32
+
33
+ vOne = {
34
+ \transposition d''
35
+ \vOneBarTabOneBarOne
36
+ }
37
+
38
+ vTwo = {
39
+ \transposition d'
40
+ \vTwoBarTabOneBarOne
41
+ }
42
+ %-----------------------------------------------------------------------
43
+ % Stanza Headings
44
+
45
+ stanzaHeadings = { \sBarTabOneBarOne }
46
+
47
+ %-----------------------------------------------------------------------
48
+ % Chord Headings
49
+
50
+ chordHeadings = { \cBarTabOneBarOne }
51
+
52
+ %-----------------------------------------------------------------------
53
+
54
+ \score {
55
+ \new StaffGroup <<
56
+ \new Staff <<
57
+ \tempo 4 = 100
58
+
59
+ \clef "treble_8"
60
+
61
+ \new Voice \with { \remove Rest_engraver } {
62
+ \stanzaHeadings
63
+ }
64
+
65
+ \new Voice {
66
+ \key d \major
67
+ \voiceOne
68
+ \vOne
69
+ }
70
+ \new Voice {
71
+ \key d \major
72
+ \voiceTwo
73
+ \vTwo
74
+ }
75
+ >>
76
+
77
+ \new TabStaff <<
78
+ \set TabStaff.stringTunings = #'(4 -1 -5 -10 -15 -22)
79
+ \new TabVoice {
80
+ \slurUp
81
+ \vOne
82
+ }
83
+ \new TabVoice {
84
+ \slurUp
85
+ \vTwo
86
+ }
87
+ \new TabVoice {
88
+ \chordHeadings
89
+ }
90
+ >>
91
+ >>
92
+
93
+ \layout {
94
+ \context { \Staff
95
+ \override TimeSignature #'style = #'numbered
96
+ \override StringNumber #'transparent = ##t
97
+ }
98
+ \context { \TabStaff
99
+ \override TimeSignature #'style = #'numbered
100
+ }
101
+ \context { \Voice
102
+ \remove Slur_engraver
103
+ }
104
+ \context { \TabVoice
105
+ \remove Dots_engraver
106
+ \remove Stem_engraver
107
+ \remove Rest_engraver
108
+ }
109
+ }
110
+ }
111
+
112
+ % showLastLength = R1*4
113
+ \score {
114
+ \new Staff \with {midiInstrument = #"acoustic guitar (nylon)"} <<
115
+ \tempo 4 = 100
116
+
117
+ \clef "treble_8"
118
+
119
+ \new Voice {
120
+ \unfoldRepeats {
121
+ \vOne
122
+ }
123
+ }
124
+ \new Voice {
125
+ \unfoldRepeats {
126
+ \vTwo
127
+ }
128
+ }
129
+ >>
130
+
131
+ \midi {}
132
+ }
@@ -0,0 +1,11 @@
1
+ Gitara.define do
2
+ key 'd \major'
3
+ string_tunings "#'(4 -1 -5 -10 -15 -22)" # Drop D
4
+ tempo "4 = 100"
5
+ transposition "d"
6
+
7
+ bar do
8
+ notes "<d'/2 fs'/1 >4. <fs'/1 d'/2 >4 <fs'/1 d'/2 >8 /skip 4"
9
+ notes "<d,/6>4 <d/4>2 <d/4>8 <a,/5>8"
10
+ end
11
+ end
data/lib/gitara/dsl.rb CHANGED
@@ -9,7 +9,9 @@ module Gitara
9
9
  can_add_property :arranger
10
10
  can_add_property :composer
11
11
  can_add_property :instrument
12
+ can_add_property :key
12
13
  can_add_property :midi_instrument
14
+ can_add_property :string_tunings
13
15
  can_add_property :tempo
14
16
  can_add_property :title
15
17
  can_add_property :transposition
@@ -4,7 +4,9 @@ module Gitara
4
4
  has_value :arranger
5
5
  has_value :composer
6
6
  has_value :instrument
7
+ has_value :key
7
8
  has_value :midi_instrument, :default => "acoustic guitar (nylon)"
9
+ has_value :string_tunings
8
10
  has_value :tempo
9
11
  has_value :title
10
12
  has_value :transposition
@@ -78,6 +78,7 @@ chordHeadings = { <%= playable_child.chorded.call_name %> }
78
78
 
79
79
  <% voices.each do |voice| %>
80
80
  \new Voice {
81
+ <%= self.key && "\\key #{self.key}" %>
81
82
  <%= voice.stem_type %>
82
83
  <%= voice.call_name %>
83
84
  }
@@ -85,6 +86,7 @@ chordHeadings = { <%= playable_child.chorded.call_name %> }
85
86
  >>
86
87
 
87
88
  \new TabStaff <<
89
+ <%= self.string_tunings && "\\set TabStaff.stringTunings = #{self.string_tunings}" %>
88
90
  <% voices.each do |voice| %>
89
91
  \new TabVoice {
90
92
  \slurUp
@@ -1,6 +1,4 @@
1
1
  <%= definition_name %> = {
2
- <% if self.transposition %>
3
- \transposition <%= self.transposition %>
4
- <% end %>
2
+ <%= self.transposition && "\\transposition #{self.transposition}" %>
5
3
  <%= parent.playable_child.voiced_as(self).call_name %>
6
4
  }
@@ -1,3 +1,3 @@
1
1
  module Gitara
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -7,15 +7,19 @@ describe App do
7
7
  def run
8
8
  app = FactoryGirl.build(:app)
9
9
  app.invoke :export, ["examples/#{name}.rb"], "target-directory" => test_tmp_dir.path, "run-lilypond" => false
10
- (Pow("tmp") / "new-#{name}.ly").write actual if self.expected != self.actual
10
+ (Pow("tmp") / "#{name}.ly").write actual if self.expected != self.actual
11
11
  end
12
12
 
13
13
  def expected
14
- @expected ||= Pow("examples/#{name}.ly").read
14
+ @expected ||= Pow("examples/#{name}.ly").read!.gsub(/\n\s+\n/, "\n")
15
+ rescue PowError => e
16
+ puts "#{e.message}. Copying actual result..."
17
+ Pow("examples/#{name}.ly").write actual
18
+ retry
15
19
  end
16
20
 
17
21
  def actual
18
- @actual ||= (test_tmp_dir / "#{name}.ly").read
22
+ @actual ||= (test_tmp_dir / "#{name}.ly").read!.gsub(/\n\s+\n/, "\n")
19
23
  end
20
24
  end
21
25
 
@@ -31,5 +35,17 @@ describe App do
31
35
  app_test.run
32
36
  app_test.actual.should == app_test.expected
33
37
  end
38
+
39
+ it "can convert a tab with alternate tuning to lilypond" do
40
+ app_test = AppTest.new(:name => 'tab-with-alternate-tuning')
41
+ app_test.run
42
+ app_test.actual.should == app_test.expected
43
+ end
44
+
45
+ it "can convert a tab with a specified key signature to lilypond" do
46
+ app_test = AppTest.new(:name => 'tab-with-key-signature')
47
+ app_test.run
48
+ app_test.actual.should == app_test.expected
49
+ end
34
50
  end
35
51
  end
@@ -203,7 +203,7 @@ describe Gitara do
203
203
  end
204
204
  end
205
205
 
206
- [:title, :composer, :arranger, :instrument, :midi_instrument, :tempo, :transposition].each do |property|
206
+ [:title, :composer, :arranger, :instrument, :key, :midi_instrument, :string_tunings, :tempo, :transposition].each do |property|
207
207
  describe "#{property}(value)" do
208
208
  it "should set the #{property} of the tab to value" do
209
209
  tab = FactoryGirl.build(:tab)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-17 00:00:00.000000000 Z
12
+ date: 2012-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_support
16
- requirement: &76036530 !ruby/object:Gem::Requirement
16
+ requirement: &78713260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *76036530
24
+ version_requirements: *78713260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: erubis
27
- requirement: &76036310 !ruby/object:Gem::Requirement
27
+ requirement: &78713040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *76036310
35
+ version_requirements: *78713040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: linguistics
38
- requirement: &76036050 !ruby/object:Gem::Requirement
38
+ requirement: &78712780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *76036050
46
+ version_requirements: *78712780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pow
49
- requirement: &76035840 !ruby/object:Gem::Requirement
49
+ requirement: &78712550 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *76035840
57
+ version_requirements: *78712550
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: thor
60
- requirement: &76035600 !ruby/object:Gem::Requirement
60
+ requirement: &78712320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *76035600
68
+ version_requirements: *78712320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: valuable
71
- requirement: &76035350 !ruby/object:Gem::Requirement
71
+ requirement: &78712070 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *76035350
79
+ version_requirements: *78712070
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: factory_girl
82
- requirement: &76035070 !ruby/object:Gem::Requirement
82
+ requirement: &78711790 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *76035070
90
+ version_requirements: *78711790
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &75681160 !ruby/object:Gem::Requirement
93
+ requirement: &78357910 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *75681160
101
+ version_requirements: *78357910
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard-rspec
104
- requirement: &75680880 !ruby/object:Gem::Requirement
104
+ requirement: &78357620 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *75680880
112
+ version_requirements: *78357620
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: pry
115
- requirement: &75680640 !ruby/object:Gem::Requirement
115
+ requirement: &78357380 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *75680640
123
+ version_requirements: *78357380
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rb-inotify
126
- requirement: &75680330 !ruby/object:Gem::Requirement
126
+ requirement: &78357060 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *75680330
134
+ version_requirements: *78357060
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: rspec
137
- requirement: &75680020 !ruby/object:Gem::Requirement
137
+ requirement: &78356740 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *75680020
145
+ version_requirements: *78356740
146
146
  description: A Ruby DSL for generating Lilypond guitar tablatures.
147
147
  email:
148
148
  - gsmendoza@gmail.com
@@ -166,10 +166,12 @@ files:
166
166
  - examples/eraserheads-huling-el-bimbo/tab.midi
167
167
  - examples/eraserheads-huling-el-bimbo/tab.pdf
168
168
  - examples/eraserheads-huling-el-bimbo/tab.rb
169
- - examples/tab-with-bar.rb
169
+ - examples/tab-with-alternate-tuning.ly
170
+ - examples/tab-with-alternate-tuning.rb
171
+ - examples/tab-with-key-signature.ly
172
+ - examples/tab-with-key-signature.rb
170
173
  - examples/tab-with-partial.ly
171
174
  - examples/tab-with-partial.rb
172
- - examples/tab-with-reused-bar.rb
173
175
  - examples/tab.ly
174
176
  - examples/tab.rb
175
177
  - gitara.gemspec
@@ -1,7 +0,0 @@
1
- Gitara.define do
2
- bar "Intro" do
3
- notes "<g'/1>8 <a/3>8 <g'/1>8 <a/3>16 <g'/1>8 <g/3>16 <e'/1>4 <g/3>8"
4
- notes "<f/4>4 <f/4>4 <c/5>4 <e/4>4"
5
- end
6
- end
7
-
@@ -1,9 +0,0 @@
1
- Gitara.define do
2
- bar "Intro" do
3
- notes "<g'/1>8 <a/3>8 <g'/1>8 <a/3>16 <g'/1>8 <g/3>16 <e'/1>4 <g/3>8"
4
- notes "<f/4>4 <f/4>4 <c/5>4 <e/4>4"
5
- end
6
-
7
- bar "Intro"
8
- end
9
-