Since I'm absolutely new to php, using prw_CopyGraceAccidentals.php as starting point I wrote this tool as a programming exercise.
It's a slightly more general version than the original one since it tests for hidden notes instead of grace notes.
Of course it's not the case (yet) to use this tool if you purposedly put a hidden muted grace note to hide the accidental!
This is matter for php exercise #2... :-)
Nor should it be. I agree with you that hidden accidentals should not cause the removal of needed accidentals on visible objects.
I have been working on a tool to audit accidentals according to your guidance. A test song is attached. Running the tool on the a copy of the top staff turns it into the bottom staff. It might make a good testbed for your tool.
Here is a problem:
Your tool adds a sharp to the last note.
Thanks Rick.
After doing my homework I'll tell you how my php course is going! ;-)
I'm not complaining here, but just for the record, I think your script is identical to mine, except for adding my "clef" enhancement I think you found that I figured out later in prw_FindAmbiguous.php, and except for the 1 line that checks for visibility rather than grace! :-) [Changing formatting doesn't count, as the compiler ignores formatting anyway :-]
So your 1 line has a problem. You assume that all non-"default" values are hidden, and it's true that "never" values are, but "always" values are not, and "top staff only" values may or may not be! The best you can probably do is check for equal to "Never", rather than not equal to "Default", since you currently have no way of knowing whether your user tool was invoked on the top staff or not. (Anyone: can a "default" value ever default to hidden?)
By default, |Instrument and |MPC are |Visibility:Never
Some items are TopStaffOnly by default.
Oh, yes. Why to reinvent the wheel?
That's life! :-(
Since I have no way of knowing whether the tool was invoked on the top staff or not I decided to assume by default it's
not (in my case it's statistically more probable).
But I forgot the "always"!Forgive the beginner!
Perhaps Context should look something like this:
That's very interesting, Rick. It looks like if you set an MPC (for example) to the "Default" visibility choice, it will stay logically "Default" in the nwxtxt clip (although the Visibility will be pruned physically, since "Default" is the default for this field :-), but it will act as if the visibility is "Never". That all makes sense for MPC/Instrument. So there is an object type that acts as if the visibility is "Top Staff Only" when the visibility is set to "Default"?!
2 of them:
- |Flow|Style:Fine
- |Ending|Endings:1
I pretty much summarize it <here> (https://forum.noteworthycomposer.com/?topic=6488.0).
Homework done.
I put in also the trick to keep the accidental hidden.
To get the most from the tool it must be run after a standard "audit accidentals".
I could have tried to let it do the full job, but I think it's too much work.
I'd like instead to see this behavior included in the built-in "audit accidentals".