music-transcription 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/examples/{make_hip.rb → hip.rb} +8 -2
  4. data/examples/hip_packed.yml +22 -0
  5. data/examples/{make_missed_connection.rb → missed_connection.rb} +8 -2
  6. data/examples/missed_connection.yml +2 -2
  7. data/examples/missed_connection_packed.yml +14 -0
  8. data/examples/{make_song1.rb → song1.rb} +7 -1
  9. data/examples/song1_packed.yml +19 -0
  10. data/examples/{make_song2.rb → song2.rb} +6 -1
  11. data/examples/song2_packed.yml +21 -0
  12. data/lib/music-transcription.rb +11 -3
  13. data/lib/music-transcription/model/link.rb +24 -6
  14. data/lib/music-transcription/model/meter.rb +10 -0
  15. data/lib/music-transcription/model/meters.rb +1 -1
  16. data/lib/music-transcription/model/note.rb +32 -0
  17. data/lib/music-transcription/model/pitch.rb +19 -0
  18. data/lib/music-transcription/packing/change_packing.rb +27 -0
  19. data/lib/music-transcription/packing/part_packing.rb +33 -0
  20. data/lib/music-transcription/packing/program_packing.rb +18 -0
  21. data/lib/music-transcription/packing/score_packing.rb +59 -0
  22. data/lib/music-transcription/parsing/convenience_methods.rb +10 -0
  23. data/lib/music-transcription/parsing/meter_parsing.rb +117 -9
  24. data/lib/music-transcription/parsing/meter_parsing.treetop +12 -0
  25. data/lib/music-transcription/parsing/note_node.rb +42 -0
  26. data/lib/music-transcription/parsing/note_parsing.rb +57 -180
  27. data/lib/music-transcription/parsing/note_parsing.treetop +2 -19
  28. data/lib/music-transcription/parsing/numbers/nonnegative_float_parsing.rb +178 -0
  29. data/lib/music-transcription/parsing/numbers/nonnegative_float_parsing.treetop +19 -0
  30. data/lib/music-transcription/parsing/{nonnegative_integer_parsing.rb → numbers/nonnegative_integer_parsing.rb} +9 -0
  31. data/lib/music-transcription/parsing/{nonnegative_integer_parsing.treetop → numbers/nonnegative_integer_parsing.treetop} +7 -1
  32. data/lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.rb +88 -0
  33. data/lib/music-transcription/parsing/numbers/nonnegative_rational_parsing.treetop +22 -0
  34. data/lib/music-transcription/parsing/{positive_integer_parsing.rb → numbers/positive_integer_parsing.rb} +0 -0
  35. data/lib/music-transcription/parsing/{positive_integer_parsing.treetop → numbers/positive_integer_parsing.treetop} +0 -0
  36. data/lib/music-transcription/parsing/segment_parsing.rb +143 -0
  37. data/lib/music-transcription/parsing/segment_parsing.treetop +25 -0
  38. data/lib/music-transcription/version.rb +1 -1
  39. data/spec/model/link_spec.rb +44 -60
  40. data/spec/model/meter_spec.rb +18 -0
  41. data/spec/model/note_spec.rb +39 -0
  42. data/spec/model/pitch_spec.rb +32 -0
  43. data/spec/packing/change_packing_spec.rb +91 -0
  44. data/spec/packing/part_packing_spec.rb +66 -0
  45. data/spec/packing/program_packing_spec.rb +33 -0
  46. data/spec/packing/score_packing_spec.rb +122 -0
  47. data/spec/parsing/meter_parsing_spec.rb +2 -2
  48. data/spec/parsing/note_node_spec.rb +87 -0
  49. data/spec/parsing/note_parsing_spec.rb +3 -0
  50. data/spec/parsing/numbers/nonnegative_float_spec.rb +11 -0
  51. data/spec/parsing/{nonnegative_integer_spec.rb → numbers/nonnegative_integer_spec.rb} +1 -1
  52. data/spec/parsing/numbers/nonnegative_rational_spec.rb +11 -0
  53. data/spec/parsing/{positive_integer_spec.rb → numbers/positive_integer_spec.rb} +1 -1
  54. data/spec/parsing/segment_parsing_spec.rb +27 -0
  55. metadata +45 -17
  56. data/lib/music-transcription/parsing/note_nodes.rb +0 -64
  57. data/spec/parsing/note_nodes_spec.rb +0 -84
@@ -1,84 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- NOTE_PARSER = Parsing::NoteParser.new
4
-
5
- describe Parsing::RestNoteNode do
6
- {
7
- '/2' => Note.new(Rational(1,2)),
8
- '4/2' => Note.new(Rational(4,2)),
9
- '28' => Note.new(Rational(28,1)),
10
- '56/33' => Note.new(Rational(56,33)),
11
- }.each do |str,tgt|
12
- res = NOTE_PARSER.parse(str)
13
- context str do
14
- it 'should parse as RestNoteNode' do
15
- res.should be_a Parsing::RestNoteNode
16
- end
17
-
18
- describe '#to_note' do
19
- n = res.to_note
20
- it 'should produce a Note' do
21
- n.should be_a Note
22
- end
23
-
24
- it 'should produce value matching input str' do
25
- n.should eq tgt
26
- end
27
- end
28
- end
29
- end
30
- end
31
-
32
- describe Parsing::MonophonicNoteNode do
33
- {
34
- '/2=C2=C2' => Note.new(Rational(1,2),[C2],articulation:SLUR, links:{C2=>Link::Slur.new(C2)}),
35
- '4/2.D#6' => Note.new(Rational(4,2),[Eb6],articulation:STACCATO),
36
- '28%Eb7!' => Note.new(Rational(28,1),[Eb7],articulation:PORTATO, accented: true),
37
- "56/33'B1" => Note.new(Rational(56,33),[B1],articulation:STACCATISSIMO),
38
- }.each do |str,tgt|
39
- res = NOTE_PARSER.parse(str)
40
- context str do
41
- it 'should parse as MonophonicNoteNode' do
42
- res.should be_a Parsing::MonophonicNoteNode
43
- end
44
-
45
- describe '#to_note' do
46
- n = res.to_note
47
- it 'should produce a Note' do
48
- n.should be_a Note
49
- end
50
-
51
- it 'should produce value matching input str' do
52
- n.should eq tgt
53
- end
54
- end
55
- end
56
- end
57
- end
58
-
59
- describe Parsing::PolyphonicNoteNode do
60
- {
61
- '/2C2,D2,E2-F2' => Note.new(Rational(1,2),[C2,D2,E2],links:{E2=>Link::Legato.new(F2)}),
62
- '4/2.D#6,G4' => Note.new(Rational(4,2),[Eb6,G4], articulation:STACCATO),
63
- '28_Eb7,D7,G7' => Note.new(Rational(28,1),[Eb7,D7,G7],articulation:TENUTO),
64
- '56/33B1,B2,B3,B4,B5!' => Note.new(Rational(56,33),[B1,B2,B3,B4,B5], accented: true),
65
- }.each do |str,tgt|
66
- res = NOTE_PARSER.parse(str)
67
- context str do
68
- it 'should parse as PolyphonicNoteNode' do
69
- res.should be_a Parsing::PolyphonicNoteNode
70
- end
71
-
72
- describe '#to_note' do
73
- n = res.to_note
74
- it 'should produce a Note' do
75
- n.should be_a Note
76
- end
77
-
78
- it 'should produce value matching input str' do
79
- n.should eq tgt
80
- end
81
- end
82
- end
83
- end
84
- end