music-transcription 0.3.0

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.
Files changed (59) hide show
  1. data/.document +3 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +1 -0
  5. data/ChangeLog.rdoc +4 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.rdoc +28 -0
  9. data/Rakefile +54 -0
  10. data/bin/transcribe +176 -0
  11. data/lib/music-transcription.rb +20 -0
  12. data/lib/music-transcription/arrangement.rb +31 -0
  13. data/lib/music-transcription/instrument_config.rb +38 -0
  14. data/lib/music-transcription/interval.rb +66 -0
  15. data/lib/music-transcription/link.rb +115 -0
  16. data/lib/music-transcription/note.rb +156 -0
  17. data/lib/music-transcription/part.rb +128 -0
  18. data/lib/music-transcription/pitch.rb +297 -0
  19. data/lib/music-transcription/pitch_constants.rb +204 -0
  20. data/lib/music-transcription/profile.rb +105 -0
  21. data/lib/music-transcription/program.rb +136 -0
  22. data/lib/music-transcription/score.rb +122 -0
  23. data/lib/music-transcription/tempo.rb +44 -0
  24. data/lib/music-transcription/transition.rb +71 -0
  25. data/lib/music-transcription/value_change.rb +85 -0
  26. data/lib/music-transcription/version.rb +7 -0
  27. data/music-transcription.gemspec +36 -0
  28. data/samples/arrangements/glissando_test.yml +71 -0
  29. data/samples/arrangements/hip.yml +952 -0
  30. data/samples/arrangements/instrument_test.yml +119 -0
  31. data/samples/arrangements/legato_test.yml +237 -0
  32. data/samples/arrangements/make_glissando_test.rb +27 -0
  33. data/samples/arrangements/make_hip.rb +75 -0
  34. data/samples/arrangements/make_instrument_test.rb +34 -0
  35. data/samples/arrangements/make_legato_test.rb +37 -0
  36. data/samples/arrangements/make_missed_connection.rb +72 -0
  37. data/samples/arrangements/make_portamento_test.rb +27 -0
  38. data/samples/arrangements/make_slur_test.rb +37 -0
  39. data/samples/arrangements/make_song1.rb +84 -0
  40. data/samples/arrangements/make_song2.rb +69 -0
  41. data/samples/arrangements/missed_connection.yml +481 -0
  42. data/samples/arrangements/portamento_test.yml +71 -0
  43. data/samples/arrangements/slur_test.yml +237 -0
  44. data/samples/arrangements/song1.yml +640 -0
  45. data/samples/arrangements/song2.yml +429 -0
  46. data/spec/instrument_config_spec.rb +47 -0
  47. data/spec/interval_spec.rb +38 -0
  48. data/spec/link_spec.rb +22 -0
  49. data/spec/musicality_spec.rb +7 -0
  50. data/spec/note_spec.rb +65 -0
  51. data/spec/part_spec.rb +87 -0
  52. data/spec/pitch_spec.rb +139 -0
  53. data/spec/profile_spec.rb +24 -0
  54. data/spec/program_spec.rb +55 -0
  55. data/spec/score_spec.rb +55 -0
  56. data/spec/spec_helper.rb +23 -0
  57. data/spec/transition_spec.rb +13 -0
  58. data/spec/value_change_spec.rb +19 -0
  59. metadata +239 -0
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Music::Transcription::Arrangement
2
+ score: !ruby/object:Music::Transcription::TempoScore
3
+ tempo_profile: !ruby/object:Music::Transcription::Profile
4
+ start_value: !ruby/object:Music::Transcription::Tempo
5
+ beats_per_minute: 120
6
+ beat_duration: !ruby/object:Rational
7
+ denominator: 4
8
+ numerator: 1
9
+ value_changes: {}
10
+ parts:
11
+ 1: !ruby/object:Music::Transcription::Part
12
+ offset: 0
13
+ loudness_profile: !ruby/object:Music::Transcription::Profile
14
+ start_value: 0.5
15
+ value_changes: {}
16
+ notes:
17
+ - !ruby/object:Music::Transcription::Note
18
+ duration: 0.125
19
+ intervals:
20
+ - !ruby/object:Music::Transcription::Interval
21
+ pitch: &20734400 !ruby/object:Music::Transcription::Pitch
22
+ cents_per_octave: 1200
23
+ octave: 3
24
+ semitone: 0
25
+ cent: 0
26
+ base_freq: 16.351597831287414
27
+ link: !ruby/object:Music::Transcription::Link
28
+ target_pitch: !ruby/object:Music::Transcription::Pitch
29
+ cents_per_octave: 1200
30
+ octave: 0
31
+ semitone: 0
32
+ cent: 0
33
+ base_freq: 16.351597831287414
34
+ relationship: :none
35
+ sustain: 0.5
36
+ attack: 0.5
37
+ separation: 0.5
38
+ - !ruby/object:Music::Transcription::Note
39
+ duration: 0.125
40
+ intervals:
41
+ - !ruby/object:Music::Transcription::Interval
42
+ pitch: !ruby/object:Music::Transcription::Pitch
43
+ cents_per_octave: 1200
44
+ octave: 3
45
+ semitone: 2
46
+ cent: 0
47
+ base_freq: 16.351597831287414
48
+ link: !ruby/object:Music::Transcription::Link
49
+ target_pitch: !ruby/object:Music::Transcription::Pitch
50
+ cents_per_octave: 1200
51
+ octave: 0
52
+ semitone: 0
53
+ cent: 0
54
+ base_freq: 16.351597831287414
55
+ relationship: :none
56
+ sustain: 0.5
57
+ attack: 0.5
58
+ separation: 0.5
59
+ - !ruby/object:Music::Transcription::Note
60
+ duration: 0.25
61
+ intervals:
62
+ - !ruby/object:Music::Transcription::Interval
63
+ pitch: *20734400
64
+ link: !ruby/object:Music::Transcription::Link
65
+ target_pitch: !ruby/object:Music::Transcription::Pitch
66
+ cents_per_octave: 1200
67
+ octave: 0
68
+ semitone: 0
69
+ cent: 0
70
+ base_freq: 16.351597831287414
71
+ relationship: :none
72
+ sustain: 0.5
73
+ attack: 0.5
74
+ separation: 0.5
75
+ - !ruby/object:Music::Transcription::Note
76
+ duration: 0.5
77
+ intervals:
78
+ - !ruby/object:Music::Transcription::Interval
79
+ pitch: *20734400
80
+ link: !ruby/object:Music::Transcription::Link
81
+ target_pitch: !ruby/object:Music::Transcription::Pitch
82
+ cents_per_octave: 1200
83
+ octave: 0
84
+ semitone: 0
85
+ cent: 0
86
+ base_freq: 16.351597831287414
87
+ relationship: :none
88
+ - !ruby/object:Music::Transcription::Interval
89
+ pitch: !ruby/object:Music::Transcription::Pitch
90
+ cents_per_octave: 1200
91
+ octave: 3
92
+ semitone: 4
93
+ cent: 0
94
+ base_freq: 16.351597831287414
95
+ link: !ruby/object:Music::Transcription::Link
96
+ target_pitch: !ruby/object:Music::Transcription::Pitch
97
+ cents_per_octave: 1200
98
+ octave: 0
99
+ semitone: 0
100
+ cent: 0
101
+ base_freq: 16.351597831287414
102
+ relationship: :none
103
+ sustain: 0.5
104
+ attack: 0.5
105
+ separation: 0.5
106
+ program: !ruby/object:Music::Transcription::Program
107
+ segments:
108
+ - !ruby/range
109
+ begin: 0
110
+ end: 1.0
111
+ excl: true
112
+ instrument_configs:
113
+ 1: !ruby/object:Music::Transcription::InstrumentConfig
114
+ plugin_name: synth_instr_3
115
+ initial_settings:
116
+ - blend
117
+ - short attack
118
+ - long decay
119
+ setting_changes: {}
@@ -0,0 +1,237 @@
1
+ --- !ruby/object:Music::Transcription::Arrangement
2
+ score: !ruby/object:Music::Transcription::TempoScore
3
+ tempo_profile: !ruby/object:Music::Transcription::Profile
4
+ start_value: !ruby/object:Music::Transcription::Tempo
5
+ beats_per_minute: 120
6
+ beat_duration: !ruby/object:Rational
7
+ denominator: 4
8
+ numerator: 1
9
+ value_changes: {}
10
+ parts:
11
+ 1: !ruby/object:Music::Transcription::Part
12
+ offset: 0
13
+ loudness_profile: !ruby/object:Music::Transcription::Profile
14
+ start_value: 0.5
15
+ value_changes: {}
16
+ notes:
17
+ - !ruby/object:Music::Transcription::Note
18
+ duration: 0.25
19
+ intervals:
20
+ - !ruby/object:Music::Transcription::Interval
21
+ pitch: &13618520 !ruby/object:Music::Transcription::Pitch
22
+ cents_per_octave: 1200
23
+ octave: 3
24
+ semitone: 0
25
+ cent: 0
26
+ base_freq: 16.351597831287414
27
+ link: !ruby/object:Music::Transcription::Link
28
+ target_pitch: !ruby/object:Music::Transcription::Pitch
29
+ cents_per_octave: 1200
30
+ octave: 0
31
+ semitone: 0
32
+ cent: 0
33
+ base_freq: 16.351597831287414
34
+ relationship: :none
35
+ sustain: 0.5
36
+ attack: 0.5
37
+ separation: 0.5
38
+ - !ruby/object:Music::Transcription::Note
39
+ duration: 0.25
40
+ intervals:
41
+ - !ruby/object:Music::Transcription::Interval
42
+ pitch: &13617440 !ruby/object:Music::Transcription::Pitch
43
+ cents_per_octave: 1200
44
+ octave: 3
45
+ semitone: 2
46
+ cent: 0
47
+ base_freq: 16.351597831287414
48
+ link: !ruby/object:Music::Transcription::Link
49
+ target_pitch: !ruby/object:Music::Transcription::Pitch
50
+ cents_per_octave: 1200
51
+ octave: 0
52
+ semitone: 0
53
+ cent: 0
54
+ base_freq: 16.351597831287414
55
+ relationship: :none
56
+ sustain: 0.5
57
+ attack: 0.5
58
+ separation: 0.5
59
+ - !ruby/object:Music::Transcription::Note
60
+ duration: 0.25
61
+ intervals:
62
+ - !ruby/object:Music::Transcription::Interval
63
+ pitch: &13616520 !ruby/object:Music::Transcription::Pitch
64
+ cents_per_octave: 1200
65
+ octave: 3
66
+ semitone: 4
67
+ cent: 0
68
+ base_freq: 16.351597831287414
69
+ link: !ruby/object:Music::Transcription::Link
70
+ target_pitch: !ruby/object:Music::Transcription::Pitch
71
+ cents_per_octave: 1200
72
+ octave: 0
73
+ semitone: 0
74
+ cent: 0
75
+ base_freq: 16.351597831287414
76
+ relationship: :none
77
+ sustain: 0.5
78
+ attack: 0.5
79
+ separation: 0.5
80
+ - !ruby/object:Music::Transcription::Note
81
+ duration: 0.25
82
+ intervals:
83
+ - !ruby/object:Music::Transcription::Interval
84
+ pitch: &13616080 !ruby/object:Music::Transcription::Pitch
85
+ cents_per_octave: 1200
86
+ octave: 3
87
+ semitone: 5
88
+ cent: 0
89
+ base_freq: 16.351597831287414
90
+ link: !ruby/object:Music::Transcription::Link
91
+ target_pitch: !ruby/object:Music::Transcription::Pitch
92
+ cents_per_octave: 1200
93
+ octave: 0
94
+ semitone: 0
95
+ cent: 0
96
+ base_freq: 16.351597831287414
97
+ relationship: :none
98
+ sustain: 0.5
99
+ attack: 0.5
100
+ separation: 0.5
101
+ - !ruby/object:Music::Transcription::Note
102
+ duration: 0.25
103
+ intervals:
104
+ - !ruby/object:Music::Transcription::Interval
105
+ pitch: *13616520
106
+ link: !ruby/object:Music::Transcription::Link
107
+ target_pitch: !ruby/object:Music::Transcription::Pitch
108
+ cents_per_octave: 1200
109
+ octave: 0
110
+ semitone: 0
111
+ cent: 0
112
+ base_freq: 16.351597831287414
113
+ relationship: :none
114
+ sustain: 0.5
115
+ attack: 0.5
116
+ separation: 0.5
117
+ - !ruby/object:Music::Transcription::Note
118
+ duration: 0.25
119
+ intervals:
120
+ - !ruby/object:Music::Transcription::Interval
121
+ pitch: *13617440
122
+ link: !ruby/object:Music::Transcription::Link
123
+ target_pitch: !ruby/object:Music::Transcription::Pitch
124
+ cents_per_octave: 1200
125
+ octave: 0
126
+ semitone: 0
127
+ cent: 0
128
+ base_freq: 16.351597831287414
129
+ relationship: :none
130
+ sustain: 0.5
131
+ attack: 0.5
132
+ separation: 0.5
133
+ - !ruby/object:Music::Transcription::Note
134
+ duration: 0.5
135
+ intervals:
136
+ - !ruby/object:Music::Transcription::Interval
137
+ pitch: *13618520
138
+ link: !ruby/object:Music::Transcription::Link
139
+ target_pitch: !ruby/object:Music::Transcription::Pitch
140
+ cents_per_octave: 1200
141
+ octave: 0
142
+ semitone: 0
143
+ cent: 0
144
+ base_freq: 16.351597831287414
145
+ relationship: :none
146
+ sustain: 0.5
147
+ attack: 0.5
148
+ separation: 0.5
149
+ - !ruby/object:Music::Transcription::Note
150
+ duration: 0.25
151
+ intervals:
152
+ - !ruby/object:Music::Transcription::Interval
153
+ pitch: *13618520
154
+ link: !ruby/object:Music::Transcription::Link
155
+ target_pitch: *13617440
156
+ relationship: :legato
157
+ sustain: 0.5
158
+ attack: 0.5
159
+ separation: 0.5
160
+ - !ruby/object:Music::Transcription::Note
161
+ duration: 0.25
162
+ intervals:
163
+ - !ruby/object:Music::Transcription::Interval
164
+ pitch: *13617440
165
+ link: !ruby/object:Music::Transcription::Link
166
+ target_pitch: *13616520
167
+ relationship: :legato
168
+ sustain: 0.5
169
+ attack: 0.5
170
+ separation: 0.5
171
+ - !ruby/object:Music::Transcription::Note
172
+ duration: 0.25
173
+ intervals:
174
+ - !ruby/object:Music::Transcription::Interval
175
+ pitch: *13616520
176
+ link: !ruby/object:Music::Transcription::Link
177
+ target_pitch: *13616080
178
+ relationship: :legato
179
+ sustain: 0.5
180
+ attack: 0.5
181
+ separation: 0.5
182
+ - !ruby/object:Music::Transcription::Note
183
+ duration: 0.25
184
+ intervals:
185
+ - !ruby/object:Music::Transcription::Interval
186
+ pitch: *13616080
187
+ link: !ruby/object:Music::Transcription::Link
188
+ target_pitch: *13616520
189
+ relationship: :legato
190
+ sustain: 0.5
191
+ attack: 0.5
192
+ separation: 0.5
193
+ - !ruby/object:Music::Transcription::Note
194
+ duration: 0.25
195
+ intervals:
196
+ - !ruby/object:Music::Transcription::Interval
197
+ pitch: *13616520
198
+ link: !ruby/object:Music::Transcription::Link
199
+ target_pitch: *13617440
200
+ relationship: :legato
201
+ sustain: 0.5
202
+ attack: 0.5
203
+ separation: 0.5
204
+ - !ruby/object:Music::Transcription::Note
205
+ duration: 0.25
206
+ intervals:
207
+ - !ruby/object:Music::Transcription::Interval
208
+ pitch: *13617440
209
+ link: !ruby/object:Music::Transcription::Link
210
+ target_pitch: *13618520
211
+ relationship: :legato
212
+ sustain: 0.5
213
+ attack: 0.5
214
+ separation: 0.5
215
+ - !ruby/object:Music::Transcription::Note
216
+ duration: 0.5
217
+ intervals:
218
+ - !ruby/object:Music::Transcription::Interval
219
+ pitch: *13618520
220
+ link: !ruby/object:Music::Transcription::Link
221
+ target_pitch: !ruby/object:Music::Transcription::Pitch
222
+ cents_per_octave: 1200
223
+ octave: 0
224
+ semitone: 0
225
+ cent: 0
226
+ base_freq: 16.351597831287414
227
+ relationship: :none
228
+ sustain: 0.5
229
+ attack: 0.5
230
+ separation: 0.5
231
+ program: !ruby/object:Music::Transcription::Program
232
+ segments:
233
+ - !ruby/range
234
+ begin: 0
235
+ end: 4.0
236
+ excl: true
237
+ instrument_configs: {}
@@ -0,0 +1,27 @@
1
+ require 'music-transcription'
2
+ require 'yaml'
3
+
4
+ include Music::Transcription
5
+
6
+ arrangement = Arrangement.new(
7
+ :score => TempoScore.new(
8
+ :program => Program.new(
9
+ :segments => [0...4.0]
10
+ ),
11
+ :tempo_profile => profile(tempo(120)),
12
+ :parts => {
13
+ 1 => Part.new(
14
+ :loudness_profile => profile(0.5),
15
+ :notes => [
16
+ note(0.75, [ interval(C3, glissando(F3)) ]),
17
+ note(0.75, [ interval(F3, glissando(C3)) ]),
18
+ note(0.5, [ interval(C3) ]),
19
+ ]
20
+ )
21
+ }
22
+ )
23
+ )
24
+
25
+ File.open("glissando_test.yml", "w") do |file|
26
+ file.write arrangement.to_yaml
27
+ end
@@ -0,0 +1,75 @@
1
+ require 'music-transcription'
2
+ require 'yaml'
3
+
4
+ include Music::Transcription
5
+
6
+ bass_riff = [
7
+ # 0.0
8
+ note(Rational(1,6), [ interval(Bb2) ]),
9
+ note(Rational(1,4)),
10
+ note(Rational(1,3), [ interval(Ab2) ]),
11
+ note(Rational(1,6), [ interval(F2) ]),
12
+ note(Rational(1,12), [ interval(Ab2) ]),
13
+ # 1.0
14
+ note(Rational(1,6), [ interval(Bb2) ]),
15
+ note(Rational(1,4)),
16
+ note(Rational(1,3), [ interval(Ab2) ]),
17
+ note(Rational(1,4), [ interval(Ab2) ]),
18
+ ]
19
+
20
+ lead_riff = [
21
+ # 0.0
22
+ note(Rational(1,6), [ interval(Bb3) ]),
23
+ note(Rational(1,4)),
24
+ note(Rational(1,12), [ interval(Db4, tie(Db4))]),
25
+ note(Rational(1,6), [ interval(Db4, tie(Db4))]),
26
+ note(Rational(1,36), [ interval(Db4)]),
27
+ note(Rational(1,36), [ interval(Eb4)]),
28
+ note(Rational(1,36), [ interval(Db4)]),
29
+ note(Rational(1,6), [ interval(Ab3)]),
30
+ note(Rational(1,12), [ interval(Db4)]),
31
+ # 1.0
32
+ note(Rational(1,6), [ interval(Bb3) ]),
33
+ note(Rational(1,4)),
34
+ note(Rational(1,12), [ interval(Db4, tie(Db4))]),
35
+ note(Rational(1,4), [ interval(Db4, tie(Db4))]),
36
+ note(Rational(1,8), [ interval(Db4, portamento(C4))]),
37
+ note(Rational(1,8), [ interval(C4)]),
38
+ ]
39
+
40
+ whole_step = Pitch.new(:semitone => 2)
41
+ bass_notes = bass_riff + bass_riff.map {|note| note.transpose(whole_step) }
42
+ lead_notes = lead_riff + lead_riff.map {|note| note.transpose(whole_step) }
43
+
44
+ arrangement = Arrangement.new(
45
+ :score => TempoScore.new(
46
+ :program => Program.new(
47
+ :segments => [0...2, 0...2,2...4,0...2]
48
+ ),
49
+ :tempo_profile => profile(tempo(120)),
50
+ :parts => {
51
+ "lead" => Part.new(
52
+ :notes => lead_notes,
53
+ :loudness_profile => profile(0.5)
54
+ ),
55
+ "bass" => Part.new(
56
+ :notes => bass_notes,
57
+ :loudness_profile => profile(0.125)
58
+ )
59
+ }
60
+ ),
61
+ :instrument_configs => {
62
+ 'bass' => InstrumentConfig.new(
63
+ :plugin_name => "synth_instr_1",
64
+ :initial_settings => ["sawtooth"]
65
+ ),
66
+ 'lead' => InstrumentConfig.new(
67
+ :plugin_name => "synth_instr_3",
68
+ :initial_settings => ["blend", "very short attack", "med decay"]
69
+ ),
70
+ }
71
+ )
72
+
73
+ File.open('hip.yml','w') do |file|
74
+ file.write arrangement.to_yaml
75
+ end