NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: NoteWorthy Online on 2010-03-15 04:05 pm

Title: Pitch Mod (nwsw) User Tool
Post by: NoteWorthy Online on 2010-03-15 04:05 pm
Inspired by Andrew Purdam's Global Mod script, this script allows you to conditionally modify note pitch/position information. After installing this script Version 2.1 or later of the NWC2 User Tool Starter Kit, the following command will be available from the User Tool command (Alt+F8):

Pitch Mod (nwsw)

Upon invoking this tool, you will be prompted for a pitch mod expression. You can use the pitch mod expression to match against note name, accidental, octave, or duration, and then set the note's accidental, position, and/or notehead style or color. For a detailed explanation of the pitch mod expression, please see below in the first replies of this topic.
Title: Pitch Mod: Matching Note Pitch with a Regular Expression
Post by: NoteWorthy Online on 2010-03-16 11:05 am
Each pitch mod expression starts with a regular expression (regex) that will be matched against each single notehead in the clip. For example, "Cb" will  match any note that is spelled as a C flat, either directly by its accidental, or indirectly based on the running key signature. You can match against multiple note names by using the regex grouping feature, so "(C|F)b" will match both a C flat or F flat.

You can also match against each notehead's raw clip text. Start your regex with "t:" in order to match against the notehead's clip text, then enter an expression that you want to match against the text. For example, "t:[^\t!]+![1-4]" will match against any notehead that uses one of the first four highlight colors. The expressions starts with the "t:" to indicate that we want to match against the clip text, followed by "[^\t!]+" which is used to skip note position, accidental, and any other text that precedes the color option, and then the "![1-4]" part is used to match against highlight color indexes one through four.

You can also match against each note's duration by starting your match expression with a "d:" prefix. For example, "d:.*(16th|32nd|64th)" will match against any notes that are 16th or smaller duration. As another example, "d:.*Triplet" will match any triplet notes.

If you are not familiar with regular expressions, here are several links that will help to get you started:

Title: Pitch Mod: Changing the Matching Notes
Post by: NoteWorthy Online on 2010-03-16 11:09 am
After you have created your regex to match certain notes, you can add actions by first placing a forward slash at the end of your regex. You then add one or more actions to be done to the matching note, each separated by a comma. No extra whitespace is permitted in the action list.

The following note properties can be changed by an action statement:

colSets the numeric highlight color for the notehead
posUsed to change the note position (beware of chord conflicts)
accSets the accidental to one of bb,b,n,#,x
head  Sets the notehead to one of o,x,X,z
All of the properties support an = operator, which is used to assign a new value to the property. The numeric properties, col and pos, also support += and -= operators for incrementing or decrementing their current value.
Title: Pitch Mod: Combining the Regex with Property Assignments
Post by: NoteWorthy Online on 2010-03-16 11:10 am
The complete pitch mod expression combines the matching regex with the property assignment action(s), separated by a slash (/). Additional pitch mod regex/action list pairs can be added by separating them with a space. If you want to see a report of matching and non-matching notes for your expression, you can add "-r" to the end of your expression. The -r report will be sent to STDERR, which will automatically be displayed by NWC2. The -r option is a good way to get started with pitch mod expressions, as it shows you the actual note pitch text that you are matching against when you create an expression.

Here are some example pitch mod expressions with explanations of what they do:

Title: Re: Pitch Mod (nwsw) User Tool
Post by: NoteWorthy Online on 2010-05-08 02:54 pm
This tool is now included in Version 2.11 of the NWC2 User Tool Starter Kit.