NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: Peter Edwards on 2018-01-15 04:27 pm

Title: Sforzando Implementation
Post by: Peter Edwards on 2018-01-15 04:27 pm
Code: [Select · Download]
Option Explicit
Dim StdErr, StdIn, StdOut, LineIn, Look, Matches, Match, Head

'Name:    Insert Sforzando
'Command: wscript scripts\Sforzando.vbs

Set StdErr = WScript.StdErr
Set StdIn = WScript.StdIn
Set StdOut = WScript.StdOut
Set Look = New RegExp
Look.Global = True
Look.IgnoreCase = True

While Not StdIn.AtEndOfStream
  LineIn = StdIn.ReadLine
  Look.Pattern = "^\|Note|^\|Chord|^\|RestChord"
  If Look.Test(LineIn) Then
    StdOut.WriteLine "|Marker|Target:Articulation|Visibility:Never"
    StdOut.WriteLine "|DynamicVariance|Style:Sforzando|Justify:Center|Placement:AtNextNote"
    If Instr(LineIn, "Accent") = 0 Then
      Look.Pattern = "(Dur[^\|]+)"
      Set Matches = Look.Execute(LineIn)
      Set Match = Matches.Item(Matches.Count - 1) 'the last one
      Head = Match.FirstIndex + Match.Length
      LineIn = Left(LineIn, Head) & ",Accent" & Right(LineIn, Len(LineIn) - Head)
    End If
  End If
  StdOut.WriteLine LineIn
Wend

This inserts a sforzando mark and accents the note and hides the accent with an invisible marker.

There's one problem though. If you manually insert a dynamic variance it inherits visibility and position from the previous one. Inserting one with a user tool doesn't.
Title: Re: Sforzando Implementation
Post by: jfb-from-germany on 2018-01-22 10:10 pm
Hi everybody,

I'm afraid I have a stupid question to ask: can you tell me where I can find a description HOW to install user tools like the the one above?
I have been looking now for quite a time, and I'm afraid I'm not smart enough to figure out how it works...

I suppose I'll have to copy the programming code above - but where should I paste it? I would the glad to get some help... :-)

Title: Re: Sforzando Implementation
Post by: Lawrie Pardy on 2018-01-23 06:10 am
See:
https://nwc-scriptorium.org/nwc2scripts.html#Installation

https://nwc-scriptorium.org/nwc2scripts/generaldiscussion.pdf

https://nwc-scriptorium.org/nwc2scripts/invocationinstructions.pdf
Title: Re: Sforzando Implementation
Post by: jfb-from-germany on 2018-01-23 06:50 am
Thanks for the links! :-)
Title: Re: Sforzando Implementation
Post by: jfb-from-germany on 2018-01-23 10:54 pm
I'm sorry to have to ask again - but I still don't get it.

I downloaded the User Tool Starter Kit, and I understand now how to install new user tools based on a php-file. So far, thanks for the links! Unfortunately I did not learn from them what to do with the code presented above.

I tried to paste it into the command line when creating a new user tool, but that didn't work (I wasn't able to paste the code, all that appeared was: "Option explecit")

Can someone tll me what I do wrong? Thanks in advance...
Title: Re: Sforzando Implementation
Post by: Rick G. on 2018-01-23 11:07 pm
I did not learn from them what to do with the code presented above.
I tried to paste it into the command line when creating a new user tool, but that didn't work
Copy the code.
Paste it into NotePad.
Save the NotePad contents as a file to your Scripts folder as: Sforzando.vbs