Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Raspberry Pi for Secret Agents
Raspberry Pi for Secret Agents

Raspberry Pi for Secret Agents: Turn your Raspberry Pi into your very own secret agent toolbox with this set of exciting projects! 

eBook
R$80 R$147.99
Paperback
R$183.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Raspberry Pi for Secret Agents

Chapter 2. Audio Antics

Greetings! Glad to see that you have powered through the initial setup and could join us for our first day of spy class. In this chapter, we'll be exploring the auditory domain and all the fun things humans (and machines) can do with sound waves.

Configuring your audio gadgets


Before you go jamming all your microphones and noisemakers into the Pi, let's take a minute to get to know the underlying sound system and the audio capabilities of the Raspberry Pi board itself.

Introducing the ALSA sound system

The Advanced Linux Sound Architecture (ALSA), is the underlying framework responsible for making all the sound stuff work on the Pi. ALSA provides kernel drivers for the Pi itself and for most USB gadgets that produce or record sound. The framework also includes code to help programmers make audio applications and a couple of command-line utilities that will prove very useful to us.

In ALSA lingo, each audio device on your system is a card, a word inherited from the days when most computers had a dedicated "sound card". This means that any USB device you connect, that makes or records sound, is a card as far as ALSA is concerned—be it a microphone, headset, or webcam.

Type in the following command to view a list of all connected audio...

Recording conversations for later retrieval


So we have our audio gear all configured and ready to record—let's get sneaky with it!

Picture the following scenario: you know that something fishy is about to go down and you'd like to record whatever sound that fishiness makes. Your first challenge will be to hide the Pi out of sight with as few cables running to it as possible. Unless you're working with a battery, the Pi will have to be hidden somewhere within a few meters of a power outlet.

Next, you'll want to connect your USB microphone and keep it hidden, yet uncovered if possible, to avoid a muffled recording. Unless you expect the action to take place right in front of the microphone, you should set the capture signal to the max with alsamixer for the microphone to be able to pick up as much of the room as possible.

Now, all we need to worry about is how to trigger the recording.

Writing to a WAV file

The Waveform Audio File (WAV) is the most common file format used for recording audio.

  • To...

Listening in on conversations from a distance


What if we want to listen in on some event, live as it goes down, but from a safe distance away from where the Pi's recording—exactly like a baby monitor?

We would need a way of broadcasting whatever is recorded across a network to another computer that we can listen to. Actually, we already have everything required to do this, SSH and SoX; one just have to know how to compose the command lines to wield these powerful tools.

Listening on Windows

You should have the full PuTTY suite installed from the Connecting to the Pi from Windows section from Chapter 1, Getting Up to No Good, as we will be using the plink command for this example.

  1. To download SoX for Windows, visit http://sourceforge.net/projects/sox/files/sox/ and click on the download link for the latest version (sox-14.4.1-win32.exe at the time of writing).

  2. Run the installer to install SoX.

  3. (Optional) To be able to play MP3 files with SoX, download the decoder library file from http://www.intestinate...

Talking to people from a distance


Instead of listening in on the action, maybe you'd like to be the one creating all the noise by making the Pi an extension of your own voice. You'll be on a computer with a microphone and the Pi can be somewhere else broadcasting your message to the world through a pair of speakers (or a megaphone). In other words, the roles of the Pi and your computer from the previous topic will be reversed.

Talking on Windows

First make sure SoX is added to Windows as per the instructions in the Listening on Windows section.

  1. Connect your microphone and check the input volume of your device. On Windows 7 you'll find the settings in Control Panel | Hardware and Sound | Manage audio devices under the Recording tab. Make your microphone the default device by selecting it and clicking on Set Default.

  2. Start a command prompt from the Start menu by clicking on the shortcut or by typing cmd in the Run/Search field.

  3. We can start a monitoring loop first to ensure our microphone works...

Distorting your voice in weird and wonderful ways


Tired of your own voice by now? Let's make it more interesting by applying some interesting SoX effects!

SoX comes with a number of sound effects that can be applied to your audio and optionally saved. Some effects are suitable to use on your live voice while others only make sense when applied to already recorded files.

To see a list of all the possible effects and their parameters, use the following command:

pi@raspberrypi ~ $ sox --help-effect=all

To apply an effect, specify the effect followed by any parameters after the output file or device.

In this example, we'll start a monitoring loop on the Pi and apply a reverb effect to our voice, live as it plays back through the speakers:

pi@raspberrypi ~ $ sox -t alsa plughw:1 -d reverb

How about that? Sounds like we're stuck in a cave. Let's see what parameters the reverb effect takes:

