Is the example defunct or am I doing something wrong?

Hi All,

I’m learning about GnuRadio and Python, and now I try to code my own
The first iteration of the dialtone example works.
now I want to vary the frequency in steps. after an evening of trying
and googling I’m a bit lost. hopefully someone more experienced
would be so kind as to check my code and/or the example provided.

I follow this example snippet in

1 class my_top_block(gr.top_block):
2 def init(self):
3 gr.top_block.init(self)
4 … # Define some blocks
5 self.amp = gr.multiply_const_ff(1) # Define multiplier block
6 … # Define more blocks
8 self.connect(…, self.amp, …) # Connect all blocks
10 def set_volume(self, volume):
11 self.amp.set_k(volume)
13 if name == ‘main’:
14 my_top_block().start()
15 sleep(2) # Wait 2 secs (assuming sleep was imported!)
16 my_top_block.set_volume(2) # Pump up the volume (by factor 2)
17 sleep(2) # Wait 2 secs (assuming sleep was imported!)
18 my_top_block().stop()

the problem is in referencing the amp block in the way shown above.
In my case I need to access a signal source src0 in the same way.
this is my code.
#!/usr/bin/env python
from gnuradio import gr
from gnuradio import audio
import time

class RvA_top_block(gr.top_block):
def init(self):
sample_raate = 44100
ampl = 0.1
self.src0 = gr.sig_source_f (sample_raate,gr.GR_SIN_WAVE, 350, ampl)
self.src1 = gr.sig_source_f (sample_raate,gr.GR_SIN_WAVE, 440, ampl)
self.dst = audio.sink(sample_raate, “”)
self.connect (self.src0, (self.dst,0))
self.connect (self.src1, (self.dst,1))
def setfreq(self,fq):
def getfreq(self):
return self.scr0.frequency()

if name == ‘main’:
i = 350.0
while ( i < 1000 ):
print i
i = i * 1.2
except [[KeyboardInterrupt]]:

the result is however a complaint that
Traceback (most recent call last):
File “./”, line 35, in
File “./”, line 20, in setfreq
“/usr/local/lib/python2.7/dist-packages/gnuradio/gr/”, line
94, in getattr
return getattr(self._tb, name)
AttributeError: ‘gr_top_block_sptr’ object has no attribute ‘scr0’

any help is greatly appreciated. I’m curious what the difference would
be between the example “amp” and my “src0”. I must be stupid, but 'im
not seeing it.

all this runs on an plain ubuntu. other examples work nicely and the
install went smoothly. I took the most current version og gnuradio and
companion about 2 weeks ago.