waveseq – Wave Sequencing User-Defined Opcode for Csound

Lately I’ve been interested in a number of hardware synthesizers that came out during the late 80’s/early 90’s, as I’ve found their synthesis methods rather curious and inventive.  One of them, the Korg Wavestation, has a very interesting synthesis system, using a combination of Vector Synthesis and Wave Sequencing. Vector Synthesis is easy enough to implement using a cross-fading between different oscillators or sound generators, but I was curious to see about implementing the Wave Sequencing in Csound code.

To implement this, I used information obtained online, information in the manuals, time experimenting on a hardware Korg Wavestation, as well as time with the Korg Legacy Wavestation Software (I ended up purchasing the whole Legacy Collection). Here is an example of the waveseq User-Defined Opcode (UDO) using f-tables generated by GEN10:

Example 1:

As well as f-tables using sampled drum sounds:

Example 2:

The UDO is implemented such that it takes in an f-table that describes the entire wave sequence.  Therefore, most of the work to using this opcode is done in creating the set of f-tables to sequence through.  I did implement the following features:

  • Tempo: 24 duration is a quarter note; if tempo is non-zero, it will be used to set the duration of the quarter note, if 0, tempo is about 105 bpm
  • WaveSequence: start wave, looping type (0 = forwards, 1 = forwards and backwards), start wave for loop, end wave
  • Wave Tables: single-cycle wave/single-shot wave/looped wave (determined on whether sample rate given in the waveseq table is 0, positive, or negative), amplitude adjustment, cross-fade time, duration of table to play
About the design, a wave sequence table holds information about how many tables are in the sequence, and how to play them. For example, in example 2, the wave sequence table used is:
itab_bass ftgenonce 0, 0, -9512, 1, "BDRUM11.WAV", 0, 0, 0
itab_tom ftgenonce 0, 0, -17600, 1, "TOM5.WAV", 0, 0, 0
itab_snare ftgenonce 0, 0, -10947, 1, "SNARE11.WAV", 0, 0, 0

iwaveseqtab ftgenonce 0, 0, -32, -2, 3, 1, 0, 0, 2,  
	itab_bass, ftsr(itab_bass), 1, 1, ixfade, iwavedur,  
	itab_tom, ftsr(itab_tom), 2, 1, ixfade, iwavedur,  
	itab_snare, ftsr(itab_snare), 2, 1, ixfade, iwavedur
The iwaveseqtab has 32 size (just needs to be big enough to hold the information for the other tables), and in its first line it describes:
  • 3 tables are in this wave sequence
  • 1 is used to denote backwards and forwards playing through the sequence
  • 0 is the index of the start wave
  • 0 is the index of the loop start
  • 2 is the index of the loop end
after that come the tables to be used.  For example, the part that starts with itab_bass says:
  • sample rate of the table (positive here, so play as single-shot)
  • amplitude adjustment of 1 (amplitude is multiplied by this factor)
  • pitch adjustment of 1 (not currently implemented)
  • crossfade of 0 (ixfade = 0 earlier in the code, not listed above)
  • duration of 6 (iwavedur = 6 earlier in the code, not listed above), this is equivalent to a 16th note
The waveseq UDO is uses the tablexkt opcode, does manual incrementing of phaser variables, use linear amplitude adjustments when cross-fading, and a lot of code for reading from the wave sequence table and configuring things. The code still requires some cleanup work, but I wanted to go ahead and make this initial, mostly-complete implementation available.  I plan to create implement some further features for the waveseq opcode, then create either a full Blue instrument plugin or a BlueSynthBuilder version of this instrument that will allow easier creation and organization of f-tables into wave sequences. I am also thinking about adding Vector Synthesis as well (using then four waveseq instances).
Overall, it was quite an enjoyable experience to study the Wavestation and learn to implement wave sequencing in Csound code.  In the end, I’m still looking at where I might use this opcode in my own work, but it’s nice to know it’s available should I find a use for it.
Download the Examples and MP3’s here: waveseq – example CSD’s and MP3’s

 

