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

Feature request: Spout texture sharing support #3

Closed
newemka opened this issue Apr 12, 2023 · 39 comments
Closed

Feature request: Spout texture sharing support #3

newemka opened this issue Apr 12, 2023 · 39 comments

Comments

@newemka
Copy link

newemka commented Apr 12, 2023

For versatility It would be awesome to have spout texture sharing support, then Milkdrop3 render could be used in OBS via Spout as background for streaming or in VJ softwares
All the information for devs:
https://github.com/leadedge/Spout2

@milkdrop2077
Copy link
Owner

Hey it's on my to-do list! I'm working on adding some other functionalities at the moment, but one day I will!

@OfficialIncubo
Copy link

I also asked for the Spout integration + I am still doing it, but because of too many errors, I can't do it. If you are done, please DM me on Twitter or Discord the code that you integrated with Spout.

@OfficialIncubo
Copy link

5 months ago, I released the issue about Spout integration on my BeatDrop improvement. Btw, it's still in my to do list.

OfficialIncubo/BeatDrop-Music-Visualizer#3

@Lagaz
Copy link

Lagaz commented Apr 19, 2023

There is a work around for the spout/syphon usage in OBS. Just take the time to pre-record the programs and then stream those video's when desired.

Yes, Spout/Syphon support would ease usage, OBS does have a Spout plugin, it's been updated to work since OBS rewrite in V28. Use it often to record NestDrop Midnight video's for a Discord community. MilkDrop v3 is "visible" to OBS. Just a matter of resizing MD3's window to either the target resolution, or a derivative of that rez. (I.E. target size = 1280 x 720. MD3 window size = 960 X 540)

@milkdrop2077
Copy link
Owner

Yes you can see the MilkDrop3 window in OBS, add 'Window Capture' in the Sources, then select the MilkDrop 3.exe, and make it fit to your screen's capture size.

@milkdrop2077 milkdrop2077 reopened this Apr 19, 2023
@vdmokstati
Copy link

hey .. id suggest to check out implimentation done by nest drop.. they had optimised it a lot more then what beatdrop could do.
im pretty sure ive mentioned this at vj union software going back years... very familiar with the subject. but i feel we had moved on from this issue...

@Lagaz
Copy link

Lagaz commented Apr 26, 2023

Just updated Nestdrop Midnight late last week. At the moment, I've close to 200K presets to curate. While there may be faster programs for viewing presets, Beatdrop is what's on hand. Can't be certain, but I chimed in with the work around of the spout inclusion. Have to say, Nestdrop Spout 2 feature pulls my fat outta fire more times than not. The video's mentioned above are 35 - 50 minutes long. This box of rocks I have doesn't have a GPU, so I'm limited to what DirectX can do on the motherboard.

@milkdrop2077
Copy link
Owner

200k presets? you must have ~150k duplicate. There are less than 70k unique presets total, and thousands of them are almost identical. You can clean your collection with a program like Czkawka to remove identical files, then try to remove almost identical files.

NestDrop is cool, next year I'm planing to code something similar, just much better and faster ;)

@Lagaz
Copy link

Lagaz commented Apr 26, 2023

Much my reasoning on Beatdrop to curate is that earlier this year I stumble upon https://github.com/milkdrop2077/milkdrop2077 . I've been loading 10 or so presets into source folders and running 500 or so mashups based on them. Thanks Milkdrop2077 ! Couple weeks ago fell into a 60 preset collection that uses images for textures. While it may not a big deal to many, with just shy of 2 years under my Milkdrop experience, it's a game changer. Yes, Nestdrop Midnight has the sprite system. The hard transitions using sprites has me digging for more elegant solutions.

@leadedge
Copy link

Hello all..

I was referred to this issue and was prompted to test Spout for DirectX 9 which I haven't done for quite some time. As a result I have been successful in updating my old fork of BeatDrop. All went well with the latest code and it's also updated for Visual Studio 2022.

The changes could be used in MilkDrop3, but there's a bit more involved because Spout texture sharing requires DirectX9EX instead of just DirectX9 that the original Milkdrop was based on. All the code is commented throughout though if you want to have a look.

