Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foo_vis_milk2 (Read 4083 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo_vis_milk2

foo_vis_milk2 is a foobar2000 component that ports Winamp's MilkDrop 2 music visualizer. In addition, I have updated rendering from the original DirectX 9 to DirectX 11. Thus, it no longer requires any additional components to run and includes a 64-bit DLL.

It is available in the components repository.

Enjoy!

Re: foo_vis_milk2

Reply #1
Very very nice. How did the port of the expression evaluator VM go?

Re: foo_vis_milk2

Reply #2
There were lots of memory leaks and type issues, using lots of insecure string functions. So, I "replaced" what was in the open-source release with its successor from WDL. That took care of some issues as that library is maintained and much more portable (to both x86-64 and ARM). The version in the open-source release leaks memory and is not immune to segfaults.

The downside is that the syntax has evolved. So, many presets that use very old syntax will throw compilation errors. Functions that have issues are:
  `assign`, `if`, `equal`, `below`, `above`, `bnot`, `megabuf`, `gmegabuf`, `sigmoid`, `band`, `bor`

Example of broken preset:
Code: [Select]
per_frame_22=vx2 = if(above(x2,0),vx2,abs(vx2)*0.5);

Should be:
Code: [Select]
per_frame_22=vx2 = x2 > 0 ? vx2 : abs(vx2) * 0.5;

I do intend to release the code. Just have to find some time to set up the repo in a way such that it is not an archaeological dig to get it going outside of my dev environment.

Re: foo_vis_milk2

Reply #3
1. Settings items display incompletely on monitors larger than 100% zoom
2. Full screen mode causes fb to crash immediately

Re: foo_vis_milk2

Reply #4
Lots of text:
1. The screens on my test machine are 150% and 175%. They both render completely. There is no guidance on what the proper size of the dialog should be. It is not a resizable window so I used the dimensions from the SDK sample and left some margin for lack of a better option. But yeah, I crammed too much into the single preference window because when I tried to do tabs like the source foobar2000 kept crashing. The upside is many of these settings are no longer applicable or would have any effect. For example, the maximum FPS for the windowed version will not be touched because it the visualization always thinks it is in fullscreen mode. Which leads me to...
2. Yes, I apologize. It is mentioned in the release notes. I debated whether to even allow it or not. It was not a simple issue to track down or consistently reproducible. What follows is not really documented anywhere I could find and took many months to work out what the player is doing. But in essence, foobar2000 does not do fullscreen mode, like say a game would, in which the window where the visualization is running is made fullscreen. It creates a new window for it and keeps everything else running in the background. However, it does not destroy the "windowed" visualizer's window--which MilkDrop already thinks is fullscreen and does not handle a DirectX device getting lost gracefully. So that needs to be paused (otherwise there would be 2 parallel visualizations going clobbering each other), a new entire Direct3D device created and lots of pointers/timers managed including moving the settings. Then on the "fullscreen" window exiting, the "fullscreen" window is destroyed and the "windowed" version needs to be started up again. However, the original window is not reinitialized. It is weird and there are lots of issues to work out in the resource management rendering pipeline of the legacy "vis_milk2" library. No excuses, just laying out the issues because I haven't seen any of the other open-source visualizations for foobar2000 deal with this in any elegant/robust way with modern Direct3D.

Re: foo_vis_milk2

Reply #5
"Supports the Default User Interface (Default UI) only."

It crashes......



Re: foo_vis_milk2

Reply #8
Thanks everyone for taking a look. I would appreciate any information you can provide to help me narrow down the reason for your crashes.

There are 4 known crash modes that I know of at the moment: a corrupt/missing data/ folder, missing/empty presets/ folder, corrupt "config.sqlite" and fullscreen mode. The latter I believe is fixed, or at least vastly improved, in version 0.0.226-alpha. The "config.sqlite" issue can be fixed by deleting the configuration store. The first three all are "fail to initialize" issues which cause foobar2000 to abruptly exit.

I would not have released the component if the main functionality was broken. I've been running this component with DirectX 11 (looking at the Git log) since April 20, 2023. I removed Shpeck that week. I run foobar2000 for several hours a day and almost every day with the component loaded and visible. The configuration of my machine is: NVIDIA Quadro T2000, Microsoft Windows 11, foobar2000 v2.1.2 (x86, x64)

Cheers!

Re: foo_vis_milk2

Reply #9
Do you intend to release a version that supports CUI?

Re: foo_vis_milk2

Reply #10
The component continues to crash, simply by calling it from the View / Visualition menu.

Re: foo_vis_milk2

Reply #11
Do you see any message in the console? Or if it crashes foobar2000 entirely there should be a failure_*.txt file under <install path>\profile\crash reports\ folder. An example of what you might see in the console log is:
foobar2000 v2.1.2 x64
foo_vis_milk2: Could not initialize MilkDrop
----
Sorry, CUI is not a feature I planned as I don't use it myself. I'm in the process of porting all of the D3DX text rendering to Direct2D/DirectWrite next. Plus figuring out why basic functionality is broken for some here. I know this is not the developer forum but if anyone is interested in implementing CUI support and testing it then I can give them source repo access before I release the code.

Re: foo_vis_milk2

Reply #12
Do you see any message in the console? Or if it crashes foobar2000 entirely there should be a failure_*.txt file under <install path>\profile\crash reports\ folder. An example of what you might see in the console log is:
foobar2000 v2.1.2 x64
foo_vis_milk2: Could not initialize MilkDrop
----
Sorry, CUI is not a feature I planned as I don't use it myself. I'm in the process of porting all of the D3DX text rendering to Direct2D/DirectWrite next. Plus figuring out why basic functionality is broken for some here. I know this is not the developer forum but if anyone is interested in implementing CUI support and testing it then I can give them source repo access before I release the code.

Re: foo_vis_milk2

Reply #13
Thanks for the report. The message "minFeatureLevel too high" is due to a corrupt configuration when creating the D3D device. I have released a new version (0.0.227-alpha) that should work around that error. Hope it launches now. Tested both launching through the "View" menu and adding as a UI panel. Grazie mille!!

Re: foo_vis_milk2

Reply #14
The two tests I did seem to pass successfully:




Re: foo_vis_milk2

Reply #15
if anyone is interested in implementing CUI support and testing it

If your source code is self contained without me faffing around installing dependencies and I can build it with VS 2022, I'll have a go.

Quote
then I can give them source repo access before I release the code.

Assuming github, I have the same username there as I do here.

Re: foo_vis_milk2

Reply #16
There were lots of memory leaks and type issues, using lots of insecure string functions. So, I "replaced" what was in the open-source release with its successor from WDL. That took care of some issues as that library is maintained and much more portable (to both x86-64 and ARM). The version in the open-source release leaks memory and is not immune to segfaults.

I've also rewritten Milkdrop's expression parser from scratch last year, in pure C to make it highly portable and reusable. I've taken great care to implement all syntactic sugar, features, hidden functions and even the smaller quirks (e.g. returning variable references in if()) to make it basically 100% compatible with ns-eel2. I've actually kept the implementation itself so close to the original that it was easy to add a small shim for ns-eel2.h, making this library a zero-change drop-in replacement for ns-eel2 in Milkdrop. It may be a tiny bit slower in some places as it doesn't use assembly, but I couldn't really notice a real difference to the original library - partially because ns-eel2 uses very old FPU instruction sets in the assembly code, while the C code can be highly optimized for modern CPUs by the compiler.

Just check it out, it's easy to integrate, has no memory leaks (if used properly of course) and I couldn't get it to segfault. I've licensed it under MIT, so it can be used in closed-source applications as well.

The only notable difference to ns-eel2 is that it won't parse expression code which is syntactically incorrect. A few presets have broken code, which may run (partially) in Milkdrop, but this parser won't compile the affected program/code block at all. Since the behavior is "undefined" at best in cuah a case, this isn't really an issue IMO.

Here's the repo i you want to check it out, the library has no dependencies and compiles on basically any platform and architecture:
https://github.com/projectM-visualizer/projectm-eval

This library can parse the "broken" example code from above just fine:
Code: [Select]
per_frame_22=vx2 = if(above(x2,0),vx2,abs(vx2)*0.5);

Re: foo_vis_milk2

Reply #17
@marc2k3 I'm almost done making it so that it's at no-faff level for you. All 4 platforms build automatically in the CI pipeline (x86, x64, ARM64, ARM64EC)! So, you should be able to get set up quickly. Taking the weekend off but I'll add you when I get back next week. And I've fixed a lot of small miscellaneous issues.

@codav Looks cool. I did most of this work over a year ago, but if I recall correctly most of the bad issues seem to be around NSEEL_VM_resetvars. You're my hero if that works without issue. Hopefully portable means ISAs as well as OSes. I'll try it out.

Re: foo_vis_milk2

Reply #18
Published an update 0.0.229-alpha. It has lots of new functionality and is (in my testing) more stable in spite of the extra stuff :)

