smml 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06bb5368c7eb0544ede87c56f49c7808730e974d
4
- data.tar.gz: 35e8347b78ef6bc939822f70df30c3c6f9980fc8
3
+ metadata.gz: 7e98825702f8770b16248f090e7dca0a3890eb91
4
+ data.tar.gz: d2b6e346dbd790585f5534e8f626e1635bac8cbb
5
5
  SHA512:
6
- metadata.gz: a266b303a40de9ce2a99da0cfaeb25ee24f03d09c3426050b09e14455d879ea8568924a3c42242d7c72808ee5495aabf37caa7af2a4c9d3934383d6582d11054
7
- data.tar.gz: 00c2c5d0aaa44000728c44222c1f070a054957af00699898b2c9d11816f349acf3a879b7572fa8daaec012e8afa8b6d0bddb012ec55b6514b88172d4cc512090
6
+ metadata.gz: 65904b8614d1f1df18564cfa439f54219a8dfb1518709582d42a3a06fcf58bc60566fd162b6a92bf26ca48cbf9c665b179ea1193001442ff54faf2b28d9cf52d
7
+ data.tar.gz: 43fd189cf0d48058b21d802b4f62b55eb293b4fbe33e669c907f3197b434e79aaa2fec21b50f6a1c3356965fc85db1db664da71e0bc002339fc66914de1b423b
@@ -117,6 +117,8 @@ syntax: ...( will be changed time after time)
117
117
  '{d,g,-b}' => multi note
118
118
  ':cmaj7,' => chord name
119
119
  and other commands are with parentheses.
120
+
121
+ for more details, see tutorial_smml.md
120
122
  EOF
121
123
  end
122
124
  def hint
@@ -289,10 +291,10 @@ module MmlReg
289
291
  self.r(key,sort,pre)
290
292
  end
291
293
  def self.trackr
292
- self.r([:hexraw,:sharp,:chord,:sword,:word,:sound,:tieNote,:register,:modifier,:velocity,:tempo,:num,:octave,:note2,:note,:mod,:note?,:sound?])
294
+ self.r([:hexraw,:sharp,:chord,:chword,:word,:sound,:tieNote,:register,:modifier,:velocity,:tempo,:num,:octave,:note2,:note,:mod,:note?,:sound?])
293
295
  end
294
296
  def self.multipletr
295
- self.r([:note2,:sword,:word,:note,:sound,:tieNote,:register,:chord,:numswing,:num,:sharp,:octave,:mod])
297
+ self.r([:note2,:chword,:word,:note,:sound,:tieNote,:register,:chord,:numswing,:num,:sharp,:octave,:mod])
296
298
  end
297
299
  def self.macroDefr
298
300
  self::MacroDef
@@ -319,7 +321,7 @@ module MmlReg
319
321
  :repStart,
320
322
  :repEnd,
321
323
  :note2,
322
- :sword,
324
+ :chword,
323
325
  :word,
324
326
  :modifier,
325
327
  :sharp,
@@ -356,7 +358,8 @@ module MmlReg
356
358
  @@h[:repmark]="\\.FINE|\\.DS|\\.DC|\\.\\$|\\.toCODA|\\.CODA|\\.SKIP"
357
359
  @@h[:comment]="\\( *comment[^\(\)]*\\)"
358
360
  @@h[:note2]="\\( *tne *:[^\(\)]*\\)|\\( *[[:alpha:]\\-\\+]+,[^,]*\\)"
359
- @@h[:sword]="\\([^\(\):,]*:[^\(\),]+\\([^\(\)]+\\)\\)"
361
+ # parenthesis arg, chord inside etc.
362
+ @@h[:chword]="\\([^\(\):,]*:[^\(\),]+\\([^\(\)]+\\)\\)"
360
363
  @@h[:word]="\\([^\(\):,]*:[^\(\)]*\\)"
361
364
  @@h[:wordStart]="\\([^\(\):]*:"
