My Idea for a Grand Opera

STAGE: A rural village in feudal Japan. A small, traditional Japanese house is nearby. Some cherry trees can be seen in the distance.

ACT ONE:

A samurai warrior enters the stage, inspecting his lands and his village. He starts singing the first aria of the opera, “A Sacred Land, A Sacred Call”, extolling the virtues of the samurai and the honor that lies with his profession. “To die for the emperor”, he sings, “a duty; an honor – oh that I would be found worthy of doing so”. Two women nearby sit kneeling with their heads bowed in deep respect for this great warrior. After he is gone, they discuss the theme of the aria between them, and how they are, like him, honor-bound in their call to serve. “This is the Meaning of Life”, they sing together in wonderful, tear-jerking duet.

But events are afoot. The samurai’s son suddenly enters the stage, looking for his father after many years away in Kyoto. They meet; father is delighted to see him and wonders how he has been doing. Alas, it is soon revealed, that the son has not followed in his father’s footsteps; he has become a traveling salesman for Hershey’s Chocolate Kisses. The samurai, enraged, commands him to stop immediately and storms out. The end of Act One ends with the son, singing to a sad tune on the clarinet, “How I Love Japan; But I Love Hershey’s Kisses Too”.

ACT TWO:

The Japanese villagers are now talking among themselves and rumor quickly spreads that the samurai’s son is a salesman for Hershey’s. Some of the villagers argue that chocolate, in every form, is a good thing and Japan must embrace the influences of the new world; others argue against; when suddenly the samurai himself appears. Finding that his authority is weakening, he quickly summons his son and asks him “very well, have you changed your mind?” The son refuses to leave his new profession, and the samurai, dishonored and enraged, throws him into a bamboo prison cell. “There you will stay”, he bellows, “until you respect your honor!”

The drama develops when a team of Hershey Co. lawyers emerge on the scene, singing a transformation of the main theme, “What Ho, What Ho? What Transpires Here?” The samurai threatens to kill the lawyers on the spot, but they quickly produce a document signed by the Emperor himself, which no samurai can question, that Hershey’s Chocolates are legitimate all over Japan by royal decree. The second act ends with the samurai father falling on his knees in shame and dishonor, crying. The villagers look on terrified.

ACT THREE:

The samurai, unable to bear the shame of his son as a traveling Hershey’s salesman, has reached a decision: He will commit suicide. The villagers are mortified, and the team of Hershey’s lawyers are beaten by them until they repel them by threatening to sue them for libel. The samuari ends this quarrel by stepping onto the stage with his swords; a gray, somber figure with ashen face, prepared to do his duty. His son sings his final aria to him from the bamboo prison, “Will You Not See: a New Dawn for Old Japan”, but the father refuses to listen.

But by mistake, when the samurai reaches for his last sake glass, he accidentally grabs a Hershey’s Chocolate Kiss instead and puts it in his mouth! Apalled at first, his countenance soon changes as he realizes he has made a dreadful mistake, and everyone soon starts laughing. He lets out his son, forgiving him with tears in his face, and the opera ends with the grand finale, the duet between father and son, singing “Here is Tradition Too”, indicating that there are traditions in Hershey’s Company as well, as it is in feudal Japan, and that both can coexist together through honor and mutual respect. The villagers and lawyers combine in a final, grand chorus. The sun sets over the cherry trees which are now blossoming in full, and the curtain falls. The End.

October Sky and Two-Part Harmony

Started studying two-part harmony again today, revisiting old chapters, and learned a whole lot of new stuff about dissonances and stuff that I had completely forgotten.

So I sat down with the theme to October Sky, which I thought was a nice exercise in two-part harmony, two violins contrasting against each other.

And then, as I listened to the original, I realized that it was slightly more than that (full string section actually), so having at least completed the exercise, I sat down to arrange something more full.

Listen to it here.

Doesn’t sound that bad, does it? (Remember, computer orchestra, and the sensitive instrument treatment of an industrial robot)

Speeding Up Delphi’s TStringList.IndexOf

Delphi’s TStringList is one of the objects I love the most. If it’s sorted (StringList.Sorted := true) then you can use it to parse huge chunks of data quickly.

For instance, looping through an enormous amount of IP addresses and keeping count of how many times they appeared, is easily done using the following code (not compiled or checked for syntax errors):

ls := TStringList.Create;
ls.Sorted := true;
for ip in ipAddresses do begin
  n := ls.IndexOf(ip);
  if n = -1 then
    ls.AddObject(ip, TObject(1))
  else
    ls.Objects[n] := TObject(Integer(ls.Objects[n]) + 1);
end;

It’s very efficient. Since TStringList.IndexOf always does a binary search, it operates in log2(n) time, and using Objects as integers allows us to keep track of count without messing with the string data.

But there are things we can do to speed it up. For instance, TStringList.IndexOf relies on TStringList.Find, which itself uses AnsiCompareStr, which is a slow Windows call, taking locale and its mother into consideration. Overriding this with our own method should be worthwhile. (The code below is adapted straight from the Classes unit.)

