Friday, July 06, 2007

 

using vim to load csound instruments

There is this chick that works for unique (temp service) that looks very unhappy and I was thinking about her when I noticed the I HATE UNIX book in the library (she knows how to use you though) that aside one of the best things to happen to windows is the port of unix tools to windows..

Testing the concept of vi, vim and ex... I didn't have it as part of gnu tools so I had to look for a download and found gvim (there is also a traditional vim as part of the distribution).. To get this to work in python I used a batch file to start the program

path = c:\program files\vim #this is just an example
python_awk_bridge.py #probily should rename this...

this is a work in progress so it isn't 100% debugged.. One thing to get used to is aditional sintax.. you will notice if you use vim and just do \instr and then \endin to get to the end of the instrument you end up with something in a comment line at least with the sample file bay-at-night.csd (modified from a csound example).. for this I added ; it is unlikely to be duplicated for other reasons unless the file owner doesn't like dex tracking and it can be replaced in that case... the code currently is as follows

def load_instrument(instr_name, csdname):
"load an instrument using vim"
f = open('csdfile.tmp','w')
my_path = "/dex tracker"
cmd = ["gvim",csdname]
vimin = subprocess.Popen(cmd,stdin=subprocess.PIPE)#.comunicate()[0] #, stdout = f, stderr = f, cwd = my_path )
#f.close()
innum = csr.return_unique_instr_number(csdname) - 1
cmd = ["""/instr""",inum]
vimin.stdin.write(cmd)
cmd = [""";""", ':r', instr_name]
f.close()

load_instrument("""c:\dex tracker\strings.orc""",'bay-at-night.csd') #"""c:\dex tracker\bay-at-night.csd""")
#f.close()

One other comment about vim and emacs is that the complaints are that they are a good operating system and not a good editor... This is a good way to get more from piping and you can run unix (and probily everything command line) right from inside vim (I haven't looked into emacs to far yet but will shortly)

Labels: , , ,


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?