Almost ready to release the source. Enjoy.

WARNING: foobar2000 replaces everything in the component's directory during install. To prevent deletion of the "presets" folder move it temporarily or extract the archive and overwrite the existing DLL.

NOTE: Keyboard messages from foobar2000 propagate to the component only during "fullscreen" or "windowed" modes. Not in "embedded" mode. Including a quick cheat sheet of the basic ones.

Keyboard Commands
-----------------
GENERAL
 ESC: toggle help message, playlist or fullscreen

PRESET LOADING
 BACKSPACE: return to previous preset
 SPACE: transition to next preset
 H: instant hard cut to next preset
 R: toggle random or sequential preset traversal
 + / -: rate current preset (better/worse)
 scroll lock: lock/unlock current preset (keyboard light on means preset is locked)
 A: aggregate preset - loads a random preset, steals the warp shader from a different random preset and steals the composite shader from a third random preset
 D: cycle between various lock-states for the warp and composite shaders; when one of these shaders is locked, loading a new preset will load everything *except* the locked shaders, creating a mix between the two presets.
 N: show per-frame variable monitor

MUSIC PLAYBACK
 Z / X / C / V / B: playback (previous / play / pause / stop / next)
 U / S: toggle shuffle (playback order) modes
 P : show playlist
 up / down arrows: volume up / down
 left / right arrows: rewind / forward 5 seconds
 SHIFT + left / right arrows: rewind / forward 30 seconds

