A little tool to invert chords. RestChords and Chords with split stems are ignored.
The lowest note in a Chord is moved up by an octave until it occupies its own line. This results in a new inversion.
Run it more than once to get the inversion you want.
Since the tool doesn't know about implied accidentals, forcing accidentals will sometimes be needed.
Copy the code and save it in your Scripts folder as: invert.vbs
Option Explicit ' Invert.vbs, Ver 1.0 - Rick G.
Dim a1, a2, a3, e
Do Until WScript.StdIn.AtEndOfStream
a1 = Split(WScript.StdIn.ReadLine, "|")
If UBound(Filter(a1, "Chord")) = 0 Then
If UBound(Filter(a1, "Dur2:")) = -1 Then
a2 = Split(Mid(a1(3), 5), ",")
a3 = aPos(a2(0))
For Each e In a2
a3(1) = a3(1) - 7 * (aPos(e)(1) - a3(1) = 0)
Next
a2(0) = Join(a3, "")
a1(3) = "Pos:" & Join(a2, ",")
End If
End If
WScript.StdOut.WriteLine Join(a1, "|")
Loop
Function aPos(s) ' NotePitchPos to array
Dim test: test = Split("nb#xv ? oxXz ^")
Dim r(3), c, i ' retval, char, index
r(1) = s: c = Left(s, 1) ' acc?
For Each i In Array(0, 3, 2)
If InStr(test(i), c) Then r(i) = c
r(1) = Replace(r(1), r(i), "", 1, 1)
c = Right(r(1), 1) ' tie?, head?
Next: aPos = r ' acc, pos, head, tie
End Function
Copy this and add it to: nwc2UserTools.ini
Invert Chord(s)='wscript scripts\invert.vbs'
All the work is done in the first For/Next loop. The rest of the code parses the input and recombines it.
2007Apr21 - fixed indentation in code.