362
365
  @@h[:sharp]="\\([+-]*[[:digit:]\\.]*\\)"
@@ -597,6 +600,7 @@ class Chord
597
600
  end
598
601
  class Notes < Hash
599
602
  @@rythmChannel=9
603
+ @@defaultbase="c"
600
604
  @@notes={
601
605
  "c"=>0,
602
606
  "C"=>1,
@@ -621,7 +625,19 @@ class Notes < Hash
621
625
  def initialize
622
626
  @@notes.each{|k,v|self[k]=v}
623
627
  end
624
- def self.n2note num
628
+ def self.offset a,b="c"
629
+ r=@@notes[a]-@@notes[b]
630
+ if r>6
631
+ r-=12
632
+ elsif r<-6
633
+ r+=12
634
+ else
635
+ end
636
+ r
637
+ end
638
+ def self.n2note num,base="c"
639
+ offset=self.offset(base,@@defaultbase)
640
+ num+=offset
625
641
  @@invert[num%@@octave]
626
642
  end
627
643
  def self.n2octave num
@@ -647,6 +663,102 @@ class Notes < Hash
647
663
  pre+@@invert[num%@@octave]
648
664
  end
649
665
  end
666
+ class Tonality
667
+ def initialize key="c"
668
+ @scalenotesize=7
669
+ @naturalscale=[*"a".."g"]
670
+ @sharp=[:f,:c,:g,:d,:a,:e,:b]
671
+ @flat=@sharp.reverse
672
+ @arabic=[0,1,4,5,7,8,10]
673
+ @cycle=[:c,:f,:A,:D,:G,:C,:F,:b,:e,:a,:d,:g,:c]
674
+ @cf={}
675
+ @cs={}
676
+ @bymarkcount={}
677
+ @sfnow={}
678
+ 7.times{|n|
679
+ i=@cycle[n]
680
+ @cycle.index(i).times{|s|
681
+ @cf[i]=[] if ! @cf[i]
682
+ @cf[i]<<@flat[s]
683
+ }
684
+ }
685
+ 7.times{|n|
686
+ i=@cycle.reverse[n]
687
+ @cycle.reverse.index(i).times{|s|
688
+ @cs[i]=[] if ! @cs[i]
689
+ @cs[i]<<@sharp[s]
690
+ }
691
+ }
692
+ 7.times{|i|@bymarkcount[i]=@cycle.reverse[i]}
693
+ 7.times{|i|@bymarkcount[-i]=@cycle[i]}
694
+ self.set(key)
695
+ end
696
+ def sharp t
697
+ @cs[t.to_sym]
698
+ end
699
+ def flat t
700
+ @cf[t.to_sym]
701
+ end
702
+ def setBySharp t,scale
703
+ return if scale.size>@scalenotesize
704
+ sc=scale.map{|i|Notes.n2note(i,t)}
705
+ offset=Notes.offset(t)
706
+ @naturalscale=@naturalscale.rotate while @naturalscale[0]!=t.downcase
707
+ r=[]
708
+ @scalenotesize.times{|i|
709
+ a=Notes.offset(sc[i],@naturalscale[i])
710
+ @sfnow[@naturalscale[i].to_sym]=a if a!=0
711
+ r<<a
712
+ }
713
+ r
714
+ end
715
+ def setArabic base
716
+ setBySharp(base,@arabic)
717
+ end
718
+ def tonalitycheck t,sfnote=false
719
+ t=@bymarkcount[t.to_i] if t=~/^[-+[:digit:]]/
720
+ if t=~/m$/
721
+ # use relative major tonality data
722
+ t=$`.to_sym
723
+ t=@cycle[(@cycle.index(t)+3)%12]
724
+ end
725
+ t=t.to_sym
726
+ cf=sfnote ? (@cf[t]||[]) : (@cf[t]||[]).size
727
+ cs=sfnote ? (@cs[t]||[]) : (@cs[t]||[]).size
728
+ case @cycle.index(t)
729
+ when 0...7
730
+ [:flat,cf]
731
+ else
732
+ [:sharp,cs]
733
+ end
734
+ end
735
+ def set t
736
+ @key=t
737
+ @sfnow={}
738
+ if t=~/ *arabic/
739
+ setArabic($`)
740
+ elsif t=~/,/
741
+ base,*sc=t.split(',')
742
+ sc=sc.map{|i|i.to_i}
743
+ setBySharp(base,sc)
744
+ else
745
+ r=tonalitycheck(t,true)
746
+ r[1].each{|i|@sfnow[i]=r[0]}
747
+ end
748
+ end
749
+ def getSharp n
750
+ n=n.to_sym
751
+ case @sfnow[n]
752
+ when -2..2 then @sfnow[n]
753
+ when :sharp then 1
754
+ when :flat then -1
755
+ else 0
756
+ end
757
+ end
758
+ def dump
759
+ [:now_cf_cs,[@sfnow,@cf,@cs].map{|i|i.map{|k,v|"#{k} #{v.class==Array ? v.sort : v}"}}]
760
+ end
761
+ end
650
762
  class ScaleNotes < Array
