Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Debian GNU-Linux Bible.pdf
Скачиваний:
22
Добавлен:
21.02.2016
Размер:
7.08 Mб
Скачать

Multimedia

Computers are no longer just workhorses that process data, crunch numbers, or calculate the half-life of some

atomic particle. Computers are also a great source for entertainment. You can use them to listen to music, watch movies, and so much more.

This chapter broadly covers these topics, showing you how you too can enjoy the pleasures of watching, listening, and experiencing multimedia on your system.

Listening to Audio Files

One of the greatest joys that a computer offers people is the ability to listen to music. Granted, a computer is an expensive radio or CD player if that were all it was used for. Many people listen to music while they work, like yours truly. This is a far cry from the muted sounds that emanated from the internal speakers of older computers.

The computer’s capability to process sound has grown dramatically. Today, sound cards not only play back music, they can help to create music as well — through the Musical Instrument Digital Interface (MIDI) port. This is just one of the capabilities of the modern sound card.

The average sound card can record and play back sound by converting audio tones into digital data. The quality of a recording depends on the number of digital bits that are used when converting from sound to digital data — generally 8 or 16 bits. Another factor affecting quality is the rate at which the sound is sampled. The sample rate range is 5 kHz to 44.1 kHz, or 5,000 to 44,100 samples per second. The faster the sample rate, the better the quality of the recording, which also means the larger the size of the resulting data file.

Most sound cards can operate in full duplex mode, which means that sound can be recorded and played back simultaneously. This mode enables you to use a headset and talk live with others. Also included with the cards are various connections:

10C H A P T E R

In This Chapter

Listening to audio files

Listening to music

CDs

Making your own music CDs

Listening to and creating streamed audio

Watching videos

Using live voice chat

204 Part II Working with Debian

Line-in — This port enables the use of external audio devices such as cassette decks, LP turntables (old-fashioned records), or any other device to connect to the computer for recording or playing back sound.

Line-out — This allows the analog signal to output to an external device such as a tape recorder, stereo system, or some other device capable of receiving the audio signal.

Speaker-out — Headphones and powered and nonpowered speakers connect here.

Mic — This port accepts a microphone for recording audio input.

Joystick/MIDI — This port connects to a joystick (usually for game play) or some type of MIDI device.

Internal port — This provides an input port for audio devices internal to the computer. Normally, this is for the CD-ROM’s audio output. Newer sound cards may have internal ports for a couple of CD devices, plus additional ones for auxiliary devices yet to be installed.

Sound cards require a driver to operate, which normally gets built into the kernel. The module that enables sound for Debian is called soundcore.o and should be added when first installed. It can also be added after initial installation by using insmod /lib/modules/2.2.17/misc/soundcore.o from the command line. Beyond that, the sound card may have a specific module driver. A variety of drivers are provided in the Open Sound System (OSS) module named sound.o. Other separate drivers available with the kernel include Ensonic, Creative Ensonic, ESS Maestro, Intel ICH, S3 Sonic Vibes, and Turtle Beach, just to name a few. A complete list can be found at www.linux.org.uk/OSS.

If you are installing a generic Sound Blast sound card, you will also need to load soundlow.o and set the parameters for the device. For the easiest method for installing and configuring the sound parameters, use the modconf interface. This is the same interface you used when you first installed Debian. Here is an example if the parameters you may need to add:

io=0x220 irq=5 dma=1 dma16=5 mpu_io=0x330

These parameters specify the hardware settings for the card. The io=0x220 indicates the base IO address for the card. The irq=5 specifies the card’s interrupt. The dma=1 and dma16=5 indicate the direct memory access (dma) settings. The mpu_io=0x330 refers to the IO address for the Musical Instrument Digital Interface (MIDI) connection on the card. You should refer to the manufacturers specifications and to the card’s configuration for your sound card.

Note For sound cards not found among the list of free drivers, go to www.opensound. com. This site offers downloadable sound drivers for evaluation. If you like them, you can buy them.

Several devices are used when accessing different features of the sound card, including the following:

Chapter 10 Multimedia 205

/dev/cdrom — This is a device used for listening to audio CDs.

/dev/dsp — This stands for digital signal processor, which is used by many processes for handling sound.

/dev/mixer — This is the sound mixing device.

/dev/sequence — This provides the interface with MIDI, GUS, and FM devices at a low level.

/dev/midi — This device provides the raw access to the MIDI port.

/dev/sndstat — This device indicates the status of the sound card.

/dev/audio — These are devices compatible with the Sun workstation audio implementation.

