From e934f55b1208102a12951fcba50b010a9b25259d Mon Sep 17 00:00:00 2001 From: MichaelMcClennan <89558058+MichaelMcClennan@users.noreply.github.com> Date: Mon, 3 Jan 2022 16:45:55 -0500 Subject: [PATCH 1/5] Add be_right_back A temporary floating bookmark. The user 'Sets' the current position ... moves around the score(maybe to copy music) ... 'Goes Back' to the saved position. --- src/be_right_back.lua | 89 +++++++++++++++++++++++++++++++++++++++ src/randomize_pitches.lua | 79 ++++++++++++++++++++++++++++++++++ src/replicate_music.lua | 23 ++++++++++ 3 files changed, 191 insertions(+) create mode 100644 src/be_right_back.lua create mode 100644 src/randomize_pitches.lua create mode 100644 src/replicate_music.lua diff --git a/src/be_right_back.lua b/src/be_right_back.lua new file mode 100644 index 00000000..30cc2a20 --- /dev/null +++ b/src/be_right_back.lua @@ -0,0 +1,89 @@ +function plugindef() + finaleplugin.Author = "Michael McClennan" + finaleplugin.Version = 1.0 + finaleplugin.Copyright = "2022/01/03" + finaleplugin.HandlesUndo = false + finaleplugin.NoStore = true +end + +local str = finale.FCString() +str.LuaString = "BRB v1.0" +BRB_dialog = finale.FCCustomLuaWindow() +BRB_dialog:SetTitle(str) +BRB_dialog:SetClientWidth(90) + +local button_go_back = BRB_dialog:CreateButton(0, 0) +str.LuaString = "Go Back" +button_go_back:SetWidth(60) +button_go_back:SetText(str) +local button_set = BRB_dialog:CreateButton(65, 0) +str.LuaString = "Set" +button_set:SetWidth(40) +button_set:SetText(str) +local buttonCancel = BRB_dialog:CreateCancelButton() +str.LuaString = "Close" +buttonCancel:SetWidth(50) +buttonCancel:SetText(str) + +BRB_table = {} +trigger = {} +function trigger.buttonGo() + local part = finale.FCPart(BRB_table.part) + part:ViewInDocument() + + --VIEWPAGE/SCROLL + if BRB_table.page_view == true then --PAGE VIEW + local ui = finenv.UI() + ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW ) + finenv.UI():MoveToMeasure(BRB_table.measure_num, 1) + ui:MenuCommand(finale.MENUCMD_VIEWPAGEVIEW ) + --insert a Zoom Level call when PDK allows + + else --SCROLL VIEW + local ui = finenv.UI() + ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW ) + --insert a Zoom Level call when PDK allows + finenv.UI():MoveToMeasure(BRB_table.measure_num, 1) + end + + local ui = finenv.UI() + ui:RedrawDocument() +end + +function trigger.button_set() + + -- local selected_region = finenv.Region() + -- BRB_table.region = selected_region:GetStartMeasure() + BRB_table.page_view = finenv.UI():IsPageView() + local p = finale.FCPart(finale.PARTID_CURRENT) + BRB_table.part = p:GetID() + BRB_table.zoom = finenv.UI():GetZoomLevel() + cur_docID = finale.FCDocument(-1) + BRB_table.document = cur_docID:GetID() + if is_page_view == true then --PAGE VIEW + local ui = finenv.UI() + BRB_table.page_num = finenv.UI():GetCurrentPage() + ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW ) + BRB_table.measure_num = finenv.UI():GetCurrentMeasure() + ui:MenuCommand(finale.MENUCMD_VIEWPAGEVIEW ) + else + BRB_table.measure_num = finenv.UI():GetCurrentMeasure() --SCROLL VIEW + end +end + +BRB_dialog:RegisterHandleControlEvent ( + button_go_back, + function(control) + trigger.buttonGo() + end +) +BRB_dialog:RegisterHandleControlEvent ( + button_set, + function(control) + trigger.button_set() + end +) + +finenv.RegisterModelessDialog(BRB_dialog) +BRB_dialog:ShowModeless() + diff --git a/src/randomize_pitches.lua b/src/randomize_pitches.lua new file mode 100644 index 00000000..c6dc6f1a --- /dev/null +++ b/src/randomize_pitches.lua @@ -0,0 +1,79 @@ +function plugindef() + finaleplugin.Author = "Michael McClennan" + finaleplugin.Version = 1.0 + finaleplugin.Copyright = "2022/01/03" + finaleplugin.HandlesUndo = true +end + +local str = finale.FCString() +dialog = finale.FCCustomLuaWindow() +str.LuaString="Randomize Pitches 0.1" +dialog:SetTitle(str) +dialog:CreateOkButton() +dialog:CreateCancelButton() + +editInterval_range = dialog:CreateEdit(85,0) +str.LuaString="3" +editInterval_range:SetText(str) +editInterval_range:SetWidth(30) +staticInterval_range = dialog:CreateStatic(0,2) +str.LuaString="Interval Range:" +staticInterval_range:SetText(str) +buttonApply = dialog:CreateButton(125,0) +str.LuaString="Apply" +buttonApply:SetText(str) + +local function randomize_pitches(interval_range) + finenv.StartNewUndoBlock("Randomize Pitches") + for entry in eachentrysaved(finenv.Region()) do + low_interval_range = interval_range * -1 + if entry:IsNote() then + for note in each(entry) do + local midi = note:CalcMIDIKey() + random_num = math.random(low_interval_range, interval_range) + note:SetMIDIKey(midi +random_num) + end + end + end + finenv.EndUndoBlock(true) +end + +if finenv.IsRGPLua then + local Lua_version_text = dialog:CreateStatic(0, 15) + str.LuaString = "(RGP Lua)" + Lua_version_text:SetText(str) + + dialog:RegisterHandleControlEvent ( + buttonApply, + function(control) + local interval_range = editInterval_range:GetInteger() + randomize_pitches(interval_range) + local ui = finenv.UI() + ui:RedrawDocument() + end + ) + + finenv.RegisterModelessDialog(dialog) + dialog:ShowModeless() + +else + local Lua_version_text = dialog:CreateStatic(0, 15) + str.LuaString = "(JW Lua)" + Lua_version_text:SetText(str) + + local function command_handler(thecontrol) + + if thecontrol:GetControlID(1) == buttonApply:GetControlID() then + local interval_range = editInterval_range:GetInteger() + randomize_pitches(interval_range) + local ui = finenv.UI() + ui:RedrawDocument() + end + end + + dialog:RegisterHandleCommand(command_handler) + + if (dialog:ExecuteModal(nil) == 1) then + -- Ok button was pressed + end +end diff --git a/src/replicate_music.lua b/src/replicate_music.lua new file mode 100644 index 00000000..e30dbcaf --- /dev/null +++ b/src/replicate_music.lua @@ -0,0 +1,23 @@ +function plugindef() + finaleplugin.Author = "Michael McClennan" + finaleplugin.Version = 1.0 + finaleplugin.Copyright = "2022/01/03" + finaleplugin.HandlesUndo = true +end + +local function replicate_music() + local region = finenv.Region() + local start_measure = finenv.Region().StartMeasure + local end_measure = finenv.Region().EndMeasure + local sum_measures = end_measure - start_measure + local start_paste_region = end_measure + 1 + finenv.StartNewUndoBlock("Replicate Music", true) + region:CopyMusic() + finenv.Region():SetStartMeasure(start_paste_region) + finenv.Region():SetEndMeasure(start_paste_region + sum_measures) + region:PasteMusic() + region:ReleaseMusic() + finenv.EndUndoBlock(true) +end + +replicate_music() \ No newline at end of file From ed03b42932722feaa8f15bd723661e0995638bd9 Mon Sep 17 00:00:00 2001 From: MichaelMcClennan <89558058+MichaelMcClennan@users.noreply.github.com> Date: Mon, 3 Jan 2022 17:26:52 -0500 Subject: [PATCH 2/5] Delete randomize_pitches.lua --- src/randomize_pitches.lua | 79 --------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/randomize_pitches.lua diff --git a/src/randomize_pitches.lua b/src/randomize_pitches.lua deleted file mode 100644 index c6dc6f1a..00000000 --- a/src/randomize_pitches.lua +++ /dev/null @@ -1,79 +0,0 @@ -function plugindef() - finaleplugin.Author = "Michael McClennan" - finaleplugin.Version = 1.0 - finaleplugin.Copyright = "2022/01/03" - finaleplugin.HandlesUndo = true -end - -local str = finale.FCString() -dialog = finale.FCCustomLuaWindow() -str.LuaString="Randomize Pitches 0.1" -dialog:SetTitle(str) -dialog:CreateOkButton() -dialog:CreateCancelButton() - -editInterval_range = dialog:CreateEdit(85,0) -str.LuaString="3" -editInterval_range:SetText(str) -editInterval_range:SetWidth(30) -staticInterval_range = dialog:CreateStatic(0,2) -str.LuaString="Interval Range:" -staticInterval_range:SetText(str) -buttonApply = dialog:CreateButton(125,0) -str.LuaString="Apply" -buttonApply:SetText(str) - -local function randomize_pitches(interval_range) - finenv.StartNewUndoBlock("Randomize Pitches") - for entry in eachentrysaved(finenv.Region()) do - low_interval_range = interval_range * -1 - if entry:IsNote() then - for note in each(entry) do - local midi = note:CalcMIDIKey() - random_num = math.random(low_interval_range, interval_range) - note:SetMIDIKey(midi +random_num) - end - end - end - finenv.EndUndoBlock(true) -end - -if finenv.IsRGPLua then - local Lua_version_text = dialog:CreateStatic(0, 15) - str.LuaString = "(RGP Lua)" - Lua_version_text:SetText(str) - - dialog:RegisterHandleControlEvent ( - buttonApply, - function(control) - local interval_range = editInterval_range:GetInteger() - randomize_pitches(interval_range) - local ui = finenv.UI() - ui:RedrawDocument() - end - ) - - finenv.RegisterModelessDialog(dialog) - dialog:ShowModeless() - -else - local Lua_version_text = dialog:CreateStatic(0, 15) - str.LuaString = "(JW Lua)" - Lua_version_text:SetText(str) - - local function command_handler(thecontrol) - - if thecontrol:GetControlID(1) == buttonApply:GetControlID() then - local interval_range = editInterval_range:GetInteger() - randomize_pitches(interval_range) - local ui = finenv.UI() - ui:RedrawDocument() - end - end - - dialog:RegisterHandleCommand(command_handler) - - if (dialog:ExecuteModal(nil) == 1) then - -- Ok button was pressed - end -end From 7d44b71641715093ad28d6848fc2465751f5f294 Mon Sep 17 00:00:00 2001 From: MichaelMcClennan <89558058+MichaelMcClennan@users.noreply.github.com> Date: Mon, 3 Jan 2022 17:27:07 -0500 Subject: [PATCH 3/5] Delete replicate_music.lua --- src/replicate_music.lua | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 src/replicate_music.lua diff --git a/src/replicate_music.lua b/src/replicate_music.lua deleted file mode 100644 index e30dbcaf..00000000 --- a/src/replicate_music.lua +++ /dev/null @@ -1,23 +0,0 @@ -function plugindef() - finaleplugin.Author = "Michael McClennan" - finaleplugin.Version = 1.0 - finaleplugin.Copyright = "2022/01/03" - finaleplugin.HandlesUndo = true -end - -local function replicate_music() - local region = finenv.Region() - local start_measure = finenv.Region().StartMeasure - local end_measure = finenv.Region().EndMeasure - local sum_measures = end_measure - start_measure - local start_paste_region = end_measure + 1 - finenv.StartNewUndoBlock("Replicate Music", true) - region:CopyMusic() - finenv.Region():SetStartMeasure(start_paste_region) - finenv.Region():SetEndMeasure(start_paste_region + sum_measures) - region:PasteMusic() - region:ReleaseMusic() - finenv.EndUndoBlock(true) -end - -replicate_music() \ No newline at end of file From 8bbbdaba4428a1535a4c0eb9b08323f72f1c406a Mon Sep 17 00:00:00 2001 From: MichaelMcClennan <89558058+MichaelMcClennan@users.noreply.github.com> Date: Mon, 3 Jan 2022 17:29:47 -0500 Subject: [PATCH 4/5] Add randomize_pitches When you need to send a file for diagnostic reasons(say to MakeMusic), but you don't want to send the real notes. --- src/randomize_pitches.lua | 79 --------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/randomize_pitches.lua diff --git a/src/randomize_pitches.lua b/src/randomize_pitches.lua deleted file mode 100644 index c6dc6f1a..00000000 --- a/src/randomize_pitches.lua +++ /dev/null @@ -1,79 +0,0 @@ -function plugindef() - finaleplugin.Author = "Michael McClennan" - finaleplugin.Version = 1.0 - finaleplugin.Copyright = "2022/01/03" - finaleplugin.HandlesUndo = true -end - -local str = finale.FCString() -dialog = finale.FCCustomLuaWindow() -str.LuaString="Randomize Pitches 0.1" -dialog:SetTitle(str) -dialog:CreateOkButton() -dialog:CreateCancelButton() - -editInterval_range = dialog:CreateEdit(85,0) -str.LuaString="3" -editInterval_range:SetText(str) -editInterval_range:SetWidth(30) -staticInterval_range = dialog:CreateStatic(0,2) -str.LuaString="Interval Range:" -staticInterval_range:SetText(str) -buttonApply = dialog:CreateButton(125,0) -str.LuaString="Apply" -buttonApply:SetText(str) - -local function randomize_pitches(interval_range) - finenv.StartNewUndoBlock("Randomize Pitches") - for entry in eachentrysaved(finenv.Region()) do - low_interval_range = interval_range * -1 - if entry:IsNote() then - for note in each(entry) do - local midi = note:CalcMIDIKey() - random_num = math.random(low_interval_range, interval_range) - note:SetMIDIKey(midi +random_num) - end - end - end - finenv.EndUndoBlock(true) -end - -if finenv.IsRGPLua then - local Lua_version_text = dialog:CreateStatic(0, 15) - str.LuaString = "(RGP Lua)" - Lua_version_text:SetText(str) - - dialog:RegisterHandleControlEvent ( - buttonApply, - function(control) - local interval_range = editInterval_range:GetInteger() - randomize_pitches(interval_range) - local ui = finenv.UI() - ui:RedrawDocument() - end - ) - - finenv.RegisterModelessDialog(dialog) - dialog:ShowModeless() - -else - local Lua_version_text = dialog:CreateStatic(0, 15) - str.LuaString = "(JW Lua)" - Lua_version_text:SetText(str) - - local function command_handler(thecontrol) - - if thecontrol:GetControlID(1) == buttonApply:GetControlID() then - local interval_range = editInterval_range:GetInteger() - randomize_pitches(interval_range) - local ui = finenv.UI() - ui:RedrawDocument() - end - end - - dialog:RegisterHandleCommand(command_handler) - - if (dialog:ExecuteModal(nil) == 1) then - -- Ok button was pressed - end -end From 1f8c7eb7482ac74172ef8f98c3d2f326513acc56 Mon Sep 17 00:00:00 2001 From: MichaelMcClennan <89558058+MichaelMcClennan@users.noreply.github.com> Date: Wed, 12 Jan 2022 09:45:46 -0500 Subject: [PATCH 5/5] Add replicate_music.lua copies the selected music, and pastes it directly to the right --- src/replicate_music.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/replicate_music.lua diff --git a/src/replicate_music.lua b/src/replicate_music.lua new file mode 100644 index 00000000..f8d9e005 --- /dev/null +++ b/src/replicate_music.lua @@ -0,0 +1,30 @@ +function plugindef() + finaleplugin.Author = "Michael McClennan" + finaleplugin.Version = 1.0 + finaleplugin.Copyright = "2022/01/03" + finaleplugin.HandlesUndo = true +return "Replicate Music", "Replicate Music", "Inspired by the 'r' key in Sibelius, this script copies the selected music, and pastes it directly to the right" +end + +--[[ +Inspired by the 'r' key in Sibelius, this script copies the selected music, and pastes it directly to the right. +Works with a single or multiple measures. +When activated with a shortcut or hotkey, ultra fast replication is possible. +--]] + + +local function replicate_music() + local region = finenv.Region() + local start_measure = finenv.Region().StartMeasure + local end_measure = finenv.Region().EndMeasure + local sum_measures = end_measure - start_measure + local start_paste_region = end_measure + 1 + + region:CopyMusic() + finenv.Region():SetStartMeasure(start_paste_region) + finenv.Region():SetEndMeasure(start_paste_region + sum_measures) + region:PasteMusic() + region:ReleaseMusic() +end + +replicate_music() \ No newline at end of file