Published
Categorized as csound

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

In Response to Computer Music Journal, Summer 2012 review of “The Audio Programming Book”

I was catching up with Computer Music Journal issues and noticed a review by Jeffrey Trevino and Drew Allen of The Audio Programming Book, in which I was a contributing author. The review has some valid points to make regarding the organization of the book and what it covers. However, I did find problematic one section of the review regarding my chapter on Modeling Orchestral Composition:

But why, you might ask, does an introduction to audio programming culminate in a computer model of the orchestra? The chapter should be reframed as an introduction to Csound, to avoid the current sense of aesthetic blindness. Rather than acknowledge the presence of the numerous higher-level electronic music programming systems that invite alternatives to the conservative score-orchestra model built into Csound, the chapter precludes the discussion of other approaches by failing to mention them. Instead of treating the score-orchestra metaphor flexibly, as is the case in most uses of Csound, the author cements its literal interpretation with a table entitled, “Comparing the Steps of Composing for Live Orchestra and Composing with [Csound’s] Orchestra Library.” (Emphasis Yi’s.) Lastly, he deals aesthetic alternatives their death blows in the form of an all-encompassing first-person plural: “By reusing an existing music software system, we can leverage the solutions already available and focus more closely on our compositional interests.”

I found this section of the review rather problematic and takes what I wrote out of context to serve the narrative of the reviewers that “the remainder of the printed text presents an arbitrary collection of special topic essays on possible relationships between Csound and programs written in C.”

There are a couple of points I wanted to discuss.  First is that the text is specifically working on modeling orchestral composition, and proposes a library design to do so. The focus of the article was on the composition aspect, or, how the composer writes for an orchestra, and how to model that aspect of the relationship between composer and orchestra. It was not specifically about the orchestra itself, but requires a discussion of the orchestra to understand the composing process for it.

In that regard, I feel that the criticism that I did not discuss a “score-orchestra metaphor flexibly” is in a way, criticism that I did not write a different text altogether. It seems that the reviewers read the text as being about a Music-N style score/orchestra design, or specifically, about Csound’s score/orchestra design. The reviewer’s misunderstanding is notable in their additions of [Csound’s] here:

“Comparing the Steps of Composing for Live Orchestra and Composing with [Csound’s] Orchestra Library.” (Emphasis Yi’s.)

Note, the original title of the table did not have “Csound’s” as the article was not about Csound’s score/orchestra at all.  The library that is the focus of the chapter uses Csound as a backend, but it in itself is a generic design of orchestral composition that could be developed to target other backends as well (i.e. PD, Max, SuperCollider, Chuck, etc.).

Note: When I wrote the chapter, I did have some reservations that there may be confusion.  Csound and Music-N languages do have a long-held design of a score and orchestra.  I did worry that it might get confused with the concepts I was trying to model.  For me, the Music-N score/orchestra are not the model of what I was doing, but just the tool I used to support the software model of the orchestral composition library. I tried to be clear of this distinction, but it seems to still have lead to some confusion.

This leads to the second issue I had with the reviewers’ comments regarding aesthetics.  In the text, I wrote a brief section on wanting to reuse an existing synthesis system.  This was so that the article could focus on orchestral composition and less on the synthesis details, which I believe are covered in other chapters of the book.  I discussed why MIDI was not sufficient for the library’s design goals, and discussed why I chose Csound.  However, I would have thought that readers who are familiar with SuperCollider, PD, Common Lisp Music, or other synthesis systems, would understand the chapter to be a generic design that could easily be implemented in other languages and systems.  I did have to discuss Csound’s ORC/SCO model to explain how the results of the orchestral composition library would ultimately map its results to another systems software model to get audible results.

