Audio with FreeBSD
Audio with FreeBSD
Greg Lehey
LEMIS (SA) Pty Ltd
grog@FreeBSD.org
grog@lemis.com
Adelaide, 11 June 2003
Audio with FreeBSD
1
Greg Lehey, 11 June 2003
Overview
•
•
•
•
•
•
•
Audio formats: CDA, WAV, MP3 and Ogg Vorbis.
Playing CDs under FreeBSD.
Playing MP3s locally.
Copying CD data to disk.
Converting from WAV to MP3.
Using flash memory under FreeBSD.
Writing data to external MP3 players.
Audio with FreeBSD
2
Greg Lehey, 11 June 2003
Audio formats
• CDA: Format of data stored on CD-ROM. Stored on CD as
16 bit words, data rate 44.1 kHz, two channels. Uncompressed.
• WAV : Uncompressed data format, closely related to CD data
format.
• MP3: Compressed format. Standard rates start at 64 kb/s
and go up to at least 256 kb/s. Sound quality ‘‘acceptable’’.
Hampered by license issues.
• Ogg Vorbis: free format, compressed.
Audio with FreeBSD
3
Greg Lehey, 11 June 2003
Audio hardware
•
•
•
•
Sounds chip handles multiple channels.
Mixer software handles relative volume levels.
By default, most channels set at 75% volume.
This is often not enough.
Audio with FreeBSD
4
Greg Lehey, 11 June 2003
Playing CDs
•
•
•
•
Not much work required.
Simple players run in text-based terminals: cdplay.
cdplay port tries to open /dev/rcd0c by default.
Specify the device to get it to work:
$ cdplay -d /dev/acd0
Audio with FreeBSD
5
Greg Lehey, 11 June 2003
Adjusting the mixer
$ mixer
Mixer vol
is
Mixer pcm
is
Mixer speaker is
Mixer line
is
Mixer mic
is
Mixer cd
is
Mixer rec
is
Mixer line1
is
Mixer phin
is
Mixer phout
is
Mixer video
is
Mixer monitor is
$ mixer vol 100
Setting the mixer
$ mixer cd 100
Setting the mixer
Audio with FreeBSD
currently
currently
currently
currently
currently
currently
currently
currently
currently
currently
currently
currently
set
set
set
set
set
set
set
set
set
set
set
set
to
to
to
to
to
to
to
to
to
to
to
to
75:75
75:75
75:75
75:75
0:0
75:75
0:0
75:75
0:0
0:0
75:75
75:75
vol from 75:75 to 100:100.
cd from 75:75 to 100:100.
6
Greg Lehey, 11 June 2003
Playing CDs (2)
• Fractionally more sophisticated players run in their own X
window: xcdplayer.
• xcdplayer port tries to open /dev/rcd0c and /dev/rmcd0c by
default.
• Specify the device to get it to work:
$ xcdplayer -device /dev/acd0
• Functionality included in more complicated
software: more later.
Audio with FreeBSD
7
Greg Lehey, 11 June 2003
Playing MP3s
•
•
•
•
Requires more effort on the part of the system.
Play MP3s with mpg123.
Man page doesn’t match program.
Set mixer pcm to 100:
$ mixer pcm 100
Setting the mixer pcm from 10:10 to 100:100.
Audio with FreeBSD
8
Greg Lehey, 11 June 2003
Copying CD audio to disk
• Copies CDA data to disk and saves in WAV format.
• Commonly known as ripping.
• Use grip.
Audio with FreeBSD
9
Greg Lehey, 11 June 2003
grip
•
•
•
•
•
•
•
•
Part of the Gnome project.
No man page.
Help not very good. Does not match the program.
Front end to other programs.
Can be used to play audio CDs directly.
Maintains a config file ˜/.grip.
.grip defaults not very appropriate.
See .grip config file at end of slides for suggested parameters.
Audio with FreeBSD
10
Greg Lehey, 11 June 2003
grip (2)
• Changing config doesn’t save until grip exits.
• Accesses your choice of a database of CD titles and information.
• The default appears to be freedb.freedb.org.
• About 90% hit rate.
• Saves files in a directory hierarchy named after the CD and
track title.
• Can rip and encode in parallel.
Audio with FreeBSD
11
Greg Lehey, 11 June 2003
Ripping
•
•
•
•
Use dagrab.
Difficult to set up parameters.
Defaults not very appropriate.
See grip config file at end of slides for suggested parameters.
Audio with FreeBSD
12
Greg Lehey, 11 June 2003
Converting from WAV to MP3
•
•
•
•
•
Called encoding.
Use lame.
Difficult to set up parameters.
Defaults not very appropriate.
See grip config file at end of slides for suggested parameters.
Audio with FreeBSD
13
Greg Lehey, 11 June 2003
Compact flash devices
•
•
•
•
•
Insert compact flash in PCMCIA slots with an adapter.
Look like IDE disk drives.
Can automount with devd.
File systems normally Microsoft FAT16.
Don’t forget to umount before removing!
Audio with FreeBSD
14
Greg Lehey, 11 June 2003
USB flash devices
•
•
•
•
•
USB appears as SCSI device.
Some have quirks which FreeBSD release 4 can’t handle.
Can automount with devd.
File systems normally Microsoft FAT16.
Don’t forget to umount before removing!
Audio with FreeBSD
15
Greg Lehey, 11 June 2003
Portable MP3 player
•
•
•
•
•
Really a glorified USB flash device.
Looks for files in the home directory ending in MP3.
Not well matched to the file names that grip uses.
Solution: script mp3link to create simpler file names.
Copy MP3 files with standard UNIX utilities.
Audio with FreeBSD
16
Greg Lehey, 11 June 2003
Demonstrations
•
•
•
•
•
•
•
•
•
•
cdplay
mixer
xcdplayer
mpg123
grip
Ripping and encoding.
Compact flash devices.
USB flash devices.
Copying to USB MP3 player.
Playing from USB MP3 player.
Audio with FreeBSD
17
Greg Lehey, 11 June 2003
Resources
• These slides at http://www.lemis.com/slides/audio/slides.pdf
• Sample configuration file at http://www.lemis.com/slides/audio/dotgrip
• mp3link script at http://www.lemis.com/slides/audio/mp3link
• /etc/devd.conf
entries
(not
complete
file)
at
http://www.lemis.com/slides/audio/devd.conf
Audio with FreeBSD
18
Greg Lehey, 11 June 2003
.grip file (1)
GRIP 2
cd_device /dev/acd0
force_scsi
ripexename /usr/local/bin/dagrab
ripcmdline -d %c -f %w %t
wav_filter_cmd
disc_filter_cmd
mp3exename /usr/local/bin/lame
mp3cmdline -h -b %b %w %m
dbserver freedb.freedb.org
ripfileformat /var/spool/music/%A/%d/%t-%n.wav
mp3fileformat /var/spool/music/%A/%d/%t-%n.mp3
m3ufileformat ˜/mp3/%A-%d.m3u
delete_wavs 1
add_m3u 1
rel_m3u 1
add_to_db 0
use_proxy 0
proxy_name
proxy_port 8000
proxy_user
proxy_pswd
cdupdate
user_email grog@lemis.com
ripnice 0
mp3nice 0
mp3_filter_cmd mp3link /var/spool/music/%!A/%!d %t-%!n.mp3 %t.mp3
.grip file (2)
doid3 1
doid3v2 1
tag_mp3_only 1
id3_comment Created by Grip
max_wavs 99
auto_rip 0
eject_after_rip 0
eject_delay 0
delay_before_rip 0
stop_between_tracks 0
beep_after_rip 1
faulty_eject 0
poll_drive 1
poll_interval 5
use_proxy_env 0
db_cgi ˜cddb/cddb.cgi
cddb_submit_email freedb-submit@freedb.org
db_use_freedb 1
dbserver2
db2_cgi ˜cddb/cddb.cgi
no_interrupt 1
stop_first 0
play_first 1
play_on_insert 0
automatic_cddb 1
automatic_reshuffle 0
.grip file (3)
no_lower_case 0
no_underscore 0
allow_high_bits 0
allow_these_chars
keep_min_size 1
num_cpu 1
kbits_per_sec 128
selected_encoder 1
selected_ripper 1
play_mode 0
playloop 0
volume 255
mp3link script
#!/bin/sh
echo -n "cwd: "
pwd
logger cwd: ‘pwd‘ args: $*
mkdir -p $1/mp3
rm -r $1/mp3/$3
logger ln $1/$2 $1/mp3/$3
ln $1/$2 $1/mp3/$3
/etc/devd.conf entries
attach 0 {
device-name "$ata-controller-regex";
action "mount /camera";
};
attach 0 {
device-name "umass[0-9]+";
action "(sleep 2; mount /mp3)&";
};
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising