Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[#21] I should be able to specify the key signature.

  • Loading branch information...
commit da65482bc65c0fb319aeec605ba6ed899b26cb2f 1 parent 7aac26d
@gsmendoza authored
View
132 examples/tab-with-key-signature.ly
@@ -0,0 +1,132 @@
+\version "2.12.3"
+\include "english.ly"
+
+\paper {
+ indent = #0
+}
+
+\header {
+ title = ""
+ composer = ""
+ arranger = ""
+ instrument = ""
+}
+
+%-----------------------------------------------------------------------
+% Chord Sets
+%-----------------------------------------------------------------------
+% Bars
+
+vOneBarTabOneBarOne = { <d'\2 fs'\1 >4. <fs'\1 d'\2 >4 <fs'\1 d'\2 >8 \skip 4 }
+vTwoBarTabOneBarOne = { <d,\6>4 <d\4>2 <d\4>8 <a,\5>8 }
+cBarTabOneBarOne = { }
+sBarTabOneBarOne = { r1 }
+%-----------------------------------------------------------------------
+% Lines
+%-----------------------------------------------------------------------
+% Stanzas
+%-----------------------------------------------------------------------
+% Scores
+%-----------------------------------------------------------------------
+% Voices
+
+vOne = {
+ \transposition d''
+ \vOneBarTabOneBarOne
+}
+
+vTwo = {
+ \transposition d'
+ \vTwoBarTabOneBarOne
+}
+%-----------------------------------------------------------------------
+% Stanza Headings
+
+stanzaHeadings = { \sBarTabOneBarOne }
+
+%-----------------------------------------------------------------------
+% Chord Headings
+
+chordHeadings = { \cBarTabOneBarOne }
+
+%-----------------------------------------------------------------------
+
+\score {
+ \new StaffGroup <<
+ \new Staff <<
+ \tempo 4 = 100
+
+ \clef "treble_8"
+
+ \new Voice \with { \remove Rest_engraver } {
+ \stanzaHeadings
+ }
+
+ \new Voice {
+ \key d \major
+ \voiceOne
+ \vOne
+ }
+ \new Voice {
+ \key d \major
+ \voiceTwo
+ \vTwo
+ }
+ >>
+
+ \new TabStaff <<
+ \set TabStaff.stringTunings = #'(4 -1 -5 -10 -15 -22)
+ \new TabVoice {
+ \slurUp
+ \vOne
+ }
+ \new TabVoice {
+ \slurUp
+ \vTwo
+ }
+ \new TabVoice {
+ \chordHeadings
+ }
+ >>
+ >>
+
+ \layout {
+ \context { \Staff
+ \override TimeSignature #'style = #'numbered
+ \override StringNumber #'transparent = ##t
+ }
+ \context { \TabStaff
+ \override TimeSignature #'style = #'numbered
+ }
+ \context { \Voice
+ \remove Slur_engraver
+ }
+ \context { \TabVoice
+ \remove Dots_engraver
+ \remove Stem_engraver
+ \remove Rest_engraver
+ }
+ }
+}
+
+% showLastLength = R1*4
+\score {
+ \new Staff \with {midiInstrument = #"acoustic guitar (nylon)"} <<
+ \tempo 4 = 100
+
+ \clef "treble_8"
+
+ \new Voice {
+ \unfoldRepeats {
+ \vOne
+ }
+ }
+ \new Voice {
+ \unfoldRepeats {
+ \vTwo
+ }
+ }
+ >>
+
+ \midi {}
+}
View
11 examples/tab-with-key-signature.rb
@@ -0,0 +1,11 @@
+Gitara.define do
+ key 'd \major'
+ string_tunings "#'(4 -1 -5 -10 -15 -22)" # Drop D
+ tempo "4 = 100"
+ transposition "d"
+
+ bar do
+ notes "<d'/2 fs'/1 >4. <fs'/1 d'/2 >4 <fs'/1 d'/2 >8 /skip 4"
+ notes "<d,/6>4 <d/4>2 <d/4>8 <a,/5>8"
+ end
+end
View
1  lib/gitara/dsl.rb
@@ -9,6 +9,7 @@ class Dsl < Valuable
can_add_property :arranger
can_add_property :composer
can_add_property :instrument
+ can_add_property :key
can_add_property :midi_instrument
can_add_property :string_tunings
can_add_property :tempo
View
1  lib/gitara/node/tab.rb
@@ -4,6 +4,7 @@ class Tab < Base
has_value :arranger
has_value :composer
has_value :instrument
+ has_value :key
has_value :midi_instrument, :default => "acoustic guitar (nylon)"
has_value :string_tunings
has_value :tempo
View
1  lib/gitara/template/tab.erb
@@ -78,6 +78,7 @@ chordHeadings = { <%= playable_child.chorded.call_name %> }
<% voices.each do |voice| %>
\new Voice {
+ <%= self.key && "\\key #{self.key}" %>
<%= voice.stem_type %>
<%= voice.call_name %>
}
View
4 lib/gitara/template/voice.erb
@@ -1,6 +1,4 @@
<%= definition_name %> = {
- <% if self.transposition %>
- \transposition <%= self.transposition %>
- <% end %>
+ <%= self.transposition && "\\transposition #{self.transposition}" %>
<%= parent.playable_child.voiced_as(self).call_name %>
}
View
12 spec/lib/gitara/app_spec.rb
@@ -12,6 +12,10 @@ def run
def expected
@expected ||= Pow("examples/#{name}.ly").read!.gsub(/\n\s+\n/, "\n")
+ rescue PowError => e
+ puts "#{e.message}. Copying actual result..."
+ Pow("examples/#{name}.ly").write actual
+ retry
end
def actual
@@ -32,10 +36,16 @@ def actual
app_test.actual.should == app_test.expected
end
- it "can convert a table with alternate tuning to lilypond" do
+ it "can convert a tab with alternate tuning to lilypond" do
app_test = AppTest.new(:name => 'tab-with-alternate-tuning')
app_test.run
app_test.actual.should == app_test.expected
end
+
+ it "can convert a tab with a specified key signature to lilypond" do
+ app_test = AppTest.new(:name => 'tab-with-key-signature')
+ app_test.run
+ app_test.actual.should == app_test.expected
+ end
end
end
View
2  spec/lib/gitara/dsl_spec.rb
@@ -203,7 +203,7 @@
end
end
- [:title, :composer, :arranger, :instrument, :midi_instrument, :string_tunings, :tempo, :transposition].each do |property|
+ [:title, :composer, :arranger, :instrument, :key, :midi_instrument, :string_tunings, :tempo, :transposition].each do |property|
describe "#{property}(value)" do
it "should set the #{property} of the tab to value" do
tab = FactoryGirl.build(:tab)
Please sign in to comment.
Something went wrong with that request. Please try again.