mml2wav 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +12 -0
- data/lib/mml2wav/parser.rb +23 -5
- data/lib/mml2wav/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cbdd2cc35197a65e4d8065938b269a33107958e
|
4
|
+
data.tar.gz: a5520c6bab70019d406db2768480202c7a283b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a4a662e1be6f29c0436fc9b4719497428f829be31f5ca88ba9fd94954bcfcc8c671a59563d375cde177e6c668709c8c647f04dfff7170dab80edddbaeb4018a
|
7
|
+
data.tar.gz: 6948108039e53bb0c81bf7a596423fd38643983f8f69d3ecb22f553ab585e0b0bf5e82d26e70a2b438b8d1a0d6f79ff366f1824b5662c343b6f0e9e49e731ad7
|
data/NEWS.md
ADDED
data/lib/mml2wav/parser.rb
CHANGED
@@ -3,7 +3,7 @@ require "mml2wav/scale"
|
|
3
3
|
module Mml2wav
|
4
4
|
class Parser
|
5
5
|
def initialize(sounds, sampling_rate, options={})
|
6
|
-
pattern = /T\d+|V\d+|L\d+|[A-
|
6
|
+
pattern = /T\d+|V\d+|L\d+|[A-GR][#+-]?\d*\.?(?:&[A-GR][#+-]?\d*\.?)*|O\d+|[><]|./i
|
7
7
|
@sounds = sounds.scan(pattern)
|
8
8
|
@sampling_rate = sampling_rate
|
9
9
|
@bpm = options[:bpm] || 120
|
@@ -22,22 +22,40 @@ module Mml2wav
|
|
22
22
|
case sound
|
23
23
|
when /\AT(\d+)/i
|
24
24
|
@bpm = $1.to_i
|
25
|
+
next
|
25
26
|
when /\AV(\d+)/i
|
26
27
|
@velocity = $1.to_i
|
28
|
+
next
|
27
29
|
when /\AL(\d+)/i
|
28
30
|
@default_length = $1.to_f
|
29
|
-
|
30
|
-
|
31
|
+
next
|
32
|
+
when /\A([A-GR][#+-]?)(\d+)?(\.)?((?:&[A-GR][#+-]?\d*\.?)*)/i
|
31
33
|
sound = $1
|
32
|
-
length =
|
34
|
+
length = $2.to_f if $2
|
35
|
+
length /= 1.5 if $3
|
36
|
+
sec = base_sec / length / @bpm
|
37
|
+
if $4
|
38
|
+
$4.scan(/&[A-GR][#+-]?(\d+)?(\.)?/i).each do |len, dot|
|
39
|
+
if len
|
40
|
+
sub_length = len.to_f
|
41
|
+
else
|
42
|
+
sub_length = @default_length
|
43
|
+
end
|
44
|
+
sub_length /= 1.5 if dot
|
45
|
+
sub_sec = base_sec / sub_length / @bpm
|
46
|
+
sec += sub_sec
|
47
|
+
end
|
48
|
+
end
|
33
49
|
when /\AO(\d+)/i
|
34
50
|
@octave = $1.to_i
|
51
|
+
next
|
35
52
|
when "<"
|
36
53
|
@octave += @octave_reverse ? -1 : 1
|
54
|
+
next
|
37
55
|
when ">"
|
38
56
|
@octave -= @octave_reverse ? -1 : 1
|
57
|
+
next
|
39
58
|
end
|
40
|
-
sec = base_sec / length / @bpm
|
41
59
|
amplitude = @velocity.to_f / 10
|
42
60
|
frequency = Scale::FREQUENCIES[sound.downcase]
|
43
61
|
next unless frequency
|
data/lib/mml2wav/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mml2wav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wavefile
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- ".gitignore"
|
64
64
|
- Gemfile
|
65
65
|
- LICENSE.txt
|
66
|
+
- NEWS.md
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
68
69
|
- bin/mml2wav
|