smml 0.1.0 → 0.1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8aa416af4560085821e2b1a7ed3e57434639602
4
- data.tar.gz: cb0b869acdc8c4b173cbab84b99487e41bd3cf92
3
+ metadata.gz: 030ec4626cbd1d8bbd61fe4e13b993ec2c27cfd6
4
+ data.tar.gz: f4a8aea294b67884dad7449c5ba524db6b162e76
5
5
  SHA512:
6
- metadata.gz: 82b264a3f12b49a27049d9eee0f43ce72a0d510ba61a95ee4fc00185c8e4279a37c876594358e6e47cc57c96d779f6ad18de0d9de5c7083c4262cc99dcb3b705
7
- data.tar.gz: 496db22b2ff32c0ade3dc275cc93362b1ff6e4f35f28e04e910a8d4d8d716320266b5fa3038fe297d7baefc6262eff6f5013ad6625d777874c0f0c783cf592ba
6
+ metadata.gz: c91c1d55a355e8bd9a35999df025fdbe95f1f1532e72e5f94fac6e6b9b0256a43543cf60383bf7865e5a3f692a2e3fccb3a27a2570449a32b5f5ba891936a0b3
7
+ data.tar.gz: fe30d0f2596410987755d5fadb450340ae7070c820e5de1b548054967b0ce7f30b680c425dad433a3f07445cc5edfcd2aaabd8011be45aa7bf00e023b897dbf5
data/README_smml.md CHANGED
@@ -23,9 +23,16 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- m=MmlTracks.new
26
+ in a ruby script,
27
+
28
+ m=Smml.new
27
29
  m.compile('infile.mml','outfile.mid')
28
30
 
31
+ Or exec command
32
+
33
+ $ smml -i infile.mml -o outfile.mid
34
+ $ smml -d "cdefgab" -o outfile.mid
35
+
29
36
  ## Contributing
30
37
 
