Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _AUTO_RELOAD_DEBUG = function() end
- class "RenoiseScriptingTool" (renoise.Document.DocumentNode)
- function RenoiseScriptingTool:__init()
- renoise.Document.DocumentNode.__init(self)
- self:add_property("Name", "Untitled Tool")
- self:add_property("Id", "Unknown Id")
- end
- local manifest = RenoiseScriptingTool()
- local ok,err = manifest:load_from("manifest.xml")
- local tool_name = manifest:property("Name").value
- local tool_id = manifest:property("Id").value
- local dialog, sng, transp, show_dialog
- local divisor = 3
- sng = renoise.song()
- transp = sng.transport
- local function move_up()
- --debug.start()
- --launch dialog if no divisor is set
- -- if not transp then show_dialog() end
- --worker values
- local line = transp.edit_pos.line
- local del_val = sng.selected_note_column.delay_value
- local sequence = transp.edit_pos.sequence
- --step length
- local lpb = transp.lpb
- local pos_in_beat = line % lpb
- local step = lpb / divisor
- -- local new_line, new_delay = math.floor(step)
- --local = math.abs((step - step_lines)/255)
- --move to closest quantised, finalise and return
- local amount_of_steps_over = math.floor(pos_in_beat / step)
- local pos_in_beat_of_last_full_step = amount_of_steps_over * step
- if not (pos_in_beat - pos_in_beat_of_last_full_step) == 0 then
- local math_floor_pos_in_beat_step_times_step_div_lpb = pos_in_beat_of_last_full_step / lpb
- line = line - pos_in_beat_of_last_full_step
- del_val = (math_floor_pos_in_beat_step_times_step_div_lpb - line)/255
- local t_edit_pos = tranp.edit_pos
- t_edit_pos.line = line
- transp.edit_pos = t_edit_pos
- sng.selected_note_column.delay_value = line * step
- return
- end
- --debug.stop()
- --[[
- local new_line
- --take into account current delay_value
- local sel_note_col = sng.selected_note_column
- --sel_note_col.delay_value
- --pattern wrap
- local sel_pat_num_of_lines = sng.selected_pattern.number_of_lines
- local pattern_wrap_onff = transp.wrapped_pattern_edit
- if line < 0 then
- if pattern_wrap_onff then
- if not sequence == 1 then
- sequence = sequence - 1
- line = sng.pattern[sequence].number_of_lines - line
- end
- else
- line = sel_pat_num_of_lines - line
- end
- end
- --finalise
- local t_edit_pos = transp.edit_pos
- t_edit_pos.line = line
- t_edit_pos.sequence = sequence
- transp.edit_pos = t_edit_pos
- --sng.selected_note_column.delay_value =
- ]]
- end
- --[[
- local function move_down()
- --launch dialog if no initial value is set
- if not transp then show_dialog() end
- --pattern wrap
- local sel_pat_num_of_lines = sng.selected_pattern.number_of_lines
- local pattern_wrap_onff = transp.wrapped_pattern_edit
- if line > sel_pat_num_of_lines then
- if pattern_wrap_onff then
- if sequence < #sng.patterns then
- sequence = sequence + 1
- line = line - sel_pat_num_of_lines
- end
- else
- line = line - sel_pat_num_of_lines
- end
- end
- end
- ]]
- function show_dialog()
- if dialog and dialog.visible then
- dialog:show()
- return
- end
- local vb = renoise.ViewBuilder()
- sng = renoise.song()
- transp = sng.transport
- local draw_content = vb:row
- {
- vb:textfield
- {
- text = tostring(divisor),
- notifier = function(text)
- divisor = tonumber(text)
- end
- },
- }
- local function keyhand(dialog, key)
- if (key.modifiers == "" and key.name == "esc") then
- dialog:close()
- else
- return key
- end
- end
- dialog = renoise.app():show_custom_dialog('divisor', draw_content, keyhand)
- end
- --------------------------------------------------------------------------------
- -- Menu entries
- --------------------------------------------------------------------------------
- renoise.tool():add_menu_entry {
- name = "Main Menu:Tools:"..tool_name.."...",
- invoke = move_up
- }
- --------------------------------------------------------------------------------
- -- Key Binding
- --------------------------------------------------------------------------------
- --[[
- renoise.tool():add_keybinding {
- name = "Global:Tools:" .. tool_name.."...",
- invoke = show_dialog
- }
- --]]
- --------------------------------------------------------------------------------
- -- MIDI Mapping
- --------------------------------------------------------------------------------
- --[[
- renoise.tool():add_midi_mapping {
- name = tool_id..":Show Dialog...",
- invoke = show_dialog
- }
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement