NoteParse – code for shorthand Csound score creation

noteParse – 2012.10.27

As part of my composition work lately I’ve been developing some new
scripts. Some are custom to the piece I’m working on, while others
have been a bit more generic.  I thought I’d share this NoteParse
Python code as I thought others might find it useful.

One of the things I’ve wanted is a shorthand for creating scores.  I’m
aware of a number of different approaches for this (microcsound,
lilypond, abc, mck/mml), but wanted something that worked more closely
to my own personal style.  I found I was able to write something
fairly quickly that is simple but flexible enough.

Attached are two python scripts.  The first works with standard
python, while the other requires being used within blue as it depends
on my python orchestra library that comes with blue.  Both use the
basic syntax I created, while the blue version allows score modifiers.
An example of the syntax with modifiers:

def stoccato(n):
    n.duration = n.duration * .5

modifiers = {"stoccato": stoccato }

a = "m:stoccato 8.00d.25a-12 4 m:clear 3d.5 2 1 0d1a-8"
notes = parseOrchScore(a, modifiers)

generates the following:

i x               0.0             0.125           8.00            8.00 -12.0           0   0
i x               0.25            0.125           8.04            8.04 -12.0           0               0
i x               0.5             0.5             8.03            8.03 -12.0           0               0
i x               1.0             0.5             8.02            8.02 -12.0           0               0
i x               1.5             0.5             8.01            8.01 -12.0           0               0
i x               2.0             1.0             8.00            8.00 -8.0            0               0

(disregard that x is used for p1, these notes get further processed by
performers and performerGroup objects in my composition library).

The things I’d like to point out:

1. The score line is:

a = "m:stoccato 8.00d.25a-12 4 m:clear 3d.5 2 1 0d1a-8"

Disregarding the m: statements, the line looks like:

a = "8.00d.25a-12 4 3d.5 2 1 0d1a-8"

How the library works is that the first note becomes a template note
that carries over values to the next note.  So, for the first note, it
uses pch 8.00, has a duration of .25, and amplitude of -12.  The next
note, which is just a 4, means scale degree four for the same octave
as previously given, so the next generated note has a pch of 8.04, a
duration of .25, and amplitude of -12.  The third note uses
scaleDegree 3, but now has a duration of .5, and carries over the
amplitude.

2. The use of modifiers is completely customizable.  To use modifiers,
supply a map that has the name of the modifier together with a
single-arg function that will process the note.  When an m: statement
is encountered, it will look up that modifier and set it as the
current modifier.  If an m:clear is found, it will set the modifier
function to None.  What I like about this is that a standard set of
modifiers could be created, but it’d be easy to create a custom one
while working on a new piece that might be very specific to that
piece.

The non-blue version attached to this email currently just returns a
list of lists of values that one can then process to generate notes
that work with the individual instrument’s p-field signatures (i.e.
your instrument may have 5 p-fields, or 10, etc. and you’d just apply
a transform to the list to generate the notes you want).

I’m still debating on other features to add, and my current plan is to
add this to my orchestra composition library that comes with blue.  My
thought is that the code is fairly small and useful to my own
composition method, but might be easy for others to take and modify
for their own use pretty easily.

Published
Categorized as Blue, csound

On Isaac Asimov’s Robot, Galactic Empire, and Foundation Series

Earlier this year I had been reading a lot of non-fiction and felt a need to balance out my reading with some fiction. I had noted in my list of books to read Asimov’s Foundation, and downloaded it for my Kindle. Very quickly I was consumed by the world created in this story: a rich and fascinating vision of a possible future history of mankind. After reading through the first book, I looked online and found that Asimov had connected up three different series of books: the Robot series, the Galactic Empire series, and the Foundation series.

Having read the first of the original Foundation Trilogy, I continued my way through the trilogy, then through the sequels, then the prequels. Afterwards, I began with I, Robot and moved through the Robot series and ended with the Galactic Empire series. I think if I were to do it all over again, I would start from the Robot Series and go chronologically through the Foundation series.

I loved the I, Robot short stories and the criminal/mystery character of the Robot series. The short stories were very thought provoking; I enjoyed the small twists and turns that came up as the ethical and moral issues of robots/technology and culture were explored. The books that featured R. Daneel Olivaw and Elijah Bailey were exciting and fun, and I found myself very much attached to the characters by the end.

Of the fifteen books, I found the Galactic Empire to be the least compelling (though, still enjoyable reads). They had less cohesion, being separate and mostly unrelated stories, and I felt the stories were a bit more predictable or not quite as polished.

Of the Foundation Series, I found the original trilogy to be extremely solid. I enjoyed how the events unfolded and the vision of a galactic empire in decay and new Foundation rising developed. I found the prequels exploring Hari Seldon to be fun but perhaps not as tightly written, and I thought the sequels were good, though I felt a bit disappointed with the ending in the final book. (Somehow, it felt like it didn’t quite answer the questions it raised.)

Overall, it was interesting that Asimov spent time to connect these series together. I think he was mostly successful in doing so, and imagine I will spend time to read through all of the books at some later point in my life. I do think a lot the ideas he explored are as relevant today as when he wrote them, and would gladly recommend these books to others. In the end, they were a joy to read and inspired many thoughts.

Being Mostly Offline

Since we moved to Ireland, our primary way of going online while at home has been on our cellphones. Originally we had planned to get either a cable modem or cellular WiFi hotspot, but since we were the traveling we did not get around to it the first month here. Since then, we had been using our cellphones for tethering once in a while in the mornings and evenings, and have decided to try not having internet at home.

So far, things have worked out very well. We are no longer going online first thing in the morning, allowing ourselves to get up and enjoy our tai chi practices with a more peaceful mind. Our evenings have been very serene, and we have been getting either more work or a lot more reading done.

Granted, getting used to less internet did take a little time to get used to, but once we did it has been fantastic. Since the amount if internet we get on our phones is limited, we are much more conscious of using the internet purposefully. We are able to get most of the things involving larger data amounts done while at our offices spaces on campus or at WiFi hotspots at coffee shops. I think though that even when we do have internet access we are using it less and more purposefully.

In some ways, our current relationship to the internet and being connected reminds me of the time before when the internet was pervasive. I have been enjoying this setup very much and I think it has been a great boost for general productivity, focus, and peace of mind. I am curious how things will develop over time, but I expect that we will continue to enjoy being mostly offline at home.

Published
Categorized as General