-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PakettiAutomation.lua
2613 lines (2135 loc) · 98.5 KB
/
PakettiAutomation.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
groove_master_track = nil
--groove_master_device = nil
paketti_automation1_device = nil
paketti_automation2_device = nil
PakettiAutomationDoofer = false
-- Utility Functions
local function set_edit_mode(value)
local song = renoise.song()
local edit_mode = value > 0
song.transport.edit_mode = edit_mode
if edit_mode then
renoise.app().window.active_middle_frame = renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
else
renoise.song().selected_track_index = renoise.song().sequencer_track_count + 1
renoise.app().window.active_lower_frame = renoise.ApplicationWindow.LOWER_FRAME_TRACK_AUTOMATION
end
end
-- Local variable to track recording state
local is_recording_active = false
local function set_sample_record(value)
if value > 80 then
if not is_recording_active then
-- Start recording
renoise.app().window.sample_record_dialog_is_visible = true
renoise.song().transport:start_stop_sample_recording()
is_recording_active = true -- Update the state to indicate recording is active
end
else
if is_recording_active then
renoise.song().transport:start_stop_sample_recording()
is_recording_active = false -- Update the state to indicate recording has stopped
end
end
renoise.app().window.active_middle_frame = 1
end
local function set_pattern_length(value)
local song = renoise.song()
local pattern_length = math.floor((value / 100) * (512 - 1) + 1)
song.selected_pattern.number_of_lines = pattern_length
end
local function set_instrument_pitch(value)
local song = renoise.song()
local transpose_value = math.floor((value / 100) * (12 + 12) - 12)
for i = 1, #song.selected_instrument.samples do
song.selected_instrument.samples[i].transpose = transpose_value
end
end
local function placeholder_notifier(index, value)
renoise.app():show_status("Placeholder" .. index .. " Value: " .. tostring(value))
end
local function set_groove_amount(index, value)
local song = renoise.song()
local groove_amounts = song.transport.groove_amounts
value = math.max(0, math.min(value, 1))
groove_amounts[index] = value
song.transport.groove_amounts = groove_amounts
end
local function set_bpm(value)
local song = renoise.song()
value = math.max(32, math.min(value, 187))
song.transport.bpm = value
end
local function set_lpb(value)
local song = renoise.song()
value = math.max(1, math.min(value, 32))
song.transport.lpb = value
end
local function set_edit_step(value)
local song = renoise.song()
value = math.floor(value * 64)
song.transport.edit_step = value
end
local function set_octave(value)
local song = renoise.song()
value = math.floor(value * 8)
song.transport.octave = value
end
local function inject_xml_to_doofer1(device)
local song = renoise.song()
local transport = song.transport
-- Get current values for Groove, BPM, LPB, EditStep, and Octave
local groove1 = transport.groove_amounts[1] * 100
local groove2 = transport.groove_amounts[2] * 100
local groove3 = transport.groove_amounts[3] * 100
local groove4 = transport.groove_amounts[4] * 100
local bpm_value = ((transport.bpm - 32) / (187 - 32)) * 100
local lpb_value = ((transport.lpb - 1) / (32 - 1)) * 100
local edit_step_value = (transport.edit_step / 64) * 100
local octave_value = (transport.octave / 8) * 100
-- Construct the XML with the dynamic values injected
local xml_content = string.format([[
<?xml version="1.0" encoding="UTF-8"?>
<FilterDevicePreset doc_version="13">
<DeviceSlot type="DooferDevice">
<IsMaximized>true</IsMaximized>
<Macro0>
<Value>%.12f</Value>
<Name>Groove#1</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>1</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro0>
<Macro1>
<Value>%.12f</Value>
<Name>Groove#2</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>2</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro1>
<Macro2>
<Value>%.12f</Value>
<Name>Groove#3</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>3</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro2>
<Macro3>
<Value>%.12f</Value>
<Name>Groove#4</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>4</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro3>
<Macro4>
<Value>%.12f</Value>
<Name>BPM</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>5</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro4>
<Macro5>
<Value>%.12f</Value>
<Name>EditStep</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>6</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro5>
<Macro6>
<Value>%.12f</Value>
<Name>Octave 0-8</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>7</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro6>
<Macro7>
<Value>%.12f</Value>
<Name>LPB 1-32</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>8</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro7>
<NumActiveMacros>8</NumActiveMacros>
<ShowDevices>false</ShowDevices>
<DeviceChain>
<SelectedPresetName>Init</SelectedPresetName>
<SelectedPresetLibrary>Bundled Content</SelectedPresetLibrary>
<SelectedPresetIsModified>true</SelectedPresetIsModified>
<Devices>
<InstrumentAutomationDevice type="InstrumentAutomationDevice">
<IsMaximized>true</IsMaximized>
<IsSelected>false</IsSelected>
<SelectedPresetName>Init</SelectedPresetName>
<SelectedPresetLibrary>Bundled Content</SelectedPresetLibrary>
<SelectedPresetIsModified>true</SelectedPresetIsModified>
<IsActive>
<Value>1.0</Value>
<Visualization>Device only</Visualization>
</IsActive>
<ParameterNumber0>0</ParameterNumber0>
<ParameterValue0>
<Value>0.740513325</Value>
<Visualization>Device only</Visualization>
</ParameterValue0>
<LinkedInstrument>0</LinkedInstrument>
<VisiblePages>2</VisiblePages>
</InstrumentAutomationDevice>
</Devices>
</DeviceChain>
</DeviceSlot>
</FilterDevicePreset>
]], groove1, groove2, groove3, groove4, bpm_value, edit_step_value, octave_value, lpb_value)
-- Inject the XML content into the active preset data of the device
device.active_preset_data = xml_content
renoise.app():show_status("Dynamic XML content with precise values injected into Paketti Automation.")
end
-- XML Injection Function for "Paketti Automation 2"
local function inject_xml_to_doofer2(device)
-- Get current pattern length and set instrument pitch to 50%
local song = renoise.song()
local pattern_length = ((song.selected_pattern.number_of_lines - 1) / (512 - 1)) * 100
local instrument_pitch = 50 -- Start at 50%
local xml_content = string.format([[
<?xml version="1.0" encoding="UTF-8"?>
<FilterDevicePreset doc_version="13">
<DeviceSlot type="DooferDevice">
<IsMaximized>true</IsMaximized>
<Macro0>
<Value>74.0513306</Value>
<Name>EditMode</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>1</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro0>
<Macro1>
<Value>0.0</Value>
<Name>Recorder</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>2</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro1>
<Macro2>
<Value>%.2f</Value>
<Name>PtnLength</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>3</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro2>
<Macro3>
<Value>%.2f</Value>
<Name>InstPitch</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>4</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro3>
<Macro4>
<Value>0.0</Value>
<Name>LoopEnd</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>5</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro4>
<Macro5>
<Value>0.0</Value>
<Name>Placeholder2</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>6</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro5>
<Macro6>
<Value>0.0</Value>
<Name>Placeholder3</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>7</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro6>
<Macro7>
<Value>0.0</Value>
<Name>Placeholder4</Name>
<Mappings>
<Mapping>
<DestDeviceIndex>0</DestDeviceIndex>
<DestParameterIndex>8</DestParameterIndex>
<Min>0.0</Min>
<Max>1.0</Max>
<Scaling>Linear</Scaling>
</Mapping>
</Mappings>
</Macro7>
<NumActiveMacros>8</NumActiveMacros>
<ShowDevices>false</ShowDevices>
<DeviceChain>
<SelectedPresetName>Init</SelectedPresetName>
<SelectedPresetLibrary>Bundled Content</SelectedPresetLibrary>
<SelectedPresetIsModified>true</SelectedPresetIsModified>
<Devices>
<InstrumentAutomationDevice type="InstrumentAutomationDevice">
<IsMaximized>true</IsMaximized>
<IsSelected>false</IsSelected>
<SelectedPresetName>Init</SelectedPresetName>
<SelectedPresetLibrary>Bundled Content</SelectedPresetLibrary>
<SelectedPresetIsModified>true</SelectedPresetIsModified>
<IsActive>
<Value>1.0</Value>
<Visualization>Device only</Visualization>
</IsActive>
<ParameterNumber0>0</ParameterNumber0>
<ParameterValue0>
<Value>0.740513325</Value>
<Visualization>Device only</Visualization>
</ParameterValue0>
<LinkedInstrument>0</LinkedInstrument>
<VisiblePages>2</VisiblePages>
</InstrumentAutomationDevice>
</Devices>
</DeviceChain>
</DeviceSlot>
</FilterDevicePreset>
]], pattern_length, instrument_pitch)
-- Inject the XML content into the active preset data of the device
device.active_preset_data = xml_content
renoise.app():show_status("XML content injected into Paketti Automation 2.")
end
-- Monitoring Function for "Paketti Automation" (Doofer 1)
function monitor_doofer1_macros(device)
-- Macro 1 -> Groove 1
local function macro1_notifier()
local value=device.parameters[1].value
set_groove_amount(1, value/100)
end
-- Macro 2 -> Groove 2
local function macro2_notifier()
local value=device.parameters[2].value
set_groove_amount(2, value/100)
end
-- Macro 3 -> Groove 3
local function macro3_notifier()
local value=device.parameters[3].value
set_groove_amount(3, value/100)
end
-- Macro 4 -> Groove 4
local function macro4_notifier()
local value=device.parameters[4].value
set_groove_amount(4, value/100)
end
-- Macro 5 -> BPM
local function macro5_notifier()
local value=device.parameters[5].value
local bpm_value=(value/100)*(260-20)+32
renoise.song().transport.bpm=bpm_value
end
-- Macro 6 -> Edit Step
local function macro6_notifier()
local value=device.parameters[6].value
local edit_step_value=math.floor((value/100)*64)
renoise.song().transport.edit_step=edit_step_value
end
-- Macro 7 -> Octave
local function macro7_notifier()
local value=device.parameters[7].value
local octave_value=math.floor((value/100)*8)
renoise.song().transport.octave=octave_value
end
-- Macro 8 -> LPB
local function macro8_notifier()
local value=device.parameters[8].value
local lpb_value=math.floor((value/100)*(32-1)+1)
renoise.song().transport.lpb=lpb_value
end
-- Set up notifiers for Doofer 1
local macros={
{index=1, notifier=macro1_notifier},
{index=2, notifier=macro2_notifier},
{index=3, notifier=macro3_notifier},
{index=4, notifier=macro4_notifier},
{index=5, notifier=macro5_notifier},
{index=6, notifier=macro6_notifier},
{index=7, notifier=macro7_notifier},
{index=8, notifier=macro8_notifier},
}
for _,macro in ipairs(macros) do
local param=device.parameters[macro.index]
if param.value_observable:has_notifier(macro.notifier) then
param.value_observable:remove_notifier(macro.notifier)
end
param.value_observable:add_notifier(macro.notifier)
end
renoise.app():show_status("Notifiers added for groove, BPM, LPB, Edit Step, and Octave control in Paketti Automation.")
end
-- Monitoring Function for "Paketti Automation 2" (Doofer 2)
function monitor_doofer2_macros(device)
-- Macro 1 -> EditMode
local function macro1_notifier()
local value=device.parameters[1].value
set_edit_mode(value)
end
-- Macro 2 -> Sample Record
local function macro2_notifier()
local value=device.parameters[2].value
set_sample_record(value)
renoise.song().selected_track_index = 1
local s=renoise.song()
local currTrak=s.selected_track_index
local currPatt=s.selected_pattern_index
local rightinstrument=nil
local rightinstrument=renoise.song().selected_instrument_index-1
if preferences._0G01_Loader.value then
local new_track_index = currTrak + 1
s:insert_track_at(new_track_index)
s.selected_track_index = new_track_index
currTrak = new_track_index
local line=s.patterns[currPatt].tracks[currTrak].lines[1]
line.note_columns[1].note_string="C-4"
line.note_columns[1].instrument_value=rightinstrument
line.effect_columns[1].number_string="0G"
line.effect_columns[1].amount_string="01"
end
end
-- Macro 3 -> Pattern Length
local function macro3_notifier()
local value=device.parameters[3].value
set_pattern_length(value)
end
-- Macro 4 -> Instrument Pitch
local function macro4_notifier()
local value=device.parameters[4].value
set_instrument_pitch(value)
end
-- Macro 5 -> LoopEnd
local function macro5_notifier()
local song = renoise.song()
local sample = song.selected_sample
local buffer = sample.sample_buffer
-- Ensure there's a sample and a valid buffer
if not sample or not buffer or not buffer.has_sample_data then
renoise.app():show_status("No valid sample or sample buffer.")
return
end
local value = device.parameters[5].value
local num_frames = buffer.number_of_frames
-- Map the macro value (0-100) to loop end position
local loop_end_position = math.floor((value / 100) * num_frames)
-- Ensure loop end does not go below 10 or above the sample length
loop_end_position = math.max(10, math.min(loop_end_position, num_frames))
-- Set the loop end point
sample.loop_end = loop_end_position
-- Optional: Provide feedback on the loop end position
-- renoise.app():show_status("Loop End set to: " .. loop_end_position .. " / " .. num_frames)
end
-- Macro 6 -> Placeholder2
local function macro6_notifier()
local value=device.parameters[6].value
placeholder_notifier(2, value)
end
-- Macro 7 -> Placeholder3
local function macro7_notifier()
local value=device.parameters[7].value
placeholder_notifier(3, value)
end
-- Macro 8 -> Placeholder4
local function macro8_notifier()
local value=device.parameters[8].value
placeholder_notifier(4, value)
end
-- Set up notifiers for Doofer 2
local macros={
{index=1, notifier=macro1_notifier},
{index=2, notifier=macro2_notifier},
{index=3, notifier=macro3_notifier},
{index=4, notifier=macro4_notifier},
{index=5, notifier=macro5_notifier},
{index=6, notifier=macro6_notifier},
{index=7, notifier=macro7_notifier},
{index=8, notifier=macro8_notifier},
}
for _,macro in ipairs(macros) do
local param=device.parameters[macro.index]
if param.value_observable:has_notifier(macro.notifier) then
param.value_observable:remove_notifier(macro.notifier)
end
param.value_observable:add_notifier(macro.notifier)
end
renoise.app():show_status("Notifiers added for EditMode, Sample Record, Pattern Length, Instrument Pitch, and Placeholders in Paketti Automation 2.")
end
-- Initialization Function
function initialize_doofer(device_name, device_reference, monitor_function, inject_function)
local song = renoise.song()
local track = renoise.song().sequencer_track_count + 1
renoise.song().selected_track_index = track
-- Check if the device is already present
if song.selected_track.devices[device_reference] and song.selected_track.devices[device_reference].display_name == device_name then
monitor_function(song.selected_track.devices[device_reference])
return
end
-- If not present, add the device
loadnative("Audio/Effects/Native/Doofer")
local device = song.selected_track.devices[device_reference]
device.display_name = device_name
inject_function(device)
monitor_function(device)
end
-- Main Initialization Function
function initialize_doofer_monitoring()
PakettiAutomationDoofer = true
if renoise.song().instruments[1].name ~= "Used for Paketti Automation" then
renoise.song():insert_instrument_at(1)
renoise.song().instruments[1].name = "Used for Paketti Automation"
end
if renoise.song().tracks[renoise.song().sequencer_track_count+1].devices[2] ~= nil and renoise.song().tracks[renoise.song().sequencer_track_count+1].devices[3] ~= nil then
if renoise.song().tracks[renoise.song().sequencer_track_count+1].devices[2].display_name == "Paketti Automation" and renoise.song().tracks[renoise.song().sequencer_track_count+1].devices[3].display_name == "Paketti Automation 2" then
local masterTrack=renoise.song().sequencer_track_count+1
monitor_doofer2_macros(renoise.song().tracks[masterTrack].devices[3])
monitor_doofer1_macros(renoise.song().tracks[masterTrack].devices[2])
return end
else end
groove_master_track = renoise.song().sequencer_track_count + 1
initialize_doofer("Paketti Automation 2", 2, monitor_doofer2_macros, inject_xml_to_doofer2)
initialize_doofer("Paketti Automation", 2, monitor_doofer1_macros, inject_xml_to_doofer1)
PakettiAutomationDoofer = true
end
-- Keybinding for Initialization
renoise.tool():add_keybinding{name="Global:Paketti:Paketti Automation",
invoke=function() initialize_doofer_monitoring() end}
--------
local renoise = renoise
local tool = renoise.tool()
function apply_selection_up_linear()
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
envelope:add_point_at(start_line, automation_parameter.value_min)
envelope:add_point_at(end_line, 1.0)
print("Selection Up Linear applied:")
print("Start Line: " .. start_line .. ", Value: " .. automation_parameter.value_min)
print("End Line: " .. end_line .. ", Value: 1.0")
end
local renoise = renoise
local tool = renoise.tool()
function apply_selection_down_linear()
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
envelope:add_point_at(start_line, 1.0)
envelope:add_point_at(end_line, automation_parameter.value_min)
print("Selection Down Linear applied:")
print("Start Line: " .. start_line .. ", Value: 1.0")
print("End Line: " .. end_line .. ", Value: " .. automation_parameter.value_min)
end
local renoise = renoise
local tool = renoise.tool()
function apply_constant_automation_top_to_top(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
envelope:add_point_at(start_line, 1.0)
envelope:add_point_at(start_line + 1, 1.0) -- A tick after start
envelope:add_point_at(end_line - 1, 1.0) -- Just before end
envelope:add_point_at(end_line, 1.0)
end
local renoise = renoise
local tool = renoise.tool()
function apply_constant_automation_bottom_to_bottom(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
envelope:add_point_at(start_line, 0.0)
envelope:add_point_at(start_line + 1, 0.0) -- A tick after start
envelope:add_point_at(end_line - 1, 0.0) -- Just before end
envelope:add_point_at(end_line, 0.0)
end
local renoise = renoise
local tool = renoise.tool()
function apply_exponential_automation_curve_top_to_center(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
print("Automation from line " .. start_line .. " to " .. end_line) -- Debug for range
envelope:clear_range(start_line, end_line)
local k = 6 -- Steepness factor
for i = start_line, end_line do
local normalizedPosition = (i - start_line) / (end_line - start_line)
local value = 1.0 - 0.5 * (1 - math.exp(-k * normalizedPosition)) -- Adjusted for decay starting at 1.0
envelope:add_point_at(i, value)
print("Adding point at line " .. i .. " with value " .. value) -- Debug print
end
-- Explicitly set the last point at end_line to 0.5
envelope:add_point_at(end_line, 0.5)
print("Explicitly setting final point at line " .. end_line .. " with value 0.5") -- Debug print for the final point
end
local renoise = renoise
local tool = renoise.tool()
function apply_exponential_automation_curve_bottom_to_center(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
print("Automation from line " .. start_line .. " to " .. end_line) -- Debug for range
envelope:clear_range(start_line, end_line)
local k = 6 -- Steepness factor
-- We make sure to include the last index by going up to end_line
for i = start_line, end_line do
local normalizedPosition = (i - start_line) / (end_line - start_line)
local value = 0.5 * (1 - math.exp(-k * normalizedPosition))
envelope:add_point_at(i, value)
print("Adding point at line " .. i .. " with value " .. value) -- Debug print
end
-- Explicitly set the last point at end_line to 0.5
envelope:add_point_at(end_line, 0.5)
print("Explicitly setting final point at line " .. end_line .. " with value 0.5") -- Debug print for the final point
end
local renoise = renoise
local tool = renoise.tool()
function apply_exponential_automation_curve_center_to_bottom(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
local k = 3
local exp_k = math.exp(k)
local denominator = exp_k - 1
for i = start_line, end_line - 1 do -- Loop until the second last point
local normalizedPosition = (i - start_line) / (end_line - start_line)
local exp_value = (math.exp(k * normalizedPosition) - 1) / denominator
local value = 0.5 - 0.5 * exp_value
-- Debug print statement
print(string.format("Line: %d, NormalizedPosition: %.4f, Value: %.4f", i, normalizedPosition, value))
envelope:add_point_at(i, value)
end
envelope:add_point_at(end_line, 0.0) -- Explicitly set the last point to 0.0
end
local renoise = renoise
local tool = renoise.tool()
local renoise = renoise
local tool = renoise.tool()
function apply_exponential_automation_curve_center_to_top(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
envelope:clear_range(start_line, end_line)
local k = 3
local exp_k = math.exp(k)
local denominator = exp_k - 1
for i = start_line, end_line - 1 do -- Loop until the second last point
local normalizedPosition = (i - start_line) / (end_line - start_line)
local exp_value = (math.exp(k * normalizedPosition) - 1) / denominator
local value = 0.5 + 0.5 * exp_value
-- Debug print statement
print(string.format("Line: %d, NormalizedPosition: %.4f, Value: %.4f", i, normalizedPosition, value))
envelope:add_point_at(i, value)
end
envelope:add_point_at(end_line, 1.0) -- Explicitly set the last point to 1.0
end
local renoise = renoise
local tool = renoise.tool()
function apply_exponential_automation_curveDOWN(type)
local song = renoise.song()
local automation_parameter = song.selected_automation_parameter
if not automation_parameter or not automation_parameter.is_automatable then
renoise.app():show_status("Please select an automatable parameter.")
return
end
local envelope = song:pattern(song.selected_pattern_index):track(song.selected_track_index):find_automation(automation_parameter)
if not envelope or not envelope.selection_range then
renoise.app():show_status("No automation selection or envelope found.")
return
end
local selection = envelope.selection_range
local start_line = selection[1]
local end_line = selection[2]
print("Selection start: " .. start_line .. ", end: " .. end_line) -- Debug for selection range
envelope:clear_range(start_line, end_line)
local k = 3 -- Adjust this value to change the steepness of the curve
for i = start_line, end_line do
local normalizedPosition = (i - start_line) / (end_line - start_line)
local value = 1 - (math.exp(k * normalizedPosition) / math.exp(k)) -- Using exponential decay