discuss-gnuradio
[Top][All Lists]
Advanced

[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 18:21:01 +0930
User-agent: KMail/1.6.2

On Friday 01 October 2004 23:55, cswiger wrote:
> Gang - Here's a simple script that demonstrates spectrum inversion
> using the multiply by [1,-1] method (mixing with Nyquist frequency).
> Requires nothing but a sound card, and sounds just like listening
> to a SSB signal on the wrong sideband.
> 
> ------------------------------------
> 
> fron gnuradio import gr
> from gnuradio import audio
> 
> def build_graph ():
> 
>       gr = gr.flow_graph ()
>       sample_rate = 8000
> 
>       src = audio.source (sample_rate)
>       out = audio.sink (sample_rate)
> 
>       vec1 = [1, -1]
>       vsource = gr.vector_source_f (vec1, 1)
>       multiply = gr.multiply_ff ()
> 
>       fg.connect (src, (multiply, 0))
>       fg.connect (vsource, (multiply, 1))
>       fg.connect (multiply, out)
> 
>       return fg
> 
> def main ():
>       fg = build_graph()
>       fg.start ()
>       raw_input ('Press Enter to quit')
>       fg.stop()
> 
> if __name__ == '__main__':
>       main ()

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:

audio_oss_sink.cc:51
  if ((d_fd = open (device_name.c_str (), O_WRONLY)) < 0){
    fprintf (stderr, "audio_oss_sink: ");
    perror (device_name.c_str ());
    throw std::runtime_error ("audio_oss_sink");
  }

audio_oss_source.cc:51
  if ((d_fd = open (device_name.c_str (), O_RDONLY)) < 0){
    fprintf (stderr, "audio_oss_source: ");
    perror (device_name.c_str ());
    throw std::runtime_error ("audio_oss_source");
  }

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:

(assuming we named the file inversion.py)

--- inversion.py.orig   2004-10-03 18:08:34.000000000 +0930
+++ inversion.py        2004-10-03 18:07:17.000000000 +0930
@@ -1,11 +1,12 @@
 #! /usr/bin/env python

-fron gnuradio import gr
+
+from gnuradio import gr
 from gnuradio import audio

 def build_graph ():

-        gr = gr.flow_graph ()
+        fg = gr.flow_graph ()
         sample_rate = 8000

         src = audio.source (sample_rate)


73, Berndt
VK5ABN




reply via email to

[Prev in Thread] Current Thread [Next in Thread]