473,398 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Can't simultaneously read/write from ossaudio dsp device

For an internet telephone application, I need to be able to read and
write data to and from /dev/dsp simultaneously. I wrote some code and
its not working. Anyone have any working code to do this? I am
assuming my card is full duplex, it is a built-in sound card on a new
dell 600m laptop, but I am not sure how to tell for sure. But I think
the problem is not so much my sound card, but that I am making some
fundamentally wrong assumption on the way to do this ;) Also I am
definitely a newbie when it comes to audio coding, so any corrections
or tips are welcome.

Here is some test code that is failing for me
--------------------------------------------------------

from twisted.internet.task import LoopingCall
from twisted.internet import reactor
import os, sys, wave, audioop

"""
While playing the contents of test1.wav, talk into the mic
and have the audio recorded into /tmp/out.wav
"""

def playnlisten_out():
audio = wavin.readframes(1024)
stereoaudio = audioop.tostereo(audio, 2, 1, 1)
dsp.write(stereoaudio)

def playnlisten_in():
audio = dsp.read(640)
wavout.write(audio)

def both():
playnlisten_out()
playnlisten_in()

dsp = ossaudiodev.open('/dev/dsp', 'rw')

wavin = wave.open("test1.wav", "r")
wavout = wave.open("/tmp/out.wav", "w")

both_loop = LoopingCall(both)
both_loop.start(0.02)

reactor.run()

------------ Actual behavior ------------------------

It fails with an error:

dsp.write(stereoaudio)
exceptions.IOError: [Errno 19] No such device

If I comment either playnlisten_out() or playnlisten_in() then the
other function will work. They just don't work at the same time.

------------ Sys info ------------------------
box:~# lsmod | grep -i audio
i810_audio 30356 1
ac97_codec 16908 1 i810_audio
soundcore 9824 3 snd,i810_audio
box:~# lsmod | grep -i snd
snd_pcm_oss 48168 0
snd_mixer_oss 16640 1 snd_pcm_oss
snd_intel8x0m 18632 0
snd_intel8x0 33068 0
snd_ac97_codec 59268 2 snd_intel8x0m,snd_intel8x0
snd_pcm 85412 3 snd_pcm_oss,snd_intel8x0m,snd_intel8x0
snd_timer 23172 1 snd_pcm
snd_page_alloc 11144 3 snd_intel8x0m,snd_intel8x0,snd_pcm
gameport 4736 1 snd_intel8x0
snd_mpu401_uart 7296 1 snd_intel8x0
snd_rawmidi 23232 1 snd_mpu401_uart
snd_seq_device 7944 1 snd_rawmidi
snd 50148 10
snd_pcm_oss,snd_mixer_oss,snd_intel8x0m,snd_intel8 x0,snd_ac97_codec,snd_pcm,snd_timer,snd_mpu401_uar t,snd_rawmidi,snd_seq_device
soundcore 9824 3 snd,i810_audio

box:~# lspci
0000:00:1f.5 Multimedia audio controller: Intel Corp. 82801DB/DBL/DBM
(ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)

box:~# uname -a
Linux box 2.6.7-1-386 #1 Thu Jul 8 05:08:04 EDT 2004 i686 GNU/Linux

Mar 13 '06 #1
1 2513
I got it working! There was another thread http://tinyurl.com/pebqc on
this group where someone had the same problem. I changed my code to
the following:

from twisted.internet.task import LoopingCall
from twisted.internet import reactor
import os, sys, wave, audioop

"""
While playing the contents of test1.wav, talk into the mic
and have the audio recorded into /tmp/out.wav
"""

def playnlisten_out():
audio = wavin.readframes(1024)
stereoaudio = audioop.tostereo(audio, 2, 1, 1)
dspout.write(stereoaudio)

def playnlisten_in():
audio = dspin.read(640)
wavout.write(audio)

def both():
playnlisten_out()
playnlisten_in()

dspout = ossaudiodev.open('/dev/dsp', 'w') # 2 file handles
dspin = ossaudiodev.open('/dev/dsp', 'r')

wavin = wave.open("test1.wav", "r")
wavout = wave.open("/tmp/out.wav", "w")

both_loop = LoopingCall(both)
both_loop.start(0.02)

reactor.run()

and it worked as expected. I did not need to mess around with
/dev/mixer.

Mar 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Scott Chapman | last post by:
Hi! I'd like a "file" on the Linux box to actually be the input and output of a Python script. Anything written to the file would be sent to a database and anything read from the file would...
8
by: collinm | last post by:
hi we use linux and c language under bash i do echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2 that send command to a led display (alpha sign communication)
7
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
0
by: Taran | last post by:
I am having this issue with both Visual C++ 6.0 and Visual Studio 2005 Beta 2. I have the SDK and DDK installed. I am trying to write a program to retrieve the EDID for a specific monitor in a...
3
by: Sean Liong via .NET 247 | last post by:
Hi, Is there any possibilities Read/Write a the storage file from a client system from a ASP.net web application? I think using the activeX component able to achieve this but is there any other...
10
by: Rich | last post by:
Hello, I have to read and write around one million records from an external data source to Sql Server2k every night. That's a lot of I/O. I am using VB6 for this (takes hours). I am...
1
by: Siegfried Heintze | last post by:
I have some cygwin cron jobs running under the Administrator account populating a MSAccess database that is simultaneously being queried by IIS/ASP.NET/C#. If I manually use windows explorer to...
3
by: markclinn | last post by:
I have a device in the field that I access by the stream method. I open the Stream and do the following: 1. stream.write a character to the device. 2. stream.read the information from the...
6
by: brianrpsgt1 | last post by:
I am new to scripting. I am trying to read the settings from a serial device using Python. I have been able to successfully connect to the device and change baud rate settings, ect... with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.