Feb 112013

Well, if you re-sample in the time domain, then you get a frequency scaling of the sampled wavetrain. If you re-sample in the frequency domain, then you get a time scaling of the sampled wavetrain. Beautiful symmetry.

A periodic sample of a waveform with a finite length implies a circular system. It could just as easily be (and in fact most often is) simple truncation.

Truncation and circular domains both imply infinite “tail” problems in the domain transformation between frequency and time. The farther your snippet is from the tails or rollover boundaries, the more the tails aren’t visible in the morphed snippet. This is just as true for a circular as for a truncated domain.

A classic way to get a snippet to behave well in both domains is to pad with long silence before and after the snippet for what ever convolutional operation you might perform. This becomes intractable for large snippets (but then it isn’t a snippet is it?)

The next solution to the problem is to chunkify the source and call it a big snippet where a middle snippet is taken out of the bigger snippet after you morph it with a staggered overlapping averager between the two. This gets to have subtractive problems at higher problems which leads to a periodicity of noise. So some folks find loudness boundaries upon which to chunkify.

I will start with sound-font stuff, which qualifies as a snippet sized piece. Then the only choice is whether to think of it as circular or truncated.

 Posted by at 7:27 pm
Jan 152012

The ALSA API gives you strictly user-land access to the ALSA driver machinery. It is an evolved thing, so it looks like a girraffe/platypus from Saturn’s moon Titan. I won’t be satisfied until I can get bit-accurate playback and capture. JACK makes the machinery “just work” and much more sensibly; but I just don’t trust it not to munge the sample. Furthermore, the “don’t worry your pretty little head about it” method that both deploy, and then the lord-knows-what resampling algorithm and data formatting under the hood … How can an OCD control freek like me get the job done?!?!

But what we can say for ALSA is:
It works.
It is above average stable.
It is everywhere you want to go.
It CAN be bit-accurate.

I assume you know what …

audio, pcm, interrupts, Nyquist’s criterion, blocking, critical code, mutex, circular buffers and lots of other computer science and signal processing

things are all about.

Because a sound card is also an evolved thing, there are lots of variants on how to get sound samples out to analog (or standard digital) wires. There are lots of cards with lots of capabilities. That’s a hairy mess.

Also because of all of the different cards, there are lots of ways to fire up and extinguish a stream of data to get out (or in) the door.

Because there are lots of uses of sound, there are a few ways to represent it in a digital stream. That’s less of a mess, but it still needs structure and enumeration.

So those are the two jobs that the ALSA PCM API takes care of. Generally speaking it is the Management Plane, the Control Plane and the Data Plane.

 Posted by at 6:20 pm
Dec 112011

I still hate the new buggyness of Unity. That’s my gig, though, so here I am railing against the bug system in the Isle of Man. They put this one as medium where I believe it should be at DEFCON INFINITY.

The Launcher forgets that I have an app running. I put it down to minimized. It’s gone … I have to kill it then re-launch it. I can NEVER minimize the app. It seems to be more common with apps that are running on other frameworks … Java … Ruby … GTK+ (just kidding on that last one) etc.

Just run:

unity --replace

It has one big drawback, that sometimes it pushes the app window above the top ribbon. Let’s hope that 12.04 fixes lots of these trashy little inconvenience bugs that sloppy coders would triage as WAD. I have nothing but sympathy for the folks at Canonical and the extended community, but I’m just saying.

I found this little trick amongst many other great ones at MakeTechEasier.


 Posted by at 11:09 am
Oct 232011

I’ve been struggling to like Unity.

I have one tip that has gone a long way to getting me to like it. It is in the CompizConfig manager (Synaptic or apt-get installed, since CompizConfig doesn’t come with Gnome3 .. sudo apt-get install compizconfig-settings-manager …) If you set the Desktop -> Reveal Mode to Top Left, then it really takes some digging to get the launcher to fly out, which stops my annoyance. You have to first fly your cursor way up to the utter top-left corner in the Global Menu. Then fly it (no clicking please) downward holding it against the left edge. Only a little bit down from the Global Menu gets the Launcher to fly out. It takes some practice and this is not for the mouse-dexterity challenged among us.

My big problem with the launcher was that it would fly out at the most annoying times when I was working in the left side. Anjuta makes big pop-ups that activate it. I have my Firefox controls all the way left and that gets it to fly out.


Sep 112011

It seems like there are a few razors out there:

First Razor, on the subject of gods: [God | Physics]
–We are an artifact of an intentional mind.
–We are an artifact of unintentional physics.

Second Razor, on our existence: [Here | NotHere]
–We actually exist.
–We are only made to believe we exist by the joke played by the First Razor.
Hay man, don’t go all Descartes on me … You know what I mean.
René: Good evening bartender.
Bartender: Hey there René, want a beer?
René: I think not.
- – POOF! René no longer exists! . . . ar ar … humor.

Third Razor, on our own intention: [Willful | Toys]
We have free will.
We don’t.

Fourth Razor, on our power: [Empowered | Feckless]
We can effect change
We can only watch

ed. note … a razor is a ideological dividing line that clearly cuts objects into one of two classes. q.v. Occam’s Razor.

Every other postulate is a combination of these ideas (I think.) They were figured out before history. We aren’t talking anything new here. The Matrix movie is a combo of God vs. Physics where God (the Matrix) is flawed and needy. The unaware ones don’t know how spoon-fed their existence actually is, but they do have choices, but if they choose badly, then reality will be discontinued on that thread and remade to satisfy the needs of the computer existence. Dreamed, limited choice, but in a matrix of physics that has physical humans and physical computers. But they never said what the computers’ existence was composed of. I think it would be very poetic if the computers side-tracked some of the human brain-power to be computers, and that’s why they so desperately needed their human hosts. I never got into The Matrix well enough to know all of these points, and it doesn’t matter because my point is that The Matrix doesn’t have any really new ideas.

Sep 042011

Some time in the years near Y2K, HP published an advert that had a picture of the hallowed lab on Addison in Palo Alto (I used to stroll by the place many Friday evenings after dinner) and Carly (according to the legend these were largely her words) had regurgitated some words, which you can see at Wikipedia’s report of the Rules of the Garage.

Here’s the rebuttal:

“Rules of the Lab:
Have a Dream.

Invent anything that needs it.
Don’t tolerate NIH.
Change the rules whenever they need it.
Beware of rule changes.

Share everything new.
Declare your errors.
Write everything down.
Don’t hide anything.
Neatness counts.

Keep the tools unlocked.
Trust your friends, colleagues are for board rooms.
No politics.
No bureaucracy.

Keep working.
Work the way you like to work.
Focus on the dream, not the tools, not the process, not the money.
Doing something, anything, is better than doing nothing.

The lab defines a job well done.”

— Duncan Gray

What Carly hid from us was the fact that all earth-shattering product starts by having some curious, selfish, nerd go and do something in which only the nerd sees value. The only “customer” that those geek society founders (of which I am a card carrying member) address are the other geeks that they know will like this thing.

Google – I wish I could find the stuff I have even though I didn’t organize the storage.

Apple – I wish I had a fun toy with one of these computer things in it.

hp – I need an oscillator, Bob … do you know of one I can afford?

The lines that the hp advert proposed are just wrong, written with a string section playing in the background to bring a tear to our eye because they seem so wholesome.
The startups that fail the most are started by marketing; which is a statement only supported by my sample space of 10. Of these, two failed and both of these were marketing starts. The success rate is high because I landed in these startups after they were pretty far along the way (except for one of the fails, where I landed within 9 months of its start.

There were startups that couldn’t fail. Motorola, TI, National Semi, et. al. couldn’t fail … oh … wait … that darned Transistor was invented by a team of weenies who were told by their bosses to just make stuff and who cares if it can succeed. Bell Labs “GOT” that good things start from pointless surprises. IBM still knows this.

That’s all for now.

Aug 222011

I’m working on an application in Linux under gtkmm using ALSA to generate and analyze audio signals.  My first goal is to find out the “quietness” of a microphone.  I’m an Ambient kind of guy, so I want to record quiet things and have the least amount of hiss that is possible.

One first instinct was to go read reviews and find what the outside world thought was the quietest, then I thought “Hey, I worked in the audio industry … Those reviews are not accurate for what I want and the manufacturers are telling us what the reviewers want to hear.  So I’ll figure out what quietness means myself.”

So here I am, ready to analyze. It’s all about air and its interface to electronics.  I can make electronics that’s as quiet as a 50Ω resistor at -200ºC.  So the other part of the hiss is the air.  Finally, there is some mechanical thing that I have to account for in the microphone itself.  This is akin to antenna gain, radiation resistance more precisely.

Mr. Johnson, back at Bell Labs in the 1920s, measured the noise, then Nyquist himself went and figured the physics behind it.  But that’s a digression.  I want to know mic quietness.


If I put a sound generator in space, I get some energy amount at a location where I put a mic.

If I control the generator, the space and the mic location, then I can get a consistent comparison between microphones.  The only thing that will muck this up is if the shape of the microphone causes reflections that reverberate in the space that then come back to pollute the sound that the microphone receives.  This is solved by making an anechoic space and separating the generator and microphone by as ridiculously large a distance as the anechoic space can tolerate.

Now, I can say that all of the 20 microphones have some reference amplitude of output for a given highly repeatable (though not known for its absolute) sonic amplitude.

Interesting side experiment – - – do this with various temperatures, humidities and barometric pressures.  The generator’s coupling variance can’t be taken out of the mix, but it’d be interesting.

Next, I put the mics into a concrete box, say 1 foot on a side with 3″ thick walls.  Hang the box from the ceiling on the loosest springs I can get.  Connect the mic to the box wall with really fine wire and connect the line to the mic pre with really fine wire.  Make sure the room’s quiet and measure the spectrum of the microphone.

To check the box attenuation, put a speaker and a microphone in the room near the box and run a frequency sweep at pretty high amplitude.  That gives the gain of signals outside the box into the box and ultimately its microphone under test.  Then record the signal spectrum that the very same microphone that listened to the loud room noise while I do the quiet test of the mic under test.  Hopefully, the gain from outside to inside (calculated from the loud noise sweep test) is of such good attenuation, that the noise spectrum measured in the quiet test is ridiculously above the attenuated version of ambient room noise.

Shoot!  Now I have to ferret out the proximity effect of those poor little air molecules bouncing off of the wall of the container right back into the box to change the noise into the microphone.  If you grok electronic transmission line or RF propagation theory, then this amounts to the certain knowledge that if an antenna is put into an environment that has a near-field reflector, the impedance is different, therefore the noise floor.

But … This is all relative, so I can get the relatives of the mics to the extent that their radiation impedance isn’t part of this.

Next is the short-circuit/open-circuit test.



Aug 212011

I was just thinking that the world goes crazy all the time … and … there seems to be no damned good reason for it … so ….

Reality 1 – Money is an agreement.

Reality 2 – Goods and Services like Wheat, Designing, Gold (because it’s conductive and not susceptible to corrosion,) Repairing, Potato Chips and Latex Paint are all objects that can do REAL things.

Reality 3 – People cannot produce Goods in any useful volume.  This is semantics, bear with me.  I produce hair and other more unsavory things. I do not “Produce” electronic products, I modify resistors and capacitors and solder and circuit boards that I bought from someone else with my hands to pass a stereo amplifier on to someone else.

Reality 4 – People can produce services.  These are very important and include Knowledge and Labor.  The production of Knowledge comes from experimentation and the production of Labor comes from working our fingers and backs to the bone.

For the most part, in the modern era, the Labor is “Educated Labor” in the form of properly timed button pushing, steering wheel turning or cow swatting.  This is in opposition to “Fundamental Labor” such as lifting rocks, picking fruit or digging dirt with our hands.  This is a Transformational Labor that makes something less useful (iron ore in the ground) into something more useful (iron ore in a train on the way to the smelter.)  My own personal Fundamental Labor is typing and speaking whereas my Educated labor is the transformation of unorganized groups of people into organized groups of people … Yes, I’ve had the operation to remove chunks of brain … I’m a Manager.  I had been an Electronics Engineer designing cool electronic widgets for the telephone system, professional audio and medical industries.

Caveat Lector:  I very strongly believe that there is no service done by any person that can be called less important than any other.  Cleaning toilets, picking peaches, sweeping streets are just as important – often more so – than designing rockets or sewing up wounds.

So What’s Money Good For?

Good question.  Start with Barter!  Could you store enough cheesecloth from the cheesecloth maker to pass on to a cheese maker when you needed to fix the cheesecloth maker’s toilet.  Then will you find someone who makes diapers when you need them WHO WILL TAKE CHEESECLOTH AS PAYMENT?!?!  No, I didn’t think so.

There are two very important terms in our world … Currency and Make-a-Market:


Way back in the day (1200 ace. back in the day) people didn’t trust anyone but themselves.  To trade their furs and get food meant that they first found someone who wanted furs BEFORE they went to someone who had some nice bread.  That fur trapper (this is the days BEFORE fur traders) needed to take something from the person who needed the fur that he was damned certain he would be able to take, at his leisure, to the bread person.  He had to be sure that the bread person would take whatever this was.

The “whatever this was” has some important properties.  Property 1 – It has to be immediately recognized as what it is.  Property 2 – It has to be small despite its representation of the value of a large thing.  Property 3 – It has to last a long time, so that it doesn’t disintegrate on your way from the fur-coat maker’s shop where you sold your furs to the baker.  Property 4 – It can’t be faked – more easily manufactured as a token than the work of hunting, killing and skinning that beautiful little ermine weasel.  Silver, copper and gold did all of this.

1.  It’s easy to know that what you have is copper, silver or gold.  They have a recognizable smell & taste (at least the copper and silver do,)  their softness, texture, color and weight just aren’t found in any other objects.  Fools’ gold got it’s name because it is so easily known not to be gold that only a fool could be … fooled.

2.  Tiny bits of these metals wind up worth a lot of value (but for really neurotic reasons.)  This was true like-for-like even when you melt them down and make a bowl or jewelry out of them.  I say neurotic because they didn’t do anything but provide decoration outside of their role as coinage.  Until electricity, conductivity was irrelevant.  They are useless for weapons or tools (except for copper, which is only marginally useful.)

3.  They are really inert compared to wood, bone or leather.  Despite their relative softness compared to stone or steel, they don’t wear down in decades of time.

4.  Related to the ease of identification, it turns out that there is nothing readily available that can mimic these three elements.  Just the luck of physics, this one.

Make a Market

A salesperson makes a market.  This is someone who does this work either from the comfort of home, or in a nice big building with a recognizable logo on it.  From home, this person just knows people.  People who buy things and people who sell things.  Either way – the quasi-anonymous shop with a shingle or the more personal Trader with a capital T – the salesperson is a hub of transfer rather than a manufacturer.  If there is great need for fur clothing, then there had better be large numbers of fur trappers and large number of fur article manufacturers.  If you could limit the number of people you have to go to as a trapper or as a manufacturer, then you can do your work rather than hunt down people to by from or sell to.  So there are fewer traders than buyers (usually) though there can be more traders than providers without loss of efficiency.

Without either currency or salespeople, we wouldn’t have quality of life with penicillin, golf clubs, ska, light bulbs and everything.

So what’s the Crazy Come From

Remember how I said that the value of the metal flakes was neurotic (might also be pronounced “wildly inflated”?)  Well, the crazy comes from not knowing what’s important about the currency coupled with believing that looking good is more important than being good.

Property 1 – Easily recognizable.  This can come from a spoken word as easily as from a metallic sheen.  The stamp we put onto paper money.  The handshake we do when we say “it’s a deal.”  Nobody gets this one wrong, so it’s not the culprit today.  BUT … its the fundamental reason why its value gets inflated … it’s pretty and rare and unique despite its uselessness.

Property 2 – Representation of value in a compact form.  Notice that I didn’t say “Intrinsic value in a compact form?”  THIS IS THE BIGGEST PROBLEM IN PEOPLES’ MINDS.

Property 3 – Value is constant.  This isn’t inflation/deflation, but rather that one dollar stays … one single dollar no matter what else happens.  It doesn’t magically become 1/2 dollar because it got rubbed down.  The coinage suffers this, though the weight loss over a century of pocket rubbing is single-digit percentage weight loss.  It was a great crime (once we stopped weighing gold flakes for trade) to scratch the edges off of coins to make gold or silver for ourselves.  That’s why valuable coins have ridges and other patterns on their edges.

Property 4 – Difficult to fake.  One way to do this is by agreement!  If nobody every made counterfeit money, the world would be a better place.  So, we have to make some huge investment in plastic, laser etching, secret threads, fancy ink or whatever else to make it difficult for North Korea to build the same machinery.


The crazy comes from believing that when we run out of money that we can’t do good things like make wheat or cars or toys or whatever else.


Peoples’ talents didn’t go away, just the money.  We have come to believe in the money more than in our talents, drive, inspiration, spirit, integrity, accuracy, honesty, diligence …  !

Nov 282010

What is distortion

In audio, there are many kinds of imperfection, but broadly, they can be categorized into correlated and non-correlated.

Correlated (as in correlated to the signal being amplified) must be broadband. This includes things like frequency response, phase response, non-linear distortion and amplitude-generated noise.

Un-correlated is stuff like power-supply hum and hash, the local AM radio and the various noises in the amplifier circuitry that are due to underlying physics. These are:

* Johnson noise (conductive phonon soup due to bulk electron population.)
* Shot noise (electrons popping past difficult barriers under the influence of an electric field.)
* Flicker noise (a very special kind of noise associated with electron herds lurking near a precipice.)

And how we analyze these does, and should, vary by the type of disturbance being considered.

To the point, Gray … stop being such a show-off.

If the disturbance is very near to a single-frequency signal under consideration, then it is Near-Carrier noise.

Phase and Amplitude

Here’s a shocker to some people … Did you know that the real world has no phase or frequency?!?!

Ayep! These two are derived quantities that depend on a whole raft of assumptions. First they assume an infinitely long reference sinusoid. Second, they assume that your signal has a “supposed to” about it (it’s a Zen thing to believe that any signal should oscillate.) There was a lot of fundamental research during the time that international timekeepers were trying to make more and more accurate clocks, and they found that oscillators are really controlled chaos generators. They came up with lots of concepts like Allen Deviation to characterize carrier motion. It was about the same time that Mandelbrot was doing his ground-breaking work on the statistics of market prices that he discovered chaos.

How does this digression relate to phase noise? Well, phase noise is dominated by flicker phenomena at arbitrarily close-in frequencies. Here’s the really scary part. For arbitrarily long observation periods, the phase will deviate by arbitrarily large amounts. Don’t worry, though; for the flicker amplitudes we deal with, it will take scores of duotrigintillions of universe lifetimes to make your oscillator explode.

Is It Complex DC, or Is It a Carrier Wave?

Well, if we demodulate a received sinusoid with a perfect closely matched sinusoid, then we get a bunch of (hopefully) low-frequency stuff with both an imaginary and a real component. In polar form, the magnitude (radius) is the amplitude and the argument (phase) represent amplitude and phase noise of the received signal, respectively.

This can be performed for various criteria. A minimax approximation requires an iterative thing, while a LMS approach can be done in one go† The procedure:
* Demodulate into I * Q
* Phasor to R and Theta, without letting it wrap around 2Ï€
* LMS this data into phase, frequency, drift and amplitude, fade etc.
* Negate the LMS elements back to the carrier

Now you’re left with a master-sinusoid and a receive data set that produce the standard things like drift and fade. The residue after aligning the reference carrier to the “DC parametric” impairments of fade and drift can be analyzed, once again in the r/θ domain, for near-in phase noise. Look at as amplitude noise and as phase noise independently then correlate the two for any underlying garbage physical process to fix.

† Because this is a cyclic thing, LMS can go crazy trying to find the bottom.

Finally, and I just can’t get lots of people to understand this, the whole Demod thing is non-linear and you will have to iterate to get the fade and drift residue to precisely equal zero.