pi@raspberrypi ~ $ sox -t alsa plughw:1 -d reverb ?
usage: [-w|--wet-only] [reverberance (50%) [HF-damping ...

Scheduling your audio actions


In this section, we'll be looking at different techniques of triggering a recording or a playback and optionally how to make it stop after a certain period of time.

Start on power up

The first method we'll cover is also the most blunt—how to start a recording or playback directly when powering up the Raspberry Pi. There isn't really a standardized way of auto-starting regular user applications on boot, so we'll have to improvise a bit to come up with our own way of doing what we want.

The Raspbian boot process is basically a collection of shell scripts being run one after the other, each script performing some important task. One of the last scripts to run is /etc/rc.local, which is a good starting point for our custom autorun solution. Right now, the script doesn't do much, just prints out the IP address of the Pi.

You can try running the script any time using the following command:

pi@raspberrypi ~ $ /etc/rc.local

We could just jam our list of commands right in...

Summary


In this chapter, we learned a great deal about audio under Linux in general and about the ALSA sound system in particular. We know how to configure and test the audio output of the Raspberry Pi board itself and how to set up our USB audio gadgets for recording.

We learned how to use SoX to record sound and store it in multiple formats, how we can avoid typing the same thing over and over with aliases, and how to keep a recording session running with tmux even when network connectivity is spotty.

Armed with only SoX and SSH software, we turned our Pi into a very capable radio—we can put it in a room and listen in, like a baby monitor, or we can let it broadcast our voice and music to the world.

We also learned how to apply SoX effects to spice up our voice or let the Pi make the noise using eSpeak. Finally, we looked at a few different techniques for controlling the timing of our sound-related mischief.

In the upcoming chapter, we'll explore the world of video streaming and motion detection...

Left arrow icon Right arrow icon

Key benefits

  • Detect an intruder on camera and set off an alarm
  • Listen in or record conversations from a distance
  • Find out what the other computers on your network are up to
  • Unleash your Raspberry Pi on the world

Description

Ever wished you could play around with all the neat gadgets your favorite spies use (like James Bond or Michael Westen)? With the introduction of the remarkable Raspberry Pi and a few USB accessories, anybody can now join in on the action.Discover how to turn your Raspberry Pi into a multipurpose secret agent tool! Through a series of fun, easy-to-follow projects you'll learn how to set up audio/video surveillance, explore your Wi-Fi network, play pranks on your friends, and even learn how to free your Raspberry Pi from the constraints of the wall socket.Raspberry Pi for Secret Agents starts out with the initial setup of your Raspberry Pi, guides you through a number of pranks and secret agent techniques, and then shows you how to apply what you've learned out in the real world. Learn how to configure your operating system for maximum mischief and start exploring the audio, video, and Wi-Fi projects. Learn how to record, listen, or talk to people from a distance and how to distort your voice. You can even plug in your webcam and set up a motion detector with an alarm, or find out what the other computers on your Wi-Fi network are up to. Once you've mastered the techniques, combine them with a battery pack and GPS for the ultimate off-road spy kit.

Who is this book for?

Raspberry Pi for Secret Agents is for all mischievous Raspberry Pi owners who'd like to see their computer transform into a neat spy gadget to be used in a series of practical pranks and projects. No previous skills are required to follow along and if you're completely new to Linux, you'll pick up much of the basics for free. Apart from the Raspberry Pi board itself, a USB microphone and/or a webcam is required for most of the audio/video topics and a Wi-Fi dongle is recommended for the networking examples. A Windows/Mac OS X/Linux computer (or second Raspberry Pi) is also recommended for remote network access.

What you will learn

  • Install and configure Raspbian OS for maximum mischief
  • Schedule a prank to happen when your foe least expects it
  • Listen in or talk to people from a distance
  • Detect an intruder with motion detection and set off an alarm
  • Distort your voice in weird and wonderful ways
  • Push unexpected images into browser windows
  • Knock all visitors off your Wi-Fi network
  • Control the Pi with your smartphone
  • Keep your data secret with encryption

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Apr 25, 2013
Length: 152 pages
Edition : 1st
Language : English
ISBN-13 : 9781849695794
Vendor :
Raspberry Pi
Category :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Apr 25, 2013
Length: 152 pages
Edition : 1st
Language : English
ISBN-13 : 9781849695794
Vendor :
Raspberry Pi
Category :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 456.98
Raspberry Pi for Secret Agents
R$183.99
Raspberry Pi cookbook for Python programmers
R$272.99
Total R$ 456.98 Stars icon

Table of Contents

5 Chapters
Getting Up to No Good Chevron down icon Chevron up icon
Audio Antics Chevron down icon Chevron up icon
Webcam and Video Wizardry Chevron down icon Chevron up icon
Wi-Fi Pranks – Exploring your Network Chevron down icon Chevron up icon
Taking your Pi Off-road Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(20 Ratings)
5 star 50%
4 star 35%
3 star 0%
2 star 5%
1 star 10%
Filter icon Filter
Top Reviews

Filter reviews by




S. cholayil Jan 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nice tricks
Amazon Verified review Amazon
Keith J. Mar 16, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a fun read. I haven't got around to trying any of the projects.
Amazon Verified review Amazon
Ivan Popov Jun 05, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Raspberry Pi for Secret Agents. Trendy title. While I wondered how serious it could be, the author's name got my attention - Stefan Sjogelid. Now that is already promising. This is the guy behind the idea, that if you're eager enough, you can build your own Linux distribution targeted at the Raspberry Pi architecture. The whole process is thoroughly described on his dedicated web site. And expectations slowly started to rise.Now with this book we're in for a treat. At least we don't get the usual starter point of view, and get some trickery instead. The book is very educating on an operating system level. Reading it, I was able to fill some large gaps in my modest but constantly expanding Linux knowledge. Once the reader starts, it quickly becomes clear that the installments built up are simple enough, yet powerful and effective. And I wouldn't be surprised if such tools are employed in a real-life espionage activities.The layout of the book is presented to be dead simple. Its significance is another story :)After the mandatory introduction of the Raspberry Pi's basics (in terms of hardware and OS) to the reader in the first chapter, the actual contents related to the main topic begin from the second one. The four sub-topics of the book are respectively: Audio, Video, WiFi and Portable Pi. The simplicity is only on the surface.Concerning the audio tasks, at first I had a difficulty to set-up a microphone due to my profanity. Without giving the proper attention to all of the Pi's interfaces I was (wrongfully) thinking that the audio output connector can deliver also an input. After a few lessons learned and a correct setup I was ready to meet some handy tools. Most of the chapter is dedicated to the SoX tool - the working horse of the audio mechanics. Combined with the rest of the tools (some of which are built-in Linux commands) and through the secure shell a lot of possible "spy techniques" are given. Those tools include tmux, espeak and at commands. They're for running SoX independently of the user's session, for speech and task-in-time automation respectively.Apart from the auxiliary elements the main idea is to be shown how the ALSA sound system is employed in the Raspberry Pi, and how easily it can be used for various projects.Regarding the video tasks, maybe the book was written and released a bit too early, because two weeks ago the guys behind the Raspberry Pi released its own camera, plugged into the dedicated CSI connector. I guess that if written today, this chapter would look a bit different. At least it could include additional information about the Pi camera and its dedicated software tools and capabilities.Well without that info the chapter is comprised of two main projects - video streaming with recording the stream and detection of moving objects.For the purpose of the first task the tools related to the framework around the UVC and V4L drivers are used in order to generate a MJPG video stream. The stream then can be accessed on the network by the VLC media player and if necessary recorded by it (without sound of course).And for the purpose of the second task the very powerful Motion software is shown to easily gather input from even more than one camera.The chapter about the WiFi networking can make a very nice addition to another of the PACKT's books, which I reviewed recently - Networking with Raspberry Pi by Rick Golden. Here the tool of the trade is the detection system Kismet. For it to work not only configuration but also building from source is required. And to be preserved consistency between the projects (and between the chapters of the book of course) it is shown a collaboration with SoX for the purpose of attaching sound signals to its processing events.Further a network mapping is done with Nmap, which leads to the logical next step - to dive into the common (or not so common) network security techniques for attack and/or monitoring with programs like Ettercap and Wireshark.In the last chapter the Raspberry Pi had to prepare its back-pack, for it was going on a field trip. Regarding the mandatory warnings for battery life, secure and low profile package and most importantly - avoiding any moisture, the portable computer can pretty quickly step outside.Setting up an ad hoc WiFi network is not difficult following the instructions in this (and partly in the previous) chapter.Two of the most interesting projects in the book (which I unfortunately haven't tested yet for some reasons) are the GPS tracking of the Pi in Google Earth, and remote controlling it from a smart-phone while tweeting its current status to the social media. Merely reading through them, they seemed to comprise a powerful, portable setup and just whet one's appetite for some future projects.The book aims to teach us how to employ the Raspberry Pi in a set up that is robust, automated and portable. All of these are actually achieved thanks to the software tools built-in or separately added to the Linux operating system. In that sense this could be regarded as the only (although not real) drawback of the book. The small computer is there, but still in the background. Everything described can be done on a regular Linux system's shell. No wires, no soldering, no bread-boards, no hardware projects. Yet the Pi is most suitable and prepared for taking these actions to the field and in real life situations. So the existing hardware is enough to become the real spy and the book just gives the vision on how prepared it is to do the job.In conclusion I can say that this book very easily achieves the goal of being funny, informative and deep at the same time.
Amazon Verified review Amazon
Retired Nokia Engineer Jan 08, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book for projects with my teenage grandson. Really cool projects for the Raspberry Pi computer.
Amazon Verified review Amazon
David R. Hassall Oct 25, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very interesting book ... Can't wait to try out some of the projects in it.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.