31
38
  1. Fork it ( https://github.com/[my-github-username]/smml/fork )
data/bin/mmlsmml ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ begin
5
+ require'./lib/smml/msm'
6
+ rescue LoadError
7
+ require'smml'
8
+ end
9
+
10
+ def help
11
+ puts Smml::VERSION
12
+ puts %Q(
13
+ ARGS:
14
+ -i infile.mml -o outfile.mid
15
+ or
16
+ -d "MML data" -o outfile.mid
17
+ for dump smml
18
+ -s
19
+
20
+ syntax:
21
+ A: a2bc dref => track A, MML data
22
+ B: c2de frga => track B, MML data
23
+
24
+ # comment
25
+ +- sharp,flat
26
+ []3 repeat 3 times
27
+ )
28
+ end
29
+
30
+ infile="infile.mml"
31
+ outfile="mml.mid"
32
+ data=""
33
+
34
+ opt = OptionParser.new
35
+ opt.on('-i file',"input file") {|v| infile=v }
36
+ opt.on('-o file',"output file") {|v| outfile=v }
37
+ opt.on('-s',"dump smml data") {|v| $smmlshow=v }
38
+ opt.on('-d d',"input data string") {|v| data=v }
39
+ opt.on('-h',"help") {|v|
40
+ help
41
+ }
42
+ opt.parse!(ARGV)
43
+
44
+ def p *v
45
+ super v if $DEBUG
46
+ end
47
+
48
+
49
+ m=Smml.new
50
+ puts
51
+ data=data.size>0 ? data.split(';')*"\n" : (File.read(infile) rescue (help;exit))
52
+ p data
53
+ data=data.split("\n").map{|i|i.commentoff("\n",'#')}*"\n"
54
+ p data
55
+ smml=Mml.tosmml(data)
56
+ puts smml if $smmlshow || $DEBUG
57
+ m.octave=:far
58
+ m.data=smml
59
+ m.outfile=outfile
60
+ m.make
61
+ m.save
data/bin/smml CHANGED
@@ -8,7 +8,6 @@ begin
8
8
  require'./lib/smml/msm'
9
9
  rescue LoadError
10
10
  require'smml'
11
- p Smml::VERSION
12
11
  end
13
12
 
14
13
  infile=false
@@ -56,14 +55,14 @@ opt.on('-m i',"mode of test/ 1:GM 2:XG 3:GS") {|v| $testmode=v.to_i }
56
55
  opt.on('-n',"test only (dont write outfile)") {|v| $testonly=true }
57
56
  opt.parse!(ARGV)
58
57
 
59
- mtr=MmlTracks.new(tbase,pspl,expfile,cmark)
60
- mtr.infile=infile
61
- mtr.outfile=outfile
62
- mtr.data=data
63
- mtr.velocity=velocity
64
- mtr.bpm=bpm
65
- mtr.octave=octaveMode
66
- mtr.vfuzzy=vfuzzy
67
- mtr.autopan=autopan
68
- mtr.make($test,$fuzzy)
69
- mtr.save if not $testonly
58
+ m=Smml.new(tbase,pspl,expfile,cmark)
59
+ m.infile=infile
60
+ m.outfile=outfile
61
+ m.data=data
62
+ m.velocity=velocity
63
+ m.bpm=bpm
64
+ m.octave=octaveMode
65
+ m.vfuzzy=vfuzzy
66
+ m.autopan=autopan
67
+ m.make($test,$fuzzy)
68
+ m.save if not $testonly
data/bin/ssmml CHANGED
@@ -8,7 +8,6 @@ begin
8
8
  require'./lib/smml/msm'
9
9
  rescue LoadError
10
10
  require'smml'
11
- p Smml::VERSION
12
11
  end
13
12
 
14
13
  infile="infile.mml"
@@ -21,5 +20,5 @@ opt.on('-o file',"output file") {|v| outfile=v }
21
20
  opt.on('-d d',"input data string") {|v| data=v }
22
21
  opt.parse!(ARGV)
23
22
 
24
- mtr=MmlTracks.new
25
- mtr.compile(infile,outfile,data)
23
+ m=Smml.new
24
+ m.compile(infile,outfile,data)
data/lib/smml/msm.rb CHANGED
@@ -7,6 +7,7 @@ $debuglevel=0
7
7
 
8
8
  def hint
9
9
  cmd=File.basename($0)
10
+ puts "Smml v#{Smml::VERSION}"
10
11
  puts <<EOF
11
12
  usage: #{cmd} -d \"dddd dr3 dddd r4 drdrdrdr dddd dr3\" -o outfile.mid -t bpm
12
13
  #{cmd} -i infile.txt -o outfile.mid -t bpm
@@ -2198,7 +2199,7 @@ def modifierComp t,macro
2198
2199
  }*""
2199
2200
  end
2200
2201
 
2201
- class MmlTracks
2202
+ class Smml
2202
2203
  attr_accessor :tracknum, :tbase, :rundatas, :rawdatas, :mx
2203
2204
  attr_accessor :bpm, :velocity, :octave, :vfuzzy, :data, :infile, :outfile, :autopan
2204
2205
  def initialize tbase=480,pagesep='///',expfile=false,cmark=';;'
@@ -2334,3 +2335,104 @@ class MmlTracks
2334
2335
  save
2335
2336
  end
2336
2337
  end
