smf 0.15.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/MANUAL +172 -0
  2. data/MANUAL.en +135 -0
  3. data/MANUAL.en.html +150 -0
  4. data/MANUAL.en.rd +144 -0
  5. data/MANUAL.html +201 -0
  6. data/MANUAL.rd +179 -0
  7. data/README +33 -0
  8. data/README.en +33 -0
  9. data/lib/smf.rb +736 -0
  10. data/lib/smf/divert.rb +21 -0
  11. data/lib/smf/io.rb +1278 -0
  12. data/lib/smf/toy/beatmap.rb +73 -0
  13. data/lib/smf/toy/gm.rb +327 -0
  14. data/lib/smf/toy/groove.rb +34 -0
  15. data/lib/smf/toy/macro.rb +282 -0
  16. data/lib/smf/toy/macro/mml.rb +34 -0
  17. data/lib/smf/toy/macro/mml/parser.rb +545 -0
  18. data/lib/smf/toy/macro/mml/parser.ry +239 -0
  19. data/lib/smf/toy/macro/stt.rb +33 -0
  20. data/lib/smf/toy/morse.rb +126 -0
  21. data/lib/smf/toy/quantize.rb +32 -0
  22. data/lib/smf/toy/rmi.rb +29 -0
  23. data/lib/smf/toy/searchsegment.rb +24 -0
  24. data/lib/smf/toy/shuffle.rb +39 -0
  25. data/lib/smf/toy/tempomap.rb +75 -0
  26. data/lib/smf/toy/text.rb +369 -0
  27. data/lib/smf/toy/velcomp.rb +42 -0
  28. data/lib/smf/toy/virtual.rb +118 -0
  29. data/lib/smf/toy/xml.rb +377 -0
  30. data/sample/Makefile +58 -0
  31. data/sample/bwv772.mid +0 -0
  32. data/sample/bwv772.mml +94 -0
  33. data/sample/bwv775.mid +0 -0
  34. data/sample/bwv775.mml +157 -0
  35. data/sample/bwv787.mid +0 -0
  36. data/sample/bwv787.mml +129 -0
  37. data/sample/groove.grv +33 -0
  38. data/sample/groove.rb +45 -0
  39. data/sample/ltvddpd2.mid +0 -0
  40. data/sample/ltvddpd2.stt +60 -0
  41. data/sample/merge.rb +38 -0
  42. data/sample/mml-samp.rb +19 -0
  43. data/sample/mml.rb +36 -0
  44. data/sample/morse-samp.rb +11 -0
  45. data/sample/morse.rb +31 -0
  46. data/sample/play-oss.rb +215 -0
  47. data/sample/play-oss2.rb +253 -0
  48. data/sample/play-oss3.rb +150 -0
  49. data/sample/play-spkr.rb +97 -0
  50. data/sample/play-win.rb +195 -0
  51. data/sample/quantize.rb +41 -0
  52. data/sample/rand1.rb +21 -0
  53. data/sample/rand2.rb +24 -0
  54. data/sample/rmi2smf.rb +26 -0
  55. data/sample/shuffle.rb +43 -0
  56. data/sample/smf2rmi.rb +26 -0
  57. data/sample/smf2smf.rb +26 -0
  58. data/sample/smf2text.rb +27 -0
  59. data/sample/smf2wav.rb +123 -0
  60. data/sample/smf2xml.rb +27 -0
  61. data/sample/split.rb +40 -0
  62. data/sample/stt-samp.rb +19 -0
  63. data/sample/stt.rb +36 -0
  64. data/sample/text2smf.rb +28 -0
  65. data/sample/velcomp.rb +45 -0
  66. data/sample/virtual-samp.rb +19 -0
  67. data/sample/xml2smf.rb +28 -0
  68. metadata +128 -0
