NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Rick G. on 2008-07-08 08:17 am

Title: Remove unneeded tags and opts: Tidy.js
Post by: Rick G. on 2008-07-08 08:17 am
This tool removes tags and options that do not effect the output.

During the course of editing, it is easy to set options that are superfluous, such as setting a slur direction on a note that is not slurred. Tidy.js will remove most of these.

Specifically, it will remove:

Using this tool before posting a clip to this forum will remove most of the extraneous items.
Using the tool on each staff before the final save should make the file easier to edit months later.
Quote from: Tidy.js
/*
   NWC2 User Tool, Ver 1.00 - Rick G.
   Purpose: remove unneeded tags and opts
   &Command: WScript Scripts\Tidy.js
*/
var io = WScript.StdIn.ReadAll().split("\r\n");
for (var j = 1; io[j].search(/\w+/) + 1; j++){
   switch (RegExp.lastMatch){
      case "Flow": case "Ending":
         Zap(/^!/, /\|Visibility:TopStaff$/); break;
      case "Instrument": case "MPC":
         Zap(/^!/, /\|Visibility:Never$/); break;
      case "Note": case "Chord": case "RestChord":
         Zap(/Staccato|Tenuto|Accent/, /ArticulationsOnStem,?/);
         Zap(/\^/, /Tie=\w+,?/);
      case "Rest":
         Zap(/Slur[,|?]/, /Slur=\w+,?/);
      default:
         Zap(/^!/, /\|Visibility:Always$/);
   }
}
WScript.StdOut.Write(io.join("\r\n"));
function Zap(re, re1) {
   if (!(re.test(io[j]))) io[j] = io[j].replace(re1, "");
} // if re is not in io[j], remove re1 from io[j]
Tidy.js doesn't remove everything that is superfluous. Some stem and tie directions are not removed, but this would require a voice analysis that is beyond the scope of this simple program.