OfficialIncubo / BeatDrop-Music-Visualizer

The Milkdrop2 Music Visualization Standalone, only for Windows
https://twitter.com/BeatDropVis
Other
34 stars 2 forks source link

Spout Integration #3

Closed OfficialIncubo closed 9 months ago

OfficialIncubo commented 1 year ago

Because of too many errors or unresolved externals using VS2019, I can't integrate Spout. Can you please help me?

OfficialIncubo commented 1 year ago

Maybe I will download the Original BeatDrop for Spout source code, adding the same new features and I will upload it.

OfficialIncubo commented 1 year ago

I asked the owner of Spout if the Spout version of BeatDrop can be compiled using Visual Studio 2019.

This answer can be found here: https://github.com/milkdrop2077/MilkDrop3/issues/3#issuecomment-1548751336

OfficialIncubo commented 9 months ago

I have managed to compile the leadedge's BeatDrop SpoutDX, but it does have some cons for it:

Here is the file what I have modified: BeatDrop-SpoutDX9-almost-working.zip

Next I can try to compile the Spout OpenGL Version of BeatDrop. I already tested this and it works as my improvement one! Wish me luck! (I give up due to a plugin.cpp problem that we're solved.)

Every Resolume Arena users wants a retrospective music visualization right now!

OfficialIncubo commented 9 months ago

Ok. Now leadedge (Lynn Jarvis) fixed the navigation keys, also a preset compatibility!

You can check out this commit here.

The Spout Integration is ALMOST done! We have to add some of my BeatDrop features and it's done!

OfficialIncubo commented 9 months ago

Yeah. The one issue is: The spout won't let me share the screen after reenabling.

https://github.com/leadedge/BeatDrop/assets/74858188/d5d51382-92cd-450f-9514-7abf60f10e7a

...and if I change the SpoutWidth and SpoutHeight below 1920, respectively below 1080, it won't let me share this visualization to Spout.

OfficialIncubo commented 9 months ago

Hey! I have finished the Spout Integration, but if I change the window, the sender doesn't change the resolution. We recommend to reenable it. Now the Spout output now works after reenabling. Afaik, it remains as a BETA.

https://github.com/OfficialIncubo/BeatDrop-Music-Visualizer/assets/74858188/8ed4d00d-a53d-4075-989a-3675a4a52d8a

Thank you, leadedge (a.k.a Lynn Jarvis) for help! ;)

OfficialIncubo commented 9 months ago

Fix: BeatDrop Window now syncs to the Spout Sender resolution instead of the fixed size.

https://github.com/OfficialIncubo/BeatDrop-Music-Visualizer/assets/74858188/d7134335-42c5-4071-b75c-a5ea1cd2156a

So, it's OFFICIALLY FINISHED!

OfficialIncubo commented 4 months ago

Hey, @leadedge! Sadly, BeatDrop uses XRGB which isn't supportable for NestDrop of invoking a Spout Sprite. Can you please make this visualizer to share ARGB texture for wide compatibility?

leadedge commented 4 months ago

I have limited time at the moment due to other commitments.

I would suggest to try forcing the backbuffer format to D3DFMT_A8R8G8B8. This should be done when DirectX is initialized.

1) Milkdrop2PcmVisualizer.cpp - InitD3d Change d3dPp.BackBufferFormat = D3DFMT_UNKNOWN; to d3dPp.BackBufferFormat = D3DFMT_A8R8G8B8;

2) pluginshell.cpp - PluginPreInitialize Change m_disp_mode_fs.Format = D3DFMT_UNKNOWN; to m_disp_mode_fs.Format = D3DFMT_A8R8G8B8; and m_disp_mode_fs.Format = (dm.dmBitsPerPel==16) ? D3DFMT_R5G6B5 : D3DFMT_X8R8G8B8; to m_disp_mode_fs.Format = (dm.dmBitsPerPel==16) ? D3DFMT_R5G6B5 : D3DFMT_A8R8G8B8;

3) plugin.cpp - AllocateMyDX9Stuff Look for "// determine format for VS1/VS2" Change case 8: fmt = D3DFMT_X8R8G8B8 ; break; to case 8: fmt = D3DFMT_A8R8G8B8 ; break;

The received format is detected as D3DFMT_A8R8G8B8 and might solve the problem so it's worth a try.

OfficialIncubo commented 4 months ago

Oh! Thank you very much! That solved a problem instead of using D3DFMT_UNKNOWN. I might tag it in a commit! ;) Now it's using ARGB instead of XRGB. I wonder... Let me test if it works with NestDrop when I enable the BeatDrop's Spout Output.

OfficialIncubo commented 4 months ago

That worked with NestDrop! Captură de ecran 2024-02-28 111042 Captură de ecran 2024-02-28 105542

I did all the steps above, but sadly, some MilkDrop 1 effects, such as invert and solarize affected the BeatDrop's Spout Sender, except video echo, brighten and darken. Any way to fix, @leadedge?

Proof: Captură de ecran 2024-02-28 112104 Captură de ecran 2024-02-28 112120

Both Invert and Solarize enabled didn't affect it. I wonder why?

EDIT: One more issue. When doing a soft cut transition, the old preset stays black and the new preset fades in (it depends on Comp Shader presets you are using).

leadedge commented 4 months ago

Well it was worth a try and it mainly works. The problem could be that alpha is not set properly and it could be 0 instead of 1.0 or vice versa. This would affect the receiving end if it uses alpha and the effects you mention probably do not set alpha as required because they are designed for XRGB. The whole design is based on XRGB. Perhaps you could make it optional. A shader would be needed to set alpha.

OfficialIncubo commented 4 months ago

Well it was worth a try and it mainly works. The problem could be that alpha is not set properly and it could be 0 instead of 1.0 or vice versa. This would affect the receiving end if it uses alpha and the effects you mention probably do not set alpha as required because they are designed for XRGB. The whole design is based on XRGB. Perhaps you could make it optional. A shader would be needed to set alpha.

Probably it's because alpha blending. How do I make it not affecting the Spout Sender by making it non-alpha blendable or something?

EDIT: I know that it's designed for XRGB, but looking forward to make the ARGB renderer very stable for the BeatDrop's Spout Sender by not affecting it by MilkDrop 1 effects and some transitions that has a Comp Shader in the old state.

leadedge commented 4 months ago

You would have to examine milkdropfps.cpp, but there are a lot of references to blending and it's complicated.

I suggest another way. Remove the changes in the BeatDrop code to force D3DFMT_A8R8G8B8 and make the change in SpoutDX9.cpp instead -

bool spoutDX9::SendDX9surface(IDirect3DSurface9* pSurface, bool bUpdate)

The texture format is determined from the surface description.

// Get the surface details
D3DSURFACE_DESC desc;
ZeroMemory(&desc, sizeof(desc));
pSurface->GetDesc(&desc);
if (desc.Width == 0 || desc.Height == 0)
    return false;

In this case we know that D3DFMT_A8R8G8B8 works, so here it can be changed to a fixed value.

desc.Format = D3DFMT_A8R8G8B8;

A shared texture of that format is then created, the surface is copied to it and receivers see ARGB. It is received OK as far as I can see.

OfficialIncubo commented 4 months ago

Hey! I have added desc.Format = D3DFMT_A8R8G8B8 below the code of the surface detail getter and it worked as intended. No more problems of the Sender. Thank you for explanation and helping! 🎉

image

EDIT: Here's what it looks like with the tweaked Spout Code of BeatDrop Source Code: https://mega.nz/file/wJZWAarL#xj5-WMG8Gy-EPY7d7DHUv-6cM7wwrl8d_W1rzZa3IQQ (video link)

leadedge commented 4 months ago

That's good. It turned out to be a simple solution and it seems to work OK.