@OfficialIncubo
Copy link

OfficialIncubo commented May 15, 2023

I will look at your Spout version of BeatDrop! Can you please make this to support for Visual Studio 2019?

Btw. What is DIRECTX9EX? I think it's an evolved version of DirectX 9.

@milkdrop2077
Copy link
Owner

Hey leadedge! thank you so much for all the information!

@leadedge
Copy link

No problems.

@OfficialIncubo - You can change to Visual Studio 2019. Open BeatDrop.sln and :

Project > Properties > General > Platform Toolset > Visual Studio 1019 (v142)

With re-build, you will get re-definition warnings due to using Windows Kits\10 together with Microsoft DirectX SDK (June 2010). These will not occur with build only. If you want to remove them :

Project > Properties > Include Directories
Include (WindowsSDK_IncludePath) before (DXSDK_DIR)Include

DirectX9EX is an enhanced version of DirectX 9 and required for shared textures. Look at DXcontext.cpp and also search for "DX9EX" in MilkDrop2PcmVisualizer.cpp. There is a function "bool CheckForDirectX9c()" that looks for the correct version on your system.

These links might be useful

https://www.microsoft.com/en-us/download/details.aspx?id=8109

http://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe

@OfficialIncubo
Copy link

OfficialIncubo commented May 16, 2023

Some cons that I found on the latest BeatDrop for Spout release are:

  • Preset editing and Preset list navigation didn't work at all.
  • Some presets may contain errors because of ns-eel modifications that you did.

Plus I didn't try how the Spout works on BeatDrop and using with more instances. I have Spout on my laptop, so I'll try if I have time. I only tried with the old version and it works perfectly!

@leadedge
Copy link

The modifications are only for reference for use of the SpoutDX class instead of the OpenGL SpoutLIbrary. I don't support the program itself any more. The SpoutLIbrary version will still work fine as long as you stay with the same library files.

@milkdrop2077
Copy link
Owner

Hey @leadedge quick question : how to recompile your first version of beatdrop with the SpoutLibrary.dll ?

I have this error :
plugin.obj : error LNK2019: unresolved external symbol _GetSpout@0 referenced in function "public: virtual void __thiscall CPlugin::MyPreInitialize(void)" (?MyPreInitialize@CPlugin@@UAEXXZ)
.\Debug\BeatDrop.exe : fatal error LNK1120: 1 unresolved externals

I am missing some OpenGL library or something? I'm using VS2019 + glut lib

@leadedge
Copy link

The linker isn't finding SpoutLibrary.

I have made a "SpoutLibrary" branch with the original code for reference.

You need a "spoutLibrary" folder as in the repo.

Project > Propertines > Linker > General
add
..\spoutlibrary

Project > Properties > Linker > Input
SpoutLibrary.lib

These might also be needed
opengl32.lib
glu32.lib

Copy SpoutLibrary.dll to your release folder.

@OfficialIncubo
Copy link

These Seven Succurro Presets are sooo epic, but I have a problem about "Succurro - TV Static 1" preset:

  • error in shape 0 init code
  • error in shape 3 init code
  • error in shape 3 per-frame code
  • Could not load texture: z.j

One thing is: I need the "zombies_03.jpg" image texture file in order to work.

@leadedge
Copy link

Really sorry but I can't help with the presets. I understand that some are brilliant.

Some time back there was collaborative work with the developer of NestDrop and the preset might have been added then. Maybe you will find the missing file in the NestDrop presets.

@OfficialIncubo
Copy link

Hey, @leadedge, I managed to compile the SpoutDX9 version of BeatDrop and I have some cons for you:

  • Navigation keys not working, function keys working
  • Some presets may be broken
  • Ctrl+Z not working.
  • The window starts at 720x720, but it's stretched. When I resize it, the visualization stays normal.

The old version (1.0.0.2) works than intended and I don't prefer the SpoutDX9 version of it until it's fixed, but where do I menage to compile the 1.0.0.2 version of BeatDrop?

@leadedge
Copy link

