Hi all,

I do not think that the proposed algorithm by Marcus is the correct way to
implement this block,
because it assumes that the frequency has remained the same throughout the
life of the block!
The correct way is to keep a state variable (say, "self.phase") that is
initialized to 0 and  records the accumulated state (modulo 2 pi) up to the
last call of work.
Then in one call of work you should just generate the sin wave as suggested:

f_rel = 2 * np.pi * self.frequency / self.sample_rate
number = len(output_items[0])
phases = (f_rel * np.arange(0,number)+self.phase ) % (2*np.pi)
output_items[0][:] = self.amplitude*np.sin(phases)
self.phase=phases[-1]+ f_rel

best
Achilleas

Reply via email to