forked from bartvdbraak/blender
Added fmod sound for OSX and fixed some endian problems in
gameengine/SoundSystem to get it to work. Maarten (mail@maartengribnau.com)
This commit is contained in:
parent
c458cc7310
commit
bd39a84c8b
@ -42,6 +42,9 @@ ifeq ($(OS),windows)
|
||||
DIRS += fmod
|
||||
DIRS += openal
|
||||
endif
|
||||
ifeq ($(OS),darwin)
|
||||
DIRS += fmod
|
||||
endif
|
||||
ifeq ($(OS),freebsd)
|
||||
DIRS += openal
|
||||
endif
|
||||
|
@ -37,21 +37,20 @@
|
||||
|
||||
#if defined (_WIN32)
|
||||
#define USE_FMOD
|
||||
#elif defined (__linux__)
|
||||
# if defined (__i386__)
|
||||
# define USE_OPENAL
|
||||
# endif
|
||||
#elif defined (__FreeBSD__)
|
||||
# define USE_OPENAL
|
||||
#elif defined (__APPLE__)
|
||||
# define USE_FMOD
|
||||
#else
|
||||
# if defined (__linux__)
|
||||
# if defined (__i386__)
|
||||
# define USE_OPENAL
|
||||
# endif
|
||||
# else
|
||||
# if defined (__FreeBSD__)
|
||||
# define USE_OPENAL
|
||||
# endif
|
||||
# ifdef USE_OPENAL
|
||||
# undef USE_OPENAL
|
||||
# endif
|
||||
# ifdef USE_FMOD
|
||||
# undef USE_FMOD
|
||||
# endif
|
||||
# ifdef USE_OPENAL
|
||||
# undef USE_OPENAL
|
||||
# endif
|
||||
# ifdef USE_FMOD
|
||||
# undef USE_FMOD
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -366,19 +366,31 @@ void SND_FmodDevice::SetObjectLoop(int id, unsigned int loopmode) const
|
||||
{
|
||||
case SND_LOOP_OFF:
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_OFF);
|
||||
#else
|
||||
char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_OFF);
|
||||
#endif
|
||||
// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_OFF);
|
||||
break;
|
||||
}
|
||||
case SND_LOOP_NORMAL:
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_NORMAL);
|
||||
#else
|
||||
char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_NORMAL);
|
||||
#endif
|
||||
// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_NORMAL);
|
||||
break;
|
||||
}
|
||||
case SND_LOOP_BIDIRECTIONAL:
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
char result = FSOUND_Sample_SetLoopMode(m_sources[id], FSOUND_LOOP_BIDI);
|
||||
#else
|
||||
char result = FSOUND_SetLoopMode(m_sources[id], FSOUND_LOOP_BIDI);
|
||||
#endif
|
||||
// char result = FSOUND_SetLoopMode(m_channels[id], FSOUND_LOOP_NORMAL);
|
||||
break;
|
||||
}
|
||||
@ -460,10 +472,14 @@ void SND_FmodDevice::SetObjectTransform(int id,
|
||||
|
||||
void SND_FmodDevice::PlayCD(int track) const
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
signed char result = FSOUND_CD_Play(track);
|
||||
#else
|
||||
signed char result = FSOUND_CD_Play(0, track);
|
||||
#endif
|
||||
|
||||
#ifdef ONTKEVER
|
||||
printf("play track %d, result: %c\n", track, result);
|
||||
printf("SND_FmodDevice::PlayCD(): track=%d, result=%d\n", track, (int)result);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -471,10 +487,14 @@ void SND_FmodDevice::PlayCD(int track) const
|
||||
|
||||
void SND_FmodDevice::PauseCD(bool pause) const
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
signed char result = FSOUND_CD_SetPaused(pause);
|
||||
#else
|
||||
signed char result = FSOUND_CD_SetPaused(0, pause);
|
||||
#endif
|
||||
|
||||
#ifdef ONTKEVER
|
||||
printf("pause cd: %d, result: %c\n", pause, result);
|
||||
printf("SND_FmodDevice::PauseCD(): pause=%d, result=%d\n", pause, (int)result);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -488,10 +508,14 @@ void SND_FmodDevice::StopCD() const
|
||||
{
|
||||
if (pCD->GetUsed())
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
signed char result = FSOUND_CD_Stop();
|
||||
#else
|
||||
signed char result = FSOUND_CD_Stop(0);
|
||||
#endif
|
||||
|
||||
#ifdef ONTKEVER
|
||||
printf("stop cd, result: %c\n", result);
|
||||
printf("SND_FmodDevice::StopCD(): result=%d\n", (int)result);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -501,7 +525,15 @@ void SND_FmodDevice::StopCD() const
|
||||
|
||||
void SND_FmodDevice::SetCDPlaymode(int playmode) const
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
FSOUND_CD_SetPlayMode(playmode);
|
||||
#else
|
||||
FSOUND_CD_SetPlayMode(0, playmode);
|
||||
#endif
|
||||
|
||||
#ifdef ONTKEVER
|
||||
printf("SND_FmodDevice::SetCDPlaymode(): playmode=%d,\n", playmode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -509,10 +541,14 @@ void SND_FmodDevice::SetCDPlaymode(int playmode) const
|
||||
void SND_FmodDevice::SetCDGain(MT_Scalar gain) const
|
||||
{
|
||||
int volume = gain * 255;
|
||||
#ifndef __APPLE__
|
||||
signed char result = FSOUND_CD_SetVolume(volume);
|
||||
#else
|
||||
signed char result = FSOUND_CD_SetVolume(0, volume);
|
||||
#endif
|
||||
|
||||
#ifdef ONTKEVER
|
||||
printf("gain: %f, volume: %d, result: %c\n", gain, volume, result);
|
||||
printf("SND_FmodDevice::SetCDGain(): gain=%f, volume=%d, result=%d\n", gain, volume, (int)result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ void SND_Scene::UpdateActiveObects()
|
||||
#endif
|
||||
|
||||
// if ((playstate == SND_STOPPED && (!juststartedplaying) && !pObject->GetLoopMode() && pObject->IsRunning())
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(__APPLE__)
|
||||
if ((playstate == SND_STOPPED) && !pObject->GetLoopMode())
|
||||
#else
|
||||
if (!pObject->GetLoopMode())
|
||||
|
@ -59,6 +59,44 @@ extern "C" {
|
||||
|
||||
#define BUFFERSIZE 32
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Begin of temporary Endian stuff.
|
||||
* I think there should be a central place to handle endian conversion but for
|
||||
* the time being it suffices. Note that the defines come from the Blender
|
||||
* source.
|
||||
*****************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
SND_endianBig = 0,
|
||||
SND_endianLittle
|
||||
} SND_TEndian;
|
||||
|
||||
#ifdef __APPLE__
|
||||
const SND_TEndian SND_fEndian = SND_endianBig;
|
||||
#else
|
||||
const SND_TEndian SND_fEndian = SND_endianLittle;
|
||||
#endif
|
||||
|
||||
/* This one swaps the bytes in a short */
|
||||
#define SWITCH_SHORT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; \
|
||||
p_i[0] = p_i[1]; \
|
||||
p_i[1] = s_i; }
|
||||
|
||||
/* This one rotates the bytes in an int */
|
||||
#define SWITCH_INT(a) { \
|
||||
char s_i, *p_i; \
|
||||
p_i= (char *)&(a); \
|
||||
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
|
||||
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
|
||||
/*****************************************************************************
|
||||
* End of temporary Endian stuff.
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/* loads a file */
|
||||
void* SND_LoadSample(char *filename)
|
||||
{
|
||||
@ -120,7 +158,10 @@ bool SND_IsSampleValid(const STR_String& name, void* memlocation)
|
||||
|
||||
if(!(memcmp(buffer, "RIFF", 4) && memcmp(&(buffer[8]), "WAVEfmt ", 8)))
|
||||
{
|
||||
int shortbuf = * ((short *) &buffer[20]);
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
short shortbuf = *((short *) &buffer[20]);
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_SHORT(shortbuf);
|
||||
|
||||
if (shortbuf == SND_WAVE_FORMAT_PCM)
|
||||
result = true;
|
||||
|
||||
@ -199,6 +240,8 @@ unsigned int SND_GetSampleFormat(void* sample)
|
||||
{
|
||||
memcpy(&sampletype, ((char*)sample) + 20, 2);
|
||||
}
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_SHORT(sampletype);
|
||||
|
||||
return (unsigned int)sampletype;
|
||||
}
|
||||
@ -214,6 +257,8 @@ unsigned int SND_GetNumberOfChannels(void* sample)
|
||||
{
|
||||
memcpy(&numberofchannels, ((char*)sample) + 22, 2);
|
||||
}
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_SHORT(numberofchannels);
|
||||
|
||||
return (unsigned int)numberofchannels;
|
||||
}
|
||||
@ -229,6 +274,8 @@ unsigned int SND_GetSampleRate(void* sample)
|
||||
{
|
||||
memcpy(&samplerate, ((char*)sample) + 24, 4);
|
||||
}
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_INT(samplerate);
|
||||
|
||||
return samplerate;
|
||||
}
|
||||
@ -244,6 +291,8 @@ unsigned int SND_GetBitRate(void* sample)
|
||||
{
|
||||
memcpy(&bitrate, ((char*)sample) + 34, 2);
|
||||
}
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_SHORT(bitrate);
|
||||
|
||||
return (unsigned int)bitrate;
|
||||
}
|
||||
@ -259,9 +308,13 @@ unsigned int SND_GetNumberOfSamples(void* sample)
|
||||
if (CheckSample(sample))
|
||||
{
|
||||
memcpy(&chunklength, ((char*)sample) + offset, 4);
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_INT(chunklength);
|
||||
|
||||
offset = offset + chunklength + 4;
|
||||
memcpy(data, ((char*)sample) + offset, 4);
|
||||
|
||||
/* This seems very unsafe, what if data is never found (f.i. corrupt file)... */
|
||||
// lets find "data"
|
||||
while (memcmp(data, "data", 4))
|
||||
{
|
||||
@ -270,6 +323,9 @@ unsigned int SND_GetNumberOfSamples(void* sample)
|
||||
}
|
||||
offset += 4;
|
||||
memcpy(&length, ((char*)sample) + offset, 4);
|
||||
|
||||
/* This was endian unsafe. See top of the file for the define. */
|
||||
if (SND_fEndian == SND_endianBig) SWITCH_INT(length);
|
||||
}
|
||||
|
||||
return length;
|
||||
|
@ -85,14 +85,19 @@ $NANBLENDERHOME/lib/darwin-6.1-powerpc/python/lib/python2.2/config
|
||||
Now copy the include files and the libpython2.2.a library to those locations.
|
||||
|
||||
FMOD:
|
||||
Will be added later.
|
||||
Download FMOD from http://www.fmod.org/ and unpack with StuffIt Expander. The
|
||||
archive contains header files and a library. Copy those to these directories
|
||||
(that you need to create first):
|
||||
$NANBLENDERHOME/lib/darwin-6.1-powerpc/fmod/include
|
||||
$NANBLENDERHOME/lib/darwin-6.1-powerpc/fmod/lib
|
||||
|
||||
RANLIB:
|
||||
Although the make files run ranlib on the libraries built, the gcc linker
|
||||
complains about ranlib not being run. Until there is a solution, you will need
|
||||
to run ranlib by hand once in a while when the make breaks. Luckily, the error
|
||||
message lists the full path of the file to run ranlib on... Anybody out there
|
||||
with a real solution?
|
||||
with a real solution? I guess the problem arises from copying the files from
|
||||
one location to the other...
|
||||
|
||||
Now wait, don't type make yet! You'll have to edit a config file of ODE first.
|
||||
go to $NANBLENDERHOME/source/ode/config and edit the file "user-settings" so
|
||||
|
@ -373,40 +373,48 @@ endif
|
||||
ifeq ($(OS),$(findstring $(OS), "freebsd linux windows"))
|
||||
ifeq ($(CPU),i386)
|
||||
ifeq ($(OS),freebsd)
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
else
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
else
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_OPENAL)/lib/libopenal.a
|
||||
# NAN_SND_LIBS += $(OCGDIR)/gameengine/FmodSoundSystem/$(DEBUG_DIR)libFmodSoundSystem.a
|
||||
# NAN_SND_LIBS += $(NAN_FMOD)/lib/libfmod.a
|
||||
# NAN_SND_LIBS += $(OCGDIR)/gameengine/FmodSoundSystem/$(DEBUG_DIR)libFmodSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS),windows)
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
# NAN_SND_LIBS += $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a
|
||||
# NAN_SND_LIBS += $(NAN_OPENAL)/lib/openal_static.lib
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/FmodSoundSystem/$(DEBUG_DIR)libFmodSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_FMOD)/lib/fmodvc.lib
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
else
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
endif
|
||||
ifeq ($(OS),windows)
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
# NAN_SND_LIBS += $(OCGDIR)/gameengine/OpenALSoundSystem/$(DEBUG_DIR)libOpenALSoundSystem.a
|
||||
# NAN_SND_LIBS += $(NAN_OPENAL)/lib/openal_static.lib
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/FmodSoundSystem/$(DEBUG_DIR)libFmodSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_FMOD)/lib/fmodvc.lib
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
else
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
endif
|
||||
endif
|
||||
else
|
||||
ifeq ($(OS),darwin)
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/FmodSoundSystem/$(DEBUG_DIR)libFmodSoundSystem.a
|
||||
NAN_SND_LIBS += $(NAN_FMOD)/lib/libfmod.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
else
|
||||
NAN_SND_LIBS = $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/DummySoundSystem/$(DEBUG_DIR)libDummySoundSystem.a
|
||||
NAN_SND_LIBS += $(OCGDIR)/gameengine/SoundSystem/$(DEBUG_DIR)libSoundSystem.a
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS),windows)
|
||||
|
Loading…
Reference in New Issue
Block a user