Hi @OfficialIncubo
I found the bug preventing some keys like Ctrl-Z from working.
I can't help with the presets. Many of these were added during collaborative work and left in the repository. Some might be useful for you.
Starting window size is 1280x720. There was an intention for the output resolution to be independent of the window size but I don't think that was ever implemented.
I updated the Master branch with the key correction and also updated the SpoutLibrary branch to Visual Studio 2022 and new library files. It works OK as far as I can tell. That's the branch you need if you want to compile the original version.

@OfficialIncubo
Copy link

Now the preset functionality and navigation keys now worked!
But... if I reenable the Spout output, it doesn't appear on the reciever.
Plus I implemented a new beat detection algorithm btw.

BeatDropSpoutReenablingIssue.mp4

I changed the SpoutWidth and SpoutHeight to 720. When I open BeatDrop, it doesn't send to Spout. It doesn't support below 1920x1080 resolution.

@leadedge
Copy link

Ok at least the keys work. I will have a look at disable/enable.

I will also look at a 720x720 window. I assume you prefer a square format.
1920x1080 is the initial sending size, independent of the window size and these initial dimensions can be changed before compiling the project. As I mentioned before, this was not completed and re-sizing the window changes the sender resolution to the window size. If the window is not re-sized, the initial resolution remains.

Also I should mention that the main reason for the change to the DirectX9 version is the increased speed and reduction of CPU load. It uses a GPU texture surface instead of pixels from the backbuffer.

@OfficialIncubo
Copy link

OfficialIncubo commented Sep 25, 2023

...these initial dimensions can be changed before compiling the project.

I tried to change the initial dimensions to 720×720, but I started BeatDrop and it doesn't initialize the Spout output to the Sender.

Also I should mention that the main reason for the change to the DirectX9 version is the increased speed and reduction of CPU load. It uses a GPU texture surface instead of pixels from the backbuffer.

Even the missing keys and some preset functionalities are fixed, I give up from menaging to compile the OpenGL Version of BeatDrop (1.0.0.2). So I'm still using the SpoutDX9 of this.

@OfficialIncubo
Copy link

Oh! And if I resize the window if I want, the Spout Reciever info only sends the old resolution info. I want it to respond to the actual resolution.

@OfficialIncubo
Copy link

Hey, @leadedge! If I enable the SpoutOutput once, it starts to send it.

Log:

[notice] CPlugin::RenderFrame - size change from 0x0 to 1920x1080
[notice] CPlugin::OpenSender(1920, 1080)
[notice] spoutDX9::SetDX9device (0xF4D8540)
[notice] spoutDX9::OpenDirectX9 - hWnd = 0x0000000
[notice] spoutDX9::CreateSharedDX9Texture 1920x1080 - format 22 - handle 0x00008C2
[notice] spoutSenderNames::CreateSender
[notice]     [BeatDrop] 1920x1080, share handle = 0x00008C2, format = 22
[notice] spoutFrameCount::CreateAccessMutex - texture access mutex [BeatDrop_SpoutAccessMutex] created
[notice]     Handle [0x00007FC]
[notice] SpoutFrameCount::EnableFrameCount - frame count semaphore [BeatDrop_Count_Semaphore] exists
[notice]     Handle for access [0x0000734]

Then I turned off and I reenabled it. Nothing happened. It won't let me to show this visualizer to sender again.

Plus after the first resize to the smaller window, it shows:

[notice] spoutDX9::CreateSharedDX9Texture 1920x1080 - format 22 - handle 0x00013C2

...which the sender info is still in 1920×1080. I want to update the resize info to the actual window resolution. Not the old one.

I will have a look at disable/enable.

Oh. I see. If you are done, then remind me.
Then, please see the window resolution bug.

@leadedge
Copy link

I have been though the whole project to complete the sender size implementation. The aim was to set a fixed sender resolution that does not change when the user re-sizes the window. The resolution can then be much larger than the monitor can display, such as 4096x4096 for large scale projection.

I made a change to SendDX9surface in the SpoutDX9 class to enable this. The same change allows an option for the sender size to be the same as the window. Code comments in milkdropfs.cpp RenderFrame/SendDX9surface describe how to do this.

I also found an error in nseel2/nseel-compiler.c where an intrinsic re-definition was removed without retaining the default definition. This might fix the preset errors.

