midi_lyrics 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de1fc14ed163e13a3b05eaddfcb29bd9b9d50948
4
- data.tar.gz: 07a79b70ea64ecfde9b52ac275a679c9f5995352
3
+ metadata.gz: 07b22e1ff4393dd7bdb547715aee9447120e18fd
4
+ data.tar.gz: d5cc38925318b678df054a00b8fd63ee43e49240
5
5
  SHA512:
6
- metadata.gz: e54f4f09be1608c63ea990e0c7952b305ab2b152cb027bb7cfe502712e95579ed55049551c4d2f5e25503a33a7efb997f95d37cc6888b2e97c9f8d98c795c7cd
7
- data.tar.gz: 482259a6013bb46532c15dbaee7395b81d2712d720a0b17ca540401a026082e51cdb27b9edb2532b2ed56a60a064e62e46043b0b1bad13048ee12af65a606010
6
+ metadata.gz: 4e2a905b89acb28eb50f2f00755cf822b341a554cb0707397cda6ba0c2393ec96ef41e5d19bc8e85e50796a63e637d7da868dc1da3170cbe1244ee2699b5a859
7
+ data.tar.gz: 557d80948ace9c3d79647cb57b7240f189e2190034146bf0450df0756d89355c901a43c2b2dc7952208435e64de649e8fb2ca34f8bf674221b4b392fcadbd1ca
@@ -1,3 +1,3 @@
1
1
  module MidiLyrics
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/midi_lyrics.rb CHANGED
@@ -64,6 +64,19 @@ module MidiLyrics
64
64
  end
65
65
  end
66
66
 
67
+ def extract
68
+ read_sequence_from_file
69
+ load_tracks
70
+ calculate_durations
71
+ load_lyrics
72
+ remove_heading_blank_lines
73
+ consolidate_empty_syllables
74
+ remove_lines_trailing_spaces
75
+ remove_repeating unless repeating
76
+ @lyrics.collect(&:as_json)
77
+ end
78
+
79
+ private
67
80
  def read_sequence_from_file
68
81
  @sequence = ::MIDI::Sequence.new()
69
82
  File.open(file, "rb") do | file |
@@ -169,17 +182,5 @@ module MidiLyrics
169
182
  merge_half_lyrics
170
183
  end
171
184
  end
172
-
173
- def extract
174
- read_sequence_from_file
175
- load_tracks
176
- calculate_durations
177
- load_lyrics
178
- remove_heading_blank_lines
179
- consolidate_empty_syllables
180
- remove_lines_trailing_spaces
181
- remove_repeating unless repeating
182
- @lyrics
183
- end
184
185
  end
185
186
  end
@@ -8,46 +8,10 @@ describe MidiLyrics do
8
8
  expect(MidiLyrics::Parser.new("spec/fixtures/one_note_one_syllable.mid").extract).to be_kind_of(Array)
9
9
  end
10
10
 
11
- context "accessing LyricSyllable attributes" do
12
- let(:lyrics) { MidiLyrics::Parser.new("spec/fixtures/repeating_lyrics.mid").extract }
13
-
14
- it "has text method" do
15
- expect(lyrics[1].text).to eq("ing")
16
- end
17
-
18
- it "has start_in_pulses method" do
19
- expect(lyrics[1].start_in_pulses).to eq(192)
20
- end
21
-
22
- it "has start method" do
23
- expect(lyrics[1].start).to eq(0.5)
24
- end
25
-
26
- it "has start2_in_pulses method" do
27
- expect(lyrics[1].start2_in_pulses).to eq(1152)
28
- end
29
-
30
- it "has start2 method" do
31
- expect(lyrics[1].start2).to eq(3.0)
32
- end
33
-
34
- it "has duration_in_pulses method" do
35
- expect(lyrics[1].duration_in_pulses).to eq(160)
36
- end
37
-
38
- it "has duration method" do
39
- expect(lyrics[1].duration).to eq(QUARTER_NOTE_DURATION)
40
- end
41
-
42
- it "has as_json method" do
43
- expect(lyrics[1].as_json).to eq({text: "ing", start: 0.5, start2: 3.0, duration: 0.417})
44
- end
45
- end
46
-
47
11
  context "file parsing" do
48
12
  it "parses one_note_one_syllable.mid correctly" do
