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.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/MANUAL +39 -44
- data/MANUAL.en +1 -0
- data/MANUAL.en.html +23 -22
- data/MANUAL.en.rd +1 -0
- data/MANUAL.html +59 -58
- data/MANUAL.rd +1 -0
- data/README +11 -11
- data/README.en +10 -10
- data/lib/smf.rb +8 -4
- data/lib/smf/toy/beatmap.rb +3 -3
- data/lib/smf/toy/gm.rb +6 -6
- data/lib/smf/toy/groove.rb +6 -6
- data/lib/smf/toy/macro.rb +5 -5
- data/lib/smf/toy/macro/mml/parser.rb +247 -252
- data/lib/smf/toy/macro/mml/parser.ry +4 -4
- data/lib/smf/toy/macro/stt.rb +21 -12
- data/lib/smf/toy/shuffle.rb +9 -17
- data/lib/smf/toy/tempomap.rb +3 -3
- data/lib/smf/toy/velcomp.rb +9 -9
- data/lib/smf/toy/virtual.rb +5 -4
- data/sample/stt-samp.rb +5 -4
- metadata +38 -40
@@ -1,5 +1,5 @@
|
|
1
|
-
# parser.ry: Written by Tadayoshi Funaba 1999-2005,2008
|
2
|
-
# $Id: parser.ry,v 1.
|
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(
|
84
|
+
@str = @str.sub(/\A(\s+)/, '')
|
85
85
|
if $1
|
86
86
|
@co += $1.count("\n")
|
87
87
|
end
|
data/lib/smf/toy/macro/stt.rb
CHANGED
@@ -1,28 +1,37 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
|
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 = { '
|
15
|
-
'
|
19
|
+
NOTETAB = { 'ラ'=>'a', 'シ' =>'b', 'ド'=>'c', 'レ'=>'d',
|
20
|
+
'ミ'=>'e', 'ファ'=>'f', 'ソ'=>'g', 'ッ'=>'r' }
|
16
21
|
|
17
22
|
def << (s)
|
18
|
-
s2 = s.
|
19
|
-
gsub(/(
|
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('
|
23
|
-
no += o.tr('
|
27
|
+
no += s.tr('♭%#', '$%#') if s
|
28
|
+
no += o.tr(',’', ",'") if o
|
24
29
|
le = 1
|
25
|
-
|
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)
|
data/lib/smf/toy/shuffle.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# shuffle.rb: Written by Tadayoshi Funaba 2005,2006,2008
|
2
|
-
# $Id: shuffle.rb,v 1.
|
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,
|
11
|
-
@unit =
|
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 /
|
25
|
-
|
26
|
-
|
27
|
-
@
|
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 = @
|
25
|
+
r2 = @spline.eval(r)
|
34
26
|
ev.offset = (q * @unit + r2).round
|
35
27
|
end
|
36
28
|
|
data/lib/smf/toy/tempomap.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# tempomap.rb: Written by Tadayoshi Funaba 2005,2006
|
2
|
-
# $Id: tempomap.rb,v 1.
|
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
|
|
data/lib/smf/toy/velcomp.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# velcomp.rb: Written by Tadayoshi Funaba 2005,2006,2008
|
2
|
-
# $Id: velcomp.rb,v 1.
|
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
|
-
|
19
|
-
|
20
|
-
@
|
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; @
|
27
|
-
def ratio=(v) @ratio = v; @
|
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 @
|
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 = @
|
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
|
data/lib/smf/toy/virtual.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# virtual.rb: Written by Tadayoshi Funaba 2005,2006
|
2
|
-
# $Id: virtual.rb,v 1.
|
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
|
-
|
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(
|
40
|
+
xs.delete_at(idx)
|
40
41
|
end
|
41
42
|
else
|
42
43
|
v << ev
|
data/sample/stt-samp.rb
CHANGED
@@ -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.
|
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
|
14
|
-
mm << "{q
|
15
|
-
mm << "{q
|
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.
|
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:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - "
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
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
|
-
|
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
|
-
|
102
|
-
|
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:
|
113
|
-
|
114
|
-
|
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:
|
119
|
-
version:
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
120
119
|
requirements: []
|
121
|
-
|
122
120
|
rubyforge_project: tadf
|
123
|
-
rubygems_version:
|
121
|
+
rubygems_version: 2.2.2
|
124
122
|
signing_key:
|
125
|
-
specification_version:
|
126
|
-
summary: SMF is a "Standard MIDI File" module for an object-oriented scripting language
|
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
|
-
|