I hope this allows you to achieve what you want to do. Unfortunately I don't have any more time to spend on this right now.

@OfficialIncubo
Copy link

Ok. The Spout Output now works after reenabling than intended.

The aim was to set a fixed sender resolution that does not change when the user re-sizes the window.

Ok. This is the one unimplemented thing (I know?), but the Spout output needs to be reenabled after resizing the BeatDrop window.

Unfortunately I don't have any more time to spend on this right now.

Ok. Feel free to take a time. The Spout Integration is now finished today, but it remains a BETA feature.

@leadedge
Copy link

The fixed sender resolution is implemented now. As far as I can see it's working OK. The Spout output remains enabled after re-sizing the window. If it has been disabled with Ctrl-Z it remains disabled.

@OfficialIncubo
Copy link

OfficialIncubo commented Sep 26, 2023

I know.
But one more: When I resize the window, it doesn't sync with the Spout Sender Resolution Info compared to the old one.
Can you please spot what's the issue of it?
As you mentioned to say this to me:

Unfortunately I don't have any more time to spend on this right now.

You can take a break. I don't want to disturb you at all ;)

@leadedge
Copy link

There was a problem was with the original version. I found a bug in SpoutDX here where the sender size was updated with class variables before they were updated. Directx9 StretchRect still worked OK and hid the error. I hope the modifications allow you to complete yoor project. By using DirectX9 functions instead of CPU, you can send 4K images at 30fps easily. I won't be taking a break so much as finishing other urgent work.

@OfficialIncubo
Copy link

OfficialIncubo commented Sep 27, 2023

I... I already changed it.

image

I think I can paste it after 'm_dwFormat = dwFormat;'...
EDIT: Still didn't work. I will try with some many attempts if I can.
...and I think I'll change it from width to m_Width, respectively height to m_Height in CreateSharedDX9Texture function.

@leadedge
Copy link

'm_dwFormat = dwFormat' is in the first section where it is not initialized yet. Using the class variables here is OK because they are already updated. The next section for a size change was incorrect and the corrected file is now in the master branch.

I have tested this with console print and I can't see any error. When you say it doesn't work, what do you mean exactly.

CreateSharedDX9Texture is passed width and height and these should be used.

@OfficialIncubo
Copy link

Ok ok ok ..... OK, I am just a little bit confused hehe 😅
I changed from spoutsender.SendDX9surface(back_buffer, false) to spoutsender.SendDX9surface(back_buffer, true). Now it syncs to the BeatDrop window instead of the fixed size without reenabling it confirmed in the comments from line 1230 in milkdropfs.cpp.

- If the update flag is true (default), size changes are handled by SendDX9surface.
   Set the initial sender size to the window size in Milkdrop2PcmVisualizer.cpp

I didn't notice if spoutsender.SendDX9surface(back_buffer, true) is commented, which is not default.

Here is a demo:

BeatDropSpoutWindowSyncTest.mp4

Now it works than trying to attempt modifying the code in SpoutDX9.cpp.

@leadedge
Copy link

OK I think you have it right. Update true is default. Fixed size allows higher resolution than the monitor for projection.

@OfficialIncubo
Copy link

Oh. I need to say something. I wish there is a Spout Input Feature on BeatDrop, ex. Using OBS Spout Filter. (Ctrl + X hotkey)

You can change to another input while it actually uses more OBS Spout Filter.

Ex. Use 3 OBS Spout Filters, Ctrl + X to activate Spout Input, Ctrl + X again to another input. Ctrl + X to turn off the Spout Input if it's in the last input.

@leadedge
Copy link

Spout input is available in NestDrop. This project was used in the development and remains as an example but I am sorry that I don't have time to develop it further.

@OfficialIncubo
Copy link

OfficialIncubo commented Nov 28, 2023

I see that you have the Spout integration done, @milkdrop2077! You can close this issue.

@OfficialIncubo
Copy link

Spout input is available in NestDrop. This project was used in the development and remains as an example but I am sorry that I don't have time to develop it further.

For Spout Input as Sprites, you can check the issue here: OfficialIncubo/BeatDrop-Music-Visualizer#26

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

6 participants