-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PakettiControls.lua
458 lines (394 loc) · 18.6 KB
/
PakettiControls.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
-- Shortcuts 2nd / 3rds
--2nd Save Song bind
function saveSong()
renoise.app():save_song()
renoise.app():show_status("Song saved: " .. "'"..renoise.app().current_song.file_name.."'")
end
renoise.tool():add_keybinding{name="Global:Paketti:Save Song (2nd)",invoke=function() saveSong() end}
function RecordFollowToggle()
local s=renoise.song()
local t=s.transport
local w=renoise.app().window
w.active_middle_frame=1
if t.edit_mode == true and t.follow_player == true then t.edit_mode=false t.follow_player=false return end
if t.edit_mode == false and t.follow_player == false then t.edit_mode=true t.follow_player=true return else t.edit_mode=false t.follow_player=false end
if t.follow_player == false and t.edit_mode == false then t.follow_player=true t.edit_mode=true else t.follow_player=false t.edit_mode=false end
w.active_middle_frame=1
end
renoise.tool():add_keybinding{name="Global:Paketti:Record+Follow Toggle (2nd)",invoke=function() RecordFollowToggle() end}
renoise.tool():add_keybinding{name="Global:Paketti:Record+Follow Toggle (3rd)",invoke=function() RecordFollowToggle() end}
renoise.tool():add_keybinding{name="Global:Paketti:Record+Follow Toggle (4th)",invoke=function() RecordFollowToggle() end}
--------------------------------------------------------------------------------------------------------------------------------------------------------
--esa- 2nd keybind for Record Toggle ON/OFF with effect_column reading
previous_edit_step = nil
function RecordToggleg()
local s = renoise.song()
local t = s.transport
-- Output the current edit_step
print("Current edit_step: " .. t.edit_step)
-- Toggle edit mode
t.edit_mode = not t.edit_mode
if t.edit_mode then
-- If turning edit_mode on
if s.selected_effect_column_index and s.selected_effect_column_index > 0 then
-- Store current edit_step before changing it to 0
previous_edit_step = t.edit_step
print("Stored previous_edit_step: " .. previous_edit_step)
t.edit_step = 0
else
-- If no effect column is selected, do nothing with edit_step
print("No effect column selected")
end
else
-- If turning edit_mode off
if s.selected_effect_column_index and s.selected_effect_column_index > 0 then
-- Restore previous edit_step if it was saved
if previous_edit_step then
t.edit_step = previous_edit_step
print("Restored edit_step to: " .. t.edit_step)
previous_edit_step = nil
else
print("No previous_edit_step saved")
end
else
-- If no effect column is selected and we are in note column
if not s.selected_effect_column_index or s.selected_effect_column_index == 0 then
-- Restore previous edit_step if edit_step is 0 and previous_edit_step is not 0
if t.edit_step == 0 and previous_edit_step and previous_edit_step ~= 0 then
t.edit_step = previous_edit_step
print("Restored edit_step to: " .. t.edit_step)
previous_edit_step = nil
end
else
print("No effect column selected and not in note column")
end
end
end
-- -- Toggle follow_player mode
-- t.follow_player = not t.follow_player
end
renoise.tool():add_keybinding{name="Global:Paketti:Toggle EditMode (2nd)",invoke=function() RecordToggleg() end}
renoise.tool():add_keybinding{name="Global:Paketti:Toggle EditMode (3rd)",invoke=function() RecordToggleg() end}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function RecordFollowMetronomeToggle()
local w=renoise.app().window
local t=renoise.song().transport
w.active_middle_frame=1
w.lock_keyboard_focus=true
if t.edit_mode==false and t.follow_player==false and t.metronome_enabled==false then
t.edit_mode=true
t.follow_player=true
t.metronome_enabled=true else
t.edit_mode=false
t.follow_player=false
t.metronome_enabled=false end
if t.playing==false then t.playing=true t.metronome_enabled=true t.follow_player=true t.edit_mode=true end
end
renoise.tool():add_keybinding{name="Global:Paketti:Record+Follow+Metronome Toggle",invoke=function() RecordFollowMetronomeToggle() end}
--------------------------------------------------------------------------------------------------------------------------------------------------------
function FollowPatternToggle()
local a=renoise.app()
local t=renoise.song().transport
local w=renoise.app().window
local pe=renoise.ApplicationWindow.MIDDLE_FRAME_PATTERN_EDITOR
if t.follow_player==true and w.active_middle_frame==pe
then t.follow_player=false
else t.follow_player = true
w.active_middle_frame=pe end end
renoise.tool():add_keybinding{name="Global:Paketti:Toggle Follow Pattern (2nd)",invoke=function() FollowPatternToggle() end}
-- 2nd Fullscreen toggle
function SecondFullscreen()
local w=renoise.app().window
if w.fullscreen==true then w.fullscreen=false else w.fullscreen=true end end
renoise.tool():add_keybinding{name="Global:Paketti:Fullscreen (2nd)",invoke=function() SecondFullscreen() end}
------
renoise.tool():add_menu_entry{name="Track Automation:Paketti..:Start/Stop Pattern Follow",invoke=function()
local fp=renoise.song().transport.follow_player
if not fp then fp=true else fp=false end end}
renoise.tool():add_menu_entry{name="DSP Device Automation:Follow Off",invoke=function() renoise.song().transport.follow_player=false end}
-------
function KeybOctave(amount)
local t = renoise.song().transport
t.octave= (t.octave + amount) % 9
end
renoise.tool():add_keybinding{name="Global:Paketti:KeybOctave Up", invoke=function() KeybOctave(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:KeybOctave Down", invoke=function() KeybOctave(-1) end}
-----
function PakettiTranspose(steps)
local song = renoise.song()
local selection = song.selection_in_pattern
local pattern = song.selected_pattern
local start_track, end_track, start_line, end_line, start_column, end_column
if selection ~= nil then
start_track = selection.start_track
end_track = selection.end_track
start_line = selection.start_line
end_line = selection.end_line
start_column = selection.start_column
end_column = selection.end_column
else
start_track = song.selected_track_index
end_track = song.selected_track_index
start_line = 1
end_line = pattern.number_of_lines
start_column = 1
end_column = song.tracks[start_track].visible_note_columns
end
local is_valid_track = false
for track_index = start_track, end_track do
local track = song:track(track_index)
if track.type == renoise.Track.TRACK_TYPE_SEQUENCER then
is_valid_track = true
break
end
end
if not is_valid_track then
renoise.app():show_status("The selected track is a Group / Master or Send, and doesn't have Note Columns. Doing nothing.")
return
end
for track_index = start_track, end_track do
local track = song:track(track_index)
if track.type == renoise.Track.TRACK_TYPE_SEQUENCER then
local track_pattern = pattern:track(track_index)
for line_index = start_line, end_line do
local line = track_pattern:line(line_index)
for column_index = start_column, end_column do
local note_column = line:note_column(column_index)
if not note_column.is_empty then
if note_column.note_value < 120 then
note_column.note_value = (note_column.note_value + steps) % 120
end
end
end
end
end
end
end
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose Octave Up (Selection/Track)",invoke=function() PakettiTranspose(12) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose Octave Down (Selection/Track)",invoke=function() PakettiTranspose(-12) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose +1 (Selection/Track)",invoke=function() PakettiTranspose(1) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose -1 (Selection/Track)",invoke=function() PakettiTranspose(-1) end}
--------------
function PakettiTransposeNoteColumn(steps)
local song = renoise.song()
local selection = song.selection_in_pattern
local pattern = song.selected_pattern
local start_track, end_track, start_line, end_line, start_column, end_column
if selection ~= nil then
start_track = selection.start_track
end_track = selection.end_track
start_line = selection.start_line
end_line = selection.end_line
start_column = selection.start_column
end_column = selection.end_column
else
start_track = song.selected_track_index
end_track = song.selected_track_index
start_line = 1
end_line = pattern.number_of_lines
start_column = song.selected_note_column_index
end_column = song.selected_note_column_index
end
for track_index = start_track, end_track do
local track = song:track(track_index)
local track_pattern = pattern:track(track_index)
local first_column = (track_index == start_track) and start_column or 1
local last_column = (track_index == end_track) and end_column or track.visible_note_columns
for line_index = start_line, end_line do
local line = track_pattern:line(line_index)
for column_index = first_column, last_column do
local note_column = line:note_column(column_index)
if not note_column.is_empty then
if note_column.note_value < 120 then
note_column.note_value = (note_column.note_value + steps) % 120
end
end
end
end
end
end
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose Octave Up Note Column (Selection/Note Column)",invoke=function() PakettiTransposeNoteColumn(12) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose Octave Down Note Column (Selection/Note Column)",invoke=function() PakettiTransposeNoteColumn(-12) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose +1 Note Column (Selection/Note Column)",invoke=function() PakettiTransposeNoteColumn(1) end}
renoise.tool():add_keybinding{name="Pattern Editor:Paketti:Transpose -1 Note Column (Selection/Note Column)",invoke=function() PakettiTransposeNoteColumn(-1) end}
---------
function simpleplay()
if renoise.song().transport.playing
then renoise.song().transport.playing=false
else renoise.song().transport.playing=true end end
renoise.tool():add_keybinding{name="Global:Paketti:Simple Play",invoke=function() simpleplay() end}
---------
function MetronomeOff()
if renoise.song().transport.metronome_enabled then renoise.song().transport.metronome_enabled = false else renoise.song().transport.metronome_enabled=true end end
renoise.tool():add_keybinding{name="Global:Paketti:Toggle Metronome On/Off",invoke=function() MetronomeOff() end}
---------
renoise.tool():add_keybinding{name="Global:Paketti:Song Details (Filename, BPM, LPB)",invoke=function()
local filename = nil
if renoise.song().file_name == ("") then filename = "(Not Yet Saved)"
else filename = renoise.song().file_name
end
renoise.app():show_status("File: " .. filename .. ", BPM: " .. renoise.song().transport.bpm .. ", LPB: " .. renoise.song().transport.lpb) end}
-------------
-- RecordFollowOn / Off / ContourShuttle
function recOffFollowOn()
renoise.song().transport.edit_mode=false
renoise.song().transport.follow_player=true
renoise.song().transport.playing=true
end
function recOnFollowOff()
renoise.song().transport.edit_mode=true
renoise.song().transport.follow_player=false
renoise.song().transport.wrapped_pattern_edit=true
renoise.app().window.active_middle_frame=1
end
renoise.tool():add_keybinding{name="Global:Paketti:Contour Shuttle Record Off", invoke=function() recOffFollowOn() end}
renoise.tool():add_keybinding{name="Global:Paketti:Contour Shuttle Record On", invoke=function() recOnFollowOff() end}
-------
renoise.tool():add_keybinding{name="Global:Paketti:Global Edit Mode Toggle",invoke=function()
if renoise.song().transport.edit_mode then renoise.song().transport.edit_mode=false
else renoise.song().transport.edit_mode=true end
end}
---------------
function upby(number)
local result = nil
local pos = renoise.song().transport.edit_pos
result = pos.line - number
if result < 1 then
result = 1
else
-- print(result)
end
pos.line = result
renoise.song().transport.edit_pos = pos
renoise.song().transport.playback_pos = pos
end
function upbyn(number)
if renoise.song().transport.playing == true then
if renoise.song().transport.follow_player == false then return end
upby(number)
renoise.app().window.active_middle_frame = 1
renoise.app().window.lock_keyboard_focus = true
if renoise.song().tracks[renoise.song().selected_track_index].max_note_columns == 0 then return end
if renoise.song().selected_track.type==2 or renoise.song().selected_track.type==3 or renoise.song().selected_track.type==4 then return
else renoise.song().selected_note_column_index = 1 end
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Rewind Playback by 4 steps", invoke=function() upbyn(4) end}
---------
function midi_imm()
if renoise.app().window.active_middle_frame==renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR
then renoise.app().window.active_middle_frame=1
else renoise.app().window.active_middle_frame=renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR end
end
renoise.tool():add_keybinding{name="Global:Paketti:Pattern Editor <-> Midi Editor Switcher",invoke=function() midi_imm() end}
-----------
function selectNextTrack()
local nextTrack= renoise.song().selected_track_index+1
if nextTrack > #renoise.song().tracks then
nextTrack=1 else end
renoise.song().selected_track_index=nextTrack
end
function selectPreviousTrack()
local previousTrack= renoise.song().selected_track_index-1
if previousTrack < 1
then previousTrack=#renoise.song().tracks
renoise.song().selected_track_index=previousTrack return else
if previousTrack > #renoise.song().tracks then
previousTrack=1 else end
end
renoise.song().selected_track_index=previousTrack
end
renoise.tool():add_keybinding{name="Global:Paketti:Select Track (Next)",invoke=function() selectNextTrack() end}
renoise.tool():add_keybinding{name="Global:Paketti:Select Track (Previous)",invoke=function() selectPreviousTrack() end}
function createNewTrack()
renoise.song():insert_track_at(renoise.song().selected_track_index)
end
renoise.tool():add_keybinding{name="Global:Paketti:Insert Track (2nd)", invoke=function() createNewTrack() end}
---------
-- Define a table with the middle frame constants
local middle_frames = {
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PHRASE_EDITOR,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_KEYZONES,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EDITOR,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_MODULATION,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_SAMPLE_EFFECTS,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_PLUGIN_EDITOR,
renoise.ApplicationWindow.MIDDLE_FRAME_INSTRUMENT_MIDI_EDITOR
}
-- Function to switch the middle frame based on the tab number
function sampleEditorTabSwitcher(tabNumber)
if tabNumber >= 1 and tabNumber <= #middle_frames then
renoise.app().window.active_middle_frame = middle_frames[tabNumber]
else
renoise.app():show_status("Invalid tab number: " .. tostring(tabNumber))
end
end
-- Function to cycle through middle frames based on MIDI input value (0-127)
function cycleMiddleFrames(midiValue)
local index = math.floor(midiValue / 127 * (#middle_frames - 1)) + 1
renoise.app().window.active_middle_frame = middle_frames[index]
end
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (01 Phrases)",invoke=function() sampleEditorTabSwitcher(1) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (02 Keyzones)",invoke=function() sampleEditorTabSwitcher(2) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (03 Waveform)",invoke=function() sampleEditorTabSwitcher(3) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (04 Modulation)",invoke=function() sampleEditorTabSwitcher(4) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (05 Effects)",invoke=function() sampleEditorTabSwitcher(5) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (06 Plugin Editor)",invoke=function() sampleEditorTabSwitcher(6) end}
renoise.tool():add_keybinding{name="Global:Paketti:Sample Editor Tab Switcher (07 Midi Editor)",invoke=function() sampleEditorTabSwitcher(7) end}
renoise.tool():add_midi_mapping{name="Paketti:Cycle Sample Editor Tabs x[Knob]",invoke=function(midiMessage) cycleMiddleFrames(midiMessage.int_value) end}
----------
--2nd keybind for LoopBlock forward/backward
function loopblockback()
local t = renoise.song().transport
t.loop_block_enabled=true
t:loop_block_move_backwards()
t.follow_player = true
end
function loopblockforward()
local t = renoise.song().transport
t.loop_block_enabled=true
t:loop_block_move_forwards()
t.follow_player = true
end
renoise.tool():add_keybinding{name="Global:Paketti:Select LoopBlock Backwards (Previous)", invoke=function() loopblockback() end}
renoise.tool():add_keybinding{name="Global:Paketti:Select LoopBlock Forwards (Next)", invoke=function() loopblockforward() end}
--------
---------
local function PakettiSetEditStep(value)
renoise.song().transport.edit_step=value
-- renoise.app():show_status("Edit Step set to " .. tostring(value))
end
-- Keybinding definitions from 00 to 64
for i=0,64 do
renoise.tool():add_keybinding{name="Global:Paketti:Set EditStep to " .. formatDigits(2,i),
invoke=function() PakettiSetEditStep(i) end}
end
----
--esa- 2nd keybind for Record Toggle ON/OFF with effect_column reading
function RecordToggle()
local a=renoise.app()
local s=renoise.song()
local t=s.transport
local currentstep=t.edit_step
--if has notifier, dump notifier, if no notifier, add notifier
if t.edit_mode then
t.edit_mode=false
if t.edit_step==0 then
t.edit_step=1
else
return
end
else
t.edit_mode = true
if s.selected_effect_column_index == 1 then t.edit_step=0
elseif s.selected_effect_column_index == 0 then t.edit_step=currentstep return
end
end
end
renoise.tool():add_keybinding{name="Global:Paketti:Record Toggle with EditStep Reading (2nd)", invoke=function() RecordToggle() end}
---------
function loadRecentlySavedSong()
renoise.app():load_song(renoise.app().recently_saved_song_files[1])
end
renoise.tool():add_keybinding{name="Global:Paketti:Load Recently Saved Song",invoke=function() loadRecentlySavedSong() end}
renoise.tool():add_menu_entry{name="Main Menu:File:Paketti..:Load Recently Saved Song",invoke=function() loadRecentlySavedSong() end}