0

I would like to capture raw data from the audio out, using Python. In the Python docs it seems that using ossaudiodev works for this purpose. However, I am using Ubuntu 11.10, which has no /dev/dsp:

>>> import ossaudiodev
>>> ossaudiodev.open('r');
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/dev/dsp'

Has anybody got a clue how to capture the sound my sound card outputs using Python?

TTT
  • 6,505
  • 10
  • 56
  • 82

2 Answers2

3

OSS is an older and deprecated audio system for Linux. The current standard is to use ALSA, and to layer on top of ALSA with either JACK or PulseAudio. Ubuntu uses PulseAudio.

The best thing you could do is to find good Python bindings for connecting to PulseAudio. I just did a quick Google search and didn't find anything for you, and I don't have time to follow up more right now.

EDIT: I just remembered that ALSA does have an OSS compatibility mode. You might be able to install the OSS compatibility stuff, then just use the Python code you already have.

https://help.ubuntu.com/community/alsa-oss

http://www.alsa-project.org/main/index.php/Main_Page

steveha
  • 74,789
  • 21
  • 92
  • 117
0

I have got programs to work which require /dev/dsp by using

aoss <PROGRAM NAME AND ARGUMENTS HERE>

If you type aoss on Ubuntu's command line, it will tell you the package to install and that should, in turn, install the needed dependencies. If it doesn't work off the bat, you can try loading a kernel module such as sudo modprobe snd_mixer_oss.

Richard
  • 56,349
  • 34
  • 180
  • 251