Author Topic: (Version 1.8) Spectrogram Panel Plugin  (Read 73970 times)

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
When I try to get the new debug file, MediaFire returns with "Download not available yet because the upload for this file is still in progress. Approximate completion time below (no time appears-svk)
Download ready soon…"

Update 5.5: Configuration panel now integrated with MusicBee. Debug logging to "MBSpectrogramLog.txt" in Dependencies folder (cleared on restart). Other general improvements.

https://www.mediafire.com/file/en7mdu45c773amb/MusicBee_Spectrogram_1.5.zip/file

sveakul

  • Hero Member
  • *****
  • Posts: 1991
Link in your last post gives the "Upload in progress.." error message from MediaFire, downloaded plugin from first page post.

Positive:  superb work integrating the option menu into the MB plugin panel, works fine.

Negative:  after playing a music file (which generates/displays an image), playing a stream afterwards still generates a duplicate PNG to the previous file, and names it according to the stream title.  Subsequent streams do not exhibit the problem, however, if you then go back and play a file that generates an image and go back to streams, the first stream played after THAT music file will also save a stream-named image, repeat.

Also noticed that starting MB with no images at all in the Spectrogram_Images folder (nothing to delete) will create an entry in the debug log indicating "Image found..."  The start of that log (before playing anything) looks like this:

3/1/2019 7:52:40 PM: Spectrogram Images Deleted..
3/1/2019 7:52:40 PM: Track changed or Plugin Startup..
3/1/2019 7:52:40 PM: Current Song Duration: 0.
3/1/2019 7:52:41 PM: Raw Title: --701-222 ////// Processed Title: --701-222.
3/1/2019 7:52:41 PM: Current Song Duration: 0.
3/1/2019 7:52:41 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\--701-22206adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:52:41 PM: Image found..
3/1/2019 7:52:41 PM: Raw Title: --701-222 ////// Processed Title: --701-222.
3/1/2019 7:52:41 PM: Current Song Duration: 0.

Here is an abridged version of the log after a music file is played, then a stream right after:

3/1/2019 7:54:03 PM: Track changed or Plugin Startup..
3/1/2019 7:54:03 PM: Current Song Duration: 221120.
3/1/2019 7:54:03 PM: Raw Title: Bashed Out-This Is the Kit-701-222 ////// Processed Title: BashedOut-ThisIstheKit-701-222.
3/1/2019 7:54:03 PM: Current Song Duration: 221120.
3/1/2019 7:54:03 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\BashedOut-ThisIstheKit-701-2222211206adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:54:03 PM: Beginning generation of image..
3/1/2019 7:54:03 PM: FFMPEG Custom Path Set To: c:\ffmpeg\ffmpeg.exe
.
3/1/2019 7:54:03 PM: Raw Title: Bashed Out-This Is the Kit-701-222 ////// Processed Title: BashedOut-ThisIstheKit-701-222.
3/1/2019 7:54:03 PM: Current Song Duration: 221120.
3/1/2019 7:54:03 PM: FFMPEG Arguments: -i "E:\New Mx\This Is the Kit - Bashed Out.flac" -lavfi showspectrumpic=s=701x222:mode=combined:legend=enabled:saturation=2:color=rainbow:scale=log:win_func=hann:gain=1 "C:\MusicBee\AppData\Dependencies\Spectrogram_Images\BashedOut-ThisIstheKit-701-2222211206adc5a76f5844dca05007858ab172af3".png.
3/1/2019 7:54:05 PM: Process ended..
3/1/2019 7:54:05 PM: Raw Title: Bashed Out-This Is the Kit-701-222 ////// Processed Title: BashedOut-ThisIstheKit-701-222.
3/1/2019 7:54:05 PM: Current Song Duration: 221120.
3/1/2019 7:54:05 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\BashedOut-ThisIstheKit-701-2222211206adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:54:05 PM: Image found..
3/1/2019 7:54:05 PM: Raw Title: Bashed Out-This Is the Kit-701-222 ////// Processed Title: BashedOut-ThisIstheKit-701-222.
3/1/2019 7:54:05 PM: Current Song Duration: 221120.
3/1/2019 7:54:05 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\BashedOut-ThisIstheKit-701-2222211206adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:54:05 PM: Raw Title: Bashed Out-This Is the Kit-701-222 ////// Processed Title: BashedOut-ThisIstheKit-701-222.

<cut out dupe info>