To me, this is not even an aesthetic choice, but an implementation detail.  To me, the aesthetic choice here is that I wrote from a perspective of a composer looking at achieving compositional practices commonly found in orchestral composition and reproducing them in a computer music context. In that regard, that is the focus of the chapter, and is even the title of the text. I do not think then that not mentioning other aesthetic goals is a valid criticism.  To me, It is as if I criticized an article about Impressionist technique as leaving out mention about Dada or Post-Modernism.

As for other tools and ways of working, I’d like to state that I have supported and continue to support other tools and software synthesis systems.  I have often promoted that everyone should use the tools that best suits them, and ultimately the important thing to me is the musical result, and not the tools used.  I think it is the reviewers’ reading of the article as being about Csound has lead to misplaced criticism.

To summarize, I appreciate the work of the reviewers to review The Audio Programming Book.  However, in regards to the section on my own chapter, I feel they had misread the text.  In the end, I still find the chapter and the design of the library interesting and hope it will be as useful to others–using whatever system they use–as it has been for my own compositional work. Hopefully I have explained my own perspective clearly, and would invite any further discussion.

Published
Categorized as General

Perils of Technology

The Daily Beast ran an article today about web addiction and the perils of technlogy.  This has been a topic on my mind a fair amount lately as I have been working on removing clutter from my days to focus more on things that are important to me.  The article also cites Sherry Turkle’s recent work, which I have been very interested in.  
While the article discusses the dangers of pervasive technology and addiction, I think it is only one side of the coin.  On the other hand, I do think technology can be utilized as a tool to facilitate interesting, positive interactions.  I also think it requires discipline and firm boundaries to remain useful and not tempt one into addiction.  
I think when I first got into using “smartphones” with internet access it was quite addictive.  Over time though, I think I have managed it to be just a tool (though, occasionally lapsing into overuse).  I have turned off 3G internet on my phone and only enable it when on trips (I use a pay-as-you-go plan), and use WIFI at other times.  I find that I can not compulsively check the internet as much and that is a good thing.
I also don’t engage with social networks too much now, averaging about once a day.  I have made other changes as well, and I have been mostly happy with my relationship to the technology I use, though am continuing to actively be aware of and modifying my usage.  
In the end, I think the article mentions very poignant issues for this period in history.  I hope that this is just a phase in the development of our technological culture and am optimistic that people will become more aware of these kinds of dangers and hopefully not so wrapped up in it all. 
Published
Categorized as General

Einstein on the Beach – Toronto – Luminato Festival 6

This past Saturday, Lisa, myself, and some friends went to Toronto to attend the performance of Philip Glass’s Einstein on the Beach, presented as part of the Luminato Festival 6.  I had long wanted to see a performance of this work, ever since my early exposure and interests in Glass some 18 years ago, and was very happy to finally satisfy this long-held curiosity.

The performance was done without intermissions, and lasted about 4.5 hours.  The performance used the original staging.  The performance was… astounding. I was mostly mesmerized from the start to finish, sitting in my seat throughout the performance.  Glass’s music felt as fresh as ever (I find his early music has “it”, that quality that permeates a timeless work).  Robert Wilson’s staging was equally as present, and Lucinda Childs’ choreography was a joy to watch.  

The highlights for me were the first Dance scene and the Spaceship scene, the first for the dance and the latter for the music.  The rest of the work was of fantastic, but those two scenes were particularly engaging for me.  The violinist did a wonderful job, as did the rest of the performers.

If there was any criticism I would have for the work, I would say two things stuck out. The first is the Building scene: the solo saxophonist didn’t really work for me.  Musically and dramatically it felt like a departure from the rest of the work. While the opera as a whole had a wonderfully surreal quality, I felt the saxophone solo broke from it.  While the visuals and rest of what was going on stage may continued the surreal dream-like world of the rest of the scenes, the music was enough to break focus and threw me off a bit.

Secondly, the performer doing the narrations involving “Mr. Bojangles.” At times I had some difficulty in understanding what was being said, especially compared to the performer doing the narrations for “I was in this prematurely air-conditioned supermarket…”.  It felt that the first performer had gotten a bit tongue-tied at times, keeping up with the rapid pace of the dialogue.

