Monday, October 08, 2007

So much for the laundry

About the Mic and C4 I was going to talk post about. Before hand, I think it would be interesting to write down some basic sound sampling theory. So if you are interested in why a CD records at 44.1kHz, 16 bits, read between the ***'s

***
The standard upper and lower boundaries for human hearing are 20Hz to 20,000Hz. If you test people's hearing, however, you don't find many people that can reliably hear signals above 16kHz, but 20kHz is the standard cited upper limit. Have you ever looked at a CD and wondered what the deal is, with the 44.1 kHz on it? You can mathematically demonstrate that if you pluck points out of a continuous time signal at a certain frequency (called the "sampling frequency"), you can perfectly reconstruct the components of the signal that are below half of that sampling frequency.

That is to say, if you are measuring the sound at 1000 Hz, (that means taking a measurement of the pressure every 0.001 second), you can reconstruct all the components of the signal
below 500 Hz perfectly (well... in a perfect world, anyway). However, if a signal in the sound is present above half the sampling rate that screws everything up. The frequency gets folded around (Fs/2) (oh no! An equation on my blog!). So, if I am sampling at 1000 Hz, and I am trying to measure a pure 700 Hz signal, it will look like a 300 Hz signal. An 800 Hz signal would look like 200 Hz, 999 would look like 1 Hz, etc. So, if you had a perfect analog-to-digital converter and you could perfectly convert your electrical signal from the microphone you would still have no idea if you were looking at a 5 Hz signal, or a 995 Hz signal, or a 1005 Hz signal, etc. In fact, there are all sorts of hurdles you have to cross before getting your measured signal into the digital domain. To name a few:

1) The output of the microphone does not perfectly correspond to the pressure it is measuring.
2) In addition to changing the signal the microphone will add garbage signals to the sound, called noise. This is impossible to avoid, for various reasons that I could go into if anyone is interested, but won't if no one is.
3) The electronics between the mic and the A/D converter are going to filter the data from capacitance/inductance, etc. And also, if you have components in the signal path that are non linear you can add harmonics, etc.
4) The signal must be anti-aliased.

Anti-aliasing is a very important step, and it is always always done in the analog domain, before the signal has reached the A/D converter. An anti-aliasing filter is what allows you to know that your digital 300 Hz signal is actually 300 Hz and not 700 Hz. For example, an anti-aliasing filter for the FS=1000Hz system above would allows signals lower than Fs/2 to pass into the A/D converter, but block the signals above 500 Hz. This eliminates the ambiguity. However... no anti aliasing filter perfectly knocks off everything greater-than-or-equal-to Fs/2. The filters have a slope, so in other words, 400 Hz signals would pass through more or less unaffected, 400 might be 10 times smaller than normal, and 500 Hz might be 60 times smaller, 600 Hz 100 times smaller, etc. (Those numbers are not worked out, they should follow a logarithmic scale). Furthermore, the filters add a slight time delay (the time delay vs. frequency can be used to calculate the "phase response" of the filter) to the signal that depends on what the frequency is.

There is a special type of filter called a "Bessel" filter that has a nice sounding phase response. However, it has a very slow roll-off. For this reason, you need to begin the roll-off much lower than Fs/2 if you want to avoid aliasing.

Back to CD's - the sample rate is 44.1 Khz, remember? 44.1/2 = 22050Hz. Bet you the 100$ I wish was in my pocket you can't hear 22050. So why this overkill? It allows for the fact that the anti-aliasing filter needs to have a lower roll-off than Fs/2 to prevent anti-aliasing. For example, I could set my Bessel-filter 3dBdown at 16kHz, and maybe have enough attenuation at Fs/2 to prevent significant aliasing, without adding crappy phase delay or dramatically affecting frequencies you can hear.

Ok, so that is a short description of what the whole sampling rate thing is w/a CD. Now the 16 Bit, 24 Bit, 32 bit nonsense... I mean... stuff.

