Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old October 12, 2022, 00:20   #1
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Compiling SDL2 in MSYS2 with sound?


I can compile the SDL2 front end from the latest source in MSYS2 and run it in Windows, following the Angband manual's instructions

https://angband.readthedocs.io/en/la...2-with-mingw64

but I get no sound (fighting monsters, etc). I have "Use sound" set to "yes" in the in-game options.

This has been discussed for more Linux-like versions here http://angband.oook.cz/forum/showthr...ght=sdl2+sound and there was a code fix around that time https://github.com/angband/angband/c...e1e6332302e51a and an issue discussing it https://github.com/angband/angband/issues/4458 --but I'm not sure how to apply configuration stuff mentioned in those pages, for instance "./configure --enable-sdl2-mixer," to compiling in MSYS2.

Is there something I should be doing when compiling in MSYS2 to get sound working?

All I'm doing is the manual's

make -f Makefile.msys2.sdl2

I installed additional packages

pacman -S mingw-w64-x86_64-SDL2_mixer
pacman -S mingw-w64-x86_64-SDL
pacman -S mingw-w64-x86_64-SDL_mixer

and tried what I think(?) does a force rebuild

make -Bf Makefile.msys2.sdl2

but that didn't get sound working.

(Update 10/18: Of those three packages, only SDL2_mixer is actually needed. And I could have done

make clean -f Makefile.msys2.sdl2
make -f Makefile.msys2.sdl2

instead of using -B.)

I've tried running from a shortcut with "-msdl2" after angband.exe, but that doesn't seem to do anything different--no sound, at any rate.

I get a repeating warning when compiling

gcc.exe: warning: C:/msys64/mingw64/lib/libSDL2.a: linker input file unused because linking not done
CC [filename].c

where [filename] is various source files. It doesn't seem to result in actual errors or stop the build from completing.
__________________
My Angband videos

Last edited by smbhax; October 18, 2022 at 21:50.
smbhax is offline   Reply With Quote
Old October 12, 2022, 00:37   #2
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Oh. Finally worked out to open src\Makefile.msys2.sdl2 and it says at the top

# If you want only video (but not sound), use it like this:
# (from angband directory)
#
# cd src
# make -f Makefile.msys2.sdl
#
# TODO: sound is not working for windows build
#

Well shoot. : P

I've tried it in Cygwin but there I get a "no available video device" message when trying to run. Some sort of Cygwin video compatibility thing, maybe? Can't find anything by Googling really. Maybe I'll finally have to run the official Windows Linux thingy or something.

(Update: got it running with sound in Ubuntu under Windows Subsystem for Linux--but it runs a little slow, and after alt-tabbing the movement keys won't work until I hit Alt again. The Alt key thing is mildly annoying, but the slightly laggy response--the movement is very slightly delayed, and the sound is further delayed--is a real drag. Guess I'll just suck it up and stick to the messy multi-Window Windows version, ah well. ; )

(Also: compile instructions at top of Makefile.sdl2 might be out of date? Or that whole file might be out of date? When I try to follow them in WSL Ubuntu I get a warning about no front-ends configured from ./configure, and a cascade of "undefined reference" messages and error after doing "SOUND=yes make -f Makefile.sdl2":

~~~~
LINK angband
/usr/bin/ld: main.o: in function `printf':
/usr/include/x86_64-linux-gnu/bits/stdio2.h:107: undefined reference to `help_spoil'
[then more undefined references]
~~~~

What worked instead under Ubuntu was--as described by others in that other forum thread I linked above--

~~~~
./autogen.sh
./configure --with-no-install --enable-sdl2 --enable-sdl2-mixer
make
./src/angband -msdl2
~~~~

)
__________________
My Angband videos

Last edited by smbhax; October 12, 2022 at 06:52.
smbhax is offline   Reply With Quote
Old October 12, 2022, 07:23   #3
backwardsEric
Swordsman
 
Join Date: Aug 2019
Posts: 339
backwardsEric is on a distinguished road
This modified version of Makefile.msys2.sdl2, https://github.com/backwardsEric/ang...ile.msys2.sdl2 https://github.com/angband/angband/b...ile.msys2.sdl2 (updated compilation instructions are at the top of the file or at https://angband.readthedocs.io/en/la...2-with-mingw64), compiles and links an executable with sound for SDL2 enabled (at least when used on the Windows runner on GitHub). I don't know if sound actually works when that executable is run on Windows.

