{ Initialize [(){ AddToPluginsMenu('Delete Chord Notes','Run'); // Initialise control variables for dialogs. // This is is case the plug-in has been edited and the // data saved with whatever values it happened to have // at the time. Include = '1'; Exclude = '0'; High1 = '0'; High2 = '0'; High3 = '0'; High4 = '0'; High5 = '0'; Low1 = '0'; Low2 = '0'; Low3 = '0'; Low4 = '0'; Low5 = '0'; MinNumNotes = '0'; }] Run [() { if (Sibelius.ScoreCount > 0) { // Get score and selection score = Sibelius.ActiveScore; selection = score.Selection; } else { Sibelius.MessageBox('Select a score'); return False; } // Display dialog box until user enters valid number continue = (Sibelius.ShowDialog(SelectNotes,Self)); while ( ((IsNumber(MinNumNotes) = False) or (MinNumNotes < 0)) and (continue = True) ) { if ((IsNumber(MinNumNotes) = False) or (MinNumNotes < 0)) { Sibelius.MessageBox('Minimum number of notes in chord must be 0 or greater. (Make sure you didnt type any spaces.)'); } continue = (Sibelius.ShowDialog(SelectNotes,Self)); } if (continue = False) { return False; } // Count noterests in selection for progress box nrCount = 0; for each NoteRest nr in selection { nrCount = nrCount + 1; } if (nrCount = 0) { Sibelius.MessageBox('There are no notes selected!'); return False; } Sibelius.CreateProgressDialog('Processing chords...',0,nrCount); nrIndex = 0; score.Redraw = False; // Process each noterest in selection for each NoteRest nr in selection { nrIndex = nrIndex + 1; if (Sibelius.UpdateProgressDialog(nrIndex,'') = 0) { Sibelius.DestroyProgressDialog(); score.Redraw = True; return False; } // To delete the note, we need several iterations through // each note in the noterest. The reason is that, if a note // is deleted, the iteration skips the next note (?!). // First, just store an array of the note names to be // deleted if (not (nr.NoteCount < MinNumNotes)) { Hindex = nr.NoteCount + 1; Lindex = 0; NumToDelete = 0; for each note in nr { Hindex = Hindex - 1; Lindex = Lindex + 1; Hvarname = 'High' & Hindex; Lvarname = 'Low' & Lindex; if ((Include = True and ((@Hvarname = True) or (@Lvarname = True))) or (Exclude = True and not ((@Hvarname = True) or (@Lvarname = True)))) { NumToDelete = NumToDelete + 1; varname = 'NoteName' & NumToDelete; @varname = note.Name; } } // Now repeatedly iterate until all required notes deleted while (NumToDelete > 0) { varname = 'NoteName' & NumToDelete; for each note in nr { if (note.Name = @varname) { nr.RemoveNote(note); NumToDelete = NumToDelete - 1; } } } } } Sibelius.DestroyProgressDialog(); score.Redraw = True; return True; }] IsNumber [(var) { // Check whether a variable is numeric or not if ( var > 0 ) { // greater than zero: must be numeric return True; } else { // zero or string? if ( var = '0' ) { return True; } else { return False; } } }] SelectNotes [Dialog] { Title [Delete Chord Notes] X [59] Y [114] Width [194] Height [207] Controls { Text { Title X [75] Y [1] Width [67] Height [11] Value [_Version] Method } Text { Title X [57] Y [9] Width [108] Height [11] Value [_Author] Method } RadioButton { Title [Delete these notes] X [9] Y [25] Width [75] Height [15] Value [Include] Method } RadioButton { Title [Delete all but these notes] X [88] Y [25] Width [99] Height [15] Value [Exclude] Method } CheckBox { Title [Highest] X [30] Y [40] Width [67] Height [16] Value [High1] Method } CheckBox { Title [2nd highest] X [30] Y [52] Width [66] Height [16] Value [High2] Method } CheckBox { Title [3rd highest] X [30] Y [64] Width [66] Height [16] Value [High3] Method } CheckBox { Title [4th highest] X [30] Y [76] Width [66] Height [16] Value [High4] Method } CheckBox { Title [5th highest] X [30] Y [88] Width [66] Height [16] Value [High5] Method } CheckBox { Title [5th lowest] X [110] Y [40] Width [66] Height [16] Value [Low5] Method } CheckBox { Title [4th lowest] X [110] Y [52] Width [66] Height [16] Value [Low4] Method } CheckBox { Title [3rd lowest] X [110] Y [64] Width [66] Height [16] Value [Low3] Method } CheckBox { Title [2nd lowest] X [110] Y [76] Width [66] Height [16] Value [Low2] Method } CheckBox { Title [Lowest] X [110] Y [88] Width [66] Height [16] Value [Low1] Method } Edit { Title X [120] Y [109] Width [18] Height [11] Value [MinNumNotes] Method } Button { Title [Continue] X [37] Y [155] Width [47] Height [16] Value Method EndDialog [1] } Button { Title [Cancel] X [104] Y [155] Width [47] Height [16] Value Method EndDialog [0] } Text { Title [Ignore chords with less than] X [29] Y [110] Width [93] Height [10] Value Method } Text { Title [notes] X [140] Y [110] Width [25] Height [10] Value Method } Button { Title [Help] X [71] Y [130] Width [47] Height [16] Value Method [Help] } } } _Author [Author: Danny Manners] _Version [Version: 1.0] High1 [0] High2 [0] High3 [0] High4 [0] High5 [0] Low1 [0] Low2 [0] Low3 [0] Low4 [0] Low5 [0] Include [1] Exclude [0] MinNumNotes [0] ANarr1 [Toggling between and is an easy way to switch between complementary sets of] ANarr3 [notes (eg upper and lower in 2-part chords, 1&3 and 2&4 in 4-part] ANarr4 [chords, etc.).] ANarr5 ANarr6 [ allows you to delete the] ANarr7 [required notes from chords but retain unison passages, etc.] ANarr8 ANarr9 [Unfortunately, this plug-in cannot recognise different voices, ] ANarr10 [and is not intended for polyphonic passages. You will have to] ANarr11 [use the Sibelius Filter function for that.] Help [() { // Display help // Text for dialog is set up here because there's a size limit in the // dialog editor ANarr1 = 'Toggling between and