musa-dsl 0.41.0 → 0.42.0
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/.gitignore +1 -0
- data/README.md +15 -1
- data/docs/README.md +1 -0
- data/docs/subsystems/datasets.md +75 -0
- data/docs/subsystems/generative.md +92 -6
- data/docs/subsystems/music.md +33 -14
- data/docs/subsystems/transport.md +26 -0
- data/lib/musa-dsl/datasets/dataset.rb +2 -0
- data/lib/musa-dsl/datasets/gdv.rb +3 -3
- data/lib/musa-dsl/datasets/p.rb +1 -1
- data/lib/musa-dsl/datasets/score/to-mxml/process-time.rb +4 -2
- data/lib/musa-dsl/datasets/score.rb +3 -1
- data/lib/musa-dsl/generative/generative-grammar.rb +3 -1
- data/lib/musa-dsl/generative/markov.rb +1 -1
- data/lib/musa-dsl/midi/midi-voices.rb +3 -1
- data/lib/musa-dsl/music/chord-definition.rb +7 -5
- data/lib/musa-dsl/music/chord-definitions.rb +37 -0
- data/lib/musa-dsl/music/chords.rb +69 -47
- data/lib/musa-dsl/music/scale_kinds/major_scale_kind.rb +1 -1
- data/lib/musa-dsl/music/scale_kinds/minor_natural_scale_kind.rb +1 -1
- data/lib/musa-dsl/music/scales.rb +219 -107
- data/lib/musa-dsl/musicxml/builder/note.rb +31 -92
- data/lib/musa-dsl/musicxml/builder/pitched-note.rb +33 -94
- data/lib/musa-dsl/musicxml/builder/rest.rb +30 -91
- data/lib/musa-dsl/musicxml/builder/unpitched-note.rb +31 -91
- data/lib/musa-dsl/neumas/array-to-neumas.rb +1 -1
- data/lib/musa-dsl/neumas/neuma-gdv-decoder.rb +2 -2
- data/lib/musa-dsl/sequencer/sequencer-dsl.rb +367 -3
- data/lib/musa-dsl/series/base-series.rb +250 -240
- data/lib/musa-dsl/series/buffer-serie.rb +10 -5
- data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +6 -3
- data/lib/musa-dsl/series/main-serie-constructors.rb +19 -15
- data/lib/musa-dsl/series/main-serie-operations.rb +74 -29
- data/lib/musa-dsl/series/proxy-serie.rb +5 -1
- data/lib/musa-dsl/series/quantizer-serie.rb +4 -2
- data/lib/musa-dsl/series/queue-serie.rb +2 -1
- data/lib/musa-dsl/series/series-composer.rb +5 -2
- data/lib/musa-dsl/series/timed-serie.rb +8 -4
- data/lib/musa-dsl/transport/timer-clock.rb +4 -2
- data/lib/musa-dsl/transport/timer.rb +27 -4
- data/lib/musa-dsl/version.rb +1 -2
- data/musa-dsl.gemspec +0 -2
- metadata +1 -1
|
@@ -493,7 +493,7 @@ module Musa
|
|
|
493
493
|
###
|
|
494
494
|
|
|
495
495
|
class UndefinedSerie
|
|
496
|
-
include Series::Serie
|
|
496
|
+
include Series::Serie::Base
|
|
497
497
|
|
|
498
498
|
def initialize
|
|
499
499
|
mark_as_undefined!
|
|
@@ -504,7 +504,7 @@ module Musa
|
|
|
504
504
|
# private_constant :UndefinedSerie
|
|
505
505
|
|
|
506
506
|
class NilSerie
|
|
507
|
-
include Series::Serie
|
|
507
|
+
include Series::Serie::Base
|
|
508
508
|
|
|
509
509
|
def initialize
|
|
510
510
|
mark_as_prototype!
|
|
@@ -530,7 +530,7 @@ module Musa
|
|
|
530
530
|
#
|
|
531
531
|
# @api private
|
|
532
532
|
class FromArray
|
|
533
|
-
include Series::Serie
|
|
533
|
+
include Series::Serie::Base
|
|
534
534
|
|
|
535
535
|
using Musa::Extension::Arrayfy
|
|
536
536
|
|
|
@@ -567,7 +567,8 @@ module Musa
|
|
|
567
567
|
# private_constant :FromArray
|
|
568
568
|
|
|
569
569
|
class Sequence
|
|
570
|
-
include Series::Serie
|
|
570
|
+
include Series::Serie::Base
|
|
571
|
+
include Series::Serie::WithSources
|
|
571
572
|
|
|
572
573
|
def initialize(series)
|
|
573
574
|
self.sources = series
|
|
@@ -612,7 +613,8 @@ module Musa
|
|
|
612
613
|
private_constant :Sequence
|
|
613
614
|
|
|
614
615
|
class FromEvalBlockWithParameters
|
|
615
|
-
include Series::Serie
|
|
616
|
+
include Series::Serie::Base
|
|
617
|
+
include Series::Serie::WithSmartBlock
|
|
616
618
|
|
|
617
619
|
using Extension::DeepCopy
|
|
618
620
|
|
|
@@ -668,7 +670,7 @@ module Musa
|
|
|
668
670
|
private_constant :FromEvalBlockWithParameters
|
|
669
671
|
|
|
670
672
|
class ForLoop
|
|
671
|
-
include Series::Serie
|
|
673
|
+
include Series::Serie::Base
|
|
672
674
|
|
|
673
675
|
def initialize(from, to, step)
|
|
674
676
|
@from = from
|
|
@@ -726,7 +728,7 @@ module Musa
|
|
|
726
728
|
private_constant :ForLoop
|
|
727
729
|
|
|
728
730
|
class RandomValueFromArray
|
|
729
|
-
include Series::Serie
|
|
731
|
+
include Series::Serie::Base
|
|
730
732
|
|
|
731
733
|
def initialize(values, random)
|
|
732
734
|
@values = values
|
|
@@ -755,7 +757,7 @@ module Musa
|
|
|
755
757
|
private_constant :RandomValueFromArray
|
|
756
758
|
|
|
757
759
|
class RandomNumberFromRange
|
|
758
|
-
include Series::Serie
|
|
760
|
+
include Series::Serie::Base
|
|
759
761
|
|
|
760
762
|
def initialize(from, to, step, random)
|
|
761
763
|
@from = from
|
|
@@ -815,7 +817,7 @@ module Musa
|
|
|
815
817
|
private_constant :RandomNumberFromRange
|
|
816
818
|
|
|
817
819
|
class RandomValuesFromArray
|
|
818
|
-
include Series::Serie
|
|
820
|
+
include Series::Serie::Base
|
|
819
821
|
|
|
820
822
|
def initialize(values, random)
|
|
821
823
|
@values = values.clone.freeze
|
|
@@ -847,7 +849,7 @@ module Musa
|
|
|
847
849
|
private_constant :RandomValuesFromArray
|
|
848
850
|
|
|
849
851
|
class RandomNumbersFromRange
|
|
850
|
-
include Series::Serie
|
|
852
|
+
include Series::Serie::Base
|
|
851
853
|
|
|
852
854
|
def initialize(from, to, step, random)
|
|
853
855
|
@from = from
|
|
@@ -909,7 +911,8 @@ module Musa
|
|
|
909
911
|
private_constant :RandomNumbersFromRange
|
|
910
912
|
|
|
911
913
|
class FromHashOfSeries
|
|
912
|
-
include Series::Serie
|
|
914
|
+
include Series::Serie::Base
|
|
915
|
+
include Series::Serie::WithSources
|
|
913
916
|
|
|
914
917
|
def initialize(hash_of_series, cycle_all_series)
|
|
915
918
|
self.sources = hash_of_series
|
|
@@ -968,7 +971,8 @@ module Musa
|
|
|
968
971
|
private_constant :FromHashOfSeries
|
|
969
972
|
|
|
970
973
|
class FromArrayOfSeries
|
|
971
|
-
include Series::Serie
|
|
974
|
+
include Series::Serie::Base
|
|
975
|
+
include Series::Serie::WithSources
|
|
972
976
|
|
|
973
977
|
def initialize(series_array, cycle_all_series)
|
|
974
978
|
self.sources = series_array
|
|
@@ -1027,7 +1031,7 @@ module Musa
|
|
|
1027
1031
|
private_constant :FromArrayOfSeries
|
|
1028
1032
|
|
|
1029
1033
|
class SinFunction
|
|
1030
|
-
include Series::Serie
|
|
1034
|
+
include Series::Serie::Base
|
|
1031
1035
|
|
|
1032
1036
|
def initialize(start, steps, amplitude, center)
|
|
1033
1037
|
@start = start.to_f
|
|
@@ -1102,7 +1106,7 @@ module Musa
|
|
|
1102
1106
|
private_constant :SinFunction
|
|
1103
1107
|
|
|
1104
1108
|
class Fibonacci
|
|
1105
|
-
include Series::Serie
|
|
1109
|
+
include Series::Serie::Base
|
|
1106
1110
|
|
|
1107
1111
|
def initialize
|
|
1108
1112
|
mark_as_prototype!
|
|
@@ -1130,7 +1134,7 @@ module Musa
|
|
|
1130
1134
|
private_constant :Fibonacci
|
|
1131
1135
|
|
|
1132
1136
|
class HarmonicNotes
|
|
1133
|
-
include Series::Serie
|
|
1137
|
+
include Series::Serie::Base
|
|
1134
1138
|
|
|
1135
1139
|
def initialize(error, extended)
|
|
1136
1140
|
@error = error
|
|
@@ -611,15 +611,22 @@ module Musa
|
|
|
611
611
|
###
|
|
612
612
|
|
|
613
613
|
class ProcessWith
|
|
614
|
-
include Serie
|
|
615
|
-
|
|
616
|
-
|
|
614
|
+
include Serie::Base
|
|
615
|
+
include Serie::WithSource
|
|
616
|
+
include Serie::WithSources
|
|
617
|
+
include Serie::WithSmartBlock
|
|
618
|
+
|
|
619
|
+
# sources are optional for ProcessWith
|
|
620
|
+
private def mandatory_sources; false; end
|
|
621
|
+
|
|
622
|
+
alias with_sources sources
|
|
623
|
+
alias with_sources= sources=
|
|
617
624
|
|
|
618
625
|
using Musa::Extension::Arrayfy
|
|
619
626
|
|
|
620
627
|
def initialize(serie, with_series = nil, on_restart = nil, isolate_values: nil, &block)
|
|
621
628
|
self.source = serie
|
|
622
|
-
self.
|
|
629
|
+
self.sources = with_series || []
|
|
623
630
|
self.on_restart = on_restart
|
|
624
631
|
|
|
625
632
|
if block
|
|
@@ -714,7 +721,9 @@ module Musa
|
|
|
714
721
|
private_constant :ProcessWith
|
|
715
722
|
|
|
716
723
|
class Anticipate
|
|
717
|
-
include Serie
|
|
724
|
+
include Serie::Base
|
|
725
|
+
include Serie::WithSource
|
|
726
|
+
include Serie::WithBlock
|
|
718
727
|
|
|
719
728
|
def initialize(serie, &block)
|
|
720
729
|
self.source = serie
|
|
@@ -747,11 +756,16 @@ module Musa
|
|
|
747
756
|
private_constant :Anticipate
|
|
748
757
|
|
|
749
758
|
class Switcher
|
|
750
|
-
include Serie
|
|
759
|
+
include Serie::Base
|
|
760
|
+
include Serie::WithSource
|
|
761
|
+
include Serie::WithSources
|
|
762
|
+
|
|
763
|
+
alias options sources
|
|
764
|
+
alias options= sources=
|
|
751
765
|
|
|
752
766
|
def initialize(selector, indexed_series, hash_series)
|
|
753
767
|
self.source = selector
|
|
754
|
-
self.
|
|
768
|
+
self.sources = indexed_series || hash_series
|
|
755
769
|
|
|
756
770
|
init
|
|
757
771
|
end
|
|
@@ -785,11 +799,16 @@ module Musa
|
|
|
785
799
|
private_constant :Switcher
|
|
786
800
|
|
|
787
801
|
class MultiplexSelector
|
|
788
|
-
include Serie
|
|
802
|
+
include Serie::Base
|
|
803
|
+
include Serie::WithSource
|
|
804
|
+
include Serie::WithSources
|
|
805
|
+
|
|
806
|
+
alias options sources
|
|
807
|
+
alias options= sources=
|
|
789
808
|
|
|
790
809
|
def initialize(selector, indexed_series, hash_series)
|
|
791
810
|
self.source = selector
|
|
792
|
-
self.
|
|
811
|
+
self.sources = indexed_series || hash_series
|
|
793
812
|
|
|
794
813
|
init
|
|
795
814
|
end
|
|
@@ -829,11 +848,16 @@ module Musa
|
|
|
829
848
|
private_constant :MultiplexSelector
|
|
830
849
|
|
|
831
850
|
class SwitchFullSerie
|
|
832
|
-
include Serie
|
|
851
|
+
include Serie::Base
|
|
852
|
+
include Serie::WithSource
|
|
853
|
+
include Serie::WithSources
|
|
854
|
+
|
|
855
|
+
alias options sources
|
|
856
|
+
alias options= sources=
|
|
833
857
|
|
|
834
858
|
def initialize(selector, indexed_series, hash_series)
|
|
835
859
|
self.source = selector
|
|
836
|
-
self.
|
|
860
|
+
self.sources = indexed_series || hash_series
|
|
837
861
|
|
|
838
862
|
init
|
|
839
863
|
end
|
|
@@ -865,7 +889,8 @@ module Musa
|
|
|
865
889
|
private_constant :SwitchFullSerie
|
|
866
890
|
|
|
867
891
|
class InfiniteRepeater
|
|
868
|
-
include Serie
|
|
892
|
+
include Serie::Base
|
|
893
|
+
include Serie::WithSource
|
|
869
894
|
|
|
870
895
|
def initialize(serie)
|
|
871
896
|
self.source = serie
|
|
@@ -895,7 +920,8 @@ module Musa
|
|
|
895
920
|
private_constant :InfiniteRepeater
|
|
896
921
|
|
|
897
922
|
class Repeater
|
|
898
|
-
include Serie
|
|
923
|
+
include Serie::Base
|
|
924
|
+
include Serie::WithSource
|
|
899
925
|
|
|
900
926
|
def initialize(serie, times = nil, &condition)
|
|
901
927
|
self.source = serie
|
|
@@ -968,7 +994,8 @@ module Musa
|
|
|
968
994
|
private_constant :Repeater
|
|
969
995
|
|
|
970
996
|
class LengthLimiter
|
|
971
|
-
include Serie
|
|
997
|
+
include Serie::Base
|
|
998
|
+
include Serie::WithSource
|
|
972
999
|
|
|
973
1000
|
def initialize(serie, length)
|
|
974
1001
|
self.source = serie
|
|
@@ -1002,7 +1029,8 @@ module Musa
|
|
|
1002
1029
|
private_constant :LengthLimiter
|
|
1003
1030
|
|
|
1004
1031
|
class Skipper
|
|
1005
|
-
include Serie
|
|
1032
|
+
include Serie::Base
|
|
1033
|
+
include Serie::WithSource
|
|
1006
1034
|
|
|
1007
1035
|
def initialize(serie, length)
|
|
1008
1036
|
self.source = serie
|
|
@@ -1036,7 +1064,7 @@ module Musa
|
|
|
1036
1064
|
private_constant :Skipper
|
|
1037
1065
|
|
|
1038
1066
|
class Flattener
|
|
1039
|
-
include Serie
|
|
1067
|
+
include Serie::Base
|
|
1040
1068
|
|
|
1041
1069
|
def initialize(serie)
|
|
1042
1070
|
@source = serie
|
|
@@ -1081,7 +1109,8 @@ module Musa
|
|
|
1081
1109
|
private_constant :Flattener
|
|
1082
1110
|
|
|
1083
1111
|
class MergeSerieOfSeries
|
|
1084
|
-
include Serie
|
|
1112
|
+
include Serie::Base
|
|
1113
|
+
include Serie::WithSource
|
|
1085
1114
|
|
|
1086
1115
|
def initialize(serie)
|
|
1087
1116
|
self.source = serie
|
|
@@ -1158,7 +1187,9 @@ module Musa
|
|
|
1158
1187
|
#
|
|
1159
1188
|
# @api private
|
|
1160
1189
|
class Processor
|
|
1161
|
-
include Serie
|
|
1190
|
+
include Serie::Base
|
|
1191
|
+
include Serie::WithSource
|
|
1192
|
+
include Serie::WithSmartBlock
|
|
1162
1193
|
|
|
1163
1194
|
def initialize(serie, parameters, &processor)
|
|
1164
1195
|
self.source = serie
|
|
@@ -1211,7 +1242,8 @@ module Musa
|
|
|
1211
1242
|
end
|
|
1212
1243
|
|
|
1213
1244
|
class Autorestart
|
|
1214
|
-
include Serie
|
|
1245
|
+
include Serie::Base
|
|
1246
|
+
include Serie::WithSource
|
|
1215
1247
|
|
|
1216
1248
|
def initialize(serie)
|
|
1217
1249
|
self.source = serie
|
|
@@ -1243,7 +1275,8 @@ module Musa
|
|
|
1243
1275
|
private_constant :Autorestart
|
|
1244
1276
|
|
|
1245
1277
|
class Cutter
|
|
1246
|
-
include Serie
|
|
1278
|
+
include Serie::Base
|
|
1279
|
+
include Serie::WithSource
|
|
1247
1280
|
|
|
1248
1281
|
def initialize(serie, length)
|
|
1249
1282
|
self.source = serie
|
|
@@ -1273,7 +1306,8 @@ module Musa
|
|
|
1273
1306
|
end
|
|
1274
1307
|
|
|
1275
1308
|
class CutSerie
|
|
1276
|
-
include Serie
|
|
1309
|
+
include Serie::Base
|
|
1310
|
+
include Serie::WithSource
|
|
1277
1311
|
|
|
1278
1312
|
def initialize(serie, length)
|
|
1279
1313
|
self.source = serie.instance
|
|
@@ -1314,7 +1348,8 @@ module Musa
|
|
|
1314
1348
|
private_constant :Cutter
|
|
1315
1349
|
|
|
1316
1350
|
class Locker
|
|
1317
|
-
include Serie
|
|
1351
|
+
include Serie::Base
|
|
1352
|
+
include Serie::WithSource
|
|
1318
1353
|
|
|
1319
1354
|
def initialize(serie)
|
|
1320
1355
|
self.source = serie
|
|
@@ -1351,7 +1386,8 @@ module Musa
|
|
|
1351
1386
|
private_constant :Locker
|
|
1352
1387
|
|
|
1353
1388
|
class Reverser
|
|
1354
|
-
include Serie
|
|
1389
|
+
include Serie::Base
|
|
1390
|
+
include Serie::WithSource
|
|
1355
1391
|
|
|
1356
1392
|
def initialize(serie)
|
|
1357
1393
|
self.source = serie
|
|
@@ -1387,7 +1423,8 @@ module Musa
|
|
|
1387
1423
|
private_constant :Reverser
|
|
1388
1424
|
|
|
1389
1425
|
class Randomizer
|
|
1390
|
-
include Serie
|
|
1426
|
+
include Serie::Base
|
|
1427
|
+
include Serie::WithSource
|
|
1391
1428
|
|
|
1392
1429
|
def initialize(serie, random)
|
|
1393
1430
|
self.source = serie
|
|
@@ -1424,7 +1461,8 @@ module Musa
|
|
|
1424
1461
|
private_constant :Randomizer
|
|
1425
1462
|
|
|
1426
1463
|
class Shifter
|
|
1427
|
-
include Serie
|
|
1464
|
+
include Serie::Base
|
|
1465
|
+
include Serie::WithSource
|
|
1428
1466
|
|
|
1429
1467
|
def initialize(serie, shift)
|
|
1430
1468
|
self.shift = shift
|
|
@@ -1500,7 +1538,9 @@ module Musa
|
|
|
1500
1538
|
private_constant :Shifter
|
|
1501
1539
|
|
|
1502
1540
|
class Remover
|
|
1503
|
-
include Serie
|
|
1541
|
+
include Serie::Base
|
|
1542
|
+
include Serie::WithSource
|
|
1543
|
+
include Serie::WithBlock
|
|
1504
1544
|
|
|
1505
1545
|
def initialize(serie, &block)
|
|
1506
1546
|
self.source = serie
|
|
@@ -1534,7 +1574,9 @@ module Musa
|
|
|
1534
1574
|
private_constant :Remover
|
|
1535
1575
|
|
|
1536
1576
|
class Selector
|
|
1537
|
-
include Serie
|
|
1577
|
+
include Serie::Base
|
|
1578
|
+
include Serie::WithSource
|
|
1579
|
+
include Serie::WithBlock
|
|
1538
1580
|
|
|
1539
1581
|
def initialize(serie, &block)
|
|
1540
1582
|
self.source = serie
|
|
@@ -1559,7 +1601,8 @@ module Musa
|
|
|
1559
1601
|
private_constant :Selector
|
|
1560
1602
|
|
|
1561
1603
|
class HashFromSeriesArray
|
|
1562
|
-
include Serie
|
|
1604
|
+
include Serie::Base
|
|
1605
|
+
include Serie::WithSource
|
|
1563
1606
|
|
|
1564
1607
|
def initialize(serie, keys)
|
|
1565
1608
|
self.source = serie
|
|
@@ -1592,7 +1635,9 @@ module Musa
|
|
|
1592
1635
|
private_constant :HashFromSeriesArray
|
|
1593
1636
|
|
|
1594
1637
|
class LazySerieEval
|
|
1595
|
-
include Serie
|
|
1638
|
+
include Serie::Base
|
|
1639
|
+
include Serie::WithSource
|
|
1640
|
+
include Serie::WithBlock
|
|
1596
1641
|
|
|
1597
1642
|
def initialize(serie, &block)
|
|
1598
1643
|
self.source = serie
|
|
@@ -74,7 +74,11 @@ module Musa
|
|
|
74
74
|
#
|
|
75
75
|
# @api private
|
|
76
76
|
class ProxySerie
|
|
77
|
-
include Series::Serie
|
|
77
|
+
include Series::Serie::Base
|
|
78
|
+
include Series::Serie::WithSource
|
|
79
|
+
|
|
80
|
+
alias proxy_source source
|
|
81
|
+
alias proxy_source= source=
|
|
78
82
|
|
|
79
83
|
def initialize(serie)
|
|
80
84
|
self.proxy_source = serie
|
|
@@ -128,7 +128,8 @@ module Musa
|
|
|
128
128
|
private_constant :QuantizerTools
|
|
129
129
|
|
|
130
130
|
class RawQuantizer
|
|
131
|
-
include Series::Serie
|
|
131
|
+
include Series::Serie::Base
|
|
132
|
+
include Series::Serie::WithSource
|
|
132
133
|
include QuantizerTools
|
|
133
134
|
|
|
134
135
|
attr_reader :source
|
|
@@ -393,7 +394,8 @@ module Musa
|
|
|
393
394
|
private_constant :RawQuantizer
|
|
394
395
|
|
|
395
396
|
class PredictiveQuantizer
|
|
396
|
-
include Series::Serie
|
|
397
|
+
include Series::Serie::Base
|
|
398
|
+
include Series::Serie::WithSource
|
|
397
399
|
include QuantizerTools
|
|
398
400
|
|
|
399
401
|
attr_reader :source
|
|
@@ -84,7 +84,8 @@ module Musa
|
|
|
84
84
|
# @see Composer::Composer Full composer implementation
|
|
85
85
|
# @api private
|
|
86
86
|
class ComposerAsOperationSerie
|
|
87
|
-
include Musa::Series::Serie
|
|
87
|
+
include Musa::Series::Serie::Base
|
|
88
|
+
include Musa::Series::Serie::WithSource
|
|
88
89
|
|
|
89
90
|
def initialize(serie, &block)
|
|
90
91
|
self.source = serie
|
|
@@ -593,10 +594,12 @@ module Musa
|
|
|
593
594
|
# @return [Route, nil] route at connection point
|
|
594
595
|
#
|
|
595
596
|
# @api private
|
|
596
|
-
def
|
|
597
|
+
def get(on, as)
|
|
597
598
|
@routes[[on, as]]
|
|
598
599
|
end
|
|
599
600
|
|
|
601
|
+
alias_method :[], :get
|
|
602
|
+
|
|
600
603
|
# Stores route at specified connection point.
|
|
601
604
|
#
|
|
602
605
|
# @param on [Symbol] connection attribute name
|
|
@@ -179,7 +179,8 @@ module Musa
|
|
|
179
179
|
#
|
|
180
180
|
# @api private
|
|
181
181
|
class TimedUnionOfArrayOfTimedSeries
|
|
182
|
-
include Series::Serie
|
|
182
|
+
include Series::Serie::Base
|
|
183
|
+
include Series::Serie::WithSources
|
|
183
184
|
|
|
184
185
|
# Creates array-mode union from series array.
|
|
185
186
|
#
|
|
@@ -356,7 +357,8 @@ module Musa
|
|
|
356
357
|
#
|
|
357
358
|
# @api private
|
|
358
359
|
class TimedUnionOfHashOfTimedSeries
|
|
359
|
-
include Series::Serie
|
|
360
|
+
include Series::Serie::Base
|
|
361
|
+
include Series::Serie::WithSources
|
|
360
362
|
|
|
361
363
|
# Creates hash-mode union from named series hash.
|
|
362
364
|
#
|
|
@@ -632,7 +634,8 @@ module Musa
|
|
|
632
634
|
#
|
|
633
635
|
# @api private
|
|
634
636
|
class TimedFlattener
|
|
635
|
-
include Series::Serie
|
|
637
|
+
include Series::Serie::Base
|
|
638
|
+
include Series::Serie::WithSource
|
|
636
639
|
|
|
637
640
|
# Creates flattener wrapping source serie.
|
|
638
641
|
#
|
|
@@ -726,7 +729,8 @@ module Musa
|
|
|
726
729
|
#
|
|
727
730
|
# @api private
|
|
728
731
|
class TimedCompacter
|
|
729
|
-
include Series::Serie
|
|
732
|
+
include Series::Serie::Base
|
|
733
|
+
include Series::Serie::WithSource
|
|
730
734
|
|
|
731
735
|
# Creates compacter wrapping source serie.
|
|
732
736
|
#
|
|
@@ -279,13 +279,15 @@ module Musa
|
|
|
279
279
|
|
|
280
280
|
# Terminates the clock's run loop.
|
|
281
281
|
#
|
|
282
|
-
# Causes {#run} to exit
|
|
282
|
+
# Causes {#run} to exit by setting the run flag to false and terminating
|
|
283
|
+
# the internal timer. This is the clean shutdown mechanism.
|
|
283
284
|
#
|
|
284
285
|
# @return [void]
|
|
285
286
|
#
|
|
286
|
-
# @note After calling this, {#run} will exit
|
|
287
|
+
# @note After calling this, {#run} will exit and {Musa::Transport::Transport#start} will return
|
|
287
288
|
def terminate
|
|
288
289
|
@run = false
|
|
290
|
+
@timer&.terminate
|
|
289
291
|
end
|
|
290
292
|
end
|
|
291
293
|
end
|
|
@@ -53,6 +53,7 @@ module Musa
|
|
|
53
53
|
@period = tick_period_in_seconds.rationalize
|
|
54
54
|
@correction = (correction || 0r).rationalize
|
|
55
55
|
@stop = stop || false
|
|
56
|
+
@terminate = false
|
|
56
57
|
|
|
57
58
|
@delayed_ticks_error = delayed_ticks_error || 1.0
|
|
58
59
|
@logger = logger
|
|
@@ -61,25 +62,29 @@ module Musa
|
|
|
61
62
|
|
|
62
63
|
# Runs the timer loop, yielding for each tick.
|
|
63
64
|
#
|
|
64
|
-
# This method blocks and runs
|
|
65
|
+
# This method blocks and runs until terminated. For each tick:
|
|
65
66
|
# 1. Yields to caller if not stopped
|
|
66
67
|
# 2. Calculates next tick time
|
|
67
68
|
# 3. Sleeps precisely until next tick
|
|
68
69
|
# 4. Logs warnings if timing cannot be maintained
|
|
69
70
|
#
|
|
70
71
|
# When stopped (@stop = true), the thread sleeps until {#continue} is called.
|
|
72
|
+
# When terminated (@terminate = true), the loop exits and this method returns.
|
|
71
73
|
#
|
|
72
74
|
# @yield Called once per tick for processing
|
|
73
75
|
# @return [void]
|
|
74
76
|
#
|
|
75
|
-
# @note This method blocks the current thread
|
|
77
|
+
# @note This method blocks the current thread until {#terminate} is called
|
|
76
78
|
# @note Uses monotonic clock for drift-free timing
|
|
77
79
|
def run
|
|
78
80
|
@thread = Thread.current
|
|
81
|
+
@terminate = false
|
|
79
82
|
|
|
80
83
|
@next_moment = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
81
84
|
|
|
82
85
|
loop do
|
|
86
|
+
break if @terminate
|
|
87
|
+
|
|
83
88
|
unless @stop
|
|
84
89
|
# Process the tick
|
|
85
90
|
yield
|
|
@@ -102,8 +107,11 @@ module Musa
|
|
|
102
107
|
sleep to_sleep if to_sleep > 0.0
|
|
103
108
|
end
|
|
104
109
|
|
|
105
|
-
# When stopped, sleep thread until continue is called
|
|
106
|
-
|
|
110
|
+
# When stopped, sleep thread until continue or terminate is called
|
|
111
|
+
if @stop
|
|
112
|
+
break if @terminate
|
|
113
|
+
sleep
|
|
114
|
+
end
|
|
107
115
|
end
|
|
108
116
|
end
|
|
109
117
|
|
|
@@ -133,6 +141,21 @@ module Musa
|
|
|
133
141
|
@next_moment = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
134
142
|
@thread.run
|
|
135
143
|
end
|
|
144
|
+
|
|
145
|
+
# Terminates the timer loop permanently.
|
|
146
|
+
#
|
|
147
|
+
# Unlike {#stop} which pauses the timer (allowing {#continue} to resume),
|
|
148
|
+
# terminate causes the {#run} loop to exit completely. Use this for
|
|
149
|
+
# clean shutdown.
|
|
150
|
+
#
|
|
151
|
+
# @return [void]
|
|
152
|
+
#
|
|
153
|
+
# @note This wakes the thread if sleeping and causes {#run} to return
|
|
154
|
+
# @see #stop For pausing without terminating
|
|
155
|
+
def terminate
|
|
156
|
+
@terminate = true
|
|
157
|
+
@thread&.wakeup
|
|
158
|
+
end
|
|
136
159
|
end
|
|
137
160
|
end
|
|
138
161
|
end
|
data/lib/musa-dsl/version.rb
CHANGED
data/musa-dsl.gemspec
CHANGED