The excess warning messages from Makefile.msys2.sdl2 aren't specific to what you did: it'd have to be modified so the options added for SDL2 don't mix those that are only needed when compiling with those that are only needed for linking.

Thanks for pointing out the out-of-date Makefile.sdl2. I'd favor removing it entirely since "./autogen.sh ; ./configure --enable-sdl2 --with-no-install ; make" should do the trick (one can add --disable-x11 and --disable-curses options to configure if those front ends aren't desired even if the necessary libraries and headers are available; --enable-sdl2 implies --enable-sdl2-mixer so it doesn't need to be explicitly included).

Last edited by backwardsEric; October 22, 2022 at 06:24. Reason: point to version that was incorporated into Angband
backwardsEric is offline   Reply With Quote
Old October 12, 2022, 08:58   #4
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
This modified version of Makefile.msys2.sdl2, https://github.com/backwardsEric/ang...ile.msys2.sdl2 , compiles and links an executable with sound for SDL2 enabled (at least when used on the Windows runner on GitHub). I don't know if sound actually works when that executable is run on Windows.
Wow! Yes, it works. Sound works in Windows through the Angband SDL2 front end with my MSYS2-compiled version now! : D And not delayed like in the Cygwin and WSL Ubuntu versions! Amazing, fantastic, excelsior!!!

: DDDDD

You've done it again! Thank you, thank you, thank you!!!

~~~~

Doesn't matter now, but re: my flailing with Cygwin and SDL2 above, I managed to get that working--although the input response and especially sound are slightly laggy, as in WSL Ubuntu--doesn't have the Alt key thing after Alt-tab like WSL Ubuntu, though.

So for SDL2 and Cygwin:

- Install the "xinit," "xorg-server," and "xlaunch" packages using Cygwin's install program

- compile Angband with
./autogen.sh
./configure --with-no-install --enable-sdl2 --enable-sdl2-mixer
make

With those Cygwin/X packages installed, we'll be able to run this through the X interface--EXCEPT that mouse input doesn't seem to work on the SDL2 front end through the X interface--clicking the menus does nothing. So here's the crude workaround:

- In a version in which you can run and configure the SDL2 front-end, such as one compiled in MSYS2, run the game and set up the SDL2 Angband Term subwindows there to your liking, then CTRL+X to quit

- copy the window.prf and sdl2init.txt from that version into the .angband/Angband folder in your Cygwin home

- run the XLaunch program installed by the xinit Cygwin package

- In the XLaunch launcher window, choose "Fullscreen" and "Start a program" - "Local program - xterm"

- when the xterm terminal appears in front of the XLaunch black screen, run Angband as if you're in the Cygwin terminal (I do "cd angband" and then "./src/angband")

^ That should launch your Cygwin-compiled Angband in the XLaunch screen, with the Angband SDL2 front-end, with the subwindows configured as you had them in the other version, and working sound (if you enable it with the usual Angband =ab "use_sound" option menu setting).

As in WSL Ubuntu, in this Cygwin/X thing, input response may be every so slightly sluggish, and sound response will be definitely sluggish. At least, it is for me.

That's why getting it all working through the MSYS2 version is so nice: that lovely single-window seamless interface, sound (thanks to backwardsEric's new config!), and no input or sound delay! : D
__________________
My Angband videos

Last edited by smbhax; October 12, 2022 at 09:06.
smbhax is offline   Reply With Quote
Old October 12, 2022, 10:28   #5
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Come to think of it, the old instructions at the top of Makefile.msys2.sdl2 say

~~~~
# cd src
# make -f Makefile.msys2.sdl
#
# TODO: sound is not working for windows build
~~~~

but that should be "sdl2," not "sdl," I guess.
__________________
My Angband videos

Last edited by smbhax; October 12, 2022 at 11:07.
smbhax is offline   Reply With Quote
Old October 12, 2022, 12:20   #6
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
Thanks for pointing out the out-of-date Makefile.sdl2. I'd favor removing it entirely since "./autogen.sh ; ./configure --enable-sdl2 --with-no-install ; make" should do the trick (one can add --disable-x11 and --disable-curses options to configure if those front ends aren't desired even if the necessary libraries and headers are available; --enable-sdl2 implies --enable-sdl2-mixer so it doesn't need to be explicitly included).
Yeah from that other forum thread it doesn't sound like people here, at least, were using Makefile.sdl2. It isn't mentioned in the manual's compiling instructions.
__________________
My Angband videos
smbhax is offline   Reply With Quote
Old October 12, 2022, 13:03   #7
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road


