Friday, January 12, 2007
views of fltk in csound and python
Fltk is a very good framework for what it does. I have noticed a couple of short commings when it comes to working with fltk. If you want to use a purely csound environment and there is no reason why you wouldn't there is not a good way to get the file name from a file picker into csound (or at least it isn't an obvious thing someone has an example of). A whole class of file players and note testers have to be code generated and not built as csound instruments. One of the claims to fame of fltk is fluid a gui builder for flick. It isn't distributed as an .exe file and it really doesn't compile out of the box. There is an app that does compile but all it does is show off some of the features. I also tried the fltk for python, examples work very well but there again is no gui builder for fltk. I did try to combine it inside of a tk widget but apparently I just ended up with two windows a fltk window and a Tk window. To sum it up fltk has alot of promise and I am looking forward to having the other tools that are needed to make it sing.
Labels: c, c++, code generator, fltk, python, Tk
Thursday, December 14, 2006
how to hardcode csound instruments with file names for code generation in python
Any csound instrument that uses a filename hardcoded in the .orc or .sco filename is a good canadate for a code generator. The first step I did when creating my code generator was to get the filename. I started by generating some code in boa-constructor for a filename picker.
dlg = wx.FileDialog(self,"load orc file", ".", "", "*.*", wx.OPEN)
try:
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
(this is just part of the code generated)
The top line of this generated code can be modified to change the message on the top or to limit the type of files that can be loaded (by changing *.* to *.ext).
After we get the file name we have to get it in a format that will work in csound. I found that using the full path name will not work in csound so that the file that you are using needs to be in the same directory as csound. In the above example filename is the entire filename including the path. To shorten it up you would use the command os.path.basename(filename). That will get rid of the path that was included in the filename before. If you want to change the extension name for any reason you can use [:-4] and then the name of the extension you want to use
batfilenametemp = os.path.basename(filename[:-4]) + '.bat'
In order for our instrument to be generated we have to write it out to a file. To do that we have to create a file and prepare it for our instrument.
sampleplayerfile = open(orcfilenametemp, 'w')
orcfilenametemp in this example is the name of our file. If you want a constant file name you would use a single quote 'sample.orc' instead of the variable name we used. To write to the file we use the command
sampleplayerfile.write("""
using triple quotes we can place all the code we want written to the file and it will save all our formatting including new lines. when we are ready to place our file name in the file we would end the string by using """) and then
sampleplayerfile.write('\n')
This creates a new line.
sampleplayerfile.write('asig soundin ')
this created the non variable part of the line.
sampleplayerfile.write('\"')
this generates the quotation mark we need around the filename
sampleplayerfile.write(os.path.basename(filename))
this will write the filename out to the file.
Once we reach that part we can finish it off and go back to triple quotes
sampleplayerfile.write('\"')
sampleplayerfile.write('\n')
sampleplayerfile.write("""
The entire example is available as part of Dex Tracker.
dlg = wx.FileDialog(self,"load orc file", ".", "", "*.*", wx.OPEN)
try:
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
(this is just part of the code generated)
The top line of this generated code can be modified to change the message on the top or to limit the type of files that can be loaded (by changing *.* to *.ext).
After we get the file name we have to get it in a format that will work in csound. I found that using the full path name will not work in csound so that the file that you are using needs to be in the same directory as csound. In the above example filename is the entire filename including the path. To shorten it up you would use the command os.path.basename(filename). That will get rid of the path that was included in the filename before. If you want to change the extension name for any reason you can use [:-4] and then the name of the extension you want to use
batfilenametemp = os.path.basename(filename[:-4]) + '.bat'
In order for our instrument to be generated we have to write it out to a file. To do that we have to create a file and prepare it for our instrument.
sampleplayerfile = open(orcfilenametemp, 'w')
orcfilenametemp in this example is the name of our file. If you want a constant file name you would use a single quote 'sample.orc' instead of the variable name we used. To write to the file we use the command
sampleplayerfile.write("""
using triple quotes we can place all the code we want written to the file and it will save all our formatting including new lines. when we are ready to place our file name in the file we would end the string by using """) and then
sampleplayerfile.write('\n')
This creates a new line.
sampleplayerfile.write('asig soundin ')
this created the non variable part of the line.
sampleplayerfile.write('\"')
this generates the quotation mark we need around the filename
sampleplayerfile.write(os.path.basename(filename))
this will write the filename out to the file.
Once we reach that part we can finish it off and go back to triple quotes
sampleplayerfile.write('\"')
sampleplayerfile.write('\n')
sampleplayerfile.write("""
The entire example is available as part of Dex Tracker.
Labels: code generator, csound, python
Monday, December 11, 2006
Dex Tracker .011
Dex Tracker beta .11 is out new features include a code generater for a simple sampler utilities for combing all files in a .csd/.orc A utility to remove all instruments from a orc/sco combination. The ability to place a help file in a .html or .txt file (other formats may be added later). The ability to use the old winsound from csound 4 (some assembly required). A handfull of instrumets that are already set up for use in the tracker. public domain tools Harmonise used to generate score files and space a file generator to be used with gen28 and to be used with csound opcode space are included in this version. csound command line help and csound utility list have been added as tools along with the command line.
Files required to run the project are on the homepage.
https://sourceforge.net/project/showfiles.php?group_id=156455&package...
look for a tutorial on creating file generators for csound in this space!!!
Files required to run the project are on the homepage.
https://sourceforge.net/project/showfiles.php?group_id=156455&package...
look for a tutorial on creating file generators for csound in this space!!!
Labels: .csd, .orc, .sco, code generator, command line, csound, csound 4, dex tracker, html, txt, utility, winsound
Tuesday, November 21, 2006
Execute your csd and orc files in csound !!!
O.K. it is a cheap trick for the code generation of .bat files. All you have to do is pick your file and it does it for you. It does seem to require csound to be installed in the c directory (csound 5.04). I also included a new menu option for adding a header string to a sco file. I am also noticing some tables that I have to figure out what to do with I may be putting them in thier own file or something. It appears that the csound binding had been broken at some point. The command line probily does most if not all of what is needed and I may ignore the binding entirely.
https://sourceforge.net/project/showfiles.php?group_id=156455&package_id=174569
https://sourceforge.net/project/showfiles.php?group_id=156455&package_id=174569
Labels: bat files, code generator, csound, music
csound 5.04 official release
Csound 5.04 has been released. I started playing around with simple simple code generators for .bat files. csound filename.csd is enough to have a .bat file that you can just click on and run. You can also run them with startfile (Check to make sure I have the right command) The panda3d people have managed to come up with a way to do it with a shortcut. I suspect that they are not going to tell me though..
Labels: .bat, code generator, csound