smml 0.1.3.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smml/msm.rb +49 -10
- data/lib/smml/version.rb +1 -1
- data/tutorial_smml.md +113 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3adeb15710c27d8fffde8600d6566f00530fd1e2
|
4
|
+
data.tar.gz: 5589cb7b1d51a32246176a770d8ac4ccdbaa1275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51def6b77027288a689991fca86e9b276b2a490fd82418f82284ba4c00e799a1eaa1060c7cf723894ca98484082539b983f03bbd62fecf1d6929a9ce9d1c6b65
|
7
|
+
data.tar.gz: 8f393f35c258a5e8791d426dab9db5d72d3d105d944cf0fb063b7e52aac316e3c7b644dce4f06bdea6d957783ba46884555b1e1f2b8cd5a069635c9712f83a50
|
data/lib/smml/msm.rb
CHANGED
@@ -16,6 +16,7 @@ usage:
|
|
16
16
|
#{cmd} -i infile.txt -o outfile.mid
|
17
17
|
show syntax
|
18
18
|
#{cmd} -s
|
19
|
+
for farther details, see tutorial_smml.md in gem
|
19
20
|
EOF
|
20
21
|
end
|
21
22
|
def showsyntax
|
@@ -495,6 +496,9 @@ def hext2hex d
|
|
495
496
|
r=ar if hex
|
496
497
|
r
|
497
498
|
end
|
499
|
+
def midiVround v
|
500
|
+
[[v,0x7f].min,0].max
|
501
|
+
end
|
498
502
|
def rolandcheck d
|
499
503
|
return d if $ignoreChecksum
|
500
504
|
if d[1]=="41"
|
@@ -599,7 +603,7 @@ def apply d,macro
|
|
599
603
|
}*""
|
600
604
|
end
|
601
605
|
def rawHexPart d,macro={}
|
602
|
-
li=d.scan(/\$se\([^)]*\)|\$delta\([^)]*\)|\$bend\([^)]*\)|\(bend:[^)]*\)|\(expre:[^)]*\)|./)
|
606
|
+
li=d.scan(/\$se\([^)]*\)|\$delta\([^)]*\)|\$bend\([^)]*\)|\(bend:[^)]*\)|\(expression:[^)]*\)|\(expre:[^)]*\)|./)
|
603
607
|
res=[]
|
604
608
|
li.map{|i|
|
605
609
|
case i
|
@@ -613,8 +617,8 @@ def rawHexPart d,macro={}
|
|
613
617
|
bendHex(d)
|
614
618
|
when /\(bend:([^)]*)\)/
|
615
619
|
"_b__#{$1.split(',')*"_"}?"
|
616
|
-
when /\(expre
|
617
|
-
"_e__#{$
|
620
|
+
when /\(expre(ssion)?:([^)]*)\)/
|
621
|
+
"_e__#{$2.split(',')*"_"}?"
|
618
622
|
else
|
619
623
|
i
|
620
624
|
end
|
@@ -625,10 +629,15 @@ def revertPre d
|
|
625
629
|
gsub(/_e__([^?]*)\?/){"(expre:#{$1.split("_")*","})"}
|
626
630
|
end
|
627
631
|
def worddata word,d
|
628
|
-
d=~/\(#{word}:(([[:digit:].]+),)?([
|
632
|
+
d=~/\(#{word}:(([[:digit:].]+),)?([-+,.[:digit:]]+)\)/
|
629
633
|
if $&
|
630
634
|
pos=$1 ? $2.to_i : 0
|
631
|
-
depth=$3.split(',').map{|i|
|
635
|
+
depth=$3.split(',').map{|i|
|
636
|
+
case i
|
637
|
+
when "+","-" ; i
|
638
|
+
else ; i.to_f
|
639
|
+
end
|
640
|
+
}
|
632
641
|
[:"#{word}",pos,depth]
|
633
642
|
else
|
634
643
|
false
|
@@ -830,6 +839,8 @@ module MidiHex
|
|
830
839
|
@strokefaster= strict ? 1 : 3
|
831
840
|
@startBpm=bpm
|
832
841
|
@midiname=false
|
842
|
+
@trackChannel={}
|
843
|
+
@trackName={}
|
833
844
|
@cmark="#"
|
834
845
|
@marktrack=MarkTrack.new
|
835
846
|
@octmode=oct
|
@@ -841,6 +852,7 @@ module MidiHex
|
|
841
852
|
@rythmChannel=9
|
842
853
|
@notes=Notes.new
|
843
854
|
@ch=0
|
855
|
+
@expression=0x7f
|
844
856
|
@velocity=vel
|
845
857
|
@velocityOrg=vel
|
846
858
|
@velocityFuzzy=vfuzzy
|
@@ -853,7 +865,7 @@ module MidiHex
|
|
853
865
|
@pancenter=64
|
854
866
|
@scalenotes=ScaleNotes.new.reset
|
855
867
|
@gtune=guitarTuning
|
856
|
-
@prepareSet=[@tbase,@ch,@velocity,@velocityFuzzy,@basekey,@gateRate,@bendrange,@bendCent,@scalenotes,@gtune]
|
868
|
+
@prepareSet=[@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendrange,@bendCent,@scalenotes,@gtune]
|
857
869
|
@chmax=15
|
858
870
|
@bendrangemax=127
|
859
871
|
file="midi-programChange-list.txt"
|
@@ -925,7 +937,7 @@ module MidiHex
|
|
925
937
|
@bendCent=8192/@bendrange/100.0 if on
|
926
938
|
end
|
927
939
|
def self.trackPrepare tc=0
|
928
|
-
@tbase,@ch,@velocity,@velocityFuzzy,@basekey,@gateRate,@bendrange,@bendCent,@scalenotes,@gtune=@prepareSet
|
940
|
+
@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendrange,@bendCent,@scalenotes,@gtune=@prepareSet
|
929
941
|
@strokespeed=0
|
930
942
|
@strokeUpDown=1
|
931
943
|
@preGate=[]
|
@@ -939,6 +951,8 @@ module MidiHex
|
|
939
951
|
tc=@chmax if tc>@chmax
|
940
952
|
@panoftrack=panbytrack(tc)
|
941
953
|
@ch=tc
|
954
|
+
@trackChannel[@tracknum]=@ch
|
955
|
+
@trackName[@tracknum]=""
|
942
956
|
Event.new(:dummy).reset
|
943
957
|
end
|
944
958
|
def self.header format,track,tbase=@tbase
|
@@ -1297,7 +1311,16 @@ module MidiHex
|
|
1297
1311
|
Event.new(:e,t," B#{ch} #{n} #{data}\n")
|
1298
1312
|
end
|
1299
1313
|
def self.expre len,d
|
1300
|
-
|
1314
|
+
c=@expression
|
1315
|
+
explus=10
|
1316
|
+
case d
|
1317
|
+
when "+" ; c+=explus
|
1318
|
+
when "-" ; c-=explus
|
1319
|
+
else ; c=d
|
1320
|
+
end
|
1321
|
+
c=midiVround(c)
|
1322
|
+
@expression=c
|
1323
|
+
self.controlChange("11,#{c},#{len}")
|
1301
1324
|
end
|
1302
1325
|
def self.ProgramChange ch,inst,len=0
|
1303
1326
|
ch=@ch if ch==false
|
@@ -1499,6 +1522,13 @@ module MidiHex
|
|
1499
1522
|
def self.gtuning s
|
1500
1523
|
@gtune=s.split(",")
|
1501
1524
|
end
|
1525
|
+
def self.trackName n
|
1526
|
+
if @trackName.values.member?(n)
|
1527
|
+
c=@trackName.keys.select{|k|@trackName[k]==n}[0]
|
1528
|
+
@ch=@trackChannel[c]
|
1529
|
+
end
|
1530
|
+
@trackName[@tracknum]=n
|
1531
|
+
end
|
1502
1532
|
def self.preLength v
|
1503
1533
|
@preLength=v.map{|i|
|
1504
1534
|
case i
|
@@ -1862,6 +1892,9 @@ module MidiHex
|
|
1862
1892
|
@h<<[:waitingtime,$1? $2.to_i : $2.to_f*@tbase]
|
1863
1893
|
when /^\(accent:([^)]*)\)/
|
1864
1894
|
@h<<[:call,:accent,$1]
|
1895
|
+
when /^\(track:(.*)\)/
|
1896
|
+
i=$1
|
1897
|
+
@h<<[:call,:trackName,i]
|
1865
1898
|
when /^\(on:(.*)\)/
|
1866
1899
|
i=$1
|
1867
1900
|
@h<<[:soundOn,i]
|
@@ -1879,10 +1912,11 @@ module MidiHex
|
|
1879
1912
|
chord=$2.split.join.split(",") # .map{|i|self.note2key(i)}
|
1880
1913
|
wait<<[:chord,chord]
|
1881
1914
|
when /^\(text:(.*)\)/
|
1882
|
-
@h<<[:
|
1915
|
+
@h<<[:metaText,$1]
|
1883
1916
|
when /^\(tempo:(.*)\)/
|
1884
1917
|
@bpm=$1.to_i
|
1885
1918
|
@h<<[:tempo,@bpm] if @bpm>0
|
1919
|
+
# limited random note
|
1886
1920
|
when /^\(\?:(.*)\)/
|
1887
1921
|
ks=$1
|
1888
1922
|
if ks=~/\-/
|
@@ -1892,7 +1926,12 @@ module MidiHex
|
|
1892
1926
|
else
|
1893
1927
|
ks=ks.split(",")
|
1894
1928
|
key=ks[rand(ks.size)]
|
1895
|
-
|
1929
|
+
a=:sound
|
1930
|
+
if key=~/\A[[:digit:]]+\z/
|
1931
|
+
a=:rawsound
|
1932
|
+
key=key.to_i
|
1933
|
+
end
|
1934
|
+
wait<<[a,key]
|
1896
1935
|
end
|
1897
1936
|
when /^\(x:(.*)\)/
|
1898
1937
|
key=$1.to_i
|
data/lib/smml/version.rb
CHANGED
data/tutorial_smml.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# smml tutorial
|
2
|
+
|
3
|
+
|
1
4
|
## note
|
2
|
-
;; note 'c', at first.
|
5
|
+
;; listen to the sound of a note 'c', at first.
|
3
6
|
|
4
7
|
```
|
5
8
|
c
|
@@ -9,7 +12,7 @@ c
|
|
9
12
|
;; 'r' means rest. small letters are note names. blanks can be used anywhere and will be ignored.
|
10
13
|
|
11
14
|
```
|
12
|
-
c d e d c3 r
|
15
|
+
r c d e d c3 r
|
13
16
|
```
|
14
17
|
;; capital letters are notes with sharps
|
15
18
|
|
@@ -26,7 +29,7 @@ e D e f F g g2
|
|
26
29
|
- e d c2
|
27
30
|
```
|
28
31
|
|
29
|
-
;; >< tempo up
|
32
|
+
;; >< tempo up/down.
|
30
33
|
|
31
34
|
```
|
32
35
|
f r > f r > f r > f r <<< fr fr fr fr
|
@@ -42,22 +45,25 @@ c d0.5 d0.5 e0.25 e0.25 e0.25 e0.25
|
|
42
45
|
```
|
43
46
|
;; ( thus, length expression is far from standard MML. usualy it is similiar to musical note name. )
|
44
47
|
|
45
|
-
## gate time
|
46
|
-
;; real tone length is important sometimes. gate time command is a percentage of tone length. (staccato etc.)
|
47
|
-
```
|
48
|
-
(g:100) a b c
|
49
|
-
(g:70) a b c
|
50
|
-
```
|
51
|
-
first line is played like with a slar. second one will be played by more shorter sounds.
|
52
48
|
## multiplet
|
53
49
|
;; but above is similiar to bellow
|
54
50
|
```
|
55
51
|
c /: dd / /: eeee /
|
56
52
|
```
|
57
|
-
;; because for example '/3: dd /' means that two 'd' notes are set inside '3' beats.
|
53
|
+
;; because for example '/3: dd /' means that two 'd' notes are set inside '3' beats.
|
58
54
|
```
|
59
55
|
/3: dd / /3: ddd / /3: dddddd / /3: dddddddddddd /
|
60
56
|
```
|
57
|
+
|
58
|
+
## gate time
|
59
|
+
;; real tone length is important sometimes. gate time command is a percentage of tone length. (staccato etc.)
|
60
|
+
```
|
61
|
+
(g:100) a b c
|
62
|
+
(g:70) a b c
|
63
|
+
```
|
64
|
+
first line is played like with a slar. second one will be played by more shorter sounds.
|
65
|
+
|
66
|
+
|
61
67
|
;; set velocity. max is 127.
|
62
68
|
```
|
63
69
|
(v:70) c (v:40) c (v:20) c (v:70) c (v:90) c
|
@@ -66,6 +72,8 @@ c /: dd / /: eeee /
|
|
66
72
|
```
|
67
73
|
(pan:>30) c d e
|
68
74
|
```
|
75
|
+
if you don't, smml sets panpot values automatically.
|
76
|
+
|
69
77
|
|
70
78
|
## repeat phraze
|
71
79
|
;; repeat 3 times
|
@@ -126,7 +134,7 @@ strange ways can be affective currently. '(+4)a' etc.
|
|
126
134
|
```
|
127
135
|
|
128
136
|
## instrument; program change
|
129
|
-
;; drum sound can be used anywhere
|
137
|
+
;; drum sound can be used anywhere, but this is not MIDI way. use instrument name.
|
130
138
|
```
|
131
139
|
_snare! = = =
|
132
140
|
```
|
@@ -142,7 +150,6 @@ _snare! = = =
|
|
142
150
|
## track
|
143
151
|
;; in SMF, MIDI channel is 1 - 16, and drum is in 10 channel. but currently, these are automaticaly set.
|
144
152
|
;; you don't need to think about it. simply seperate tracks with a command '|||'.
|
145
|
-
;; in the future, track names may be used.
|
146
153
|
```
|
147
154
|
(p:piano) c d e f ||| (p:organ) e f g a ||| (p:guitar) g a b c
|
148
155
|
```
|
@@ -152,6 +159,14 @@ _snare! = = =
|
|
152
159
|
||| (p:organ) e f g a
|
153
160
|
||| (p:guitar) g a b c
|
154
161
|
```
|
162
|
+
;; the same track name, the same MIDI channel and setting.
|
163
|
+
```
|
164
|
+
(track:foo) (p:organ) aa
|
165
|
+
||| (track:foo) bb
|
166
|
+
||| (track:hoge) cc
|
167
|
+
```
|
168
|
+
first two tracks are 'organ' sound by the track names declared.
|
169
|
+
|
155
170
|
## page
|
156
171
|
;; then seperate pages by three or longer one line '/'.
|
157
172
|
;; but this command do not adjust time potisions. it simply resets track number increment.
|
@@ -166,7 +181,7 @@ _snare! = = =
|
|
166
181
|
```
|
167
182
|
cdef cdef cdef ||| efga efga efga ||| gabc gabc gabc
|
168
183
|
```
|
169
|
-
;; if you want to adjust tracks, use a blank page. the last three 'c' will be played adjusted.
|
184
|
+
;; if you want to adjust tracks, use a blank page by two lines of page seperaters. the last three 'c' will be played adjusted.
|
170
185
|
```
|
171
186
|
cd ||| e ||| abcde
|
172
187
|
////////////////////
|
@@ -182,9 +197,24 @@ cd ||| e ||| abcde
|
|
182
197
|
||| (mark:positionName) c
|
183
198
|
||| (mark:positionName) c
|
184
199
|
```
|
200
|
+
these are played like this.
|
201
|
+
```
|
202
|
+
cdrrr c ;; track 1
|
203
|
+
||| errrr c ;; track 2
|
204
|
+
||| abcde c ;; track 3
|
205
|
+
```
|
185
206
|
;; marks are not needed for all tracks. positions will be adjusted automaticaly to the preceeding track while the same marks exist.
|
186
207
|
;; like this, most commands except tempo, a command effects its belonging track only.
|
187
208
|
|
209
|
+
|
210
|
+
```
|
211
|
+
[ a b c (mark:m) ] 3
|
212
|
+
```
|
213
|
+
;; same mark names 'm' in repeated section or one track will be automaticaly substituded by 'm m@2 m@3'. to adjust, use it in other tracks.
|
214
|
+
```
|
215
|
+
a b c (mark:m) a b c (mark:m@2) a b c (mark:m@3)
|
216
|
+
```
|
217
|
+
|
188
218
|
## instrument map
|
189
219
|
;; a MIDI Program Change event sets the instrument on a channel.
|
190
220
|
if channel is 10, a note number means each drum instrument.
|
@@ -334,6 +364,19 @@ or maybe
|
|
334
364
|
e /2: cagb /
|
335
365
|
```
|
336
366
|
etc.
|
367
|
+
if a scale has been defined as below, random notes will be selected from its scale notes.
|
368
|
+
```
|
369
|
+
(scale:a,b,c,d,e)
|
370
|
+
(scale:a,+2,+3,+5,+7,+9,+11)
|
371
|
+
```
|
372
|
+
still incompleted to use.
|
373
|
+
|
374
|
+
|
375
|
+
another random note.
|
376
|
+
```
|
377
|
+
[ (?:56-58) ] 4 ;; use range 56 to 58, note number. in this case, 4 times repeating maybe '{56}{56}{58}{57}' etc.
|
378
|
+
(?:a,b,40,45,90,12) ;; select from a note number or name list.
|
379
|
+
```
|
337
380
|
|
338
381
|
## transpose
|
339
382
|
```
|
@@ -346,7 +389,7 @@ major key, minor key ,modulation of keys have not been implimented yet.
|
|
346
389
|
```
|
347
390
|
(cc:10,64)
|
348
391
|
```
|
349
|
-
controlChange number 10 value 64. see SMF format.
|
392
|
+
controlChange number 10 value 64. see SMF format for details.
|
350
393
|
|
351
394
|
## General MIDI etc.
|
352
395
|
```
|
@@ -354,8 +397,17 @@ controlChange number 10 value 64. see SMF format.
|
|
354
397
|
(gs:reset)
|
355
398
|
(xg:on)
|
356
399
|
```
|
357
|
-
after these commands, it need some time over 50 mili sec. or so for running.
|
400
|
+
after these MIDI system commands, it need some time over 50 mili sec. or so for running.
|
358
401
|
implementation of it is not fixed, so for adjusting, please set marks on all tracks. for example '(mark:start)'.
|
402
|
+
or like this.
|
403
|
+
```
|
404
|
+
(gm:on)r
|
405
|
+
///////////////
|
406
|
+
///////////////
|
407
|
+
;; sound data start
|
408
|
+
abc
|
409
|
+
||| def
|
410
|
+
```
|
359
411
|
|
360
412
|
## compile order
|
361
413
|
now compiling order is : page,track seperate => macro set and replace => repeat check => sound data make.
|
@@ -441,11 +493,12 @@ preceding modifier gate rates. if next notes are 'abc' ,3rd tone 'c' is with a g
|
|
441
493
|
new preceding modifiers will cancel old rest preceding values if it remains.
|
442
494
|
|
443
495
|
```
|
444
|
-
^ ;; accent
|
445
|
-
` ;; too fast note, play ahead
|
446
|
-
' ;; too late note, lay back
|
496
|
+
^ ;; accent. for changing a value of accent base, use '(accent:15)'.
|
497
|
+
` ;; too fast note, play ahead. for changing a value of shift ticks base, use '(roll:45)'.
|
498
|
+
' ;; too late note, lay back.
|
447
499
|
```
|
448
500
|
set these modifiers before note commands.
|
501
|
+
|
449
502
|
```
|
450
503
|
(loadf:filename.mid,2)
|
451
504
|
```
|
@@ -460,14 +513,48 @@ this command do not check about track data strictly. be careful.
|
|
460
513
|
|
461
514
|
now, note type commands are :
|
462
515
|
```
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
516
|
+
c ;; single note
|
517
|
+
(-)d ;; single note with flat/sharp/natural modifiers
|
518
|
+
{64} ;; single note by absolute note number
|
519
|
+
_snare! ;; drum note by instrument name search keyword 'snare'
|
520
|
+
{d,g,-b} ;; multi note
|
521
|
+
:cmaj7, ;; chord name
|
522
|
+
= ;; copy of the latest note type command
|
470
523
|
```
|
471
524
|
|
472
525
|
and other commands are with parentheses.
|
473
526
|
|
527
|
+
```'~'``` seems likely note type, but it is zipped to preceding note as calculated note length. most commands cannot be set inside of ```'a~~~'.```
|
528
|
+
|
529
|
+
|
530
|
+
## preprocess
|
531
|
+
;; some pre-process commands.
|
532
|
+
set it in the top of file.
|
533
|
+
|
534
|
+
|
535
|
+
```
|
536
|
+
;; midifilename out.mid
|
537
|
+
;; title this music name
|
538
|
+
```
|
539
|
+
|
540
|
+
## in pre modifier parts
|
541
|
+
limited commands can be used. bend,expre.
|
542
|
+
|
543
|
+
```
|
544
|
+
(A: o o o o o o o o (bend:20,-5000,-4700,-4700,-400,-200,0,0,10000,-10000) o, )
|
545
|
+
(A: o o o o o o o o (expre:20,40,+,+,+,+,-,-,-,-,+,+,+,+,-,-,-,-,+,+,+,+) o, )
|
546
|
+
a b ~ ~ c ~ ~ d e ~ f g a b c d
|
547
|
+
```
|
548
|
+
note loudness is result of velocity, expression and volume values multipled. expression is used for a running note etc..
|
549
|
+
velocity for more long span, volume for total sound level etc.
|
550
|
+
in above case, the 9th note 'b' is with modifier data, expression and bend. the first value is time interval.
|
551
|
+
all after that are real values. the '+' adds 10 to latest value as default.
|
552
|
+
so expression data is ;``` 40,50,60,70,80,70,60,50,40,50,60,70,80...``` with each 20 ticks interval.
|
553
|
+
|
554
|
+
## text
|
555
|
+
text implement to MIDI file.
|
556
|
+
```
|
557
|
+
(text:this_is_a_pen)
|
558
|
+
```
|
559
|
+
but now blanks are removed. someday maybe fixed ?
|
560
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tabasano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|