^ In case anyone's unfamiliar with the silky smooth look of the SDL2 front end. : ) (Click it for full size.)

That's with "Border" toggled off on each window. I've mostly duplicated the standard Windows version's default window layout there, except that with the "Size" and "Move" toggles in the upper right corner it's really easy to line the windows up seamlessly in SDL2.

If you're using tiles and you're used to how they work in the standard Windows version's front end, one thing to keep in mind is that the tile scaling works a little differently in the SDL2 front end: whereas in the standard Windows front end, with the square Shockbolt tiles for instance you'd set tile scaling to 4x2, in SDL2 you'd set it to 4x4; and the size of the font you use for the main ("A/"Angband") window in SDL2 affects the tile scaling! In particular, a square font makes it a lot easier to get predictable scaling out of square tiles like Shockbolt's.

After a little trial and error, I found that on my screen these settings for the SDL2 front-end duplicated the scale of the tiles in the standard Windows version's front end:

"A"/"Angband" window:
- Font - Name - 16x16x.fon
- Tiles - Set - Shockbolt Dark
- Tiles - Size - Tile Width 4
- Tiles - Size - Tile Height 4

Other windows:
- Font - Name - 8x12x.fon

As I mentioned, I un-selected "Borders" for all the subwindows. And I left "Fullscreen" selected in the main menu.

If you've scrambled your subwindow settings perhaps by copying files over from a different installation, and find your subwindows keep changing their "Purpose" setting back to something else each time you load your character, well there's probably some better way to straighten that out or better yet never do whatever I did in messing around with files to get it like that in the first place--but you can straighten the "Purpose" of the windows out in the game's =w "Subwindow setup" menu, then save that to user.prf with the game's =f "Save subwindow setup to pref file" command, and they'll automatically load up the right way when you restart.

Unlike the standard Windows version which by default prompts you to load a file when you start up, when you start the SDL2 front end it will automatically load your last character file name or something--anyway one way to set it to load a specific character file name is to put it in the "Target" command of a shortcut to angband.exe: make a Windows shortcut for angband.exe, right-click it, select Properties, and in the "Target" field of the "Details" tab, add "-u[save file name from lib\user\save]" at the end; my normal shortcut's "Target" field for instance is

C:\msys64\home\smbhax\angband\angband.exe -uSmbhax

Compiling with the sound-enabled version of the MSYS2 SDL2 Makefile @backwardsEric linked above requires an additional package:

pacman -S mingw-w64-x86_64-SDL2_mixer

The MSYS2-compiled SDL2 front end with sound can be seen and heard in action here: https://www.youtube.com/watch?v=HoSvVNSILf4&t=2855s

There are currently a couple visual glitches: game screen blanked after Windows lock screen (toggling fonts will clear it up) (5497), and accented letters are displayed incorrectly (5498; Update 10/18: backwardsEric has fixes for this one, linked in that issue).
__________________
My Angband videos

Last edited by smbhax; October 18, 2022 at 21:54.
smbhax is offline   Reply With Quote
Old October 23, 2022, 03:56   #8
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Quote:
Originally Posted by backwardsEric View Post
This modified version of Makefile.msys2.sdl2, https://github.com/backwardsEric/ang...ile.msys2.sdl2 https://github.com/angband/angband/b...ile.msys2.sdl2 (updated compilation instructions are at the top of the file or at https://angband.readthedocs.io/en/la...2-with-mingw64), compiles and links an executable with sound for SDL2 enabled (at least when used on the Windows runner on GitHub). I don't know if sound actually works when that executable is run on Windows.
I just synced up to the new check ins in the Angband git repository and building with sound is broken now.

- compilation instructions at top of Makefile.msys2.sdl2 have NOT been updated (also, it says "# File: Makefile.sdl2" at the top)

- When I try compiling without SOUND=yes, it does compile and run, but there's a new compile warning:

Code:
smbhax@DESKTOP-64GQN1N MINGW64 ~/angband/src
$ make -f Makefile.msys2.sdl2
        CC main.c
<command-line>: warning: no previous prototype for 'SDL_main' [-Wmissing-prototypes]
main.c:317:5: note: in expansion of macro 'main'
  317 | int main(int argc, char *argv[])
      |     ^~~~
