forked from renoise/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlobalMidiActions.lua
2510 lines (1968 loc) · 67.6 KB
/
GlobalMidiActions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[============================================================================
GlobalMidiActions.lua
DO NOT EDIT THIS FILE IN THE RENOISE RESOURCE FOLDER! UPDATING RENOISE WILL
TRASH YOUR MODIFICATIONS!
TO EXTEND MIDI MAPPINGS, COPY THIS FILE TO THE RENOISE PREFERENCES SCRIPT
FOLDER, THEN DO YOUR CHANGES AND ADDITIONS THERE.
============================================================================]]--
--[[
List of actions which defines the set of global MIDI mappings in Renoise.
The message parameter, passed to invoke the action, is defined as:
class "TriggerMessage"
-- returns if the should be invoked at all
function is_trigger() -> boolean
-- check which properties are valid
function is_switch() -> boolean
function is_rel_value() -> boolean
function is_abs_value() -> boolean
-- [0 - 127] for abs values, [-63 - 63] for relative values
-- valid when is_rel_value() or is_abs_value() returns true, else nil
int_value
-- valid [true OR false] when :is_switch() returns true, else nil
boolean_value
-- [0.0 - 1.0] min/max range scaling for parameter values. always valid.
value_min_scaling
value_max_scaling
---- Adding new mappings
If you want to extend the default MIDI mapping set, first copy this file to the
"Scripts" folder in your preferences folder. Then do your changes there. The
file in the Renoise resource folder may be overwritten when updating Renoise.
Click on "Help" -> "Show Preferences Folder..." in Renoise to locate the folder.
New MIDI actions can not be bound to the Renoise GUI (the highlighted frames in
the GUI that get visible with the MIDI mapping dialog). They will only show
up in the "Available & Active Messages" list in the MIDI mapping dialog.
Any errors that may happen in the MIDI message handlers, are not shown to the
user. They are only dumped into the scripting terminal. Make sure its open
when changing anything in here to make debugging easier.
When editing this file in Renoises "Scripting Terminal&Editor", any changes
to the message set will instantly be applied as soon as you save the file.
This way you can quickly test out your changes.
When working with an external editor, you can manually reload this script and
apply changes by clicking on the small "refresh" button in Renoise's MIDI
Mapping dialog. Watch out for a small refresh icon next to the "Available &
Active Messages" list.
Scripting developer tools must be enabled to see the "refresh" button and the
scripting terminal. Please see http://scripting.renoise.com for more info about
this.
---- Add mappings via XRNX tools
Alternatively to editing this file, you can also define new midi mappings via
Renoise XRNX tool bundles. This way new mappings can be easily installed (drag
& drop the xrnx tool bundle) and upgrading Renoise won't remove your mappings.
Please have a look at the "Renoise.ScriptingTool.API.lua" documentation for more
info about this.
]]
--------------------------------------------------------------------------------
-- Globals (interface to Renoise)
--------------------------------------------------------------------------------
-- max mapping counts
MAX_SECTION_MAPPINGS = 64
MAX_SEQUENCE_MAPPINGS = 256
MAX_TRACK_MAPPINGS = 64
MAX_SEND_TRACK_MAPPINGS = 32
MAX_GENERIC_PARAMETER_MAPPINGS = 32
-- available_actions
local action_names = table.create()
function available_actions()
return action_names
end
-- invoke_action
local action_map = {}
function invoke_action(name, message)
local action = action_map[name]
if (action == nil) then
error(string.format("trying to invoke undefined action '%s'", name))
end
action(message)
end
--------------------------------------------------------------------------------
-- Locals (message registration & helpers)
--------------------------------------------------------------------------------
-- add_action
local function add_action(name, func)
--[[ debug:
if (name:match("%[Trigger%]$") == nil and
name:match("%[Toggle%]$") == nil and
name:match("%[Set%]$") == nil)
then
error(("action '%s' should be marked, " ..
"end with: [Trigger], [Toggle] or [Set]"):format(name))
end
if (action_map[name] ~= nil) then
error(("action '%s' was already added"):format(name))
end
]]
action_map[name] = func
action_names:insert(name)
end
--------------------------------------------------------------------------------
-- app
local app = renoise.app
-- song
local song = renoise.song
-- sequencer_track
local function sequencer_track(track_index)
if (track_index <= song().sequencer_track_count) then
return song():track(track_index)
else
return nil
end
end
-- send_track
local function send_track(send_index)
if (send_index <= song().send_track_count) then
-- send tracks are always behind the master track
return song():track(song().sequencer_track_count + 1 + send_index)
else
return nil
end
end
-- master_track
local function master_track()
-- master track is always behind the sequencer tracks
return song():track(song().sequencer_track_count + 1)
end
-- selected_track
local function selected_track()
return song().selected_track
end
-- selected_track_device
local function selected_track_device()
return song().selected_track_device
end
-- selected_track_device_index
local function selected_track_device_index()
return song().selected_track_device_index
end
--------------------------------------------------------------------------------
-- clamp_value
local function clamp_value(value, min_value, max_value)
return math.min(max_value, math.max(value, min_value))
end
-- wrap_value
local function wrap_value(value, min_value, max_value)
local range = max_value - min_value + 1
assert(range > 0, "invalid range")
while (value < min_value) do
value = value + range
end
while (value > max_value) do
value = value - range
end
return value
end
-- quantize_value
local function quantize_value(value, quantum)
if (value >= 0) then
value = value + quantum / 2
else
value = value - quantum / 2
end
return math.floor(value / quantum) * quantum
end
--------------------------------------------------------------------------------
-- boolean_message_value
local function boolean_message_value(message, value)
if (message:is_switch()) then
return message.boolean_value
else
return value
end
end
-- toggle_message_value
local function toggle_message_value(message, value)
if (message:is_trigger()) then
return not value
else
return value
end
end
-- message_value_with_offset
local function message_value_with_offset(message, value,
offset, min_value, max_value)
if (message:is_abs_value()) then
return clamp_value(message.int_value + offset, min_value, max_value)
elseif (message:is_rel_value()) then
return clamp_value(value + message.int_value, min_value, max_value)
else
return value
end
end
-- message_value
local function message_value(message, value, min_value, max_value)
return message_value_with_offset(message, value, 0, min_value, max_value)
end
-- inc_message_value
local function inc_message_value(message, value, min_value, max_value)
if (message:is_trigger()) then
return clamp_value(value + 1, min_value, max_value)
else
return value
end
end
-- dec_message_value
local function dec_message_value(message, value, min_value, max_value)
if (message:is_trigger()) then
return clamp_value(value - 1, min_value, max_value)
else
return value
end
end
-- parameter_message_value
local function parameter_message_value(message, parameter)
local new_value = parameter.value
local quantum = parameter.value_quantum
local parameter_min = (parameter.value_max - parameter.value_min) *
message.value_min_scaling + parameter.value_min
local parameter_max = (parameter.value_max - parameter.value_min) *
message.value_max_scaling + parameter.value_min
if (quantum > 0) then
new_value = quantize_value(new_value, quantum)
parameter_min = quantize_value(parameter_min, quantum)
parameter_max = quantize_value(parameter_max, quantum)
end
local parameter_range = parameter_max - parameter_min
if (message:is_abs_value()) then
new_value = parameter_min + (message.int_value / 127 * parameter_range)
if (parameter.polarity == renoise.DeviceParameter.POLARITY_BIPOLAR) then
local center_value = parameter.value_min +
(parameter.value_max - parameter.value_min) / 2;
if (math.abs(center_value - new_value) < parameter_range / 128) then
-- snap to center
new_value = center_value
end
end
elseif (message:is_rel_value()) then
if (quantum > 0) then
if (message.int_value > 0) then
new_value = new_value + quantum
else
new_value = new_value - quantum
end
else
new_value = new_value + parameter_range / 127 * message.int_value;
if (parameter.polarity == renoise.DeviceParameter.POLARITY_BIPOLAR) then
local center_value = parameter.value_min +
(parameter.value_max - parameter.value_min) / 2;
if (math.abs(center_value - new_value) < parameter_range / 128) then
-- snap to center
new_value = center_value
end
end
end
new_value = clamp_value(new_value,
math.min(parameter_min, parameter_max),
math.max(parameter_min, parameter_max)
)
elseif (message:is_switch()) then
if (message.boolean_value) then
new_value = parameter_max
else
new_value = parameter_min
end
elseif (message:is_trigger()) then
if (quantum > 0) then
-- walk through quantized values
if (parameter_max > parameter_min) then
new_value = new_value + quantum;
if (new_value > parameter_max) then
new_value = parameter_min
end
elseif (parameter_max < parameter_min) then
new_value = new_value - quantum
if (new_value < parameter_max) then
new_value = parameter_min
end
end
else
-- toggle between min/max
if (parameter.value > parameter_min + parameter_range / 2) then
new_value = parameter_min
else
new_value = parameter_max
end
end
end
return new_value
end
-- parameter_message_fader_value
local function parameter_message_fader_value(message, volume_parameter)
if (message:is_abs_value() and message.int_value == 0 and message.value_min_scaling == 0) then
return 0 -- always -INF at the bottom
end
if (message:is_abs_value() or message:is_rel_value()) then
local range_min_db
local range_max_db
if (app().window.mixer_fader_type == renoise.ApplicationWindow.MIXER_FADER_TYPE_24DB) then
range_min_db = -24
range_max_db = 3
elseif (app().window.mixer_fader_type == renoise.ApplicationWindow.MIXER_FADER_TYPE_48DB) then
range_min_db = -48
range_max_db = 3
elseif (app().window.mixer_fader_type == renoise.ApplicationWindow.MIXER_FADER_TYPE_96DB) then
range_min_db = -96
range_max_db = 3
else
return parameter_message_value(message, volume_parameter)
end
local hardware_value = message.int_value / 127
-- scaling is entered on a linear 0-1 scale so must convert to fv
-- with the right fader type before we can scale the value
local param_range = volume_parameter.value_max - volume_parameter.value_min
local min_lin = volume_parameter.value_min + message.value_min_scaling * param_range
local max_lin = volume_parameter.value_min + message.value_max_scaling * param_range
local min_db = math.lin2db(min_lin)
local max_db = math.lin2db(max_lin)
local min_fv = math.db2fader(range_min_db, range_max_db, min_db)
local max_fv = math.db2fader(range_min_db, range_max_db, max_db)
local fader_value
if (message:is_abs_value()) then
fader_value = min_fv + hardware_value * (max_fv - min_fv)
else
local quantum = volume_parameter.value_quantum
if (quantum < 1) then
quantum = 1/127
end
local old_db = math.lin2db(volume_parameter.value)
local old_fv = math.db2fader(range_min_db, range_max_db, old_db)
if (hardware_value > 0) then
fader_value = old_fv + quantum * (max_fv - min_fv)
else
fader_value = old_fv - quantum * (max_fv - min_fv)
end
if (fader_value < 0) then
return 0 -- always -INF at the bottom
else
fader_value = clamp_value(fader_value, min_fv, max_fv)
end
end
local db_value = math.fader2db(range_min_db, range_max_db, fader_value);
local lin_value = math.db2lin(db_value);
lin_value = clamp_value(lin_value, volume_parameter.value_min, volume_parameter.value_max)
return lin_value
else
return parameter_message_value(message, volume_parameter)
end
end
-- section helpers
local gather_section_positions = function()
local positions = {}
for k,v in ipairs(song().sequencer.pattern_sequence) do
if song().sequencer:sequence_is_start_of_section(k) then
table.insert(positions,k)
end
end
return positions
end
local get_section_index_by_seq_pos = function(seq_pos)
local positions = gather_section_positions()
if not table.is_empty(positions) then
for k,v in ipairs(positions) do
if (v > seq_pos) then
return k-1
elseif (v == seq_pos) then
return k
end
end
return #positions,positions
end
end
--------------------------------------------------------------------------------
-- Transport
--------------------------------------------------------------------------------
-- Transport:Playback
add_action("Transport:Playback:Panic [Trigger]",
function(message)
if message:is_trigger() then
song().transport:panic()
end
end)
add_action("Transport:Playback:Start Playing [Trigger]",
function(message)
if message:is_trigger() then
local play_mode = renoise.Transport.PLAYMODE_RESTART_PATTERN
song().transport:start(play_mode)
end
end)
add_action("Transport:Playback:Stop Playing [Trigger]",
function(message)
if message:is_trigger() then
song().transport:stop()
end
end)
add_action("Transport:Playback:Start/Stop Playing [Set]",
function(message)
local start_playing = boolean_message_value(
message, song().transport.playing)
if (start_playing ~= song().transport.playing) then
if start_playing then
local play_mode = renoise.Transport.PLAYMODE_RESTART_PATTERN
song().transport:start(play_mode)
else
song().transport:stop()
end
end
end)
add_action("Transport:Playback:Loop Pattern [Set]",
function(message)
song().transport.loop_pattern = boolean_message_value(
message, song().transport.loop_pattern)
end)
add_action("Transport:Playback:Loop Pattern [Toggle]",
function(message)
song().transport.loop_pattern = toggle_message_value(
message, song().transport.loop_pattern)
end)
add_action("Transport:Playback:Loop Block [Set]",
function(message)
song().transport.loop_block_enabled = boolean_message_value(
message, song().transport.loop_block_enabled)
end)
add_action("Transport:Playback:Loop Block [Toggle]",
function(message)
song().transport.loop_block_enabled = toggle_message_value(
message, song().transport.loop_block_enabled)
end)
add_action("Transport:Playback:Loop Block Range [Set]",
function(message)
-- reverses the range, so we don't use message_value...
if message:is_abs_value() then
song().transport.loop_block_range_coeff = clamp_value(
message.int_value, 2, 16)
elseif message:is_rel_value() then
song().transport.loop_block_range_coeff = clamp_value(
song().transport.loop_block_range_coeff - message.int_value, 2, 16)
end
end)
add_action("Transport:Playback:Move Loop Block Backwards [Trigger]",
function(message)
if message:is_trigger() then
song().transport:loop_block_move_backwards()
end
end)
add_action("Transport:Playback:Move Loop Block Forwards [Trigger]",
function(message)
if message:is_trigger() then
song().transport:loop_block_move_forwards()
end
end)
add_action("Transport:Playback:Follow Player [Set]",
function(message)
song().transport.follow_player = boolean_message_value(
message, song().transport.follow_player)
end)
add_action("Transport:Playback:Follow Player [Toggle]",
function(message)
song().transport.follow_player = toggle_message_value(
message, song().transport.follow_player)
end)
-- Transport:Record
add_action("Transport:Record:Undo Last Action [Trigger]",
function(message)
if message:is_trigger() then
if(song():can_undo()) then
song():undo()
end
end
end)
add_action("Transport:Record:Redo Last Action [Trigger]",
function(message)
if message:is_trigger() then
if(song():can_redo()) then
song():redo()
end
end
end)
add_action("Transport:Record:Metronome Enabled [Set]",
function(message)
song().transport.metronome_enabled = boolean_message_value(
message, song().transport.metronome_enabled)
end)
add_action("Transport:Record:Metronome Enabled [Toggle]",
function(message)
song().transport.metronome_enabled = toggle_message_value(
message, song().transport.metronome_enabled)
end)
add_action("Transport:Record:Quantization Enabled [Set]",
function(message)
song().transport.record_quantize_enabled = boolean_message_value(
message, song().transport.record_quantize_enabled)
end)
add_action("Transport:Record:Quantization Enabled [Toggle]",
function(message)
song().transport.record_quantize_enabled = toggle_message_value(
message, song().transport.record_quantize_enabled)
end)
add_action("Transport:Record:Quantization Amount [Set]",
function(message)
song().transport.record_quantize_lines = message_value(
message, song().transport.record_quantize_lines, 1, 32)
end)
add_action("Transport:Record:Decrease Quantization Amount [Trigger]",
function(message)
song().transport.record_quantize_lines = dec_message_value(
message, song().transport.record_quantize_lines, 1, 32)
end)
add_action("Transport:Record:Increase Quantization Amount [Trigger]",
function(message)
song().transport.record_quantize_lines = inc_message_value(
message, song().transport.record_quantize_lines, 1, 32)
end)
add_action("Transport:Record:Parameter Record Mode [Set]",
function(message)
local record_into_automation = (song().transport.record_parameter_mode ==
renoise.Transport.RECORD_PARAMETER_MODE_AUTOMATION)
if boolean_message_value(message, record_into_automation) then
song().transport.record_parameter_mode =
renoise.Transport.RECORD_PARAMETER_MODE_AUTOMATION
else
song().transport.record_parameter_mode =
renoise.Transport.RECORD_PARAMETER_MODE_PATTERN
end
end)
add_action("Transport:Record:Parameter Record Mode [Toggle]",
function(message)
local record_into_automation = (song().transport.record_parameter_mode ==
renoise.Transport.RECORD_PARAMETER_MODE_AUTOMATION)
if toggle_message_value(message, record_into_automation) then
song().transport.record_parameter_mode =
renoise.Transport.RECORD_PARAMETER_MODE_AUTOMATION
else
song().transport.record_parameter_mode =
renoise.Transport.RECORD_PARAMETER_MODE_PATTERN
end
end)
add_action("Transport:Record:Start/Stop Sample Recording [Trigger]",
function(message)
if message:is_trigger() then
song().transport:start_stop_sample_recording()
end
end)
add_action("Transport:Record:Cancel Sample Recording [Trigger]",
function(message)
if message:is_trigger() then
song().transport:cancel_sample_recording()
end
end)
-- Transport:Song
add_action("Transport:Song:BPM [Set]",
function(message)
song().transport.bpm = message_value_with_offset(
message, song().transport.bpm, 60, 32, 999)
end)
add_action("Transport:Song:Decrease BPM [Trigger]",
function(message)
song().transport.bpm = dec_message_value(
message, song().transport.bpm, 32, 999)
end)
add_action("Transport:Song:Increase BPM [Trigger]",
function(message)
song().transport.bpm = inc_message_value(
message, song().transport.bpm, 32, 999)
end)
add_action("Transport:Song:LPB [Set]",
function(message)
song().transport.lpb = message_value(
message, song().transport.lpb, 1, 256)
end)
add_action("Transport:Song:Decrease LPB [Trigger]",
function(message)
song().transport.lpb = dec_message_value(
message, song().transport.lpb, 1, 256)
end)
add_action("Transport:Song:Increase LPB [Trigger]",
function(message)
song().transport.lpb = inc_message_value(
message, song().transport.lpb, 1, 256)
end)
add_action("Transport:Song:Shuffle Enabled [Set]",
function(message)
song().transport.groove_enabled = boolean_message_value(
message, song().transport.groove_enabled)
end)
add_action("Transport:Song:Shuffle Enabled [Toggle]",
function(message)
song().transport.groove_enabled = toggle_message_value(
message, song().transport.groove_enabled)
end)
-- Transport:Edit
add_action("Transport:Edit:Edit Mode [Set]",
function(message)
song().transport.edit_mode = boolean_message_value(
message, song().transport.edit_mode)
end)
add_action("Transport:Edit:Edit Mode [Toggle]",
function(message)
song().transport.edit_mode = toggle_message_value(
message, song().transport.edit_mode)
end)
add_action("Transport:Edit:Edit Mode Step [Set]",
function(message)
song().transport.edit_step = message_value(
message, song().transport.edit_step, 0, 64)
end)
add_action("Transport:Edit:Decrease Edit Mode Step [Trigger]",
function(message)
song().transport.edit_step = dec_message_value(
message, song().transport.edit_step, 0, 64)
end)
add_action("Transport:Edit:Increase Edit Mode Step [Trigger]",
function(message)
song().transport.edit_step = inc_message_value(
message, song().transport.edit_step, 0, 64)
end)
add_action("Transport:Edit:Octave [Set]",
function(message)
song().transport.octave = message_value(
message, song().transport.octave, 0, 8)
end)
add_action("Transport:Edit:Decrease Octave [Trigger]",
function(message)
song().transport.octave = dec_message_value(
message, song().transport.octave, 0, 8)
end)
add_action("Transport:Edit:Increase Octave [Trigger]",
function(message)
song().transport.octave = inc_message_value(
message, song().transport.octave, 0, 8)
end)
add_action("Transport:Edit:Keyboard Velocity Enabled [Toggle]",
function(message)
song().transport.keyboard_velocity_enabled = toggle_message_value(
message, song().transport.keyboard_velocity_enabled)
end)
add_action("Transport:Edit:Keyboard Velocity Enabled [Set]",
function(message)
song().transport.keyboard_velocity_enabled = boolean_message_value(
message, song().transport.keyboard_velocity_enabled)
end)
add_action("Transport:Edit:Keyboard Velocity [Set]",
function(message)
song().transport.keyboard_velocity = message_value(
message, song().transport.keyboard_velocity, 0, 127)
end)
add_action("Transport:Edit:Decrease Keyboard Velocity [Trigger]",
function(message)
song().transport.keyboard_velocity = dec_message_value(
message, song().transport.keyboard_velocity, 0, 127)
end)
add_action("Transport:Edit:Increase Keyboard Velocity [Trigger]",
function(message)
song().transport.keyboard_velocity = inc_message_value(
message, song().transport.keyboard_velocity, 0, 127)
end)
add_action("Transport:Edit:Single Track Edit Mode [Toggle]",
function(message)
song().transport.single_track_edit_mode = toggle_message_value(
message, song().transport.single_track_edit_mode)
end)
add_action("Transport:Edit:Single Track Edit Mode [Set]",
function(message)
song().transport.single_track_edit_mode = boolean_message_value(
message, song().transport.single_track_edit_mode)
end)
add_action("Transport:Edit:Patternwrap Mode [Toggle]",
function(message)
song().transport.wrapped_pattern_edit = toggle_message_value(
message, song().transport.wrapped_pattern_edit)
end)
add_action("Transport:Edit:Patternwrap Mode [Set]",
function(message)
song().transport.wrapped_pattern_edit = boolean_message_value(
message, song().transport.wrapped_pattern_edit)
end)
--------------------------------------------------------------------------------
-- Seq. Triggering
--------------------------------------------------------------------------------
-- Seq. Triggering:Trigger
add_action("Seq. Triggering:Trigger:Current [Trigger]",
function(message)
if message:is_trigger() then
song().transport:trigger_sequence(song().transport.edit_pos.sequence)
end
end)
add_action("Seq. Triggering:Trigger:Sequence XX [Set]",
function(message)
if message:is_abs_value() then
local sequence_pos = clamp_value(
message.int_value, 1, song().transport.song_length.sequence)
song().transport:trigger_sequence(sequence_pos)
end
end)
for sequence_pos = 1,MAX_SEQUENCE_MAPPINGS do
add_action(string.format(
"Seq. Triggering:Trigger:Sequence XX:Sequence #%02d [Trigger]",
sequence_pos),
function(message)
if message:is_trigger() then
if sequence_pos <= #song().sequencer.pattern_sequence then
song().transport:trigger_sequence(sequence_pos)
end
end
end)
end
-- Seq. Triggering:Schedule:Section
local set_scheduled_section = function(section_index)
local positions = gather_section_positions()
if positions[section_index] then
song().transport:set_scheduled_sequence(positions[section_index])
end
end
add_action("Seq. Triggering:Schedule:Section:Current [Trigger]",
function(message)
if message:is_trigger() then
local seq_pos = song().transport.edit_pos.sequence
local section_index = get_section_index_by_seq_pos(seq_pos)
set_scheduled_section(section_index)
end
end)
add_action("Seq. Triggering:Schedule:Section:Next [Trigger]",
function(message)
if message:is_trigger() then
local seq_pos = song().transport.edit_pos.sequence
local section_index = get_section_index_by_seq_pos(seq_pos)
set_scheduled_section(section_index+1)
end
end)
add_action("Seq. Triggering:Schedule:Section:Previous [Trigger]",
function(message)
if message:is_trigger() then
local seq_pos = song().transport.edit_pos.sequence
local section_index = get_section_index_by_seq_pos(seq_pos)
set_scheduled_section(section_index-1)
end
end)
add_action("Seq. Triggering:Schedule:Section:Section XX [Set]",
function(message)
if message:is_abs_value() then
local section_index = clamp_value(
message.int_value, 1, MAX_SECTION_MAPPINGS)
set_scheduled_section(section_index)
end
end)
for section_index = 1,MAX_SECTION_MAPPINGS do
add_action(string.format(
"Seq. Triggering:Schedule:Section XX:Section #%02d [Trigger]",
section_index),
function(message)
if message:is_trigger() then
set_scheduled_section(section_index)
end
end)
end
-- Seq. Looping:Section
local loop_section_by_index = function(section_index)