Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display of additional metadata (genre, audio/data service types) #16

Open
markjfine opened this issue Jan 25, 2021 · 36 comments
Open

Display of additional metadata (genre, audio/data service types) #16

markjfine opened this issue Jan 25, 2021 · 36 comments

Comments

@markjfine
Copy link

markjfine commented Jan 25, 2021

Pretty new to this and late to the party...

After a few days playing around with this, was thinking about adding the following:

  1. Adding "Genre" to the track listing. Like "Album", it's not often used, but it's there sometimes.
  2. Adding the various audio types for each stream to the Info tab. For one thing, it helps to know how many streams are actually being used by each station, and what each is providing. Ultimately this could be used to limit the stream selector at the top to just the number of streams actually being used.
  3. Adding the various data types for each station to the Info tab. Like the audio types, this helps to know which ones are providing image maps/navigation for weather and traffic.

I'm not a Python developer, but I've made some preliminary changes to nrsc5_gui.py and main_form.glade to display these things. I can provide a diff to the one provided in 2.0.0 if interested.

Some images:
Screen Shot 2021-01-24 at 9 27 19 PM
Screen Shot 2021-01-24 at 9 28 14 PM

@markjfine
Copy link
Author

Made a few more changes:

  1. Updated to use the new open and ppm API, per the repository.
  2. Added info for message, alert, and stream names per the SIS/SIG events.
  3. Made the stream names/types clickable so you can change to them.

Screen Shot 2021-01-25 at 4 01 18 PM

@markjfine
Copy link
Author

May have also found a small bug that prevents album art from updating properly. Currently, it updates the album art after switching from the initial logo image, but self.xhdr_changed towards the end of update() may be preventing it from updating it after that. Might be a timing thing where the image changes before XHDR does, in which case it never gets past the test.

Recommend changing
if self.xhdr_changed and self.last_image != image and os.path.isfile(image_path):
to either
if (self.last_image != image) and os.path.isfile(image_path):
or
if (self.xhdr_changed or (self.last_image != image)) and os.path.isfile(image_path):
the latter, using an 'or' instead of an 'and' to pass the test whenever XHDR changes.

@secludedhusky
Copy link

Would it be possible for you to make a pull request with these changes?

@markjfine
Copy link
Author

markjfine commented Feb 13, 2021

How about a patch against the v2 baseline of main_form.glade and nrsc5_gui.py...

