The Phantom Zone

2009 June 6
by bmccosar

I remember back in the day, in the old Superman comics, there was a place called the Phantom Zone.  It was used as a sort of combination of prison and exile.  People who were sent there existed as formless wraiths, able to observe the universe, but having no place in it, and no ability to affect it.

For the past year, I think I’ve been living on the outskirts.

A year ago, we moved from Florida to Virginia.  A lot has changed in that time.  We sold our house in Florida (a miracle, in this economy), found a place to rent until we could get our bearings, and moved on with our lives.

Well, at least my wife moved ahead.  She’s adapted quite well.

As for me, I drifted.

A year has passed, and I haven’t put down any roots here.  I guess, psychologically, having lost everything, it’s difficult for me to start over.  Like the Martians in War of the Worlds, I’m past my prime and on the way down, living in a world that seems to be falling apart.  (This is another interpretation of my last Jamendo album, Martian Winter.)

So here I am, in my own private Phantom Zone, on the verge of yet another change:  we’re moving again.  Not to a new state, not to a new city — only a mile away, actually.  We’re buying a house.

I look forward to having a home of my own again.

And yet I dread this month.  I hate the process of moving, the process of worrying over paperwork, the process of waiting, the fear of unexpected obstacles, mismatched schedules, and constant delays.  Legal matters and financial matters are something I fear more than cancer.  I think of legal processes as being a great machine, grinding us all, occasionally carelessly mangling our lives.

For these next two months — at least until August — my life is going to be on hold.  Everything is going to the move, and to the new house.

Music is the thing that keeps me going; and yet music is always the first thing to go.  There’s always something More Important.  To an outsider, it’s an easy sacrifice — I mean, in this world, in this culture, unless a thing has a monetary or material value, it’s apparently worthless.  Free time is just that, free, and if you’re not getting ahead, you’re being left behind . . . .

To me, though, it’s a pretty deep cut.

So, to use the catchphrase made famous by one of the current summer blockbusters, “I’ll be back.”  I’m going deep into the Phantom Zone this time.

Into . . . and hopefully through.  In August, maybe I’ll be ready for a return to the real world.

Be seeing you.

gpcsets-0.9.2.0, now with Compact Format

2009 May 14
by bmccosar

A minor addition, but certainly worthwhile:  the module Data.PcSets.Compact, which allows translation to and from “Compact Format.”

gpcsets-0.9.2.0

In Compact Format, each pitch class element is represented by a single alphanumeric character.  Probably the best way I can show this is to demonstrate.

mccosar (1) -> ~/Torchwood/gpcsets/src
$ ghci Data/PcSets/Compact.lhs
GHCi, version 6.10.3: http://www.haskell.org/ghc/  :?  for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 2] Compiling Data.PcSets      ( Data/PcSets.lhs, interpreted )
[2 of 2] Compiling Data.PcSets.Compact ( Data/PcSets/Compact.lhs, interpreted )
Ok, modules loaded: Data.PcSets, Data.PcSets.Compact.
*Data.PcSets.Compact> let cMaj7 = toStdSet "047B"
*Data.PcSets.Compact> cMaj7
StdSet [0,4,7,11]
*Data.PcSets.Compact> let gMaj7 = Data.PcSets.transpose 7 cMaj7
*Data.PcSets.Compact> gMaj7
StdSet [7,11,2,6]
*Data.PcSets.Compact> compact gMaj7
"7B26"
*Data.PcSets.Compact> :q
Leaving GHCi.

Above, I defined a CMaj7 chord using the compact format “047B”.  This translated to the pitch class set [0,4,7,11].  I transposed it to GMaj7, then used compact to write the new set as a string — in this case, 7B26.

The basic alphanumeric conversion is Base 36 (0-9 and A-Z).  Therefore, standard pitch class sets can be entered as 0-9 with A=10 and B=11.

There is an alternative set of functions which use a duodecimal conversion: 0-9 with T=10 and E=11.  In this case, the GMaj7 chord above would be “7E26.”

