discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] reconfigure flow graph, sleep function in main


From: larry
Subject: [Discuss-gnuradio] reconfigure flow graph, sleep function in main
Date: Sun, 25 Jan 2009 16:47:47 -0700
User-agent: Web-Based Email 4.14.19

Hi -

I am trying to get the example Python code fragment running taken from the "Controlling flow graphs" section of:
http://gnuradio.org/trac/wiki/Tutorials/WritePythonApplications

Here is my code:

#!/usr/bin/env python
 
from gnuradio import gr
from gnuradio import audio
import time
 
class my_top_block(gr.flow_graph):
    
    def __init__(self):
        
        gr.flow_graph.__init__(self)
        
        sampling_freq = 48000
        ampl = 0.1
    
        self.src0 = gr.sig_source_f(sampling_freq, gr.GR_SIN_WAVE, 350, ampl)
        self.src1 = gr.sig_source_f(sampling_freq, gr.GR_SIN_WAVE, 440, ampl)
    
        self.adder = gr.add_ff()
        self.sink = audio.sink(sampling_freq)        
 
        self.amp = gr.multiply_const_ff(1) # Define multiplier block
        
        self.connect(self.src0, (self.adder, 0))
        self.connect(self.src1, (self.adder, 1))
 
        self.connect(self.adder, self.amp, self.sink) # Connect all blocks
 
    def set_volume(self, volume):
        self.amp.set_k(volume)
 
if __name__ == '__main__':
    
    my_top_block().start()
    time.sleep(2) # Wait 2 secs (assuming sleep was imported!)
    #raw_input ('Press Enter to quit: ')
    my_top_block.set_volume(2) # Pump up the volume (by factor 2)
    time.sleep(2) # Wait 2 secs (assuming sleep was imported!)
    my_top_block().stop()
   
And here is the error:

Traceback (most recent call last):
  File "h3.py", line 37, in <module>
    my_top_block.set_volume(2) # Pump up the volume (by factor 2)
TypeError: unbound method set_volume() must be called with my_top_block instance as first argument (got int instance instead)

Thanks for your help in advance,

 - Larry Wagner

reply via email to

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