[Don't know if this needs to be said, but if your patch creates new files, it will create something with "_new." added to the filename. After applying, you may have to rename the originals as "_old.", then remove the "_new" part from the new ones in order to run them.]

nrsc5_gui_v2_mjf_enhancements.diff.txt

@secludedhusky
Copy link

Could you provide the nrsc5.py file as well? It gives me errors every time I try to get the Data Svcs working, telling me that the data couldn't be found.

@markjfine
Copy link
Author

You might as well pull down the whole v2.0.0 baseline again and make sure you've updated the nrsc5 to it's latest version (I think it's 2.7.5). It sounds like you may have broke something. I didn't modify nrsc5.py at all, and it wouldn't be appropriate for me to re-post it here.

@andrewfer000
Copy link

andrewfer000 commented Mar 10, 2021

I applied your patch and the new features seem to work well (if the station broadcasts that info.) I feel like this is ready for a PR. The only thing I think would be a nice change is to lessen the space (padding?) around the album art. I feel like with a little more improvement overall this program would make a cool app for the GNU/Linux Smartphones.

@markjfine
Copy link
Author

Cheers. And I tend to agree about the white space around the album art. As I've said, I'm no Python guru, but there might be a way to stretch the image to proportionately fill the area.

@andrewfer000
Copy link

andrewfer000 commented Mar 10, 2021

changing pixbuf = pixbuf.scale_simple(200, 200, GdkPixbuf.InterpType.HYPER) to 256, 256, will stretch the image. Although it does make the album art look a little blurry.

@markjfine
Copy link
Author

I've even tried setting GtkImage properties vexpand and hexpand to TRUE, valign and halign to GTK_ALIGN_FULL to see if I couldn't get the thing to stretch to the full size, then just direct load the img_cover and logo using set_from_file()... no joy.
May be another way to display a filled image in something other than an GtkAlignment widget, and then set a sizing callback for when the window size changes. Think the GtkAlignment is keeping it from doing what we want it to do.

@markjfine
Copy link
Author

BTW Can using InterpType.BILINEAR instead of InterpType.HYPER and see if the blurriness goes away.

@secludedhusky
Copy link

secludedhusky commented Mar 10, 2021

Hey Mark. What OS are you using for this? I'm using Kubuntu 20.04 and I've had nothing but errors trying to get the patch applied.

It's not able to find any of the station data from my RTL SDR, even on confirmed stations with HD.

Also, making a pull request would be highly suggested so that the creator's of this program can promptly update their program.

And, I'm curious how you're not a python guru but you know more about python than me and I've been doing it for 4-5 years now.

@markjfine
Copy link
Author

markjfine commented Mar 10, 2021

I'm on a MacBook Pro, but that should be irrelevant if you've pulled down (and built from) the most recent code, and are using Python3 (not 2), since that's what I worked from:
nrsc5: github clone https://github.com/theori-io/nrsc5.git
nrsc5-gui: github clone https://github.com/cmnybo/nrsc5-gui.git

@andrewfer000
Copy link

Changing HYPER to BILINEAR did not change anything at least for me.

@markjfine
Copy link
Author

markjfine commented Mar 10, 2021

ok... think I got the image thing partially solved:

  1. In main_form.glade, change the GtkAlignment to a GtkScrolledWindow, name it 'alignment_cover' and comment out all the padding:
    <!--object class="GtkAlignment" id="alignmentCover"-->
    <object class="GtkScrolledWindow" id="alignment_cover">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <!--property name="top_padding">6</property-->
    <!--property name="bottom_padding">6</property-->
    <!--property name="left_padding">6</property-->
    <!--property name="right_padding">6</property-->

  2. Also in main_form.glade, similarly modify the GtkImage as follows (Actually not so sure if this is necessary, but couldn't hurt:
    <object class="GtkImage" id="img_cover">
    <!--property name="width_request">200</property-->
    <!--property name="height_request">200</property-->
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="expand">TRUE</property>
    <property name="halign">GTK_ALIGN_FILL</property>
    <property name="valign">GTK_ALIGN_FILL</property>
    </object>

  3. In nrsc5_gui.py, search for # get controls and add a line to reference the scrolled window above img_cover:
    self.notebook_main = builder.get_object("notebook_main")
    self.alignment_cover = builder.get_object("alignment_cover")
    self.img_cover = builder.get_object("img_cover")

  4. Also in nrsc5_gui.py, search for the two places where img_cover gets filled (def display_logo, and def check_status) and modify as follows (they're both similar):

in def display_logo:

self.stream_info["logo"] = self.station_logos[self.station_str][self.stream_num]
img_size = min(self.alignment_cover.get_allocated_height(), self.alignment_cover.get_allocated_width())
pixbuf = GdkPixbuf.Pixbuf.new_from_file(logo)
pixbuf = pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)
self.img_cover.set_from_pixbuf(pixbuf)

and in def check_status:

self.last_image = image
img_size = min(self.alignment_cover.get_allocated_height(), self.alignment_cover.get_allocated_width())
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path)
pixbuf = pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)
self.img_cover.set_from_pixbuf(pixbuf)

Adding a callback to redraw the image on a window resize should be trivial, but this being Python and not true Gtk/Gdk I'm having a mental block at getting the syntax right atm.

@markjfine
Copy link
Author

Changing HYPER to BILINEAR did not change anything at least for me.

Yeah, it's minimal. BILINEAR should be a little quicker in terms of clock cycles though.

@markjfine
Copy link
Author

Now I'm thinking how:

  1. The freq spinner should accept a return as a play event.
  2. Realize the stream spinner helps with the real estate, but is pretty useless imo. Would much rather have a small row of 4 buttons between the freq setting and the notebook that a) has the stream 'name' on it, b) jumps to the stream when pressed.
  3. How cmnybo is secretly hating on me for messing with his creation. lol