2338
+
2339
+ module Mml
2340
+ def self.calclen len,digdef,last
2341
+ if last == :sound
2342
+ htn=0
2343
+ if len=~/\.+/
2344
+ len=$`.to_i
2345
+ len=digdef if len==0
2346
+ htn=$&.size
2347
+ end
2348
+ len=4.0/len.to_i
2349
+ baselen=len/2.0
2350
+ htn.times{len+=baselen;baselen/=2.0}
2351
+ len=len.round if len==len.round
2352
+ len="" if len==1
2353
+ end
2354
+ len
2355
+ end
2356
+ def self.tosmml data
2357
+ tracks={}
2358
+ tr=0
2359
+ last=:no
2360
+ lines=data.split("\n")
2361
+ lines.each{|mml|
2362
+ octave=3
2363
+ digdef=4
2364
+ mml.scan(/([[:alpha:]]):|([[:alpha:]<>])([#\+\-])?([[:digit:]\.]+)?|@([[:alpha:]]+|[[:digit:]]+)|([[:digit:]\.]+)|([\[\]])| |/).each{|tname,al,sharp,dig,sname,dig2,same|
2365
+ valueAr=[tname,al,sharp,dig,sname,dig2,same]
2366
+ value=valueAr*""
2367
+ (tr=tname;next) if tname
2368
+ len=dig|| digdef
2369
+ len=calclen(len,digdef,:sound)
2370
+ dig2=calclen(dig2,digdef,last) if dig2
2371
+ last=:no
2372
+ v=""
2373
+ case al ? al.upcase : al
2374
+ when ">"
2375
+ octave+=1
2376
+ v="+"
2377
+ p "oct= #{octave} : #{v}"
2378
+ when "<"
2379
+ octave-=1
2380
+ v="-"
2381
+ p "oct= #{octave} : #{v}"
2382
+ when "L"
2383
+ digdef=dig
2384
+ p "defaault length : #{dig}"
2385
+ when "O"
2386
+ v="(oct:#{dig})"
2387
+ p "octave #{dig} : #{v}"
2388
+ when "Q"
2389
+ v="(gate:#{dig})"
2390
+ p "gate #{dig} : #{v}"
2391
+ when "P"
2392
+ v="(pan:#{dig})"
2393
+ p "pan #{dig} : #{v}"
2394
+ when "N"
2395
+ v="{#{dig}}"
2396
+ p "note #{dig} : #{v}"
2397
+ when "T"
2398
+ v="(tempo:#{dig})"
2399
+ p "tempo #{dig} : #{v}"
2400
+ when "V"
2401
+ v="(v:#{dig})"
2402
+ p "velocity #{dig} : #{v}"
2403
+ when "R"
2404
+ v="r#{len}"
2405
+ p "rest #{len} : #{v}"
2406
+ last=:sound
2407
+ when nil
2408
+ if sname
2409
+ v="(p:#{sname})"
2410
+ p "sound name #{sname} : #{v}"
2411
+ elsif same
2412
+ v=same
2413
+ p "same : #{v}"
2414
+ end
2415
+ when "A".."G"
2416
+ note=al.downcase
2417
+ case sharp
2418
+ when "#","+"
2419
+ note=note.upcase
2420
+ when "-"
2421
+ note="(-)"+note
2422
+ end
2423
+ v="#{note}#{len}"
2424
+ p "note #{al} #{sharp} #{len} : #{v}"
2425
+ last=:sound
2426
+ end
2427
+ v="#{dig2}" if dig2
2428
+ STDERR.puts "[#{value}] undefined?" if v=="" && value.size>0
2429
+ if tracks[tr]
2430
+ tracks[tr]<<v
2431
+ else
2432
+ tracks[tr]=v
2433
+ end
2434
+ }
2435
+ }
2436
+ tracks.keys.sort.map{|k|tracks[k]}*"\n|||\n"
2437
+ end
2438
+ end
data/lib/smml/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Smml
2
- VERSION = "0.1.0"
1
+ class Smml
2
+ VERSION = "0.1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tabasano
@@ -42,6 +42,7 @@ description: compile a Music Macro Language file to a Standard MIDI file.
42
42
  email:
43
43
  - pianotoieba+smml@gmail.com
44
44
  executables:
45
+ - mmlsmml
45
46
  - smml
46
47
  - ssmml
47
48
  extensions: []
@@ -54,6 +55,7 @@ files:
54
55
  - lib/smml/midi-programChange-list.txt
55
56
  - lib/smml/msm.rb
56
57
  - lib/smml/version.rb
58
+ - bin/mmlsmml
57
59
  - bin/smml
58
60
  - bin/ssmml
59
61
  - Gemfile