Skip to contentSkip to conversation

How do create a dummy device for recording audio? Does it exist already?

DISCUSSION Caleb Crome 5 participants 12 messages Apr 22, 2004 – Apr 29, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,
I've looked through the archives and I couldn't find what I'm
looking for, so here goes:

I'd like to create a dummy audio device that can record the PCM data written to it into a file. So, the dummy device would appear as a sound card to the audio program (Real Player for example), and start dumping audio into a file, or maybe it would create another device that could be read simply by 'dd' or some custom command. Then I'd pipe the data into an MP3 or OGG encoder, split into 1/2 hour chunks, or whatever length chunks I like.

Once the system is running, I'd do something like this:

1) Open my Player, tune to my favorite station. Use my new device for audio output.
2) do something like: dd if=/dev/audiocapturepcmout count=xxx | lame --output myfile.mp3

What would it take to make a alsa drive that captures the PCM data into a file? How about one that captures it, then pumps it into a new /dev/ device for reading?

Thanks,
-Caleb

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#1 lore raw
Quoted 4 lines

1) Open my Player, tune to my favorite station. Use my new device for audio output.
2) do something like: dd if=/dev/audiocapturepcmout count=xxx | lame --output myfile.mp3

streamripper is a much better option for this. its specially designed for this task. you are also talking about mp3->PCM->mp3 conversion, which is not very nice for audio quality.

http://streamripper.sf.net/

--p

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#2 lore raw

StreamRipper: Close, but no cigar. That only works for MP3 streams, not for other streams, such as RealPlayer. I have looked at streamripper before and it doesn't do what I want as far as I can tell. In the case of RealPlayer, the audio goes from Real->PCM->MP3, which I admit isn't great for audio quality, but I don't really care, I'm not trying to listen to music. In fact, that would be an extraordinarily hard way to get music. I actually want it mainly so that I can record NPR constantly and have 30 minutes blocks automatically encoded and sitting on my hard drive. Then when I come in to a show half way, and what to hear the whole thing, I just grab the files and burn them to MP3 CD. Then I can listen to CarTalk or whatever whenever I want, on my terms.

Quoted 6 lines · Paul Davis
Quoted 5 lines

1) Open my Player, tune to my favorite station. Use my new device for audio output.
2) do something like: dd if=/dev/audiocapturepcmout count=xxx | lame --output myfile.mp3

Quoted 10 lines

streamripper is a much better option for this. its specially designed for this task. you are also talking about mp3->PCM->mp3 conversion, which is not very nice for audio quality.

http://streamripper.sf.net/

--p

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#3 lore raw
In reply to Caleb Crome
Quoted 3 lines · Caleb Crome

I'd like to create a dummy audio device that can record the PCM data written to it into a file. So, the dummy device would appear as a sound card to the audio program (Real Player for example), and start dumping

How about 'file' type plugin? For example:

pcm.file {
    type file
    slave {
        pcm "hw:0,0"
    }
    file "/tmp/file.raw"
}                                                                              
Quoted 2 lines

audio into a file, or maybe it would create another device that could be read simply by 'dd' or some custom command. Then I'd pipe the data into

It works with named pipes as well.

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html#pcm_plugins_file

Arek

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#4 lore raw

Arek,
That looks like what I want. However, I'm sorry to be such an
ignoramus -- what do I do with that bit of configuration data? I found the /usr/share/alsa/alsa.conf, and there is a similar pcm.file entry in that, but it seems to take parameters. Since I have no sound card, how do I configure my system to use the dummy PCM driver and use the pcm.file plugin?

Sorry to the developer community -- this is a user question. I'll move the thread over there if it continues on.

Thanks,
-Caleb

Quoted 30 lines · Arek Korbik
Quoted 3 lines · Caleb Crome

I'd like to create a dummy audio device that can record the PCM data written to it into a file. So, the dummy device would appear as a sound card to the audio program (Real Player for example), and start dumping

How about 'file' type plugin? For example:

pcm.file {
   type file
   slave {
       pcm "hw:0,0"
   }
   file "/tmp/file.raw"
}                                                                              
Quoted 3 lines

audio into a file, or maybe it would create another device that could be read simply by 'dd' or some custom command. Then I'd pipe the data into

It works with named pipes as well.

http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html#pcm_plugins_file

Arek

Quoted 12 lines

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#5 lore raw

At Thu, 22 Apr 2004 14:24:30 -0700,

Quoted 8 lines · Caleb Crome

Arek,
That looks like what I want. However, I'm sorry to be such an
ignoramus -- what do I do with that bit of configuration data? I found the /usr/share/alsa/alsa.conf, and there is a similar pcm.file entry in that, but it seems to take parameters. Since I have no sound card, how do I configure my system to use the dummy PCM driver and use the pcm.file plugin?

you can specify the filename as the parameter of file plugin. for example,

% aplay -Dfile:foo.raw bar.wav

will dump bar.wav as the raw sample data to a new file foo.raw.

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#6 lore raw
In reply to Caleb Crome
Quoted 9 lines · Caleb Crome
Quoted 7 lines · Arek Korbik
pcm.file {
   type file
   slave {
       pcm "hw:0,0"
   }
   file "/tmp/file.raw"
}
Quoted 3 lines

what do I do with that bit of configuration data? I found the /usr/share/alsa/alsa.conf, and there is a similar pcm.file entry in that, but it seems to take parameters.

