rhythmmml 0.0.2 → 0.0.3

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: de6910bb661fa7543e33efcc11cba0bb73c2d3b3
4
- data.tar.gz: 21563af764fb579fca57f6ca78c71fd36a42fd4b
3
+ metadata.gz: 0d41c409deeb7f63e8c9795913be84a46ada7fe5
4
+ data.tar.gz: 4912abeba6c447bc3d97bcb9584d561de7aeb991
5
5
  SHA512:
6
- metadata.gz: bdb8e3b03f5ea28ecada61bfdc97c3c5b1f488874330dd3b983c61787564ac13017fcb9c367f8ee543560b92c548036a21c73c8cb3fa49e255d65854ff3357f3
7
- data.tar.gz: 90f1a799d48b1fe2b142fc23f641fbe452d24d5413951ca67a150975aab2756f66484b4993d9125949d0978119d02d73ac8fa75b43e0bf0b8cd4357a1ceb5abf
6
+ metadata.gz: a9b1c51894c35fc231359257f053563e1f9e74e53d506331fe9a986884d08d1cb9f087eed5409d6118385ed06708137721b43f74a37c96418226fe783d5e7bb8
7
+ data.tar.gz: 384267c1f1cbe8ae5e32e01e9d24f9a5bed03fc7644e9c73ac74774ac6a8ef6760fd56bdd64d983312f192a1d8071f0324e5cf32d98e45ec05b0b6a9bbdfa51f
data/NEWS.md ADDED
@@ -0,0 +1,21 @@
1
+ # NEWS
2
+
3
+ ## 0.0.3: 2015-05-03
4
+
5
+ ### Improvements
6
+
7
+ * Supported tie.
8
+
9
+ ### Fixes
10
+
11
+ * Supported dot without length.
12
+
13
+ ## 0.0.2: 2015-04-29
14
+
15
+ ### Improvements
16
+
17
+ * Supported Windows.
18
+
19
+ ## 0.0.1: 2015-04-29
20
+
21
+ Initial release!
data/Rakefile CHANGED
@@ -4,4 +4,8 @@ task :run do
4
4
  ruby("-I", "lib", "bin/rhythmmml")
5
5
  end
6
6
 
7
- task :default => :run
7
+ task :test do
8
+ ruby("test/run-test.rb")
9
+ end
10
+
11
+ task :default => :test
@@ -3,7 +3,7 @@ require "mml2wav"
3
3
  module Rhythmmml
4
4
  class Parser
5
5
  def initialize(sounds, sampling_rate, options={})
