Apress - Smart Home Automation with Linux (2010)- P22 potx

5 206 0
Apress - Smart Home Automation with Linux (2010)- P22 potx

Đang tải... (xem toàn văn)

Thông tin tài liệu

CHAPTER 2 ■ APPLIANCE HACKING 83 ■ Note All devices should be grounded accordingly, not as shown in the figures for clarity. Conclusion In the same way you can build complex and evocative systems using a couple of well-chosen pieces of hardware, so can you build smart automation tools with a minimum of effort. By using alternate input devices, such as pressure mats and joysticks, you can change the way you interface with your home. By adding alternate output devices, perhaps powered by old game consoles, you supply visuals to areas previously inaccessible to full-scale desktop PCs. And the introduction of robots and computerized welcome mats adds a level of previously unknown of coolness to your home. C H A P T E R 3 ■ ■ ■ 85 Media Systems Incorporating the TV and the HiFi The most visible part in any home environment is the media system. Ever since real fireplaces fell out of fashion, the TV or stereo system has become the focal point of most living rooms. They are also the devices with which we spend the most time interacting. It is therefore essential you understand the possibilities of these devices. As with all consumer electronics, the feature sets and prices change on a daily basis. Therefore, I’ll concentrate primarily on the necessary features and inner workings of the machines without detailing specific makes and models, since by the time you read this, other machines will already be available. The Data Chain The simple act of “playing an album” changes significantly in the home automation field. Not only is the location of the media itself unconstrained, but it’s also the place where you can listen to it. This has been exemplified recently with iTunes allowing you to play music on several different computers and with Spotify providing a music-streaming service allowing access to various music tracks from your home PC or mobile. 1 If your interest in music is casual, or chart-based, then these services are often enough. But for many people, they have albums in their collection that are either rare or obscure enough to not appear on any commercial-led web site. Or they might prefer to have their music data stored on their own computers, lest the company go out of business, change the terms of service, or lose connectivity in some other fashion. When this is the case, we need to provide a way of getting the music from a hard disk to the human ear. This is the data chain. There are four steps in this chain. The first step is the data itself. This is the directory structure of WAVs, MP3s, or OGGs that represent the music (or other media) in your collection. This data is then read by a server (which is the second step) before being distributed (the third step) to one or more speakers in the house. The fourth and final step is when the human gets to hear (or see) the media. This model still applies when playing music on a portable music player or desktop PC, although for a desktop PC all the logical units are held within one physical box. 1 Access through a mobile phone requires the paid-for premium service. CHAPTER 3 ■ MEDIA SYSTEMS 86 Extracting the Data Often known as ripping, this is the process where the media, usually stored on DVD or CD, is converted into a computer-friendly data format, ready for playback. Many pieces of software are available, so I’ll cover these with an example only. Compact Disc A CD is the easiest and quickest format by far, because most of the constituent parts are available within Linux. A tool, such as abcde, can automatically do the following: • Extract the audio as a WAV file • Convert it to OGG Vorbis • Determine the artist and album • Download and apply the tags automatically • Name the files accordingly All that is then necessary is to copy the files to your filesystem. I personally always extract my CDs to a separate (local) folder for reasons of speed—it’s faster to write locally and then copy en masse since it means my server isn’t dealing with lots of small write requests when I might be wanting to stream something else. This also gives me an opportunity to manually change the files in case there’s a problem, as sometimes happens when the album is longer than the standard 74 minutes. 2 For mass ripping, you can write a short script that saves time by automatically opening and closing the CD drawer. It might not sound a lot, but the initial hurdle in extracting your music collection is psychological; the thought of swapping many hundreds of CDs and renaming and tagging each file is daunting. Since the audio is ripped at the speed of your CD or DVD drive (and not the duration of the album), you can extract a whole disc in about 5 to 10 minutes. And with the online track listings database (CDDB, which combines the start time and duration of each track into an ID for the disc as a whole), the tagging process is also automatic. Sometimes there are duplicate IDs, which requires manual intervention, but most of the discs can be processed automatically using the -N flag, as shown in the following script. The abcde script also supports arguments that allow you to specify the format of the filenames, if this is important to you, along with layout information for handling albums with multiple artists. 2 You have to terminate the hung process and manually tag the file. CHAPTER 3 ■ MEDIA SYSTEMS 87 #!/bin/bash while : do echo Insert next disc read x cdcd close abcde -N cdcd eject done DVD With the more complex format of DVDs and the industry’s perpetual insistence that encryption is necessary, the ripping of DVDs has an extra requirement, 3 namely, libdvdcss2. This is a library that circumvents the copy protection on encrypted discs, which most commercial movies use. Its legality is uncertain, so the major Linux distributions have erred on the side of caution by not including the package. Instead, the library must be downloaded separately, either from an alternative repository or from compiled source. Naturally, I must take the same “safe” approach and can only tell you how you might install it, if you find the files on a web site somewhere. On Debian, for example, an extra repository is added by placing a single line in the /etc/apt/sources.list file: deb http://www.debian-multimedia.org lenny main This is followed by the following traditional process: apt-get update apt-get install libdvdcss2 Sometimes you have to download and install the package manually. That command line invocation would be as follows: dpkg -i libdvdcss2_1.2.10-1_i386.deb Alternatively, the source installation would be as per the INSTALL file, probably something like the trinity of this: ./configure make make install # as root 3 You might also need the Win32 codecs package (w32codecs). . can build complex and evocative systems using a couple of well-chosen pieces of hardware, so can you build smart automation tools with a minimum of effort. By using alternate input devices,. computers and with Spotify providing a music-streaming service allowing access to various music tracks from your home PC or mobile. 1 If your interest in music is casual, or chart-based, then. significantly in the home automation field. Not only is the location of the media itself unconstrained, but it’s also the place where you can listen to it. This has been exemplified recently with iTunes

Ngày đăng: 03/07/2014, 20:20

Mục lục

  • Prelim

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewers

  • Acknowledgments

  • Introduction

  • Appliance Control

    • Making Things Do Stuff

    • X10

      • About X10

      • General Design

      • Simple Case

      • Standard Case

      • Fully Automated

      • Assigning Addresses

      • Using Multiple House Codes

      • Device Modules

      • Controlling Lights

        • Lamp Module (LM12U)

        • Bayonet Lamp Module (LM15EB)

        • Wall Switch (LW10U)

        • MicroModule with Dimmer (LWM1)

Tài liệu cùng người dùng

Tài liệu liên quan