The dsp, mixer, midi, and audio device names have more than one device associated with them. This allows for multiple sound devices within the same machine. Regarding the /dev/dsp device, there also exists /dev/dsp1, /dev/dsp2, and /dev/dsp3 devices. Each of these devices can represent an additional piece of hardware.

You can determine the status of the sound card and the drivers loaded by using the following:

cat /dev/sndstat

The previous command results in the following output:

OSS/Free:3.8s2++-971130

Load type: Driver loaded as a module

Kernel: Linux hoth 2.2.17 #1 Sun Jun 25 09:24:41 EST 2000 i686 Config options: 0

Installed drivers:

Card config:

Audio devices:

0: Sound Blaster 16 (4.13) (DUPLEX) Synth devices:

Midi devices:

0: Sound Blaster 16

Timers:

0: System clock

Mixers:

0: Sound Blaster

This code shows which drivers were installed for the sound card. In this case, Sound Blaster drivers (sb.o) are indicated for the audio, MIDI, and mixers. Remember that if no devices are listed, no drivers are loaded.

206 Part II Working with Debian

Note Most computers have, at minimum, a PC speaker. The kernel can be configured to use that speaker for audible beeps and dings. You can get the source to add speaker support as a patch to the kernel at ftp.infradead.org/pub/pcsp.

Audio file formats

Audio files come in several formats. Some applications work with a specific format, while other applications can play a variety of formats. For convenience, an application called SOund eXchanger (Sox) enables you to use over 20 types of sound files by converting them into a usable format (see Table 10-1).

Table 10-1

Sound formats used by Sox

Format

Description

Format

Description

extension

 

extension

 

 

 

 

 

aiff

File format used on Apple IIc/IIgs

au

Format used by Sun

 

and SGI, which may require a

 

Microsystems.

 

separate archiver to work with

 

 

 

these files.

 

 

 

 

 

 

cdr

Used to create audio master CDs

cvs

Continuously Variable Slope

 

 

 

Delta modulation, which is

 

 

 

used for speech compression

 

 

 

such as voice mail

 

 

 

 

dat

This contains the text representation

vms

Used to compress audio

 

of the sound data.

 

speech

 

 

 

 

gsm

The Global Standard for Mobil tele-

hcom

Macintosh HCOM files

 

communications (GSM), which is

 

 

 

used for some voice mail applications.

 

 

 

 

 

 

maud

An AMIGA format that allows 8-bit

ossdsp

A pseudo-file for the OSS

 

linear, 16-bit linear, A-Law, and

 

/dev/dsp device driver for

 

u-law in mono and stereo.

 

playing and recording files

 

 

 

 

raw

Raw sound files containing no

sf

Used by academic music

 

header information about the file

 

software such as Csound

 

 

 

 

smp

Turtle Beach SampleVision files

8svx

The Amiga 8SVX musical

 

used to communicate with MIDI

 

instrument description format

 

samplers

 

 

 

 

 

 

Chapter 10 Multimedia 207

Format

Description

Format

Description

extension

 

extension

 

 

 

 

txw

Yamaha TX-16W sampler used for

sb; sw; ub; Raw formats with

 

sampling keyboards

ul; uw

characteristics. (sb signed byte;

 

 

 

sw = signed word; ub =

 

 

 

unsigned byte; uw = unsigned

 

 

 

word; ul = ulaw)

 

 

 

 

voc

Sound file used for Sound Blaster

wav

The native Microsoft sound

 

 

 

format

 

 

 

 

wve

Format used on the Psion palmtop

 

 

 

portable computer

 

 

 

 

 

 

Audio CDs

Music commonly comes on CDs. Audio CDs contain tracks whereby each song is equal to one track. A track is similar to a file. CD players use the information contained on the track to determine song length, which on some players can then be displayed. Songs can be pulled from a CD, but you need special software to do so.

Generally, you just want to listen to CDs. Several applications enable you to listen to CD music. The next sections cover some of the applications that work well.

GNOME CD player

The GNOME player is a rudimentary CD player specifically created to work in the GNOME environment. This application gets installed with the GNOME applications. As you can see in Figure 10-1, it contains the basic player functions, including play, rewind, fast forward, and even a button to eject the CD. The player shows the name of the group, the CD title, and the current track in the display.

Figure 10-1: Playing CDs with the GNOME CD player

To run the application from the command line, use gtcd. This application is loaded as part of the GNOME desktop.

208 Part II Working with Debian

XMMS

Another application that will play audio CDs is XMMS, formerly known as X11Amp. You can install this application using the xmms package found among the Debian package archives. This application has the look and feel of the popular WinAmp application found on the Windows platform.