Overall, I thought the performance was fantastic, and I was more than ecstatic in satisfying this long held curiosity to see this work.  I hope that later in my life that there will continue to be performances of this work to attend.  I was also very inspired by this performance, and I look forward to now getting back to my own composing work.

Published
Categorized as General

Lessons from Lumosity: Slower and more correct is better than fast and being wrong

I have been doing brain training games on lumosity.com for a while now.  Doing the daily training has been fun, and I feel that they do have a positive impact.  Of all the things I have taken away from the games, the one lesson that has most been on my mind lately has been that “slower and more correct is better than fast and being wrong.”

In certain games, one gets a higher score by getting more correct in a row, rather than total correct.  I have always had a tendency to do things quickly, at the expense of not necessarily doing this completely correctly.  I can see this manifest in a number of areas in my life.  The earliest was when I was in middle and high school, taking exams I would often finish early and turn things in, getting a few mistakes that would have been easy to correct if I had taken my time.  In my writing, I often find awkward phrases while editing that I imagine could have been done better the first time around.  (Though, with writing, sometimes it’s better to just get the thoughts out and revise later.)

I have been thinking about this idea a fair amount during my tai chi practices recently. I have been focusing on practicing with more awareness and more precision, trying to do things correctly.  Consequently, my practices have been slower and longer, but I find the work has been very rewarding.

I think too with programming, there’s a lot of conversations about incurring technical debt due to introducing quick fixes/hacks that will later need to be redone more properly.  This too can be a case where doing things more correctly can be better.

The flip-side of this is trying to do things absolutely perfectly.  This can be paralyzing to work on a project. It is a spectrum of correctness and speed: perfection and slowness on one side, fast but incorrect on the other.  I think I have tended to be on the faster side, but I am now working to bring myself more in balance.  I hope that the patience I have been working on in Lumosity and in my tai chi practice will continue to manifest in my music and programming work.

Published
Categorized as General

The Living Ocean

Completed: 2012.05.14
Duration: 5:17
Ensemble: Electronic (blue, Csound)

MP3: Click Here
OGG: Click Here
FLAC: Click Here
Project Files – Click here (.blue, .csd)

“The Living Ocean” is a piece inspired by Stanislaw Lem’s “Solaris”. I was struck by the humans encounters with the living ocean on the planet, their fascination and draw into it, and their ultimate inability to rationalize and understand it. Their experiences often left them with more questions than answers, not only about the living ocean, but also themselves and the nature of their own existence.

For me, the story of “Solaris” holds many parallels to the experience of art that I search for when composing. Listening: drawn in, fascinated, the rational mind at rest, only an irrational experience is left. Afterwards: awe, questions about the work, questions for myself, curiosity.

Solaris – Stanisław Lem

I finished reading Stanisław Lem’s Solaris this weekend and was just so completely drawn into the work.  The Solaris ocean, the idea of encountering life that existed truly outside of human experience, the exploration of man’s coming to some terms with understanding what it is, and through it learning something of themselves… I had seen the 1972 Tarkovsky film adaptation some time ago, but remembered very little of it except that I thought it somewhat surreal.  I’d like to revisit the film now, and perhaps even watch the 2002 version as well.  
One of the things that I am still thinking about now is the ocean as something somewhat unaware of the humans, something that is reacting to but only mildly curious of them.  Something that just is, going on about itself, and the humans there observing, pondering. It made me think too of music, one that was not in dialogue with an audience, but something that moved along freely in time, existing, simply being, and an audience there as observers, listening and pondering the piece. In this the piece could move along in its own time, by its own set of rules, perhaps ones by which listeners may or may not understand.  
I think the music I have found most connection with has had these kinds of qualities. A co-existence in space and time, breathing and moving along, unaware of those around.  A freely living sound. 
I imagine I will revisit Solaris more than a few times in my lifetime.  I thoroughly enjoyed the book and am still very much deeply contemplating it…