smf 0.15.12 → 0.15.15

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.
@@ -1,5 +1,5 @@
1
- # parser.ry: Written by Tadayoshi Funaba 1999-2005,2008
2
- # $Id: parser.ry,v 1.3 2008-02-16 16:56:21+09 tadf Exp $
1
+ # parser.ry: Written by Tadayoshi Funaba 1999-2005,2008,2014
2
+ # $Id: parser.ry,v 1.5 2014-04-27 08:46:58+09 tadf Exp $
3
3
 
4
4
  class SMF::MMLParser
5
5
 
@@ -58,7 +58,7 @@ end
58
58
 
59
59
  require 'smf'
60
60
  require 'smf/toy/macro'
61
- require 'rational'
61
+ require 'rational' unless defined?(Rational)
62
62
 
63
63
  class SemanticError < StandardError; end
64
64
 
@@ -81,7 +81,7 @@ class SemanticError < StandardError; end
81
81
 
82
82
  def next_token
83
83
  loop do
84
- @str = @str.sub(/\A([\s\v]+)/, '')
84
+ @str = @str.sub(/\A(\s+)/, '')
85
85
  if $1
86
86
  @co += $1.count("\n")
87
87
  end
@@ -1,28 +1,37 @@
1
- # stt.rb: Written by Tadayoshi Funaba 2005
2
- # $Id: stt.rb,v 1.2 2005-07-17 17:08:20+09 tadf Exp $
3
-
4
- $KCODE = 'e'
1
+ # coding: utf-8
2
+ # stt.rb: Written by Tadayoshi Funaba 2005,2014
3
+ # $Id: stt.rb,v 1.3 2014-04-27 08:46:58+09 tadf Exp $
4
+
5
+ unless defined?(Encoding)
6
+ $KCODE = 'u'
7
+ require 'jcode'
8
+ else
9
+ # Encoding.default_external = 'utf-8'
10
+ end
5
11
 
6
12
  require 'smf/toy/macro/mml'
7
13
  require 'kconv'
8
- require 'jcode'
9
14
 
10
15
  module SMF
11
16
 
12
17
  class STT < MML
13
18
 
14
- NOTETAB = { '��'=>'a', '��' =>'b', '��'=>'c', '��'=>'d',
15
- '��'=>'e', '�ե�'=>'f', '��'=>'g', '��'=>'r' }
19
+ NOTETAB = { ''=>'a', '' =>'b', ''=>'c', ''=>'d',
20
+ ''=>'e', 'ファ'=>'f', ''=>'g', ''=>'r' }
16
21
 
17
22
  def << (s)
