Feeds:
Posts
Comments

Posts Tagged ‘algorithm’

Sonatina

The above is a visual representation of the opening measures of Muzio Clementi’s sonatina, Op 26, No1 as rendered by sf2sound — a kind of command line synthesizer that takes a stream of solfa symbols as input. This is homework for an eventual ear-training program. In any case, here is the audio file:

theme

One of the challenges has been in shaping the waveforms of the individual notes so that they fit together without making annoying pops. A simple exponential decay did not work, although that is good for making the sound more or less percussive. What I discovered is that (at a minimum), one has to shape the attack and release of the note. For the moment I have done this by shaping the wave form with a simple quadratic function.

I’ve been experimenting with various settings and algorithms in order to get a better or more interesting sound. The sound file you hear is slightly more complex than the other ones I have posted. In previous version the sound was either (1) an exponentially damped sine wave, or (2) the former with some kind of shaping of the amplitude profile as mentioned above. In the current version, higher harmonics are mixed with the fundamental tone. Here is the code snippet of quad2samp where the mixing occurs:

// Form the sine wave and add harmonics to it
samp = sin(W*phase);
samp += -0.4*sin(2*W*phase);
samp += +0.2*sin(3*W*phase);
samp += -0.1*sin(4*W*phase);

I’ve observed an odd but likely well-known phenomenon (or is it an illusion?). When the sound consists of a shaped sine wave, i.e. no (deliberate) harmonic mixture, I find it painful to listen to it, even at relatively low volumes. Painful in the most elementary sense of the word, not because the poor artistry of sf2sound! When I mix in higher harmonics in some degree, the (physical) pain diminishes. I suspect this because the acoustic energy in the first instance is concentrated near a single frequency, so a small number of hair cells in the inner ear are overstimulated. When the same energy is spread among the various harmonics, albeit in unequal proportions, it is also spread over more hair cells, so that individual cells are not overstimulated. Perhaps someone who really knows what is going on can comment.

I’ll close with one more image — a close-up shot that shows how the wave forms from two adjacent notes join smoothly. The jaggedness of the sound wave reflects the addition of higher harmonics to the sine wave representing the fundamental tone.

HH

Sonatina: close-up

Advertisements

Read Full Post »

A small change in our algorithm, just a tweak to four similar and adjacent lines of code, has made what for us is a big esthetic improvement in the “pieces” produced by our app. The change was in fact an accident that was meant to apply to a small part of the art engine, but which affected everything that is drawn. Local versus global, as they say in politics, mathematics, and computer science!

We’ve taken the caption for the frame below from the name of jazz standard. There is a wonderful recording by the Bill Evans Trio. Now if we could just permission to have this recording play along with little show produced by our app! That would be ever so cool. Alas, it will never happen.

HH

Blue in Gree

Blue in Green

Read Full Post »

Hello friends! Some of you have asked “Where’s Hakon? We don’t see him on wordpress these days, we don’t see him at the neighborhood bar, the laundromat, or even the pizza parlor.” Well, a few persistent souls have observed my comings and goings, but the truth is prosaic, even boring. I have been writing code. The bad news is that the coding for this software project has been exhausting, with the exhaustion prolonged by the kinds of things that always go wrong with a many-person effort (whose name and nature must legally, but also mercifully go unmentioned). The good news is that the project is finished! The final commit was made last Monday, and the suits have approved our work. May their names be praised!

Kinetic Art

I am now liberated, or at any rate well into the liberation the process. Spent the weekend cleaning the apartment and my mind, playing the piano, and, well, writing some code. But the latter is strictly for pleasure. A friend and I are doing a little kinetic art app for the iphone — see a one-frame screen shot on the left. Think of it as a kind of algorithmically created film in which the user/viewer can involve himself if he wishes — selecting parameters, shaping sequences, etc. It has been fun — a combination of art, mathematidcs, and coding. All of which are arts of course!!

I doubt our little app will make much money, but we are having a blast doing it. I will keep you posted. We hope to release it in the next month or two.

Speaking of film and art, my friend’s son, who was at one point interested in mathematics, has now switched to film. Below is his first YouTube post. Both live video and stop motion animation edited together. It is amazing what kids can do with the software tools available now. I remember the days when one of the main tools was a razor blade!

Time is never long to die

Well, time to get some sleep. Hope to spend more now time blogging and doing other things both significant and frivolous.

HH

Read Full Post »