473,387 Members | 1,628 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,387 software developers and data experts.

ossaudiodev full duplex

rjm
I'm messing around with trying to record sound reflections off of
various objects at different frequencies. I'm using python 2.4 on
Fedora Core 3 and I have an SBLive card. Basically, I want to send
some samples through a speaker and then record from an input source
(the line input on the sound card which I have the output of a mixer
going into and a mic plugged into the mixer). So I want to using the
soundcard in full duplex mode. I'm trying something like this:

number_of_channels= 1
sample_rate= 44100
sample_width= 2
frames_out= get_frames("test.wav")

fh= ossaudiodev.open("/dev/dsp", "rw")
fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels,
sample_rate)
fh.writeall(frames_out)
frames_in= fh.read(number_of_samples * sample_width)
fh.close()
However, even if I turn off the speakers I get the original output tone
back from the read (as well as the input from the mic). I'm assuming
it's the same internal buffer somewhere on the soundcard so when I do
the read I'm really reading what the write just wrote (because I get
that orginal tone in the background even though I turned off the
speaker so it's just not the reflections coming back through the
mic...it's happening internally somewhere). If I unplug everything from
the sound card I'll still get it.

I tried closing the filehandle after the write and then reopening it
before the read and I also tried opening two filehandles, one to
/dev/dsp and another to /dev/dsp1 and still have th same problem. In
the above example I tried the ossaudiodev's sync() and reset()
functions inbetween the write() and read(). Also still have the same
problem even when I do this:

fh= ossaudiodev.open("/dev/dsp", "w")
fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels,
sample_rate)
fh.writeall(frames_out)
fh.close()

fh= ossaudiodev.open("/dev/dsp", "r")
fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels,
sample_rate)
frames_in= fh.read(number_of_samples * sample_width)
fh.close()
Any ideas? Am I doing something fundamentally wrong? Any help would
be greatly appreciated.
Thanks.
-richie

Jul 18 '05 #1
3 3515
In <11**********************@f14g2000cwb.googlegroups .com>, rjm wrote:
[recording the output]

Any ideas? Am I doing something fundamentally wrong? Any help would
be greatly appreciated.


You have to use the mixer to select which channel(s) should be the source
of the recording. It's best is to deselect all other sources except the
line-in or microphone input because some soundcards can mix several input
sources when recording.

The `ossaudiodev` module has an `openmixer()` function but it may be
easier to use one of the graphical mixer programs like `kmix` or
`alsamixergui`.

Ciao,
Marc 'BlackJack' Rintsch
Jul 18 '05 #2
rjm
Thanks that was helpful.

The mixer seems werid though. I tested first with the alsamixer and the
only way I can get the line-in in to record is to put the "mix" channel
into capture mode. However, doing that mixes all the record sources
together so I get the orginal sound that is played through the output
on the "Wave" channel recorded as well. If I don't select the "mix"
channel for capture I still get the "wave" channel in the record but I
don't get the line-in channel anymore.

Thanks again for your help at least it set me in the right direction
for things to look for.
-richie

Marc 'BlackJack' Rintsch wrote:
In <11**********************@f14g2000cwb.googlegroups .com>, rjm wrote:
[recording the output]

Any ideas? Am I doing something fundamentally wrong? Any help would be greatly appreciated.
You have to use the mixer to select which channel(s) should be the

source of the recording. It's best is to deselect all other sources except the line-in or microphone input because some soundcards can mix several input sources when recording.

The `ossaudiodev` module has an `openmixer()` function but it may be
easier to use one of the graphical mixer programs like `kmix` or
`alsamixergui`.

Ciao,
Marc 'BlackJack' Rintsch


Jul 18 '05 #3
rj*@si.rr.com wrote:
fh= ossaudiodev.open("/dev/dsp", "rw")
fh.setparameters(ossaudiodev.AFMT_S16_LE, number_of_channels,
sample_rate)
fh.writeall(frames_out)
frames_in= fh.read(number_of_samples * sample_width)
fh.close()


One problem with this is that you can't use a single file
object for independent reading and writing at the same
time. C stdio implementations tend to get confused if
you try to do that.

You may have other problems as well, but you'll at least
need to open two separate file objects.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
Jul 18 '05 #4

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

Similar topics

4
by: manofbluz | last post by:
I have two complex Word templates that also contain some Bookmarks for receiving database data dynamically. I'm using Word automation code within VB.NET to manipulate the template. I don't need to...
2
by: Matt Brandes | last post by:
Can anybody tell me how to tell what speed and duplex a machine is currently running at. It is very easy to find on a switch, however it is incredibly difficult if not impossible on the PC. For...
0
by: KohlerTommy | last post by:
In my application I need to give the user the ability to print duplex if the selected printer supports duplex printing. Many of the printer options do not make much sense in my application, and...
10
by: Joe M | last post by:
I was wondering if someone could lend me a hand with a C# problem I am having I am trying to use the “setPrinter” api to change the duplex setting (under printing preferences on printer...
0
by: Ernest G Ngaruiya | last post by:
I got some code for playin g sounds using python. The code was meant for alinux platform and so if I use it on Windows, it says there is no module named ossaudiodev. I'd like to try this out on...
1
by: =?iso-8859-1?B?QW5kcuk=?= | last post by:
I'm using winsound and ossaudiodev to produce simple sounds (of set frequency for a given duration) in a an application that is used on Windows-based computer and Linux-based ones. Is there a...
1
by: dotnetdummy | last post by:
Hi, Can anyone who can help me out if possible. At the moment, I'm working on a window application (vb.net) which print out html document's through a default network printer. I'm using...
0
by: Hans123 | last post by:
Hello, My goal is the properties settings of the default network printer by vba ( or vb code). In my case properties duplex/simplex. With the winspool.dll. This works fine if there the...
1
msewing
by: msewing | last post by:
I'm running 2.5.1 on Fedora 8 (2.6.23.9-85.fc8) with the following soundcards: Ensoniq ES1370 (rev 01) VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller (rev 50) I'm working on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.