<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.5pt;
font-family:Consolas;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:Consolas;}
span.EmailStyle19
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Here's my first attempt. My work is with choral music so this plugin applies to choral scores. It scans the selected region to find the highest, lowest, and mean notes in the selected staves. It then displays them in the first measure of the staff. It assumes that there is at least one note in the first measure already. All of my templates are set up like that. The plugin works as it is, but I think there is a more efficient way to get the notes placed in the first measure. Suggestions welcomed.<o:p></o:p></p><p class=MsoNormal>Pat<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>function plugindef()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- This function and the 'finaleplugin' namespace<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- are both reserved for the plug-in definition.<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.RequireScore = true<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.RequireSelection = true<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.MinFinaleVersion = "2012"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.MinJWLuaVersion = "0.45"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.Author = "PDR Editions"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.Copyright = "2016"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.Version = "1.0"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.Date = "5/11/2016"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.AuthorURL = "<a href="http://www.pdreditions.com">www.pdreditions.com</a>"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.AuthorEmail = "<a href="mailto:Mr.Pat@pdreditions.com">Mr.Pat@pdreditions.com</a>"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> finaleplugin.CategoryTags = "Chord, Measure, MIDI, Note, Pitch, Region, Staff"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> return "Find Ranges", "Find Range", "Finds highest, lowest, and median range"<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>-- Use sounding pitch<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local written_pitch = false <o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>-- Table MIDI notes for each staff<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local lowestnotes = {}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local highestnotes = {}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local midnotes = {}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local notecount = {}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local staff = {}<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local region = finenv.Region()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>for slot = region.StartSlot, region.EndSlot do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> staff[region:CalcStaffNumber(slot)] = slot<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>for entry in eachentry(region) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if entry:IsNote() then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- Get the staff number where the entry is placed<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> local staffnumber = entry.Staff<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- skip the first measure<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if entry.Measure >1 then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- Parse through all notes in the note entry (=chord)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> for note in each(entry) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- Use the enharmonic MIDI note to check the pitch<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> local midikeynumber = note:CalcMIDIKey()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- See if the note is lowest on the staff<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if not lowestnotes[staffnumber] or lowestnotes[staffnumber] > midikeynumber then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> lowestnotes[staffnumber] = midikeynumber<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- See if the note is the highest on the staff<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if not highestnotes[staffnumber] or highestnotes[staffnumber] < midikeynumber then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> highestnotes[staffnumber] = midikeynumber<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> -- Add the note to midnotes<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if not midnotes[staffnumber] then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> midnotes[staffnumber] = midikeynumber<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> midnotes[staffnumber] = midnotes[staffnumber] + midikeynumber<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> if not notecount[staffnumber] then<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> notecount[staffnumber] = 1<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> else<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> notecount[staffnumber] = notecount[staffnumber] + 1<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>-- Add new notes to each staff as needed. Assume at least one existing note<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local staffnum<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>local slotnum<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>for staffnum, slotnum in pairs(staff) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell = finale.FCNoteEntryCell(region.StartMeasure, staffnum)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell:Load()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> for noteentry in each(noteentrycell) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> for i = noteentry.Count, 2, 1 do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentry:AddNewNote()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell:Save()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>end<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>-- Set the values for each note<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>for staffnum, slotnum in pairs(staff) do<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell = finale.FCNoteEntryCell(region.StartMeasure, staffnum)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell:Load()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> local noteentry = noteentrycell:GetItemAt(0)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> local note = noteentry:GetItemAt(0)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note:SetMIDIKey(math.floor(midnotes[staffnum]/notecount[staffnum] + .5))<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note.Playback = false<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note = noteentry:GetItemAt(1)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note:SetMIDIKey(highestnotes[staffnum])<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note.Playback = false<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note = noteentry:GetItemAt(2)<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note:SetMIDIKey(lowestnotes[staffnum])<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> note.Playback = false<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentry.CheckAccidentals = true<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'> noteentrycell:Save()<o:p></o:p></span></p><p class=MsoPlainText><span style='font-size:8.0pt;font-family:"Courier New"'>end<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:8.0pt'><o:p> </o:p></span></p></div></body></html>