[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun
From: |
Berndt Josef Wulf |
Subject: |
Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun |
Date: |
Sun, 3 Oct 2004 22:56:47 +0930 |
User-agent: |
KMail/1.6.2 |
On Sunday 03 October 2004 22:01, Chuck Swiger wrote:
> At 06:21 PM 10/3/2004 +0930, you wrote:
>
> >Does linux allow you to open the same device twice? Both calls to
> >audio_source
> >and audio_sink open the same device namely /dev/dsp and hence would return
> >two file handles:
> >
> >
> >Running the above demo program with GnuRadio on a NetBSD system will return
a
> >"device busy" signal as one would expect. Am I missing something here? What
> >is the secret? :)
> >
> >Also, If I'm not mistaken, the code demonstrated contains a couple of
typos:
>
>
> Hi Berndt - yes there were two typos, the dangers of not having
> cut-and-paste working.
That's ok, just mentioned it for others that may want to try it.
> I cannot speak to the sound card issue on NetBSD - it does work on Linux
> (RedHat
> Fedora Core 2) with the sound device built into an Asus A7V motherboard. Is
> your
> sound card full duplex? Many are not, and only allow opening for input or
> output only,
> but not both.
The soundchip is full duplex alright and it does working. However, with your
script it tries to open the device twice and hence it will fail to allocate a
file handle for that device.
The way it works on NetBSD can be demonstrated with a simple C example shown
below:
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/audioio.h>
#include <sys/types.h>
#define BUFFERSIZE 256
int main(void)
{
char buffer[BUFFERSIZE];
int audio_fd;
int n;
int fullduplex;
fullduplex = 1;
audio_fd = open("/dev/sound", O_RDWR|O_NONBLOCK);
if(audio_fd < 0)
err(EXIT_FAILURE, "failed to open audio device");
if(ioctl(audio_fd, AUDIO_SETFD, &fullduplex) < 0)
err(EXIT_FAILURE, "failed to set fullduplex");
for(;;) {
n = read(audio_fd, buffer, BUFFERSIZE);
if(n > 0) {
n = write(audio_fd, buffer, n);
}
}
if(close(audio_fd))
err(EXIT_FAILURE, "faild to close audio device");
return EXIT_SUCCESS;
}
Here one call opens the device and the file descriptor is shared by the
application for reading and writing. Opening a device with seperate open()
calls for read and write access is currently not possible on NetBSD.
It will be hard for to work around this problem to make it work. I'm open to
any suggestions.
'm not familiar with the Linux kernel and hence my inquisitive question just
making sure that I understood the example correctly... ;-)
I> You could always break the script up into two parts - One records the audio
> stream
> to a disk file, and the other plays the disk file back, with the vector
> mixing in one or the
> other.
>
> In the first part your 'out' would be something like
> out = gr.file_sink (gr.sizeof_float, "filename")
>
> and in the second your 'src' would be like
> src = gr.file_source (gr.sizeof_float, "filename", X ) // X=1
> repeat, X=0 play one time
Yep, that's what I ended up doing to check it out and yes, it does sound like
SSB on the wrong sideband.... ;-)
Thanks for your reply and help.
73, Berndt
VK5ABN
- [Discuss-gnuradio] Audio spectrum inversion - easy & fun, cswiger, 2004/10/01
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Berndt Josef Wulf, 2004/10/03
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Chuck Swiger, 2004/10/03
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun,
Berndt Josef Wulf <=
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Eric Blossom, 2004/10/03
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Berndt Josef Wulf, 2004/10/03
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Eric Blossom, 2004/10/04
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Berndt Josef Wulf, 2004/10/04
- Re: [Discuss-gnuradio] Audio spectrum inversion - easy & fun, Eric Blossom, 2004/10/04