Scripting and blue

Every once in a while someone releases a new program for score generation, a utility they've decided to make for their own benefit that they've graciously shared with the community. Often, these musical tools are exclusive in their use, meaning they're good for their use, but are difficult to integrate with other work.

For example: say you're working on a piece and want to use an external score generator to generate a score to add to your piece. now, in experimenting, you might have to:

  1. Create your csound score

  2. Create your input file for the external score generator in another file

  3. Run the score generator

  4. Copy the generated score into your csound score file

  5. Repeat process as you experiment

Now imagine that process to the nth degree if you decide to use multiple external programs!

However, with blue, you can do all of that in one environment. You could write your standard csound scores as well as your input to your chosen score generator within blue, press the play button and then have blue do the work of going out to compile the score generator material and bring it back in, integrate it with your csound score, and output a single unified score file. You get the benefit of using the visual timeline to move your generated score blocks around in time, as well as only having to concentrate on the score input to the score generator, leaving all of the tedious work to blue to handle.

Or, say you're working on a score generating library in a scripting language. Now that you've finished it, you want to start working with it. but say you want to also do standard csound scores along with your scripts; having to do the two in the single scripting environment might not be optimal, as you would constantly have to use "print()" functions or use note objects, when it might just be easier to write "i1 0 1 2 3 4 5" and work with that for some of your work, and use your libraries for others. In this case, blue can handle that in that you can call your libraries you've developed and script the parts you want to script within blue, as well handle all of the standard csound score type work.

Within blue there are currently two main objects for scripting, the Python SoundObject and the external SoundObject. The external SoundObject runs scripts outside of blue and brings the results back into blue, and the execution of those scripts is as fast as it would be running the script outside of blue. With the external SoundObject, one may also choose from a variety of scripting and score generating languages to use. The Python SoundObject is limited to Python, and runs Python scripts much slower than they would be for running a Python script outside of blue using the external SoundObject. However, the PythonObject has two main features which may influence your decision in which to use it or not: it does not require Python to be installed on the system as it uses Jython to interpret the script (Jython is an all-Java implmentation of the Python interpreter; for more information about Jython, visit ), and it does not reinitialize the interpreter between uses.

The second point regarding the Python SoundObject may need some explanation: by not reinitializing the interpreter between uses, all Python SoundObjects in blue all share the same interpreter. By doing this, you can define variables, functions, and objects in one block, while using those variables in another block.

As an example, in my recent work with the Python SoundObject, I've set up the first PythonObject in my blue work file to have nothing but class definitions as well as function definitions. The second PythonObject block only has script that sets up instances of those classes written in the first PythonObject, and in this second block I did all of my initialization work for these classes. Finally, throughout the rest of the blue work file, I had PythonObjects that used the class objects I set up in the second PythonObject. This would not be possible using the external SoundObject, as once a script is run, all existing information in memory for that script is lost (unless you decided to make some kind of serialization scheme to write data to a file to be accessed by other scripts, or perhaps were using a web server to maintain state data).

The next two sections below will explain how to use the two different SoundObjects, and for the Python programmer, help you determine when you might want to use one object verse the other.