discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: Gnuradio: SineWave generator python block choppy audio out


From: Achilleas Anastasopoulos
Subject: Re: Gnuradio: SineWave generator python block choppy audio out
Date: Wed, 26 May 2021 12:47:26 -0400

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

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