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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06613389b80c23f0feceb9a329027156ffdfa049
4
- data.tar.gz: c885d9a54797cfe5a73c1e7b25dc6107b6bb3a4d
3
+ metadata.gz: 4cbdd2cc35197a65e4d8065938b269a33107958e
4
+ data.tar.gz: a5520c6bab70019d406db2768480202c7a283b92
5
5
  SHA512:
6
- metadata.gz: 6c5d0613578307b8dc99cd947de6f7aab9c5e4bf42a2d4f0674a9bcca81c5b4238ae43a7f4f4ffe4d10e22c7e7bd88922ebb2e18df983f683e89391cc337abc6
7
- data.tar.gz: 18ab290f8e4b791855cd7ac65f5532632063c759f09b0d5a0d40eb8b521e605a420c374724c3d3502e13c0a907f55350b7f333991a5bef40238b5696bc8f7cb7
6
+ metadata.gz: 6a4a662e1be6f29c0436fc9b4719497428f829be31f5ca88ba9fd94954bcfcc8c671a59563d375cde177e6c668709c8c647f04dfff7170dab80edddbaeb4018a
7
+ data.tar.gz: 6948108039e53bb0c81bf7a596423fd38643983f8f69d3ecb22f553ab585e0b0bf5e82d26e70a2b438b8d1a0d6f79ff366f1824b5662c343b6f0e9e49e731ad7
data/NEWS.md ADDED
@@ -0,0 +1,12 @@
1
+ # NEWS
2
+
3
+ ## 0.0.5: 2015-05-03
4
+
5
+ ### Improvements
6
+
7
+ * Supported tie.
8
+
9
+ ### Fixes
10
+
11
+ * Supported length for rest.
12
+ * Supported dot without length.
@@ -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-G][#+-]?\d*\.?|O\d+|[><]|./i
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
- when /\A([A-G][#+-]?)(\d+)(\.)?/i
30
- length = $2.to_f
31
+ next
32
+ when /\A([A-GR][#+-]?)(\d+)?(\.)?((?:&[A-GR][#+-]?\d*\.?)*)/i
31
33
  sound = $1
32
- length = @default_length / 1.5 if $3
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
@@ -1,3 +1,3 @@
1
1
  module Mml2wav
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
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
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-04-27 00:00:00.000000000 Z
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