3/1/2019 7:54:25 PM: Track changed or Plugin Startup..
3/1/2019 7:54:25 PM: Current Song Duration: 221120.
3/1/2019 7:54:25 PM: Raw Title: Come Home (Zetandel Chillout Remix)-Roman Messer-701-222 ////// Processed Title: ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222.
3/1/2019 7:54:25 PM: Current Song Duration: 221120.
3/1/2019 7:54:25 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\ComeHome(ZetandelChilloutRemix)-RomanMesser-701-2222211206adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:54:25 PM: Beginning generation of image..
3/1/2019 7:54:25 PM: FFMPEG Custom Path Set To: c:\ffmpeg\ffmpeg.exe
.
3/1/2019 7:54:25 PM: Raw Title: Come Home (Zetandel Chillout Remix)-Roman Messer-701-222 ////// Processed Title: ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222.
3/1/2019 7:54:25 PM: Current Song Duration: 221120.
3/1/2019 7:54:25 PM: FFMPEG Arguments: -i "E:\New Mx\This Is the Kit - Bashed Out.flac" -lavfi showspectrumpic=s=701x222:mode=combined:legend=enabled:saturation=2:color=rainbow:scale=log:win_func=hann:gain=1 "C:\MusicBee\AppData\Dependencies\Spectrogram_Images\ComeHome(ZetandelChilloutRemix)-RomanMesser-701-2222211206adc5a76f5844dca05007858ab172af3".png.
3/1/2019 7:54:27 PM: Process ended..
3/1/2019 7:54:27 PM: Track changed or Plugin Startup..
3/1/2019 7:54:27 PM: Current Song Duration: -1.
3/1/2019 7:54:27 PM: Raw Title: Come Home (Zetandel Chillout Remix)-Roman Messer-701-222 ////// Processed Title: ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222.
3/1/2019 7:54:27 PM: Current Song Duration: -1.
3/1/2019 7:54:27 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222-16adc5a76f5844dca05007858ab172af3.png.
3/1/2019 7:54:27 PM: Image found..
3/1/2019 7:54:27 PM: Raw Title: Come Home (Zetandel Chillout Remix)-Roman Messer-701-222 ////// Processed Title: ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222.
3/1/2019 7:54:27 PM: Current Song Duration: -1.
3/1/2019 7:54:27 PM: Image Check: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\ComeHome(ZetandelChilloutRemix)-RomanMesser-701-222-16adc5a76f5844dca05007858ab172af3.png.

If you need the entire log file, let me know, but the pattern is the same as the above.  BTW the dupe file png named for the stream and saved only stays in the display window for 1-2 secs while the first stream plays, remaining  blank for subsequent streams until a new file is played, when behavior will then repeat.

sveakul

  • Hero Member
  • *****
  • Posts: 1991
Another suggestion:  ability to not display the "Images Deleted" popup on MusicBee opening, just delete them silently when the delete on startup option is selected.

The new color options make for some nice graphics!!  https://getmusicbee.com/forum/index.php?topic=2258.msg155817#msg155817

Thanks for this plugin,  I hope you are able to diagnose the problem with errant image generation when switching from file to stream.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
Another suggestion:  ability to not display the "Images Deleted" popup on MusicBee opening, just delete them silently when the delete on startup option is selected.

The new color options make for some nice graphics!!  https://getmusicbee.com/forum/index.php?topic=2258.msg155817#msg155817

Thanks for this plugin,  I hope you are able to diagnose the problem with errant image generation when switching from file to stream.

Hey, that's great!

And yes, I can remove that message. It was really for debugging purposes more than anything else.

Your logs definitely indicate some weird behavior.  It seems to be ignoring a lot of conditions. I'm going to run mine again and compare.

Thanks for sending those over!

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
Yeah, there's definitely something wrong with ImgCheck(). It also looks like the current song duration was copied from the last-played track the first time you played that stream.

There also might be some weird behavior when you run a stream which resolves the track name instead of just the stream name.

Did you start MusicBee with a specific track queued up or something? I also don't get the blank image log at startup.

Are you on MusicBee 3.3.6996? It really seems like it's a bug with the API, but I'm going to keep looking into it on my end.


EDIT: I managed to replicate the issue, finally. Now I can troubleshoot it.
Last Edit: March 02, 2019, 04:32:59 PM by zkhcohen

sveakul

  • Hero Member
  • *****
  • Posts: 1991
From your *edit* message it seems like you've finally got the info you need to solve this if that's possible on your end, great!!  Yes could be the API.  FYI, yes I'm always running the latest Mb 3.3x patch version, and no, I don't start with anything queued up.  Good luck with this!

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
From your *edit* message it seems like you've finally got the info you need to solve this if that's possible on your end, great!!  Yes could be the API.  FYI, yes I'm always running the latest Mb 3.3x patch version, and no, I don't start with anything queued up.  Good luck with this!

Update 5.6: Attempt to fix stream image generation. Code optimizations.