18
- s2 = s.toeuc.
19
- gsub(/(��|��|��|��|��|�ե�|��|��)([$%#�����]+)?([,'����]+)?(��+)?/) do
23
+ s2 = s.toutf8.
24
+ gsub(/(ラ|シ|ド|レ|ミ|ファ|ソ|ッ)([$%#♭%#]+)?([,',’]+)?(ー+)?/) do
20
25
  n, s, o, x = $1, $2, $3, $4
21
26
  no = NOTETAB[n]
22
- no += s.tr('�����', '$%#') if s
23
- no += o.tr('����', ",'") if o
27
+ no += s.tr('♭%#', '$%#') if s
28
+ no += o.tr(',’', ",'") if o
24
29
  le = 1
25
- le += x.jsize if x
30
+ if ''.respond_to?(:jsize)
31
+ le += x.jsize if x
32
+ else
33
+ le += x.size if x
34
+ end
26
35
  format('{le*=%d %s}', le, no)
27
36
  end
28
37
  super(s2)
@@ -1,5 +1,5 @@
1
- # shuffle.rb: Written by Tadayoshi Funaba 2005,2006,2008
2
- # $Id: shuffle.rb,v 1.4 2008-02-16 16:56:21+09 tadf Exp $
1
+ # shuffle.rb: Written by Tadayoshi Funaba 2005,2006,2008,2014
2
+ # $Id: shuffle.rb,v 1.5 2014-03-22 07:48:58+09 tadf Exp $
3
3
 
4
4
  require 'gsl'
5
5
 
@@ -7,30 +7,22 @@ module SMF
7
7
 
8
8
  class Shuffle
9
9
 
10
- def initialize(div, unit=1.0/8)
11
- @unit = unit * div * 4
10
+ def initialize(div, beat=1.0/8)
11
+ @unit = beat * div * 4
12
12
  self.amount = 0.5
13
13
  end
14
14
 
15
15
  def amount=(v)
16
- =begin
17
- shift = @unit / 2 * v
18
- @x = GSL::Vector.alloc(0, @unit / 2, @unit)
19
- @y = GSL::Vector.alloc(0, @unit / 2 + shift, @unit)
20
- @interp = Interp.alloc('linear', 3)
21
- =end
22
- #=begin
23
16
  qunit = @unit / 4
24
- shift = @unit / 4 * v
25
- @x = GSL::Vector.alloc(0, qunit, qunit*2, qunit*3, @unit)
26
- @y = GSL::Vector.alloc(0, qunit, qunit*2 + shift, qunit*3 + shift/2, @unit)
27
- @interp = GSL::Interp.alloc('linear', 5)
28
- #=end
17
+ shift = @unit / 2 * v
18
+ x = GSL::Vector.alloc(0, qunit, qunit*2, qunit*3, @unit)
19
+ y = GSL::Vector.alloc(0, qunit + shift*0.25, qunit*2 + shift, qunit*3 + shift*0.5, @unit)
20
+ @spline = GSL::Spline.alloc('linear', x, y)
29
21
  end
30
22
 
31
23
  def shuffle(ev)
32
24
  q, r = ev.offset.divmod(@unit)
33
- r2 = @interp.eval(@x, @y, r)
25
+ r2 = @spline.eval(r)
34
26
  ev.offset = (q * @unit + r2).round
35
27
  end
36
28
 
@@ -1,8 +1,8 @@
1
- # tempomap.rb: Written by Tadayoshi Funaba 2005,2006
2
- # $Id: tempomap.rb,v 1.2 2006-06-20 22:24:14+09 tadf Exp $
1
+ # tempomap.rb: Written by Tadayoshi Funaba 2005,2006,2014
2
+ # $Id: tempomap.rb,v 1.3 2014-04-27 08:46:58+09 tadf Exp $
3
3
 
4
4
  require 'smf/toy/searchsegment'
5
- require 'rational'
5
+ require 'rational' unless defined?(Rational)
6
6
 
7
7
  module SMF
8
8
 
@@ -1,5 +1,5 @@
1
- # velcomp.rb: Written by Tadayoshi Funaba 2005,2006,2008
2
- # $Id: velcomp.rb,v 1.3 2008-02-16 16:56:21+09 tadf Exp $
1
+ # velcomp.rb: Written by Tadayoshi Funaba 2005,2006,2008,2014
2
+ # $Id: velcomp.rb,v 1.4 2014-03-22 07:48:58+09 tadf Exp $
3
3
 
4
4
  require 'gsl'
5
5
 
@@ -15,23 +15,23 @@ module SMF
15
15
 
16
16
  def init
17
17
  max = @thresh + (127 - @thresh) * @ratio
18
- @x = GSL::Vector.alloc(0, @thresh, 127)
19
- @y = GSL::Vector.alloc(0, @thresh, max)
20
- @interp = GSL::Interp.alloc('linear', 3)
18
+ x = GSL::Vector.alloc(0, @thresh, 127)
19
+ y = GSL::Vector.alloc(0, @thresh, max)
20
+ @spline = GSL::Spline.alloc('linear', x, y)
21
21
  end
22
22
 
23
23
  private :init
24
24
 
25
25
  def gain=(v) @gain = v end
26
- def thresh=(v) @thresh = v; @interp = nil end
27
- def ratio=(v) @ratio = v; @interp = nil end
26
+ def thresh=(v) @thresh = v; @spline = nil end
27
+ def ratio=(v) @ratio = v; @spline = nil end
28
28
 
29
29
  def velcomp(ev)
30
- init unless @interp
30
+ init unless @spline
31
31
  v = ev.vel + @gain
32
32
  v = 127 if v > 127
33
33
  v = 1 if v < 1
34
- v2 = @interp.eval(@x, @y, v)
34
+ v2 = @spline.eval(v)
35
35
  v2 = 127 if v > 127
36
36
  v2 = 1 if v < 1
37
37
  ev.vel = v2.round
@@ -1,5 +1,5 @@
1
- # virtual.rb: Written by Tadayoshi Funaba 2005,2006
2
- # $Id: virtual.rb,v 1.3 2006-11-10 21:58:21+09 tadf Exp $
1
+ # virtual.rb: Written by Tadayoshi Funaba 2005,2006,2014
2
+ # $Id: virtual.rb,v 1.4 2014-04-27 08:46:58+09 tadf Exp $
3
3
 
4
4
  module SMF
5
5
 
@@ -26,8 +26,9 @@ module SMF
26
26
  xs.push(ev)
27
27
  when NoteOff
28
28
  on = nil
29
- i = 0
29
+ idx = 0
30
30
  xs.each_with_index do |x, i|
31
+ idx = i
31
32
  if x.ch == ev.ch && x.note == ev.note
32
33
  on = x
33
34
  break
@@ -36,7 +37,7 @@ module SMF
36
37
  if on
37
38
  v << VirtualNote.new(on.offset, on.ch, on.note,
38
39
  on.vel, ev.vel, ev.offset - on.offset)
39
- xs.delete_at(i)
40
+ xs.delete_at(idx)
40
41
  end
41
42
  else
42
43
  v << ev
@@ -1,7 +1,8 @@
1
1
  #! /usr/bin/env ruby
2
+ # coding: utf-8
2
3
 
3
4
  # stt-samp.rb: Written by Tadayoshi Funaba 2005
4
- # $Id: stt-samp.rb,v 1.1 2005-07-17 17:16:18+09 tadf Exp $
5
+ # $Id: stt-samp.rb,v 1.2 2014-04-27 08:49:03+09 tadf Exp $
5
6
 
6
7
  require 'smf/toy/macro/stt'
7
8
  include SMF
@@ -10,9 +11,9 @@ sq = Sequence.new
10
11
  mm = STT.new(sq)
11
12
  mm << 'gm=1 r ch=0 pr=0'
12
13
  12.times do
13
- mm << "{q �ɡ� h �ɡ� q r}&"
14
- mm << "{q ��� h ��� q r}&"
15
- mm << "{q �� h �� q r}"
14
+ mm << "{q ド# h ド# q r}&"
15
+ mm << "{q レ# h レ# q r}&"
16
+ mm << "{q h q r}"
16
17
  mm << "oc += 1/12"
17
18
  end
18
19
  mm.generate
metadata CHANGED
@@ -1,36 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: smf
3
- version: !ruby/object:Gem::Version
4
- version: 0.15.12
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.15.15
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Tadayoshi Funaba
8
- autorequire: smf
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2008-11-12 00:00:00 +09:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: gopt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
17
20
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.0'
25
27
  description:
26
28
  email: tadf@funaba.org
27
29
  executables: []
28
-
29
30
  extensions: []
30
-
31
31
  extra_rdoc_files: []
32
-
33
- files:
32
+ files:
33
+ - LICENSE
34
34
  - MANUAL
35
35
  - MANUAL.en
36
36
  - MANUAL.en.html
@@ -98,31 +98,29 @@ files:
98
98
  - sample/velcomp.rb
99
99
  - sample/virtual-samp.rb
100
100
  - sample/xml2smf.rb
101
- has_rdoc: false
102
- homepage: http://www.funaba.org/en/ruby.html
101
+ homepage: http://www.funaba.org/code
102
+ licenses:
103
+ - BSD 2-Clause
104
+ metadata: {}
103
105
  post_install_message:
104
106
  rdoc_options: []
105
-
106
- require_paths:
107
+ require_paths:
107
108
  - lib
108
- required_ruby_version: !ruby/object:Gem::Requirement
109
- requirements:
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
110
111
  - - ">="
111
- - !ruby/object:Gem::Version
112
- version: "0"
113
- version:
114
- required_rubygems_version: !ruby/object:Gem::Requirement
115
- requirements:
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
116
  - - ">="
117
- - !ruby/object:Gem::Version
118
- version: "0"
119
- version:
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
120
119
  requirements: []
121
-
122
120
  rubyforge_project: tadf
123
- rubygems_version: 1.3.1
121
+ rubygems_version: 2.2.2
124
122
  signing_key:
125
- specification_version: 2
126
- summary: SMF is a "Standard MIDI File" module for an object-oriented scripting language Ruby.
123
+ specification_version: 4
124
+ summary: SMF is a "Standard MIDI File" module for an object-oriented scripting language
125
+ Ruby.
127
126
  test_files: []
128
-