FUNCTION KEYS
 F1: show help screen
 F2: show song title
 F3: show song length
 F4: show preset name
 F5: show frames per second
 F6: show rating of current preset

Re: foo_vis_milk2

Reply #19
WARNING: foobar2000 replaces everything in the component's directory during install. To prevent deletion of the "presets" folder move it temporarily or extract the archive and overwrite the existing DLL.

Your presets folder should go in the user's profile, not the component folder. Use core_api::get_profile_path().

Re: foo_vis_milk2

Reply #20
Thank you @mark2k3 for that hint. Corrected for next release.

Re: foo_vis_milk2

Reply #21
The last release (0.0.229-alpha), wasn't providing any working preset. Then, once started without anything but bare defaults, a right click on the extension window is unconditionally leading to a foobar crash.

Re: foo_vis_milk2

Reply #22
The last release (0.0.229-alpha), wasn't providing any working preset. Then, once started without anything but bare defaults, a right click on the extension window is unconditionally leading to a foobar crash.

This was unforunately my experience as well :( Trying to add the recommended presets folder again then led to foobar crashing on startup or whenever I tried to add the component.

Re: foo_vis_milk2

Reply #23
New release 0.0.230-alpha. Additional notes:
  • This release moves presets and textures to the "profile" folder to avoid overwriting presets on every install, thanks to @mark2k3. This should be the last upgrade where you'd need to manually move the folder. Personally, I use symlinks to share the same presets and textures across multiple foobar2000 instances.
  • Also, thanks to @codav, this release pilots the projectM EEL. It might improve the preset support situation.
  • Source code release is imminent, just documenting the licensing situation with all of the disparate components. You'll then be able to laugh at my incompetence. ;-)
  • From this release I've kept back the full preset editing menu ("M" key), preset mashing, preset saving and related functionality because I don't have this text rendering working reliably. It is the last major feature missing. Nothing is planned after this other than minimal maintenance, some refactoring of a couple of overgrown files and bug squashing.
  • If you press a key and something is stuck you hit an invisible menu. Just hit "Escape" once to get back out to regular mode. If this happens let me know which key did it and which menu mode you were in.
  • Same goes for a preference that has no effect or doesn't save across sessions.
  • Speaking of keys, the 2 menus that should work are the playlist menu (with "P" or the right click menu) and the preset menu (with "L"). The playlist menu movement should be synchronized to the foobar2000 GUI--only playback and navigation works no editing calls are made such as delete, rename, add, move or similar as it's pretty easy to do something unintentional.

Again, it tests really stable for me. To "acid" test I run an x86 instance and x64 instance of foobar2000 at the same time. Running for multiple hours a day non-stop with other components in both windows such as foo_vis_spectrum_analyzer. In one instance the component window is embedded into the UI and in the other it is separate. Both fullscreen correctly and both have the Visual Studio debugger attached looking for exceptions. The only things I see repeatedly unrelated to this component:
Code: [Select]
Exception thrown at 0xAddress in foobar2000.exe: Microsoft C++ exception: exception_album_art_not_found at memory location 0xAddress1.
Exception thrown at 0xAddress in foobar2000.exe: Microsoft C++ exception: foobar2000_io::exception_io_not_found at memory location 0xAddress2.

Finally, the component is built using the Windows 11 SDK (10.0.22621.0) and MSVC v143. So, make sure you're using either of:
  • Windows 10 version 1507 or higher
  • Windows 8.1
  • Windows 7 SP1 (might crash because of DXGI 1.6)

Reach out here if you need some help with getting the component up and running. "Listen good."

Re: foo_vis_milk2

Reply #24
@Dfaure and @dreampillet. Much has changed in the last few days since 229-alpha. For 230-alpha, I clear my profile and remove any previous version to install the new one. When I launch, I see this window:



Funny enough, the image is similar to Voyager's calibration image.

The "milkdrop2" folder should be created under "profile" to add in the "presets" folder on first launch. Not very helpful, I know. However, if you don't see this image then there might be something else wrong that I have not encountered in my testing.