When the application is running, place the CD into the CD drive, right-click the application panel, and select Play File or Playlist. Browse to the CD device, where you should see a list of the tracks on the CD.

With this program, not only can you listen to audio CDs, but you can also listen to your MP3 files (discussed later in this chapter). Figure 10-2 shows the additional features XMMS offers, such as an equalizer and a playlist. The highlighted song in the playlist is the one currently playing.

Figure 10-2: Listening to the MP3s with XMMS

If you have a directory with all the songs you wish to listen to, right-click the main display, select Add Location from the menu, and open the directory containing the song files. The rest of the controls follow the standard player conventions — play, rewind, fast forward, pause, and stop.

Grip

Another CD player of sorts is grip (also found among the Debian package archives). Launch grip from the command line and you will see a graphical interface like the one shown in Figure 10-3. In addition to playing CDs, this player enables you to copy the song tracks off the CD into a WAV file, which can be converted to MP3 format or left as a WAV. No MP3 encoder software comes as a Debian package. If you insist on creating MP3 files, you need to get one of the pre-config- ured converters or convert them separately.

Chapter 10 Multimedia 209

Figure 10-3: Grip enables you to copy files from a CD into a WAV file.

One useful converter (also called an encoder) is bladeenc. This GPL application can be obtained from Tucows at www.tucows.com under Linux : Console : Multimedia/MP3 applications. It is a command-line application. Just remember to stay within the copyright guidelines and only make copies for personal use.

MP3 on Linux

A huge craze right now is the creation, sharing, and playing of MP3 song files. If you didn’t know about it before, you probably learned about when the creators of Napster, a MP3 file-sharing program, were sued for copyright infringements. The appeal of MP3 is the small file size compared to the size of a CD track. The track for a five-minute song on a CD contains approximately 50MB of data. That same data can be compressed to 5MB with MP3.

You can see now how appealing the MP3 format is, if for no other reason than size. MP3 copies keep most of the original quality because of the way in which the data is converted. Studies have shown that there is virtually no perceivable difference between 1,000 kHz and 1,001 kHz audible tones. The original sound data may contain information about both frequencies, but this information gets dropped when converted to MP3. If you have ever tried to convert an MP3 file back to a larger format such as WAV, you may have noticed a reduction in quality because of the missing data.

210 Part II Working with Debian

Caution

This is a disclaimer and warning to anyone wanting to share MP3 song files.

 

Making copies of music for your own use is acceptable, but sharing or selling those

 

files is considered a copyright violation. You should have the original media for all

 

music copies.

Recording CDs

Recording CDs can be just as much fun as playing them. Compilations and “Best of” collections make great audio CDs. Use an application like grip to pull selected songs from other CDs, and then record them to a single CD with all your favorite songs.

Cross-

CDs can be used to store data files as well, a topic covered in Chapter 18.

Reference

 

Gramofile

If you grew up before the advent of CDs, you might remember listening to songs on long-playing (LP) records. If you still have any of those records hanging around, you may have considered copying them over to CD. Here is a little application to help you do that.

The gramofile package, found among the Debian archives, enables you to perform the complete process of recording an LP, processing the recorded sound file, and then recording the final file to CD. You can connect the output from your stereo (not the speaker output), which can play the LP to the input port of your sound card. Run the gramofile program from the command line of a virtual terminal. You will then get a menu to start your production process:

Record audio to a sound file. This option records the audio to create a sound file. The source can be a record, a tape, or any other source.

Copy sound from an audio CD to a file. This option is not yet implemented. You can use another program to record the contents of the CD onto the hard disk in a WAV format.

Locate tracks. LPs contain several songs separated by short periods of silence. This option locates the separation points and creates separate .track files for each song.

Process the audio signal. This option filters the song file to remove pops and cracks. Separate files get created for the filtered file.

Write an audio CD. This option is not yet implemented. You can use an application such as xcdroast to record the final song files to a CD.

Chapter 10 Multimedia 211

Later versions should be fully functional, but at present, the version found in the Debian 2.2 release takes care of functions not found in many applications when recording from LP records, such as filtering and file separation.

xcdroast

There are several command-line applications for creating CDs. This CD creation process can be tedious. xcdroast uses a graphical interface to control the settings when recording CDs. You can doanload this package from one of the Debian mirror archives listed on the Debian Web site. Figure 10-4 shows what this interface looks like from the startup screen.

Figure 10-4: Introduction screen to xcdroast

The buttons along the left side take you to different control panels from which you can copy data, copy audio, create a master, or create an image to burn later.

This package depends on the existence of other packages in order to work properly. When you install the xcdroast package, make sure that you accept the other packages as well.

212 Part II Working with Debian

Streaming audio

Streaming audio has also soared in popularity, due in part to faster Internet connections and improved audio data compression. Streaming audio is similar to what you listen to on the car radio. A radio broadcast station transmits a signal that is picked up by your car radio antenna and processed by your local radio for you to hear.

Now, with access to the Internet, these same radio stations are broadcasting to your computer. If you would like to try your hand at becoming an online DJ, try Icecast, the subject of the next section.

Icecast client/server

Icecast is an open source project that was released to the public. The project enables anyone to set up an MP3 streaming broadcasting server. Icecast comes in two parts — a client and a server for installing in Debian. You can obtain these packages from one of the mirror sites found on Debian’s home page. The server portion runs as a daemon and is controlled at /etc/init.d/icecast. The client feeds the MP3 stream to the server for others to pick up.

You can find a list of people broadcasting at icecast.linuxpower.org. The official Web site for Icecast is www.icecast.org. When you install the client and server portions on your Debian system, here is how it works:

The server gets started with /etc/init.d/icecast start. It then runs using the default settings, waiting for a device to stream audio to it for broadcasting. (Editing the /etc/default/icecast file will also allow icecast to start when system starts)

The client portion that streams the music to the Icecast server is called shout. Run shout from a command line to get the settings straight. Several options are available for use with the client. Later, you can create an executable with all the options fixed. Here is an example command using the shout client:

# shout localhost -P letmein -a -x -p ~/playlist -l -g techno

-n “My techno server” -u “http://icecast.org”

Using the preceding line, shout would connect to localhost using the default password of letmein; stream the files listed in the file ~/playlist; and send directory server information indicating that the genre of music is techno, the name of the broadcast is My techno server, and the URL is http://icecast.org. You would then see the following when run:

cecast.org” /cdrom/technohe.mp3

Parsing arguments...

Base directory does not exist, trying to create

Adding /cdrom/technohe.mp3 without bitrate

Resolving hostname localhost...

Creating socket...

Connecting to server localhost on port 8001

Chapter 10 Multimedia 213

Logging in...

Activating signal handlers..

Starting main source streaming loop..

Playing from /tmp/shout/shout.playlist, line 1

No bitrate or command specified, using autodetect

Checking mpeg headers...

 

 

Filename: /cdrom/technohe.mp3

 

Layer: III

Version: MPEG-1 Frequency: 44100

Bitrate: 128 kbit/s

Padding: 0

Mode: j-stereo

Ext: 0 Mode_Ext: 0

Copyright: 0

Original: 1

Error Protection: 1

Emphasis: 0

Stereo: 2

Playing /cdrom/technohe.mp3

 

[3:18] Size: 3180379 Bitrate: 128000 (40774 bytes/dot)

 

[

]

The sound begins to stream immediately. When the first song finishes, the next one starts broadcasting.

Once the Icecast server is set up, you can use one of three formats: mpg123, xmms, or freeamp. Because xmms was discussed in this chapter, here is how you would listen to streamed audio with the xmms client: Run xmms http://host:port, or press Ctrl+L and enter the URL. The host name and the port number (8000 by default for players) are defined by the Icecast server. In the case of the server you just set up, this is how you would start listening to your broadcast:

# xmms http://localhost:8000 | mpg123

RealPlayer

A popular player found in the commercial world is RealPlayer, which is in no way opensource. This player offers several advantages that most players don’t, one of which is that it includes a plug-in for Netscape. Now, when you browse a Web site that includes playable links, you can listen as you would with streaming audio from radio stations.

If you want to use RealPlayer yourself or make it available for others to use on your system, here is how to you can download and install a free copy (you can also purchase a copy online if you would like):

1.Open a Web browser and connect to www.real.com/player.

2.Click the RealAudio Basic link in the lower left area of the Web page to get the free version of the player. This will take you to a form.

3.First click the OS version and select UNIX from the list. The form will change again.

4.Now you can fill in the fields with the appropriate information. When you get to the Select OS box again, select Linux 2.x (libc6 i386) from the list.

5.After the information is entered in the fields, click the download button. It will take you to the download location page.

214 Part II Working with Debian

6.Click a location, usually the one closest to you, to start the file downloading. It doesn’t matter where you save the file locally, as the file you are downloading is a binary installer.

7.Once the file is local, make sure that it is executable. Launch the installer, and follow the directions presented during the installation.

#chmod u+x rp8_linux20_libc6_i386_cs1.bin

#./rp8_linux20_libc6_i386_cs1.bin

The player is installed at /usr/local/RealPlayer7 when logged in at root, and the binary that starts the program is realplay. Otherwise, the program is installed in your home directory. When installed for the system, make a link from the executable program to /usr/bin so others can launch the player easily. Here is the command you use to create the link:

# ln /usr/local/RealPlayer7/realplay /usr/bin/realplay

Now, anyone with /usr/bin in their path (which is most anyone) can launch realplay from the command line.

Note RealPlayer also displays a certain type of video media formatted for RealPlayer. These usually end with .rm to indicate that they are real media for the player. You can also use the player for streaming audio and video.

Watching Videos

Watching video is not unlike listening to audible media. Once you get the hardware configured correctly, you only need to make sure that you are trying to view a compatible file format.

A component built into the kernel these days goes by the name of video4linux. These are specific modules that enable the kernel to communicate and control video cards specifically designed to buffer captured video. These cards are referred to as frame buffers due to their capability to capture frames of video. Some of these cards, for example, are used in laboratory environments where they capture frames from a camera connected to a microscope. Normally, these cards are very expensive and not meant for the average desktop.

However, in most cases, as long as your video card can view X , it should be able to view video files.

Cross-

For more information on setting up your video card to work in the X Window envi-

Reference

ronment, see Chapter 4.

 

Chapter 10 Multimedia 215

MPEG videos

Like audio, video also comes in several formats. The most common is the Moving Picture Experts Group (MPEG) format. This format can include sound as well as the video. To view an MPEG video, you need to install the smpeg-plaympeg package along with any other packages it depends on.

Once installed, you can start viewing a video file by typing the following:

plaympeg filename

The filename is the name of the MPEG video you intend to watch. The video will start playing in its own window. There are no controls for starting, stopping, or pausing the video once it starts.

Note You can find other players at one of the online repository sites, such as Tucows (www.tucows.com). Several Linux players work with X11, GNOME, and KDE. Many of them are freely available with the GNU public license, so feel free to share them with friends when you find one you like.

DVD videos

Playing Digital Video Disk (DVD) movies on your Linux workstation will take a bit more effort. First of all, there is the matter of obtaining the software. Since there has been some controversy over the DVD encryption — some contend that it has proprietary information, and law suits have cropped up to stop open source distribution. Clearing the legal hurdle is the first step. You can find out more about these issues at www.opendvd.org/myths.php3.

To get a DVD to work with your system, you must first have a DVD drive installed. You also need to add a patch to the 2.2.x kernel to enable the kernel to control the player. To get the patch, go to www.linuxvideo.org/developer/dl.phtml, where you will find other video-related applications as well. Contained in the compressed tar files is a README document that contains the instructions for compiling and installing the patch for the kernel. The 2.4 kernel includes the code for the DVD players and does not need the patch.

At the time of this writing, the DVD player software, called LiViD, is in alpha release. Some screen shots available on the Web site show remarkable clarity from the player. At present, the LiViD compressed tar package contains the DVD patch and other drivers. You can extract the contents of the packages using

tar zxvf filename

where filename is the name of the compressed tar file. Follow the instructions included in the compressed file to complete the installation.

216 Part II Working with Debian

Using Live Voice Chat

You can also use the sound card in your system for live two-way conversations via the Internet. All you need besides the sound card is a microphone, speakers, and software on each computer participating in the conversation.

One application that enables you to talk through the computer is called SpeakFreely, and it can be obtained from www.speakfreely.org as source code. Or, you can get an RPM package from a place such as Tucows’ (www.tucows.com) Linux : X11 : Communications section. If you get the source, you need to compile it before running. Instructions for compiling can be found in the INSTALL file in the extracted directory.

This version of SpeakFreely, available at Tucows, is compatible with the Windows versions also available from the SpeakFreely Web site. In addition to SpeekFreely, another program, RogerWilco BaseStation (www.resounding.com/products/ downloads), also allows verbal communication through the computer. The Web site offers the binaries for download as well as instruction for installation.

Summary

You can now turn your computer into a fully functioning multimedia station for listening and watching nearly any form of entertainment media that comes your way. You should now know how to convert audio formats to a form that you can use, and then listen to those files. With the convenient tools covered in this chapter, playing audio CDs should no longer be shrouded in mystery.

With the MP3 craze gaining steam, you now know how to listen to your own MP3 songs. You can even set up your own streaming audio server for a local network, as well as make a public station on the Internet.

MPEG-formatted video files can also be viewed on your local system. And watch for the open-source DVD players to soon become available in a stable version. All in all, there is no reason why a Debian GNU/Linux workstation cannot be used as a multimedia workstation using the tools discussed in this chapter.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]