Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Raspberry Pi for Secret Agents - Second Edition
Raspberry Pi for Secret Agents - Second Edition

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

Arrow left icon
Profile Icon Sjogelid
Arrow right icon
zł59.99 zł87.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (14 Ratings)
eBook Jan 2015 206 pages 2nd Edition
eBook
zł59.99 zł87.99
Paperback
zł108.99
Subscription
Free Trial
Arrow left icon
Profile Icon Sjogelid
Arrow right icon
zł59.99 zł87.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (14 Ratings)
eBook Jan 2015 206 pages 2nd Edition
eBook
zł59.99 zł87.99
Paperback
zł108.99
Subscription
Free Trial
eBook
zł59.99 zł87.99
Paperback
zł108.99
Subscription
Free Trial

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 - Second Edition

Chapter 2. Audio Antics

Greetings! Glad to see that you have powered through the initial setup and can 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...

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 fishy thing 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...

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 has to know how to compose the command lines to wield these powerful tools.

Listening in Windows

You should have the full PuTTY suite installed from the Connecting to the Pi from Windows section in 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 at http:...

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 in Windows

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

  1. Connect your microphone and check the input volume of your device. 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 cool 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...

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, with 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, it 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...

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 devices...

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 fishy thing 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...

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 has to know how to compose the command lines to wield these powerful tools.

Listening in Windows

You should have the full PuTTY suite installed from the Connecting to the Pi from Windows section in 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 at http://www.intestinate...

Left arrow icon Right arrow icon

Description

This book is an easy-to-follow guide with practical examples in each chapter. Suitable for the novice and expert alike, each topic provides a fast and easy way to get started with exciting applications and also guides you through setting up the Raspberry Pi as a secret agent toolbox.

Who is this book for?

This book is an easy-to-follow guide with practical examples in each chapter. Suitable for the novice and expert alike, each topic provides a fast and easy way to get started with exciting applications and also guides you through setting up the Raspberry Pi as a secret agent toolbox.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 27, 2015
Length: 206 pages
Edition : 2nd
Language : English
ISBN-13 : 9781784391386
Category :
Languages :

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 : Jan 27, 2015
Length: 206 pages
Edition : 2nd
Language : English
ISBN-13 : 9781784391386
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 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
$199.99 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 zł20 each
Feature tick icon Exclusive print discounts
$279.99 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 zł20 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 376.97
Penetration Testing with Raspberry PI
zł133.99
Raspberry Pi Sensors
zł133.99
Raspberry Pi for Secret Agents - Second Edition
zł108.99
Total 376.97 Stars icon
Banner background image

Table of Contents

6 Chapters
1. Getting Up to No Good Chevron down icon Chevron up icon
2. Audio Antics Chevron down icon Chevron up icon
3. Webcam and Video Wizardry Chevron down icon Chevron up icon
4. Wi-Fi Pranks – Exploring Your Network Chevron down icon Chevron up icon
5. Taking Your Pi Off-road Chevron down icon Chevron up icon
Index 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
(14 Ratings)
5 star 71.4%
4 star 7.1%
3 star 0%
2 star 7.1%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




AT Jan 13, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent Stuff Indeed!
Amazon Verified review Amazon
Mr. Alexander Knox Nov 11, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great read. Just waiting for my Pi to arrive so I can use in earnest
Amazon Verified review Amazon
Manly Geek Oct 30, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Made the Raspberry Pi fun to explore. I bought my first picture via pre-order but only now want to get it out and play.
Amazon Verified review Amazon
Niel Apr 05, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
My kids love these cool Pi projects.
Amazon Verified review Amazon
Amazon Customer Jul 21, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Let me state for the record that I am not a secret agent and have no affiliation with any security service, so I'm unable to assess this book in terms of its application in the world of espionage and covert operations - but, as a maker, hacker, nerd, techie, experimenter, perfectly normal guy who likes playing with electronics (description varies depending upon who you talk to) I can happily say that this is a very, very good and useful book if you want to do interesting things with Raspberry Pi.From the basic setting-up of the Pi it moves to audio and covers, more or less everything you're likely to want. Then on to video, adding the Pi Camera, recording video, playing video, motion detection, multiple cameras, video on the Internet, automated operation – it's all there.Got WiFi and want to dig around in it, control access to it, do more with it and don't want to get bogged down in really deep technical stuff? Yep, that's included too and goes as far as encrypted messaging – in the most understandable application I've ever seen.This book even covers the things that everyone else seems to take for granted – enclosures and battery power for a self-contained Pi (what good is a secret agent in search of a power outlet?).On a technical level this book is excellent and it's very, very readable – well worth buying and enjoying. (but you didn't hear that from me – OK?)
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.