651
763
  def setSampleRate c
652
764
  @samplerate=c
@@ -1244,6 +1356,7 @@ module MidiHex
1244
1356
  # initialize
1245
1357
  def self.prepare bpm=120,tbase=480,vel=0x40,oct=:near,vfuzzy=2,strict=false
1246
1358
  @ready=true
1359
+ @tonality=Tonality.new("c")
1247
1360
  @bendHalfMax=BendHalf
1248
1361
  @strictmode=strict
1249
1362
  @autopan= strict ? false : true
@@ -1299,11 +1412,11 @@ module MidiHex
1299
1412
  end
1300
1413
  def self.setDefault
1301
1414
  @prepareSet=[
1302
- @tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash
1415
+ @tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash,@tonality
1303
1416
  ]
1304
1417
  end
1305
1418
  def self.getDefault
1306
- @tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash=
1419
+ @tbase,@ch,@velocity,@expression,@velocityFuzzy,@basekey,@gateRate,@bendCentOn,@bendrange,@bendCent,@bendNow,@scalenotes,@gtune,@expressionRest,@expressionDef,@registerHash,@swingHash,@tonality=
1307
1420
  @prepareSet
1308
1421
  end
1309
1422
  def self.dumpstatus
@@ -1312,6 +1425,9 @@ module MidiHex
1312
1425
  p [i, val] if "#{val}".size<100
1313
1426
  }
1314
1427
  end
1428
+ def self.setTonality n
1429
+ @tonality.set(n)
1430
+ end
1315
1431
  def self.setmidiname name
1316
1432
  @midiname=name
1317
1433
  end
@@ -1453,6 +1569,15 @@ module MidiHex
1453
1569
  l,r=len,0 if len<lenforgate
1454
1570
  [l,r]
1455
1571
  end
1572
+ def self.notesharp note,sharp
1573
+ s=0
1574
+ if sharp!=0
1575
+ s=sharp
1576
+ else
1577
+ s=@tonality.getSharp(note)
1578
+ end
1579
+ s
1580
+ end
1456
1581
  def self.soundOn key=@basekey,velocity=@velocity,ch=@ch,sharp=0
1457
1582
  key=self.note2key(key) if key.class==String
1458
1583
  key,ch=key if key.class==Array
@@ -1611,6 +1736,7 @@ module MidiHex
1611
1736
  end
1612
1737
  def self.noteCalc c,last,base
1613
1738
  n=@notes[c]
1739
+ n+=self.notesharp(c,0)
1614
1740
  if @octmode==:near && n.class != Array
1615
1741
  if last
1616
1742
  n+=12 if last-n>6
@@ -2026,7 +2152,7 @@ module MidiHex
2026
2152
  k=if tone=~/^_/
2027
2153
  [self.percussionGet(tone),@rythmChannel]