The link on the first page should be updated. The debug logs should look a lot cleaner now that I've reduced the number of method calls.


EDIT: I've made some more improvements for the next release. Looking for a more reliable way of preventing streams from being generated because there's definitely an issue with the File Duration API call.

EDIT 2: Fixed it for good by using: mbApiInterface.NowPlaying_GetFileProperty(FilePropertyType.Size) != "N/A". Will release after I do some code cleanup.
Last Edit: March 02, 2019, 10:19:55 PM by zkhcohen

sveakul

  • Hero Member
  • *****
  • Posts: 1991
EDIT 2: Fixed it for good by using: mbApiInterface.NowPlaying_GetFileProperty(FilePropertyType.Size) != "N/A". Will release after I do some code cleanup.

Will hold off on any more testing then until I get a "go" from you here, sounds promising!

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
EDIT 2: Fixed it for good by using: mbApiInterface.NowPlaying_GetFileProperty(FilePropertyType.Size) != "N/A". Will release after I do some code cleanup.

Will hold off on any more testing then until I get a "go" from you here, sounds promising!


Update 5.7: Fixed stream image generated bug. Fixed track seeking when frequency legend is enabled.

The workaround wasn't quite as simple as I thought it would be. I also had to create a _lastPlayed variable, since it looks like ALL of the API "NowPlaying" calls carry over.

Interestingly, this only occurs for streams with "Continuous" next to them. They seem to start, then immediately restart, sending a second notification.

I'm going to create a bug report for this.

sveakul

  • Hero Member
  • *****
  • Posts: 1991
Testing version 5.7 with MusicBee 3.3.6998:

1.  The generation of a spurious image when a stream is played immediately after a file is FIXED (hurrah!).  Tried every combination I could to "break" it and could not.  Only file images are now saved/displayed.  Good job, zkhcohen!

2.  The image folder is now silently cleared on startup if that option is selected, no more popup to "OK."

3.  The seek within the spectrogram is now MUCH more accurate (frequency scale is enabled).

I realize the debug log is temporary, but wanted to mention that when an image IS generated for a file, the log gets very "excited":

3/2/2019 10:03:38 PM:

 Track changed or Plugin Startup.
3/2/2019 10:03:38 PM: Current Song Duration: 178901
3/2/2019 10:03:38 PM: Get file path.
3/2/2019 10:03:38 PM: Raw Title: 1000 Tonnen Glück-Grossstadtgeflüster-701-250 ////// Processed Title: 1000TonnenGlück-Grossstadtgeflüster-701-250
3/2/2019 10:03:38 PM: Size: 1.9 MB
3/2/2019 10:03:38 PM: Path: C:\MusicBee\AppData\Dependencies\Spectrogram_Images\1000TonnenGlück-Grossstadtgeflüster-701-2501789016adc5a76f5844dca05007858ab172af3.png
3/2/2019 10:03:38 PM: Beginning generation of image.
3/2/2019 10:03:38 PM: FFMPEG Custom Path Set To: c:\ffmpeg\ffmpeg.exe

3/2/2019 10:03:38 PM: Raw Title: 1000 Tonnen Glück-Grossstadtgeflüster-701-250 ////// Processed Title: 1000TonnenGlück-Grossstadtgeflüster-701-250
3/2/2019 10:03:38 PM: FFMPEG Arguments: -i "E:\New Mx\Grossstadtgeflüster - 1000 Tonnen Glück.opus" -lavfi showspectrumpic=s=701x250:mode=combined:legend=enabled:saturation=2:color=rainbow:scale=log:win_func=hann:gain=1 "C:\MusicBee\AppData\Dependencies\Spectrogram_Images\1000TonnenGlück-Grossstadtgeflüster-701-2501789016adc5a76f5844dca05007858ab172af3".png
3/2/2019 10:03:41 PM: Image generated.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:03:41 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:39 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
3/2/2019 10:04:43 PM: Image found.
<then waits until a new file is played before writing>

I mention that in case all these "calls" are taking unnecessary CPU time and can be reduced.  Also would like to suggest adding the OPTION to disable logging.

I would also like to submit a revised installation instruction for page one that more accurately reflects what I have experienced to get the plugin going (actually nothing needs to be "disabled then re-enabled", etc. like the popup indicates):

1. With MusicBee off, extract the file located in the "Plugins" folder to your MusicBee Plugins directory.

2. Start MusicBee.

3. A message will appear telling you where to place the plugin's "Dependencies" folder;  extract the whole folder there now.

4. In MusicBee navigate to Edit > Edit Preferences > Plugins. Ensure that "spectrogram-display" appears. Enable it, and hit Save.