Ok, I'm getting tired of writing this out. And this part is more complicated. 16 bits tells you that you have 2^16 different voltage levels that you can approximate your signal with. For an ideally working 16 bit A/D signal that functions between say -5V to +5V, you would have a stairway (65536 steps high), of values between -5 and 5 volts that your measured signal would be forced into.

This is where it gets more complicated. Forcing the signal to stick to one of these 65536 values is essentially the same as adding "white noise" to the signal (again, with some minor caveats), and determines a dynamic range of the system (another key statistic) - the ratio of the loudest to quietest signal that the system can detect. However, back to reality: you rarely ever get 16 good digital bits of data from a 16 bit system. Most of the time, if you measure the noise floor of a 16 bit A/D converter, you end up finding that only about 14 of your 16 bits have real, good, data. If you want a real 16 bit converter they are painfully expensive, and they normally work by taking data from a 20 bit converter and hacking off the last 4 bits.

But, then you see advertisements for these 24bit 96 kHz systems. Let's get this straight right now - I've looked at specs from tons of high quality A/D's and none I've ever seen or even heard of give you 24bits of good data while measuring at 96 kHz. What they mean is that they give you 24 bits of "data." However, perhaps only 20, or 16 or... even only 12 of the bits have actually good information in them. It's kind of a marketing scam. Some companies, like TI, are honest about the actual noise performance of there A/D converters but in some other cases you have no idea and you have to measure for yourself. There are several limitations imposed by the nature of the A/D process that make a real 24bit 96kHz system difficult to realize in practice. (For example, if you want to measure a signal fast, you need a very small capacitance to store charge quickly. However, the fact that the capacitance is small makes it noisier, which cuts down on the dynamic range, etc).

And, if you want to know something really surprising, most audio A/D front ends are only a few bits (as opposed to 16 bits), but they they take advantage of the fact that you can shape the noise floor of the output, sample at MHz, and then integrate/average the signal, which does several nice things: 1) it gives your analog front end much more grace concerning the anti-aliasing filter, and 2) lets you down sample using digital filters which give you a lot more control. These A/D converters are called "Sigma Delta" converters, and were invented because the regular method was running into theoretical noise limitations past 16 bits or so. Basically after averaging, these can get the equivalent dynamic range of something like an 18 bit converter, give or take a few maybe. But 18 bits sucks to work with digitally, 24 bits is much more convenient. So the AD converter sends out a package of 18 good bits followed by 6 crappy bits, in a 24 bit word, and you get your "24 bit converter." Tadaaa!

***

Ok, yeah, so back to the mic. You always run into a problem with condenser microphones: to raise the frequency response you need to increasing the tension on the diaphragm, decreasing the compliance of the volume behind the diaphragm, decrease the mass of the diaphragm, or strut the membrane so that only higher modes can be excited. All of these modifications decrease the sensitivity. If you have a condenser microphone adjusted so that the microphone has a flat response to higher frequencies it will have a lower dynamic range (this equates to a higher noise floor, after you normalize the amplitude). Again, to poke a little more fun at the audio industry that I am now glad I am not part of: your bajillion dollar Sennheiser microphone that has a response to 50 kHz? Well... frankly your ears are probably more sensitive to the increase in noise from the additional 30 kHz of response, than they are to the extra high frequencies that the mic can measure (and, in all likely hood are getting filtered out somewhere in your A/D or D/A system in playback).

So, if there is no benefit to using a microphone that measures up to 50kHz over a microphone that measures up to 20 kHz, why build a microphone that measures up to... 1,000,000,000 Hz??