And, of course, since this is after all the “General” pitch class set module, the functions also work with sets defined with a different basis or modulus.  However, the practical limit is modulus 36.  Beyond that, I’m not certain how helpful “compact format” would be to a 136 element 144-TET structure (I think it would look more like an md5 sum than music).

gpcsets-0.9.1.0, now with SVG

2009 May 11
by bmccosar

As I mentioned a while back, one of the things I had in development for gpcsets was a module for making simple SVG diagrams of pitch class sets.  I’ve just released a new version of the module with that capability:

gpcsets-0.9.1.0

There are now some working demos in the doc/examples directory of the source distribution.  Below, I’ve posted the code for each example (simplified — the original is in literate Haskell) and PNG images derived from each of the SVGs in the demo.  (WordPress still doesn’t like SVGs.)

svgdemo1

Simple Example: the C Major Scale, a Standard Pitch Class Set (12-TET, or modulus 12).

import qualified Data.PcSets as P
import qualified Data.PcSets.Svg as S

cMajor :: P.StdSet
cMajor = P.stdset [0,2,4,5,7,9,11]

main :: IO ()
main = putStrLn $ S.pcSvg cMajor

svgdemo1

svgdemo2

C Major Scale with its main inversion axis. The operation invertXY 2 2 or invertXY 0 4, for example, will result only in the same scale.

import qualified Data.PcSets as P
import qualified Data.PcSets.Svg as S

cMajor :: P.StdSet
cMajor = P.stdset [0,2,4,5,7,9,11]

main :: IO ()
main = putStrLn $ S.pcSvgAx cMajor (2,2)

svgdemo2

svgdemo3

The 19-TET C Major scale (for more info, see this article).

import qualified Data.PcSets as P
import qualified Data.PcSets.Svg as S

cMajor19 :: P.GenSet
cMajor19 = P.genset 19 [0,3,6,8,11,14,17]

main :: IO ()
main = putStrLn $ S.pcSvg cMajor19

svgdemo3

svgdemo4

Finally, a demonstration using custom rendering.

import qualified Data.PcSets as P
import Data.PcSets.Svg

cMajor19 :: P.GenSet
cMajor19 = P.genset 19 [0,3,6,8,11,14,17]

altRen :: Rendering
altRen = Rendering
  {
    pxSize = 500,       -- default size
    lnColor = "black",
    psColor = "yellow", -- ps, colors IN the set.
    csColor = "blue",   -- cs, colors complementary to the set.
    axColor = "red",    -- axis isn't used here.
    relMain = 0.70,     -- default is 80% of the frame.
    relElem = 0.15,     -- default is 10% of the main circle.
    relAxis = 0.95      -- axis isn't used here.
  }

main :: IO ()
main = putStrLn $ pcSvg' altRen cMajor19

svgdemo4

First ever release: gpcsets, Pitch Class Sets for Haskell

2009 May 9
by bmccosar

The day is here.  Today, I uploaded my first ever release of gpcsets to Hackage.  Here’s the page:

gpcsets-0.9.0.0

That was a lot of work.  And I’ve only got one module complete out of the five I have planned.

HOWEVER, what I’ve got is cool.  Here are some features:

  • It’s fully documented through Literate Haskell and Haddock.  This means the source code was transformed directly into the library and testsuite documentation.  There are nicely formatted .pdf manuals available in the “doc” directory.
  • The entire thing builds and runs through Cabal.
  • All the functions of my original pcsets module (for Python) are implemented in Haskell . . . usually in about one line of code.
  • The test suite is very thorough.  Frightening, really.
  • Future modules are planned: Svg, for Scalar Vector Graphics representation of pitch class sets; Notes, for standard representations of pitch class sets (eg “C E G B” instead of [0,4,7,11]); Compact for the “compact format” representation of pitch class sets (eg 047B instead of “C E G B”); and Catalog for calculating prime set catalogs in different modulus systems.

This is still a work in progress.

