Increase sine frequency every N samples

Hi,

I want to generate a sine wave that increases in some kHz its
frequency every N samples it produces.

I know I can change the frequency of the sine using the available
setter method on the gr_sig_source block. My problem is how to perform
that change exactly after N samples have been produced by the
gr_sig_source block. I’ve come up with some ideas:

  • Make the top_block aware of the number of samples that the
    gr_sig_source has produced. When N samples are produced, the top_block
    could call Lock(), change the parameter, and then Unlock(). My problem
    here is how to make the top_block aware of that count. I could use a
    “listener block” just after the gr_sig_source and let it count the
    samples that pass through it. After N samples, it could trigger some
    signal to the top block. I don’t like this approach because it seems
    too complex.

  • Extend the functionality of gr_sig_source to increase the frequency
    by itself. By directly extending the class that won’t work because
    there is no public constructor for gr_sig_source. Is there any other
    way of doing that?

  • Save N samples of different sine waves into files and then generate
    a single one by concatenation. I could use then a file_source block to
    incorporate these sine waves into any flow graph. The problem is the
    size of the resulting file.

I would appreciate very much any help on that.

I’m using gnuradio-3.2.2 and I want to generate a 100% C++ application.

Thanks,
Carlos.

PS: I haven’t posted any code because I don’t have any yet :slight_smile:

A few tips:

  1. you dont have to lock the flow graph to change parameters (just to
    disconnect and connect blocks)

  2. you simplify this problem a bit by using the
    gr_frequency_modulator_fc block. You can feed the frequency modulator a
    step function that increases every N samples.

you could probably generate the input to the modulator with a ramp
function (sig source), a sample and hold block, and the vector source to
control the sample and hold block

-Josh