49
13
  expect(
50
- MidiLyrics::Parser.new("spec/fixtures/one_note_one_syllable.mid").extract.collect(&:as_json)
14
+ MidiLyrics::Parser.new("spec/fixtures/one_note_one_syllable.mid").extract
51
15
  ).to eq([
52
16
  { text: "Test", start: 0.0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
53
17
  { text: "\r\n", start: QUARTER_NOTE_DURATION, start2: 0.0, duration: 0.0 }
@@ -56,7 +20,7 @@ describe MidiLyrics do
56
20
 
57
21
  it "parses one_note_two_syllable.mid correctly" do
58
22
  expect(
59
- MidiLyrics::Parser.new("spec/fixtures/one_note_two_syllable.mid").extract.collect(&:as_json)
23
+ MidiLyrics::Parser.new("spec/fixtures/one_note_two_syllable.mid").extract
60
24
  ).to eq([
61
25
  { text: "Test One", start: 0.0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
62
26
  { text: "\r\n", start: QUARTER_NOTE_DURATION, start2: 0.0, duration: 0.0 }
@@ -65,7 +29,7 @@ describe MidiLyrics do
65
29
 
66
30
  it "parses two_notes_one_syllable.mid correctly" do
67
31
  expect(
68
- MidiLyrics::Parser.new("spec/fixtures/two_notes_one_syllable.mid").extract.collect(&:as_json)
32
+ MidiLyrics::Parser.new("spec/fixtures/two_notes_one_syllable.mid").extract
69
33
  ).to eq([
70
34
  { text: "Test", start: 0, start2: 0.0, duration: 0.5 + QUARTER_NOTE_DURATION },
71
35
  { text: "\r\n", start: 0.5 + QUARTER_NOTE_DURATION, start2: 0.0, duration: 0.0 }
@@ -74,7 +38,7 @@ describe MidiLyrics do
74
38
 
75
39
  it "parses two_notes_two_syllables.mid correctly" do
76
40
  expect(
77
- MidiLyrics::Parser.new("spec/fixtures/two_notes_two_syllables.mid").extract.collect(&:as_json)
41
+ MidiLyrics::Parser.new("spec/fixtures/two_notes_two_syllables.mid").extract
78
42
  ).to eq([
79
43
  { text: "Test", start: 0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
80
44
  { text: "ing", start: 0.5, start2: 0.0, duration: QUARTER_NOTE_DURATION },
@@ -84,7 +48,7 @@ describe MidiLyrics do
84
48
 
85
49
  it "parses two_notes_three_syllables.mid correctly" do
86
50
  expect(
87
- MidiLyrics::Parser.new("spec/fixtures/two_notes_three_syllables.mid").extract.collect(&:as_json)
51
+ MidiLyrics::Parser.new("spec/fixtures/two_notes_three_syllables.mid").extract
88
52
  ).to eq([
89
53
  { text: "Hello, test", start: 0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
90
54
  { text: "ing", start: 0.5, start2: 0.0, duration: QUARTER_NOTE_DURATION },
@@ -94,7 +58,7 @@ describe MidiLyrics do
94
58
 
95
59
  it "parses spaces_and_returns.mid correctly" do
96
60
  expect(
97
- MidiLyrics::Parser.new("spec/fixtures/spaces_and_returns.mid").extract.collect(&:as_json)
61
+ MidiLyrics::Parser.new("spec/fixtures/spaces_and_returns.mid").extract
98
62
  ).to eq([
99
63
  { text: "Test", start: 0.5, start2: 0.0, duration: QUARTER_NOTE_DURATION },
100
64
  { text: "ing", start: 1, start2: 0.0, duration: QUARTER_NOTE_DURATION },
@@ -110,7 +74,7 @@ describe MidiLyrics do
110
74
 
111
75
  it "parses repeating_lyrics.mid correctly repeating" do
112
76
  expect(
113
- MidiLyrics::Parser.new("spec/fixtures/repeating_lyrics.mid", repeating: true).extract.collect(&:as_json)
77
+ MidiLyrics::Parser.new("spec/fixtures/repeating_lyrics.mid", repeating: true).extract
114
78
  ).to eq([
115
79
  { text: "Test", start: 0.0, start2: 0.0, duration: QUARTER_NOTE_DURATION },
116
80
  { text: "ing", start: 0.5, start2: 0.0, duration: QUARTER_NOTE_DURATION },
@@ -135,7 +99,7 @@ describe MidiLyrics do
135
99
 
136
100
  it "parses repeating_lyrics.mid correctly not repeating" do
137
101
  expect(
138
- MidiLyrics::Parser.new("spec/fixtures/repeating_lyrics.mid").extract.collect(&:as_json)
102
+ MidiLyrics::Parser.new("spec/fixtures/repeating_lyrics.mid").extract
139
103
  ).to eq([
140
104
  { text: "Test", start: 0.0, start2: 2.5, duration: QUARTER_NOTE_DURATION },
141
105
  { text: "ing", start: 0.5, start2: 3.0, duration: QUARTER_NOTE_DURATION },
@@ -174,13 +138,13 @@ describe MidiLyrics do
174
138
 
175
139
  it "parses complete_example.mid correctly repeating" do
176
140
  expect(
177
- MidiLyrics::Parser.new("spec/fixtures/complete_example.mid").extract.collect(&:as_json)
141
+ MidiLyrics::Parser.new("spec/fixtures/complete_example.mid").extract
178
142
  ).to eq(parsed_complete_example)
179
143
  end
180
144
 
181
145
  it "parses complete_example.mid correctly not repeating" do
182
146
  expect(
183
- MidiLyrics::Parser.new("spec/fixtures/complete_example.mid", repeating: true).extract.collect(&:as_json)
147
+ MidiLyrics::Parser.new("spec/fixtures/complete_example.mid", repeating: true).extract
184
148
  ).to eq(parsed_complete_example)
185
149
  end
186
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midi_lyrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateus Del Bianco