Permalink
Browse files

[#18] I should be able to specify if a bar is a partial.

  • Loading branch information...
gsmendoza committed Mar 17, 2012
1 parent aa7c475 commit db31972dd73dfbab0a6c78adde643020a3f43551

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.
@@ -8,6 +8,7 @@
tempo "4 = 90"
chords :G, 'r1-"G"'
+ chords :G8, 'r8-"G"'
chords :C, 'r1-"C"'
chords :A7, 'r1-"A7"'
chords :Em, 'r1-"Em"'
@@ -17,9 +18,10 @@
stanza "Verse" do
line do
bar do
- notes "r2. r8 <g/3>8"
- notes "r1"
- chords :G
+ partial 8
+ notes "<g/3>8"
+ notes "r8"
+ chords :G8
end
bar do
@@ -0,0 +1,167 @@
+\version "2.12.3"
+\include "english.ly"
+
+\paper {
+ indent = #0
+}
+
+\header {
+ title = "Huling El Bimbo"
+ composer = "Eraserheads"
+ arranger = "Arranged by George Mendoza"
+ instrument = "Guitar (capo on first fret)"
+}
+
+%-----------------------------------------------------------------------
+% Chord Sets
+
+cChordSetG = { r1-"G" }
+cChordSetGEight = { r8-"G" }
+cChordSetC = { r1-"C" }
+cChordSetASeven = { r1-"A7" }
+cChordSetEm = { r1-"Em" }
+cChordSetD = { r1-"D" }
+
+%-----------------------------------------------------------------------
+% Bars
+
+vOneBarVerseLineOneBarOne = { \partial 8 <g\3>8 }
+vTwoBarVerseLineOneBarOne = { \partial 8 r8 }
+cBarVerseLineOneBarOne = { \partial 8 \cChordSetGEight }
+sBarVerseLineOneBarOne = { \partial 8 r8^"Verse" }
+
+vOneBarVerseLineOneBarTwo = { <a\3>16\glissando <b\3>16 <b\3>4 r16 <a\3>16\glissando <b\3>4. <a\3>16( <g\3>16) }
+vTwoBarVerseLineOneBarTwo = { r1 }
+cBarVerseLineOneBarTwo = { \cChordSetG }
+sBarVerseLineOneBarTwo = { r1 }
+
+
+%-----------------------------------------------------------------------
+% Lines
+
+vOneLineVerseLineOne = { \vOneBarVerseLineOneBarOne \vOneBarVerseLineOneBarTwo \break }
+vTwoLineVerseLineOne = { \vTwoBarVerseLineOneBarOne \vTwoBarVerseLineOneBarTwo \break }
+cLineVerseLineOne = { \cBarVerseLineOneBarOne \cBarVerseLineOneBarTwo }
+sLineVerseLineOne = { \sBarVerseLineOneBarOne \sBarVerseLineOneBarTwo }
+
+
+%-----------------------------------------------------------------------
+% Stanzas
+
+vOneStanzaVerse = { \vOneLineVerseLineOne }
+vTwoStanzaVerse = { \vTwoLineVerseLineOne }
+cStanzaVerse = { \cLineVerseLineOne }
+sStanzaVerse = { \sLineVerseLineOne }
+
+
+%-----------------------------------------------------------------------
+% Scores
+
+vOneScoreTabOneScoreOne = { \vOneStanzaVerse }
+vTwoScoreTabOneScoreOne = { \vTwoStanzaVerse }
+cScoreTabOneScoreOne = { \cStanzaVerse }
+sScoreTabOneScoreOne = { \sStanzaVerse }
+
+
+%-----------------------------------------------------------------------
+% Voices
+
+vOne = {
+ \transposition cs''
+ \vOneScoreTabOneScoreOne
+}
+
+vTwo = {
+ \transposition cs'
+ \vTwoScoreTabOneScoreOne
+}
+
+
+%-----------------------------------------------------------------------
+% Stanza Headings
+
+stanzaHeadings = { \sScoreTabOneScoreOne }
+
+%-----------------------------------------------------------------------
+% Chord Headings
+
+chordHeadings = { \cScoreTabOneScoreOne }
+
+%-----------------------------------------------------------------------
+
+\score {
+ \new StaffGroup <<
+ \new Staff <<
+ \tempo 4 = 90
+
+ \clef "treble_8"
+
+ \new Voice \with { \remove Rest_engraver } {
+ \stanzaHeadings
+ }
+
+ \new Voice {
+ \voiceOne
+ \vOne
+ }
+ \new Voice {
+ \voiceTwo
+ \vTwo
+ }
+ >>
+
+ \new TabStaff <<
+ \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 = 90
+
+ \clef "treble_8"
+
+ \new Voice {
+ \unfoldRepeats {
+ \vOne
+ }
+ }
+ \new Voice {
+ \unfoldRepeats {
+ \vTwo
+ }
+ }
+ >>
+
+ \midi {}
+}
@@ -0,0 +1,35 @@
+Gitara.define do
+ title "Huling El Bimbo"
+ composer "Eraserheads"
+ arranger "Arranged by George Mendoza"
+ instrument "Guitar (capo on first fret)"
+ midi_instrument "acoustic guitar (nylon)"
+ transposition "cs"
+ tempo "4 = 90"
+
+ chords :G, 'r1-"G"'
+ chords :G8, 'r8-"G"'
+ chords :C, 'r1-"C"'
+ chords :A7, 'r1-"A7"'
+ chords :Em, 'r1-"Em"'
+ chords :D, 'r1-"D"'
+
+ score do
+ stanza "Verse" do
+ line do
+ bar do
+ partial 8
+ notes "<g/3>8"
+ notes "r8"
+ chords :G8
+ end
+
+ bar do
+ notes "<a/3>16/glissando <b/3>16 <b/3>4 r16 <a/3>16/glissando <b/3>4. <a/3>16( <g/3>16)"
+ notes "r1"
+ chords :G
+ end
+ end
+ end
+ end
+end
View
@@ -26,35 +26,35 @@ cChordSetFD = { r4-"F" r r-"D" r }
%-----------------------------------------------------------------------
% Bars
-vOneBarBeganIt = { \skip 4 <a\3 c'\2 >8 <g\3>8 \skip 4 <g\3 c'\2 >8 <g\3>8 }
-vTwoBarBeganIt = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
-cBarBeganIt = { \cChordSetFC }
-sBarBeganIt = { r1 }
-
-vOneBarItsNot = { r8 <g'\1>4 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>16( <a\3>16) }
-vTwoBarItsNot = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
-cBarItsNot = { \cChordSetFC }
-sBarItsNot = { r1 }
-
-vOneBarItThough = { r8 <d'\2>16( <c'\2>16) r8 <a\3>16 <c'\2>16 r8 <d'\2>16( <c'\2>16) r8 <a\3>8 }
-vTwoBarItThough = { <f\4>4 <f\4>4 <d\4>4 <d\4>4 }
-cBarItThough = { \cChordSetFD }
-sBarItThough = { r1 }
-
-vOneBarWhatYouThought = { r8 <g'\1>4 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>8 }
-vTwoBarWhatYouThought = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
-cBarWhatYouThought = { \cChordSetFC }
-sBarWhatYouThought = { r1 }
-
-vOneBarWhenYouFirst = { <e'\1>8 <d'\2>16( <c'\2>8) <a\3>8. <c'\2>4 <a\3>8 <c'\2>8 }
-vTwoBarWhenYouFirst = { <a,\5>4 <a,\5>8 <e\4>4 <a,\5>4 \skip 8 }
-cBarWhenYouFirst = { \cChordSetAm }
-sBarWhenYouFirst = { r1 }
-
-vOneBarYouGot = { <g'\1>8 <a\3>8 <g'\1>8 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>16( <a\3>16) }
-vTwoBarYouGot = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
-cBarYouGot = { \cChordSetFC }
-sBarYouGot = { r1 }
+vOneBarBeganIt = { \skip 4 <a\3 c'\2 >8 <g\3>8 \skip 4 <g\3 c'\2 >8 <g\3>8 }
+vTwoBarBeganIt = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
+cBarBeganIt = { \cChordSetFC }
+sBarBeganIt = { r1 }
+
+vOneBarItsNot = { r8 <g'\1>4 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>16( <a\3>16) }
+vTwoBarItsNot = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
+cBarItsNot = { \cChordSetFC }
+sBarItsNot = { r1 }
+
+vOneBarItThough = { r8 <d'\2>16( <c'\2>16) r8 <a\3>16 <c'\2>16 r8 <d'\2>16( <c'\2>16) r8 <a\3>8 }
+vTwoBarItThough = { <f\4>4 <f\4>4 <d\4>4 <d\4>4 }
+cBarItThough = { \cChordSetFD }
+sBarItThough = { r1 }
+
+vOneBarWhatYouThought = { r8 <g'\1>4 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>8 }
+vTwoBarWhatYouThought = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
+cBarWhatYouThought = { \cChordSetFC }
+sBarWhatYouThought = { r1 }
+
+vOneBarWhenYouFirst = { <e'\1>8 <d'\2>16( <c'\2>8) <a\3>8. <c'\2>4 <a\3>8 <c'\2>8 }
+vTwoBarWhenYouFirst = { <a,\5>4 <a,\5>8 <e\4>4 <a,\5>4 \skip 8 }
+cBarWhenYouFirst = { \cChordSetAm }
+sBarWhenYouFirst = { r1 }
+
+vOneBarYouGot = { <g'\1>8 <a\3>8 <g'\1>8 <a\3>16 <g'\1>8 <g\3>16 <e'\1>4 <g\3>16( <a\3>16) }
+vTwoBarYouGot = { <f\4>4 <f\4>4 <c\5>4 <e\4>4 }
+cBarYouGot = { \cChordSetFC }
+sBarYouGot = { r1 }
%-----------------------------------------------------------------------
View
@@ -44,6 +44,10 @@ def notes(value)
add Node::NoteSet.new(:value => value)
end
+ def partial(duration)
+ node.specified_duration = duration
+ end
+
def score(*names, &block)
add_names :names => names, :node_class => Node::Score, &block
end
View
@@ -1,6 +1,12 @@
module Gitara
module Node
class Bar < Base
+ has_value :specified_duration
+
+ def duration
+ specified_duration || 1
+ end
+
def first_bar_of_stanza?
stanza && stanza.descendants(Node::Bar)[0] == self
end
@@ -9,12 +15,16 @@ def note_sets
children.select{|child| child.is_a?(Node::NoteSet)}
end
+ def specified_duration_as_lilypond
+ specified_duration ? "\\partial #{specified_duration}" : nil
+ end
+
def stanza
self.ancestor(Node::Stanza)
end
def stanza_heading
- first_bar_of_stanza? ? %Q|r1^"#{ancestor(Node::Stanza).name}"| : "r1"
+ first_bar_of_stanza? ? %Q|r#{duration}^"#{ancestor(Node::Stanza).name}"| : "r#{duration}"
end
end
end
@@ -1,5 +1,5 @@
<% self.voiced_as(self.root.voices).each do |voiced_bar| %>
-<%= voiced_bar.definition_name %> = { <%= voiced_bar.matching_note_set.value %> }
+<%= voiced_bar.definition_name %> = { <%= voiced_bar.node.specified_duration_as_lilypond %> <%= voiced_bar.matching_note_set.value %> }
<% end %>
-<%= self.chorded.definition_name %> = { <%= self.chorded.value %> }
-<%= self.stanza_version.definition_name %> = { <%= self.stanza_version.value %> }
+<%= self.chorded.definition_name %> = { <%= self.specified_duration_as_lilypond %> <%= self.chorded.value %> }
+<%= self.stanza_version.definition_name %> = { <%= self.specified_duration_as_lilypond %> <%= self.stanza_version.value %> }
@@ -1,16 +1,35 @@
require 'spec_helper'
describe App do
- describe "export" do
- it "can convert a tab without a reused bar to lilypond" do
+ class AppTest < Valuable
+ has_value :name
+
+ def run
app = FactoryGirl.build(:app)
- app.invoke :export, ['examples/tab.rb'], "target-directory" => test_tmp_dir.path, "run-lilypond" => false
+ app.invoke :export, ["examples/#{name}.rb"], "target-directory" => test_tmp_dir.path, "run-lilypond" => false
+ (Pow("tmp") / "new-#{name}.ly").write actual if self.expected != self.actual
+ end
+
+ def expected
+ @expected ||= Pow("examples/#{name}.ly").read
+ end
- example = Pow('examples/tab.ly').read
- actual = (test_tmp_dir / 'tab.ly').read
+ def actual
+ @actual ||= (test_tmp_dir / "#{name}.ly").read
+ end
+ end
+
+ describe "export" do
+ it "can convert a tab to lilypond" do
+ app_test = AppTest.new(:name => 'tab')
+ app_test.run
+ app_test.actual.should == app_test.expected
+ end
- (Pow('tmp') / 'new-tab.ly').write actual if example != actual
- actual.should == example
+ it "can convert a tab with a partial to lilypond" do
+ app_test = AppTest.new(:name => 'tab-with-partial')
+ app_test.run
+ app_test.actual.should == app_test.expected
end
end
end
Oops, something went wrong.

0 comments on commit db31972

Please sign in to comment.