1
General Discussion / Re: Chords
YAHOO! it worked like magic.
Lawrie, thanks for sticking with me your tool worked great.
Flurmy, thanks for letting me know about yours as well.
This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.
imagine volume and expression like two volume knobs in cascade.
using the "expression" MPC for dynamics effects ...
Much cleaner than the PHP library.
"""joeSelReverse.py Reverses the Notes that are selected in a NoteWorthy Composer staff
see:
https://github.com/nwsw/nwc2ut-python
"""
import sys
# import joeNWCtxtInPythonNew as nwctxt
import nwctxt # see https://github.com/nwsw/nwc2ut-python
import logging
logging.basicConfig(filename='joeNWC_PY.log',level=logging.DEBUG) # DEBUG => print ALL msgs
clip = nwctxt.NWC2Clip()
PlayContext = nwctxt.NWC2PlayContext()
txtItemL = clip.Items
clipItemL = [nwctxt.NWC2ClipItem(txtItem) for txtItem in txtItemL]
first2 = clipItemL[:2]
reversedClipItemL = first2 + list(reversed(clipItemL[2:]))
reversedTextItemL = [item.ReconstructClipText() for item in reversedClipItemL]
print clip.GetClipHeader()
for textItem in reversedTextItemL[2:]:
#print "clipItem.GetObjType()= %s, type(clipItem.GetObjType())= %s, "%(clipItem.GetObjType(), type(clipItem.GetObjType()))
print textItem
print clip.GetClipFooter()
# TO DEBUG uncomment below to report to NWC STDOUT DIALOG & to CAUSE NO STAFF MODIFICATION
# sys.exit(nwctxt.NWC2RC_REPORT)
For the instance of NWC that runs it, this tool will report the current working directory for all tools
IS NOT <path>\NoteWorthy Composer 2\Scripts\
BUT IS <path>\NoteWorthy Composer 2\
System => Windows NT cmptrName 5.1 build 2600 (Windows XP Professional Service Pack 3) i586
Build Date => Sep 17 2009 19:13:11
Compiler => MSVC9 (Visual C++ 2008)
Architecture => x86
Configure Command => cscript /nologo configure.js "--disable-all" "--enable-cli" "--enable-zlib"
Server API => Command Line Interface
import sys
instr = sys.stdin.read()
f = open('joesFirstTestOut.txt', 'w'); f.write(instr); f.close()
C:\...Scripts>python joesFirst.py<joesFirstTestIn.txt
group: joe
name: joesFirst.py
command: python scripts\joesFirst.py
input type: clip text
options:
compress input: [ ]
returns file text: [ ]
long task handling: [ ]
prompts for user input: [ ]
group: joe
name: joesFirst.py
command: python scripts\joesFirst.py
input type: clip text
options:
compress input: [ ]
returns file text: [ ]
long task handling: [X]
prompts for user input: [ ]
convert to and from full spec. MusicXML files.
At some point, someone should write a converter to/from MXML...sigh.
BASIS FOR AN OPEN SOURCE PROJECT to convert NoteWorthy Composer files from/to MusicXML. Two Python 3 programs for NoteWorthy Composer files in nwctxt format. 1. nwctxt2xml.py - Converts nwctxt into XML 2. xml2nwctxt.py - Converts XML into nwctxt
test: 001 time: Fri Aug 07 13:48:51 2009 file: ambeaut.nwctxt -> OK
test: 002 time: Fri Aug 07 13:48:54 2009 file: bosgbaa.nwctxt -> OK
test: 003 time: Fri Aug 07 13:48:55 2009 file: hillhbr.nwctxt -> OK
test: 004 time: Fri Aug 07 13:48:56 2009 file: hussaut.nwctxt -> OK
test: 005 time: Fri Aug 07 13:49:39 2009 file: JesusLM.nwctxt -> OK
test: 006 time: Fri Aug 07 13:49:39 2009 file: mozhall.nwctxt -> OK
test: 007 time: Fri Aug 07 14:01:02 2009 file: ocanada.nwctxt -> OK
test: 008 time: Fri Aug 07 14:01:02 2009 file: wamr01-intrt.nwctxt -> OK
test: 009 time: Fri Aug 07 14:01:22 2009 file: wamr02s-dies.nwctxt -> OK
test: 010 time: Fri Aug 07 14:01:43 2009 file: wamr07-lacri.nwctxt -> OK
test: 011 time: Fri Aug 07 14:01:49 2009 file: wamr10-sanct.nwctxt -> OK
test: 012 time: Fri Aug 07 14:01:55 2009 file: wamr12-agnus.nwctxt -> OK
#Joe Dorocak's small additions to kahman's :
#pyNWC-a .nwctxt syntax parser (I/O) in python
#Created by NWC forum user kahman.
#Use it however you please. Feel free to modify it, but please return all modifications to the forum.
#See below for known bugs.
#If you want to "translate" it into another computer language, feel free to do so. If you want to modify it, feel free to do so.
#Basically, what it does is you can give it a line of code and it will process it by | and :, so |Note|Dur:4th|Pos:0 becomes the line of code ['Note', {'Dur': '4th', 'Pos': '0'}]
#If anyone makes any modifications, post them here.
#At some point, someone should write a converter to/from MXML...sigh.
#Oh, and at some point, I'll work on a program to convert from this back to NWCTXT.
#If you find a bug, please post it here.
#Known bugs:
# *Cannot import lyrics that have line-breaks in them.
"""
nwcTxtParse.py Translates NWCTextFormat to PythonListDictFormat
Usage: nwcTxtParse.py infileName outfileName
Example: nwcTxtParse.py mySong.nwctxt mySong.py
"""
def parsefile(_file):
"parse one file"
_file=_file.split('\n') #split the file by line
for x in range(len(_file)): #for each remaining line,
_file[x]=parseline(_file[x]) #parse it seperately
while 1: #until error occurs
try:
_file.remove(None) #remove a None from the list
except ValueError: #if there is no None,
break #break
return _file
def parseline(line):
"parse one line"
output=[]
if line=='': #if line is blank,
return None #destroy it
elif line[0]=='#': #or if it's a comment,
return None #destroy it
elif line[0]=='!': #or if it's start/end marker,
return None #destroy it
line=line.split('|') #split the line by |
output.append(line[1]) #set what object it is
output.append({})
for x in line[2:]: #then for each property/value
y=(x.split(':')) #split it into property and value
output[1][y[0]]=y[1] #and add these to the dictionary
return output
def writefile(tree):
"write a file"
output='!NoteWorthyComposer(2.0)\n' #start empty output
for x in tree: #for each line
output=output+writeline(x)+'\n' #process it seperately
output=output+'!NoteWorthyComposer-End'
return output
def writeline(line):
"write a line"
output='|' #start empty output
output=output+line[0]
for x in line[1].keys():
output=output+'|%s:%s' %(x, line[1][x])
return output
import sys
N_ARGS = 2
def main(argv=None):
if argv == None: argv=sys.argv
args = argv[1:] #NOTE: args[0] != argv[0] == <full path to example.py>
if len(args) != N_ARGS or "-h" in args or "--help" in args:
print __doc__
sys.exit(2)
f = open(args[0], 'r'); s = f.read(); f.close() # get the input file into s
s2 = parsefile(s) # translate s into s2
f = open(args[1], 'w'); f.write(str(s2)); f.close() # write str(s2) into the output file
print 'Translated ' + str(args[0]) + ' yielding ' + str(args[1])
if __name__ == '__main__':
sys.exit(main())
"""
nwcPy2nwcXml.py Translates
FROM: nwcPythonListDictFormat (kahman's nwctxt to python converter pyNWC-a output)
TO: jdorocak's homegrown xml (So I can use data folding in a text editor.) :)
Usage: nwcPy2nwcXml.py infileName outfileName
Example: nwcPy2nwcXml.py mySong.py mySong.xml
Author: Joe Dorocak
License: Use this as you please. :)
Use with caution - I have done minimal testing. No warranty is implied. :)
"""
class ConvertToXML():
"""
Converts
FROM: nwcPythonListDictFormat (NWC Virtuoso kahman's nwctxt to python converter pyNWC-a output)
TO: jdorocak's homegrown xml (So I can use data folding in a text editor.) :)
rs == resultString; il == indentationLevel; aprs(il,str) == appendToResultString(indentationLevel,strToAppend)
data == string output of kahman's nwctxt to python converter
ix == index of current pythonListDict item;
joe's xml syntax for nwctxtPy files inferred from analysis of data (i added elements named j*):
<jNwctxtPy>
<SongInfo count=1></SongInfo>
<PgSetup count=1></PgSetup>
<jFonts><Font count=12></Font></jFonts>
<PgMargins count=1></PgMargins>
<jStaves>
<jStaff>
<AddStaff count=1></AddStaff>
<StaffProperties count=2></StaffProperties>
<StaffInstrument count=1></StaffInstrument>
<Clef count=n></Clef>
<Key count=n></Key>
<Tempo count=n></Tempo>
<Note count=n></Note>
<Chord count=n></Chord>
<Bar count=n></Bar>
</jStaff>
</jStaves>
</jNwctxtPy>
"""
def __init__(self, indata):
"""
data == data to be converted. FROM: nwcPythonListDictFormat (kahman's nwctxt to python converter pyNWC-a output)
rs == resultString; converted data jdorocak's homegrown xml (So I can use data folding in a text editor.) :)
"""
self.data = eval(indata)
self.data.append(['End', {'Joe': 'End', 'Pos': 'Whatever'}])
self.rs = ''
def toxml(self):
self.aprs(0,'<jNwctxtPy>')
#SongInfo
self.aprs(1,'<SongInfo count=1>')
ix = 0
print len(self.data)
for k,v in self.data[ix][1].iteritems():
self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>')
self.aprs (1,'</SongInfo>')
#PgSetup
self.aprs (1,'<PgSetup count=1>')
ix = 1
for k,v in self.data[ix][1].iteritems():
self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>' )
self.aprs (1,'</PgSetup>')
#Fonts
self.aprs (1,'<jFonts>')
for ix in range(2,14):
self.aprs (2,'<Font count=12>')
for k,v in self.data[ix][1].iteritems():
self.aprs (3,'<' + k + '>' + str(v) + '</' + k + '>' )
self.aprs (2,'</Font>')
self.aprs (1,'</jFonts>')
#PgMargins
self.aprs (1,'<PgSetup count=1>')
ix = 15
for k,v in self.data[ix][1].iteritems():
self.aprs (2,'<' + k + '>' + str(v) + '</' + k + '>' )
self.aprs (1,'</PgSetup>')
self.aprs (1,'<jStaves>')
self.aprs (2,'<jStaff>')
#AddStaff
ix = 16
for ix in range(ix,len(self.data)-1):
#if self.data[ix+1][0] == 'AddStaff': self.aprs (2,'<jStaff>') #ix+1 needed to add ['End',{'Joe':'whatever'}]
self.aprs (3,'<'+ self.data[ix][0] +'>')
for k,v in self.data[ix][1].iteritems():
self.aprs (4,'<' + k + '>' + str(v) + '</' + k + '>' )
self.aprs (3,'</'+ self.data[ix][0] +'>')
if self.data[ix+1][0] == 'AddStaff': #ix+1 needed to add ['End',{'Joe':'whatever'}]
self.aprs (2,'</jStaff>')
self.aprs (2,'<jStaff>')
self.aprs (2,'</jStaff>')
self.aprs (1,'</jStaves>')
self.aprs(0,'</jNwctxtPy>')
return self.rs
def aprs(self, il, strToAppend):
"""aprs(il,str) == appendToResultString(indentationLevel,strToAppend)"""
self.rs = ''.join([self.rs, il*2*' '+strToAppend+'\n'])
#print il*2*' '+strToAppend
import sys
N_ARGS = 2
def main(argv=None):
if argv == None: argv=sys.argv
args = argv[1:] #NOTE: args[0] != argv[0] == <full path to example.py>
if len(args) != N_ARGS or "-h" in args or "--help" in args:
print __doc__
sys.exit(2)
f = open(args[0], 'r'); s = f.read(); f.close() # get the input file into s
cx = ConvertToXML(s) # make a new converter for s
sXml = cx.toxml() # translate s into sXml
f = open(args[1], 'w'); f.write(sXml); f.close() # write str(s2) into the output file
print 'Translated ' + str(args[0]) + ' yielding ' + str(args[1])
if __name__ == '__main__':
sys.exit(main())
Using SendKeys is something of a "dark art." Routines that work perfectly on Win98, fail miserably on WinXP.