@andrewfer000
Copy link

Make your changes and generate a diff. I'll be glad to test it out.

@markjfine
Copy link
Author

markjfine commented Mar 11, 2021

Got the callback sorted:

All in nrsc5_gui.py...

  1. In def _init_, add an init for self.cover_img between last_image and last_xhdr:
    self.last_image = ""
    self.cover_img = ""
    self.last_xhdr = ""

  2. In def display_logo save logo to cover_img:
    pixbuf = GdkPixbuf.Pixbuf.new_from_file(logo)
    self.cover_img = logo
    pixbuf = pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)

  3. In def check_status/def update() right after clearing img_cover, also init cover_img:
    if not os.path.isfile(image_path):
    self.img_cover.clear()
    self.cover_img = ""

then, as with logo, save image_path to cover_img:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_path)
self.cover_img = image_path
pixbuf = pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)

  1. At the end of def get_controls, add the connect for the resize event:
    self.lv_bookmarks.set_model(self.ls_bookmarks)
    self.lv_bookmarks.get_selection().connect("changed", self.on_lv_bookmarks_sel_changed)
    self.main_window.connect("check-resize", self.on_cover_resize, self.img_cover)

  2. And finally, just before def display_logo, add the callback:
    def on_cover_resize(self, container, image_widget):
    if self.cover_img != "":
    img_size = min(self.alignment_cover.get_allocated_height(), self.alignment_cover.get_allocated_width())
    pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.cover_img)
    pixbuf = pixbuf.scale_simple(img_size, img_size, GdkPixbuf.InterpType.BILINEAR)
    image_widget.set_from_pixbuf(pixbuf)

@markjfine
Copy link
Author

Make your changes and generate a diff. I'll be glad to test it out.

Might be a tomorrow problem. Definitely like the button idea though. Constantly looking at the info tab was getting kind of cumbersome.

That said, I've noticed an interesting phenomenon with a station in NYC where the stream name and stream description don't correlate to the same stream index. WNSH 94.7 has CBS Sports on stream index 2, but the description for it is on index 1. Even stranger, Wikipedia says it's no longer in use, even though the station is still transmitting the confusing markers. Weird.

@markjfine
Copy link
Author

Incorporated all the changes above, plus added the 'return to tune' & the stream buttons. Not totally thrilled with the way the buttons work because they'll expand the whole window if the station uses long names, but it's a start.

Diff is as before: Created against most recent versions of main_form.glade and nrsc5-gui.py here on github.

If my previous diff was applied, unsure what re-applying this would do depending upon your version of diff, etc. So it's best to start by pulling down raw versions of these files from the Code section as the baseline, and apply the patch against that.

Once applied, you will have to realign the file names: Rename the original files to *_old to save them, and remove the *_new part of the patched ones.

Enjoy.

nrsc5_gui_v3_mjf_enhancements.diff.txt

@andrewfer000
Copy link

andrewfer000 commented Mar 11, 2021

I like the new buttons! This works great for me! Thank you for your contribution! I do think the album art is a little big though but that is okay. Also it would be a nice touch if the button stayed highlighted when on a station but that's not necessary either.

Here is a screenshot:
image

Now I just need to work on fixing
ALSA lib pcm.c:8526:(snd_pcm_recover) underrun occurred

Which for some reason is happening more but as I continue my testing it could be my environment that could be causing it. Not sure tbh.

I plan on testing this application on a RPi when I get one and maybe a PinePhone if I ever get one of those. (I wish Linux Phones had SDRs built into them. Even if it is just one of those cheap DVB tuners...)

@markjfine
Copy link
Author

If you want to re-insert a 6-pixel border, find the three places where img_size is calculated, and just add - 12 to the end of the line(s). The image will be centered, so this will do essentially the same thing the GtkAlignment was doing.

@markjfine
Copy link
Author

