Bring BSD-licensed ext2fs from FreeBSD
[ikiwiki.git] / docs / handbook / handbook-sound-mp3.mdwn
1 \r
2 \r
3 ## 16.3 MP3 Audio \r
4 \r
5 ***Contributed by Chern Lee. ***\r
6 \r
7 MP3 (MPEG Layer 3 Audio) accomplishes near CD-quality sound, leaving no reason to let your DragonFly workstation fall short of its offerings.\r
8 \r
9 ### 16.3.1 MP3 Players \r
10 \r
11 A popular X11 MP3 player is  **XMMS**  (X Multimedia System).  **Winamp**  skins can be used with  **XMMS**  since the GUI is almost identical to that of Nullsoft's  **Winamp** .  **XMMS**  also has native plug-in support.\r
12 \r
13  **XMMS**  can be installed from the [audio/xmms](http://pkgsrc.se/audio/xmms) port or package.\r
14 \r
15  **XMMS** ' interface is intuitive, with a playlist, graphic equalizer, and more. Those familiar with  **Winamp**  will find  **XMMS**  simple to use.\r
16 \r
17 The [audio/mpg123](http://pkgsrc.se/audio/mpg123) port is an alternative, command-line MP3 player.\r
18 \r
19 ***'mpg123***' can be run by specifying the sound device and the MP3 file on the command line, as shown below:\r
20 \r
21     \r
22     # mpg123 -a /dev/dsp1.0 Foobar-GreatestHits.mp3\r
23     High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.\r
24     Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.\r
25     Uses code from various people. See 'README' for more!\r
26     THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!\r
27     \r
28     Playing MPEG stream from Foobar-GreatestHits.mp3 ...\r
29     MPEG 1.0 layer III, 128 kbit/s, 44100 Hz joint-stereo\r
30 \r
31 \r
32 `/dev/dsp1.0` should be replaced with the `dsp` device entry on your system.\r
33 \r
34 ### 16.3.2 Ripping CD Audio Tracks \r
35 \r
36 Before encoding a CD or CD track to MP3, the audio data on the CD must be ripped onto the hard drive. This is done by copying the raw CDDA (CD Digital Audio) data to WAV files.\r
37 \r
38 The `cdda2wav` tool, which is a part of the [sysutils/cdrtools](http://pkgsrc.se/sysutils/cdrtools) suite, is used for ripping audio information from CDs and the information associated with them.\r
39 \r
40 With the audio CD in the drive, the following command can be issued (as `root`) to rip an entire CD into individual (per track) WAV files:\r
41 \r
42     \r
43     # cdda2wav -D 0,1,0 -B\r
44 \r
45 \r
46  **cdda2wav**  will support ATAPI (IDE) CDROM drives. To rip from an IDE drive, specify the device name in place of the SCSI unit numbers. For example, to rip track 7 from an IDE drive:\r
47 \r
48     \r
49     # cdda2wav -D /dev/acd0a -t 7\r
50 \r
51 \r
52 The `-D `0,1,0` indicates the SCSI device `0,1,0`, which corresponds to the output of `cdrecord -scanbus`.\r
53 \r
54 To rip individual tracks, make use of the `-t` option as shown:\r
55 \r
56     \r
57     # cdda2wav -D 0,1,0 -t 7\r
58 \r
59 \r
60 This example rips track seven of the audio CDROM. To rip a range of tracks, for example, track one to seven, specify a range:\r
61 \r
62     \r
63     # cdda2wav -D 0,1,0 -t 1+7\r
64 \r
65 \r
66 The utility [dd(1)](http://leaf.dragonflybsd.org/cgi/web-man?command#dd&section1) can also be used to extract audio tracks on ATAPI drives, read [this Section](creating-cds.html#DUPLICATING-AUDIOCDS) for more information on that possibility.\r
67 \r
68 ### 16.3.3 Encoding MP3s \r
69 \r
70 Nowadays, the mp3 encoder of choice is  **lame** .  **Lame**  can be found at [audio/lame](http://pkgsrc.se/audio/lame) in the pkgsrc® tree.\r
71 \r
72 Using the ripped WAV files, the following command will convert `audio01.wav` to `audio01.mp3`:\r
73 \r
74     \r
75     # lame -h -b 128 \\r
76     --tt "Foo Song Title" \\r
77     --ta "FooBar Artist" \\r
78     --tl "FooBar Album" \\r
79     --ty "2001" \\r
80     --tc "Ripped and encoded by Foo" \\r
81     --tg "Genre" \\r
82     audio01.wav audio01.mp3\r
83 \r
84 \r
85 128 kbits seems to be the standard MP3 bitrate in use. Many enjoy the higher quality 160, or 192. The higher the bitrate, the more disk space the resulting MP3 will consume--but the quality will be higher. The `-h` option turns on the ***higher quality but a little slower*** mode. The options beginning with `--t` indicate ID3 tags, which usually contain song information, to be embedded within the MP3 file. Additional encoding options can be found by consulting the lame man page.\r
86 \r
87 ### 16.3.4 Decoding MP3s \r
88 \r
89 In order to burn an audio CD from MP3s, they must be converted to a non-compressed WAV format. Both  **XMMS**  and ***'mpg123***' support the output of MP3 to an uncompressed file format.\r
90 \r
91 Writing to Disk in  **XMMS** :\r
92 \r
93   1. Launch  **XMMS** .\r
94   1. Right-click on the window to bring up the  **XMMS**  menu.\r
95   1. Select `Preference` under `Options`.\r
96   1. Change the Output Plugin to ***Disk Writer Plugin***.\r
97   1. Press `Configure`.\r
98   1. Enter (or choose browse) a directory to write the uncompressed files to.\r
99   1. Load the MP3 file into  **XMMS**  as usual, with volume at 100% and EQ settings turned off.\r
100   1. Press `Play` --  **XMMS**  will appear as if it is playing the MP3, but no music will be heard. It is actually playing the MP3 to a file.\r
101   1. Be sure to set the default Output Plugin back to what it was before in order to listen to MP3s again.\r
102 \r
103 Writing to stdout in ***'mpg123***':\r
104 \r
105   1. Run `mpg123 -s audio01.mp3 > audio01.pcm`\r
106 \r
107  **XMMS**  writes a file in the WAV format, while ***'mpg123***' converts the MP3 into raw PCM audio data. Both of these formats can be used with  **cdrecord**  to create audio CDs. You have to use raw PCM with [burncd(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#burncd&section8). If you use WAV files, you will notice a small tick sound at the beginning of each track, this sound is the header of the WAV file. You can simply remove the header of a WAV file with the utility  **SoX**  (it can be installed from the [audio/sox](http://pkgsrc.se/audio/sox) port or package):\r
108 \r
109     \r
110     % sox -t wav -r 44100 -s -w -c 2 track.wav track.raw\r
111 \r
112 \r
113 Read [this Section](creating-cds.html) for more information on using a CD burner in DragonFly.\r
114 \r
115 \r
116 \r
117 CategoryHandbook\r
118 CategoryHandbook-multimedia\r