NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Rick G. on 2013-03-04 05:40 am

Title: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: Rick G. on 2013-03-04 05:40 am
Quite easy. Figuring out how easy took several hours.
Code: (php) [Select · Download]
<?php
# rg_ForceAccidentals.php ver 1.0
# Ref: http://my.noteworthysoftware.com/?topic=8445.0
require_once ('lib/nwc2clips.inc');
$clip = new NWC2Clip(); // Input Type: Clip Text
echo $clip->GetClipHeader(), PHP_EOL; // Returns Clip Text
$PlayContext = new NWC2PlayContext();
foreach ($clip->Items as $item) {
  $o = new NWC2ClipItemWithPitchPos($item, true);
  foreach (array('Pos', 'Pos2') as $pos_tag)
    foreach ($o->PitchPos[$pos_tag] as $npp)
      $npp->Accidental = $PlayContext->GetNotePitchAccidental($npp);
  $PlayContext->UpdateContext($o);
  $o->ReconstructPosOpts();
  echo $o->ReconstructClipText(), PHP_EOL;
}
echo NWC2_ENDCLIP, PHP_EOL;
?>
Comments and criticisms welcome.
Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: Richard Woodroffe on 2013-03-04 08:19 am
Thanks Rick, that should be useful and will save copying part of a staff to a new staff in order to force accidentals for a section.

One issue I have found is that if you have a tied accidental across a bar line the receiving note does not always get the correct accidental and because of that, the tie is now "searching" for a home. This is not for every case but I haven't been able to pin down the "when" and "why"

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.5,Single)
|Clef|Type:Treble
|TimeSig|Signature:4/4
|Note|Dur:4th|Pos:-1
|Note|Dur:4th|Pos:-2
|Note|Dur:4th|Pos:0
|Note|Dur:4th|Pos:b-3^
|Bar
|Note|Dur:4th|Pos:-3
|Note|Dur:4th|Pos:-3
|Note|Dur:4th|Pos:-2
|Note|Dur:4th|Pos:-1
!NoteWorthyComposerClip-End


Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: Rick G. on 2013-03-04 03:52 pm
Looks like a problem with NoteWorthy Composer 2 User Tools (http://ntworthy.com/nwc2/usertools/)' library code.
Problem fixed in 2.51 update.
Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: Rick G. on 2013-03-04 08:02 pm
I'm going to wait for the update of the Starter Kit (http://ntworthy.com/nwc2/usertools/). It looks like NoteWorthy is aware of the problem. In the example below, 'nwsw_NoteNames.php' responds rather badly, but the NoteWorthy Composer 2 Note Names (http://ntworthy.com/webtool/nwc2-notenames.php) WebTool is correct. Assuming that there is some PHP code that is processing the web form, a fix seems to be in the works. Thanks again Richard, for the discovery.

example removed. Problem solved with 2.51 update.
Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: NoteWorthy Online on 2013-03-30 09:07 pm
The web tool actually uses an older API which does not even attempt to emulate what NWC 2.5 does with ties. The older API actually works better In this case.

We will be releasing a new PHP Starter Kit in NWC 2.51 which will include a fix for this issue.
Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: NoteWorthy Online on 2013-03-30 09:36 pm
The target fixes for NWC 2.51 have been pushed to github:

Commit on github (https://github.com/nwsw/nwc2utsk/commit/e730bc9902d8c5ec163e841df1fb0b043b7d03f4)
Title: Re: rg_ForceAccidentals.php - Force Accidentals on a selection
Post by: Rick G. on 2013-03-31 09:32 am
The target fixes for NWC 2.51 have been pushed to github
This seems to solve the problem.

The problem in obj_NWC2PlayContext.inc (https://forum.noteworthycomposer.com/?topic=8440.msg59408) remains. Fixed in latest github updates.