I spent a bit of time over xmas updating my iStethoscope iphone application
(which links to The Undercover Scientist book) and adding many of the features
requested by users. As usual, for those interested in the gory details, I'll explain how it
works here.
The core features of the program remain unchanged, although I optimized the code to
make it a little more stable. Please see the entry for version 1.1 and versio
n 1.0 for details of how the audio processing works.
In version 2.0 I've added several major new features. The first and most significant is a
shake-activated phonocardiogram. This appears if you give your iphone a left-right shake
(that's a sharp movement in the x-axis accelerometer). It then replays the last 8 seconds of
audio in a loop, while displaying the wave form and animating a grey bar to show which part
is currently being played. The waveform is automatically scaled to fit, so eight seconds of
quiet sounds will show a nice wobbly waveform, but a single loud noise may cause such a
big spike that the rest of the pattern is scaled to nothing. To stop this happening when
you've been listening to your heart and then remove the device causing a loud noise, the
scaling ignores the last second of audio. So for best results when viewing the waveform
corresponding to your heartbeat, hold the mic in place for 8 or more seconds when you can
hear a clear sound, then remove and shake within one second. The phonocardiogram is
cancelled with a second shake, and recording of audio begins again. Inevitably the
resolution and sampling of the waveform is not perfect (there is only room to display 920
spikes out of 352800) so the display should be regarded as an approximation. Not all
information can be shown, so the absence of a spike on the display does not mean there is
none there. (The animation uses Layers - the waveform is written once into a
bitmap called a layer and then that bitmap is redrawn over the new grey rectangle.)
Note that there's an iphone bug which affects all apps - if the iphone goes into standby
for more than a minute while the program is running, the accelerometer is switched off. If
you find the program does not respond to movements, restart the program and it should
work again.
Another major new feature is a new mode: "Accelerometer." I added this mainly for ipod
touch users who have no microphone and so can't use the other modes of the program. In
"Accelerometer" mode, front-back vibrations (z-axis forces) are mapped to audio tones. A
small movement gives a low tone, a bigger movement gives a higher tone. Sensitivity
automatically changes according to the average movements, so several seconds of small
movements will result in the iphone becoming more sensitive. This mode is more for fun
than anything serious - there are too many interfering subsonic vibrations everywhere for
you to detect your heart reliably in this mode. Because it uses the accelerometer to make
noises, the shake-activated phonocardiogram is deactivated in this mode (the shaking
iphone symbol disappears in the corner to tell you this).
The final change to the program is the addition of help images on the first screen
(press the undercover scientist) and more hints in the pop up window about making the
most from the program. I've done another youtube video below, enjoy! If you need help,
leave a comment here and I'll post a reply.
The US version of The Undercover Scientist is different to all the others around the world.
They changed the title to Why Sh*t Happens. We'll have to see whether people appreciate
this - here's the first review of the book in USA anyway:
Why Sh*t Happens:
The Science of a Really Bad Day
Peter J. Bentley. Rodale, $16.95 (304p)
ISBN 978-1-59486-956-3
Everyone has one of those days when
nothing seems to go right, but why? Unlike
others who have broached the question,
British computer science guru Bentley
(Digital Biology) actually escorts readers
through a really bad day, exploring the
science behind all the little things that
can go wrong: he looks at why you slept
through the alarm (to explain the nature
of sleep); why you then slipped on the
spilled shampoo (a look at the nature of
cleansers and lubricants); why that torrential
downpour soaked you on your way to
work (a look at the cycle of water in nature).
This journey through the day, if
sometimes strained (getting chewing
gum stuck in one’s hair on the bus), is a
neat device for explaining the science behind
everyday things such as how clothing
is woven and why fabric is so strong
(until it rips when you bend over) and
how capsaicin in chilis fool the body and
provoke a burning sensation. Each chapter
ends with a brief tip on how to avoid
future mishaps. Hopefully, readers and librarians
won’t be put off by the title and
miss Bentley’s reader-friendly explanations
of the science behind everyday life.
(Apr.)
W. F. Howes are making the unabridged audio book version of The Undercover Scientist.
One week ago I went into the studio and saw what it was like to record the audio for an audio book. I
discovered quite how important that word "unabridged" is... They tell me the book will be about 12
to 15 hours long - that's rather more time than I want to spend in front of a microphone, trying to
sound interesting and exciting. So we've come to a compromise - they'll use an actor called Roger
May to read it, and I'll record an interview to be used at the end, and for publicity.
It's often quite funny reading online reviews of books and programs. It seems many people
who
write book reviews don't bother reading the books, and many people who review software
don't
bother reading the instructions. For example, there have been several people who seem to
find
the challenge of listening to their heartbeat using my "istethoscope" program just a little too
much... one person even seemed to think that it was impossible and could never work. (I
think if I
was going to make up a fictional functionality I would be a bit more imaginative...) So just to
show
how easy it is, I made a little video recently:
My USA publisher, Rodale, has just sent me a pile of advance proofs of Why Sh*t
Happens - their version of The Undercover Scientist. It's a smaller format so the
book feels more chunky and pocket-sized. Their intention is to get a few more nice reviewers'
comments for the cover of the final version and generate a bit of advance interest. They also
plan a 20-city radio satellite tour and some print features, so I may be busy next year. And on
the subject of interest, my iphone application has generated so much extra traffic on my
websites that I'm in danger of exceeding the monthly maximum in the first week... I've had to
reduce the size of all images (which has the advantage that everything downloads faster) but
at this rate I may have to switch to UCL servers soon.
My iStethoscope iphone application (which links to The Undercover
Scientist book) continues to do extremely well in iTunes. It was the 11th most popular
utility today out of over 700, with over 30,000 downloads in the last week. To celebrate I've
created a second version which introduces a new listening mode: heartbeat pure. This uses
different filtering to enable much clearer deep sounds, while removing all hiss and crackle.
Although it may sound a little quieter that's because it's playing only the lower frequency
sounds. I've found that it enables the 3G iphone to hear heartbeats much more reliably and
count the heartrate much better than before. Using a good pair of headphones instead of
the white earphones, you can also use the iphone like a real stethoscope and place it on
your chest. (Remember the microphone is on the bottom, so that's the part that needs to be
pressed to your chest.)
As before, for those interested, I'll explain how it works here. There are several minor
updates in v1.1: The gain control at the bottom now automatically sets itself to the optimal
level to help you listen without harming your ears. The first time the little undercover
scientist appears, he gives instructions. I've adjusted the filter settings for "clear sound" to
improve sensitivity. The link on the first screen to my book now works when you tap the
name. But the main change is the new "heartbeat pure" mode. This uses an improved low-
pass filter and no high pass filter at all. The result is that only very low frequency sounds
remain audible and the resulting sound is much more pure and clean without any hiss. The
3G iphone suffered from hiss quite a lot, which prevented people from finding their
heartbeats so easily and confused the heartrate monitor. Using this new mode, the heartrate
monitor is much better, and it's much less fussy about accuracy with the microphone - you
can still hear a heartbeat even if you are not so good at finding your pulse or artery. The
downside to this change is that more processing is needed, so I had to increase the slight
delay between the sound and playback fractionally compared to the last version. Users
should also take care using the new "heartbeat pure" mode with volume and gain on
maximum - if you brush against the microphone you may find the result very loud, and it
might make the sound glitch a little. (You should restart the program if the sound continues
to glitch.)
Hopefully everyone will enjoy the application, and remember that learning to find your
pulse is a valuable skill. If you found the app interesting do please check out the popular
science book that accompanies the program: The Undercover Scientist.
I was wondering why I have been getting sooo many downloads of the istethocope iphone
application from Italy and France in the last few days. I've now discovered why - there's a
nice little
review of the application online here:
My "istethoscope" application (which allows you to listen to your heartbeat and features a
little
undercover scientist giving little facts now and again) has now been on iTunes for just under
three
days. To my surprise it's had over 7000 downloads already and is in the top 30 Utilities in
the store.
I'm hoping it will help people become aware of The Undercover Scientist book, so
it's very
exciting that the app is popular so far.
If any reader of the book or user of the program has any ideas for other free
"undercover
scientist" programs for the iphone, or something for the "Why Sh*t Happens" US version, let
me
know!
For fun I recently created an application for the iPhone - iStethoscope which
basically turns the device into a stethoscope, allowing you to listen to your own heartbeat
(or other quiet sounds nearby). I've linked it to The Undercover Scientist book,
using the little scientist cartoon as a friendly way to show (hopefully interesting) facts
related to sound and hearts.
For those interested, here's a little detail about how it works. The program takes audio
from the microphone, buffers it for a very short amount of time and then plays it. Playing is
continuous as new audio is received, so all processing has to be performed on-the-fly as
the data is copied from input to output buffers. Inevitably a small delay results from this
buffering process. Several types of processing happens - a low-pass filter is applied to
remove hiss, a high-pass filter is applied to remove rumble, a heartrate monitor listens and
attempts to count repetitive noises separated by quiet, and an automatic volume control
listens for excessively loud sounds. If a loud noise is detected, the filter parameters are
adjusted to reduce the volume. These adjustments are then slowly returned to normal when
only quieter sounds are detected. The different modes correspond to different filter settings
and different gain settings for the volume control. "Heartbeat" uses a heavy low-pass filter
to let low thuds through but remove most higher- pitched sounds and reduce crackle of
microphone against skin. "Conversation" uses low and high pass filters to let through middle
frequencies like those transmitted by telephones. "Clear Sound" uses minimal filtering to let
most of the sound through unchanged. The heartrate monitor is active in "Mute" and
"Heartbeat" modes. Because it cannot use extreme filtering to make it work better (that
would make it sound awful when listening) it does get a little confused if there is any crackle
or noise. It only displays the pulserate when it is reasonably sure it's right, so you have to
position the microphone carefully to make it work.
Simultaneously to all this on-line processing, the controls are monitored and now and
again the little undercover scientist is animated in a separate concurrent thread. It's all
optimized to work with as little delay as the processor can handle. But if a different program
or operating system process decides to use the processor or audio, this can screw up the
audio buffering and cause minor audio glitches. (If that happens the program should be
restarted to reset the buffering.) The best way to improve speed and avoid problems like this
would be to do all processing in the iPhone audio Digital Signal Processor instead of in
software; unfortunately the API does not permit this.
The application is now freely available on iTunes, just search for "istethoscope" in the
AppStore. Please leave feedback if you download it!
For the last week or two, more people than usual had been asking me about The Undercover
Scientist. Today one of my students explained why - Waterstones has the book on their
recommended reading list. I had a look for myself this evening... he was right.