- When I compile with SOUND=yes, there are errors:

Code:
smbhax@DESKTOP-64GQN1N MINGW64 ~/angband/src
$ make -f Makefile.msys2.sdl2 SOUND=yes
        CC snd-sdl.c
snd-sdl.c:42:17: error: unknown type name 'Mix_Chunk'
   42 |                 Mix_Chunk *chunk;       /* Sample in WAVE format */
      |                 ^~~~~~~~~
snd-sdl.c:43:17: error: unknown type name 'Mix_Music'
   43 |                 Mix_Music *music;       /* Sample in MP3 format */
      |                 ^~~~~~~~~
snd-sdl.c: In function 'open_audio_sdl':
snd-sdl.c:67:9: error: unknown type name 'Uint16'; did you mean 'uint16_t'?
   67 |         Uint16 audio_format = AUDIO_S16;
      |         ^~~~~~
      |         uint16_t
snd-sdl.c:67:31: error: 'AUDIO_S16' undeclared (first use in this function)
   67 |         Uint16 audio_format = AUDIO_S16;
      |                               ^~~~~~~~~
snd-sdl.c:67:31: note: each undeclared identifier is reported only once for each function it appears in
snd-sdl.c:71:13: warning: implicit declaration of function 'SDL_Init' [-Wimplicit-function-declaration]
   71 |         if (SDL_Init(SDL_INIT_AUDIO) < 0) {
      |             ^~~~~~~~
snd-sdl.c:71:13: warning: nested extern declaration of 'SDL_Init' [-Wnested-externs]
snd-sdl.c:71:22: error: 'SDL_INIT_AUDIO' undeclared (first use in this function)
   71 |         if (SDL_Init(SDL_INIT_AUDIO) < 0) {
      |                      ^~~~~~~~~~~~~~
snd-sdl.c:72:62: warning: implicit declaration of function 'SDL_GetError' [-Wimplicit-function-declaration]
   72 |                 plog_fmt("SDL: Couldn't initialize SDL: %s", SDL_GetError());
      |                                                              ^~~~~~~~~~~~
snd-sdl.c:72:62: warning: nested extern declaration of 'SDL_GetError' [-Wnested-externs]
snd-sdl.c:77:13: warning: implicit declaration of function 'Mix_OpenAudio' [-Wimplicit-function-declaration]
   77 |         if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
      |             ^~~~~~~~~~~~~
snd-sdl.c:77:13: warning: nested extern declaration of 'Mix_OpenAudio' [-Wnested-externs]
snd-sdl.c:79:17: warning: implicit declaration of function 'SDL_QuitSubSystem' [-Wimplicit-function-declaration]
   79 |                 SDL_QuitSubSystem(SDL_INIT_AUDIO);
      |                 ^~~~~~~~~~~~~~~~~
snd-sdl.c:79:17: warning: nested extern declaration of 'SDL_QuitSubSystem' [-Wnested-externs]
snd-sdl.c: In function 'load_sample_sdl':
snd-sdl.c:94:53: warning: implicit declaration of function 'Mix_LoadWAV' [-Wimplicit-function-declaration]
   94 |                         sample->sample_data.chunk = Mix_LoadWAV(filename);
      |                                                     ^~~~~~~~~~~
snd-sdl.c:94:53: warning: nested extern declaration of 'Mix_LoadWAV' [-Wnested-externs]
snd-sdl.c:94:51: warning: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   94 |                         sample->sample_data.chunk = Mix_LoadWAV(filename);
      |                                                   ^
snd-sdl.c:102:53: warning: implicit declaration of function 'Mix_LoadMUS' [-Wimplicit-function-declaration]
  102 |                         sample->sample_data.music = Mix_LoadMUS(filename);
      |                                                     ^~~~~~~~~~~
snd-sdl.c:102:53: warning: nested extern declaration of 'Mix_LoadMUS' [-Wnested-externs]
snd-sdl.c:102:51: warning: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  102 |                         sample->sample_data.music = Mix_LoadMUS(filename);
      |                                                   ^
snd-sdl.c: In function 'play_sound_sdl':
snd-sdl.c:153:54: warning: implicit declaration of function 'Mix_PlayChannel' [-Wimplicit-function-declaration]
  153 |                                         return (0 == Mix_PlayChannel(-1, sample->sample_data.chunk, 0));
      |                                                      ^~~~~~~~~~~~~~~
snd-sdl.c:153:54: warning: nested extern declaration of 'Mix_PlayChannel' [-Wnested-externs]
snd-sdl.c:158:54: warning: implicit declaration of function 'Mix_PlayMusic' [-Wimplicit-function-declaration]
  158 |                                         return (0 == Mix_PlayMusic(sample->sample_data.music, 1));
      |                                                      ^~~~~~~~~~~~~
snd-sdl.c:158:54: warning: nested extern declaration of 'Mix_PlayMusic' [-Wnested-externs]
snd-sdl.c: In function 'unload_sound_sdl':
snd-sdl.c:180:42: warning: implicit declaration of function 'Mix_FreeChunk' [-Wimplicit-function-declaration]
  180 |                                          Mix_FreeChunk(sample->sample_data.chunk);
      |                                          ^~~~~~~~~~~~~
snd-sdl.c:180:42: warning: nested extern declaration of 'Mix_FreeChunk' [-Wnested-externs]
snd-sdl.c:186:41: warning: implicit declaration of function 'Mix_FreeMusic' [-Wimplicit-function-declaration]
  186 |                                         Mix_FreeMusic(sample->sample_data.music);
      |                                         ^~~~~~~~~~~~~
snd-sdl.c:186:41: warning: nested extern declaration of 'Mix_FreeMusic' [-Wnested-externs]
snd-sdl.c: In function 'close_audio_sdl':
snd-sdl.c:213:9: warning: implicit declaration of function 'Mix_CloseAudio' [-Wimplicit-function-declaration]
  213 |         Mix_CloseAudio();
      |         ^~~~~~~~~~~~~~
snd-sdl.c:213:9: warning: nested extern declaration of 'Mix_CloseAudio' [-Wnested-externs]
snd-sdl.c:214:27: error: 'SDL_INIT_AUDIO' undeclared (first use in this function)
  214 |         SDL_QuitSubSystem(SDL_INIT_AUDIO);
      |                           ^~~~~~~~~~~~~~
make: *** [Makefile.msys2.sdl2:142: snd-sdl.o] Error 1
(I tried installing SDL in MSYS2

$ pacman -S mingw-w64-x86_64-SDL
$ pacman -S mingw-w64-x86_64-SDL_gfx
$ pacman -S mingw-w64-x86_64-SDL_image
$ pacman -S mingw-w64-x86_64-SDL_mixer
$ pacman -S mingw-w64-x86_64-SDL_net
$ pacman -S mingw-w64-x86_64-SDL_ttf

but it didn't fix it; I removed those again.)
__________________
My Angband videos
smbhax is offline   Reply With Quote
Old October 23, 2022, 05:47   #9
backwardsEric
Swordsman
 
Join Date: Aug 2019
Posts: 339
backwardsEric is on a distinguished road
The recently updated Makefile.msys2.sdl2 in Angband's main branch works when run on GitHub's Windows runner and building with sound enabled (output is here, https://github.com/angband/angband/a...obs/5448261777 ; it does have the warning about no prototype for SDL_main()). From your description of the contents of Makefile.msys2.sdl2, it sounds like the version in the main branch isn't what you got (compare with https://github.com/angband/angband/b...ile.msys2.sdl2 ).
backwardsEric is offline   Reply With Quote
Old October 23, 2022, 07:28   #10
smbhax
Swordsman
 
Join Date: Oct 2021
Location: WA
Posts: 311
smbhax is on a distinguished road
Yikes. Did I manage to get just a partial git pull or something. Weird because I was doing "git status" checks all evening and they didn't show anything out of the ordinary. Another git pull and yeah now I can compile and play with sound, although still with that new sdl compile warning.

Sorry for the weirdness, MANY thanks for the patient help with my endless silliness. D-argh.
__________________
My Angband videos

Last edited by smbhax; October 23, 2022 at 08:07.
smbhax is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Angband 4.2.4 Windows SDL2 Build Issue docrobot Vanilla 4 February 24, 2022 02:43
4.2.0 windows sdl2 frontend Adriankhl Development 10 June 11, 2020 16:55
SDL2 port when ? shirish Development 89 September 2, 2019 12:59
Latest Nightly release, SDL2 crashing with 8 terms EducatedNoob Development 3 June 24, 2019 23:17
v4.1.2 Sound? Imzy Vanilla 1 January 27, 2018 23:45


All times are GMT +1. The time now is 14:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.