-
Notifications
You must be signed in to change notification settings - Fork 233
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
Windows support #479
Comments
Sure, I don't mind that you copied winscap, but I would strongly recommend that you rewrite it anyways. I wrote winscap in like an hour or two, lazily using the builtin Visual C++ smart pointer library and C++ for no reason other than to make it quicker to code. It seems like you replaced the smart pointer code with plain COM code but didn't do any of the cleanups, so right now cava is leaking memory like a sieve on Windows. You can write COM code perfectly fine in C, so I would recommend that you just do the rewrite and eliminate the C++ dependency, fixing the memory management in the process. |
Alright, my first thought was to take it down to plain c, but I don't have any experience with com. So when I couldn't make it work my second thought was that it had to be in c++. But if I can do it all in c that's a lot better, will do that. Thanks! |
This is a large commit that most likely should have been splitted up a bit. But poor workflow made it better to just squash together all work from the windows branch. in short: 1) added windows input module (winscap, originaly written by @quantum5) 2) visual studio solution and proejct file added in cava_win folder this uses nuget to get all dependencies and all paths should be set up to use them autmatically 3) some non-windows stuff are ifdefed out, this might be seperated out in to other files at a later time 4) a common input sample separator was added in the common write_to_cava_input_buffers function. This required all of the other input modules to be re-written slightly. All in all it should be less duplicated code now 5) since ini files are native to windows the config loading part is more or less separated. Should maybe be better separated. stuff that are not supported on windows: 1) terminal output 2) raw output 2) embedding the default config file into the binary 3) user eq
Hey @karlstav! I was able to build cava from source on Windows and both However since cava is popularly used in terminals, how can I use the (ncurses is available in the MSYS2 environment, see https://packages.msys2.org/base/mingw-w64-ncurses. Notcurses, while not readily available, can also be built inside the MSYS2 environment, see https://github.com/dankamongmen/notcurses/blob/master/INSTALL.md#microsoft-windows) |
Terminal output should be possible, will require some rewriting as it still relies on some unix based stuff. I will try to stay clear of the msys2 as I have more gone down the route of visual studio / msbuild. (If people want to emulate unix/bash they might as well run cava via WSL). However, the noncurses implementation that i use in cava is something i wrote myself and only uses printf so it should be possible to port to windows. I will have a go at it when I get time. |
Just as a heads up, the MSYS2 environment I mentioned above is only for building: it does not emulate unix - I linked to the |
hi @rashil2000, I was able to make the noncurses output work! There was however two issues that might come back to bite us:
|
It looks great! I was curious about the build system here and tried to get the ncurses part working. I added the relevant file in the project file: diff --git a/cava_win/cava/cava.vcxproj b/cava_win/cava/cava.vcxproj
index d158fca..8687e76 100644
--- a/cava_win/cava/cava.vcxproj
+++ b/cava_win/cava/cava.vcxproj
@@ -153,6 +153,7 @@
<ClCompile Include="..\..\output\sdl_cava.c" />
<ClCompile Include="..\..\output\sdl_glsl.c" />
<ClCompile Include="..\..\output\terminal_noncurses.c" />
+ <ClCompile Include="..\..\output\terminal_ncurses.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\cavacore.h" />
@@ -163,6 +164,7 @@
<ClInclude Include="..\..\output\sdl_cava.h" />
<ClInclude Include="..\..\output\sdl_glsl.h" />
<ClInclude Include="..\..\output\terminal_noncurses.h" />
+ <ClInclude Include="..\..\output\terminal_ncurses.h" />
<ClInclude Include="..\..\util.h" />
</ItemGroup>
<ItemGroup> I downloaded the ncurses package, and added an include path in the build command: msbuild /p:IncludePath="D:\Downloads\mingw-w64-x86_64-ncurses\mingw64\include;D:\Downloads\mingw-w64-x86_64-ncurses\mingw64\include\ncursesw;$(IncludePath)" But now I'm facing some bogus syntax errors: What seems to be the issue here? |
msvc does not like that you use variables in array length, just replace gradient_count with 8 here: cava/output/terminal_ncurses.c Line 130 in a014284
|
Hmm, that fixes error on line 130, but I still can't figure out what's wrong with 252, 257 etc. |
Looks like it's the max macro in util.h that's causing issues. |
looks like the max macro is already defined on windows. I just ifdefed it out. try now. |
doesn't look like you are linking the ncurses library at all. I think you might have to add it here: cava/cava_win/cava/cava.vcxproj Line 124 in 4b61cdd
remember to add them for both debug and release. |
remove hard coded not used include paths, use dependencies debug libs in debug
Okay, I added it. Compilation successful! I changed the config file to use ncurses output but it threw this error :( Line 205 in a16742a
|
You have to set the NCURSES preprocessor define in the project file |
Well, I got this far... cava/output/terminal_ncurses.c Line 41 in a16742a
|
hmm, windows terminal is able to change color definitions (at least it does this in noncurses mode). However the default color should be not to try to do this. I changed it to that now. So try again after latest commit or just set foreground and background colors in your config to "default" |
Now it starts up and exits immediately, no error shown. |
my bad @rashil2000, fixed now. Please try again. |
Yes! It's working now. I had to disable gradients in the config file (because of the complaint with changing terminal colors), and then it started working. The performance is much much better than nonurses. I can make a PR for this change, but since I'm using MinGW's ncurses package, I don't exactly know how to proceed. I searched around on nuget.org and found these wrappers: Should we use one of these? Also, currently it's only black-and-white, but I know for a fact that ncurses can change Windows terminal's colors - the cmatrix project uses ncurses and it supports all colors, even bold texts. |
Nice! You could try to just comment or ifdef out the check for "can change color". I don't want to have ncurses enabled by default unless it can be installed via the nuget thing. If there is no way of doing that we will have to stick with a guide in the readme on how to install and build with ncurses. |
I temporarily removed the check, but the colors still stay black-and-white :( |
What if you set the foreground color to a predefined color like "red"? Remember to disable gradient first. |
No effect :( |
Hi everyone, i just tried to get cava running on win11, with no luck. |
since we now has sdl support and this ting exists I thought that windows support should be simple to implement. And it was!
so @quantum5 hope you don't mind that I snipped your winscap code to create the input module.
windows does not like autoconf so I made a separate visual studio solution for it. It all lives in it's own branch for now (just check out
windows
branch), but it will be merged to master soon. Both normal sdl and the new sgl_glsl works fine:The text was updated successfully, but these errors were encountered: