NoteWorthy Composer Forum

Forums => General Discussion => Topic started by: Warren Porter on 2011-02-25 04:25 am

Title: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-02-25 04:25 am
I have a pair of new webpages: 

P.S. Forgot attachment.  The B will replace the G as the two notes swap dynamics.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Rick G. on 2011-02-25 12:01 pm
Nice code. Easy to follow.
A few problems with the tempo page:

I have written a similar User Tool. I never published it because its use requires too many caveats. If the resulting tempo falls outside the range of 4 - 32767, it is not reversible. If there is no tempo at the beginning of the input, it is difficult to know what the starting tempo is.

My regular expression for extracting the 'Controller Value(s):' from MPC's is
Quote
"(\|Pt\d:\d+,)(\d+)"
this returns an array which I can simply iterate and not have to fool with indexes. I'm in a different language, so YMMV

Edit:
The tempo page doesn't respond well to:
Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.0,Single)
|Text|Text:"\|MPC\|Pt1:0,64"|Font:StaffBold|Pos:8
|MPC|Controller:pan|Style:Absolute|TimeRes:Quarter|SweepRes:1|Pt1:0,64|Pos:8
!NoteWorthyComposerClip-End
I have found though painful experience that I need to check object types and take extra care when dealing with objects that contain quoted text.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-02-25 04:07 pm
I've changed a number of things in the tempo page, I'm now looking for /\|Tempo.*\|Tempo:(\d+)/ so it will accept notes other than the default.  New tempos are calculated first and checked against your range.  I'm not quite sure what happened on my original continue; statement, but I'm using an if statement now to run the change() function when I find an MPC..tempo statement.

I had to ask for help on the problem of changing the Pt's in a loop in a javascript forum.  I'm a long way from being able to code something like that from scratch but I think I found out how it works--my attempt to adapt that to the dynamics page without splitting the textarea into lines first resulted in an endless loop.

Also, I added code to find the earliest occurrence of MPC..tempo or Tempo statement vs Note or Rest or RestChord.  Notes before a tempo indication will cause an alert.

The submit functions can be triggered by either clicking the appropriate button OR changing the last time or either of the factors.  I'll look into changing that but pressing the TAB key after entering a factor or time should work.

Many thanks for checking it out and your suggestions.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-02-27 11:36 pm
I've consolidated all my NWC related webpages under one umbrella: http://www.wjporter.com/nwc/ (http://www.wjporter.com/nwc/).
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Flurmy on 2011-02-28 07:48 am
Quote
Inserts stacissimo symbol above/below selected notes.

I suppose you mean "staccatissimo".
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-02-28 12:34 pm
I suppose you mean "staccatissimo".
Thanks, fixed.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-03-09 05:38 pm
I just added a do it yourself (http://www.wjporter.com/nwc/diy.txt) webpage to my suite based on an earlier thread (https://forum.noteworthycomposer.com/?topic=7664.msg53238#msg53238).  Since the user would modify it to some other task I created it as a text file the user could change and save as .htm.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: fathafluff on 2011-03-09 06:06 pm
The "do it yourself" link seems to go to a page with a heading of "Replace whole rests with four quarter rests", and a large text box (empty). Below that is the text "Copy the above to your clipboard (it's pre-selected) and paste it into a song you have already open in NoteWorthy Composer." but, as I said, "the above" seems to be empty.

Edit: I think I am catching on. To use, you must extract the source from the page, modify it to do what you need, and save it as .html. To use your new function, open the new .html file in your browser, cut data from an nwc song, paste it into the box, and click "Read". Then the previously pasted text will be modified and selected. Copy that modified data and paste back to the nwc song. Is that about it?  
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-03-09 09:42 pm
I think I am catching on. To use, you must extract the source from the page, modify it to do what you need, and save it as .html. To use your new function, open the new .html file in your browser, cut data from an nwc song, paste it into the box, and click "Read". Then the previously pasted text will be modified and selected. Copy that modified data and paste back to the nwc song. Is that about it?  

Ding! Ding! Ding! Ding! Ding! We have a winner! Actually, I would start by creating a new NWC file with copies of the object I want to change and what I want to change it to on the staff, then copy that staff to the page for reference (between "body" and "form").  Plug those into the "from" and "to" literals and be sure the length of the "from" literal is correct in the slice.  From here your instructions are spot on.

This assumes you want to replace the entire line with something else and it works great for simple objects with no Pos: or any options which may need overriding or left intact on a different object.  To keep an attribute intact while changing things around it, study exec, match, replace, and regular expressions.  While working on other pages in the suite I referred to the "Pattern Matching with Regular Expressions" chapter so much I highlighted the edge of the pages so I could find it.

I retired from a career as a programmer or systems analyst and still enjoy these types of challenges as a hobby.  Hope you like them as well.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-05-03 05:18 pm
Just added a new page to the set: nummeas.htm (http://www.wjporter.com/nwc/nummeas.htm).  First create a "model" text entry for your first measure number, before or after the bar, with the starting measure number and position all ready to go.  Starting from your measure number, Cut to the end of the staff and paste into the webpage.  Click Read and copy back to the clipboard to paste it back.  It ignores hidden bar lines and those excluded from measure count.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-05-09 11:36 pm
Nummeas now counts hidden barlines w/o creating a measure number and ignores bar lines with "exclude from bar count" attribute.  Corrected the "dotted" checkbox on the guitar page.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: David Palmquist on 2011-05-11 07:36 am
Nummeas worked very nicely, once I read your instructions properly, and it took, oh, maybe half a second to number 315 bars.  Nice work, Warren, and thank you for creating this tool (macro?). 
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-05-11 11:15 am
Nummeas worked very nicely, once I read your instructions properly, and it took, oh, maybe half a second to number 315 bars.  Nice work, Warren, and thank you for creating this tool (macro?). 
You're welcome.  I'll try to transcribe other semware macros into web pages as time permits.
Title: Re: Nwctxt webpages to work on dynamics and tempo
Post by: Warren Porter on 2011-08-13 12:31 pm
--Removed by author--