Skip to content

Commit acafc68

Browse files
authored
Merge pull request #280 from mrikola/music
Add fluidsynth-lite to Windows builds
2 parents f08a04c + e346b1a commit acafc68

File tree

7 files changed

+85
-17
lines changed

7 files changed

+85
-17
lines changed

Diff for: CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ message(STATUS "Found SDL2 Include:${SDL2_INCLUDE_DIRS} Library:${SDL2_LIBRARIES
5555
message(STATUS "Found SDL2_Mixer Include:${SDL2_MIXER_INCLUDE_DIRS} Library:${SDL2_MIXER_LIBRARIES}")
5656

5757
# Find FluidSynth
58-
find_library(FLUIDSYNTH_LIBRARY fluidsynth)
58+
find_library(FLUIDSYNTH_LIBRARY fluidsynth PATHS build_ext/fluidsynth-lite/src)
5959

6060
# for now I'll put a Carbon/Carbon.h into src/stubs/
6161
# that defines Mac-specific types and provides stubs for used functions
@@ -331,8 +331,10 @@ target_link_libraries(systemshock
331331
)
332332

333333
if(FLUIDSYNTH_LIBRARY)
334+
message(STATUS "Fluidsynth found")
334335
add_definitions("-DUSE_FLUIDSYNTH=1")
335336
target_link_libraries(systemshock "${FLUIDSYNTH_LIBRARY}")
337+
include_directories(${CMAKE_SOURCE_DIR}/build_ext/fluidsynth-lite/include)
336338
endif()
337339

338340
if (WIN32)

Diff for: appveyor.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ environment:
1313
# Avoid rebuilding external dependencies (ie. SDL and SDL_mixer)
1414
# Uncache build_ext if external deps change
1515
cache:
16-
# - build_ext
16+
- res/music.sf2
17+
- build_ext
1718

1819
# Actual build script..
1920
# Step 1: Git has to reside in a path without spaces because the SDL build script is weird like that.
@@ -23,7 +24,7 @@ cache:
2324
build_script:
2425
- mklink /D c:\git "C:\Program Files\Git"
2526
- set PATH=%PATH:C:\Program Files (x86)\Git\bin;=%
26-
- set PATH=c:\git\usr\bin;%PATH%;C:\MinGW\bin
27+
- set PATH=c:\git\usr\bin;%PATH%;C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin\
2728
- copy windows\make.exe \git\usr\bin
2829
- set CMAKE_MAKE_PROGRAM=c:\git\usr\bin\make.exe
2930
- sh build_windows.sh
@@ -39,8 +40,9 @@ after_build:
3940
- copy build_ext\built_sdl\bin\SDL*.dll .
4041
- copy build_ext\built_sdl_mixer\bin\SDL*.dll .
4142
- copy build_ext\built_glew\lib\glew32.dll .
43+
- copy build_ext\fluidsynth-lite\src\libfluidsynth.dll .
4244
- copy readme\readme-windows.txt readme.txt
43-
- 7z a systemshock-windows.zip systemshock.exe *.dll readme.txt shaders/
45+
- 7z a systemshock-windows.zip systemshock.exe *.dll readme.txt shaders/ res/
4446

4547
artifacts:
4648
- path: systemshock-windows.zip

Diff for: build_deps.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ if [ -d ./build_ext/ ]; then
1010
exit
1111
fi
1212

13+
if [ ! -d ./res/ ]; then
14+
mkdir ./res/
15+
fi
16+
1317
mkdir ./build_ext/
1418
cd ./build_ext/
1519

@@ -32,13 +36,33 @@ function build_sdl_mixer {
3236
tar xvf SDL2_mixer-${SDL2_mixer_version}.tar.gz
3337
pushd SDL2_mixer-${SDL2_mixer_version}
3438

35-
export SDL2_CONFIG="${install_dir}/built_sdl/bin/sdl2-config"
39+
export SDL2_CONFIG="${install_dir}/built_sdl/bin/sdl2-config"
3640
./configure "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32" --prefix=${install_dir}/built_sdl_mixer
3741
make
3842
make install
3943

4044
popd
4145
}
4246

47+
function build_fluidsynth {
48+
git clone https://github.com/Doom64/fluidsynth-lite.git
49+
pushd fluidsynth-lite
50+
sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt
51+
# if building fluidsynth fails, move on without it
52+
set +e
53+
cmake .
54+
cmake --build .
55+
56+
# download a soundfont that's close to the Windows default everyone knows
57+
curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2
58+
set -e
59+
popd
60+
}
61+
62+
4363
build_sdl
4464
build_sdl_mixer
65+
build_fluidsynth
66+
67+
cd ..
68+
mv build_ext/fluidsynth-lite/*.sf2 ./res

Diff for: build_windows.sh

+35-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ GLEW_version=2.1.0
77
CMAKE_version=3.11.3
88
#CMAKE_architecture=win64-x64
99
CMAKE_architecture=win32-x86
10+
CMAKE_target=Unix\ Makefiles
1011

1112
# Removing the mwindows linker option lets us get console output
1213
function remove_mwindows {
@@ -52,6 +53,21 @@ function build_glew {
5253
popd
5354
}
5455

56+
function build_fluidsynth {
57+
git clone https://github.com/Doom64/fluidsynth-lite.git
58+
pushd fluidsynth-lite
59+
sed -i 's/DLL"\ off/DLL"\ on/' CMakeLists.txt
60+
# if building fluidsynth fails, move on without it
61+
set +e
62+
cmake -G "${CMAKE_target}" .
63+
cmake --build .
64+
65+
# download a soundfont that's close to the Windows default everyone knows
66+
curl -o music.sf2 http://rancid.kapsi.fi/windows.sf2
67+
set -e
68+
popd
69+
}
70+
5571
function get_cmake {
5672
curl -O https://cmake.org/files/v3.11/cmake-${CMAKE_version}-${CMAKE_architecture}.zip
5773
unzip cmake-${CMAKE_version}-${CMAKE_architecture}.zip
@@ -72,35 +88,47 @@ rm -rf CMakeFiles/
7288
rm -rf CMakeCache.txt
7389

7490
cp windows/make.exe /usr/bin/
91+
92+
if [ ! -d ./res/ ]; then
93+
mkdir ./res/
94+
fi
95+
7596
mkdir ./build_ext/
7697
cd ./build_ext/
7798
install_dir=`pwd -W`
7899

79-
build_sdl
80-
build_sdl_mixer
81-
build_glew
82-
83100
if ! [ -x "$(command -v cmake)" ]; then
84101
echo "Getting CMake"
85102
get_cmake
86103
fi
87104

88-
# Back to the root directory, copy SDL DLL files for the executable
105+
build_fluidsynth
106+
107+
build_sdl
108+
build_sdl_mixer
109+
build_glew
110+
111+
112+
# Back to the root directory, copy required DLL files for the executable
89113
cd ..
90114
cp build_ext/built_sdl/bin/SDL*.dll .
91115
cp build_ext/built_sdl_mixer/bin/SDL*.dll .
92116
cp build_ext/built_glew/lib/*.dll .
117+
cp build_ext/fluidsynth-lite/src/*.dll .
118+
119+
# move the soundfont to the correct place if we successfully built fluidsynth
120+
mv build_ext/fluidsynth-lite/*.sf2 ./res
93121

94122
# Set up build.bat
95123
if [[ -z "${APPVEYOR}" ]]; then
96124
echo "Normal build"
97125
echo "@echo off
98126
set PATH=%PATH%;${CMAKE_ROOT}
99-
cmake -G \"MinGW Makefiles\" .
127+
cmake -G \"${CMAKE_target}\" .
100128
mingw32-make systemshock" >build.bat
101129
else
102130
echo "Appveyor"
103-
echo "cmake -G \"Unix Makefiles\" .
131+
echo "cmake -G \"${CMAKE_target}\" .
104132
make systemshock" >build.bat
105133
fi
106134

Diff for: src/GameSrc/cutsloop.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extern char EngSubtitle[256];
6969
extern char FrnSubtitle[256];
7070
extern char GerSubtitle[256];
7171

72+
extern SDL_AudioDeviceID device;
7273

7374

7475
extern void change_svga_screen_mode(void);
@@ -140,7 +141,7 @@ void cutscene_exit(void)
140141

141142
if (cutscene_audiostream != NULL)
142143
{
143-
SDL_PauseAudio(1);
144+
SDL_PauseAudioDevice(device, 1);
144145
SDL_Delay(1);
145146

146147
SDL_FreeAudioStream(cutscene_audiostream);
@@ -171,7 +172,7 @@ void cutscene_loop(void)
171172

172173
if (cutscene_audiostream)
173174
{
174-
SDL_PauseAudio(0);
175+
SDL_PauseAudioDevice(device, 0);
175176

176177
if (cutscene_audiobuffer_size > 0)
177178
{
@@ -307,7 +308,7 @@ short play_cutscene(int id, bool show_credits)
307308

308309
if (sfx_on)
309310
{
310-
SDL_PauseAudio(1);
311+
SDL_PauseAudioDevice(device, 1);
311312
SDL_Delay(1);
312313

313314
cutscene_audiostream = SDL_NewAudioStream(AUDIO_U8, 1, fix_int(amovie->a.sampleRate), AUDIO_S16SYS, 2, 48000);

Diff for: src/MacSrc/SDLSound.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ int snd_start_digital(void) {
3232
spec.callback = AudioStreamCallback;
3333
spec.userdata = (void *)&cutscene_audiostream;
3434

35-
if (SDL_OpenAudio(&spec, &obtained)) {ERROR("Could not open SDL audio");}
36-
else {INFO("Opened Music Stream");}
35+
extern SDL_AudioDeviceID device;
36+
device = SDL_OpenAudioDevice(NULL, 0, &spec, &obtained, 0);
37+
38+
if (device == 0) {
39+
ERROR("Could not open SDL audio");
40+
} else {
41+
INFO("Opened Music Stream, deviceID %d, freq %d, size %d, format %d, channels %d, samples %d", device,
42+
obtained.freq, obtained.size, obtained.format, obtained.channels, obtained.samples);
43+
}
44+
45+
SDL_PauseAudioDevice(device, 0);
3746

3847

3948
if (Mix_Init(MIX_INIT_MP3) < 0) {ERROR("%s: Init failed", __FUNCTION__);}

Diff for: src/MacSrc/Shock.c

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ SDL_Window* window;
9797
SDL_Palette* sdlPalette;
9898
SDL_Renderer* renderer;
9999

100+
SDL_AudioDeviceID device;
101+
100102
char window_title[128];
101103
int num_args;
102104
char** arg_values;

0 commit comments

Comments
 (0)