@@ -0,0 +1,27 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # smf2xml.rb: Written by Tadayoshi Funaba 2004-2006
4
+ # $Id: smf2xml.rb,v 1.3 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/toy/xml'
8
+ require 'gopt'
9
+ include SMF
10
+
11
+ def usage
12
+ warn 'usage: smf2xml [-o output] [input]'
13
+ exit 1
14
+ end
15
+
16
+ usage unless opt = Gopt.gopt('o:')
17
+ usage unless $*.size >= 0 && $*.size <= 1
18
+
19
+ ifile = $*.shift
20
+ ifile = nil if ifile == '-'
21
+
22
+ ofile = opt[:o] if opt[:o]
23
+ ofile ||= File.basename(ifile, '.mid') + '.xml' if ifile
24
+ ofile = nil if ofile == '-'
25
+
26
+ sq = unless ifile then Sequence.read($stdin) else Sequence.load(ifile) end
27
+ unless ofile then sq.write_xml($stdout) else sq.save_xml(ofile) end
@@ -0,0 +1,40 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # split.rb: Written by Tadayoshi Funaba 1999-2006
4
+ # $Id: split.rb,v 1.10 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/divert'
8
+ require 'gopt'
9
+ include SMF
10
+
11
+ def usage
12
+ warn 'usage: split [-o output] [input]'
13
+ exit 1
14
+ end
15
+
16
+ usage unless opt = Gopt.gopt('o:')
17
+ usage unless $*.size >= 0 && $*.size <= 1
18
+
19
+ ifile = $*.shift
20
+ ifile = nil if ifile == '-'
21
+
22
+ ofile = opt[:o] if opt[:o]
23
+ ofile ||= File.basename(ifile, '.mid') + '-split.mid' if ifile
24
+ ofile = nil if ofile == '-'
25
+
26
+ sq = unless ifile then Sequence.read($stdin) else Sequence.load(ifile) end
27
+ nsq = Sequence.new(1, sq.division)
28
+ eot = []
29
+ sq.each do |tr|
30
+ tr.divert(nsq) do |ev|
31
+ case ev
32
+ when EndOfTrack; eot << ev; nil
33
+ when ChannelMessage; ev.ch + 1
34
+ else; 0
35
+ end
36
+ end
37
+ end
38
+ max = eot.max unless eot.empty?
39
+ nsq.each{|tr| tr << max}
40
+ unless ofile then nsq.write($stdout) else nsq.save(ofile) end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # 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
+
6
+ require 'smf/toy/macro/stt'
7
+ include SMF
8
+
9
+ sq = Sequence.new
10
+ mm = STT.new(sq)
11
+ mm << 'gm=1 r ch=0 pr=0'
12
+ 12.times do
13
+ mm << "{q �ɡ� h �ɡ� q r}&"
14
+ mm << "{q ��� h ��� q r}&"
15
+ mm << "{q �� h �� q r}"
16
+ mm << "oc += 1/12"
17
+ end
18
+ mm.generate
19
+ sq.save('stt-samp.mid')
@@ -0,0 +1,36 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # stt.rb: Written by Tadayoshi Funaba 2005,2006
4
+ # $Id: stt.rb,v 1.4 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf/toy/macro/stt'
7
+ require 'gopt'
8
+ include SMF
9
+
10
+ def usage
11
+ warn 'usage: stt [-o output] [-e command] [input]'
12
+ exit 1
13
+ end
14
+
15
+ usage unless opt = Gopt.gopt('o:e:')
16
+ usage unless $*.size >= 0 && $*.size <= 1
17
+
18
+ ifile = $*.shift
19
+ ifile = nil if ifile == '-'
20
+
21
+ ofile = opt[:o] if opt[:o]
22
+ ofile ||= File.basename(ifile, '.stt') + '.mid' if ifile
23
+ ofile = nil if ofile == '-'
24
+
25
+ so = opt[:e] if opt[:e]
26
+ so ||= unless ifile then $stdin.read else IO.read(ifile) end
27
+ sq = Sequence.new(1, 480)
28
+ mm = STT.new(sq)
29
+ mm << so
30
+ begin
31
+ mm.generate
32
+ rescue ParseError
33
+ warn format('%s: %s', (opt[:e] && '-e') || ifile || '(stdin)', $!)
34
+ exit 1
35
+ end
36
+ unless ofile then sq.write($stdout) else sq.save(ofile) end
@@ -0,0 +1,28 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # text2smf.rb: Written by Tadayoshi Funaba 2001-2006
4
+ # $Id: text2smf.rb,v 1.5 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/toy/text'
8
+ require 'gopt'
9
+ include SMF
10
+
11
+ def usage
12
+ warn 'usage: text2smf [-o output] [input]'
13
+ exit 1
14
+ end
15
+
16
+ usage unless opt = Gopt.gopt('o:')
17
+ usage unless $*.size >= 0 && $*.size <= 1
18
+
19
+ ifile = $*.shift
20
+ ifile = nil if ifile == '-'
21
+
22
+ ofile = opt[:o] if opt[:o]
23
+ ofile ||= File.basename(ifile, '.txt') + '.mid' if ifile
24
+ ofile = nil if ofile == '-'
25
+
26
+ sq = unless ifile
27
+ then Sequence.read_text($stdin) else Sequence.load_text(ifile) end
28
+ unless ofile then sq.write($stdout) else sq.save(ofile) end
@@ -0,0 +1,45 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # velcomp.rb: Written by Tadayoshi Funaba 2005,2006
4
+ # $Id: velcomp.rb,v 1.3 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/toy/velcomp'
8
+ require 'gopt'
9
+ include SMF
10
+
11
+ def usage
12
+ warn 'usage: velcomp [-o output] [-g gain] [-t thresh] [-r ratio] [input]'
13
+ exit 1
14
+ end
15
+
16
+ usage unless opt = Gopt.gopt('o:g:t:r:')
17
+ usage unless $*.size >= 0 && $*.size <= 1
18
+
19
+ ifile = $*.shift
20
+ ifile = nil if ifile == '-'
21
+
22
+ ofile = opt[:o] if opt[:o]
23
+ ofile ||= File.basename(ifile, '.mid') + '-velcomp.mid' if ifile
24
+ ofile = nil if ofile == '-'
25
+
26
+ g = (opt[:g] || '0').to_f
27
+ t = (opt[:t] || '80').to_f
28
+ r = (opt[:r] || '0.9').to_f
29
+
30
+ sq = unless ifile then Sequence.read($stdin) else Sequence.load(ifile) end
31
+ vc = VelComp.new
32
+ vc.gain = g
33
+ vc.thresh = t
34
+ vc.ratio = r
35
+
36
+ sq.each do |tr|
37
+ tr.pop
38
+ tr.each do |ev|
39
+ case ev
40
+ when NoteOn
41
+ vc.velcomp(ev)
42
+ end
43
+ end
44
+ end
45
+ unless ofile then sq.write($stdout) else sq.save(ofile) end
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # virtual-samp.rb: Written by Tadayoshi Funaba 2005
4
+ # $Id: virtual-samp.rb,v 1.1 2005-07-17 17:16:18+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/toy/virtual'
8
+ include SMF
9
+
10
+ sq = VirtualSequence.load('bwv772.mid')
11
+ sq.each do |tr|
12
+ tr.each do |ev|
13
+ case ev
14
+ when VirtualNote
15
+ ev.length /= 2
16
+ end
17
+ end
18
+ end
19
+ sq.save('virtual-samp.mid')
@@ -0,0 +1,28 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ # xml2smf.rb: Written by Tadayoshi Funaba 2004-2006
4
+ # $Id: xml2smf.rb,v 1.3 2006-11-10 21:57:06+09 tadf Exp $
5
+
6
+ require 'smf'
7
+ require 'smf/toy/xml'
8
+ require 'gopt'
9
+ include SMF
10
+
11
+ def usage
12
+ warn 'usage: xml2smf [-o output] [input]'
13
+ exit 1
14
+ end
15
+
16
+ usage unless opt = Gopt.gopt('o:d:')
17
+ usage unless $*.size >= 0 && $*.size <= 1
18
+
19
+ ifile = $*.shift
20
+ ifile = nil if ifile == '-'
21
+
22
+ ofile = opt[:o] if opt[:o]
23
+ ofile ||= File.basename(ifile, '.xml') + '.mid' if ifile
24
+ ofile = nil if ofile == '-'
25
+
26
+ sq = unless ifile
27
+ then Sequence.read_xml($stdin) else Sequence.load_xml(ifile) end
28
+ unless ofile then sq.write($stdout) else sq.save(ofile) end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.15.12
5
+ platform: ruby
6
+ authors:
7
+ - Tadayoshi Funaba
8
+ autorequire: smf
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-12 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gopt
17
+ 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:
25
+ description:
26
+ email: tadf@funaba.org
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - MANUAL
35
+ - MANUAL.en
36
+ - MANUAL.en.html
37
+ - MANUAL.en.rd
38
+ - MANUAL.html
39
+ - MANUAL.rd
40
+ - README
41
+ - README.en
42
+ - lib/smf.rb
43
+ - lib/smf/divert.rb
44
+ - lib/smf/io.rb
45
+ - lib/smf/toy/beatmap.rb
46
+ - lib/smf/toy/gm.rb
47
+ - lib/smf/toy/groove.rb
48
+ - lib/smf/toy/macro.rb
49
+ - lib/smf/toy/macro/mml.rb
50
+ - lib/smf/toy/macro/mml/parser.rb
51
+ - lib/smf/toy/macro/mml/parser.ry
52
+ - lib/smf/toy/macro/stt.rb
53
+ - lib/smf/toy/morse.rb
54
+ - lib/smf/toy/quantize.rb
55
+ - lib/smf/toy/rmi.rb
56
+ - lib/smf/toy/searchsegment.rb
57
+ - lib/smf/toy/shuffle.rb
58
+ - lib/smf/toy/tempomap.rb
59
+ - lib/smf/toy/text.rb
60
+ - lib/smf/toy/velcomp.rb
61
+ - lib/smf/toy/virtual.rb
62
+ - lib/smf/toy/xml.rb
63
+ - sample/Makefile
64
+ - sample/bwv772.mid
65
+ - sample/bwv772.mml
66
+ - sample/bwv775.mid
67
+ - sample/bwv775.mml
68
+ - sample/bwv787.mid
69
+ - sample/bwv787.mml
70
+ - sample/groove.grv
71
+ - sample/groove.rb
72
+ - sample/ltvddpd2.mid
73
+ - sample/ltvddpd2.stt
74
+ - sample/merge.rb
75
+ - sample/mml-samp.rb
76
+ - sample/mml.rb
77
+ - sample/morse-samp.rb
78
+ - sample/morse.rb
79
+ - sample/play-oss.rb
80
+ - sample/play-oss2.rb
81
+ - sample/play-oss3.rb
82
+ - sample/play-spkr.rb
83
+ - sample/play-win.rb
84
+ - sample/quantize.rb
85
+ - sample/rand1.rb
86
+ - sample/rand2.rb
87
+ - sample/rmi2smf.rb
88
+ - sample/shuffle.rb
89
+ - sample/smf2rmi.rb
90
+ - sample/smf2smf.rb
91
+ - sample/smf2text.rb
92
+ - sample/smf2wav.rb
93
+ - sample/smf2xml.rb
94
+ - sample/split.rb
95
+ - sample/stt-samp.rb
96
+ - sample/stt.rb
97
+ - sample/text2smf.rb
98
+ - sample/velcomp.rb
99
+ - sample/virtual-samp.rb
100
+ - sample/xml2smf.rb
101
+ has_rdoc: false
102
+ homepage: http://www.funaba.org/en/ruby.html
103
+ post_install_message:
104
+ rdoc_options: []
105
+
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: "0"
119
+ version:
120
+ requirements: []
121
+
122
+ rubyforge_project: tadf
123
+ rubygems_version: 1.3.1
124
+ signing_key:
125
+ specification_version: 2
126
+ summary: SMF is a "Standard MIDI File" module for an object-oriented scripting language Ruby.
127
+ test_files: []
128
+