I’m planning on releasing this series (and any bug fixes) as 0.9.0.x.  Each module I add thereafter will increase the third number by one, eg 0.9.1.x.

Therefore, if I finish four new modules and four new test suites, I should end up at 0.9.8.x.  When all of the smoke clears and the entire library has been tested, tested, and retested, I’ll call it “stable” and put it out there as 1.0.0.

In the fullness of time ;-)

In progress: gpcsets, pitch class sets for Haskell

2009 May 2
by bmccosar

Once again, I’ve been very busy offline, and haven’t posted an update here in a while.  There’s a good reason.

As you can probably tell from my recent posts, I’ve been learning Haskell.  I think I’m finally getting good with it.  The best way to learn, sometimes, is to just jump into a project and run with it.

And so I have.  I’m writing a new Haskell library, on the same theme as my earlier pcsets: Pitch Class Sets for Python. (Python folks, there’s news about a future version of pcsets, if you’re coming here from the pcsets page.  So read on.)

I’m calling it

gpcsets:  Pitch Class Sets for Haskell

The “g” stands for “general.”  This version is not restricted to 12-tone equal temperament (12-TET).  The best way to explain is just to demonstrate.  (Here I’m using GHC 6.10.2, but any reasonably modern version of Haskell should work.)

Standard Pitch Class Sets

mccosar (1) -> ~/Torchwood/testarea
$ ghci PcSets.hs
GHCi, version 6.10.2: http://www.haskell.org/ghc/  :?  for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling PcSets           ( PcSets.hs, interpreted )
Ok, modules loaded: PcSets.

First, let’s define a standard pitch class set (based on 12-TET).

*PcSets> let s = stdset [0,1,3,6,10]
*PcSets> s
StdSet [0,1,3,6,10]

A basic pitch class set operation is transpose n:

*PcSets> transpose 4 s
StdSet [4,5,7,10,2]

Also, standard pitch class inversion:

*PcSets> invert s
StdSet [0,11,9,6,2]

In addition, XY inversion, defined as “an inversion that causes the pitches X and Y to interchange”:

*PcSets> invertXY 3 6 s
StdSet [9,8,6,3,11]

Notice that the elements 3 and 6 have interchanged, above.  In truth, the pitch class set operation known as “inversion” is closer to the geometrical idea of rotation about an axis in the plane (flipping).  Sometimes this is hard for people to see.

Well, no longer.  One of the modules in gpcsets translates pitch class sets into Scalable Vector Graphics (SVG).  Here, I’ve taken the set “s” above, rendered it to SVG (with the invertXY 3 6 axis shown), and translated the SVG to the .png image format (because WordPress apparently doesn’t like SVGs :-S )

gpcsets-testAbove, the pitch classes are numbered like a clock face, with “0″ at the 12 o’clock position.  Clearly flipping about the blue inversion axis will exchange 3 with 6, and vice versa.  In addition, 10 should become 11, 0 should become 9, and 1 should become 8.  This is exactly what happened in the operation invertXY 3 6 s.

General Pitch Class Sets

The extension I’ve made here is that the library can also handle general sets with a modulus (temperament base) other than 12.  For example, here are the notes C, D, E, and F in 19-TET:

*PcSets> let g = genset 19 [0,3,6,8]
*PcSets> g
GenSet 19 [0,3,6,8]

Just as before, these sets can be transposed — they simply have a larger pitch class space to move around in.

*PcSets> transpose 4 g
GenSet 19 [4,7,10,12]

Standard inversion (about the zero axis) also works:

*PcSets> invert g
GenSet 19 [0,16,13,11]

In addition, notice invertXY has the same functionality in 19-TET space:

*PcSets> invertXY 3 6 g
GenSet 19 [9,6,3,1]

What about pcsets?