2028
2154
  elsif @notes.keys.member?(i)
2029
- @basekey+oct*12+@notes[i]
2155
+ @basekey+oct*12+@notes[i]+self.notesharp(i,0)
2030
2156
  else
2031
2157
  i.to_i
2032
2158
  end
@@ -2077,9 +2203,8 @@ module MidiHex
2077
2203
  @chordCenter=[[0,@chordCenter].max,0x7f].min
2078
2204
  @firstchordbase=@chordCenter
2079
2205
  end
2080
- # todo: use scale name
2081
2206
  def self.scale s
2082
- s=s.split(",")
2207
+ s=s.scan(/[^,]-[^-,]+|[-+]+[[:digit:]]+|[^()]*\([^()]+\)|[^,]+|,/)-[","]
2083
2208
  first=s.first
2084
2209
  mode=s[1]
2085
2210
  if s.size==1
@@ -2087,18 +2212,19 @@ module MidiHex
2087
2212
  when /^[-+]/
2088
2213
  shift=first.to_i
2089
2214
  @scalenotes=@scalenotes.move(shift)
2215
+ when /^(.)-([^-]+)$/
2216
+ f,mode=$1,$2
2217
+ @scalenotes.reset
2218
+ @scalenotes.setmode(f,:"#{mode}")
2090
2219
  when /^:?(.)(.*)/
2091
2220
  @scalenotes.reset
2092
2221
  base=$1
2093
2222
  ten=Chord.type($2)
2094
2223
  ten.each{|i|
2095
- note=Notes.get(base,i) # if i=~/^[-+]+[[:digit:]]+$/
2224
+ note=Notes.get(base,i)
2096
2225
  @scalenotes<<note
2097
2226
  }
2098
2227
  end
2099
- elsif @scalenotes.keys.member?(:"#{mode}")
2100
- @scalenotes.reset
2101
- @scalenotes.setmode(first,:"#{mode}")
2102
2228
  else
2103
2229
  @scalenotes.reset
