Variable transmission time of a single frequency

Basically, I am trying to send a single frequency tone for a specified
duration (currently 5ms) whenever a user wants to send one. My current
solution uses messages by basically sending a single byte of ones no
matter what a person enters on the cmd line. I convert that byte to
symbols (representing one due to my above hardcode) and add to it the
frequency of transmission. I then use a fixed number of repeaters to
extend this symbol and use that to ourput from a vco that particular
frequency. I have the code at the end of my email.

What I am observing is that there seems to be some fundamental limit
to how short that tranmission can be. In my code below, I am trying to
send an 18Khz tone for 5ms. However, no matter what I do:
a) the transmitted signal lasts for ~10-11ms (from scope and wav file)
b) not every key press generates the tone. I generally miss one or two
keypress. This happens even if the keypress are well spaced in time.

So two questions to the community. What could be causing such a
behavior? and is there an alternative way to get a similar result than
what I am currently doing?

Thank you.



TONE_FREQ=18000 #hz
AUDIO_RATE=48000 #samples/sec
TONE_DUR=5/1000#in sec

Main Graph

class tone_graph(gr.top_block):

 def __init__(self):
     audio_rate = AUDIO_RATE

     self.src = gr.message_source(gr.sizeof_char, msgq_limit)

     src = self.src

     b_to_syms = gr.bytes_to_syms()

#we know that there should always be just one byte of code
     add = gr.add_const_ff(TONE_FREQ)

     repeater = gr.repeat(gr.sizeof_float,REPEAT_TIME)

     fsk_f = gr.vco_f(audio_rate, 2*pi,1.0)

     speaker = audio.sink(audio_rate);
     dst = gr.wavfile_sink("tone_tx.wav", 1, audio_rate, 16)


def main():

 fg = tone_graph()

 fg.start()                       # start flow graph

     while True:
         message = raw_input(" transmit a 5ms tone (Ctrl-D to

exit): ")

  #make a one byte packet to indicate the tone transmission.
         pkt = struct.pack('B', 0xff)

         msg = gr.message_from_string(pkt)


 except EOFError:
     print "\nExiting."

Main python entry

if name == ‘main’:
except KeyboardInterrupt:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs