Skip to content

Commit

Permalink
FMOD: Updated for FMOD Programmers API 2
Browse files Browse the repository at this point in the history
Some API changes compared to version 1.
  • Loading branch information
skyjake committed Jan 7, 2021
1 parent b43e544 commit d202e8c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/client/libs/fmod/src/driver_fmod.cpp
Expand Up @@ -191,6 +191,7 @@ static int DS_Init(void)
return false;
}

#if FMOD_VERSION < 0x20000
// Options.
FMOD_ADVANCEDSETTINGS settings;
de::zap(settings);
Expand All @@ -199,6 +200,7 @@ static int DS_Init(void)
settings.HRTFMinAngle = 180;
settings.HRTFFreq = 11000;
FMOD_System_SetAdvancedSettings(fmodSystem, &settings);
#endif

#ifdef _DEBUG
int numPlugins = 0;
Expand Down
12 changes: 12 additions & 0 deletions doomsday/apps/client/libs/fmod/src/fmod_sfx.cpp
Expand Up @@ -429,7 +429,11 @@ void fmod_DS_SFX_Play(sfxbuffer_t* buf)
FMOD_Channel_Set3DMinMaxDistance(info.channel,
info.minDistanceMeters,
info.maxDistanceMeters);
#if FMOD_VERSION < 0x20000
FMOD_Channel_Set3DAttributes(info.channel, &info.position, &info.velocity, 0);
#else
FMOD_Channel_Set3DAttributes(info.channel, &info.position, &info.velocity);
#endif
FMOD_Channel_SetMode(info.channel, info.mode);
}

Expand Down Expand Up @@ -557,15 +561,23 @@ void fmod_DS_SFX_Setv(sfxbuffer_t* buf, int prop, float* values)
case SFXBP_POSITION:
info.position.set(values);
if (info.channel)
#if FMOD_VERSION < 0x20000
FMOD_Channel_Set3DAttributes(info.channel, &info.position,
&info.velocity, 0);
#else
FMOD_Channel_Set3DAttributes(info.channel, &info.position, &info.velocity);
#endif
break;

case SFXBP_VELOCITY:
info.velocity.set(values);
if (info.channel)
#if FMOD_VERSION < 0x20000
FMOD_Channel_Set3DAttributes(info.channel, &info.position,
&info.velocity, 0);
#else
FMOD_Channel_Set3DAttributes(info.channel, &info.position, &info.velocity);
#endif
break;

default:
Expand Down
14 changes: 10 additions & 4 deletions doomsday/cmake/FindFMOD.cmake
Expand Up @@ -5,20 +5,26 @@ set (_oldPath ${FMOD_FMOD_H})
# We may need to clean up the provided path.
deng_clean_path (fmodRoot ${FMOD_DIR})

find_file (FMOD_FMOD_H api/lowlevel/inc/fmod.h
find_file (FMOD_FMOD_H
NAMES
api/lowlevel/inc/fmod.h
api/core/inc/fmod.h
PATHS "${fmodRoot}"
HINTS ENV DENG_DEPEND_PATH
PATH_SUFFIXES "FMOD" "FMOD Programmers API" "FMOD Studio API Windows"
PATH_SUFFIXES
"FMOD"
"FMOD Programmers API"
"FMOD Studio API Windows"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
mark_as_advanced (FMOD_FMOD_H)

if (NOT _oldPath STREQUAL FMOD_FMOD_H)
if (FMOD_FMOD_H)
message (STATUS "Looking for FMOD Low Level Programmer API - found")
message (STATUS "Looking for FMOD Programmer API - found")
else ()
message (STATUS "Looking for FMOD Low Level Programmer API - not found (set the FMOD_DIR variable)")
message (STATUS "Looking for FMOD Programmer API - not found (set the FMOD_DIR variable)")
endif ()
endif ()

Expand Down
4 changes: 4 additions & 0 deletions doomsday/libs/gloom/src/audio/audiosystem.cpp
Expand Up @@ -384,7 +384,11 @@ DE_PIMPL(AudioSystem)
vel.y = velocity().y;
vel.z = velocity().z;

#if FMOD_VERSION < 0x20000
FMOD_Channel_Set3DAttributes(channel, &pos, &vel, NULL);
#else
FMOD_Channel_Set3DAttributes(channel, &pos, &vel);
#endif
FMOD_Channel_Set3DMinMaxDistance(channel, minDistance(), 10000);
FMOD_Channel_Set3DSpread(channel, spatialSpread());
}
Expand Down

0 comments on commit d202e8c

Please sign in to comment.