So, the part that bothered me about the buttons was that they couldn't serve as an indicator of what stream was being used - like the preset buttons on an old school car radio. I've fixed that by changing them to toggle buttons, then eliminated the stream spinner, which truly became redundant. This also includes the 6-pixel space around the album art, described previously.

Patch attached. Usual disclaimers apply.
nrsc5_gui_v4_mjf_enhancements.diff.txt

@markjfine
Copy link
Author

markjfine commented Mar 16, 2021

Created pull requests for both of these (main_form.glade and nrsc5_gui.py), but have no idea if I've done it correctly.

@markjfine
Copy link
Author

Still not totally thrilled with the Frequency spinner being alone with a lot of white space around it. Thinking about possible ways to help fill that space: Add a text box to the right of the spinner, showing the station name (and slogan?), then add a small pilot image to show when the radio acquires/loses synchronization in the lower left corner (where the station name is now)... If anyone has any other ideas.

@markjfine
Copy link
Author

Added these to the pull request... I think.

@markjfine
Copy link
Author

Updated in the current pull request:

  1. Reordered the Info tab
  2. Fixed the way the Programs and Data Services were listed to be more relevant (and stable)
  3. Made the Program Buttons ellipcized to prevent expanding the window
  4. Removed the Slogan from the Frequency line to prevent expanding the window

@andrewfer000
Copy link

Can you give me a diff for these changes?

@andrewfer000
Copy link

Nevermind, I just pulled down the code from your repo. I like the changes. I'm onto something for the PyAudio problems but it's still W.I.P.

@markjfine
Copy link
Author

Cool. Guess I’ve set it up correctly. Was afraid the increments wouldn’t take.

One other thing I’d like to add is a way to group the bookmarks. I’m in NJ now, but all my bookmarks are for Virginia. This way you can have different sets of bookmarks for different locations, different station types, or whatever you want.

As for the PyAudio, are you sure it’s not an issue with the signal. I get rhythmic dropouts on some stations, but I just assume it’s from intermittent adjacent station interference and/or spurs on one of the sidebands. The RTL-SDR is kind of funky for these kinds of things and I find myself constantly adjusting the rabbit ears that come with it. This is one of the reasons why I’d really rather use an AirSpy HF+ Discovery... signal’s a lot cleaner.

@andrewfer000
Copy link

andrewfer000 commented Mar 19, 2021

As for the PyAudio, are you sure it’s not an issue with the signal. I get rhythmic dropouts on some stations, but I just assume it’s from intermittent adjacent station interference and/or spurs on one of the sidebands. The RTL-SDR is kind of funky for these kinds of things and I find myself constantly adjusting the rabbit ears that come with it. This is one of the reasons why I’d really rather use an AirSpy HF+ Discovery... signal’s a lot cleaner.

A few days ago, I found that setting the AUDIO_SAMPLE_RATE to 43400 from 44100 and it seems to work very well without distorting the audio. This may have something to do with digital radio. Also, on other programs like nrsc5 by itself and hdfm there are no audio dropouts or signal issues.

@markjfine
Copy link
Author

markjfine commented Mar 19, 2021

Didn't notice the odd-ball sample rate. I would think that 44100 or 48000 would be standard.

Anyway, wrapped img_map in a scrolled window, adjusted some resize things and now have prototype stretchy travel and weather maps. I'll post the changes after I've tested it some.

@secludedhusky
Copy link

image

I appear to have gotten it to work so far. Everything is in order, however it's reporting that stations have Traffic info even though they don't.

image

Appreciate the work that you have spent on this program Mark, thanks for the help :3

@andrewfer000
Copy link

Yes - If you want even more features and audio stability, check out the new fork. We could always use more testers.

@markjfine
Copy link
Author

The Traffic/Navigation that station provides is via NavTeq/HERE, which is currently unsupported by nrsc5. It only supports maps from Total Traffic and Weather Network on iHeart Media stations. There was an issue in the version I posted here in that it was pulling info from a data type description, not the actual name of the service. As @andrewfer000 states, it's 'fixed' in the new fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants