smml 0.1.11 → 0.1.11.5
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 +4 -4
- data/lib/smml/msm.rb +301 -112
- data/lib/smml/version.rb +1 -1
- data/tutorial_smml.md +23 -2
- 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: bc386302aaef1ecc9aea9dc8a5a3cf2ae35b6535
|
4
|
+
data.tar.gz: 7c506e05aac70336b2d9c474492ece2993f77523
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393656c916d75e843e40541370272454def0751d134f6526eafddf328b883f868279ce0783de05da6ef5b0991cfca90a7a700a6af870b975c4e822bd6b7a96f2
|
7
|
+
data.tar.gz: f817a17d7f50c215db348642e471765fa9e67fabaff70729b2ca0e463b3abc2f1cf926ff1a754599a31b01f148f776ca6941c03c4db04cc2278d057b97f56798
|
data/lib/smml/msm.rb
CHANGED
@@ -147,6 +147,103 @@ class Array
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
)
|
150
|
+
# MyLength.new(1,"2j")
|
151
|
+
# num and fixed mark word, for swing rythm
|
152
|
+
class MyLength < Numeric
|
153
|
+
def initialize *a
|
154
|
+
p [:in,a,a.size] if $DEBUG
|
155
|
+
a=a[0] if a.size==1
|
156
|
+
r=[]
|
157
|
+
case a
|
158
|
+
when String
|
159
|
+
a=~/\?\?([^\?]*)\?\?/
|
160
|
+
a=$1 if $1
|
161
|
+
r=a.split("+")
|
162
|
+
when Array
|
163
|
+
r=a
|
164
|
+
when MyLength
|
165
|
+
r=a.s,a.j
|
166
|
+
else
|
167
|
+
r=[a]
|
168
|
+
end
|
169
|
+
@s=Float(r[0])
|
170
|
+
@j=([r[1]]-[nil]).flatten||[]
|
171
|
+
p [:i,@s,@j,r,a] if $DEBUG
|
172
|
+
end
|
173
|
+
def s
|
174
|
+
@s
|
175
|
+
end
|
176
|
+
def j
|
177
|
+
@j
|
178
|
+
end
|
179
|
+
def + (other)
|
180
|
+
p "#{@s} #{other} +!" if $DEBUG
|
181
|
+
o=MyLength.new(other)
|
182
|
+
s=@s+o.s
|
183
|
+
j=@j
|
184
|
+
j=o.j if j.size<1
|
185
|
+
MyLength.new(s,j)
|
186
|
+
end
|
187
|
+
def - (other)
|
188
|
+
p "#{@s} #{other} -!" if $DEBUG
|
189
|
+
o=MyLength.new(other)
|
190
|
+
s=@s-o.s
|
191
|
+
j=@j
|
192
|
+
MyLength.new(s,j)
|
193
|
+
end
|
194
|
+
def * (other)
|
195
|
+
p "#{@s} #{other} *!" if $DEBUG
|
196
|
+
o=MyLength.new(other)
|
197
|
+
s=@s*o.s
|
198
|
+
j=@j
|
199
|
+
j=o.j if j.size<1
|
200
|
+
MyLength.new(s,j)
|
201
|
+
end
|
202
|
+
def / (other)
|
203
|
+
p "#{@s} #{other} /!" if $DEBUG
|
204
|
+
o=MyLength.new(other)
|
205
|
+
s=@s/o.s
|
206
|
+
j=@j
|
207
|
+
MyLength.new(s,j)
|
208
|
+
end
|
209
|
+
def coerce(other)
|
210
|
+
p [:c] if $DEBUG
|
211
|
+
if other.kind_of?(Float)
|
212
|
+
return MyLength.new(other), self
|
213
|
+
elsif other.kind_of?(Fixnum)
|
214
|
+
return MyLength.new(other), self
|
215
|
+
elsif other.kind_of?(String)
|
216
|
+
return self,MyLength.new(other)
|
217
|
+
else
|
218
|
+
super
|
219
|
+
end
|
220
|
+
end
|
221
|
+
def round
|
222
|
+
MyLength.new(@s.round,@j)
|
223
|
+
end
|
224
|
+
def inspect
|
225
|
+
"#{@s}(#{@j})!?"
|
226
|
+
end
|
227
|
+
def to_s int=true
|
228
|
+
j=@j.inject(""){|s,i|s+(i||"")}
|
229
|
+
(int ? @s.to_i.to_s : @s.to_s)+ (j.size>0 ? "_#{j}" : "")
|
230
|
+
end
|
231
|
+
def to_f
|
232
|
+
self.to_s(false)
|
233
|
+
end
|
234
|
+
def to_l
|
235
|
+
@s
|
236
|
+
end
|
237
|
+
def to_i
|
238
|
+
@s.to_i
|
239
|
+
end
|
240
|
+
end
|
241
|
+
class Numeric
|
242
|
+
def to_myl
|
243
|
+
MyLength.new(self)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
150
247
|
def multilineTrim l,com
|
151
248
|
r=[]
|
152
249
|
on=false
|
@@ -185,14 +282,17 @@ module MmlReg
|
|
185
282
|
puts "Regex part,arg bug",[key-@@keys]
|
186
283
|
raise
|
187
284
|
end
|
285
|
+
def self.rr key, sort=true, pre=""
|
286
|
+
/#{self.r(key,sort,pre)}/
|
287
|
+
end
|
188
288
|
def self.rPlusPre key, pre, sort=true
|
189
289
|
self.r(key,sort,pre)
|
190
290
|
end
|
191
291
|
def self.trackr
|
192
|
-
self.r([:hexraw,:sharp,:chord,:word,:sound,:modifier,:velocity,:tempo,:num,:octave,:note2,:note,:mod,:note?,:sound?])
|
292
|
+
self.r([:hexraw,:sharp,:chord,:word,:sound,:tieNote,:register,:modifier,:velocity,:tempo,:num,:octave,:note2,:note,:mod,:note?,:sound?])
|
193
293
|
end
|
194
294
|
def self.multipletr
|
195
|
-
self.r([:note2,:word,:note,:sound,:chord,:num,:sharp,:octave,:mod])
|
295
|
+
self.r([:note2,:word,:note,:sound,:tieNote,:register,:chord,:numswing,:num,:sharp,:octave,:mod])
|
196
296
|
end
|
197
297
|
def self.macroDefr
|
198
298
|
self::MacroDef
|
@@ -203,6 +303,7 @@ module MmlReg
|
|
203
303
|
@@h={} # mml regex key hash. order is in @@keys
|
204
304
|
@@keys=[
|
205
305
|
:comment,
|
306
|
+
:keyword,
|
206
307
|
:macrodefAStart,
|
207
308
|
:macrodefA,
|
208
309
|
:macrodefStart,
|
@@ -226,9 +327,12 @@ module MmlReg
|
|
226
327
|
:chord,
|
227
328
|
:velocity,
|
228
329
|
:sound,
|
330
|
+
:tieNote,
|
331
|
+
:register,
|
229
332
|
:tempo,
|
230
333
|
:mod,
|
231
334
|
:octave,
|
335
|
+
:numswing,
|
232
336
|
:num,
|
233
337
|
:blank,
|
234
338
|
:valueSep,
|
@@ -261,7 +365,9 @@ module MmlReg
|
|
261
365
|
@@h[:note?]="[BE]"
|
262
366
|
@@h[:dummyNote]="o"
|
263
367
|
@@h[:randNote]="\\?"
|
264
|
-
@@h[:sound]="_[^!]
|
368
|
+
@@h[:sound]="_[^!]+!|="
|
369
|
+
@@h[:tieNote]="~|w"
|
370
|
+
@@h[:register]="\\\"[[:digit:]]+"
|
265
371
|
@@h[:sound?]="[[:alpha:]]"
|
266
372
|
@@h[:DCmark?]="\\.[[:alpha:]]+"
|
267
373
|
@@h[:tempo]="[><][[:digit:]]*"
|
@@ -274,14 +380,16 @@ module MmlReg
|
|
274
380
|
@@h[:repEnd]="\\]"
|
275
381
|
@@h[:multipletStart]="\\/\\*?[[:digit:]\\.]*:"
|
276
382
|
@@h[:multipletmark]="\\/"
|
277
|
-
@@h[:
|
383
|
+
@@h[:numswing]="[[:digit:]],"
|
384
|
+
@@h[:num]="[-+*]?[[:digit:]]+_[[:digit:]]+j,|[-+*]?[[:digit:]]+\\.[[:digit:]]+|[-+*]?[[:digit:]]+"
|
278
385
|
@@h[:hexraw]="&\\([^()]*\\)"
|
279
386
|
@@h[:hexrawStart]="&\\("
|
387
|
+
@@h[:keyword]="macro +"
|
280
388
|
@@h[:macroA]="\\$\\{[^}]+\\}\\[[^\\]]+\\]|\\$[^}\\$\\{\\(\\)]+\\[[^\\]]+\\]"
|
281
389
|
@@h[:macro]="\\$[[:alnum:]]+\\([^)]*\\)|\\$[[:alnum:]]+|\\$\\{[^}]+\\}"
|
282
|
-
@@h[:macrodefAStart]="[[:alnum:]]+\\([,[:alpha:]]+\\):= *\\( *[
|
390
|
+
@@h[:macrodefAStart]="[[:alnum:]]+\\([,[:alpha:]]+\\):= *\\( *[;]"
|
283
391
|
@@h[:macrodefA]= "[[:alnum:]]+\\([,[:alpha:]]+\\):= *[^\\(;\\n][^;\\n]*"
|
284
|
-
@@h[:macrodefStart]="[[:alnum:]]+:= *\\( *[
|
392
|
+
@@h[:macrodefStart]="[[:alnum:]]+:= *\\( *[;]"
|
285
393
|
@@h[:macrodef]= "[[:alnum:]]+:= *[^\\(;\\n][^;\\n]+"
|
286
394
|
@@h[:blank]="[[:blank:]]+"
|
287
395
|
@@h[:valueSep]=","
|
@@ -325,7 +433,7 @@ module MmlReg
|
|
325
433
|
/#{r}|./
|
326
434
|
end
|
327
435
|
def self.blanks
|
328
|
-
[:comment,:blank,:lineSep]
|
436
|
+
[:comment,:blank,:lineSep,:keyword]
|
329
437
|
end
|
330
438
|
end
|
331
439
|
|
@@ -1065,6 +1173,8 @@ module MidiHex
|
|
1065
1173
|
@gateRate=100
|
1066
1174
|
@nowtime=0
|
1067
1175
|
@onlist=[]
|
1176
|
+
@registerHash={}
|
1177
|
+
@swingHash={1=>1.2,2=>1.8}
|
1068
1178
|
@waitingtime=0
|
1069
1179
|
@rythmChannel=9
|
1070
1180
|
@notes=Notes.new
|
@@ -1103,11 +1213,11 @@ module MidiHex
|
|
1103
1213
|
end
|
1104
1214
|
def self.setDefault
|
1105
1215
|
@prepareSet=[
|
1106
|
-
@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef
|
1216
|
+
@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash
|
1107
1217
|
]
|
1108
1218
|
end
|
1109
1219
|
def self.getDefault
|
1110
|
-
@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef=
|
1220
|
+
@tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash=
|
1111
1221
|
@prepareSet
|
1112
1222
|
end
|
1113
1223
|
def self.dumpstatus
|
@@ -1172,8 +1282,8 @@ module MidiHex
|
|
1172
1282
|
cent= @bendCentOn ? 100.0 : 1
|
1173
1283
|
@bendCent=@bendHalfMax/@bendrange/cent
|
1174
1284
|
end
|
1175
|
-
def self.
|
1176
|
-
@
|
1285
|
+
def self.vibratoType m
|
1286
|
+
@vibratoType=
|
1177
1287
|
case m
|
1178
1288
|
when /^expre/
|
1179
1289
|
"expre"
|
@@ -1208,6 +1318,7 @@ module MidiHex
|
|
1208
1318
|
# track initialize
|
1209
1319
|
def self.trackPrepare tc=0
|
1210
1320
|
self.getDefault
|
1321
|
+
@basekeybend=0
|
1211
1322
|
@theremin=false
|
1212
1323
|
@strokespeed=0
|
1213
1324
|
@strokeUpDown=1
|
@@ -1217,6 +1328,7 @@ module MidiHex
|
|
1217
1328
|
@preLength=[]
|
1218
1329
|
@preBefore=[]
|
1219
1330
|
@preAfter=[]
|
1331
|
+
@registered=[]
|
1220
1332
|
@tracknum=tc+1
|
1221
1333
|
tc+=1 if tc>=@rythmChannel # ch10 is drum kit channel
|
1222
1334
|
tc=@chmax if tc>@chmax
|
@@ -1304,7 +1416,8 @@ module MidiHex
|
|
1304
1416
|
r<<self.bend(pos,depth.to_s,ch)
|
1305
1417
|
r
|
1306
1418
|
end
|
1307
|
-
def self.oneNote len=@tbase,key=@basekey,velocity=@velocity,ch=@ch,sharp=0
|
1419
|
+
def self.oneNote len=@tbase,key=@basekey,velocity=@velocity,ch=@ch,sharp=0,swing=false
|
1420
|
+
len+=len*self.getswing(swing)
|
1308
1421
|
bendStart=@bendNow
|
1309
1422
|
ch=[ch,0x0f].min
|
1310
1423
|
key+=sharp
|
@@ -1312,6 +1425,10 @@ module MidiHex
|
|
1312
1425
|
return self.thereminNote(len,key,velocity,ch) if @theremin
|
1313
1426
|
velocity=@preVelocity.shift if @preVelocity.size>0
|
1314
1427
|
gate=@gateRate
|
1428
|
+
if @registered.member?(:staccato)
|
1429
|
+
@registered-=[:staccato]
|
1430
|
+
gate=10
|
1431
|
+
end
|
1315
1432
|
velocity-=rand(@velocityFuzzy) if @velocityFuzzy>0
|
1316
1433
|
velocity=[velocity,0x7f].min
|
1317
1434
|
key=format("%02x",@key)
|
@@ -1354,7 +1471,8 @@ module MidiHex
|
|
1354
1471
|
end
|
1355
1472
|
r
|
1356
1473
|
end
|
1357
|
-
def self.dummyNote key,len,accent=false,sharp=0
|
1474
|
+
def self.dummyNote key,len,accent=false,sharp=0,swing=false
|
1475
|
+
len+=len*self.getswing(swing)
|
1358
1476
|
vel=@veloecity
|
1359
1477
|
vel+=@accentPlus
|
1360
1478
|
if key=="?"
|
@@ -1365,12 +1483,12 @@ module MidiHex
|
|
1365
1483
|
len=@preLength.shift if @preLength.size>0
|
1366
1484
|
self.oneNote(len,key,vel,sharp)
|
1367
1485
|
end
|
1368
|
-
def self.byKey key,len,accent=false,sharp=0
|
1486
|
+
def self.byKey key,len,accent=false,sharp=0,swing=false
|
1369
1487
|
vel=@velocity
|
1370
1488
|
vel+=@accentPlus
|
1371
|
-
self.oneNote(len,key,vel,@ch,sharp)
|
1489
|
+
self.oneNote(len,key,vel,@ch,sharp,swing)
|
1372
1490
|
end
|
1373
|
-
def self.notekey key,length=false,accent=false,sharp=0
|
1491
|
+
def self.notekey key,length=false,accent=false,sharp=0,swing=false
|
1374
1492
|
len,velocity,ch=[@tbase,@velocity,@ch]
|
1375
1493
|
velocity+=@accentPlus if accent
|
1376
1494
|
len=length if length
|
@@ -1379,12 +1497,12 @@ module MidiHex
|
|
1379
1497
|
key,ch=key
|
1380
1498
|
end
|
1381
1499
|
key=key+@basekey
|
1382
|
-
self.oneNote(len,key,velocity,ch,sharp)
|
1500
|
+
self.oneNote(len,key,velocity,ch,sharp,swing)
|
1383
1501
|
end
|
1384
|
-
def self.percussionNote key,len=@tbase,accent=false,sharp=0
|
1502
|
+
def self.percussionNote key,len=@tbase,accent=false,sharp=0,swing=false
|
1385
1503
|
vel=@velocity
|
1386
1504
|
vel+=@accentPlus if accent
|
1387
|
-
self.oneNote(len,key,vel,@rythmChannel,sharp)
|
1505
|
+
self.oneNote(len,key,vel,@rythmChannel,sharp,swing)
|
1388
1506
|
end
|
1389
1507
|
def self.noteCalc c,last,base
|
1390
1508
|
n=@notes[c]
|
@@ -1400,7 +1518,14 @@ module MidiHex
|
|
1400
1518
|
end
|
1401
1519
|
[n,last,base]
|
1402
1520
|
end
|
1403
|
-
def self.
|
1521
|
+
def self.float2bend f
|
1522
|
+
v=f*@bendHalfMax/@bendrange
|
1523
|
+
if @bendCentOn
|
1524
|
+
v=f*100
|
1525
|
+
end
|
1526
|
+
v
|
1527
|
+
end
|
1528
|
+
def self.notes c,l=false,accent=false,sharp=0,sharpFloat=false,swing=false
|
1404
1529
|
if sharpFloat && (sharpFloat!=0)
|
1405
1530
|
s=sharp+sharpFloat
|
1406
1531
|
sharp=s.to_i
|
@@ -1412,16 +1537,15 @@ module MidiHex
|
|
1412
1537
|
n,@lastnote,@basekey=self.noteCalc(c,@lastnote,@basekey)
|
1413
1538
|
r=[]
|
1414
1539
|
if sharpFloat && sharpFloat!=0
|
1415
|
-
v=sharpFloat
|
1416
|
-
v=sharpFloat*100 if @bendCentOn
|
1540
|
+
v=float2bend(sharpFloat)
|
1417
1541
|
@bendNow=v
|
1418
1542
|
v+=bendStart
|
1419
1543
|
r<<self.bend(0,v) if not @theremin
|
1420
|
-
r<<self.notekey(n,l,accent,sharp)
|
1544
|
+
r<<self.notekey(n,l,accent,sharp,swing)
|
1421
1545
|
r<<self.bend(0,bendStart) if not @theremin
|
1422
1546
|
@bendNow=bendStart
|
1423
1547
|
else
|
1424
|
-
r<<self.notekey(n,l,accent,sharp)
|
1548
|
+
r<<self.notekey(n,l,accent,sharp,swing)
|
1425
1549
|
# r<<self.bend(0,bendStart)# if bends
|
1426
1550
|
# @bendNow=bendStart
|
1427
1551
|
end
|
@@ -1433,7 +1557,8 @@ module MidiHex
|
|
1433
1557
|
chord=chord.orotate(1) while chord[0]<base-limit
|
1434
1558
|
chord
|
1435
1559
|
end
|
1436
|
-
def self.chordName c,l=false,accent=false,sharp=0
|
1560
|
+
def self.chordName c,l=false,accent=false,sharp=0,swing=false
|
1561
|
+
l+=l*self.getswing(swing)
|
1437
1562
|
c=~/(.)([^(]*)(\((.*)\))?/
|
1438
1563
|
root=$1
|
1439
1564
|
type=$2
|
@@ -1536,7 +1661,8 @@ module MidiHex
|
|
1536
1661
|
cc=c.map{|i|(i-r)%12}.sort.map{|i|i+r}
|
1537
1662
|
cc
|
1538
1663
|
end
|
1539
|
-
def self.chord c,l=false,accent=false,sharp=0
|
1664
|
+
def self.chord c,l=false,accent=false,sharp=0,swing=false
|
1665
|
+
l+=l*self.getswing(swing)
|
1540
1666
|
r=[]
|
1541
1667
|
sspeed=@strokespeed
|
1542
1668
|
c=c.reverse if @strokeUpDown<0
|
@@ -1552,7 +1678,7 @@ module MidiHex
|
|
1552
1678
|
r+=self.soundOff(i,@ch,sharp)
|
1553
1679
|
}
|
1554
1680
|
self.strokeUpDownReset
|
1555
|
-
r+=self.rest(rest) if rest>0
|
1681
|
+
r+=self.rest(rest,false,@ch) if rest>0
|
1556
1682
|
r
|
1557
1683
|
end
|
1558
1684
|
def self.strokeUpDownReset
|
@@ -1561,7 +1687,7 @@ module MidiHex
|
|
1561
1687
|
def self.setExpressionRest v
|
1562
1688
|
@expressionRest=v.to_i
|
1563
1689
|
end
|
1564
|
-
def self.rest len
|
1690
|
+
def self.rest len,swing=false,ch=@ch
|
1565
1691
|
chx=format("%01x",ch)
|
1566
1692
|
@nowtime+=len
|
1567
1693
|
r=[]
|
@@ -1576,7 +1702,7 @@ module MidiHex
|
|
1576
1702
|
r
|
1577
1703
|
end
|
1578
1704
|
def self.restHex len=@tbase,ch=@ch
|
1579
|
-
r=self.rest(len,ch)
|
1705
|
+
r=self.rest(len,false,ch)
|
1580
1706
|
r[0]
|
1581
1707
|
end
|
1582
1708
|
# d : hex data
|
@@ -1811,6 +1937,7 @@ module MidiHex
|
|
1811
1937
|
depth=@lastbend+depth
|
1812
1938
|
end
|
1813
1939
|
@lastbend=depth
|
1940
|
+
depth+=@basekeybend
|
1814
1941
|
pos+=@waitingtime
|
1815
1942
|
@waitingtime=0
|
1816
1943
|
@nowtime+=pos
|
@@ -1866,6 +1993,10 @@ module MidiHex
|
|
1866
1993
|
@basekey=d
|
1867
1994
|
end
|
1868
1995
|
end
|
1996
|
+
def self.basekeyReset
|
1997
|
+
self.basekeySet(@basekeyOrg)
|
1998
|
+
@basekeybend=0
|
1999
|
+
end
|
1869
2000
|
def self.chordCenter c
|
1870
2001
|
case c
|
1871
2002
|
when "reset"
|
@@ -1966,7 +2097,7 @@ module MidiHex
|
|
1966
2097
|
}
|
1967
2098
|
end
|
1968
2099
|
def self.revertPre d
|
1969
|
-
mode=@
|
2100
|
+
mode=@vibratoType
|
1970
2101
|
d.gsub(/_b__([^?]*)\?/){"(bend:#{$1.split("_")*","})"}.
|
1971
2102
|
gsub(/_e__([^?]*)\?/){"(expre:#{$1.split("_")*","})"}.
|
1972
2103
|
gsub(/_p__([^?]*)\?/){"(panpot:#{$1.split("_")*","})"}.
|
@@ -2085,17 +2216,18 @@ module MidiHex
|
|
2085
2216
|
r<<self.expre(restl,e)
|
2086
2217
|
r
|
2087
2218
|
end
|
2088
|
-
def self.noteExpression arg,t,accent,sharp,sharpFloat
|
2219
|
+
def self.noteExpression arg,t,accent,sharp,sharpFloat,swing
|
2089
2220
|
lexpression=@expression
|
2090
2221
|
n,e=arg.split(',')
|
2091
2222
|
r=[]
|
2092
2223
|
r<<self.expre(0,e)
|
2093
|
-
r<<self.notes(n,t,accent,sharp,sharpFloat)
|
2224
|
+
r<<self.notes(n,t,accent,sharp,sharpFloat,swing)
|
2094
2225
|
r<<self.expre(0,lexpression)
|
2095
2226
|
r
|
2096
2227
|
end
|
2097
2228
|
# transition rate, note, expression
|
2098
|
-
def self.tne arg,t,accent,sharp,sharpFloat
|
2229
|
+
def self.tne arg,t,accent,sharp,sharpFloat,swing
|
2230
|
+
t+=t*self.getswing(swing)
|
2099
2231
|
exp=@expression
|
2100
2232
|
trans,n,e=arg.split(',')
|
2101
2233
|
trans=0.3 if trans.size==0
|
@@ -2124,6 +2256,20 @@ module MidiHex
|
|
2124
2256
|
@lastTne[-1]=@basekey
|
2125
2257
|
r
|
2126
2258
|
end
|
2259
|
+
def self.register v
|
2260
|
+
r=@registerHash[v.to_i]
|
2261
|
+
if r
|
2262
|
+
@registered<<r.to_sym
|
2263
|
+
else
|
2264
|
+
STDERR.puts "register: no data"
|
2265
|
+
end
|
2266
|
+
end
|
2267
|
+
def self.setSwing k,v
|
2268
|
+
@swingHash[k.to_i]=v.to_f
|
2269
|
+
end
|
2270
|
+
def self.setRegister k,v
|
2271
|
+
@registerHash[k.to_i]=v
|
2272
|
+
end
|
2127
2273
|
def self.broken v
|
2128
2274
|
v=~/off/
|
2129
2275
|
@broken= $& ? false : true
|
@@ -2139,6 +2285,11 @@ module MidiHex
|
|
2139
2285
|
puts "bad name '#{v}'"
|
2140
2286
|
end
|
2141
2287
|
end
|
2288
|
+
def self.key2bend k
|
2289
|
+
v=k.class==Float ? @bendCent*(k-k.to_i) : 0
|
2290
|
+
v*=100 if @bendCentOn
|
2291
|
+
v
|
2292
|
+
end
|
2142
2293
|
def self.eventlist2str elist
|
2143
2294
|
@eventlist=[]
|
2144
2295
|
r=@eventlist
|
@@ -2151,7 +2302,8 @@ module MidiHex
|
|
2151
2302
|
case cmd
|
2152
2303
|
when :comment
|
2153
2304
|
when :basekeyPlus
|
2154
|
-
@basekey+=arg[0]
|
2305
|
+
@basekey+=arg[0].to_i
|
2306
|
+
@basekeybend+=self.key2bend(arg[0])
|
2155
2307
|
when :raw
|
2156
2308
|
r<<Event.new(:raw,arg[0])
|
2157
2309
|
when :ahead
|
@@ -2229,9 +2381,92 @@ module MidiHex
|
|
2229
2381
|
# Array of String or Event class instance
|
2230
2382
|
rr
|
2231
2383
|
end
|
2384
|
+
def self.getswing v,hs=@swingHash
|
2385
|
+
r=v ? hs[v.to_i] : false
|
2386
|
+
if r
|
2387
|
+
(r-v.to_i)/v.to_i
|
2388
|
+
else
|
2389
|
+
0
|
2390
|
+
end
|
2391
|
+
end
|
2392
|
+
def self.tie d,tbase,swingHash
|
2393
|
+
res=[]
|
2394
|
+
# if no length word after '~' length is 1
|
2395
|
+
li=[]
|
2396
|
+
li0=d.scan(MmlReg::RwAll)
|
2397
|
+
li0.size.times{|i|
|
2398
|
+
li<<li0[i]
|
2399
|
+
case li0[i]
|
2400
|
+
when "~","w"
|
2401
|
+
li<<"1" if li0[i+1] !~ /^(\*)?[[:digit:]]/
|
2402
|
+
else
|
2403
|
+
end
|
2404
|
+
}
|
2405
|
+
li.each{|i|
|
2406
|
+
case i
|
2407
|
+
when /^\(setSwing:(.*)\)/
|
2408
|
+
k,v=$1.split(',')
|
2409
|
+
swingHash[k.to_i]=v.to_f
|
2410
|
+
res<<[:modifier,i]
|
2411
|
+
when /^(\*)?([[:digit:].]+)(_([[:digit:]]+)j,)?/
|
2412
|
+
tick=$1? $2.to_f : $2.to_f*tbase
|
2413
|
+
tick+=tick*self.getswing($4,swingHash)
|
2414
|
+
if res[-1][0]==:tick
|
2415
|
+
res[-1][1]+=tick
|
2416
|
+
else
|
2417
|
+
res<<[:tick,tick]
|
2418
|
+
end
|
2419
|
+
when "~"
|
2420
|
+
res<<[:tick,tbase] if res[-1][0]==:e
|
2421
|
+
# add vibrato data
|
2422
|
+
when "w"
|
2423
|
+
lasttick=0
|
2424
|
+
lasttick=res[-1][1] if res[-1][0]==:tick
|
2425
|
+
res<<[:tick,tbase] if res[-1][0]==:e
|
2426
|
+
m="m"
|
2427
|
+
d=innerdata(m,["100_start#{lasttick}_vibrato"])
|
2428
|
+
res.insert(-3,[:modifier,"(A:#{d})"])
|
2429
|
+
when /^\([VGABLN]:[^)]+/
|
2430
|
+
res<<[:modifier,i]
|
2431
|
+
else
|
2432
|
+
res<<[:e,i]
|
2433
|
+
end
|
2434
|
+
}
|
2435
|
+
line=""
|
2436
|
+
frest=0
|
2437
|
+
(res.size-1).times{|i|
|
2438
|
+
next if res[i][0]!=:modifier
|
2439
|
+
next if res[i+1][0]!=:tick
|
2440
|
+
# if tick after modifier, it must be by tie mark
|
2441
|
+
n=i-1
|
2442
|
+
n-=1 while res[n][0]!=:tick
|
2443
|
+
res[n][1]+=res[i+1][1]
|
2444
|
+
res[i+1][0]=:omit
|
2445
|
+
}
|
2446
|
+
res.each{|mark,data|
|
2447
|
+
case mark
|
2448
|
+
when :e , :modifier
|
2449
|
+
line<<data
|
2450
|
+
when :tick
|
2451
|
+
tick=data.to_i
|
2452
|
+
frest+=data-tick
|
2453
|
+
(tick+=frest;puts "frest:#{frest}" if $DEBUG && $debuglevel>1;frest=0) if frest>1
|
2454
|
+
line<<"*#{tick}"
|
2455
|
+
when :omit
|
2456
|
+
puts "# shift tick data by tie part" if $DEBUG
|
2457
|
+
else
|
2458
|
+
STDERR.puts "tie?"
|
2459
|
+
end
|
2460
|
+
}
|
2461
|
+
p res,line if $DEBUG && $debuglevel>1
|
2462
|
+
line
|
2463
|
+
end
|
2232
2464
|
def self.makefraze mmldata,tc
|
2233
2465
|
return "" if not mmldata
|
2234
2466
|
self.trackPrepare(tc)
|
2467
|
+
p [:beforeTie,mmldata] if $DEBUG
|
2468
|
+
mmldata=self.tie(mmldata,@tbase,@swingHash)
|
2469
|
+
p [:afterTie,mmldata] if $DEBUG
|
2235
2470
|
@systemWait=120
|
2236
2471
|
@h=[]
|
2237
2472
|
wait=[]
|
@@ -2250,8 +2485,9 @@ module MidiHex
|
|
2250
2485
|
cmd.each{|i|
|
2251
2486
|
if wait.size>0
|
2252
2487
|
t=@tbase
|
2253
|
-
i=~/^(\*)?([[:digit:]]+(\.[[:digit:]]+)?)
|
2488
|
+
i=~/^(\*)?([[:digit:]]+(\.[[:digit:]]+)?)(_([[:digit:]]+)j,)?/
|
2254
2489
|
tickmode=$1
|
2490
|
+
swing=$5
|
2255
2491
|
t=$2.to_f if $&
|
2256
2492
|
if $&
|
2257
2493
|
if tickmode
|
@@ -2268,8 +2504,8 @@ module MidiHex
|
|
2268
2504
|
end
|
2269
2505
|
end
|
2270
2506
|
wait.each{|m,c|
|
2271
|
-
arg=[c,t,accent,sharp]
|
2272
|
-
arg2=[c,t,accent,sharp,sharpFloat]
|
2507
|
+
arg=[c,t,accent,sharp,swing]
|
2508
|
+
arg2=[c,t,accent,sharp,sharpFloat,swing]
|
2273
2509
|
case m
|
2274
2510
|
when :percussion
|
2275
2511
|
@h<<[:percussionNote,*arg]
|
@@ -2288,7 +2524,7 @@ module MidiHex
|
|
2288
2524
|
when :chordName
|
2289
2525
|
@h<<[:chordName,*arg]
|
2290
2526
|
when :rest
|
2291
|
-
@h<<[:rest,t]
|
2527
|
+
@h<<[:rest,t,swing]
|
2292
2528
|
end
|
2293
2529
|
}
|
2294
2530
|
lastwait=wait
|
@@ -2314,10 +2550,21 @@ module MidiHex
|
|
2314
2550
|
plus=s1 ? s1[0..0] : "+"
|
2315
2551
|
sharpFloat*=-1 if plus=="-"
|
2316
2552
|
sharp="#{plus}#{n}".to_i
|
2317
|
-
when /^\(key:(-?)\+?([[:digit:]]+)\)/
|
2318
|
-
|
2553
|
+
when /^\(key:(-?)\+?([[:digit:].]+)\)/
|
2554
|
+
num=$2
|
2555
|
+
tr=num.to_i
|
2556
|
+
tr=num.to_f if num=~/\./
|
2319
2557
|
tr*=-1 if $1=="-"
|
2320
2558
|
@h<<[:basekeyPlus,tr]
|
2559
|
+
when MmlReg.rr([:register])
|
2560
|
+
i=~/[[:digit:]]+/
|
2561
|
+
@h<<[:call,:register,$&]
|
2562
|
+
when /^\(set":(.*)\)/
|
2563
|
+
d=$1.split(",")
|
2564
|
+
@h<<[:call,:setRegister,*d]
|
2565
|
+
when /^\(setSwing:(.*)\)/
|
2566
|
+
d=$1.split(",")
|
2567
|
+
@h<<[:call,:setSwing,*d]
|
2321
2568
|
when /^\(broken:(.*)\)/
|
2322
2569
|
@h<<[:call,:broken,$1]
|
2323
2570
|
when /^\(tne:(.*)\)/
|
@@ -2362,8 +2609,8 @@ module MidiHex
|
|
2362
2609
|
@h<<[:call,:preBefore,s]
|
2363
2610
|
when /^\(roll:(.*)\)/
|
2364
2611
|
@shiftbase=$1.to_i
|
2365
|
-
when /^\(
|
2366
|
-
@h<<[:call,:
|
2612
|
+
when /^\(vibratoType:(.*)\)/
|
2613
|
+
@h<<[:call,:vibratoType,$1]
|
2367
2614
|
when /^\(vibrato:(.*)\)/
|
2368
2615
|
v=$1
|
2369
2616
|
@h<<[:setFloat,:vibratoRate,v]
|
@@ -2379,7 +2626,7 @@ module MidiHex
|
|
2379
2626
|
oct=($2.to_i+2)*12
|
2380
2627
|
@h<<[:call,:basekeySet,oct]
|
2381
2628
|
when /^\(key:reset\)/
|
2382
|
-
@h<<[:call,:
|
2629
|
+
@h<<[:call,:basekeyReset]
|
2383
2630
|
when /^\(p:(([[:digit:]]+),)?(([[:digit:]]+)|([\?[:alnum:]]+)(,([[:digit:]]))?)\)/
|
2384
2631
|
channel=$1 ? $2.to_i : false
|
2385
2632
|
subNo=false
|
@@ -2726,13 +2973,19 @@ def multiplet d,tbase
|
|
2726
2973
|
r.each{|i|
|
2727
2974
|
case i
|
2728
2975
|
# modifier
|
2729
|
-
when /^[-+]+[[:digit:]]*/,/^[\^`',<>]/,/^\([-+]*[[:digit:]]?\)
|
2976
|
+
when /^[-+]+[[:digit:]]*/,/^[\^`',<>]/,/^\([-+]*[[:digit:]]?\)/,MmlReg.rr([:register])
|
2730
2977
|
mod<<i
|
2731
2978
|
# note
|
2732
2979
|
when /^\((\?|x|C|chord|tne):[^\)]+\)|^\^?:[^,]+,|^=|\([[:alpha:]\\-\\+]+,[^,]*\)/
|
2733
2980
|
lengths<<1
|
2734
2981
|
notes<<"#{mod*""}#{i}"
|
2735
2982
|
mod=[]
|
2983
|
+
# length swing
|
2984
|
+
when /^([[:digit:]]+),/
|
2985
|
+
n=$1.to_i
|
2986
|
+
s=n.to_myl
|
2987
|
+
s+=MyLength.new(0,"#{n}j,")
|
2988
|
+
lengths[-1]*=s
|
2736
2989
|
# length
|
2737
2990
|
when /^[[:digit:]]+/
|
2738
2991
|
lengths[-1]*=i.to_f
|
@@ -2740,11 +2993,12 @@ def multiplet d,tbase
|
|
2740
2993
|
when /^\([^\(\):,]*:.*\)/
|
2741
2994
|
mod<<i
|
2742
2995
|
else
|
2743
|
-
lengths<<1
|
2996
|
+
lengths<<1.to_myl
|
2744
2997
|
notes<<"#{mod*""}#{i}"
|
2745
2998
|
mod=[]
|
2746
2999
|
end
|
2747
3000
|
}
|
3001
|
+
p [:multipletle,lengths] if $DEBUG
|
2748
3002
|
sum=lengths.inject{|s,i|s+i}
|
2749
3003
|
ls=lengths.map{|i|(i*1.0/sum*total).round} # .map{|i|i.round(dep)}
|
2750
3004
|
er=(total-ls.inject{|s,i|s+i}).to_i
|
@@ -2859,72 +3113,7 @@ def nestsearch d,macro
|
|
2859
3113
|
p "nest? #{a} #{b} #{c} #{chord}",r,macro if $DEBUG
|
2860
3114
|
a||b||c||chord
|
2861
3115
|
end
|
2862
|
-
|
2863
|
-
res=[]
|
2864
|
-
# if no length word after '~' length is 1
|
2865
|
-
li=[]
|
2866
|
-
li0=d.scan(MmlReg::RwAll)
|
2867
|
-
li0.size.times{|i|
|
2868
|
-
li<<li0[i]
|
2869
|
-
case li0[i]
|
2870
|
-
when "~","w"
|
2871
|
-
li<<"1" if li0[i+1] !~ /^(\*)?[[:digit:]]/
|
2872
|
-
else
|
2873
|
-
end
|
2874
|
-
}
|
2875
|
-
li.each{|i|
|
2876
|
-
case i
|
2877
|
-
when /^(\*)?([[:digit:].]+)/
|
2878
|
-
tick=$1? $2.to_f : $2.to_f*tbase
|
2879
|
-
if res[-1][0]==:tick
|
2880
|
-
res[-1][1]+=tick
|
2881
|
-
else
|
2882
|
-
res<<[:tick,tick]
|
2883
|
-
end
|
2884
|
-
when "~"
|
2885
|
-
res<<[:tick,tbase] if res[-1][0]==:e
|
2886
|
-
when "w"
|
2887
|
-
lasttick=0
|
2888
|
-
lasttick=res[-1][1] if res[-1][0]==:tick
|
2889
|
-
res<<[:tick,tbase] if res[-1][0]==:e
|
2890
|
-
m="m"
|
2891
|
-
d=innerdata(m,["100_start#{lasttick}_vibrato"])
|
2892
|
-
res.insert(-3,[:modifier,"(A:#{d})"])
|
2893
|
-
when /^\([VGABLN]:[^)]+/
|
2894
|
-
res<<[:modifier,i]
|
2895
|
-
else
|
2896
|
-
res<<[:e,i]
|
2897
|
-
end
|
2898
|
-
}
|
2899
|
-
line=""
|
2900
|
-
frest=0
|
2901
|
-
(res.size-1).times{|i|
|
2902
|
-
next if res[i][0]!=:modifier
|
2903
|
-
next if res[i+1][0]!=:tick
|
2904
|
-
# if tick after modifier, it must be by tie mark
|
2905
|
-
n=i-1
|
2906
|
-
n-=1 while res[n][0]!=:tick
|
2907
|
-
res[n][1]+=res[i+1][1]
|
2908
|
-
res[i+1][0]=:omit
|
2909
|
-
}
|
2910
|
-
res.each{|mark,data|
|
2911
|
-
case mark
|
2912
|
-
when :e , :modifier
|
2913
|
-
line<<data
|
2914
|
-
when :tick
|
2915
|
-
tick=data.to_i
|
2916
|
-
frest+=data-tick
|
2917
|
-
(tick+=frest;puts "frest:#{frest}" if $DEBUG && $debuglevel>1;frest=0) if frest>1
|
2918
|
-
line<<"*#{tick}"
|
2919
|
-
when :omit
|
2920
|
-
puts "# shift tick data by tie part" if $DEBUG
|
2921
|
-
else
|
2922
|
-
STDERR.puts "tie?"
|
2923
|
-
end
|
2924
|
-
}
|
2925
|
-
p res,line if $DEBUG && $debuglevel>1
|
2926
|
-
line
|
2927
|
-
end
|
3116
|
+
|
2928
3117
|
# repeat block analysis: no relation with MIDI format
|
2929
3118
|
# '(:..)' => '(lastcmd:..)'
|
2930
3119
|
def repCalc line,macro,tbase
|
@@ -3032,7 +3221,7 @@ def repCalc line,macro,tbase
|
|
3032
3221
|
p res if $DEBUG && $debuglevel>1
|
3033
3222
|
# 空白
|
3034
3223
|
res=res.split.join
|
3035
|
-
res
|
3224
|
+
res
|
3036
3225
|
end
|
3037
3226
|
def loadCalc d
|
3038
3227
|
if d=~/\(loadf:(.+)(,(.+))?\)/
|
data/lib/smml/version.rb
CHANGED
data/tutorial_smml.md
CHANGED
@@ -782,7 +782,7 @@ now, note type commands are :
|
|
782
782
|
|
783
783
|
and other commands are with parentheses.
|
784
784
|
|
785
|
-
```
|
785
|
+
```~``` or ```w``` seems likely note type, but it is compressed to preceding note as calculated note length. most commands cannot be set inside of ```'c~~~'.```
|
786
786
|
|
787
787
|
;; theremin like sound,
|
788
788
|
|
@@ -817,10 +817,11 @@ rest of second 'f' is 30% of one beat instead others are 30% of three beats.
|
|
817
817
|
;; vibrato
|
818
818
|
|
819
819
|
```
|
820
|
+
(vibratoType:bend)
|
820
821
|
f~~ww~~
|
821
822
|
```
|
822
823
|
|
823
|
-
note f then vibrato. bend or expression, under construction.
|
824
|
+
note f then vibrato. bend, panpot or expression, under construction.
|
824
825
|
|
825
826
|
;; _REPEAT_ variable
|
826
827
|
|
@@ -835,6 +836,26 @@ as if uncontrolled
|
|
835
836
|
(broken:on) (broken:off)
|
836
837
|
```
|
837
838
|
|
839
|
+
;; swing
|
840
|
+
easy way to express fuzzy swing rythm.
|
841
|
+
|
842
|
+
```
|
843
|
+
/:a2b1/
|
844
|
+
(setSwing:2,2.4)(setSwing:1,0.6)/:a2,b1,/
|
845
|
+
(setSwing:2,1.8)(setSwing:1,1.2)/:a2,b1,/
|
846
|
+
```
|
847
|
+
|
848
|
+
just 2:1, first longer, first shorter. broken if setting part is wrong.
|
849
|
+
|
850
|
+
;; register of modifiers
|
851
|
+
|
852
|
+
```
|
853
|
+
(set":1,staccato) "1e
|
854
|
+
```
|
855
|
+
|
856
|
+
```"1``` sets modifier number 1 as staccato for note```e```. now there are no other modes. reserved for simple presetting modifier for one note.
|
857
|
+
|
858
|
+
|
838
859
|
## preprocess
|
839
860
|
;; some pre-process commands.
|
840
861
|
set it in the top of file.
|
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.11
|
4
|
+
version: 0.1.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tabasano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|