6
- pattern = /T\d+|V\d+|L\d+|[A-GR][#+-]?\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
@@ -30,10 +30,23 @@ module Rhythmmml
30
30
  when /\AL(\d+)/i
31
31
  @default_length = $1.to_f
32
32
  next
33
- when /\A([A-GR][#+-]?)(\d+)(\.)?/i
34
- length = $2.to_f
33
+ when /\A([A-GR][#+-]?)(\d+)?(\.)?((?:&[A-GR][#+-]?\d*\.?)*)/i
35
34
  sound = $1
36
- length = @default_length / 1.5 if $3
35
+ length = $2.to_f if $2
36
+ length /= 1.5 if $3
37
+ sec = base_sec / length / @bpm
38
+ if $4
39
+ $4.scan(/&[A-GR][#+-]?(\d+)?(\.)?/i).each do |len, dot|
40
+ if len
41
+ sub_length = len.to_f
42
+ else
43
+ sub_length = @default_length
44
+ end
45
+ sub_length /= 1.5 if dot
46
+ sub_sec = base_sec / sub_length / @bpm
47
+ sec += sub_sec
48
+ end
49
+ end
37
50
  when /\AO(\d+)/i
38
51
  @octave = $1.to_i
39
52
  next
@@ -44,7 +57,6 @@ module Rhythmmml
44
57
  @octave -= @octave_reverse ? -1 : 1
45
58
  next
46
59
  end
47
- sec = base_sec / length / @bpm
48
60
  amplitude = @velocity.to_f / 10
49
61
  frequency = Mml2wav::Scale::FREQUENCIES[sound.downcase]
50
62
  next unless frequency
@@ -1,3 +1,3 @@
1
1
  module Rhythmmml
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_runtime_dependency("gosu")
22
22
  spec.add_runtime_dependency("mml2wav")
23
23
 
24
+ spec.add_development_dependency("test-unit")
25
+ spec.add_development_dependency("test-unit-notify")
24
26
  spec.add_development_dependency("bundler")
25
27
  spec.add_development_dependency("rake")
26
28
  end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ base_dir = File.expand_path("..", File.dirname(__FILE__))
4
+ lib_dir = File.join(base_dir, "lib")
5
+ test_dir = File.join(base_dir, "test")
6
+ $LOAD_PATH.unshift(lib_dir)
7
+ $LOAD_PATH.unshift(test_dir)
8
+
9
+ require 'test-unit'
10
+ require 'test/unit/notify'
11
+
12
+ exit Test::Unit::AutoRunner.run(true, test_dir)
@@ -0,0 +1,75 @@
1
+ require "rhythmmml/parser"
2
+
3
+ class TestParser < Test::Unit::TestCase
4
+ def test_a_scale
5
+ parser = Rhythmmml::Parser.new("c", 8000)
6
+ assert_equal([
7
+ ["c", 0.5, [523.252, 8000, 0.5, 0.5]],
8
+ ],
9
+ parser.parse)
10
+ end
11
+
12
+ def test_length
13
+ parser = Rhythmmml::Parser.new("c8", 8000)
14
+ assert_equal([
15
+ ["c", 0.25, [523.252, 8000, 0.25, 0.5]],
16
+ ],
17
+ parser.parse)
18
+ end
19
+
20
+ def test_dot
21
+ parser = Rhythmmml::Parser.new("c.", 8000)
22
+ assert_equal([
23
+ ["c", 0.75, [523.252, 8000, 0.75, 0.5]],
24
+ ],
25
+ parser.parse)
26
+ end
27
+
28
+ def test_length_with_dot
29
+ parser = Rhythmmml::Parser.new("c8.", 8000)
30
+ assert_equal([
31
+ ["c", 0.375, [523.252, 8000, 0.375, 0.5]],
32
+ ],
33
+ parser.parse)
34
+ end
35
+
36
+ def test_a_tie
37
+ parser = Rhythmmml::Parser.new("c&c", 8000, bpm: 60)
38
+ assert_equal([
39
+ ["c", 2.0, [523.252, 8000, 2.0, 0.5]],
40
+ ],
41
+ parser.parse)
42
+ end
43
+
44
+ def test_a_tie_with_length
45
+ parser = Rhythmmml::Parser.new("c&c16", 8000, bpm: 60)
46
+ assert_equal([
47
+ ["c", 1.25, [523.252, 8000, 1.25, 0.5]],
48
+ ],
49
+ parser.parse)
50
+ end
51
+
52
+ def test_a_tie_with_dot
53
+ parser = Rhythmmml::Parser.new("c&c.", 8000, bpm: 60)
54
+ assert_equal([
55
+ ["c", 2.5, [523.252, 8000, 2.5, 0.5]],
56
+ ],
57
+ parser.parse)
58
+ end
59
+
60
+ def test_a_tie_with_length_with_dot
61
+ parser = Rhythmmml::Parser.new("c&c2.", 8000, bpm: 60)
62
+ assert_equal([
63
+ ["c", 4.0, [523.252, 8000, 4.0, 0.5]],
64
+ ],
65
+ parser.parse)
66
+ end
67
+
68
+ def test_ties
69
+ parser = Rhythmmml::Parser.new("c&c&c", 8000, bpm: 60)
70
+ assert_equal([
71
+ ["c", 3.0, [523.252, 8000, 3.0, 0.5]],
72
+ ],
73
+ parser.parse)
74
+ end
75
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhythmmml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-29 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: gosu
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit-notify
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +105,7 @@ files:
77
105
  - ".gitignore"
78
106
  - Gemfile
79
107
  - LICENSE.txt
108
+ - NEWS.md
80
109
  - README.md
81
110
  - Rakefile
82
111
  - bin/rhythmmml
@@ -91,6 +120,8 @@ files:
91
120
  - lib/rhythmmml/version.rb
92
121
  - lib/rhythmmml/z_order.rb
93
122
  - rhythmmml.gemspec
123
+ - test/run-test.rb
124
+ - test/test-parser.rb
94
125
  homepage: https://github.com/myokoym/rhythmmml
95
126
  licenses:
96
127
  - MIT
@@ -115,5 +146,7 @@ rubygems_version: 2.4.5
115
146
  signing_key:
116
147
  specification_version: 4
117
148
  summary: A rhythm game for MML (Music Macro Language) by Gosu.
118
- test_files: []
149
+ test_files:
150
+ - test/run-test.rb
151
+ - test/test-parser.rb
119
152
  has_rdoc: