Sunday, November 17, 2013

New Painting

I'm pausing the programming after about five solid days working on it, with moderate (but not good enough) results. Instead I decided to finish this simple painting; "An Experience that isn't Shared is the Same as No Experience", oil on MDF, 420x318mm.

Wednesday, November 13, 2013

Soundy Stuff

I'm supposed to be recording music this week but I've got caught up with enthusiasm for sound programming, as my new music will be vocal and I'd like some vocal processing options. I write my music on my own software, which is brilliant because it's cheap AND it gives you the freedom and power to add new bits as needed. Today I wrote a vocoder, which turned out to be quite simple; it's a bank of band-pass filters that filter the voice at different frequencies, then boost a sound wave (music) in those frequencies by an amount proportional to the volume of each filter.

It has sixteen filters. I wondered what would happen if I changed the destination frequencies but kept the source ones the same. I got some interesting results when boosting the mid range but didn't experiment further. I must try more of that one day...

My next task though is to pitch correct a vocal sample. Playing a sample at any pitch is easy so the hard part is determining the root frequency of the voice. I started by pondering (and head scratching) at Discrete Fourier Transforms for a couple of days. This bamboozling maths made sense; from what I understand it's basically that there are two ways to represent a complex waveform; as amplitude and time, and as a sum of sine and cosine waves of different frequencies. Both represent the same wave, just in two forms, the time and frequency way ("domain" mwahahahaha). This made me wonder if the universe behaves like this, as it sparked off a connection with waves and particles; odd how waves are seen as timeless and infinite but particles are discrete and finite, yet they are the same thing seen in different ways. It made me think that the Fourier transform has an important role in physics, and that any equation for the universe must be two equations, both different that say the same thing in two ways. After all, everything is one wave, the whole universe is a complex wave.

I'll leave that prediction to history and get back to my speech test. So, I need to work out the frequency of a bit of singing. I've split the sound into lots of sections. After lots of reading it seems there are several ways to identify pitch. The frequency way had appeal because I'd not done it before; that basically divides the sample into root frequencies, so a pure note would be a clear spike. The thing is the voice isn't a pure note anyway, so it's not necessarily easier than looking at the normal time-based sample.

So I think I'll start with normal sample data. Speech/singing isn't always pitched anyway, lots of hissy sounds like "sh" "tch" "sss" are white noise really and could be ignored. I'll need some A.I. to guess a good pitch, or even think that it isn't a pitch, and discard it.

Some principles mused...

A singing voice might be off but it's not going to be very off so it's more likely to be close to the desired pitch, or it's more likely to be at the previously sung pitch (rarely will a song jump up two octaves). You could go further and guess that a pitch will be musically pleasant, guessing that a tune is probably in the right key. This is the start of artificial intelligence routines...

So, I've got a few starting strategies. At best I want to determine the difference between ideals; a sine wave and white noise, and if it's a sine wave then determine the frequency. What options are there to detect either?

A sine wave flows smoothly, white noise jerks about. I thought of a fish flowing along the wave, heading up or down for the next hillock or trough. The fish can't turn as rapidly as the sound wave. If the fish stays close to the target path then it's a smooth wave, if it's always turning or miles away then it's more likely to be random noise. Perhaps the fish could be rewarded when it's close to the wave with accumulated points, but those fall away if the fish becomes sad at unable to track the wave (or rapidly turns; the pain of the anxious fish means white noise psychosis). So, a volume tracker of some sort is one strategy.

Another is to pick random points every so often... if that fish headed for waypoints every so many samples, then on a sine wave the results would still be easy going; a quantized sine wave would still appear smooth, a noisy one still random. Does that help?

And frequency. I thought I could track zero crossings, the times that the wave jumps above and below zero, then track similarity. This would be a great indicator on perfect source data; on an ideal sine wave the periods would be identical; and totally random on white noise. So a reward number for regularity would be good, together with a proposed period.

(EDIT: What if a sound wave had a good repeating pattern rather than simple repeats? I expect a few natural sounds might do that, or do they?)

Looking at different windows of samples might be a problem too, chances are there will be a few periods of pitch on there. An ideal size to analyse must be sought; one short enough to find only one sound/syllable, but long enough to give a good indicator of periodicity for low notes. Perhaps window periods that match the tempo of the song would be an idea. An idea that a musician and never a mathematician would even pick, as powers of two are best, and they're not at 120 B.P.M. (I wonder why 44,100hz was chosen as CD frequency and not 65,536hz for example? Maybe it's something to do with the laser of a compact disc, or a transistor or something.)

Well, I'll give it a go tomorrow. Please excuse my meandering thoughts but I wanted to type them out and I thought that this might be useful to other signal processing people in future. There's no conclusion to this blog post ... well, not tonight :) Happy dreams of sound fish to you!

Friday, November 01, 2013

A Big Post about Music Production and The Invisible Man

Well, my Iris is still not finished, despite days of work. Each step seems to just lead to another, but the end is in sight. I'm reminded that Fabergé didn't make his eggs, he might have designed them, and quality checked them, but he had a vast team of experts to actually do the craft work. That unskilled Carl Fabergé.

Now, speaking of Kraftwerk I'm in music mode. Yesterday I saw a call for the National Songwriting Competition and decided on the spur of the moment to enter. I'm not very keen on this contest as I suspect that it's there to leech money from the vast numbers of people eager for music success (I base this judgement on A: the fact that they've spammed every email address I have with calls for entries, and charge a lot for them, and B: I thought their critique of my last entry One Day was poor, it seemed they'd not even heard the song never mind analysed it). That aside, a deadline is fun and inspiring, and I want to write and record a new album this month, so I thought I'd record a new song in the four days until closing date. I re-wrote (the music to) a 2009 song a few days ago so I chose that.

The song is a plodding ballad that grows in power. In my head the backing was a piano, and I began with "Imagine" style chords (two then one then two etc.) this was a bit monotonous (sorry, John) so on the piano played something grand like Tchaikovsky's 1st piano concerto, but made the low notes single notes, then realised that it was similar to the Bohemian Rhapsody intro. I stuck with it, then added alternating flutes. In my head the song had the power of Calypso 3 by Jarre, a climb of mountains up and down in vast sways, and I toyed with booming slow percussion and considered a vocoded part like a titanium sound cannon at the start of each pattern.

The song is in three bits, but one interesting feature is that the chorus really should be quiet because it's about invisibility, being unnoticed. A vast chorus wouldn't fit the meaning yet songs demand a chorus that's more special than the verses. The chords in this one are pleasant, so I wanted something gentle that enhances them, like Karl Jenkins Palladio, or Vivaldi, and a harpsichord was ideal, stabbed in regular beats. It has a gentle feel (the modern ability to make it quiet is really a godsend for this wonderful instrument) and also a high narrow register that means it goes really well in songs without interfering with other instruments.

The last part was integrating the piano and harpsichord. At one point I toyed with having either, not both, but I found that the depth and richness of the piano really improved the verses, the song sounding icy spidery without it. In the chorus, alongside the harpsichord, I added high tremulating strings, ghostly. The lead in (the "I drift" lines...) was powerful, initially a large piano stab (Tchaikovsky/Grieg! again) then more subtle. I added some warm brass there, echoes of Comfortably Numb, which is a song with similar mood and themes (I experimented with an electric guitar solo in the middle too, which I might add later, but I didn't have the time and there was no real need for one; would it add to a sense of invisibility? That most famous and wonderful solo in the Pink Floyd song, does it really convey numbness? Not really, you could say that it's a wailing at the forces of malevolent emptiness, a banshee at the oppressive doctor, but it was more a showy rock part I think, an aesthetic element, than anything on an intellectual or emotional connected with the song).

I added and removed lots. At one point a large echoing stab took place on each chord change of the chorus, but it made it too dramatic when the chords alone convey enough. I played with the Strawberry Fields style flutes (more inspired by Beethoven's 6th and my Infinite Forest music, which is full of sighing alternations) but left them in because it added something to the song generally, I hummed them when I took them out so they must be worth keeping. The intro is short but was extended a bit, and some casual ambient speech added there. A wailing ambulance (a Vangellisism from Blade Runner) was toyed with but unused. The tempo changes were the last thing, a gentle slow into the chorus, so important. The deadness of tempo and volume expressiveness is the curse of modern pop. Then finally a booming piano end (ala I Don't Like Mondays).

Overall though, the whole song is all of those influences and none. If anything, the tune and mood is more like Nobody Home than Comfortably Numb on that Pink Floyd album, but with a soupcon of a power ballad by an 80's Heart, the verse with a relaxed feeling like Love Letters Straight From Your Heart...

To hear the final tune, you'll have to wait until I learn to sing it (I must learn fast!) and make at least a crude video for YouTube (though this song would benefit from some special effects - yes?)

Here, in the mean time, are the words to The Invisible Man...

No parts.
No broken clockwork heart.
No bits of hair to depart.
That's me.
That gap inside the crowd.
A snowflake inside a cloud.

I drift inside a fog all day.
I close my eyes to find out that the world won't go away.

There's no-one to believe me.
There's nothing left to leave.
My body is clear as air.
There's no eye that can see me.
I blinked and I was gone.
I woke up to find myself

Too bad.
My happy life went sad.
I've turned from obscure to mad.
I call,
but make no sound at all.
The mirror just shows the wall.

Is this what it feels like to die?
Appealing to a frozen sun inside a silent sky.

no-one to believe me.
There's nothing left to leave.
My body is clear as air.
There's no eye that can see me.
I blinked and I was gone.
I woke up to find myself