Well, first off, you would not want to use this to mic your guitar. You would hear a very loud "Hsssss" in the background. The mic isn't meant for the studio, it's for measuring... [bum ba da dum...] plastic explosive blasts and tank rounds! The goal is to measure the front of the blast waveform as accurately as possible. I don't want to post actual wave forms because I don't want people knocking at my door. But, it turns out that there are frequency components far in excess of what a standard microphone can measure - even B&K's ultra nice/expensive 1/8th inch mic's (one of which I destroyed 2 years ago by accident) that can measure up to 150 kHz. This microphone is a little less sensitive than the others, but it can measure extremely high frequencies. Maybe I'll talk about how it does it, and take apart the guts and show what's inside later, but for now, here are shots of the microphone itself:

The shiny dot in the center of the disk is the active portion, where the coated mylar is stretched over the backplate. The disk around the diaphragm is there because I know how to digitally compensate for the disk, but I don't know how to compensate for the crap behind the disk. So I made the disk large to prevent a lot of reflections from the other stuff from being really significant. The box behind it has all the preamp/electronics stuff (the capacitance is high so it doesn't have to be right next to the diaphragm). The arm is the clamp used to mount it on the pole, and the grey plastic thing is the cap so the membrane doesn't get damaged.


This is a closer view of the top. Inside the cylinder behind the top is sort of a mechanical system to allow the person to fix the diaphragm and stretch the diaphragm over the backplate appropriately.

Anyway, many fun hours spent on the late for this one. I'm gonna try to make another one, and I'm pretty sure it will look a lot better than this one, got a lot of good ideas. But first, I need to build an ultra low frequency infrasonic microphone to work w/my piston phone first. Hmmm sometimes work gets me down, but when I'm thinking about it now, maybe it's really not all that bad :)

Friday, October 05, 2007

More interconnectedness, frat tires, Mhz mics, and C4

Recently I was in at an army base measuring various explosions, C4, and bullets fired from shells like these among others:

(Pic not taken on the base. That would have been illegal.).

While working in the gear tent, I decide to check the voltage of the marine batteries powering our equipment. I probed the batteries with the meter:

[Hmmm. 11.32 volts. A little low...] "Hey, Dr. Gabrielson, the batteries are down to-"

"11.32!" Someone yells.

"Yeah, how did you-" I poked my head out of the tent. 50 meters away some guys are measuring the distance of blast pencils from the suspended C4 sticks.

"This one is 11.32 meters from suspension point Chris."

If you have read my blog (thank you Andy・Woelke・Ben・Matt) any over the past couple years, you know that I love recording the things that happen in my life that are just too weird to be true... you know, like when you are working on homework and you realize your phone hasn't rung in hours, and you have a strange feeling that it's about to ring. And then it does. What are the chances of someone making a completely unrelated measurement, and coming up with the exact same answer as me at the exact same time, and shouting it right when I was about to say it?? The odds are smaller than winning the lottery. My professor even thought it was weird.

But it was just volts and meters. Completely meaningless.

I dunno. I see this sort of thing happen so often (why don't other people write this sort of thing down? I don't believe crazy things happen only to me. Is it that I'm the only one actively looking for them?) . It reminds me that everything is part of something bigger.

Which is good. For maybe the first time ever, a girl that I was really, really strongly attracted too, returned this. And how I met her, and the circumstances around it involve many strange stories of the type I'm talking about. It was too weird. Like something out of a movie, and you think: "This isn't too good to be true. This is too good to not be true."

But, she turned me down.

Of course there was a lot of complexity to the situation, and like someone just mentioned, a guy never thinks rationally in this sort of circumstance. Thinking about it with more clarity now, it makes sense and I can understand/respect her choice.

***

Anyway, one of the tires on my Ford went flat yesterday. My spare is also flat, apparently. And, while biking to ICF this evening, I hoped a curb and my rear tire went flat. 3 flat tires. Good thing I like walking eh? Well, a few hours from now a friend will help me get my spare out of storage and we'll go to the Firestone.

So, it's 3:00AM, I just finished my "Japanese lessons" (dubbed anime) and I guess I'll have to post about the C4 and Mhz mic later.
じゃあ ね