type
  TStringListEx = class(TStringList)
  public
    function Find(const S: string; var Index: Integer): Boolean; override;
  end;

function TStringListEx.Find(const S: string; var Index: Integer): Boolean;
var
  L, H, I, C: Integer;
begin
  Result := False;
  L := 0;
  H := Count - 1;
  while L <= H do
  begin
    I := (L + H) shr 1;
    C := CompareStr(Get(I), S);
    if C < 0 then L := I + 1 else
    begin
      H := I - 1;
      if C = 0 then
      begin
        Result := True;
        if Duplicates <> dupAccept then L := I;
      end;
    end;
  end;
  Index := L;
end;

We’ve replaced AnsiCompareStr with Delphi’s own CompareStr, which is a highly optimized FastCode routine. There are some drawbacks – things will always be sorted in byte order and no case-sensitivity is done. But we don’t care about this – it can always be done afterwards; right now, speed is the main importance.

And it turns out that using the above code, in pure examples, can slash execution time with up to about 80%. Dramatic savings, indeed. In my own example, where I analyze ftp log data, I managed to cut execution time on 122 MB of data down from 7 seconds down to 3.1 seconds.

Best of all, since TStringList.Find is declared virtual, we don’t need to change any types anywhere, just do a TStringListEx.Create instead of a TStringList.Create and you’re good to go.

Jean Michel Jarre in Gothenburg

Last Tuesday, we went to see Jean Michel Jarre’s indoor concert in Gothenburg.

Jarre is one of the musicians I remember from my childhood; I bought almost every record (and then subsequently CD) with him and listened to over and over.

This concert was a smaller one, he is otherwise known for his huge and spectacular concert in Houston, Paris, Lyon, London etc. This was inside the Scandinavium arena, and it was just one night – he played in Malmö the day before, and Stockholm the day after.

It was quite a remarkable concert though. It featured a lot of old songs, as well as some newer ones. And, of course, spectacular effects with lights and lasers and a few other oddities thrown in. It was also unbelievably loud – I should bring earplugs the next time. Lesson learned. Then again, I think that goes for most concerts.

I think the most amazing thing with Jarre is that he is not using synthesizers to emulate the sound of “real instruments” – which they are rather poor that, but that he is using them as instruments in themselves. He has always pioneered ways of using them and producing sound with them that goes quite beyond everything else.

It was quite evident as he was playing some more avant-garde pieces, featuring quite an unusual sound (especially from the theremin) and evoked rather strange moods, that would have been impossible with normal acoustic instruments.

All in all, well worth seeing, although it is evident that the highlight of his career probably was in the past; the audience were mostly people in their 30′s, 40′s and 50′s.

Two Songs Published (in PDF form)

I’ve just officially published two of my songs as PDF music.

For those of you who have pianos and feel up for playing something new, be sure to head over to my “My Music” page and take a look.

If you do try it out, please leave a comment or so about what you thought. I always like to get feedback on what I do, even if it’s critical. Reasonably critical, that is.

Sing a Song of America

Started writing a song during Christmas. Got stuck on the second verse though… Anyone got suggestions?

     A
The flag still flying and I stand and cheer
     D
The red-white-blue that snaps so dear
        A
In the blowing wind
                 E
    That blows today

      A
And thinkin' of our soldiers in arms who stand
 D
Backed by prayers in a foreign land
        A
It's because of them
                E
    I'm free today

     G
The life I live in a world of fear
       D
When freedom is so strong and near
    A
My heart is pounding as I sing a song
     G      D      A
Of Ame  -  ri  -  ca
           A
          Sing a song
     G      D      A
Of Ame  -  ri  -  ca

Schoolkids jumping on the bus in the sunrise
Swallows flying in the clear blue skies
It's another day
    In my home town (?)

Farmers plowing in the fields outside...  ?

/Refrain/

I don’t like “swallows” in the second part, doesn’t feel really American, more Swedish somehow. Maybe June bugs? Dolly Parton sang about June bugs, but I don’t know if they fly in the “clear blue skies”. May need some major tweaking.

Small Piece for Oboe, Clarinet, Flute and Strings

Well, I couldn’t hold off the inspiration any longer. I sat down with my trusty Melody Assistant, from Myriad, and wrote a small little piece for oboe, clarinet, flute and strings (violin, viola and cello).

It’s very simple in structure, but this is, I think, the first time I’ve been able to make something that sounds good, conforms to common structural guidelines, and actually has a bit of structure. I’m rather proud of it.

Listen to it here, if you want to.

Bridal March from Lohengrin

Over the past few days I’ve been dabbling around with some demo versions of music software, to see how it all works together, and I must say I’m becoming somewhat impressed.

Using FL Studio and Garritan Personal Orchestra, I selected the Full Organ, added an enormous amount of large cathedral reverb, tuned the sound a little, and then sat down to record on my digital piano.

Here’s the result. What do you think?