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: Marcus Müller
Subject: Re: Gnuradio: SineWave generator python block choppy audio out
Date: Wed, 26 May 2021 13:22:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

err Oh! I shouldn't have answered in a hurry, sorry!
The method self.nitems_written(0) gives you the items your block has already 
produced, so
that at each call to work() the sine continues exactly where it left off.
My apologies for the confusion this caused,
Marcus

On 26.05.21 13:06, Mitja kocjančič wrote:
> OK, I tried it even on GNURadio 3.9 and self.noutputs_written(0) is still not 
> defined
> https://imgur.com/ylW1uGy <https://imgur.com/ylW1uGy>
> 
> so is there any other way to set startnrto the right value so my audio won't 
> be choppy
> 
> BTW: side question, is it possible to somehow tell gnuradio to always use 
> notepad++ as its
> editor (config option or something)?
> 
> 
> V V sre., 26. maj 2021 ob 11:59 je oseba Marcus Müller <mmueller@gnuradio.org
> <mailto:mmueller@gnuradio.org>> napisala:
> 
>     Sorry, the function is called self.noutputs_written() of course.
> 
>     https://github.com/rftap/gr-rftap <https://github.com/rftap/gr-rftap> 
> shouldn't be
>     necessary, usually; I think gr-ieee802-11
>     even contains exactly this functionality!
> 
>     gr-rds has definitely been ported to 3.8 (it's even the default branch), 
> and 3.9 (the
>     maint-3.9 branch).
> 
>     Best regards,
>     Marcus
> 
>     On 26.05.21 10:37, Mitja kocjančič wrote:
>     > Thanks you very much
>     > the reason I use gnuradio 3.7 is because some OOT modules
>     >
>     > gr-rftap https://github.com/rftap/gr-rftap 
> <https://github.com/rftap/gr-rftap>
>     <https://github.com/rftap/gr-rftap <https://github.com/rftap/gr-rftap>>
>     > gr-rds (don't know about this one but probably would work on 3.9):
>     > https://github.com/bastibl/gr-rds <https://github.com/bastibl/gr-rds>
>     <https://github.com/bastibl/gr-rds <https://github.com/bastibl/gr-rds>>
>     >
>     > do not work on gnuradio 3.9 (rftap doesn't even work on 3.8) and I am 
> waiting for
>     them to
>     > port over
>     >
>     > am not sure where you got
>     > ninputs_written(0) from as its not defined and even looked in gnuradio 
> 3.9 source
>     code and
>     > couldn't find it mentioned anywhere
>     >
>     >
>     >
>     > V V sre., 26. maj 2021 ob 00:18 je oseba Marcus Müller 
> <mmueller@gnuradio.org
>     <mailto:mmueller@gnuradio.org>
>     > <mailto:mmueller@gnuradio.org <mailto:mmueller@gnuradio.org>>> napisala:
>     >
>     >     Hi Mitja!
>     >
>     >     Great to have you here :)
>     >
>     >
>     >     Couple of things up front:
>     >
>     >     1. This is GNU Radio 3.7. Especially if you want to implement 
> things in Python
>     blocks, 3.8
>     >     or later is a *must*. GNU Radio 3.7 is really just in legacy 
> keepalive mode, not
>     actively
>     >     developed. Please update to GNU Radio 3.8 or 3.9. You really should 
> not start
>     developing
>     >     for GNU Radio 3.7 in 2021!
>     >     2. WX GUI is dead. We stopped being able to support it a long time 
> ago. Please
>     use Qt GUI
>     >     instead.
>     >
>     >     All in all, please update your version of GNU Radio. In case any 
> bugs occur, we
>     won't be
>     >     able to help you with GNU Radio 3.7. GNU Radio 3.8 can be natively 
> installed on
>     almost all
>     >     modern Linux distros directly from their package managers, and on 
> Windows, and
>     OS X using
>     >     conda and other tools, without any complications.
>     >
>     >     With that out of the way, let's look at your code:
>     >
>     >             for i in range(0, len(output_items[0])): #8192
>     >                 output_items[0][i] = np.sin(2 * np.pi * self.frequency 
> * (i /
>     >     self.sample_rate)) * self.amplitude
>     >
>     >     No surprise the sound is choppy! You reset your i to 0 for every 
> new call to work();
>     >     however, GNU Radio doesn't guarantee that work is called with 
> number of items
>     equal to a
>     >     multiple of your sine period.
>     >     So, this is a bug in your design. What you'd want is really 
> something like
>     >
>     >     def work(self, input_items, output_items):
>     >        # get rid of the for loop!
>     >        startnr = self.ninputs_written(0)
>     >        f_rel = 2 * np.pi * self.frequency / self.sample_rate
>     >        number = len(output_items[0])
>     >        output_items[0][:] = self.amplitude*np.sin(f_rel * 
> np.arange(startnr,
>     startnr+number))
>     >        return number
>     >
>     >     Best regards
>     >     Marcus
>     >
> 



reply via email to

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