• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a fork of Zandronum used on servers hosted by The Sentinels Playground (TSPG), Euroboros (EB), and Down Under Doomers (DUD).


Commit MetaInfo

修訂4dc0c7a95f068bb7571e8988e652b9ec3cebd542 (tree)
時間2010-08-16 04:54:59
作者Randy Heit <rheit@zdoo...>
CommiterRandy Heit

Log Message

- Added FluidSynth support as snd_mididevice -5. Only tested with Linux. I will have

to try compiling it myself on Windows to see if it's really that slow or if
Ubuntu just ships an unoptimized version, because performance is pretty pathetic
when compared to the other options. (I understand that it's a complete SoundFont2
renderer, so it is understandably slower than something like TiMidity++, but still.
Does it really need to be around 10x slower? I played with the chorus, reverb, and
interpolation settings, and none of them seemed to make much difference in
performance.)

SVN r2545 (trunk)

Change Summary

差異

diff -r b1a14dcd96c8 -r 4dc0c7a95f06 FindFluidSynth.cmake
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/FindFluidSynth.cmake Sun Aug 15 19:54:59 2010 +0000
@@ -0,0 +1,23 @@
1+# - Find fluidsynth
2+# Find the native fluidsynth includes and library
3+#
4+# FLUIDSYNTH_INCLUDE_DIR - where to find fluidsynth.h
5+# FLUIDSYNTH_LIBRARIES - List of libraries when using fluidsynth.
6+# FLUIDSYNTH_FOUND - True if fluidsynth found.
7+
8+
9+IF (FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARIES)
10+ # Already in cache, be silent
11+ SET(FluidSynth_FIND_QUIETLY TRUE)
12+ENDIF (FLUIDSYNTH_INCLUDE_DIR AND FLUIDSYNTH_LIBRARIES)
13+
14+FIND_PATH(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
15+
16+FIND_LIBRARY(FLUIDSYNTH_LIBRARIES NAMES fluidsynth )
17+MARK_AS_ADVANCED( FLUIDSYNTH_LIBRARIES FLUIDSYNTH_INCLUDE_DIR )
18+
19+# handle the QUIETLY and REQUIRED arguments and set FLUIDSYNTH_FOUND to TRUE if
20+# all listed variables are TRUE
21+INCLUDE(FindPackageHandleStandardArgs)
22+FIND_PACKAGE_HANDLE_STANDARD_ARGS(FluidSynth DEFAULT_MSG FLUIDSYNTH_LIBRARIES FLUIDSYNTH_INCLUDE_DIR)
23+
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/CMakeLists.txt
--- a/src/CMakeLists.txt Sun Aug 15 14:09:17 2010 +0000
+++ b/src/CMakeLists.txt Sun Aug 15 19:54:59 2010 +0000
@@ -31,6 +31,10 @@
3131 # fmodapi<version>linux[64] -or simply- fmod
3232 # jpeg-6b
3333 # ...
34+# The recommended method is to put it in the zdoom tree, since its
35+# headers are unversioned. Especially now that we can't work properly
36+# with anything newer than 4.26.xx, you probably don't want to use
37+# a system-wide version.
3438
3539 # Construct version numbers for searching for the FMOD library on Linux.
3640 set( MINOR_VERSIONS "50" "49" "48" "47" "46" "45" "44" "43" "42" "41"
@@ -236,6 +240,10 @@
236240 endif( FMOD_LIBRARY )
237241
238242
243+# Search for FluidSynth
244+
245+include( ../FindFluidSynth.cmake )
246+
239247 # Search for NASM
240248
241249 if( NOT NO_ASM )
@@ -370,7 +378,8 @@
370378
371379 if( CMAKE_COMPILER_IS_GNUCXX )
372380 if( PROFILE )
373- set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" )
381+ set( CMAKE_C_FLinclude( FindFluidSynth.cmake )
382+AGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pg" )
374383 set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg" )
375384 set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -pg" )
376385 set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -pg" )
@@ -476,8 +485,10 @@
476485
477486 # Libraries ZDoom needs
478487
479-set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${FMOD_LIBRARY}" )
480-include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" )
488+
489+message( STATUS "Fluid synth libs: ${FLUIDSYNTH_LIBRARIES}" )
490+set( ZDOOM_LIBS ${ZDOOM_LIBS} "${ZLIB_LIBRARIES}" "${JPEG_LIBRARIES}" "${BZIP2_LIBRARIES}" "${FMOD_LIBRARY}" "${FLUIDSYNTH_LIBRARIES}" )
491+include_directories( "${ZLIB_INCLUDE_DIR}" "${FMOD_INCLUDE_DIR}" "${BZIP2_INCLUDE_DIR}" "${LZMA_INCLUDE_DIR}" "${JPEG_INCLUDE_DIR}" "${FLUIDSYNTH_INCLUDE_DIR}" )
481492
482493 # Start defining source files for ZDoom
483494
@@ -572,6 +583,9 @@
572583 set( X86_SOURCES )
573584 endif( SSE_MATTERS )
574585
586+if( FLUIDSYNTH_FOUND )
587+ add_definitions( -DHAVE_FLUIDSYNTH )
588+endif( FLUIDSYNTH_FOUND )
575589
576590 add_executable( zdoom WIN32
577591 autostart.cpp
@@ -793,6 +807,7 @@
793807 sound/music_mus_midiout.cpp
794808 sound/music_mus_opl.cpp
795809 sound/music_stream.cpp
810+ sound/music_fluidsynth_mididevice.cpp
796811 sound/music_timidity_mididevice.cpp
797812 sound/music_win_mididevice.cpp
798813 textures/automaptexture.cpp
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/fmodsound.cpp
--- a/src/sound/fmodsound.cpp Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/fmodsound.cpp Sun Aug 15 19:54:59 2010 +0000
@@ -101,6 +101,7 @@
101101 EXTERN_CVAR (Int, snd_samplerate)
102102 EXTERN_CVAR (Bool, snd_pitched)
103103 EXTERN_CVAR (Int, snd_channels)
104+EXTERN_CVAR (String, snd_midipatchset)
104105
105106 extern int sfx_empty;
106107
@@ -115,7 +116,6 @@
115116 CVAR (String, snd_resampler, "Linear", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
116117 CVAR (String, snd_speakermode, "Auto", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
117118 CVAR (String, snd_output_format, "PCM-16", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
118-CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
119119 CVAR (Bool, snd_profile, false, 0)
120120
121121 // Underwater low-pass filter cutoff frequency. Set to 0 to disable the filter.
@@ -644,6 +644,7 @@
644644 ChannelGroupTargetUnit = NULL;
645645 SfxReverbHooked = false;
646646 SfxReverbPlaceholder = NULL;
647+ SfxHeadMixer = NULL;
647648 OutputPlugin = 0;
648649
649650 Printf("I_InitSound: Initializing FMOD\n");
@@ -706,7 +707,8 @@
706707
707708 if (!ShowedBanner)
708709 {
709- Printf("FMOD Sound System, copyright © Firelight Technologies Pty, Ltd., 1994-2009.\n");
710+ // '\xa9' is the copyright symbol in the Windows-1252 code page.
711+ Printf("FMOD Sound System, copyright \xa9 Firelight Technologies Pty, Ltd., 1994-2009.\n");
710712 Printf("Loaded FMOD version %x.%02x.%02x\n", version >> 16, (version >> 8) & 255, version & 255);
711713 ShowedBanner = true;
712714 }
@@ -1014,6 +1016,12 @@
10141016 result = Sys->createDSPByType(FMOD_DSP_TYPE_MIXER, &SfxReverbPlaceholder);
10151017 if (result == FMOD_OK)
10161018 {
1019+ result = Sys->createDSPByType(FMOD_DSP_TYPE_MIXER, &SfxHeadMixer);
1020+ result = sfx_head->addInput(SfxHeadMixer, &SfxConnection);
1021+ result = sfx_head->disconnectFrom(pausable_head);
1022+ sfx_head = SfxHeadMixer;
1023+ SfxHeadMixer->setActive(true);
1024+ SfxHeadMixer->setBypass(false);
10171025 // Replace the PausableSFX->SFX connection with
10181026 // PausableSFX->ReverbPlaceholder->SFX.
10191027 result = SfxReverbPlaceholder->addInput(pausable_head, NULL);
@@ -1023,13 +1031,13 @@
10231031 result = sfx_head->addInput(SfxReverbPlaceholder, &connection);
10241032 if (result == FMOD_OK)
10251033 {
1026- sfx_head->disconnectFrom(pausable_head);
1034+// sfx_head->disconnectFrom(pausable_head);
10271035 SfxReverbPlaceholder->setActive(true);
10281036 SfxReverbPlaceholder->setBypass(true);
10291037 // The placeholder now takes the place of the pausable_head
10301038 // for the following connections.
10311039 pausable_head = SfxReverbPlaceholder;
1032- SfxConnection = connection;
1040+ // SfxConnection = connection;
10331041 }
10341042 }
10351043 else
@@ -1038,6 +1046,7 @@
10381046 SfxReverbPlaceholder = NULL;
10391047 }
10401048 }
1049+#if 1
10411050 result = WaterLP->addInput(pausable_head, NULL);
10421051 WaterLP->setActive(false);
10431052 WaterLP->setParameter(FMOD_DSP_LOWPASS_CUTOFF, snd_waterlp);
@@ -1069,6 +1078,7 @@
10691078 {
10701079 result = sfx_head->addInput(WaterLP, NULL);
10711080 }
1081+#endif
10721082 }
10731083 }
10741084 }
@@ -1147,6 +1157,11 @@
11471157 SfxReverbPlaceholder->release();
11481158 SfxReverbPlaceholder = NULL;
11491159 }
1160+ if (SfxHeadMixer != NULL)
1161+ {
1162+ SfxHeadMixer->release();
1163+ SfxHeadMixer = NULL;
1164+ }
11501165
11511166 Sys->close();
11521167 if (OutputPlugin != 0)
@@ -1330,10 +1345,10 @@
13301345 #endif
13311346
13321347 out.Format ("%d channels,"TEXTCOLOR_YELLOW"%5.2f"TEXTCOLOR_NORMAL"%% CPU "
1333- "(DSP:"TEXTCOLOR_YELLOW"%2.2f"TEXTCOLOR_NORMAL"%% "
1334- "Stream:"TEXTCOLOR_YELLOW"%2.2f"TEXTCOLOR_NORMAL"%% "
1335- "Geometry:"TEXTCOLOR_YELLOW"%2.2f"TEXTCOLOR_NORMAL"%% "
1336- "Update:"TEXTCOLOR_YELLOW"%2.2f"TEXTCOLOR_NORMAL"%%)",
1348+ "(DSP:"TEXTCOLOR_YELLOW"%5.2f"TEXTCOLOR_NORMAL"%% "
1349+ "Stream:"TEXTCOLOR_YELLOW"%5.2f"TEXTCOLOR_NORMAL"%% "
1350+ "Geometry:"TEXTCOLOR_YELLOW"%5.2f"TEXTCOLOR_NORMAL"%% "
1351+ "Update:"TEXTCOLOR_YELLOW"%5.2f"TEXTCOLOR_NORMAL"%%)",
13371352 channels, total, dsp, stream, geometry, update);
13381353 return out;
13391354 }
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/fmodsound.h
--- a/src/sound/fmodsound.h Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/fmodsound.h Sun Aug 15 19:54:59 2010 +0000
@@ -103,7 +103,8 @@
103103 FMOD::DSP *WaterLP, *WaterReverb;
104104 FMOD::DSPConnection *SfxConnection;
105105 FMOD::DSP *ChannelGroupTargetUnit;
106- FMOD::DSP *SfxReverbPlaceholder;
106+ FMOD::DSP *SfxReverbPlaceholder;
107+ FMOD::DSP *SfxHeadMixer;
107108 bool SfxReverbHooked;
108109 float LastWaterLP;
109110 unsigned int OutputPlugin;
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/i_music.cpp
--- a/src/sound/i_music.cpp Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/i_music.cpp Sun Aug 15 19:54:59 2010 +0000
@@ -162,6 +162,18 @@
162162 {
163163 }
164164
165+void MusInfo::FluidSettingInt(const char *, int)
166+{
167+}
168+
169+void MusInfo::FluidSettingNum(const char *, double)
170+{
171+}
172+
173+void MusInfo::FluidSettingStr(const char *, const char *)
174+{
175+}
176+
165177 FString MusInfo::GetStats()
166178 {
167179 return "No stats available for this song";
@@ -428,6 +440,12 @@
428440 {
429441 info = new MUSSong2(file, musiccache, len, MIDI_Timidity);
430442 }
443+#ifdef HAVE_FLUIDSYNTH
444+ else if (snd_mididevice == -5 && device == MDEV_DEFAULT)
445+ {
446+ info = new MUSSong2(file, musiccache, len, MIDI_Fluid);
447+ }
448+#endif
431449 if (info != NULL && !info->IsValid())
432450 {
433451 delete info;
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/i_music.h
--- a/src/sound/i_music.h Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/i_music.h Sun Aug 15 19:54:59 2010 +0000
@@ -98,6 +98,9 @@
9898 virtual FString GetStats();
9999 virtual MusInfo *GetOPLDumper(const char *filename);
100100 virtual MusInfo *GetWaveDumper(const char *filename, int rate);
101+ virtual void FluidSettingInt(const char *setting, int value); // FluidSynth settings
102+ virtual void FluidSettingNum(const char *setting, double value); // "
103+ virtual void FluidSettingStr(const char *setting, const char *value); // "
101104
102105 enum EState
103106 {
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/i_musicinterns.h
--- a/src/sound/i_musicinterns.h Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/i_musicinterns.h Sun Aug 15 19:54:59 2010 +0000
@@ -95,6 +95,9 @@
9595 virtual bool NeedThreadedCallback() = 0;
9696 virtual void PrecacheInstruments(const WORD *instruments, int count);
9797 virtual void TimidityVolumeChanged();
98+ virtual void FluidSettingInt(const char *setting, int value);
99+ virtual void FluidSettingNum(const char *setting, double value);
100+ virtual void FluidSettingStr(const char *setting, const char *value);
98101 virtual FString GetStats();
99102 };
100103
@@ -255,6 +258,64 @@
255258 FILE *File;
256259 };
257260
261+// FluidSynth implementation of a MIDI device -------------------------------
262+
263+#ifdef HAVE_FLUIDSYNTH
264+#include <fluidsynth.h>
265+
266+class FluidSynthMIDIDevice : public MIDIDevice
267+{
268+public:
269+ FluidSynthMIDIDevice();
270+ ~FluidSynthMIDIDevice();
271+
272+ int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata);
273+ void Close();
274+ bool IsOpen() const;
275+ int GetTechnology() const;
276+ int SetTempo(int tempo);
277+ int SetTimeDiv(int timediv);
278+ int StreamOut(MIDIHDR *data);
279+ int StreamOutSync(MIDIHDR *data);
280+ int Resume();
281+ void Stop();
282+ int PrepareHeader(MIDIHDR *data);
283+ int UnprepareHeader(MIDIHDR *data);
284+ bool FakeVolume();
285+ bool Pause(bool paused);
286+ bool NeedThreadedCallback();
287+ void PrecacheInstruments(const WORD *instruments, int count);
288+ FString GetStats();
289+ void FluidSettingInt(const char *setting, int value);
290+ void FluidSettingNum(const char *setting, double value);
291+ void FluidSettingStr(const char *setting, const char *value);
292+
293+protected:
294+ static bool FillStream(SoundStream *stream, void *buff, int len, void *userdata);
295+ bool ServiceStream(void *buff, int numbytes);
296+ void HandleEvent(int status, int parm1, int parm2);
297+ int LoadPatchSets(const char *patches);
298+
299+ void (*Callback)(unsigned int, void *, DWORD, DWORD);
300+ void *CallbackData;
301+
302+ void CalcTickRate();
303+ int PlayTick();
304+
305+ FCriticalSection CritSec;
306+ SoundStream *Stream;
307+ fluid_settings_t *FluidSettings;
308+ fluid_synth_t *FluidSynth;
309+ double Tempo;
310+ double Division;
311+ double SamplesPerTick;
312+ double NextTickIn;
313+ MIDIHDR *Events;
314+ bool Started;
315+ DWORD Position;
316+};
317+#endif
318+
258319 // Base class for streaming MUS and MIDI files ------------------------------
259320
260321 // MIDI device selection.
@@ -262,7 +323,8 @@
262323 {
263324 MIDI_Win,
264325 MIDI_OPL,
265- MIDI_Timidity
326+ MIDI_Timidity,
327+ MIDI_Fluid
266328 };
267329
268330 class MIDIStreamer : public MusInfo
@@ -282,6 +344,9 @@
282344 bool IsValid() const;
283345 void Update();
284346 FString GetStats();
347+ void FluidSettingInt(const char *setting, int value);
348+ void FluidSettingNum(const char *setting, double value);
349+ void FluidSettingStr(const char *setting, const char *value);
285350
286351 protected:
287352 MIDIStreamer(const char *dumpname, EMIDIDevice type);
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/music_midi_base.cpp
--- a/src/sound/music_midi_base.cpp Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/music_midi_base.cpp Sun Aug 15 19:54:59 2010 +0000
@@ -9,6 +9,9 @@
99
1010 static DWORD nummididevices;
1111 static bool nummididevicesset;
12+
13+CVAR (String, snd_midipatchset, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
14+
1215 #ifdef _WIN32
1316 UINT mididevice;
1417
@@ -19,7 +22,7 @@
1922 if (!nummididevicesset)
2023 return;
2124
22- if ((self >= (signed)nummididevices) || (self < -4))
25+ if ((self >= (signed)nummididevices) || (self < -5))
2326 {
2427 Printf ("ID out of range. Using default device.\n");
2528 self = 0;
@@ -177,8 +180,8 @@
177180
178181 CUSTOM_CVAR(Int, snd_mididevice, -1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
179182 {
180- if (self < -3)
181- self = -3;
183+ if (self < -5)
184+ self = -5;
182185 else if (self > -1)
183186 self = -1;
184187 }
diff -r b1a14dcd96c8 -r 4dc0c7a95f06 src/sound/music_midistream.cpp
--- a/src/sound/music_midistream.cpp Sun Aug 15 14:09:17 2010 +0000
+++ b/src/sound/music_midistream.cpp Sun Aug 15 19:54:59 2010 +0000
@@ -215,6 +215,12 @@
215215 assert(0);
216216 // Intentional fall-through for non-Windows systems.
217217
218+#ifdef HAVE_FLUIDSYNTH
219+ case MIDI_Fluid:
220+ MIDI = new FluidSynthMIDIDevice;
221+ break;
222+#endif
223+
218224 case MIDI_Timidity:
219225 MIDI = new TimidityMIDIDevice;
220226 break;
@@ -225,10 +231,10 @@
225231 }
226232
227233 #ifndef _WIN32
228- assert(MIDI->NeedThreadedCallback() == false);
234+ assert(MIDI == NULL || MIDI->NeedThreadedCallback() == false);
229235 #endif
230236
231- if (0 != MIDI->Open(Callback, this))
237+ if (MIDI == NULL || 0 != MIDI->Open(Callback, this))
232238 {
233239 Printf(PRINT_BOLD, "Could not open MIDI out device\n");
234240 return;
@@ -435,6 +441,48 @@
435441 }
436442 }
437443
444+//==========================================================================
445+//
446+// MIDIStreamer :: FluidSettingInt
447+//
448+//==========================================================================
449+
450+void MIDIStreamer::FluidSettingInt(const char *setting, int value)
451+{
452+ if (MIDI != NULL)
453+ {
454+ MIDI->FluidSettingInt(setting, value);
455+ }
456+}
457+
458+//==========================================================================
459+//
460+// MIDIStreamer :: FluidSettingNum
461+//
462+//==========================================================================
463+
464+void MIDIStreamer::FluidSettingNum(const char *setting, double value)
465+{
466+ if (MIDI != NULL)
467+ {
468+ MIDI->FluidSettingNum(setting, value);
469+ }
470+}
471+
472+//==========================================================================
473+//
474+// MIDIDeviceStreamer :: FluidSettingStr
475+//
476+//==========================================================================
477+
478+void MIDIStreamer::FluidSettingStr(const char *setting, const char *value)
479+{
480+ if (MIDI != NULL)
481+ {
482+ MIDI->FluidSettingStr(setting, value);
483+ }
484+}
485+
438486
439487 //==========================================================================
440488 //
@@ -842,6 +890,36 @@
842890
843891 //==========================================================================
844892 //
893+// MIDIDevice :: FluidSettingInt
894+//
895+//==========================================================================
896+
897+void MIDIDevice::FluidSettingInt(const char *setting, int value)
898+{
899+}
900+
901+//==========================================================================
902+//
903+// MIDIDevice :: FluidSettingNum
904+//
905+//==========================================================================
906+
907+void MIDIDevice::FluidSettingNum(const char *setting, double value)
908+{
909+}
910+
911+//==========================================================================
912+//
913+// MIDIDevice :: FluidSettingStr
914+//
915+//==========================================================================
916+
917+void MIDIDevice::FluidSettingStr(const char *setting, const char *value)
918+{
919+}
920+
921+//==========================================================================
922+//
845923 // MIDIDevice :: GetStats
846924 //
847925 //==========================================================================