2104
2230
  s.each{|i|
@@ -2365,8 +2491,8 @@ module MidiHex
2365
2491
  vars=self.instance_variables.map{|i|i.to_s[1..-1]}.sort
2366
2492
  s=v.split(',')
2367
2493
  s.each{|v|
2368
- v=~/\A[[:alnum:]]+\z/
2369
- if $& && vars.member?(v)
2494
+ v=~/\A([[:alnum:]]+)[[:alnum:].]*\z/
2495
+ if $& && vars.member?($1)
2370
2496
  puts "@#{v} #{eval("@#{v}")}"
2371
2497
  elsif v=="?"
2372
2498
  puts vars*", "
@@ -2649,6 +2775,8 @@ module MidiHex
2649
2775
  when MmlReg.rr([:register])
2650
2776
  i=~/[[:digit:]]+/
2651
2777
  @h<<[:call,:register,$&]
2778
+ when /^\(tonality:(.*)\)/
2779
+ @h<<[:call,:setTonality,$1]
2652
2780
  when /^\(set":(.*)\)/
2653
2781
  d=$1.split(",")
2654
2782
  @h<<[:call,:setRegister,*d]
@@ -3303,8 +3431,11 @@ def repCalc line,macro,tbase
3303
3431
  pointDS=countertmp
3304
3432
  when ";"
3305
3433
  current=""
3306
- when /^\(([^\)]+):$/
3307
- lastcmd=$1 if $1 != "C"
3434
+ when /^\((\^)?([^\)]+):$/
3435
+ mark,cmd=$1,$2
3436
+ # (reUsedCmd:arg) (^onceOnlyCmd:arg)
3437
+ lastcmd=cmd if ! mark && cmd != "C"
3438
+ current="(#{cmd}:"
3308
3439
  when "(:"
3309
3440
  current="(#{lastcmd}:"
3310
3441
  else
@@ -1,3 +1,3 @@
1
1
  class Smml
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
@@ -193,7 +193,7 @@ direct tention order by pre ':' with a half note distance number from chord base
193
193
  ```
194
194
 
195
195
  in chord name, generally numbers don't mean chromatic distance. don't confuse.
196
- easy way of counting distance number in chord is to count only white key ignoring black on a piano.
196
+ when key is c major etc., scale not using sharps/flats , easy way of counting distance number in the chord is to count only white key ignoring black on a piano.
197
197
  +5 means a sharp of 5th. if there is perfect 5th in the chord, 5th note will be deleted by '(+5)' because they don't appear together generally.
198
198
  when you want to use abnormal tentions like conbination of these, direct order can be used like 'c7(:8)' on your own risk.
199
199
  :8 expresses a note sharp of 5th by a half note expression. count all of the white and black key between c and g sharp on a piano.
@@ -218,6 +218,11 @@ list of chromatic scale expression is here, (when base note is 'c')
218
218
  :12 c (next octave)
219
219
  ```
220
220
 
221
+ as an useless example, the chord using all 12 notes of an octave is 'c(:0,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)'
222
+
223
+ normally important tention notes are used in high positions, but now it is not considered in chord transpose calculating.
224
+ all notes are considered as even importances.
225
+
221
226
 
222
227
  ## tempo
223
228
  ;; most commands except note type ones, are inside parenthesis. set the tempo 120 bpm.
@@ -287,6 +292,7 @@ this multi-tone passage is repeated four times. ```:0``` is 'c' and ```:1``` is
287
292
  _snare! = = =
288
293
  ```
289
294
 
295
+
290
296
  ;; set instrument. automaticaly searched by even not exact name. (MIDI program change command)
291
297
  it depend on map files.
292
298
 
@@ -583,8 +589,30 @@ in the same way,
583
589
  is same mean to above. 'o' is dummy note. note hights are substituted by '(N:..)' values.
584
590
 
585
591
 
592
+ ## scale
593
+
594
+ scale values are used for random notes only now.
595
+
596
+
597
+ definition:
598
+
599
+ ```
600
+ (scale:a,b,c,d,e) ;; series of note names
601
+ (scale:d-dorian) ;; starting note and mode name. this will be '(scale:d,e,f,g,a,b,c)'
602
+ (scale:a,+2,+3,+5,+7,+9,+11) ;; first note and plus values to add to first note
603
+ (scale:+5) ;; shift all values from preceding scale. after above scale, this will be '(scale:d, ...)'.
604
+ (scale:g7) ;; by chord name
605
+ (scale:) ;; reset scale value
606
+ ```
607
+
608
+ shift value is by a half tone.
609
+ when arg size of a scale command is one, it is manipulated as a chord name, mode name, or relative shift value.
610
+ still incompleted to use.
611
+
586
612
  ## dummy note
587
613
  'o' is dummy. '?' is for random note etc.
614
+ if a scale has been defined as above, random notes will be selected from its scale notes.
615
+
588
616
 
589
617
  ```
590
618
  ? /2: ???? /
@@ -603,26 +631,36 @@ or maybe
603
631
  ```
604
632
 
605
633
  etc.
606
- if a scale has been defined as below, random notes will be selected from its scale notes.
634
+
635
+
636
+ another random note.
607
637
 
608
638
  ```
609
- (scale:a,b,c,d,e) ;; series of note names
610
- (scale:a,+2,+3,+5,+7,+9,+11) ;; first note and plus values to add to first note
611
- (scale:+5) ;; shift all values from preceding scale. after above scale, this will be '(scale:d, ...)'.
612
- (scale: :g7, ) ;; by chord name
639
+ [ (?:56-58) ] 4 ;; use range 56 to 58, note number. in this case, 4 times repeating maybe '{56}{56}{58}{57}' etc.
640
+ (?:a,b,40,45,90,12) ;; select from a note number or name list.
613
641
  ```
614
642
 
615
- shift value etc. is by a half tone.
616
- still incompleted to use.
643
+ ## tonality
644
+
645
+ ```
646
+ (tonality:d)
647
+ (tonality:+2)
648
+ ```
617
649
 
650
+ set tonality 'd', d major. 'dm' as d minor.
651
+ after above, 'defgabcd' will become 'deFgabCd' automaticaly by two sharps, so '+2' can be used as an argument.
652
+ still under construction.
618
653
 
619
- another random note.
620
654
 
621
655
  ```
622
- [ (?:56-58) ] 4 ;; use range 56 to 58, note number. in this case, 4 times repeating maybe '{56}{56}{58}{57}' etc.
623
- (?:a,b,40,45,90,12) ;; select from a note number or name list.
656
+ (tonality:D)efgabcde
624
657
  ```
625
658
 
659
+ in above, the tonality is 'D' major, e flat major, so following e, a, and b are flat notes.
660
+ feel strange a little bit? i think so too.
661
+
662
+
663
+
626
664
  ## transpose
627
665
 
628
666
  ```
@@ -951,19 +989,46 @@ but now blanks are removed. someday maybe fixed ?
951
989
  (dumpVar: varName)
952
990
  ```
953
991
 
954
- directly set local MidiHex variable, dump while compiling if the varName and value are valid.
992
+ directly set local MidiHex variable, dump while compiling if the varName (with noe method) and value are valid.
993
+
955
994
 
956
995
  # syntax implement policy:
957
996
 
958
997
 
959
998
  parenthesis command is buil with (name:value,value,...). names often used are shorter, or leave it as it is as possible.
960
999
 
961
-
962
- sound is modifier + note + length word.
963
-
1000
+ sound is modifier + note + length word. modifiers are effective for one note only against premodifier etc., parenthesis commands, are for permanent effects.
964
1001
 
965
1002
  let it not too complicated in sound part for visibility.
966
1003
  especially, for other words not to hide note type words.
967
1004
 
968
-
969
1005
  many values in MIDI are 0-127, so values are integers except pre -/+ values that mean differences.
1006
+
1007
+ a priority matter is how to catch up with sound which come to mind and to write down it quickly.
1008
+
1009
+
1010
+ # prologue
1011
+
1012
+ one of my neibourhood, who cann't play or write music, said that oh i remember this piano piece i had listened once only you played last time, i am great, great, great?
1013
+ people can remind or make sounds in their mind easily but it is difficult to write it down except trained.
1014
+ i play the piano and other instruments, but it took another long time to learn writing down music.
1015
+
1016
+
1017
+ at first i felt like starting write music again in a computer, windows pc. i searched softwares.
1018
+ midi is best for me, i thought. cherry is good. i tried it by my pc keyboard.
1019
+ soon i felt uncomfortable. it is too ...
1020
+ i plays the piano that has midi out/in. for me, i thought it is better to use a stand alone midi sequencer with connecting my e-piano as a keyboard.
1021
+ i got and tried QY70 etc.
1022
+ it was useful.
1023
+ a little bit later, again, i felt uncomfortable. it is too much ...
1024
+ set chords, select preset tracks, set melodies, then soon i was able to listen music. great. too much useful, i don't need to complete details.
1025
+ dont need to study or make jazz, latin, ethnic patterns. only to do is to select preset ones.
1026
+ to play the piano is not too difficult, but to play with click sounds is not comfortable. it is not interesting work.
1027
+ it is better than midi event writing with a pc keyboard. but it must be another way to write music for me and some people who don't wanna be machines.
1028
+ MML is best for writing music easily, if able to sing do-re-mi.
1029
+ let's say good-bye to irritate click sounds, mouses and pianos?! lol
1030
+
1031
+
1032
+ but i feel that it is too ... too much difficult to read general MMLs and understand and remind sounds ... sometimes.
1033
+ what can we do? forget music? become a machine? change MML? change the world?
1034
+
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.12
4
+ version: 0.1.13
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-24 00:00:00.000000000 Z
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler