Different people have tried this in different ways. For me, configuring ALSA to capture from the "Mix" device didn't work since I don't have a "Mix" listed when I try the amixer command. I could however write the ALSA output to a file by configuring the PCM chain.
Have the following code in your ~/.asoundrc file:
pcm.rate48000Hz {
type rate
slave {
pcm writeFile # Direct to the plugin which will write to a file
format S16_LE
# channels 2
rate 48000
}
#route_policy copy
}
pcm.writeFile {
type file
slave {
pcm card0 # Now write to the actual sound card
}
file "aplay-D_card0-t_raw-f_S16_LE-r48000-c_2.raw"
format "raw"
}
pcm.card0 {
type hw
card 0
}
ctl.card0 {
type hw
card 0
}
Now get a terminal, go to a directory that contains a media file, issue the player command to play the media. For example,
$ xmms my-song.mp3
Well, you will later on do something useful than the above since in this case you already have the audio in a file. Here we are experimenting.
Once the play is finished, you will have the “aplay-D_card0-t_raw-f_S16_LE-r48000-c_2.raw” file in the directory. That's the recording.
Now you are going to play the file. Here's one approach:
$ aplay -D card0 -t raw -f S16_LE -r 48000 -c 2 aplay-D_card0-t_raw-f_S16_LE-r48000-c_2.raw
Or else, first rename the ~/.asoundrc to something else to prevent overwriting the recording.
$ mv ~/.asoundrc ~/.asoundrc-alsa-record
Let's convert the raw file to a wav file (which will include the encoding details in a header):
$ sox -w -s -L -r 48000 -c 2 aplay-D_card0-t_raw-f_S16_LE-r48000-c_2.raw out.wav
Now play
$ play out.wav
My environment: Fedora 7, ALSA 1.0.14, Kernel 2.6.23.15
Tips:
| Attachment | Size |
|---|---|
| asoundrc (save as .asoundrc) | 449 bytes |
Comments
Post new comment