midi_lyrics 0.0.7 → 0.0.8
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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/midi_lyrics/version.rb +1 -1
- data/lib/midi_lyrics.rb +18 -13
- data/spec/fixtures/two_notes_two_syllables_dash.mid +0 -0
- data/spec/fixtures/two_notes_two_syllables_dash.nwc +0 -0
- data/spec/midi_lyrics_spec.rb +10 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a310168013f34acd05cac16d712dd0d8e8cc23e
|
4
|
+
data.tar.gz: cd5b78485d19c94f551e67142f2c22690ff19e2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d57f45820e56a7d6ab6ee2f0d327bc89c0e1327c09b68bc9249bc610def44dfcfc61b45f896d171dac12e6943c620a976f597e2ccfbcf124d2057111ddaf8a0
|
7
|
+
data.tar.gz: 343f76df6de80b0a407932feae49bc36126211ed7a2fa96f9ccab3c4c8873da808ca7ccc048314f78a5c5e3c2c58616f7e85da765412da7ef4e434ce2e08577b
|
data/README.md
CHANGED
@@ -20,11 +20,11 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
>> MidiLyrics::Parser.new("test.mid").extract
|
23
|
+
>> MidiLyrics::Parser.new("test.mid").extract
|
24
24
|
=> [
|
25
|
-
{ text: "Test",
|
26
|
-
{ text: "ing",
|
27
|
-
{ text: "\r\n", start: 0.917, start2: 0.0, duration: 0
|
25
|
+
{ text: "Test", start: 0, start2: 0.0, duration: 0.417 },
|
26
|
+
{ text: "ing", start: 0.5, start2: 0.0, duration: 0.417 },
|
27
|
+
{ text: "\r\n", start: 0.917, start2: 0.0, duration: 0.0 }
|
28
28
|
]
|
29
29
|
|
30
30
|
## Contributing
|
data/lib/midi_lyrics/version.rb
CHANGED
data/lib/midi_lyrics.rb
CHANGED
@@ -29,7 +29,7 @@ module MidiLyrics
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def blank?
|
32
|
-
text.strip == ""
|
32
|
+
text.gsub('-', '').strip == ""
|
33
33
|
end
|
34
34
|
|
35
35
|
def similar_to?(another)
|
@@ -109,12 +109,12 @@ module MidiLyrics
|
|
109
109
|
@lyrics = []
|
110
110
|
@lyrics_track.each do |event|
|
111
111
|
event_text = event.data.collect{|x| x.chr(Encoding::UTF_8)}.join
|
112
|
-
letters = event_text.gsub(
|
112
|
+
letters = event_text.gsub(/^[\s-]+|[\s-]+$/, '')
|
113
113
|
|
114
|
-
heading_space = event_text.match(/^(\s+)[
|
114
|
+
heading_space = event_text.match(/^([\s-]+)[^[\s-]]/)
|
115
115
|
heading_space = heading_space[1] unless heading_space.nil?
|
116
116
|
|
117
|
-
trailing_space = event_text.match(/(\s+)$/)
|
117
|
+
trailing_space = event_text.match(/([\s-]+)$/)
|
118
118
|
trailing_space = trailing_space[1] unless trailing_space.nil?
|
119
119
|
|
120
120
|
[heading_space, letters, trailing_space].each do |text|
|
@@ -131,7 +131,7 @@ module MidiLyrics
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def remove_heading_blank_lines
|
134
|
-
while @lyrics.first.
|
134
|
+
while @lyrics.first.blank?
|
135
135
|
@lyrics.shift
|
136
136
|
end
|
137
137
|
end
|
@@ -140,13 +140,18 @@ module MidiLyrics
|
|
140
140
|
new_lyrics = []
|
141
141
|
@lyrics.each do |l|
|
142
142
|
if l.blank?
|
143
|
-
if new_lyrics.last
|
144
|
-
new_lyrics.last.
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
143
|
+
# if new_lyrics.last
|
144
|
+
if new_lyrics.last.blank?
|
145
|
+
new_lyrics.last.text += l.text
|
146
|
+
else
|
147
|
+
l.start_in_pulses = new_lyrics.last.start_in_pulses + new_lyrics.last.duration_in_pulses
|
148
|
+
l.duration_in_pulses = 0.0
|
149
|
+
new_lyrics << l
|
150
|
+
end
|
151
|
+
# else
|
152
|
+
# l.duration_in_pulses = 0.0
|
153
|
+
# new_lyrics << l
|
154
|
+
# end
|
150
155
|
else
|
151
156
|
new_lyrics << l
|
152
157
|
end
|
@@ -156,7 +161,7 @@ module MidiLyrics
|
|
156
161
|
|
157
162
|
def remove_lines_trailing_spaces
|
158
163
|
@lyrics.each do |l|
|
159
|
-
l.text.gsub!(/^ ([\r\n])/, '\1')
|
164
|
+
l.text.gsub!(/^[ -]*([\r\n])/, '\1')
|
160
165
|
end
|
161
166
|
end
|
162
167
|
|
Binary file
|
Binary file
|
data/spec/midi_lyrics_spec.rb
CHANGED
@@ -46,6 +46,16 @@ describe MidiLyrics do
|
|
46
46
|
])
|
47
47
|
end
|
48
48
|
|
49
|
+
it "parses two_notes_two_syllables_dash.mid correctly" do
|
50
|
+
expect(
|
51
|
+
MidiLyrics::Parser.new("spec/fixtures/two_notes_two_syllables_dash.mid").extract
|
52
|
+
).to eq([
|
53
|
+
{ text: "Test", start: 0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
|
54
|
+
{ text: "ing", start: 0.5, start2: 0.0, duration: QUARTER_NOTE_DURATION },
|
55
|
+
{ text: "\r\n", start: 0.5 + QUARTER_NOTE_DURATION, start2: 0.0, duration: 0.0 }
|
56
|
+
])
|
57
|
+
end
|
58
|
+
|
49
59
|
it "parses two_notes_three_syllables.mid correctly" do
|
50
60
|
expect(
|
51
61
|
MidiLyrics::Parser.new("spec/fixtures/two_notes_three_syllables.mid").extract
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midi_lyrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateus Del Bianco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,6 +101,8 @@ files:
|
|
101
101
|
- spec/fixtures/two_notes_three_syllables.nwc
|
102
102
|
- spec/fixtures/two_notes_two_syllables.mid
|
103
103
|
- spec/fixtures/two_notes_two_syllables.nwc
|
104
|
+
- spec/fixtures/two_notes_two_syllables_dash.mid
|
105
|
+
- spec/fixtures/two_notes_two_syllables_dash.nwc
|
104
106
|
- spec/midi_lyrics_spec.rb
|
105
107
|
- spec/spec_helper.rb
|
106
108
|
homepage: https://github.com/mateusdelbianco/midi_lyrics
|
@@ -144,5 +146,7 @@ test_files:
|
|
144
146
|
- spec/fixtures/two_notes_three_syllables.nwc
|
145
147
|
- spec/fixtures/two_notes_two_syllables.mid
|
146
148
|
- spec/fixtures/two_notes_two_syllables.nwc
|
149
|
+
- spec/fixtures/two_notes_two_syllables_dash.mid
|
150
|
+
- spec/fixtures/two_notes_two_syllables_dash.nwc
|
147
151
|
- spec/midi_lyrics_spec.rb
|
148
152
|
- spec/spec_helper.rb
|