Once I’ve got a relatively stable version of gpcsets working in Haskell, I’m going to rewrite the original pcsets to work with Python 3.0.  There were good reasons for waiting:

  • pcsets version 2.0 was very stable, probably because of my insanely exhaustive test suite.
  • While I was planning a rewrite of pcsets to accommodate general sets and alternative tunings, Python 3 came out.  I figured I’d wait for it to stabilize and, more importantly, get in all of the Linux repositories (Ubuntu, Fedora, etc.) in some usable form.

Therefore, pcsets-3.0 will be in the works this summer.

What about gpcsets?

Right.  We’re talking about vaporware right now — I’ve yet to make even a single release.  Again, good reasons:

  • Just as I did in Python, I want to create an insanely exhaustive test suite.  Fairly easy to do in Haskell, using QuickCheck.  (Although, warning, I’m using the version 2 series, which isn’t installed by default with GHC.)
  • One of the things that made pcsets work was the fact I documented, basically, every molecule of the source code.  Again, this is easy in Haskell using two systems — haddock (a comment-based system) and literate Haskell (which can be easily adapted to LaTeX output).
  • I’ve updated my development methods to the standards in these two articles: [1] How to write a Haskell program and [2] Structure of a Haskell project.  The first time I used darcs dist -d I was pretty much hooked, and I’m a long time subversion user.  (I can say the same for ./Setup.lhs sdist using Cabal.)

I don’t know what sort of time frame I’m on, because I’m always learning something new and refactoring my code so it is more powerful and easy to use.  Right now, with no public release, I’m up to gpcsets-0.8.3 here at home.  That’s actually the 4th complete rewrite of the core PcSets.hs code — odd minor versions such as 0.7.x were unstable, often cobbled together to test a new idea, while even minor versions have been more complete implementations.  I don’t think I can do to much more improvement on the core module, though, so I may be close to that first release.

Why am I writing this today, instead of working on gpcsets? :D

Someone actually gave me a very kind compliment on my “about” page, here on WordPress.

It turns out LameSpirale has been working on some similar ideas, especially the SVG implementation — and based on my pcsets code!  However, where I’ve gone to the abstract and impractical ;-) , LS is apparently applying the pcsets library to a chord voicing dictionary for guitar.