5. Navigate to View > Arrange Panels...

6. Drag the "spectrogram-display" element from the "available elements" window to the "main panel" section to your desired position, for instance above the "now playing bar" element. Note: This is not the required location of the plugin, but it is HIGHLY RECOMMENDED that you position it here.  Hit Save.

7. Drag the top of the Spectrogram window where you have placed it to the desired height.

8. Try playing a song. After a second or two of processing, the spectrogram should appear.  You can seek through the song if desired within the spectrogram window.

9. See the first post of the plugin's thread on the MusicBee forum for instructions on using the plugin's built-in Configuration Panel and other important information.

NOTE:  If desired, the ffmpeg.exe supplied inside the Dependencies folder can be removed and a path given to your own copy of ffmpeg.exe elsewhere on the PC;  see step #9 for more details.  A 32-bit version of ffmpeg.exe (64-bit supplied) is necessary if you have a 32-bit OS.  The latest static release build at the Zeranoe site has been tested and works fine (https://ffmpeg.zeranoe.com/builds/).

Feel free to use any or none of the suggested modifications above.

Sir, GREAT JOB, and THANK YOU!
Last Edit: March 03, 2019, 03:44:17 AM by sveakul

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
Thanks for the feedback! Glad to hear that the issues are finally patched.

The StreamWriter isn't resource intensive but I'll make debugging optional. The "image found" spam is a result of the way that MusicBee re-paints the panel.

I'll also modify the README with your suggestions and consider simply swapping FFMPEG builds entirely.

sveakul

  • Hero Member
  • *****
  • Posts: 1991
Well, I guess I better report this, dang it...  Just noticed that the MusicBee error log is logging the following error every time MB is opened with the plugin active, though NOT generating any pop-up error window about it (which is why I never noticed until now--spotted an ErrorLog.dat file in my Appdata during a backup):

3/3/2019 1:38:06 AM - 6.1.7601.65536 - 3.3.6998.33948 P - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MusicBeePlugin.Plugin.CurrentTitle()
   at MusicBeePlugin.Plugin.ImgCheck()
   at MusicBeePlugin.Plugin.ReceiveNotification(String sourceFileUrl, NotificationType type)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at #=zGWVOIIfXVyqY4V9P1w==.#=z4MWx6ZgbQymW()


MB and the plugin continue functioning normally after the "stealth" error message.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
Well, I guess I better report this, dang it...  Just noticed that the MusicBee error log is logging the following error every time MB is opened with the plugin active, though NOT generating any pop-up error window about it (which is why I never noticed until now--spotted an ErrorLog.dat file in my Appdata during a backup):

3/3/2019 1:38:06 AM - 6.1.7601.65536 - 3.3.6998.33948 P - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MusicBeePlugin.Plugin.CurrentTitle()
   at MusicBeePlugin.Plugin.ImgCheck()
   at MusicBeePlugin.Plugin.ReceiveNotification(String sourceFileUrl, NotificationType type)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at #=zGWVOIIfXVyqY4V9P1w==.#=z4MWx6ZgbQymW()


MB and the plugin continue functioning normally after the "stealth" error message.



Fixed.



Update 5.8: Debugging Mode made optional. Fixed MusicBee error log spam. Code optimizations. Updated README.

Edit: Let me know if you have issues with songs playing in the background not always generating a picture. Happened once and I'm not sure if it's an issue with the API notifications or not.
Last Edit: March 03, 2019, 07:58:59 AM by zkhcohen

sveakul

  • Hero Member
  • *****
  • Posts: 1991
Version 5.8:  seems like the "money build."  No errors in MB error log are written.  Option to disable debug log works.  Different behavior on install: when first copying plugin dll to the MB Plugins folder and starting MB, a message about where to place Dependencies folder no longer appears (no big deal if you indicate where it should go in the readme).  Placed it myself in Appdata like usual, and followed normally.

Have not seen lack of image generation if minimized during a song change during an initial test, but will let you know if I ever do.

zkhcohen

  • Sr. Member
  • ****
  • Posts: 342
Version 5.8:  seems like the "money build."  No errors in MB error log are written.  Option to disable debug log works.  Different behavior on install: when first copying plugin dll to the MB Plugins folder and starting MB, a message about where to place Dependencies folder no longer appears (no big deal if you indicate where it should go in the readme).  Placed it myself in Appdata like usual, and followed normally.

Have not seen lack of image generation if minimized during a song change during an initial test, but will let you know if I ever do.

Awesome! I'll look into the dependencies message. I think I might have killed it when I fixed the error spam.

Steven responded to my other topic (the bug report) so hopefully I'll be able to get him enough info to give me a permanent solution.