diff --git a/CMakeLists.txt b/CMakeLists.txt index fec51ae36..f1002cbc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,6 @@ endif() set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") -option( NO_FMOD "Disable FMODEx sound support" OFF ) option( NO_OPENAL "Disable OpenAL sound support" OFF ) find_package( BZip2 ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc79bc3e7..1779f0eb7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,57 +38,6 @@ if( CMAKE_SIZEOF_VOID_P MATCHES "8" ) set( X64 64 ) endif() -# You can either use "make install" on the FMOD distribution to put it -# in standard system locations, or you can unpack the FMOD distribution -# in the root of the zdoom tree. e.g.: -# zdoom -# docs -# fmodapilinux[64] -or simply- fmod -# jpeg-6b -# ... -# The recommended method is to put it in the zdoom tree, since its -# headers are unversioned. Especially now that we can't work properly -# with anything newer than 4.26.xx, you probably don't want to use -# a system-wide version. - -# Construct version numbers for searching for the FMOD library on Linux. -set( MINOR_VERSIONS "61" "50" "49" "48" "47" "46" "45" "44" "43" "42" "41" - "40" "39" "38" "37" "36" "35" "34" "33" "32" "31" "30" "29" "28" - "27" "26" "25" "24" "23" "22" "21" "20" "21" "19" "18" "17" "16" - "15" "14" "13" "12" "11" "10" "09" "08" "07" "06" "05" "04" "03" - "02" "01" "00" ) -set( MAJOR_VERSIONS "44" "34" "28" "26" "24" "22" "20" ) - -if( NOT FMOD_DIR_VERSIONS ) - set( FMOD_DIR_VERSIONS "" ) -endif() -if( NOT FMOD_VERSIONS ) - set( FMOD_VERSIONS "" ) -endif() -if( NOT FMOD_LOCAL_INC_DIRS ) - set( FMOD_LOCAL_INC_DIRS "" ) -endif() -if( NOT FMOD_LOCAL_LIB_DIRS ) - set( FMOD_LOCAL_LIB_DIRS "" ) -endif() - -set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "../fmod" ) -foreach( majver ${MAJOR_VERSIONS} ) - foreach( minver ${MINOR_VERSIONS} ) - set( FMOD_VERSIONS ${FMOD_VERSIONS} "fmodex${X64}-4.${majver}.${minver}" ) - # FMOD Ex version 4.44 unified 32-bit and 64-bit linux packages into one. - if( NOT majver EQUAL "44" ) - set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux${X64}" ) - else() - set( FMOD_DIR_VERSIONS ${FMOD_DIR_VERSIONS} "${CMAKE_HOME_DIRECTORY}/fmodapi4${majver}${minver}linux" ) - endif() - endforeach() - foreach( dir ${FMOD_DIR_VERSIONS} ) - set( FMOD_LOCAL_INC_DIRS ${FMOD_LOCAL_INC_DIRS} "${dir}/api/inc" ) - set( FMOD_LOCAL_LIB_DIRS ${FMOD_LOCAL_LIB_DIRS} "${dir}/api/lib" ) - endforeach() -endforeach() - if( NOT ZDOOM_LIBS ) set( ZDOOM_LIBS "" ) endif() @@ -104,14 +53,6 @@ if( WIN32 ) add_definitions( -D_WIN32 ) - set( FMOD_SEARCH_PATHS - "C:/Program Files/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - "C:/Program Files (x86)/FMOD SoundSystem/FMOD Programmers API ${WIN_TYPE}/api" - # This next one is for Randy. - "E:/Software/Dev/FMOD/${WIN_TYPE}/api" - ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) - set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) set( NASM_NAMES nasmw nasm ) find_path( D3D_INCLUDE_DIR d3d9.h @@ -168,9 +109,6 @@ if( WIN32 ) DelayImp ) else() if( APPLE ) - set( FMOD_SEARCH_PATHS "/Developer/FMOD Programmers API Mac/api" ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES inc ) - set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) set( NO_GTK ON ) # Prevent inclusion of fp.h and FixMath.h from Carbon framework @@ -182,17 +120,6 @@ else() option( NO_GTK "Disable GTK+ dialogs (Not applicable to Windows)" ) option( VALGRIND "Add special Valgrind sequences to self-modifying code" ) - set( FMOD_SEARCH_PATHS - /usr/local/include - /usr/local/include/fmodex - /usr/include - /usr/include/fmodex - /opt/local/include - /opt/local/include/fmodex - /opt/include - /opt/include/fmodex ) - set( FMOD_INC_PATH_SUFFIXES PATH_SUFFIXES fmodex ) - # Use GTK+ for the IWAD picker, if available. if( NOT NO_GTK ) pkg_check_modules( GTK2 gtk+-2.0 ) @@ -244,65 +171,6 @@ if( NOT NO_OPENAL ) endif() endif() -if( NOT NO_FMOD ) - # Search for FMOD include files - if( NOT WIN32 ) - find_path( FMOD_INCLUDE_DIR fmod.hpp - PATHS ${FMOD_LOCAL_INC_DIRS} ) - endif() - - if( NOT FMOD_INCLUDE_DIR ) - find_path( FMOD_INCLUDE_DIR fmod.hpp - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_INC_PATH_SUFFIXES} ) - endif() - - if( FMOD_INCLUDE_DIR ) - message( STATUS "FMOD include files found at ${FMOD_INCLUDE_DIR}" ) - include_directories( "${FMOD_INCLUDE_DIR}" ) - else() - message( STATUS "Could not find FMOD include files" ) - set( NO_FMOD ON ) - endif() -endif() - -if( NOT NO_FMOD ) - # Decide on the name of the FMOD library we want to use. - if( NOT FMOD_LIB_NAME AND MSVC ) - set( FMOD_LIB_NAME fmodex${X64}_vc ) - endif() - - if( NOT FMOD_LIB_NAME AND BORLAND ) - set( FMOD_LIB_NAME fmodex${X64}_bc ) - endif() - - if( NOT FMOD_LIB_NAME ) - set( FMOD_LIB_NAME fmodex${X64} ) - endif() - - # Search for FMOD library - if( WIN32 OR APPLE ) - find_library( FMOD_LIBRARY ${FMOD_LIB_NAME} - PATHS ${FMOD_SEARCH_PATHS} - ${FMOD_LIB_PATH_SUFFIXES} ) - else() - find_library( FMOD_LIBRARY - NAMES ${FMOD_VERSIONS} - PATHS ${FMOD_LOCAL_LIB_DIRS} ) - endif() - - if( FMOD_LIBRARY ) - message( STATUS "FMOD library found at ${FMOD_LIBRARY}" ) - set( ZDOOM_LIBS ${ZDOOM_LIBS} "${FMOD_LIBRARY}" ) - else() - message( STATUS "Could not find FMOD library" ) - set( NO_FMOD ON ) - endif() -endif() - -if( NO_FMOD ) - add_definitions( -DNO_FMOD=1 ) -endif() if( NO_OPENAL ) add_definitions( -DNO_OPENAL=1 ) @@ -697,10 +565,9 @@ elseif( APPLE ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ) endif() - set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} "${FMOD_LIBRARY}" ) + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} ) set_source_files_properties( posix/osx/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) - set_source_files_properties( "${FMOD_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks ) set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions ) else() set( SYSTEM_SOURCES_DIR posix posix/sdl ) @@ -1002,7 +869,7 @@ set( FASTMATH_SOURCES oplsynth/music_opldumper_mididevice.cpp oplsynth/music_opl_mididevice.cpp oplsynth/opl_mus_player.cpp - sound/fmodsound.cpp + sound/commonsound.cpp sound/i_music.cpp sound/i_sound.cpp sound/mpg123_decoder.cpp @@ -1429,7 +1296,7 @@ endif() if( MSVC ) option( ZDOOM_GENERATE_MAPFILE "Generate .map file for debugging." OFF ) - set( LINKERSTUFF "/MANIFEST:NO /DELAYLOAD:\"fmodex${X64}.dll\"" ) + set( LINKERSTUFF "/MANIFEST:NO /DELAYLOAD:\"OpenAL32.dll\"" ) if( ZDOOM_GENERATE_MAPFILE ) set( LINKERSTUFF "${LINKERSTUFF} /MAP" ) endif() @@ -1467,21 +1334,6 @@ if( APPLE ) set_target_properties(zdoom PROPERTIES LINK_FLAGS "-framework Carbon -framework Cocoa -framework IOKit -framework OpenGL" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" ) - - if( NOT NO_FMOD ) - # Fix fmod link so that it can be found in the app bundle. - find_program( OTOOL otool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" ) - find_program( INSTALL_NAME_TOOL install_name_tool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin" ) - execute_process( COMMAND "${OTOOL}" -L "${FMOD_LIBRARY}" - COMMAND grep "libfmodex.dylib (compat" - COMMAND head -n1 - COMMAND awk "{print $1}" - OUTPUT_VARIABLE FMOD_LINK - OUTPUT_STRIP_TRAILING_WHITESPACE ) - add_custom_command( TARGET zdoom POST_BUILD - COMMAND "${INSTALL_NAME_TOOL}" -change "${FMOD_LINK}" @executable_path/../Frameworks/libfmodex.dylib "$" - COMMENT "Relinking FMOD Ex" ) - endif() endif() source_group("Assembly Files\\ia32" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/asm_ia32/.+") diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index d1753c405..d4c72c40f 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -188,10 +188,6 @@ static bool CheckSkipOptionBlock(FScanner &sc) { filter |= IsOpenALPresent(); } - else if (sc.Compare("FModEx")) - { - filter |= IsFModExPresent(); - } } while (sc.CheckString(",")); sc.MustGetStringName(")"); diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 6c7bb97df..2b9f69b00 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -1370,7 +1370,7 @@ static void S_AddSNDINFO (int lump) sc.MustGetString(); MidiDeviceSetting devset; if (sc.Compare("timidity")) devset.device = MDEV_TIMIDITY; - else if (sc.Compare("fmod") || sc.Compare("sndsys")) devset.device = MDEV_SNDSYS; + else if (sc.Compare("sndsys")) devset.device = MDEV_SNDSYS; else if (sc.Compare("standard")) devset.device = MDEV_MMAPI; else if (sc.Compare("opl")) devset.device = MDEV_OPL; else if (sc.Compare("default")) devset.device = MDEV_DEFAULT; diff --git a/src/sound/commonsound.cpp b/src/sound/commonsound.cpp new file mode 100644 index 000000000..0d3220dcd --- /dev/null +++ b/src/sound/commonsound.cpp @@ -0,0 +1,106 @@ +/* +** commonsound.cpp +** Common definitions for all sound system backends. +** +**--------------------------------------------------------------------------- +** Copyright 1998-2009 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + +// HEADER FILES ------------------------------------------------------------ + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +extern HWND Window; +#define USE_WINDOWS_DWORD +#else +#define FALSE 0 +#define TRUE 1 +#endif +#ifdef __APPLE__ +#include +#elif __sun +#include +#else +#include +#endif + +#include "except.h" +#include "templates.h" +#include "i_sound.h" +#include "c_cvars.h" +#include "i_system.h" +#include "i_music.h" +#include "v_text.h" +#include "v_video.h" +#include "v_palette.h" +#include "cmdlib.h" +#include "s_sound.h" +#include "files.h" + +// MACROS ------------------------------------------------------------------ + +// killough 2/21/98: optionally use varying pitched sounds +//#define PITCH(freq,pitch) (snd_pitched ? ((freq)*(pitch))/128.f : float(freq)) + +// Just some extra for music and whatever +#define NUM_EXTRA_SOFTWARE_CHANNELS 1 + +#define MAX_CHANNELS 256 + +#define SPECTRUM_SIZE 256 + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +ReverbContainer *ForcedEnvironment; + +CVAR(Int, snd_driver, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, snd_buffercount, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, snd_hrtf, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, snd_waterreverb, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(String, snd_resampler, "Linear", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(String, snd_speakermode, "Auto", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(String, snd_output_format, "PCM-16", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(String, snd_midipatchset, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, snd_profile, false, 0) + +// Underwater low-pass filter cutoff frequency. Set to 0 to disable the filter. +CUSTOM_CVAR(Float, snd_waterlp, 250, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + // Clamp to the DSP unit's limits. + if (*self < 10 && *self != 0) + { + self = 10; + } + else if (*self > 22000) + { + self = 22000; + } +} diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index 894951d1b..54da3fcce 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -53,7 +53,6 @@ extern HINSTANCE g_hInst; #include #include "except.h" -#include "fmodsound.h" #include "oalsound.h" #include "mpg123_decoder.h" @@ -82,9 +81,7 @@ CVAR (Int, snd_samplerate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Int, snd_buffersize, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (String, snd_output, "default", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -#ifndef NO_FMOD -#define DEF_BACKEND "fmod" -#elif !defined(NO_OPENAL) +#if !defined(NO_OPENAL) #define DEF_BACKEND "openal" #else #define DEF_BACKEND "null" @@ -266,47 +263,19 @@ void I_InitSound () return; } - // This has been extended to allow falling back from FMod to OpenAL and vice versa if the currently active sound system cannot be found. if (stricmp(snd_backend, "null") == 0) { GSnd = new NullSoundRenderer; } - else if(stricmp(snd_backend, "fmod") == 0) +#ifndef NO_OPENAL + else if (stricmp(snd_backend, "openal") == 0) { - #ifndef NO_FMOD - if (IsFModExPresent()) - { - GSnd = new FMODSoundRenderer; - } - #endif - #ifndef NO_OPENAL - if ((!GSnd || !GSnd->IsValid()) && IsOpenALPresent()) - { - Printf (TEXTCOLOR_RED"FMod Ex Sound init failed. Trying OpenAL.\n"); - I_CloseSound(); - GSnd = new OpenALSoundRenderer; - snd_backend = "openal"; - } - #endif - } - else if(stricmp(snd_backend, "openal") == 0) - { - #ifndef NO_OPENAL - if (IsOpenALPresent()) - { - GSnd = new OpenALSoundRenderer; - } - #endif - #ifndef NO_FMOD - if ((!GSnd || !GSnd->IsValid()) && IsFModExPresent()) - { - Printf (TEXTCOLOR_RED"OpenAL Sound init failed. Trying FMod Ex.\n"); - I_CloseSound(); - GSnd = new FMODSoundRenderer; - snd_backend = "fmod"; - } - #endif + if (IsOpenALPresent()) + { + GSnd = new OpenALSoundRenderer; + } } +#endif else { Printf (TEXTCOLOR_RED"%s: Unknown sound system specified\n", *snd_backend); diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 836d62019..06debcb2f 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -175,7 +175,6 @@ FISoundChannel *S_GetChannel(void *syschan); extern ReverbContainer *DefaultEnvironments[26]; -bool IsFModExPresent(); bool IsOpenALPresent(); #endif