Put it into your ~/.asoundrc file, or into /etc/asound.conf for all users.

Quoted 2 lines

Since I have no sound card, how do I configure my system to use the dummy PCM driver and use the pcm.file plugin?

"modprobe snd-dummy" should work.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#8 lore raw
In reply to a message not in the archive
Quoted 62 lines · Caleb Crome

Alright, I did what you suggested, and real player comes up and connects to the dummy sound card (I had to do a modprobe snd-pcm-oss and snd-mixer-oss). However, I don't get a file called /tmp/file.raw. Is there any way to check how the data is routed? Do I have to do anything to make .asoundrc get reread?

Thanks again,
-Caleb

Quoted 52 lines · Clemens Ladisch
Quoted 12 lines · Caleb Crome
Quoted 8 lines · Arek Korbik

pcm.file {
type file

  slave {
      pcm "hw:0,0"

}
file "/tmp/file.raw"
}

Quoted 4 lines

what do I do with that bit of configuration data? I found the /usr/share/alsa/alsa.conf, and there is a similar pcm.file entry in that, but it seems to take parameters.

Put it into your ~/.asoundrc file, or into /etc/asound.conf for all users.

Quoted 3 lines

Since I have no sound card, how do I configure my system to use the dummy PCM driver and use the pcm.file plugin?

"modprobe snd-dummy" should work.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#9 lore raw
In reply to a message not in the archive
Quoted 11 lines · Caleb Crome
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

pcm.file {
type file

  slave {
      pcm "hw:0,0"

}
file "/tmp/file.raw"
}

Alright, I did what you suggested, and real player comes up and connects to the dummy sound card (I had to do a modprobe snd-pcm-oss and
snd-mixer-oss). However, I don't get a file called /tmp/file.raw.

You have to configure the program to use the PCM named "file" instead of the default "default".

However, Realplayer uses the OSS emulation through /dev/dsp0. To make that work with your "file" device, add the following to the config file:

pcm.dsp0 = file

and try to run realplayer with the aoss script from the alsa-oss package.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek For a limited time only, get FREE Ground shipping on all orders of $35 or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297

#10 lore raw
Quoted 25 lines · Clemens Ladisch
Quoted 9 lines · Caleb Crome
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

pcm.file {
type file

 slave {
     pcm "hw:0,0"

}
file "/tmp/file.raw"
}

Quoted 5 lines

Alright, I did what you suggested, and real player comes up and connects to the dummy sound card (I had to do a modprobe snd-pcm-oss and
snd-mixer-oss). However, I don't get a file called /tmp/file.raw.

You have to configure the program to use the PCM named "file" instead of the default "default".

However, Realplayer uses the OSS emulation through /dev/dsp0. To make that work with your "file" device, add the following to the config file:

Quoted 12 lines

pcm.dsp0 = file

and try to run realplayer with the aoss script from the alsa-oss package.

HTH
Clemens

Awesome! It works like a charm. Than you so much! The one thing that doesn't work quite right is that I get the following error when RealPlayer attempts to access the mixer:

ALSA lib control.c:601:(snd_ctl_open_noupdate) Invalid CTL mixer0

Is there a simple way to get it to control the mixer? Currently, I have to bring up alsamixergui to turn up the volume.

Thanks again,
-Caleb Crome

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click

#11 lore raw
Quoted 5 lines · Caleb Crome
Quoted 4 lines · Clemens Ladisch

However, Realplayer uses the OSS emulation through /dev/dsp0. To make that work with your "file" device, add the following to the config file:

Quoted 7 lines
Quoted 1 line

pcm.dsp0 = file

Awesome! It works like a charm. Than you so much! The one thing that doesn't work quite right is that I get the following error when RealPlayer attempts to access the mixer:

ALSA lib control.c:601:(snd_ctl_open_noupdate) Invalid CTL mixer0

It tries to use /dev/mixer0, too. Add the following:

ctl.mixer0 = "hw:0"

HTH
Clemens

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click

#12 lore raw
Quoted 21 lines · Clemens Ladisch
Quoted 7 lines · Caleb Crome
Quoted 4 lines · Clemens Ladisch

However, Realplayer uses the OSS emulation through /dev/dsp0. To make that work with your "file" device, add the following to the config file:

Quoted 10 lines
Quoted 3 lines

pcm.dsp0 = file

Awesome! It works like a charm. Than you so much! The one thing that doesn't work quite right is that I get the following error when RealPlayer attempts to access the mixer:

ALSA lib control.c:601:(snd_ctl_open_noupdate) Invalid CTL mixer0

Quoted 11 lines

It tries to use /dev/mixer0, too. Add the following:

ctl.mixer0 = "hw:0"

HTH
Clemens

Clemens,
Thanks for the info, however now I get the following:

ALSA lib control.c:516:(snd_ctl_open_conf) Invalid type for CTL mixer0 definition

Any ideas? Just for the record, my asoundrc is:

pcm.dsp0 = file

pcm.file {
    type file
    slave {
          pcm "hw:0,0"
    }

file "/tmp/pcm.raw.pipe"
}
ctl.mixer0 = "hw:0"

When I changed the last line to:

ctl.mixer0 = hw

it doesn't complain any more. Is that the correct syntax?

Thanks again,
-Caleb

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click