Skip to main content
Topic: Problem with obj_NWC2PlayContext.inc (5,258 byte version) (Read 11795 times) previous topic - next topic

Problem with obj_NWC2PlayContext.inc (5,258 byte version)

around line 94:
Code: (php) [Select · Download]
<?php
if (isset($o->Opts["Stem"]) && ($o->Opts["Stem"] == "Up")) $notes = array_merge($notes2,$notes);
else $notes = array_merge($notes,$notes2);
?>
Currently: isset($o->Opts["Stem"]) will be false for any input from NWC.

Perhaps the test should be:
  if (isset($o->Opts['Opts']) and $o->Opts['Opts']['Stem'] == 'Up') ...

The target fixes for NWC 2.51 have been pushed to github:
Commit on github
Which moved the code to around line 104 where it remains unchanged. Perhaps the merge order no longer matters.
Registered user since 1996

Re: Problem with obj_NWC2PlayContext.inc (5,258 byte version)

Reply #1
This appears to be a workable replacement:
Code: (php) [Select · Download]
<?php
require_once('lib/nwc2clips.inc');
$clip = new NWC2Clip('php://stdin');
foreach ($clip->Items as $item) {
  $o = new NWC2ClipItem($item);
//
  $bits = isset($o->Opts['Pos']) | isset($o->Opts['Pos2']) << 1;
  if ($bits == 3) $bits |= ($o->Opts['Opts']['Stem'] == "Up") << 2;
  switch ($bits) {
    case 1: $pos = $o->Opts['Pos']; break;
    case 2: $pos = $o->Opts['Pos2']; break;
    case 3: $pos = array_merge($o->Opts['Pos'], $o->Opts['Pos2']); break;
    case 7: $pos = array_merge($o->Opts['Pos2'], $o->Opts['Pos']); break;
    default: $pos = '';
  }
//
  echo substr($o->ReconstructClipText(), 0, 68), PHP_EOL, '  ';
  if (is_array($pos)) echo join(',', $pos), PHP_EOL; else var_dump($pos);
}
exit(NWC2RC_REPORT);
?>
Try running it on this gauntlet:
Code: (new) [Select · Download]
!NoteWorthyComposerClip(2.5,Single)
|Clef|Type:Treble
|Tempo|Tempo:120|Pos:10
|Rest|Dur:Half
|Note|Dur:Half|Pos:1
|Chord|Dur:Half|Pos:-2,-1,0,1,2
|RestChord|Dur:Half|Opts:Stem=Down|Dur2:Half|Pos2:-2,-1,0,1,2
|RestChord|Dur:Half|Opts:Stem=Up|Dur2:Half|Pos2:-2,-1,0,1,2
|Chord|Dur:Half|Pos:1,2,3,4,5|Opts:Stem=Up|Dur2:Whole|Pos2:-4,-3,-2,-1,0
|Chord|Dur:Half|Pos:-4,-3,-2,-1,0|Opts:Stem=Down|Dur2:Whole|Pos2:1,2,3,4,5
|TimeSig|Signature:Common
!NoteWorthyComposerClip-End
The code does not attempt to sort out 'Fake' items. If that were needed, I would use a function so that multiple returns could be used.
Registered user since 1996

Re: Problem with obj_NWC2PlayContext.inc (5,258 byte version)

Reply #2
Fixed on github:

Commit on github

The following clip seems like a good test case:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.5,Single)
|Clef|Type:Treble
|Chord|Dur:4th|Pos:-1,n1|Opts:Stem=Up|Dur2:Half|Pos2:b-6
|Note|Dur:4th|Pos:1|Opts:Stem=Up
|Chord|Dur:4th|Pos:-1,b1|Opts:Stem=Up|Dur2:Half|Pos2:n-6
|Note|Dur:4th|Pos:1|Opts:Stem=Up
!NoteWorthyComposerClip-End

Before the fix, the note names tool generates this:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.5,Single)
|Clef|Type:Treble
|Text|Text:"AC,Cb"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Chord|Dur:4th|Pos:-1,n1|Opts:Stem=Up|Dur2:Half|Pos2:b-6
|Text|Text:"Cb"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Note|Dur:4th|Pos:1|Opts:Stem=Up
|Text|Text:"ACb,C"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Chord|Dur:4th|Pos:-1,b1|Opts:Stem=Up|Dur2:Half|Pos2:n-6
|Text|Text:"C"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Note|Dur:4th|Pos:1|Opts:Stem=Up
!NoteWorthyComposerClip-End

After the fix, the note names tool generates this, which accurately depicts how NWC would perform it:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.51,Single)
|Clef|Type:Treble
|Text|Text:"AC,Cb"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Chord|Dur:4th|Pos:-1,n1|Opts:Stem=Up|Dur2:Half|Pos2:b-6
|Text|Text:"C"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Note|Dur:4th|Pos:1|Opts:Stem=Up
|Text|Text:"ACb,C"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Chord|Dur:4th|Pos:-1,b1|Opts:Stem=Up|Dur2:Half|Pos2:n-6
|Text|Text:"Cb"|Font:User1|Pos:10|Wide:Y|Justify:Center|Placement:AtNextNote
|Note|Dur:4th|Pos:1|Opts:Stem=Up
!NoteWorthyComposerClip-End

 

Re: Problem with obj_NWC2PlayContext.inc (5,258 byte version)

Reply #3
Thanks. Due to limited github support for IE8, extracting the update from the zip archive seems to work best. This yields files that are LF terminated. Not a problem unless viewed with NotePad, but strange for code that is only useful in Windows.
Edit: I'm locking this topic since the issue is resolved as of the March 31, 2013 commit on github.
I would anticipate an update to NoteWorthy Composer 2 User Tools to Version 2.5+ pending NWC's 2.5+ release.
Registered user since 1996

Re: Problem with obj_NWC2PlayContext.inc (5,258 byte version)

Reply #4
The jargon is over my head. 

What's Lua?

I almost asked the same thing about Github, but I clicked the link.  I see it says Github doesn't support older versions of IE.  While Rick touched on this, he didn't mention this will likely be a problem for those of us with older older operating systems.  When last I checked, I could not instal Internet Explorer 9 because it isn't compatible with WinXP.  Please don't send us to websites if there's a strong possibility we won't be able to go there.

Re: Problem with obj_NWC2PlayContext.inc (5,258 byte version)

Reply #5
David, Lua is the official built-in scripting language for NWC going forward, starting in 2.51.

The discussion here is about specific bugs in the PHP based NWC User Tool Starter Kit. The next full release will have all of this fixed once it is installed. The github links are the view into the kitchen, showing how the update is made. It will not be needed at general release.