I tried something similar back in the day, a program I called Chordinateur [Peut-être vous voyez que c'est un jeu de mots  :D ]  It had two purposes — to generate chord voicings, and to generate novel chord progressions.  Like most two headed monsters, it died a horrible death.  Next time, I’ll remember — one purpose per program!

What about that next Jamendo album?

Oh, and one more thing.  I’m supposed to be practicing right now.  Time to go.

Scorange

2009 April 12
by bmccosar

OK, today, a bit of a departure.  I just completed my first programming project using Haskell.

I call it Scorange.  Why?

  1. It’s a portmanteau of ’score’ and ‘range’.
  2. It finally gives us something that rhymes with orange.

I’ve already demonstrated its use on my Csound blog.  Briefly, here’s what it does: it allows me to create Csound score files of arpeggios, and automates a number of repetitive tasks.  It also allows me to control the sound by generating an arbitrary number of parameters.  (I’ve more discussion on this in the original article.)

Anyway, for regular readers of my WordPress blog — who may or may not be into Haskell or Csound — here’s what it sounds like.  If you generated the score file using the program below, and processed the score file using Csound, you’d hear something like this:

Scorpio [mp3, 13.8 seconds, 218 K]

OK, now that you’ve heard it, most of you can leave.  Haskell folks who’ve stumbled on to this page — the code is posted below (beyond the ‘more’ tag).

read more…

Tunehenge

2009 April 9
by bmccosar

Just a quick note, today — back in February, I participated in FAWM 2009.  One of the artists I met there was Joel D. Canfield.  It turns out Joel hosts a blogtalkradio show, Tunehenge (and also runs the Tunehenge music community).

Well, this Saturday, I’m the guest on the show.

Hard as that is to believe.

Those of you who have followed my music — and followed this blog — can infer that I’m pretty much an introvert.  Music, science, and mathematics are my main thing.  Nevertheless, if you want to be present at an event akin to a bigfoot sighting or crop circle outbreak . . . here I am, and here I’ll be on Saturday:

Show Details

Album artwork update

2009 April 7
by bmccosar

It occurs to me I’ve outlived several different media formats.  At first there were vinyl record albums; then there were cassette tapes; then CDs.

And now what?  Electronic copies?

One thing is missing from this equation.  Album art used to be nice.  I’m thinking Ohio Players type ‘nice‘, not Mr. Rogers type ‘nice’. :D

(Those of you who got that reference, I salute you.)

At any rate, I’m still one of those throwbacks who likes actual, physical copies of my albums.  Every time I release one online, I always make sure to burn a bunch of physical copies, complete with album art and a track listing.

Volume, volume, volume . . . and I’m passing the savings on to you.

That is, I’ve got all these .pdf files — the actual CD labels — sitting on my hard drive, and decided to make them publicly available.  You can download them, print them, and make your own album cover.  Here’s the link:

Printable Album Art

This is for not only my five Jamendo albums, but also the less formal albums hosted on SoundClick.

Preparing for Album #6: The Calculus of Variations

2009 April 1
by bmccosar

Today, I started preparing for my sixth Jamendo album.

I’ve given it a working title: The Calculus of Variations.

I don’t know when it will come out, because the next few months are going to be very rough.  My wife is going away on a business trip for most of April and May.  I will miss her a lot.

Evidently misery makes for good music.  One of my most popular albums, right now, is La vie sous la mer.  It was composed while I was at one of the lowest points in my life.  Privately, I regard it as my best work to date.

Well, this next album should be spectacular, then.  I’m using a lot of material from FAWM 2009 — and some older material, which you can preview on SoundClick — plus the Linux audio skills I’ve picked up this past month.

March was a month for experimentation.  I started out in one direction, and ended up in an unexpected place.  Here’s the story so far.

Systems

Most of the latter part of March was spent installing and testing Linux systems (see previous article).

Fedora / CCRMA

I’m very happy with Fedora 10 + CCRMA.  The system is incredibly stable, and (in 32 bit mode) allows me to run just about every possible Linux audio app, from Rosegarden, to Jack, to Csound, to Audacity.

However, Fedora 11 Beta just came out . . .

I chose not to test it.  See, there’s a problem:

  • Fedora writes volume labels on the disk partitions during install.
  • Some parts of the Fedora boot process look for LABEL=”/” to find the right volume.
  • When two places are labeled “/”, chaos ensues!

That’s right, just like in Highlander . . . There Can Be Only One.  I have a feeling my second Fedora install would have to be on a second hard drive.  Which I don’t have.

On the other hand, there’s no big rush.  The most important addition — the CCRMA packages — won’t be ported to Fedora 11 until after the finished product is released.  (That’s my guess . . . that’s the way it was for Fedora 10).

Ubuntu

Perhaps the raging success story of the year has been the Ubuntu 9.04 Beta.  Originally, I installed it almost as a throwaway, just in case everything went wrong . . . now, I’m spending more time in the beta than I am in Ubuntu 8.10.

I know, I know, it’s a beta, and the world could end tomorrow.

Still, it’s good.

I have KDE 4 as my main desktop, now.  I hated it in Ubuntu 8.10.  Well, in 9.04, as I mentioned, the NVidia drivers actually work on my computer.  KDE 4 is spectacular!

Great news for Kubuntu.

Of course the one thing that aggravates me is that I’m still using the stock kernel . . . the realtime kernel in 9.04 isn’t (yet) up to the same level of usability and performance as the one from Fedora 10 + CCRMA (core testing).

Not good news for Ubuntu Studio.

On the other hand . . . I did find a set of hacks for fixing the realtime kernel on my own . . . .

Programs

Renoise

Renoise is back.  When I was running 64 bit only, and my onboard soundcard didn’t work, I was stuck, and briefly gave up on it.  Renoise will run on 64 bit computers (in 32 bit mode) — however, it REALLY needs JACK to work well, and it’s not compatible with 64 bit JACK.  Therefore, until I installed 32-bit Fedora 10 + CCRMA, I’d shelved it.

The good news is, not only am I back to Renoise, Renoise is out in a new version (2.0).

You can hear a lot of Renoise work in my fourth album, Points of Departure.  (I used it for the rhythm tracks on most of the songs.)

Hydrogen

When I was a Renoise outcast in 64 bit land, I got very proficient at using Hydrogen.  Most of my work in FAWM 2009 featured Hydrogen as my “drum corps” — as did my fifth album, Martian Winter.

Csound

I’ve been practicing with Csound, and learning to generate a lot of new sound textures.  I’m hoping I can continue to write on my Csound blog as I adapt these techniques to my new album.

But then . . . what’s one big project . . . without another huge project?

Haskell

Ah, yes.  I learned Python a few years ago.  I’ve since gotten into heavy mathematical programming — using programs such as Sage, Octave, and Maxima.  (Long story there, but it does go a way toward explaining my choice of title for my sixth album.)

I do have an idea for an algorithmic composition system . . . problem is, I’ve always had problems implementing it in Python.  I figure, if I’m stalled, attack the problem from a different direction.

That direction is functional programming . . . through Haskell.

I’m at the “baby steps” level right now.  Here’s my latest program, based on the hit game show NumberWang (featured on That Mitchell and Web Look.)

-- That's Numberwang!

module Main
  where

import IO
import Random

main = do
  hSetBuffering stdin LineBuffering
  putStrLn "Let's play NumberWang!"
  numberWang

numberWang = do
  putStrLn "? -> "
  guess <- getLine
  wang <- randomRIO (1::Int,10)
  if wang < 3
    then do putStrLn "That's NumberWang!"
    else do putStrLn "No..."
            numberWang

If the above code is copied and saved as numberwang.hs, it can be compiled and run as in the example below (I’m using ghc 6.8.2 on Ubuntu 9.04 beta):

mccosar (1) -> ~/Projects/Haskell
$ ghc --make numberwang.hs -o numberwang
[1 of 1] Compiling Main             ( numberwang.hs, numberwang.o )
Linking numberwang ...
mccosar (1) -> ~/Projects/Haskell
$ ls
expt01.hs  expt02.hs  numberwang  numberwang.hi  numberwang.hs  numberwang.o  Test.hs  yaht-3.7.hs
mccosar (1) -> ~/Projects/Haskell
$ ./numberwang
Let's play NumberWang!
? ->
11
That's NumberWang!
mccosar (1) -> ~/Projects/Haskell
$ ./numberwang
Let's play NumberWang!
? ->
14
That's NumberWang!
mccosar (1) -> ~/Projects/Haskell
$ ./numberwang
Let's play NumberWang!
? ->
-4
No...
? ->
24
No...
? ->
13
No...
? ->
3
No...
? ->
44
No...
? ->
7
No...
? ->
13.3
That's NumberWang!

Remarkably true to the spirit of the game!

The Part of “Why”

All these projects . . . why?

One one level, my music is all I have to leave behind.

On a deeper level . . .

I will miss my wife.  It’s only a few months.  But it’s a long stretch of empty, in a colder, crueler world.

Maybe if I fill up my days, the nights will pass in quiet oblivion.

Ubuntu 9.04 (update)

2009 March 28
by bmccosar

Wow.

Today, I tried my final experiment, designed to destroy my brand-new Ubuntu 9.04 Beta . . .

I installed the NVidia driver.

. . . And it actually works!

This was emphatically NOT the case with Ubuntu 8.10.

Moreover — yesterday, I mentioned KDE was kind of slow . . . today it is as smooth as glass.

NOW I get it.  This is what I was missing from the KDE 4 experience.

Moreover — I figured out how to do one task in the new KDE that had evaded me: create desktop quicklaunch icons.  In the old days, this was handled with a right click.  Now . . . just drag the item from the menu to the desktop.

All systems go!