mirror of https://github.com/axmolengine/axmol.git
Merge branch 'LinuxPort' of https://github.com/laschweinski/cocos2d-x into linux_port
This commit is contained in:
commit
c24d1d3fd6
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,217 @@
|
|||
#ifdef __cplusplus
|
||||
# error "A C++ compiler has been selected for C."
|
||||
#endif
|
||||
|
||||
#if defined(__18CXX)
|
||||
# define ID_VOID_MAIN
|
||||
#endif
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "Watcom"
|
||||
|
||||
#elif defined(__SUNPRO_C)
|
||||
# define COMPILER_ID "SunPro"
|
||||
|
||||
#elif defined(__HP_cc)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#elif defined(__DECC)
|
||||
# define COMPILER_ID "Compaq"
|
||||
|
||||
#elif defined(__IBMC__)
|
||||
# if defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
# elif __IBMC__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
# else
|
||||
# define COMPILER_ID "VisualAge"
|
||||
# endif
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
|
||||
#elif defined(__PATHSCALE__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_ID "GNU"
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
|
||||
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
/* Analog Devices C++ compiler for Blackfin, TigerSHARC and
|
||||
SHARC (21000) DSPs */
|
||||
# define COMPILER_ID "ADSP"
|
||||
|
||||
/* IAR Systems compiler for embedded systems.
|
||||
http://www.iar.com
|
||||
Not supported yet by CMake
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
# define COMPILER_ID "IAR" */
|
||||
|
||||
/* sdcc, the small devices C compiler for embedded systems,
|
||||
http://sdcc.sourceforge.net */
|
||||
#elif defined(SDCC)
|
||||
# define COMPILER_ID "SDCC"
|
||||
|
||||
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
/* This compiler is either not known or is too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__sgi)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
|
||||
# define PLATFORM_ID "IRIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
/* Haiku also defines __BEOS__ so we must
|
||||
put it prior to the check for __BEOS__
|
||||
*/
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID ""
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is becase
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef ID_VOID_MAIN
|
||||
void main() {}
|
||||
#else
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
require += info_arch[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
||||
#endif
|
Binary file not shown.
|
@ -0,0 +1,203 @@
|
|||
/* This source file must have a .cpp extension so that all C++ compilers
|
||||
recognize the extension without flags. Borland does not know .cxx for
|
||||
example. */
|
||||
#ifndef __cplusplus
|
||||
# error "A C compiler has been selected for C++."
|
||||
#endif
|
||||
|
||||
#if defined(__COMO__)
|
||||
# define COMPILER_ID "Comeau"
|
||||
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "Watcom"
|
||||
|
||||
#elif defined(__SUNPRO_CC)
|
||||
# define COMPILER_ID "SunPro"
|
||||
|
||||
#elif defined(__HP_aCC)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#elif defined(__DECCXX)
|
||||
# define COMPILER_ID "Compaq"
|
||||
|
||||
#elif defined(__IBMCPP__)
|
||||
# if defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
# elif __IBMCPP__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
# else
|
||||
# define COMPILER_ID "VisualAge"
|
||||
# endif
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
|
||||
#elif defined(__PATHSCALE__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
# define COMPILER_ID "GNU"
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
|
||||
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
|
||||
/* Analog Devices C++ compiler for Blackfin, TigerSHARC and
|
||||
SHARC (21000) DSPs */
|
||||
# define COMPILER_ID "ADSP"
|
||||
|
||||
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
/* This compiler is either not known or is too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__sgi)
|
||||
# define COMPILER_ID "MIPSpro"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
|
||||
# define PLATFORM_ID "IRIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU) || defined(__HAIKU__) || defined(_HAIKU)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
/* Haiku also defines __BEOS__ so we must
|
||||
put it prior to the check for __BEOS__
|
||||
*/
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID ""
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is becase
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,61 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
.PHONY : default_target
|
||||
|
||||
# The main recursive all target
|
||||
all:
|
||||
.PHONY : all
|
||||
|
||||
# The main recursive preinstall target
|
||||
preinstall:
|
||||
.PHONY : preinstall
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canoncical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
||||
SUFFIXES =
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E remove -f
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/laschweinski/git/cocos2d-x/Box2D
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/laschweinski/git/cocos2d-x/Box2D
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
|
@ -0,0 +1 @@
|
|||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1 @@
|
|||
05569f7633bf44a60894b602d7c1b94d85daba60
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* AudioPlayer.h
|
||||
*
|
||||
* Created on: Aug 18, 2011
|
||||
* Author: laschweinski
|
||||
*/
|
||||
|
||||
#ifndef AUDIOPLAYER_H_
|
||||
#define AUDIOPLAYER_H_
|
||||
|
||||
namespace CocosDenshion {
|
||||
|
||||
class AudioPlayer {
|
||||
public:
|
||||
virtual void close() = 0;
|
||||
|
||||
/**
|
||||
@brief Preload background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
virtual void preloadBackgroundMusic(const char* pszFilePath) = 0;
|
||||
|
||||
/**
|
||||
@brief Play background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
@param bLoop Whether the background music loop or not
|
||||
*/
|
||||
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop = false) = 0;
|
||||
|
||||
/**
|
||||
@brief Stop playing background music
|
||||
@param bReleaseData If release the background music data or not.As default value is false
|
||||
*/
|
||||
virtual void stopBackgroundMusic(bool bReleaseData = false) = 0;
|
||||
|
||||
/**
|
||||
@brief Pause playing background music
|
||||
*/
|
||||
virtual void pauseBackgroundMusic() = 0;
|
||||
|
||||
/**
|
||||
@brief Resume playing background music
|
||||
*/
|
||||
virtual void resumeBackgroundMusic() = 0;
|
||||
|
||||
/**
|
||||
@brief Rewind playing background music
|
||||
*/
|
||||
virtual void rewindBackgroundMusic() = 0;
|
||||
|
||||
virtual bool willPlayBackgroundMusic() = 0;
|
||||
|
||||
/**
|
||||
@brief Whether the background music is playing
|
||||
@return If is playing return true,or return false
|
||||
*/
|
||||
virtual bool isBackgroundMusicPlaying() = 0;
|
||||
|
||||
// properties
|
||||
/**
|
||||
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
virtual float getBackgroundMusicVolume() = 0;
|
||||
|
||||
/**
|
||||
@brief set the volume of background music
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
virtual void setBackgroundMusicVolume(float volume) = 0;
|
||||
|
||||
/**
|
||||
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
virtual float getEffectsVolume() = 0;
|
||||
|
||||
/**
|
||||
@brief set the volume of sound effecs
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
virtual void setEffectsVolume(float volume) = 0;
|
||||
|
||||
// for sound effects
|
||||
/**
|
||||
@brief Play sound effect
|
||||
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
@bLoop Whether to loop the effect playing, default value is false
|
||||
*/
|
||||
virtual unsigned int playEffect(const char* pszFilePath, bool bLoop = false) = 0;
|
||||
|
||||
/**
|
||||
@brief Stop playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
virtual void stopEffect(unsigned int nSoundId) = 0;
|
||||
|
||||
/**
|
||||
@brief preload a compressed audio file
|
||||
@details the compressed audio will be decode to wave, then write into an
|
||||
internal buffer in SimpleaudioEngine
|
||||
*/
|
||||
virtual void preloadEffect(const char* pszFilePath) = 0;
|
||||
|
||||
/**
|
||||
@brief unload the preloaded effect from internal buffer
|
||||
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
virtual void unloadEffect(const char* pszFilePath) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif /* AUDIOPLAYER_H_ */
|
|
@ -0,0 +1,356 @@
|
|||
/*
|
||||
* FmodAudioPlayer.cpp
|
||||
*
|
||||
* Created on: Aug 18, 2011
|
||||
* Author: laschweinski
|
||||
*/
|
||||
|
||||
#include "FmodAudioPlayer.h"
|
||||
#include <stdio.h>
|
||||
#include "stdlib.h"
|
||||
#include "assert.h"
|
||||
#include "string.h"
|
||||
|
||||
#define szMusicSuffix "|"
|
||||
|
||||
namespace CocosDenshion {
|
||||
|
||||
FmodAudioPlayer* FmodAudioPlayer::sharedPlayer() {
|
||||
static FmodAudioPlayer s_SharedPlayer;
|
||||
return &s_SharedPlayer;
|
||||
}
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result) {
|
||||
if (result != FMOD_OK) {
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
FmodAudioPlayer::FmodAudioPlayer() :
|
||||
pMusic(0), pBGMChannel(0), iSoundChannelCount(0) {
|
||||
init();
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::init(){
|
||||
//init
|
||||
FMOD_RESULT result;
|
||||
FMOD::ChannelGroup *masterChannelGroup;
|
||||
|
||||
unsigned int version;
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&pSystem);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = pSystem->setOutput(FMOD_OUTPUTTYPE_ALSA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = pSystem->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = pSystem->createChannelGroup("Channel Group", &pChannelGroup);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = pSystem->getMasterChannelGroup(&masterChannelGroup);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = masterChannelGroup->addGroup(pChannelGroup);
|
||||
ERRCHECK(result);
|
||||
|
||||
mapEffectSound.clear();
|
||||
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::close() {
|
||||
FMOD_RESULT result;
|
||||
//BGM
|
||||
if (pBGMChannel != NULL) {
|
||||
result = pBGMChannel->stop();
|
||||
ERRCHECK(result);
|
||||
pBGMChannel = 0;
|
||||
}
|
||||
|
||||
if (pMusic != NULL) {
|
||||
result = pMusic->release();
|
||||
ERRCHECK(result);
|
||||
pMusic = 0;
|
||||
}
|
||||
|
||||
result = pChannelGroup->release();
|
||||
ERRCHECK(result);
|
||||
sMusicPath.clear();
|
||||
|
||||
result = pSystem->close();
|
||||
ERRCHECK(result);
|
||||
result = pSystem->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
FmodAudioPlayer::~FmodAudioPlayer() {
|
||||
FMOD_RESULT result;
|
||||
//BGM
|
||||
if (pBGMChannel != NULL) {
|
||||
result = pBGMChannel->stop();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
if (pMusic != NULL) {
|
||||
result = pMusic->release();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = pChannelGroup->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = pSystem->close();
|
||||
ERRCHECK(result);
|
||||
result = pSystem->release();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
// BGM
|
||||
void FmodAudioPlayer::preloadBackgroundMusic(const char* pszFilePath) {
|
||||
FMOD_RESULT result;
|
||||
pSystem->update();
|
||||
string sNewMusicPath = string(pszFilePath) + szMusicSuffix;
|
||||
if (pMusic && sNewMusicPath != sMusicPath) {
|
||||
//release old
|
||||
result = pMusic->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
sMusicPath = sNewMusicPath;
|
||||
|
||||
}
|
||||
|
||||
result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0, &pMusic);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::playBackgroundMusic(const char* pszFilePath, bool bLoop) {
|
||||
pSystem->update();
|
||||
if (pMusic == NULL) {
|
||||
//did not load it
|
||||
//load the new music
|
||||
FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL,
|
||||
0, &pMusic);
|
||||
ERRCHECK(result);
|
||||
sMusicPath = string(pszFilePath) + szMusicSuffix;
|
||||
} else {
|
||||
string sNewMusicPath = string(pszFilePath) + szMusicSuffix;
|
||||
if (pBGMChannel) {
|
||||
pBGMChannel->stop();
|
||||
pBGMChannel = 0;
|
||||
}
|
||||
|
||||
if (sNewMusicPath != sMusicPath) {
|
||||
|
||||
pMusic->release();
|
||||
//load the new music
|
||||
FMOD_RESULT result = pSystem->createSound(pszFilePath,
|
||||
FMOD_LOOP_NORMAL, 0, &pMusic);
|
||||
sMusicPath = sNewMusicPath;
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pMusic, true,
|
||||
&pBGMChannel);
|
||||
ERRCHECK(result);
|
||||
|
||||
pBGMChannel->setLoopCount((bLoop) ? -1 : 1);
|
||||
result = pBGMChannel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::stopBackgroundMusic(bool bReleaseData) {
|
||||
FMOD_RESULT result;
|
||||
pSystem->update();
|
||||
|
||||
if (pBGMChannel == NULL || pMusic == NULL) {
|
||||
return;
|
||||
}
|
||||
if (bReleaseData) {
|
||||
result = pBGMChannel->stop();
|
||||
ERRCHECK(result);
|
||||
result = pMusic->release();
|
||||
ERRCHECK(result);
|
||||
pBGMChannel = 0;
|
||||
} else {
|
||||
result = pBGMChannel->stop();
|
||||
ERRCHECK(result);
|
||||
pBGMChannel = 0;
|
||||
}
|
||||
sMusicPath.clear();
|
||||
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::pauseBackgroundMusic() {
|
||||
if (pBGMChannel == NULL) {
|
||||
return;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->setPaused(true);
|
||||
ERRCHECK(result);
|
||||
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::resumeBackgroundMusic() {
|
||||
if (pBGMChannel == NULL) {
|
||||
return;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::rewindBackgroundMusic() {
|
||||
if (pBGMChannel == NULL) {
|
||||
return;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->setPosition(0, FMOD_TIMEUNIT_MS);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
bool FmodAudioPlayer::willPlayBackgroundMusic() {
|
||||
pSystem->update();
|
||||
return false; //do it according to win
|
||||
}
|
||||
|
||||
bool FmodAudioPlayer::isBackgroundMusicPlaying() {
|
||||
bool bPlaying;
|
||||
if (pBGMChannel == NULL) {
|
||||
return false;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->isPlaying(&bPlaying);
|
||||
ERRCHECK(result);
|
||||
return bPlaying;
|
||||
|
||||
}
|
||||
|
||||
float FmodAudioPlayer::getBackgroundMusicVolume() {
|
||||
float fVolumn;
|
||||
if (pBGMChannel == NULL) {
|
||||
return 0;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->getVolume(&fVolumn);
|
||||
ERRCHECK(result);
|
||||
return fVolumn;
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::setBackgroundMusicVolume(float volume) {
|
||||
if (pBGMChannel == NULL) {
|
||||
return;
|
||||
}
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pBGMChannel->setVolume(volume);
|
||||
ERRCHECK(result);
|
||||
|
||||
}
|
||||
//~BGM
|
||||
|
||||
// for sound effects
|
||||
float FmodAudioPlayer::getEffectsVolume() {
|
||||
float fVolumn;
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pChannelGroup->getVolume(&fVolumn);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::setEffectsVolume(float volume) {
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pChannelGroup->setVolume(volume);
|
||||
ERRCHECK(result);
|
||||
|
||||
}
|
||||
|
||||
unsigned int FmodAudioPlayer::playEffect(const char* pszFilePath, bool bLoop) {
|
||||
FMOD::Channel* pChannel;
|
||||
FMOD::Sound* pSound = NULL;
|
||||
|
||||
pSystem->update();
|
||||
|
||||
map<string, FMOD::Sound*>::iterator l_it = mapEffectSound.find(
|
||||
string(pszFilePath));
|
||||
if (l_it == mapEffectSound.end()) {
|
||||
//no load it yet
|
||||
preloadEffect(pszFilePath);
|
||||
l_it = mapEffectSound.find(string(pszFilePath));
|
||||
}
|
||||
pSound = l_it->second;
|
||||
assert(pSound);
|
||||
|
||||
FMOD_RESULT result = pSystem->playSound(FMOD_CHANNEL_FREE, pSound, true,
|
||||
&pChannel);
|
||||
ERRCHECK(result);
|
||||
|
||||
pChannel->setChannelGroup(pChannelGroup);
|
||||
|
||||
//set its loop
|
||||
pChannel->setLoopCount((bLoop) ? -1 : 1);
|
||||
result = pChannel->setPaused(false);
|
||||
|
||||
mapEffectSoundChannel[iSoundChannelCount] = pChannel;
|
||||
|
||||
return iSoundChannelCount++;
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::stopEffect(unsigned int nSoundId) {
|
||||
FMOD::Channel* pChannel;
|
||||
pSystem->update();
|
||||
|
||||
map<unsigned int, FMOD::Channel*>::iterator l_it =
|
||||
mapEffectSoundChannel.find(nSoundId);
|
||||
if (l_it == mapEffectSoundChannel.end()) {
|
||||
//no play yet
|
||||
return;
|
||||
}
|
||||
pChannel = l_it->second;
|
||||
//stop the channel;
|
||||
pChannel->stop();
|
||||
|
||||
//delete from the map;
|
||||
mapEffectSoundChannel.erase(nSoundId);
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::preloadEffect(const char* pszFilePath) {
|
||||
FMOD::Sound* pLoadSound;
|
||||
|
||||
pSystem->update();
|
||||
FMOD_RESULT result = pSystem->createSound(pszFilePath, FMOD_LOOP_NORMAL, 0,
|
||||
&pLoadSound);
|
||||
ERRCHECK(result);
|
||||
|
||||
mapEffectSound[string(pszFilePath)] = pLoadSound;
|
||||
|
||||
}
|
||||
|
||||
void FmodAudioPlayer::unloadEffect(const char* pszFilePath) {
|
||||
FMOD::Sound* pSound;
|
||||
pSystem->update();
|
||||
|
||||
map<string, FMOD::Sound*>::iterator l_it = mapEffectSound.find(
|
||||
string(pszFilePath));
|
||||
if (l_it == mapEffectSound.end()) {
|
||||
//no load yet
|
||||
return;
|
||||
}
|
||||
pSound = l_it->second;
|
||||
|
||||
//release the sound;
|
||||
pSound->release();
|
||||
|
||||
//delete from the map
|
||||
mapEffectSound.erase(string(pszFilePath));
|
||||
}
|
||||
|
||||
//~for sound effects
|
||||
|
||||
} /* namespace CocosDenshion */
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* FmodAudioPlayer.h
|
||||
*
|
||||
* Created on: Aug 18, 2011
|
||||
* Author: laschweinski
|
||||
*/
|
||||
|
||||
#ifndef FMODAUDIOPLAYER_H_
|
||||
#define FMODAUDIOPLAYER_H_
|
||||
|
||||
#include "fmod.hpp"
|
||||
#include "fmod_errors.h"
|
||||
#include "AudioPlayer.h"
|
||||
#include "string"
|
||||
#include <map>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace CocosDenshion {
|
||||
|
||||
class FmodAudioPlayer : public AudioPlayer{
|
||||
public:
|
||||
FmodAudioPlayer();
|
||||
virtual ~FmodAudioPlayer();
|
||||
|
||||
static FmodAudioPlayer* sharedPlayer();
|
||||
|
||||
virtual void close();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@brief Preload background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
virtual void preloadBackgroundMusic(const char* pszFilePath);
|
||||
|
||||
/**
|
||||
@brief Play background music
|
||||
@param pszFilePath The path of the background music file,or the FileName of T_SoundResInfo
|
||||
@param bLoop Whether the background music loop or not
|
||||
*/
|
||||
virtual void playBackgroundMusic(const char* pszFilePath, bool bLoop);
|
||||
|
||||
/**
|
||||
@brief Stop playing background music
|
||||
@param bReleaseData If release the background music data or not.As default value is false
|
||||
*/
|
||||
virtual void stopBackgroundMusic(bool bReleaseData);
|
||||
|
||||
/**
|
||||
@brief Pause playing background music
|
||||
*/
|
||||
virtual void pauseBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Resume playing background music
|
||||
*/
|
||||
virtual void resumeBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Rewind playing background music
|
||||
*/
|
||||
virtual void rewindBackgroundMusic();
|
||||
|
||||
virtual bool willPlayBackgroundMusic();
|
||||
|
||||
/**
|
||||
@brief Whether the background music is playing
|
||||
@return If is playing return true,or return false
|
||||
*/
|
||||
virtual bool isBackgroundMusicPlaying();
|
||||
|
||||
// properties
|
||||
/**
|
||||
@brief The volume of the background music max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
virtual float getBackgroundMusicVolume();
|
||||
|
||||
/**
|
||||
@brief set the volume of background music
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
virtual void setBackgroundMusicVolume(float volume);
|
||||
|
||||
/**
|
||||
@brief The volume of the effects max value is 1.0,the min value is 0.0
|
||||
*/
|
||||
virtual float getEffectsVolume();
|
||||
|
||||
/**
|
||||
@brief set the volume of sound effecs
|
||||
@param volume must be in 0.0~1.0
|
||||
*/
|
||||
virtual void setEffectsVolume(float volume);
|
||||
|
||||
// for sound effects
|
||||
/**
|
||||
@brief Play sound effect
|
||||
@param pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
@bLoop Whether to loop the effect playing, default value is false
|
||||
*/
|
||||
virtual unsigned int playEffect(const char* pszFilePath, bool bLoop = false);
|
||||
|
||||
/**
|
||||
@brief Stop playing sound effect
|
||||
@param nSoundId The return value of function playEffect
|
||||
*/
|
||||
virtual void stopEffect(unsigned int nSoundId);
|
||||
|
||||
/**
|
||||
@brief preload a compressed audio file
|
||||
@details the compressed audio will be decode to wave, then write into an
|
||||
internal buffer in SimpleaudioEngine
|
||||
*/
|
||||
virtual void preloadEffect(const char* pszFilePath);
|
||||
|
||||
/**
|
||||
@brief unload the preloaded effect from internal buffer
|
||||
@param[in] pszFilePath The path of the effect file,or the FileName of T_SoundResInfo
|
||||
*/
|
||||
virtual void unloadEffect(const char* pszFilePath);
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
map<string, FMOD::Sound*> mapEffectSound;
|
||||
map<unsigned int, FMOD::Channel*> mapEffectSoundChannel;
|
||||
|
||||
FMOD::System* pSystem;
|
||||
FMOD::Sound* pMusic; //BGM
|
||||
FMOD::Channel* pBGMChannel;
|
||||
|
||||
FMOD::ChannelGroup* pChannelGroup;
|
||||
|
||||
unsigned int iSoundChannelCount;
|
||||
|
||||
string sMusicPath;
|
||||
|
||||
};
|
||||
|
||||
} /* namespace CocosDenshion */
|
||||
#endif /* FMODAUDIOPLAYER_H_ */
|
|
@ -0,0 +1,137 @@
|
|||
#include "SimpleAudioEngine.h"
|
||||
#include "FmodAudioPlayer.h"
|
||||
|
||||
namespace CocosDenshion {
|
||||
|
||||
static AudioPlayer* oAudioPlayer;
|
||||
|
||||
SimpleAudioEngine::SimpleAudioEngine() {
|
||||
oAudioPlayer = FmodAudioPlayer::sharedPlayer();
|
||||
}
|
||||
|
||||
SimpleAudioEngine::~SimpleAudioEngine() {
|
||||
}
|
||||
|
||||
SimpleAudioEngine* SimpleAudioEngine::sharedEngine() {
|
||||
static SimpleAudioEngine s_SharedEngine;
|
||||
return &s_SharedEngine;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::end() {
|
||||
oAudioPlayer->close();
|
||||
|
||||
// sharedMusic().Close();
|
||||
//
|
||||
// EffectList::iterator p = sharedList().begin();
|
||||
// while (p != sharedList().end())
|
||||
// {
|
||||
// delete p->second;
|
||||
// p->second = NULL;
|
||||
// p++;
|
||||
// }
|
||||
// sharedList().clear();
|
||||
// return;
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::setResource(const char* pszZipFileName) {
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// BackgroundMusic
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath,
|
||||
bool bLoop) {
|
||||
oAudioPlayer->playBackgroundMusic(pszFilePath, bLoop);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) {
|
||||
oAudioPlayer->stopBackgroundMusic(bReleaseData);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::pauseBackgroundMusic() {
|
||||
oAudioPlayer->pauseBackgroundMusic();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::resumeBackgroundMusic() {
|
||||
oAudioPlayer->resumeBackgroundMusic();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::rewindBackgroundMusic() {
|
||||
oAudioPlayer->rewindBackgroundMusic();
|
||||
}
|
||||
|
||||
bool SimpleAudioEngine::willPlayBackgroundMusic() {
|
||||
return oAudioPlayer->willPlayBackgroundMusic();
|
||||
}
|
||||
|
||||
bool SimpleAudioEngine::isBackgroundMusicPlaying() {
|
||||
return oAudioPlayer->isBackgroundMusicPlaying();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// effect function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath,
|
||||
bool bLoop) {
|
||||
return oAudioPlayer->playEffect(pszFilePath, bLoop);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::stopEffect(unsigned int nSoundId) {
|
||||
return oAudioPlayer->stopEffect(nSoundId);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::preloadEffect(const char* pszFilePath) {
|
||||
return oAudioPlayer->preloadEffect(pszFilePath);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) {
|
||||
return oAudioPlayer->preloadBackgroundMusic(pszFilePath);
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::unloadEffect(const char* pszFilePath) {
|
||||
return oAudioPlayer->unloadEffect(pszFilePath);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// volume interface
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float SimpleAudioEngine::getBackgroundMusicVolume() {
|
||||
return oAudioPlayer->getBackgroundMusicVolume();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::setBackgroundMusicVolume(float volume) {
|
||||
return oAudioPlayer->setBackgroundMusicVolume(volume);
|
||||
}
|
||||
|
||||
float SimpleAudioEngine::getEffectsVolume() {
|
||||
return oAudioPlayer->getBackgroundMusicVolume();
|
||||
}
|
||||
|
||||
void SimpleAudioEngine::setEffectsVolume(float volume) {
|
||||
return oAudioPlayer->setEffectsVolume(volume);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// static function
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char * _FullPath(const char * szPath) {
|
||||
}
|
||||
|
||||
unsigned int _Hash(const char *key) {
|
||||
// unsigned int len = strlen(key);
|
||||
// const char *end=key+len;
|
||||
// unsigned int hash;
|
||||
//
|
||||
// for (hash = 0; key < end; key++)
|
||||
// {
|
||||
// hash *= 16777619;
|
||||
// hash ^= (unsigned int) (unsigned char) toupper(*key);
|
||||
// }
|
||||
// return (hash);
|
||||
}
|
||||
|
||||
} // end of namespace CocosDenshion
|
|
@ -0,0 +1,294 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1982681102">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1982681102" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CocosDenshion"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CocosDenshion/Debug"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="CocosDenshion"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1982681102" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug" postannouncebuildStep="move output libs to a specific libs" postbuildStep="sh ../../../post.sh ${ProjName} cocosdenshion ${ConfigName}">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1982681102." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1290289406" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.1343594495" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
|
||||
<builder buildPath="${workspace_loc:/CocosDenshion/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.2041927999" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1293331295" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2092876171" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
|
||||
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.2020537008" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.886209200" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1002280254" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/third_party/fmod/api/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1604049990" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1178240227" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.206236808" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.debug.option.debugging.level.828037565" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.985313341" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/third_party/fmod/api/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.370598124" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1145844969" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
|
||||
<option defaultValue="true" id="gnu.c.link.option.shared.1822605485" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1767253018" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
|
||||
<option id="gnu.cpp.link.option.libs.956474372" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="fmodex"/>
|
||||
</option>
|
||||
<option defaultValue="true" id="gnu.cpp.link.option.shared.430688089" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1207468004" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1192863353" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.2047527740" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="android|third_party/fmod/tools|third_party/fmod/fmoddesignerapi|third_party/fmod/examples|third_party/fmod/documentation|wophone|win32|proj.wophone|proj.win32|proj.airplay|iphone|airplay" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.509246766">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.509246766" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CocosDenshion"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CocosDenshion/Release"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="CocosDenshion"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.509246766" name="Release" parent="cdt.managedbuild.config.gnu.exe.release" postannouncebuildStep="move output libs to a specific libs" postbuildStep="sh ../../../post.sh ${ProjName} cocosdenshion ${ConfigName}">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.509246766." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.305868874" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.506287391" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
|
||||
<builder buildPath="${workspace_loc:/CocosDenshion/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.1316417033" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1125358518" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.222121229" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
|
||||
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.1962013303" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.2015755429" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1414683978" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/third_party/fmod/api/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1557365568" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1919066836" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1295172282" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.release.option.debugging.level.1006696632" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.92938039" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/third_party/fmod/api/inc}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.757092405" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.490094345" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
|
||||
<option defaultValue="true" id="gnu.c.link.option.shared.2114715478" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1107958294" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
|
||||
<option id="gnu.cpp.link.option.libs.1450744481" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="fmodex"/>
|
||||
</option>
|
||||
<option defaultValue="true" id="gnu.cpp.link.option.shared.1840009551" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1952243970" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.86394856" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.895909947" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="android|third_party/fmod/tools|third_party/fmod/fmoddesignerapi|third_party/fmod/examples|third_party/fmod/documentation|wophone|win32|proj.wophone|proj.win32|proj.airplay|iphone|airplay" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1982681102.1621062209">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1982681102.1621062209" moduleId="org.eclipse.cdt.core.settings" name="AndroidDebug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CocosDenshion"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CocosDenshion/AndroidDebug"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="CocosDenshion"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.1982681102.1621062209" name="AndroidDebug" parent="cdt.managedbuild.config.gnu.exe.debug" postannouncebuildStep="move output libs to a specific libs" postbuildStep="sh ../../../post.sh ${ProjName} cocosdenshion ${ConfigName}">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.1982681102.1621062209." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.1558765061" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.620879821" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/>
|
||||
<builder buildPath="${workspace_loc:/CocosDenshion/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.507120743" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.archiver.base.40387952" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
<tool command="arm-linux-androideabi-g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.792840741" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
|
||||
<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.976541662" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.1307745860" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.438026184" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.2045722816" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1567615028" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.879455147" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.debug.option.debugging.level.1476208622" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.554440625" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.260627685" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.1900603638" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug">
|
||||
<option defaultValue="true" id="gnu.c.link.option.shared.1038390402" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.303615758" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug">
|
||||
<option id="gnu.cpp.link.option.libs.1196370704" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="log"/>
|
||||
</option>
|
||||
<option defaultValue="true" id="gnu.cpp.link.option.shared.1009537507" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.331207899" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.1169174011" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.776530056" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="third_party|Linux|third_party/fmod/tools|third_party/fmod/fmoddesignerapi|third_party/fmod/examples|third_party/fmod/documentation|wophone|win32|proj.wophone|proj.win32|proj.airplay|iphone|airplay" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.509246766.1769340575">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.509246766.1769340575" moduleId="org.eclipse.cdt.core.settings" name="AndroidRelease">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/CocosDenshion"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/CocosDenshion/AndroidRelease"/>
|
||||
<entry flags="RESOLVED" kind="libraryFile" name="CocosDenshion"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="so" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.sharedLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.509246766.1769340575" name="AndroidRelease" parent="cdt.managedbuild.config.gnu.exe.release" postannouncebuildStep="move output libs to a specific libs" postbuildStep="sh ../../../post.sh ${ProjName} cocosdenshion ${ConfigName}">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.exe.release.509246766.1769340575." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.885182269" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1280043208" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
|
||||
<builder buildPath="${workspace_loc:/CocosDenshion/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.474969838" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.archiver.base.509102503" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1702337749" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
|
||||
<option id="gnu.cpp.compiler.exe.release.option.optimization.level.44964931" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.exe.release.option.debugging.level.2138571216" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1983104201" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1493650421" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1390354356" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.923425099" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.exe.release.option.debugging.level.1422867368" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.1675694653" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/include}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.858170289" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.168343506" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
|
||||
<option defaultValue="true" id="gnu.c.link.option.shared.2128797843" name="Shared (-shared)" superClass="gnu.c.link.option.shared" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool command="arm-linux-androideabi-g++" id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.2083694616" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release">
|
||||
<option id="gnu.cpp.link.option.libs.1657717164" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="log"/>
|
||||
</option>
|
||||
<option defaultValue="true" id="gnu.cpp.link.option.shared.21289368" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.258929024" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.1157573136" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.980689040" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="third_party|Linux|third_party/fmod/tools|third_party/fmod/fmoddesignerapi|third_party/fmod/examples|third_party/fmod/documentation|wophone|win32|proj.wophone|proj.win32|proj.airplay|iphone|airplay" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="CocosDenshion.cdt.managedbuild.target.gnu.exe.346390339" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1982681102;cdt.managedbuild.config.gnu.exe.debug.1982681102.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1178240227;cdt.managedbuild.tool.gnu.c.compiler.input.370598124">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.1982681102;cdt.managedbuild.config.gnu.exe.debug.1982681102.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.2092876171;cdt.managedbuild.tool.gnu.cpp.compiler.input.1604049990">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.509246766;cdt.managedbuild.config.gnu.exe.release.509246766.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1919066836;cdt.managedbuild.tool.gnu.c.compiler.input.757092405">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.509246766;cdt.managedbuild.config.gnu.exe.release.509246766.;cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.222121229;cdt.managedbuild.tool.gnu.cpp.compiler.input.1557365568">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
|
@ -0,0 +1,105 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CocosDenshion</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/CocosDenshion/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>Linux</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/Linux</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>android</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/android</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>include</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/include</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>third_party</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-1-PROJECT_LOC/third_party</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,65 @@
|
|||
VERSION = 4.36.01
|
||||
LIBDIR = api/lib
|
||||
HDRDIR = api/inc
|
||||
DESTLIBDIR = /usr/local/lib
|
||||
DESTHDRDIR = /usr/local/include/fmodex
|
||||
|
||||
all:
|
||||
@echo "Possible targets:"
|
||||
@echo "'make fmod_examples' - Build all examples"
|
||||
@echo "'make install' - Install FMOD Ex libraries and headers"
|
||||
@echo "'make uninstall' - Uninstall FMOD Ex libraries and headers"
|
||||
|
||||
fmod_examples:
|
||||
cd examples/3d && make
|
||||
cd examples/cdplayer && make
|
||||
cd examples/channelgroups && make
|
||||
cd examples/dsp_effectperspeaker && make
|
||||
cd examples/dsp_custom && make
|
||||
cd examples/effects && make
|
||||
cd examples/filecallbacks && make
|
||||
cd examples/generatetone && make
|
||||
cd examples/loadfrommemory && make
|
||||
cd examples/multiplesoundcard && make
|
||||
cd examples/multispeakeroutput && make
|
||||
cd examples/netstream && make
|
||||
cd examples/offlinedecoding && make
|
||||
cd examples/pitchdetection && make
|
||||
cd examples/playlist && make
|
||||
cd examples/playsound && make
|
||||
cd examples/playstream && make
|
||||
cd examples/plugin_dev/codec_raw && make
|
||||
cd examples/plugin_dev/dsp_gain && make
|
||||
cd examples/readtags && make
|
||||
cd examples/realtimestitching && make
|
||||
cd examples/recording && make
|
||||
cd examples/recordtodisk && make
|
||||
cd examples/ripnetstream && make
|
||||
cd examples/submixing && make
|
||||
cd examples/useplugins && make
|
||||
cd examples/usercreatedsound && make
|
||||
cd fmoddesignerapi/examples/effects && make
|
||||
cd fmoddesignerapi/examples/info_only && make
|
||||
cd fmoddesignerapi/examples/load_data && make
|
||||
cd fmoddesignerapi/examples/max_playbacks && make
|
||||
cd fmoddesignerapi/examples/parameters && make
|
||||
cd fmoddesignerapi/examples/programmer_selected && make
|
||||
cd fmoddesignerapi/examples/programmer_sound && make
|
||||
cd fmoddesignerapi/examples/simple_event && make
|
||||
|
||||
install:
|
||||
@echo "Installing FMOD Ex libraries and headers..."
|
||||
cp -f ${LIBDIR}/libfmodex-${VERSION}.so ${DESTLIBDIR}
|
||||
cp -f ${LIBDIR}/libfmodexL-${VERSION}.so ${DESTLIBDIR}
|
||||
ldconfig -n ${DESTLIBDIR}
|
||||
mkdir -p ${DESTHDRDIR}
|
||||
cp -f ${HDRDIR}/*.h* ${DESTHDRDIR}
|
||||
@echo "done."
|
||||
|
||||
uninstall:
|
||||
@echo "Uninstalling FMOD Ex libraries..."
|
||||
rm -f ${DESTLIBDIR}/libfmodex-${VERSION}.so
|
||||
rm -f ${DESTLIBDIR}/libfmodexL-${VERSION}.so
|
||||
ldconfig -n ${DESTLIBDIR}
|
||||
rm -rf ${DESTHDRDIR}
|
||||
@echo "done."
|
|
@ -0,0 +1 @@
|
|||
94cc999c1245ef76bb6109e235399b831d00a694
|
|
@ -0,0 +1,607 @@
|
|||
/* ========================================================================================== */
|
||||
/* FMOD Ex - C++ header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2011. */
|
||||
/* */
|
||||
/* Use this header in conjunction with fmod.h (which contains all the constants / callbacks) */
|
||||
/* to develop using C++ classes. */
|
||||
/* ========================================================================================== */
|
||||
|
||||
#ifndef _FMOD_HPP
|
||||
#define _FMOD_HPP
|
||||
|
||||
#include "fmod.h"
|
||||
|
||||
/*
|
||||
Constant and defines
|
||||
*/
|
||||
|
||||
/*
|
||||
FMOD Namespace
|
||||
*/
|
||||
namespace FMOD
|
||||
{
|
||||
class System;
|
||||
class Sound;
|
||||
class Channel;
|
||||
class ChannelGroup;
|
||||
class SoundGroup;
|
||||
class Reverb;
|
||||
class DSP;
|
||||
class DSPConnection;
|
||||
class Geometry;
|
||||
|
||||
/*
|
||||
FMOD global system functions (optional).
|
||||
*/
|
||||
inline FMOD_RESULT Memory_Initialize(void *poolmem, int poollen, FMOD_MEMORY_ALLOCCALLBACK useralloc, FMOD_MEMORY_REALLOCCALLBACK userrealloc, FMOD_MEMORY_FREECALLBACK userfree, FMOD_MEMORY_TYPE memtypeflags = FMOD_MEMORY_ALL) { return FMOD_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); }
|
||||
inline FMOD_RESULT Memory_GetStats (int *currentalloced, int *maxalloced, bool blocking = true) { return FMOD_Memory_GetStats(currentalloced, maxalloced, blocking); }
|
||||
inline FMOD_RESULT Debug_SetLevel(FMOD_DEBUGLEVEL level) { return FMOD_Debug_SetLevel(level); }
|
||||
inline FMOD_RESULT Debug_GetLevel(FMOD_DEBUGLEVEL *level) { return FMOD_Debug_GetLevel(level); }
|
||||
inline FMOD_RESULT File_SetDiskBusy(int busy) { return FMOD_File_SetDiskBusy(busy); }
|
||||
inline FMOD_RESULT File_GetDiskBusy(int *busy) { return FMOD_File_GetDiskBusy(busy); }
|
||||
|
||||
/*
|
||||
FMOD System factory functions.
|
||||
*/
|
||||
inline FMOD_RESULT System_Create(System **system) { return FMOD_System_Create((FMOD_SYSTEM **)system); }
|
||||
|
||||
/*
|
||||
'System' API
|
||||
*/
|
||||
|
||||
class System
|
||||
{
|
||||
private:
|
||||
|
||||
System(); /* Constructor made private so user cannot statically instance a System class.
|
||||
System_Create must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
|
||||
// Pre-init functions.
|
||||
FMOD_RESULT F_API setOutput (FMOD_OUTPUTTYPE output);
|
||||
FMOD_RESULT F_API getOutput (FMOD_OUTPUTTYPE *output);
|
||||
FMOD_RESULT F_API getNumDrivers (int *numdrivers);
|
||||
FMOD_RESULT F_API getDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid);
|
||||
FMOD_RESULT F_API getDriverInfoW (int id, short *name, int namelen, FMOD_GUID *guid);
|
||||
FMOD_RESULT F_API getDriverCaps (int id, FMOD_CAPS *caps, int *controlpaneloutputrate, FMOD_SPEAKERMODE *controlpanelspeakermode);
|
||||
FMOD_RESULT F_API setDriver (int driver);
|
||||
FMOD_RESULT F_API getDriver (int *driver);
|
||||
FMOD_RESULT F_API setHardwareChannels (int numhardwarechannels);
|
||||
FMOD_RESULT F_API setSoftwareChannels (int numsoftwarechannels);
|
||||
FMOD_RESULT F_API getSoftwareChannels (int *numsoftwarechannels);
|
||||
FMOD_RESULT F_API setSoftwareFormat (int samplerate, FMOD_SOUND_FORMAT format, int numoutputchannels, int maxinputchannels, FMOD_DSP_RESAMPLER resamplemethod);
|
||||
FMOD_RESULT F_API getSoftwareFormat (int *samplerate, FMOD_SOUND_FORMAT *format, int *numoutputchannels, int *maxinputchannels, FMOD_DSP_RESAMPLER *resamplemethod, int *bits);
|
||||
FMOD_RESULT F_API setDSPBufferSize (unsigned int bufferlength, int numbuffers);
|
||||
FMOD_RESULT F_API getDSPBufferSize (unsigned int *bufferlength, int *numbuffers);
|
||||
FMOD_RESULT F_API setFileSystem (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek, FMOD_FILE_ASYNCREADCALLBACK userasyncread, FMOD_FILE_ASYNCCANCELCALLBACK userasynccancel, int blockalign);
|
||||
FMOD_RESULT F_API attachFileSystem (FMOD_FILE_OPENCALLBACK useropen, FMOD_FILE_CLOSECALLBACK userclose, FMOD_FILE_READCALLBACK userread, FMOD_FILE_SEEKCALLBACK userseek);
|
||||
FMOD_RESULT F_API setAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings);
|
||||
FMOD_RESULT F_API getAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings);
|
||||
FMOD_RESULT F_API setSpeakerMode (FMOD_SPEAKERMODE speakermode);
|
||||
FMOD_RESULT F_API getSpeakerMode (FMOD_SPEAKERMODE *speakermode);
|
||||
FMOD_RESULT F_API setCallback (FMOD_SYSTEM_CALLBACK callback);
|
||||
|
||||
// Plug-in support
|
||||
FMOD_RESULT F_API setPluginPath (const char *path);
|
||||
FMOD_RESULT F_API loadPlugin (const char *filename, unsigned int *handle, unsigned int priority = 0);
|
||||
FMOD_RESULT F_API unloadPlugin (unsigned int handle);
|
||||
FMOD_RESULT F_API getNumPlugins (FMOD_PLUGINTYPE plugintype, int *numplugins);
|
||||
FMOD_RESULT F_API getPluginHandle (FMOD_PLUGINTYPE plugintype, int index, unsigned int *handle);
|
||||
FMOD_RESULT F_API getPluginInfo (unsigned int handle, FMOD_PLUGINTYPE *plugintype, char *name, int namelen, unsigned int *version);
|
||||
FMOD_RESULT F_API setOutputByPlugin (unsigned int handle);
|
||||
FMOD_RESULT F_API getOutputByPlugin (unsigned int *handle);
|
||||
FMOD_RESULT F_API createDSPByPlugin (unsigned int handle, DSP **dsp);
|
||||
FMOD_RESULT F_API createCodec (FMOD_CODEC_DESCRIPTION *description, unsigned int priority = 0);
|
||||
|
||||
// Init/Close
|
||||
FMOD_RESULT F_API init (int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata);
|
||||
FMOD_RESULT F_API close ();
|
||||
|
||||
// General post-init system functions
|
||||
FMOD_RESULT F_API update (); /* IMPORTANT! CALL THIS ONCE PER FRAME! */
|
||||
|
||||
FMOD_RESULT F_API set3DSettings (float dopplerscale, float distancefactor, float rolloffscale);
|
||||
FMOD_RESULT F_API get3DSettings (float *dopplerscale, float *distancefactor, float *rolloffscale);
|
||||
FMOD_RESULT F_API set3DNumListeners (int numlisteners);
|
||||
FMOD_RESULT F_API get3DNumListeners (int *numlisteners);
|
||||
FMOD_RESULT F_API set3DListenerAttributes(int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
|
||||
FMOD_RESULT F_API get3DListenerAttributes(int listener, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *forward, FMOD_VECTOR *up);
|
||||
FMOD_RESULT F_API set3DRolloffCallback (FMOD_3D_ROLLOFFCALLBACK callback);
|
||||
FMOD_RESULT F_API set3DSpeakerPosition (FMOD_SPEAKER speaker, float x, float y, bool active);
|
||||
FMOD_RESULT F_API get3DSpeakerPosition (FMOD_SPEAKER speaker, float *x, float *y, bool *active);
|
||||
|
||||
FMOD_RESULT F_API setStreamBufferSize (unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype);
|
||||
FMOD_RESULT F_API getStreamBufferSize (unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype);
|
||||
|
||||
// System information functions.
|
||||
FMOD_RESULT F_API getVersion (unsigned int *version);
|
||||
FMOD_RESULT F_API getOutputHandle (void **handle);
|
||||
FMOD_RESULT F_API getChannelsPlaying (int *channels);
|
||||
FMOD_RESULT F_API getHardwareChannels (int *numhardwarechannels);
|
||||
FMOD_RESULT F_API getCPUUsage (float *dsp, float *stream, float *geometry, float *update, float *total);
|
||||
FMOD_RESULT F_API getSoundRAM (int *currentalloced, int *maxalloced, int *total);
|
||||
FMOD_RESULT F_API getNumCDROMDrives (int *numdrives);
|
||||
FMOD_RESULT F_API getCDROMDriveName (int drive, char *drivename, int drivenamelen, char *scsiname, int scsinamelen, char *devicename, int devicenamelen);
|
||||
FMOD_RESULT F_API getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype);
|
||||
FMOD_RESULT F_API getWaveData (float *wavearray, int numvalues, int channeloffset);
|
||||
|
||||
// Sound/DSP/Channel/FX creation and retrieval.
|
||||
FMOD_RESULT F_API createSound (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound);
|
||||
FMOD_RESULT F_API createStream (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound);
|
||||
FMOD_RESULT F_API createDSP (FMOD_DSP_DESCRIPTION *description, DSP **dsp);
|
||||
FMOD_RESULT F_API createDSPByType (FMOD_DSP_TYPE type, DSP **dsp);
|
||||
FMOD_RESULT F_API createChannelGroup (const char *name, ChannelGroup **channelgroup);
|
||||
FMOD_RESULT F_API createSoundGroup (const char *name, SoundGroup **soundgroup);
|
||||
FMOD_RESULT F_API createReverb (Reverb **reverb);
|
||||
|
||||
FMOD_RESULT F_API playSound (FMOD_CHANNELINDEX channelid, Sound *sound, bool paused, Channel **channel);
|
||||
FMOD_RESULT F_API playDSP (FMOD_CHANNELINDEX channelid, DSP *dsp, bool paused, Channel **channel);
|
||||
FMOD_RESULT F_API getChannel (int channelid, Channel **channel);
|
||||
FMOD_RESULT F_API getMasterChannelGroup (ChannelGroup **channelgroup);
|
||||
FMOD_RESULT F_API getMasterSoundGroup (SoundGroup **soundgroup);
|
||||
|
||||
// Reverb API
|
||||
FMOD_RESULT F_API setReverbProperties (const FMOD_REVERB_PROPERTIES *prop);
|
||||
FMOD_RESULT F_API getReverbProperties (FMOD_REVERB_PROPERTIES *prop);
|
||||
FMOD_RESULT F_API setReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop);
|
||||
FMOD_RESULT F_API getReverbAmbientProperties(FMOD_REVERB_PROPERTIES *prop);
|
||||
|
||||
// System level DSP access.
|
||||
FMOD_RESULT F_API getDSPHead (DSP **dsp);
|
||||
FMOD_RESULT F_API addDSP (DSP *dsp, DSPConnection **connection);
|
||||
FMOD_RESULT F_API lockDSP ();
|
||||
FMOD_RESULT F_API unlockDSP ();
|
||||
FMOD_RESULT F_API getDSPClock (unsigned int *hi, unsigned int *lo);
|
||||
|
||||
// Recording API.
|
||||
FMOD_RESULT F_API getRecordNumDrivers (int *numdrivers);
|
||||
FMOD_RESULT F_API getRecordDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid);
|
||||
FMOD_RESULT F_API getRecordDriverInfoW (int id, short *name, int namelen, FMOD_GUID *guid);
|
||||
FMOD_RESULT F_API getRecordDriverCaps (int id, FMOD_CAPS *caps, int *minfrequency, int *maxfrequency);
|
||||
FMOD_RESULT F_API getRecordPosition (int id, unsigned int *position);
|
||||
|
||||
FMOD_RESULT F_API recordStart (int id, Sound *sound, bool loop);
|
||||
FMOD_RESULT F_API recordStop (int id);
|
||||
FMOD_RESULT F_API isRecording (int id, bool *recording);
|
||||
|
||||
// Geometry API.
|
||||
FMOD_RESULT F_API createGeometry (int maxpolygons, int maxvertices, Geometry **geometry);
|
||||
FMOD_RESULT F_API setGeometrySettings (float maxworldsize);
|
||||
FMOD_RESULT F_API getGeometrySettings (float *maxworldsize);
|
||||
FMOD_RESULT F_API loadGeometry (const void *data, int datasize, Geometry **geometry);
|
||||
FMOD_RESULT F_API getGeometryOcclusion (const FMOD_VECTOR *listener, const FMOD_VECTOR *source, float *direct, float *reverb);
|
||||
|
||||
// Network functions.
|
||||
FMOD_RESULT F_API setNetworkProxy (const char *proxy);
|
||||
FMOD_RESULT F_API getNetworkProxy (char *proxy, int proxylen);
|
||||
FMOD_RESULT F_API setNetworkTimeout (int timeout);
|
||||
FMOD_RESULT F_API getNetworkTimeout (int *timeout);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
/*
|
||||
'Sound' API
|
||||
*/
|
||||
class Sound
|
||||
{
|
||||
private:
|
||||
|
||||
Sound(); /* Constructor made private so user cannot statically instance a Sound class.
|
||||
Appropriate Sound creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
FMOD_RESULT F_API getSystemObject (System **system);
|
||||
|
||||
// Standard sound manipulation functions.
|
||||
FMOD_RESULT F_API lock (unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
|
||||
FMOD_RESULT F_API unlock (void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
|
||||
FMOD_RESULT F_API setDefaults (float frequency, float volume, float pan, int priority);
|
||||
FMOD_RESULT F_API getDefaults (float *frequency, float *volume, float *pan, int *priority);
|
||||
FMOD_RESULT F_API setVariations (float frequencyvar, float volumevar, float panvar);
|
||||
FMOD_RESULT F_API getVariations (float *frequencyvar, float *volumevar, float *panvar);
|
||||
FMOD_RESULT F_API set3DMinMaxDistance (float min, float max);
|
||||
FMOD_RESULT F_API get3DMinMaxDistance (float *min, float *max);
|
||||
FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
|
||||
FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);
|
||||
FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);
|
||||
FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);
|
||||
FMOD_RESULT F_API setSubSound (int index, Sound *subsound);
|
||||
FMOD_RESULT F_API getSubSound (int index, Sound **subsound);
|
||||
FMOD_RESULT F_API setSubSoundSentence (int *subsoundlist, int numsubsounds);
|
||||
FMOD_RESULT F_API getName (char *name, int namelen);
|
||||
FMOD_RESULT F_API getLength (unsigned int *length, FMOD_TIMEUNIT lengthtype);
|
||||
FMOD_RESULT F_API getFormat (FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits);
|
||||
FMOD_RESULT F_API getNumSubSounds (int *numsubsounds);
|
||||
FMOD_RESULT F_API getNumTags (int *numtags, int *numtagsupdated);
|
||||
FMOD_RESULT F_API getTag (const char *name, int index, FMOD_TAG *tag);
|
||||
FMOD_RESULT F_API getOpenState (FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, bool *starving, bool *diskbusy);
|
||||
FMOD_RESULT F_API readData (void *buffer, unsigned int lenbytes, unsigned int *read);
|
||||
FMOD_RESULT F_API seekData (unsigned int pcm);
|
||||
|
||||
FMOD_RESULT F_API setSoundGroup (SoundGroup *soundgroup);
|
||||
FMOD_RESULT F_API getSoundGroup (SoundGroup **soundgroup);
|
||||
|
||||
// Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
|
||||
FMOD_RESULT F_API getNumSyncPoints (int *numsyncpoints);
|
||||
FMOD_RESULT F_API getSyncPoint (int index, FMOD_SYNCPOINT **point);
|
||||
FMOD_RESULT F_API getSyncPointInfo (FMOD_SYNCPOINT *point, char *name, int namelen, unsigned int *offset, FMOD_TIMEUNIT offsettype);
|
||||
FMOD_RESULT F_API addSyncPoint (unsigned int offset, FMOD_TIMEUNIT offsettype, const char *name, FMOD_SYNCPOINT **point);
|
||||
FMOD_RESULT F_API deleteSyncPoint (FMOD_SYNCPOINT *point);
|
||||
|
||||
// Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
|
||||
FMOD_RESULT F_API setMode (FMOD_MODE mode);
|
||||
FMOD_RESULT F_API getMode (FMOD_MODE *mode);
|
||||
FMOD_RESULT F_API setLoopCount (int loopcount);
|
||||
FMOD_RESULT F_API getLoopCount (int *loopcount);
|
||||
FMOD_RESULT F_API setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
|
||||
FMOD_RESULT F_API getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
|
||||
|
||||
// For MOD/S3M/XM/IT/MID sequenced formats only.
|
||||
FMOD_RESULT F_API getMusicNumChannels (int *numchannels);
|
||||
FMOD_RESULT F_API setMusicChannelVolume (int channel, float volume);
|
||||
FMOD_RESULT F_API getMusicChannelVolume (int channel, float *volume);
|
||||
FMOD_RESULT F_API setMusicSpeed (float speed);
|
||||
FMOD_RESULT F_API getMusicSpeed (float *speed);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
/*
|
||||
'Channel' API.
|
||||
*/
|
||||
class Channel
|
||||
{
|
||||
private:
|
||||
|
||||
Channel(); /* Constructor made private so user cannot statically instance a Channel class.
|
||||
Appropriate Channel creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API getSystemObject (System **system);
|
||||
|
||||
FMOD_RESULT F_API stop ();
|
||||
FMOD_RESULT F_API setPaused (bool paused);
|
||||
FMOD_RESULT F_API getPaused (bool *paused);
|
||||
FMOD_RESULT F_API setVolume (float volume);
|
||||
FMOD_RESULT F_API getVolume (float *volume);
|
||||
FMOD_RESULT F_API setFrequency (float frequency);
|
||||
FMOD_RESULT F_API getFrequency (float *frequency);
|
||||
FMOD_RESULT F_API setPan (float pan);
|
||||
FMOD_RESULT F_API getPan (float *pan);
|
||||
FMOD_RESULT F_API setDelay (FMOD_DELAYTYPE delaytype, unsigned int delayhi, unsigned int delaylo);
|
||||
FMOD_RESULT F_API getDelay (FMOD_DELAYTYPE delaytype, unsigned int *delayhi, unsigned int *delaylo);
|
||||
FMOD_RESULT F_API setSpeakerMix (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright);
|
||||
FMOD_RESULT F_API getSpeakerMix (float *frontleft, float *frontright, float *center, float *lfe, float *backleft, float *backright, float *sideleft, float *sideright);
|
||||
FMOD_RESULT F_API setSpeakerLevels (FMOD_SPEAKER speaker, float *levels, int numlevels);
|
||||
FMOD_RESULT F_API getSpeakerLevels (FMOD_SPEAKER speaker, float *levels, int numlevels);
|
||||
FMOD_RESULT F_API setInputChannelMix (float *levels, int numlevels);
|
||||
FMOD_RESULT F_API getInputChannelMix (float *levels, int numlevels);
|
||||
FMOD_RESULT F_API setMute (bool mute);
|
||||
FMOD_RESULT F_API getMute (bool *mute);
|
||||
FMOD_RESULT F_API setPriority (int priority);
|
||||
FMOD_RESULT F_API getPriority (int *priority);
|
||||
FMOD_RESULT F_API setPosition (unsigned int position, FMOD_TIMEUNIT postype);
|
||||
FMOD_RESULT F_API getPosition (unsigned int *position, FMOD_TIMEUNIT postype);
|
||||
FMOD_RESULT F_API setReverbProperties (const FMOD_REVERB_CHANNELPROPERTIES *prop);
|
||||
FMOD_RESULT F_API getReverbProperties (FMOD_REVERB_CHANNELPROPERTIES *prop);
|
||||
FMOD_RESULT F_API setLowPassGain (float gain);
|
||||
FMOD_RESULT F_API getLowPassGain (float *gain);
|
||||
|
||||
FMOD_RESULT F_API setChannelGroup (ChannelGroup *channelgroup);
|
||||
FMOD_RESULT F_API getChannelGroup (ChannelGroup **channelgroup);
|
||||
FMOD_RESULT F_API setCallback (FMOD_CHANNEL_CALLBACK callback);
|
||||
|
||||
// 3D functionality.
|
||||
FMOD_RESULT F_API set3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel);
|
||||
FMOD_RESULT F_API get3DAttributes (FMOD_VECTOR *pos, FMOD_VECTOR *vel);
|
||||
FMOD_RESULT F_API set3DMinMaxDistance (float mindistance, float maxdistance);
|
||||
FMOD_RESULT F_API get3DMinMaxDistance (float *mindistance, float *maxdistance);
|
||||
FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
|
||||
FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);
|
||||
FMOD_RESULT F_API set3DConeOrientation (FMOD_VECTOR *orientation);
|
||||
FMOD_RESULT F_API get3DConeOrientation (FMOD_VECTOR *orientation);
|
||||
FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);
|
||||
FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);
|
||||
FMOD_RESULT F_API set3DOcclusion (float directocclusion, float reverbocclusion);
|
||||
FMOD_RESULT F_API get3DOcclusion (float *directocclusion, float *reverbocclusion);
|
||||
FMOD_RESULT F_API set3DSpread (float angle);
|
||||
FMOD_RESULT F_API get3DSpread (float *angle);
|
||||
FMOD_RESULT F_API set3DPanLevel (float level);
|
||||
FMOD_RESULT F_API get3DPanLevel (float *level);
|
||||
FMOD_RESULT F_API set3DDopplerLevel (float level);
|
||||
FMOD_RESULT F_API get3DDopplerLevel (float *level);
|
||||
FMOD_RESULT F_API set3DDistanceFilter (bool custom, float customLevel, float centerFreq);
|
||||
FMOD_RESULT F_API get3DDistanceFilter (bool *custom, float *customLevel, float *centerFreq);
|
||||
|
||||
// DSP functionality only for channels playing sounds created with FMOD_SOFTWARE.
|
||||
FMOD_RESULT F_API getDSPHead (DSP **dsp);
|
||||
FMOD_RESULT F_API addDSP (DSP *dsp, DSPConnection **connection);
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT F_API isPlaying (bool *isplaying);
|
||||
FMOD_RESULT F_API isVirtual (bool *isvirtual);
|
||||
FMOD_RESULT F_API getAudibility (float *audibility);
|
||||
FMOD_RESULT F_API getCurrentSound (Sound **sound);
|
||||
FMOD_RESULT F_API getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype);
|
||||
FMOD_RESULT F_API getWaveData (float *wavearray, int numvalues, int channeloffset);
|
||||
FMOD_RESULT F_API getIndex (int *index);
|
||||
|
||||
// Functions also found in Sound class but here they can be set per channel.
|
||||
FMOD_RESULT F_API setMode (FMOD_MODE mode);
|
||||
FMOD_RESULT F_API getMode (FMOD_MODE *mode);
|
||||
FMOD_RESULT F_API setLoopCount (int loopcount);
|
||||
FMOD_RESULT F_API getLoopCount (int *loopcount);
|
||||
FMOD_RESULT F_API setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
|
||||
FMOD_RESULT F_API getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
/*
|
||||
'ChannelGroup' API
|
||||
*/
|
||||
class ChannelGroup
|
||||
{
|
||||
private:
|
||||
|
||||
ChannelGroup(); /* Constructor made private so user cannot statically instance a ChannelGroup class.
|
||||
Appropriate ChannelGroup creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
FMOD_RESULT F_API getSystemObject (System **system);
|
||||
|
||||
// Channelgroup scale values. (changes attributes relative to the channels, doesn't overwrite them)
|
||||
FMOD_RESULT F_API setVolume (float volume);
|
||||
FMOD_RESULT F_API getVolume (float *volume);
|
||||
FMOD_RESULT F_API setPitch (float pitch);
|
||||
FMOD_RESULT F_API getPitch (float *pitch);
|
||||
FMOD_RESULT F_API set3DOcclusion (float directocclusion, float reverbocclusion);
|
||||
FMOD_RESULT F_API get3DOcclusion (float *directocclusion, float *reverbocclusion);
|
||||
FMOD_RESULT F_API setPaused (bool paused);
|
||||
FMOD_RESULT F_API getPaused (bool *paused);
|
||||
FMOD_RESULT F_API setMute (bool mute);
|
||||
FMOD_RESULT F_API getMute (bool *mute);
|
||||
|
||||
// Channelgroup override values. (recursively overwrites whatever settings the channels had)
|
||||
FMOD_RESULT F_API stop ();
|
||||
FMOD_RESULT F_API overrideVolume (float volume);
|
||||
FMOD_RESULT F_API overrideFrequency (float frequency);
|
||||
FMOD_RESULT F_API overridePan (float pan);
|
||||
FMOD_RESULT F_API overrideReverbProperties(const FMOD_REVERB_CHANNELPROPERTIES *prop);
|
||||
FMOD_RESULT F_API override3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel);
|
||||
FMOD_RESULT F_API overrideSpeakerMix (float frontleft, float frontright, float center, float lfe, float backleft, float backright, float sideleft, float sideright);
|
||||
|
||||
// Nested channel groups.
|
||||
FMOD_RESULT F_API addGroup (ChannelGroup *group);
|
||||
FMOD_RESULT F_API getNumGroups (int *numgroups);
|
||||
FMOD_RESULT F_API getGroup (int index, ChannelGroup **group);
|
||||
FMOD_RESULT F_API getParentGroup (ChannelGroup **group);
|
||||
|
||||
// DSP functionality only for channel groups playing sounds created with FMOD_SOFTWARE.
|
||||
FMOD_RESULT F_API getDSPHead (DSP **dsp);
|
||||
FMOD_RESULT F_API addDSP (DSP *dsp, DSPConnection **connection);
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT F_API getName (char *name, int namelen);
|
||||
FMOD_RESULT F_API getNumChannels (int *numchannels);
|
||||
FMOD_RESULT F_API getChannel (int index, Channel **channel);
|
||||
FMOD_RESULT F_API getSpectrum (float *spectrumarray, int numvalues, int channeloffset, FMOD_DSP_FFT_WINDOW windowtype);
|
||||
FMOD_RESULT F_API getWaveData (float *wavearray, int numvalues, int channeloffset);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
/*
|
||||
'SoundGroup' API
|
||||
*/
|
||||
class SoundGroup
|
||||
{
|
||||
private:
|
||||
|
||||
SoundGroup(); /* Constructor made private so user cannot statically instance a SoundGroup class.
|
||||
Appropriate SoundGroup creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
FMOD_RESULT F_API getSystemObject (System **system);
|
||||
|
||||
// SoundGroup control functions.
|
||||
FMOD_RESULT F_API setMaxAudible (int maxaudible);
|
||||
FMOD_RESULT F_API getMaxAudible (int *maxaudible);
|
||||
FMOD_RESULT F_API setMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR behavior);
|
||||
FMOD_RESULT F_API getMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR *behavior);
|
||||
FMOD_RESULT F_API setMuteFadeSpeed (float speed);
|
||||
FMOD_RESULT F_API getMuteFadeSpeed (float *speed);
|
||||
FMOD_RESULT F_API setVolume (float volume);
|
||||
FMOD_RESULT F_API getVolume (float *volume);
|
||||
FMOD_RESULT F_API stop ();
|
||||
|
||||
// Information only functions.
|
||||
FMOD_RESULT F_API getName (char *name, int namelen);
|
||||
FMOD_RESULT F_API getNumSounds (int *numsounds);
|
||||
FMOD_RESULT F_API getSound (int index, Sound **sound);
|
||||
FMOD_RESULT F_API getNumPlaying (int *numplaying);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
/*
|
||||
'DSP' API
|
||||
*/
|
||||
class DSP
|
||||
{
|
||||
private:
|
||||
|
||||
DSP(); /* Constructor made private so user cannot statically instance a DSP class.
|
||||
Appropriate DSP creation or retrieval function must be used. */
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
FMOD_RESULT F_API getSystemObject (System **system);
|
||||
|
||||
// Connection / disconnection / input and output enumeration.
|
||||
FMOD_RESULT F_API addInput (DSP *target, DSPConnection **connection);
|
||||
FMOD_RESULT F_API disconnectFrom (DSP *target);
|
||||
FMOD_RESULT F_API disconnectAll (bool inputs, bool outputs);
|
||||
FMOD_RESULT F_API remove ();
|
||||
FMOD_RESULT F_API getNumInputs (int *numinputs);
|
||||
FMOD_RESULT F_API getNumOutputs (int *numoutputs);
|
||||
FMOD_RESULT F_API getInput (int index, DSP **input, DSPConnection **inputconnection);
|
||||
FMOD_RESULT F_API getOutput (int index, DSP **output, DSPConnection **outputconnection);
|
||||
|
||||
// DSP unit control.
|
||||
FMOD_RESULT F_API setActive (bool active);
|
||||
FMOD_RESULT F_API getActive (bool *active);
|
||||
FMOD_RESULT F_API setBypass (bool bypass);
|
||||
FMOD_RESULT F_API getBypass (bool *bypass);
|
||||
FMOD_RESULT F_API setSpeakerActive (FMOD_SPEAKER speaker, bool active);
|
||||
FMOD_RESULT F_API getSpeakerActive (FMOD_SPEAKER speaker, bool *active);
|
||||
FMOD_RESULT F_API reset ();
|
||||
|
||||
|
||||
// DSP parameter control.
|
||||
FMOD_RESULT F_API setParameter (int index, float value);
|
||||
FMOD_RESULT F_API getParameter (int index, float *value, char *valuestr, int valuestrlen);
|
||||
FMOD_RESULT F_API getNumParameters (int *numparams);
|
||||
FMOD_RESULT F_API getParameterInfo (int index, char *name, char *label, char *description, int descriptionlen, float *min, float *max);
|
||||
FMOD_RESULT F_API showConfigDialog (void *hwnd, bool show);
|
||||
|
||||
// DSP attributes.
|
||||
FMOD_RESULT F_API getInfo (char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);
|
||||
FMOD_RESULT F_API getType (FMOD_DSP_TYPE *type);
|
||||
FMOD_RESULT F_API setDefaults (float frequency, float volume, float pan, int priority);
|
||||
FMOD_RESULT F_API getDefaults (float *frequency, float *volume, float *pan, int *priority);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
'DSPConnection' API
|
||||
*/
|
||||
class DSPConnection
|
||||
{
|
||||
private:
|
||||
|
||||
DSPConnection(); /* Constructor made private so user cannot statically instance a DSPConnection class.
|
||||
Appropriate DSPConnection creation or retrieval function must be used. */
|
||||
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API getInput (DSP **input);
|
||||
FMOD_RESULT F_API getOutput (DSP **output);
|
||||
FMOD_RESULT F_API setMix (float volume);
|
||||
FMOD_RESULT F_API getMix (float *volume);
|
||||
FMOD_RESULT F_API setLevels (FMOD_SPEAKER speaker, float *levels, int numlevels);
|
||||
FMOD_RESULT F_API getLevels (FMOD_SPEAKER speaker, float *levels, int numlevels);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
'Geometry' API
|
||||
*/
|
||||
class Geometry
|
||||
{
|
||||
private:
|
||||
|
||||
Geometry(); /* Constructor made private so user cannot statically instance a Geometry class.
|
||||
Appropriate Geometry creation or retrieval function must be used. */
|
||||
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
|
||||
// Polygon manipulation.
|
||||
FMOD_RESULT F_API addPolygon (float directocclusion, float reverbocclusion, bool doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex);
|
||||
FMOD_RESULT F_API getNumPolygons (int *numpolygons);
|
||||
FMOD_RESULT F_API getMaxPolygons (int *maxpolygons, int *maxvertices);
|
||||
FMOD_RESULT F_API getPolygonNumVertices (int index, int *numvertices);
|
||||
FMOD_RESULT F_API setPolygonVertex (int index, int vertexindex, const FMOD_VECTOR *vertex);
|
||||
FMOD_RESULT F_API getPolygonVertex (int index, int vertexindex, FMOD_VECTOR *vertex);
|
||||
FMOD_RESULT F_API setPolygonAttributes (int index, float directocclusion, float reverbocclusion, bool doublesided);
|
||||
FMOD_RESULT F_API getPolygonAttributes (int index, float *directocclusion, float *reverbocclusion, bool *doublesided);
|
||||
|
||||
// Object manipulation.
|
||||
FMOD_RESULT F_API setActive (bool active);
|
||||
FMOD_RESULT F_API getActive (bool *active);
|
||||
FMOD_RESULT F_API setRotation (const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
|
||||
FMOD_RESULT F_API getRotation (FMOD_VECTOR *forward, FMOD_VECTOR *up);
|
||||
FMOD_RESULT F_API setPosition (const FMOD_VECTOR *position);
|
||||
FMOD_RESULT F_API getPosition (FMOD_VECTOR *position);
|
||||
FMOD_RESULT F_API setScale (const FMOD_VECTOR *scale);
|
||||
FMOD_RESULT F_API getScale (FMOD_VECTOR *scale);
|
||||
FMOD_RESULT F_API save (void *data, int *datasize);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
'Reverb' API
|
||||
*/
|
||||
class Reverb
|
||||
{
|
||||
private:
|
||||
|
||||
Reverb(); /* Constructor made private so user cannot statically instance a Reverb class.
|
||||
Appropriate Reverb creation or retrieval function must be used. */
|
||||
|
||||
public:
|
||||
|
||||
FMOD_RESULT F_API release ();
|
||||
|
||||
// Reverb manipulation.
|
||||
FMOD_RESULT F_API set3DAttributes (const FMOD_VECTOR *position, float mindistance, float maxdistance);
|
||||
FMOD_RESULT F_API get3DAttributes (FMOD_VECTOR *position, float *mindistance,float *maxdistance);
|
||||
FMOD_RESULT F_API setProperties (const FMOD_REVERB_PROPERTIES *properties);
|
||||
FMOD_RESULT F_API getProperties (FMOD_REVERB_PROPERTIES *properties);
|
||||
FMOD_RESULT F_API setActive (bool active);
|
||||
FMOD_RESULT F_API getActive (bool *active);
|
||||
|
||||
// Userdata set/get.
|
||||
FMOD_RESULT F_API setUserData (void *userdata);
|
||||
FMOD_RESULT F_API getUserData (void **userdata);
|
||||
|
||||
FMOD_RESULT F_API getMemoryInfo (unsigned int memorybits, unsigned int event_memorybits, unsigned int *memoryused, FMOD_MEMORY_USAGE_DETAILS *memoryused_details);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,159 @@
|
|||
/* ==================================================================================================== */
|
||||
/* FMOD Ex - codec development header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2011. */
|
||||
/* */
|
||||
/* Use this header if you are wanting to develop your own file format plugin to use with */
|
||||
/* FMOD's codec system. With this header you can make your own fileformat plugin that FMOD */
|
||||
/* can register and use. See the documentation and examples on how to make a working plugin. */
|
||||
/* */
|
||||
/* ==================================================================================================== */
|
||||
|
||||
#ifndef _FMOD_CODEC_H
|
||||
#define _FMOD_CODEC_H
|
||||
|
||||
typedef struct FMOD_CODEC_STATE FMOD_CODEC_STATE;
|
||||
typedef struct FMOD_CODEC_WAVEFORMAT FMOD_CODEC_WAVEFORMAT;
|
||||
|
||||
/*
|
||||
Codec callbacks
|
||||
*/
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_OPENCALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_CLOSECALLBACK) (FMOD_CODEC_STATE *codec_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_READCALLBACK) (FMOD_CODEC_STATE *codec_state, void *buffer, unsigned int sizebytes, unsigned int *bytesread);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETLENGTHCALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *length, FMOD_TIMEUNIT lengthtype);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SETPOSITIONCALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETPOSITIONCALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *position, FMOD_TIMEUNIT postype);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SOUNDCREATECALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, FMOD_SOUND *sound);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_METADATACALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_TAGTYPE tagtype, char *name, void *data, unsigned int datalen, FMOD_TAGDATATYPE datatype, int unique);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETWAVEFORMAT) (FMOD_CODEC_STATE *codec_state, int index, FMOD_CODEC_WAVEFORMAT *waveformat);
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
When creating a codec, declare one of these and provide the relevant callbacks and name for FMOD to use when it opens and reads a file.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
|
||||
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_CODEC_STATE
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_CODEC_DESCRIPTION
|
||||
{
|
||||
const char *name; /* [in] Name of the codec. */
|
||||
unsigned int version; /* [in] Plugin writer's version number. */
|
||||
int defaultasstream; /* [in] Tells FMOD to open the file as a stream when calling System::createSound, and not a static sample. Should normally be 0 (FALSE), because generally the user wants to decode the file into memory when using System::createSound. Mainly used for formats that decode for a very long time, or could use large amounts of memory when decoded. Usually sequenced formats such as mod/s3m/xm/it/midi fall into this category. It is mainly to stop users that don't know what they're doing from getting FMOD_ERR_MEMORY returned from createSound when they should have in fact called System::createStream or used FMOD_CREATESTREAM in System::createSound. */
|
||||
FMOD_TIMEUNIT timeunits; /* [in] When setposition codec is called, only these time formats will be passed to the codec. Use bitwise OR to accumulate different types. */
|
||||
FMOD_CODEC_OPENCALLBACK open; /* [in] Open callback for the codec for when FMOD tries to open a sound using this codec. */
|
||||
FMOD_CODEC_CLOSECALLBACK close; /* [in] Close callback for the codec for when FMOD tries to close a sound using this codec. */
|
||||
FMOD_CODEC_READCALLBACK read; /* [in] Read callback for the codec for when FMOD tries to read some data from the file to the destination format (specified in the open callback). */
|
||||
FMOD_CODEC_GETLENGTHCALLBACK getlength; /* [in] Callback to return the length of the song in whatever format required when Sound::getLength is called. */
|
||||
FMOD_CODEC_SETPOSITIONCALLBACK setposition; /* [in] Seek callback for the codec for when FMOD tries to seek within the file with Channel::setPosition. */
|
||||
FMOD_CODEC_GETPOSITIONCALLBACK getposition; /* [in] Tell callback for the codec for when FMOD tries to get the current position within the with Channel::getPosition. */
|
||||
FMOD_CODEC_SOUNDCREATECALLBACK soundcreate; /* [in] Sound creation callback for the codec when FMOD finishes creating the sound. (So the codec can set more parameters for the related created sound, ie loop points/mode or 3D attributes etc). */
|
||||
FMOD_CODEC_GETWAVEFORMAT getwaveformat; /* [in] Callback to tell FMOD about the waveformat of a particular subsound. This is to save memory, rather than saving 1000 FMOD_CODEC_WAVEFORMAT structures in the codec, the codec might have a more optimal way of storing this information. */
|
||||
} FMOD_CODEC_DESCRIPTION;
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Set these values marked 'in' to tell fmod what sort of sound to create.<br>
|
||||
The format, channels and frequency tell FMOD what sort of hardware buffer to create when you initialize your code. So if you wrote an MP3 codec that decoded to stereo 16bit integer PCM, you would specify FMOD_SOUND_FORMAT_PCM16, and channels would be equal to 2.<br>
|
||||
Members marked as 'out' are set by fmod. Do not modify these. Simply specify 0 for these values when declaring the structure, FMOD will fill in the values for you after creation with the correct function pointers.<br>
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
|
||||
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
<br>
|
||||
An FMOD file might be from disk, memory or network, however the file may be opened by the user.<br>
|
||||
<br>
|
||||
'numsubsounds' should be 0 if the file is a normal single sound stream or sound. Examples of this would be .WAV, .WMA, .MP3, .AIFF.<br>
|
||||
'numsubsounds' should be 1+ if the file is a container format, and does not contain wav data itself. Examples of these types would be CDDA (multiple CD tracks), FSB (contains multiple sounds), MIDI/MOD/S3M/XM/IT (contain instruments).<br>
|
||||
The arrays of format, channel, frequency, length and blockalign should point to arrays of information based on how many subsounds are in the format. If the number of subsounds is 0 then it should point to 1 of each attribute, the same as if the number of subsounds was 1. If subsounds was 100 for example, each pointer should point to an array of 100 of each attribute.<br>
|
||||
When a sound has 1 or more subsounds, you must play the individual sounds specified by first obtaining the subsound with Sound::getSubSound.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_SOUND_FORMAT
|
||||
FMOD_FILE_READCALLBACK
|
||||
FMOD_FILE_SEEKCALLBACK
|
||||
FMOD_CODEC_METADATACALLBACK
|
||||
Sound::getSubSound
|
||||
Sound::getNumSubSounds
|
||||
]
|
||||
*/
|
||||
struct FMOD_CODEC_WAVEFORMAT
|
||||
{
|
||||
char name[256]; /* [in] Name of sound.*/
|
||||
FMOD_SOUND_FORMAT format; /* [in] Format for (decompressed) codec output, ie FMOD_SOUND_FORMAT_PCM8, FMOD_SOUND_FORMAT_PCM16.*/
|
||||
int channels; /* [in] Number of channels used by codec, ie mono = 1, stereo = 2. */
|
||||
int frequency; /* [in] Default frequency in hz of the codec, ie 44100. */
|
||||
unsigned int lengthbytes; /* [in] Length in bytes of the source data. */
|
||||
unsigned int lengthpcm; /* [in] Length in decompressed, PCM samples of the file, ie length in seconds * frequency. Used for Sound::getLength and for memory allocation of static decompressed sample data. */
|
||||
int blockalign; /* [in] Blockalign in decompressed, PCM samples of the optimal decode chunk size for this format. The codec read callback will be called in multiples of this value. */
|
||||
int loopstart; /* [in] Loopstart in decompressed, PCM samples of file. */
|
||||
int loopend; /* [in] Loopend in decompressed, PCM samples of file. */
|
||||
FMOD_MODE mode; /* [in] Mode to determine whether the sound should by default load as looping, non looping, 2d or 3d. */
|
||||
unsigned int channelmask; /* [in] Microsoft speaker channel mask, as defined for WAVEFORMATEXTENSIBLE and is found in ksmedia.h. Leave at 0 to play in natural speaker order. */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Codec plugin structure that is passed into each callback.<br>
|
||||
<br>
|
||||
Set these numsubsounds and waveformat members when called in FMOD_CODEC_OPENCALLBACK to tell fmod what sort of sound to create.<br>
|
||||
<br>
|
||||
The format, channels and frequency tell FMOD what sort of hardware buffer to create when you initialize your code. So if you wrote an MP3 codec that decoded to stereo 16bit integer PCM, you would specify FMOD_SOUND_FORMAT_PCM16, and channels would be equal to 2.<br>
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
|
||||
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
<br>
|
||||
An FMOD file might be from disk, memory or internet, however the file may be opened by the user.<br>
|
||||
<br>
|
||||
'numsubsounds' should be 0 if the file is a normal single sound stream or sound. Examples of this would be .WAV, .WMA, .MP3, .AIFF.<br>
|
||||
'numsubsounds' should be 1+ if the file is a container format, and does not contain wav data itself. Examples of these types would be CDDA (multiple CD tracks), FSB (contains multiple sounds), DLS (contain instruments).<br>
|
||||
The arrays of format, channel, frequency, length and blockalign should point to arrays of information based on how many subsounds are in the format. If the number of subsounds is 0 then it should point to 1 of each attribute, the same as if the number of subsounds was 1. If subsounds was 100 for example, each pointer should point to an array of 100 of each attribute.<br>
|
||||
When a sound has 1 or more subsounds, you must play the individual sounds specified by first obtaining the subsound with Sound::getSubSound.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_SOUND_FORMAT
|
||||
FMOD_FILE_READCALLBACK
|
||||
FMOD_FILE_SEEKCALLBACK
|
||||
FMOD_CODEC_METADATACALLBACK
|
||||
Sound::getSubSound
|
||||
Sound::getNumSubSounds
|
||||
]
|
||||
*/
|
||||
struct FMOD_CODEC_STATE
|
||||
{
|
||||
int numsubsounds; /* [in] Number of 'subsounds' in this sound. Anything other than 0 makes it a 'container' format (ie CDDA/DLS/FSB etc which contain 1 or more su bsounds). For most normal, single sound codec such as WAV/AIFF/MP3, this should be 0 as they are not a container for subsounds, they are the sound by itself. */
|
||||
FMOD_CODEC_WAVEFORMAT *waveformat; /* [in] Pointer to an array of format structures containing information about each sample. Can be 0 or NULL if FMOD_CODEC_GETWAVEFORMAT callback is preferred. The number of entries here must equal the number of subsounds defined in the subsound parameter. If numsubsounds = 0 then there should be 1 instance of this structure. */
|
||||
void *plugindata; /* [in] Plugin writer created data the codec author wants to attach to this object. */
|
||||
|
||||
void *filehandle; /* [out] This will return an internal FMOD file handle to use with the callbacks provided. */
|
||||
unsigned int filesize; /* [out] This will contain the size of the file in bytes. */
|
||||
FMOD_FILE_READCALLBACK fileread; /* [out] This will return a callable FMOD file function to use from codec. */
|
||||
FMOD_FILE_SEEKCALLBACK fileseek; /* [out] This will return a callable FMOD file function to use from codec. */
|
||||
FMOD_CODEC_METADATACALLBACK metadata; /* [out] This will return a callable FMOD metadata function to use from codec. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,752 @@
|
|||
/* ========================================================================================== */
|
||||
/* FMOD Ex - DSP header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2011. */
|
||||
/* */
|
||||
/* Use this header if you are interested in delving deeper into the FMOD software mixing / */
|
||||
/* DSP engine. In this header you can find parameter structures for FMOD system reigstered */
|
||||
/* DSP effects and generators. */
|
||||
/* Also use this header if you are wanting to develop your own DSP plugin to use with FMOD's */
|
||||
/* dsp system. With this header you can make your own DSP plugin that FMOD can */
|
||||
/* register and use. See the documentation and examples on how to make a working plugin. */
|
||||
/* */
|
||||
/* ========================================================================================== */
|
||||
|
||||
#ifndef _FMOD_DSP_H
|
||||
#define _FMOD_DSP_H
|
||||
|
||||
typedef struct FMOD_DSP_STATE FMOD_DSP_STATE;
|
||||
|
||||
/*
|
||||
DSP callbacks
|
||||
*/
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_CREATECALLBACK) (FMOD_DSP_STATE *dsp_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_RELEASECALLBACK) (FMOD_DSP_STATE *dsp_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_RESETCALLBACK) (FMOD_DSP_STATE *dsp_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_READCALLBACK) (FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPOSITIONCALLBACK)(FMOD_DSP_STATE *dsp_state, unsigned int pos);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPARAMCALLBACK) (FMOD_DSP_STATE *dsp_state, int index, float value);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_GETPARAMCALLBACK) (FMOD_DSP_STATE *dsp_state, int index, float *value, char *valuestr);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_DIALOGCALLBACK) (FMOD_DSP_STATE *dsp_state, void *hwnd, int show);
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
These definitions can be used for creating FMOD defined special effects or DSP units.
|
||||
|
||||
[REMARKS]
|
||||
To get them to be active, first create the unit, then add it somewhere into the DSP network, either at the front of the network near the soundcard unit to affect the global output (by using System::getDSPHead), or on a single channel (using Channel::getDSPHead).
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
System::createDSPByType
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_TYPE_UNKNOWN, /* This unit was created via a non FMOD plugin so has an unknown purpose. */
|
||||
FMOD_DSP_TYPE_MIXER, /* This unit does nothing but take inputs and mix them together then feed the result to the soundcard unit. */
|
||||
FMOD_DSP_TYPE_OSCILLATOR, /* This unit generates sine/square/saw/triangle or noise tones. */
|
||||
FMOD_DSP_TYPE_LOWPASS, /* This unit filters sound using a high quality, resonant lowpass filter algorithm but consumes more CPU time. */
|
||||
FMOD_DSP_TYPE_ITLOWPASS, /* This unit filters sound using a resonant lowpass filter algorithm that is used in Impulse Tracker, but with limited cutoff range (0 to 8060hz). */
|
||||
FMOD_DSP_TYPE_HIGHPASS, /* This unit filters sound using a resonant highpass filter algorithm. */
|
||||
FMOD_DSP_TYPE_ECHO, /* This unit produces an echo on the sound and fades out at the desired rate. */
|
||||
FMOD_DSP_TYPE_FLANGE, /* This unit produces a flange effect on the sound. */
|
||||
FMOD_DSP_TYPE_DISTORTION, /* This unit distorts the sound. */
|
||||
FMOD_DSP_TYPE_NORMALIZE, /* This unit normalizes or amplifies the sound to a certain level. */
|
||||
FMOD_DSP_TYPE_PARAMEQ, /* This unit attenuates or amplifies a selected frequency range. */
|
||||
FMOD_DSP_TYPE_PITCHSHIFT, /* This unit bends the pitch of a sound without changing the speed of playback. */
|
||||
FMOD_DSP_TYPE_CHORUS, /* This unit produces a chorus effect on the sound. */
|
||||
FMOD_DSP_TYPE_VSTPLUGIN, /* This unit allows the use of Steinberg VST plugins */
|
||||
FMOD_DSP_TYPE_WINAMPPLUGIN, /* This unit allows the use of Nullsoft Winamp plugins */
|
||||
FMOD_DSP_TYPE_ITECHO, /* This unit produces an echo on the sound and fades out at the desired rate as is used in Impulse Tracker. */
|
||||
FMOD_DSP_TYPE_COMPRESSOR, /* This unit implements dynamic compression (linked multichannel, wideband) */
|
||||
FMOD_DSP_TYPE_SFXREVERB, /* This unit implements SFX reverb */
|
||||
FMOD_DSP_TYPE_LOWPASS_SIMPLE, /* This unit filters sound using a simple lowpass with no resonance, but has flexible cutoff and is fast. */
|
||||
FMOD_DSP_TYPE_DELAY, /* This unit produces different delays on individual channels of the sound. */
|
||||
FMOD_DSP_TYPE_TREMOLO, /* This unit produces a tremolo / chopper effect on the sound. */
|
||||
FMOD_DSP_TYPE_LADSPAPLUGIN, /* This unit allows the use of LADSPA standard plugins. */
|
||||
FMOD_DSP_TYPE_HIGHPASS_SIMPLE, /* This unit filters sound using a simple highpass with no resonance, but has flexible cutoff and is fast. */
|
||||
FMOD_DSP_TYPE_FORCEINT = 65536 /* Makes sure this enum is signed 32bit. */
|
||||
} FMOD_DSP_TYPE;
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Structure to define a parameter for a DSP unit.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
|
||||
<br>
|
||||
The step parameter tells the gui or application that the parameter has a certain granularity.<br>
|
||||
For example in the example of cutoff frequency with a range from 100.0 to 22050.0 you might only want the selection to be in 10hz increments. For this you would simply use 10.0 as the step value.<br>
|
||||
For a boolean, you can use min = 0.0, max = 1.0, step = 1.0. This way the only possible values are 0.0 and 1.0.<br>
|
||||
Some applications may detect min = 0.0, max = 1.0, step = 1.0 and replace a graphical slider bar with a checkbox instead.<br>
|
||||
A step value of 1.0 would simulate integer values only.<br>
|
||||
A step value of 0.0 would mean the full floating point range is accessable.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
System::createDSP
|
||||
DSP::setParameter
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_DSP_PARAMETERDESC
|
||||
{
|
||||
float min; /* [w] Minimum value of the parameter (ie 100.0). */
|
||||
float max; /* [w] Maximum value of the parameter (ie 22050.0). */
|
||||
float defaultval; /* [w] Default value of parameter. */
|
||||
char name[16]; /* [w] Name of the parameter to be displayed (ie "Cutoff frequency"). */
|
||||
char label[16]; /* [w] Short string to be put next to value to denote the unit type (ie "hz"). */
|
||||
const char *description; /* [w] Description of the parameter to be displayed as a help item / tooltip for this parameter. */
|
||||
} FMOD_DSP_PARAMETERDESC;
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
When creating a DSP unit, declare one of these and provide the relevant callbacks and name for FMOD to use when it creates and uses a DSP unit of this type.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
|
||||
<br>
|
||||
There are 2 different ways to change a parameter in this architecture.<br>
|
||||
One is to use DSP::setParameter / DSP::getParameter. This is platform independant and is dynamic, so new unknown plugins can have their parameters enumerated and used.<br>
|
||||
The other is to use DSP::showConfigDialog. This is platform specific and requires a GUI, and will display a dialog box to configure the plugin.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
System::createDSP
|
||||
FMOD_DSP_STATE
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_DSP_DESCRIPTION
|
||||
{
|
||||
char name[32]; /* [w] Name of the unit to be displayed in the network. */
|
||||
unsigned int version; /* [w] Plugin writer's version number. */
|
||||
int channels; /* [w] Number of channels. Use 0 to process whatever number of channels is currently in the network. >0 would be mostly used if the unit is a unit that only generates sound. */
|
||||
FMOD_DSP_CREATECALLBACK create; /* [w] Create callback. This is called when DSP unit is created. Can be null. */
|
||||
FMOD_DSP_RELEASECALLBACK release; /* [w] Release callback. This is called just before the unit is freed so the user can do any cleanup needed for the unit. Can be null. */
|
||||
FMOD_DSP_RESETCALLBACK reset; /* [w] Reset callback. This is called by the user to reset any history buffers that may need resetting for a filter, when it is to be used or re-used for the first time to its initial clean state. Use to avoid clicks or artifacts. */
|
||||
FMOD_DSP_READCALLBACK read; /* [w] Read callback. Processing is done here. Can be null. */
|
||||
FMOD_DSP_SETPOSITIONCALLBACK setposition; /* [w] Set position callback. This is called if the unit wants to update its position info but not process data, or reset a cursor position internally if it is reading data from a certain source. Can be null. */
|
||||
|
||||
int numparameters; /* [w] Number of parameters used in this filter. The user finds this with DSP::getNumParameters */
|
||||
FMOD_DSP_PARAMETERDESC *paramdesc; /* [w] Variable number of parameter structures. */
|
||||
FMOD_DSP_SETPARAMCALLBACK setparameter; /* [w] This is called when the user calls DSP::setParameter. Can be null. */
|
||||
FMOD_DSP_GETPARAMCALLBACK getparameter; /* [w] This is called when the user calls DSP::getParameter. Can be null. */
|
||||
FMOD_DSP_DIALOGCALLBACK config; /* [w] This is called when the user calls DSP::showConfigDialog. Can be used to display a dialog to configure the filter. Can be null. */
|
||||
int configwidth; /* [w] Width of config dialog graphic if there is one. 0 otherwise.*/
|
||||
int configheight; /* [w] Height of config dialog graphic if there is one. 0 otherwise.*/
|
||||
void *userdata; /* [w] Optional. Specify 0 to ignore. This is user data to be attached to the DSP unit during creation. Access via DSP::getUserData. */
|
||||
} FMOD_DSP_DESCRIPTION;
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
DSP plugin structure that is passed into each callback.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_DSP_DESCRIPTION
|
||||
]
|
||||
*/
|
||||
struct FMOD_DSP_STATE
|
||||
{
|
||||
FMOD_DSP *instance; /* [r] Handle to the DSP hand the user created. Not to be modified. C++ users cast to FMOD::DSP to use. */
|
||||
void *plugindata; /* [w] Plugin writer created data the output author wants to attach to this object. */
|
||||
unsigned short speakermask; /* [w] Specifies which speakers the DSP effect is active on */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
===================================================================================================
|
||||
|
||||
FMOD built in effect parameters.
|
||||
Use DSP::setParameter with these enums for the 'index' parameter.
|
||||
|
||||
===================================================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_OSCILLATOR filter.
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_OSCILLATOR_TYPE, /* Waveform type. 0 = sine. 1 = square. 2 = sawup. 3 = sawdown. 4 = triangle. 5 = noise. */
|
||||
FMOD_DSP_OSCILLATOR_RATE /* Frequency of the sinewave in hz. 1.0 to 22000.0. Default = 220.0. */
|
||||
} FMOD_DSP_OSCILLATOR;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_LOWPASS filter.
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_LOWPASS_CUTOFF, /* Lowpass cutoff frequency in hz. 10.0 to 22000.0. Default = 5000.0. */
|
||||
FMOD_DSP_LOWPASS_RESONANCE /* Lowpass resonance Q value. 1.0 to 10.0. Default = 1.0. */
|
||||
} FMOD_DSP_LOWPASS;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_ITLOWPASS filter.<br>
|
||||
This is different to the default FMOD_DSP_TYPE_ITLOWPASS filter in that it uses a different quality algorithm and is
|
||||
the filter used to produce the correct sounding playback in .IT files.<br>
|
||||
FMOD Ex's .IT playback uses this filter.<br>
|
||||
|
||||
[REMARKS]
|
||||
Note! This filter actually has a limited cutoff frequency below the specified maximum, due to its limited design,
|
||||
so for a more open range filter use FMOD_DSP_LOWPASS or if you don't mind not having resonance,
|
||||
FMOD_DSP_LOWPASS_SIMPLE.<br>
|
||||
The effective maximum cutoff is about 8060hz.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_ITLOWPASS_CUTOFF, /* Lowpass cutoff frequency in hz. 1.0 to 22000.0. Default = 5000.0/ */
|
||||
FMOD_DSP_ITLOWPASS_RESONANCE /* Lowpass resonance Q value. 0.0 to 127.0. Default = 1.0. */
|
||||
} FMOD_DSP_ITLOWPASS;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_HIGHPASS filter.
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_HIGHPASS_CUTOFF, /* Highpass cutoff frequency in hz. 1.0 to output 22000.0. Default = 5000.0. */
|
||||
FMOD_DSP_HIGHPASS_RESONANCE /* Highpass resonance Q value. 1.0 to 10.0. Default = 1.0. */
|
||||
} FMOD_DSP_HIGHPASS;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_ECHO filter.
|
||||
|
||||
[REMARKS]
|
||||
Note. Every time the delay is changed, the plugin re-allocates the echo buffer. This means the echo will dissapear at that time while it refills its new buffer.<br>
|
||||
Larger echo delays result in larger amounts of memory allocated.<br>
|
||||
<br>
|
||||
'<i>maxchannels</i>' also dictates the amount of memory allocated. By default, the maxchannels value is 0. If FMOD is set to stereo, the echo unit will allocate enough memory for 2 channels. If it is 5.1, it will allocate enough memory for a 6 channel echo, etc.<br>
|
||||
If the echo effect is only ever applied to the global mix (ie it was added with System::addDSP), then 0 is the value to set as it will be enough to handle all speaker modes.<br>
|
||||
When the echo is added to a channel (ie Channel::addDSP) then the channel count that comes in could be anything from 1 to 8 possibly. It is only in this case where you might want to increase the channel count above the output's channel count.<br>
|
||||
If a channel echo is set to a lower number than the sound's channel count that is coming in, it will not echo the sound.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_ECHO_DELAY, /* Echo delay in ms. 10 to 5000. Default = 500. */
|
||||
FMOD_DSP_ECHO_DECAYRATIO, /* Echo decay per delay. 0 to 1. 1.0 = No decay, 0.0 = total decay (ie simple 1 line delay). Default = 0.5. */
|
||||
FMOD_DSP_ECHO_MAXCHANNELS, /* Maximum channels supported. 0 to 16. 0 = same as fmod's default output polyphony, 1 = mono, 2 = stereo etc. See remarks for more. Default = 0. It is suggested to leave at 0! */
|
||||
FMOD_DSP_ECHO_DRYMIX, /* Volume of original signal to pass to output. 0.0 to 1.0. Default = 1.0. */
|
||||
FMOD_DSP_ECHO_WETMIX /* Volume of echo signal to pass to output. 0.0 to 1.0. Default = 1.0. */
|
||||
} FMOD_DSP_ECHO;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_DELAY filter.
|
||||
|
||||
[REMARKS]
|
||||
Note. Every time MaxDelay is changed, the plugin re-allocates the delay buffer. This means the delay will dissapear at that time while it refills its new buffer.<br>
|
||||
A larger MaxDelay results in larger amounts of memory allocated.<br>
|
||||
Channel delays above MaxDelay will be clipped to MaxDelay and the delay buffer will not be resized.<br>
|
||||
<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_DELAY_CH0, /* Channel #0 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH1, /* Channel #1 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH2, /* Channel #2 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH3, /* Channel #3 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH4, /* Channel #4 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH5, /* Channel #5 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH6, /* Channel #6 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH7, /* Channel #7 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH8, /* Channel #8 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH9, /* Channel #9 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH10, /* Channel #10 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH11, /* Channel #11 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH12, /* Channel #12 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH13, /* Channel #13 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH14, /* Channel #14 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_CH15, /* Channel #15 Delay in ms. 0 to 10000. Default = 0. */
|
||||
FMOD_DSP_DELAY_MAXDELAY /* Maximum delay in ms. 0 to 10000. Default = 10. */
|
||||
} FMOD_DSP_DELAY;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_FLANGE filter.
|
||||
|
||||
[REMARKS]
|
||||
Flange is an effect where the signal is played twice at the same time, and one copy slides back and forth creating a whooshing or flanging effect.<br>
|
||||
As there are 2 copies of the same signal, by default each signal is given 50% mix, so that the total is not louder than the original unaffected signal.<br>
|
||||
<br>
|
||||
Flange depth is a percentage of a 10ms shift from the original signal. Anything above 10ms is not considered flange because to the ear it begins to 'echo' so 10ms is the highest value possible.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_FLANGE_DRYMIX, /* Volume of original signal to pass to output. 0.0 to 1.0. Default = 0.45. */
|
||||
FMOD_DSP_FLANGE_WETMIX, /* Volume of flange signal to pass to output. 0.0 to 1.0. Default = 0.55. */
|
||||
FMOD_DSP_FLANGE_DEPTH, /* Flange depth. 0.01 to 1.0. Default = 1.0. */
|
||||
FMOD_DSP_FLANGE_RATE /* Flange speed in hz. 0.0 to 20.0. Default = 0.1. */
|
||||
} FMOD_DSP_FLANGE;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_TREMOLO filter.
|
||||
|
||||
[REMARKS]
|
||||
The tremolo effect varies the amplitude of a sound. Depending on the settings, this unit can produce a tremolo, chopper or auto-pan effect.<br>
|
||||
<br>
|
||||
The shape of the LFO (low freq. oscillator) can morphed between sine, triangle and sawtooth waves using the FMOD_DSP_TREMOLO_SHAPE and FMOD_DSP_TREMOLO_SKEW parameters.<br>
|
||||
FMOD_DSP_TREMOLO_DUTY and FMOD_DSP_TREMOLO_SQUARE are useful for a chopper-type effect where the first controls the on-time duration and second controls the flatness of the envelope.<br>
|
||||
FMOD_DSP_TREMOLO_SPREAD varies the LFO phase between channels to get an auto-pan effect. This works best with a sine shape LFO.<br>
|
||||
The LFO can be synchronized using the FMOD_DSP_TREMOLO_PHASE parameter which sets its instantaneous phase.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_TREMOLO_FREQUENCY, /* LFO frequency in Hz. 0.1 to 20. Default = 4. */
|
||||
FMOD_DSP_TREMOLO_DEPTH, /* Tremolo depth. 0 to 1. Default = 0. */
|
||||
FMOD_DSP_TREMOLO_SHAPE, /* LFO shape morph between triangle and sine. 0 to 1. Default = 0. */
|
||||
FMOD_DSP_TREMOLO_SKEW, /* Time-skewing of LFO cycle. -1 to 1. Default = 0. */
|
||||
FMOD_DSP_TREMOLO_DUTY, /* LFO on-time. 0 to 1. Default = 0.5. */
|
||||
FMOD_DSP_TREMOLO_SQUARE, /* Flatness of the LFO shape. 0 to 1. Default = 0. */
|
||||
FMOD_DSP_TREMOLO_PHASE, /* Instantaneous LFO phase. 0 to 1. Default = 0. */
|
||||
FMOD_DSP_TREMOLO_SPREAD /* Rotation / auto-pan effect. -1 to 1. Default = 0. */
|
||||
} FMOD_DSP_TREMOLO;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_DISTORTION filter.
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_DISTORTION_LEVEL /* Distortion value. 0.0 to 1.0. Default = 0.5. */
|
||||
} FMOD_DSP_DISTORTION;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_NORMALIZE filter.
|
||||
|
||||
[REMARKS]
|
||||
Normalize amplifies the sound based on the maximum peaks within the signal.<br>
|
||||
For example if the maximum peaks in the signal were 50% of the bandwidth, it would scale the whole sound by 2.<br>
|
||||
The lower threshold value makes the normalizer ignores peaks below a certain point, to avoid over-amplification if a loud signal suddenly came in, and also to avoid amplifying to maximum things like background hiss.<br>
|
||||
<br>
|
||||
Because FMOD is a realtime audio processor, it doesn't have the luxury of knowing the peak for the whole sound (ie it can't see into the future), so it has to process data as it comes in.<br>
|
||||
To avoid very sudden changes in volume level based on small samples of new data, fmod fades towards the desired amplification which makes for smooth gain control. The fadetime parameter can control this.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_NORMALIZE_FADETIME, /* Time to ramp the silence to full in ms. 0.0 to 20000.0. Default = 5000.0. */
|
||||
FMOD_DSP_NORMALIZE_THRESHHOLD, /* Lower volume range threshold to ignore. 0.0 to 1.0. Default = 0.1. Raise higher to stop amplification of very quiet signals. */
|
||||
FMOD_DSP_NORMALIZE_MAXAMP /* Maximum amplification allowed. 1.0 to 100000.0. Default = 20.0. 1.0 = no amplifaction, higher values allow more boost. */
|
||||
} FMOD_DSP_NORMALIZE;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_PARAMEQ filter.
|
||||
|
||||
[REMARKS]
|
||||
Parametric EQ is a bandpass filter that attenuates or amplifies a selected frequency and its neighbouring frequencies.<br>
|
||||
<br>
|
||||
To create a multi-band EQ create multiple FMOD_DSP_TYPE_PARAMEQ units and set each unit to different frequencies, for example 1000hz, 2000hz, 4000hz, 8000hz, 16000hz with a range of 1 octave each.<br>
|
||||
<br>
|
||||
When a frequency has its gain set to 1.0, the sound will be unaffected and represents the original signal exactly.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_PARAMEQ_CENTER, /* Frequency center. 20.0 to 22000.0. Default = 8000.0. */
|
||||
FMOD_DSP_PARAMEQ_BANDWIDTH, /* Octave range around the center frequency to filter. 0.2 to 5.0. Default = 1.0. */
|
||||
FMOD_DSP_PARAMEQ_GAIN /* Frequency Gain. 0.05 to 3.0. Default = 1.0. */
|
||||
} FMOD_DSP_PARAMEQ;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_PITCHSHIFT filter.
|
||||
|
||||
[REMARKS]
|
||||
This pitch shifting unit can be used to change the pitch of a sound without speeding it up or slowing it down.<br>
|
||||
It can also be used for time stretching or scaling, for example if the pitch was doubled, and the frequency of the sound was halved, the pitch of the sound would sound correct but it would be twice as slow.<br>
|
||||
<br>
|
||||
<b>Warning!</b> This filter is very computationally expensive! Similar to a vocoder, it requires several overlapping FFT and IFFT's to produce smooth output, and can require around 440mhz for 1 stereo 48khz signal using the default settings.<br>
|
||||
Reducing the signal to mono will half the cpu usage.<br>
|
||||
Reducing this will lower audio quality, but what settings to use are largely dependant on the sound being played. A noisy polyphonic signal will need higher fft size compared to a speaking voice for example.<br>
|
||||
<br>
|
||||
This pitch shifter is based on the pitch shifter code at http://www.dspdimension.com, written by Stephan M. Bernsee.<br>
|
||||
The original code is COPYRIGHT 1999-2003 Stephan M. Bernsee <smb@dspdimension.com>.<br>
|
||||
<br>
|
||||
'<i>maxchannels</i>' dictates the amount of memory allocated. By default, the maxchannels value is 0. If FMOD is set to stereo, the pitch shift unit will allocate enough memory for 2 channels. If it is 5.1, it will allocate enough memory for a 6 channel pitch shift, etc.<br>
|
||||
If the pitch shift effect is only ever applied to the global mix (ie it was added with System::addDSP), then 0 is the value to set as it will be enough to handle all speaker modes.<br>
|
||||
When the pitch shift is added to a channel (ie Channel::addDSP) then the channel count that comes in could be anything from 1 to 8 possibly. It is only in this case where you might want to increase the channel count above the output's channel count.<br>
|
||||
If a channel pitch shift is set to a lower number than the sound's channel count that is coming in, it will not pitch shift the sound.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_PITCHSHIFT_PITCH, /* Pitch value. 0.5 to 2.0. Default = 1.0. 0.5 = one octave down, 2.0 = one octave up. 1.0 does not change the pitch. */
|
||||
FMOD_DSP_PITCHSHIFT_FFTSIZE, /* FFT window size. 256, 512, 1024, 2048, 4096. Default = 1024. Increase this to reduce 'smearing'. This effect is a warbling sound similar to when an mp3 is encoded at very low bitrates. */
|
||||
FMOD_DSP_PITCHSHIFT_OVERLAP, /* Removed. Do not use. FMOD now uses 4 overlaps and cannot be changed. */
|
||||
FMOD_DSP_PITCHSHIFT_MAXCHANNELS /* Maximum channels supported. 0 to 16. 0 = same as fmod's default output polyphony, 1 = mono, 2 = stereo etc. See remarks for more. Default = 0. It is suggested to leave at 0! */
|
||||
} FMOD_DSP_PITCHSHIFT;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_CHORUS filter.
|
||||
|
||||
[REMARKS]
|
||||
Chrous is an effect where the sound is more 'spacious' due to 1 to 3 versions of the sound being played along side the original signal but with the pitch of each copy modulating on a sine wave.<br>
|
||||
This is a highly configurable chorus unit. It supports 3 taps, small and large delay times and also feedback.<br>
|
||||
This unit also could be used to do a simple echo, or a flange effect.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_CHORUS_DRYMIX, /* Volume of original signal to pass to output. 0.0 to 1.0. Default = 0.5. */
|
||||
FMOD_DSP_CHORUS_WETMIX1, /* Volume of 1st chorus tap. 0.0 to 1.0. Default = 0.5. */
|
||||
FMOD_DSP_CHORUS_WETMIX2, /* Volume of 2nd chorus tap. This tap is 90 degrees out of phase of the first tap. 0.0 to 1.0. Default = 0.5. */
|
||||
FMOD_DSP_CHORUS_WETMIX3, /* Volume of 3rd chorus tap. This tap is 90 degrees out of phase of the second tap. 0.0 to 1.0. Default = 0.5. */
|
||||
FMOD_DSP_CHORUS_DELAY, /* Chorus delay in ms. 0.1 to 100.0. Default = 40.0 ms. */
|
||||
FMOD_DSP_CHORUS_RATE, /* Chorus modulation rate in hz. 0.0 to 20.0. Default = 0.8 hz. */
|
||||
FMOD_DSP_CHORUS_DEPTH, /* Chorus modulation depth. 0.0 to 1.0. Default = 0.03. */
|
||||
FMOD_DSP_CHORUS_FEEDBACK /* Chorus feedback. Controls how much of the wet signal gets fed back into the chorus buffer. 0.0 to 1.0. Default = 0.0. */
|
||||
} FMOD_DSP_CHORUS;
|
||||
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_ITECHO filter.<br>
|
||||
This is effectively a software based echo filter that emulates the DirectX DMO echo effect. Impulse tracker files can support this, and FMOD will produce the effect on ANY platform, not just those that support DirectX effects!<br>
|
||||
|
||||
[REMARKS]
|
||||
Note. Every time the delay is changed, the plugin re-allocates the echo buffer. This means the echo will dissapear at that time while it refills its new buffer.<br>
|
||||
Larger echo delays result in larger amounts of memory allocated.<br>
|
||||
<br>
|
||||
As this is a stereo filter made mainly for IT playback, it is targeted for stereo signals.<br>
|
||||
With mono signals only the FMOD_DSP_ITECHO_LEFTDELAY is used.<br>
|
||||
For multichannel signals (>2) there will be no echo on those channels.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::SetParameter
|
||||
DSP::GetParameter
|
||||
FMOD_DSP_TYPE
|
||||
System::addDSP
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_ITECHO_WETDRYMIX, /* Ratio of wet (processed) signal to dry (unprocessed) signal. Must be in the range from 0.0 through 100.0 (all wet). The default value is 50. */
|
||||
FMOD_DSP_ITECHO_FEEDBACK, /* Percentage of output fed back into input, in the range from 0.0 through 100.0. The default value is 50. */
|
||||
FMOD_DSP_ITECHO_LEFTDELAY, /* Delay for left channel, in milliseconds, in the range from 1.0 through 2000.0. The default value is 500 ms. */
|
||||
FMOD_DSP_ITECHO_RIGHTDELAY, /* Delay for right channel, in milliseconds, in the range from 1.0 through 2000.0. The default value is 500 ms. */
|
||||
FMOD_DSP_ITECHO_PANDELAY /* Value that specifies whether to swap left and right delays with each successive echo. The default value is zero, meaning no swap. Possible values are defined as 0.0 (equivalent to FALSE) and 1.0 (equivalent to TRUE). CURRENTLY NOT SUPPORTED. */
|
||||
} FMOD_DSP_ITECHO;
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_COMPRESSOR unit.
|
||||
This is a simple linked multichannel software limiter that is uniform across the whole spectrum.<br>
|
||||
|
||||
[REMARKS]
|
||||
The limiter is not guaranteed to catch every peak above the threshold level,
|
||||
because it cannot apply gain reduction instantaneously - the time delay is
|
||||
determined by the attack time. However setting the attack time too short will
|
||||
distort the sound, so it is a compromise. High level peaks can be avoided by
|
||||
using a short attack time - but not too short, and setting the threshold a few
|
||||
decibels below the critical level.
|
||||
<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::SetParameter
|
||||
DSP::GetParameter
|
||||
FMOD_DSP_TYPE
|
||||
System::addDSP
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_COMPRESSOR_THRESHOLD, /* Threshold level (dB) in the range from -60 through 0. The default value is 0. */
|
||||
FMOD_DSP_COMPRESSOR_ATTACK, /* Gain reduction attack time (milliseconds), in the range from 10 through 200. The default value is 50. */
|
||||
FMOD_DSP_COMPRESSOR_RELEASE, /* Gain reduction release time (milliseconds), in the range from 20 through 1000. The default value is 50. */
|
||||
FMOD_DSP_COMPRESSOR_GAINMAKEUP /* Make-up gain (dB) applied after limiting, in the range from 0 through 30. The default value is 0. */
|
||||
} FMOD_DSP_COMPRESSOR;
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_SFXREVERB unit.<br>
|
||||
|
||||
[REMARKS]
|
||||
This is a high quality I3DL2 based reverb.<br>
|
||||
On top of the I3DL2 property set, "Dry Level" is also included to allow the dry mix to be changed.<br>
|
||||
<br>
|
||||
These properties can be set with presets in FMOD_REVERB_PRESETS.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::SetParameter
|
||||
DSP::GetParameter
|
||||
FMOD_DSP_TYPE
|
||||
System::addDSP
|
||||
FMOD_REVERB_PRESETS
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_SFXREVERB_DRYLEVEL, /* Dry Level : Mix level of dry signal in output in mB. Ranges from -10000.0 to 0.0. Default is 0. */
|
||||
FMOD_DSP_SFXREVERB_ROOM, /* Room : Room effect level at low frequencies in mB. Ranges from -10000.0 to 0.0. Default is -10000.0. */
|
||||
FMOD_DSP_SFXREVERB_ROOMHF, /* Room HF : Room effect high-frequency level re. low frequency level in mB. Ranges from -10000.0 to 0.0. Default is 0.0. */
|
||||
FMOD_DSP_SFXREVERB_DECAYTIME, /* Decay Time : Reverberation decay time at low-frequencies in seconds. Ranges from 0.1 to 20.0. Default is 1.0. */
|
||||
FMOD_DSP_SFXREVERB_DECAYHFRATIO, /* Decay HF Ratio : High-frequency to low-frequency decay time ratio. Ranges from 0.1 to 2.0. Default is 0.5. */
|
||||
FMOD_DSP_SFXREVERB_REFLECTIONSLEVEL, /* Reflections : Early reflections level relative to room effect in mB. Ranges from -10000.0 to 1000.0. Default is -10000.0. */
|
||||
FMOD_DSP_SFXREVERB_REFLECTIONSDELAY, /* Reflect Delay : Delay time of first reflection in seconds. Ranges from 0.0 to 0.3. Default is 0.02. */
|
||||
FMOD_DSP_SFXREVERB_REVERBLEVEL, /* Reverb : Late reverberation level relative to room effect in mB. Ranges from -10000.0 to 2000.0. Default is 0.0. */
|
||||
FMOD_DSP_SFXREVERB_REVERBDELAY, /* Reverb Delay : Late reverberation delay time relative to first reflection in seconds. Ranges from 0.0 to 0.1. Default is 0.04. */
|
||||
FMOD_DSP_SFXREVERB_DIFFUSION, /* Diffusion : Reverberation diffusion (echo density) in percent. Ranges from 0.0 to 100.0. Default is 100.0. */
|
||||
FMOD_DSP_SFXREVERB_DENSITY, /* Density : Reverberation density (modal density) in percent. Ranges from 0.0 to 100.0. Default is 100.0. */
|
||||
FMOD_DSP_SFXREVERB_HFREFERENCE, /* HF Reference : Reference high frequency in Hz. Ranges from 20.0 to 20000.0. Default is 5000.0. */
|
||||
FMOD_DSP_SFXREVERB_ROOMLF, /* Room LF : Room effect low-frequency level in mB. Ranges from -10000.0 to 0.0. Default is 0.0. */
|
||||
FMOD_DSP_SFXREVERB_LFREFERENCE /* LF Reference : Reference low-frequency in Hz. Ranges from 20.0 to 1000.0. Default is 250.0. */
|
||||
} FMOD_DSP_SFXREVERB;
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_LOWPASS_SIMPLE filter.<br>
|
||||
This is a very simple low pass filter, based on two single-pole RC time-constant modules.
|
||||
The emphasis is on speed rather than accuracy, so this should not be used for task requiring critical filtering.<br>
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_LOWPASS_SIMPLE_CUTOFF /* Lowpass cutoff frequency in hz. 10.0 to 22000.0. Default = 5000.0 */
|
||||
} FMOD_DSP_LOWPASS_SIMPLE;
|
||||
|
||||
/*
|
||||
[ENUM]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Parameter types for the FMOD_DSP_TYPE_HIGHPASS_SIMPLE filter.<br>
|
||||
This is a very simple single-order high pass filter.
|
||||
The emphasis is on speed rather than accuracy, so this should not be used for task requiring critical filtering.<br>
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
DSP::setParameter
|
||||
DSP::getParameter
|
||||
FMOD_DSP_TYPE
|
||||
]
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FMOD_DSP_HIGHPASS_SIMPLE_CUTOFF /* Highpass cutoff frequency in hz. 10.0 to 22000.0. Default = 1000.0 */
|
||||
} FMOD_DSP_HIGHPASS_SIMPLE;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/*$ preserve start $*/
|
||||
|
||||
/* ============================================================================================== */
|
||||
/* FMOD Ex - Error string header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2011. */
|
||||
/* */
|
||||
/* Use this header if you want to store or display a string version / english explanation of */
|
||||
/* the FMOD error codes. */
|
||||
/* */
|
||||
/* ============================================================================================== */
|
||||
|
||||
#ifndef _FMOD_ERRORS_H
|
||||
#define _FMOD_ERRORS_H
|
||||
|
||||
#include "fmod.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
static const char *FMOD_ErrorString(FMOD_RESULT errcode) __attribute__((unused));
|
||||
#endif
|
||||
|
||||
static const char *FMOD_ErrorString(FMOD_RESULT errcode)
|
||||
{
|
||||
switch (errcode)
|
||||
{
|
||||
/*$ preserve end $*/
|
||||
case FMOD_ERR_ALREADYLOCKED: return "Tried to call lock a second time before unlock was called. ";
|
||||
case FMOD_ERR_BADCOMMAND: return "Tried to call a function on a data type that does not allow this type of functionality (ie calling Sound::lock on a streaming sound). ";
|
||||
case FMOD_ERR_CDDA_DRIVERS: return "Neither NTSCSI nor ASPI could be initialised. ";
|
||||
case FMOD_ERR_CDDA_INIT: return "An error occurred while initialising the CDDA subsystem. ";
|
||||
case FMOD_ERR_CDDA_INVALID_DEVICE: return "Couldn't find the specified device. ";
|
||||
case FMOD_ERR_CDDA_NOAUDIO: return "No audio tracks on the specified disc. ";
|
||||
case FMOD_ERR_CDDA_NODEVICES: return "No CD/DVD devices were found. ";
|
||||
case FMOD_ERR_CDDA_NODISC: return "No disc present in the specified drive. ";
|
||||
case FMOD_ERR_CDDA_READ: return "A CDDA read error occurred. ";
|
||||
case FMOD_ERR_CHANNEL_ALLOC: return "Error trying to allocate a channel. ";
|
||||
case FMOD_ERR_CHANNEL_STOLEN: return "The specified channel has been reused to play another sound. ";
|
||||
case FMOD_ERR_COM: return "A Win32 COM related error occured. COM failed to initialize or a QueryInterface failed meaning a Windows codec or driver was not installed properly. ";
|
||||
case FMOD_ERR_DMA: return "DMA Failure. See debug output for more information. ";
|
||||
case FMOD_ERR_DSP_CONNECTION: return "DSP connection error. Connection possibly caused a cyclic dependancy. Or tried to connect a tree too many units deep (more than 128). ";
|
||||
case FMOD_ERR_DSP_FORMAT: return "DSP Format error. A DSP unit may have attempted to connect to this network with the wrong format. ";
|
||||
case FMOD_ERR_DSP_NOTFOUND: return "DSP connection error. Couldn't find the DSP unit specified. ";
|
||||
case FMOD_ERR_DSP_RUNNING: return "DSP error. Cannot perform this operation while the network is in the middle of running. This will most likely happen if a connection or disconnection is attempted in a DSP callback. ";
|
||||
case FMOD_ERR_DSP_TOOMANYCONNECTIONS: return "DSP connection error. The unit being connected to or disconnected should only have 1 input or output. ";
|
||||
case FMOD_ERR_EVENT_ALREADY_LOADED: return "The specified project has already been loaded. Having multiple copies of the same project loaded simultaneously is forbidden. ";
|
||||
case FMOD_ERR_EVENT_FAILED: return "An Event failed to be retrieved, most likely due to 'just fail' being specified as the max playbacks behavior. ";
|
||||
case FMOD_ERR_EVENT_GUIDCONFLICT: return "An event with the same GUID already exists. ";
|
||||
case FMOD_ERR_EVENT_INFOONLY: return "Can't execute this command on an EVENT_INFOONLY event. ";
|
||||
case FMOD_ERR_EVENT_INTERNAL: return "An error occured that wasn't supposed to. See debug log for reason. ";
|
||||
case FMOD_ERR_EVENT_MAXSTREAMS: return "Event failed because 'Max streams' was hit when FMOD_EVENT_INIT_FAIL_ON_MAXSTREAMS was specified. ";
|
||||
case FMOD_ERR_EVENT_MISMATCH: return "FSB mismatches the FEV it was compiled with, the stream/sample mode it was meant to be created with was different, or the FEV was built for a different platform. ";
|
||||
case FMOD_ERR_EVENT_NAMECONFLICT: return "A category with the same name already exists. ";
|
||||
case FMOD_ERR_EVENT_NEEDSSIMPLE: return "Tried to call a function on a complex event that's only supported by simple events. ";
|
||||
case FMOD_ERR_EVENT_NOTFOUND: return "The requested event, event group, event category or event property could not be found. ";
|
||||
case FMOD_ERR_FILE_BAD: return "Error loading file. ";
|
||||
case FMOD_ERR_FILE_COULDNOTSEEK: return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format. ";
|
||||
case FMOD_ERR_FILE_DISKEJECTED: return "Media was ejected while reading. ";
|
||||
case FMOD_ERR_FILE_EOF: return "End of file unexpectedly reached while trying to read essential data (truncated data?). ";
|
||||
case FMOD_ERR_FILE_NOTFOUND: return "File not found. ";
|
||||
case FMOD_ERR_FILE_UNWANTED: return "Unwanted file access occured. ";
|
||||
case FMOD_ERR_FORMAT: return "Unsupported file or audio format. ";
|
||||
case FMOD_ERR_HTTP: return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere. ";
|
||||
case FMOD_ERR_HTTP_ACCESS: return "The specified resource requires authentication or is forbidden. ";
|
||||
case FMOD_ERR_HTTP_PROXY_AUTH: return "Proxy authentication is required to access the specified resource. ";
|
||||
case FMOD_ERR_HTTP_SERVER_ERROR: return "A HTTP server error occurred. ";
|
||||
case FMOD_ERR_HTTP_TIMEOUT: return "The HTTP request timed out. ";
|
||||
case FMOD_ERR_INITIALIZATION: return "FMOD was not initialized correctly to support this function. ";
|
||||
case FMOD_ERR_INITIALIZED: return "Cannot call this command after System::init. ";
|
||||
case FMOD_ERR_INTERNAL: return "An error occured that wasn't supposed to. Contact support. ";
|
||||
case FMOD_ERR_INVALID_ADDRESS: return "On Xbox 360, this memory address passed to FMOD must be physical, (ie allocated with XPhysicalAlloc.) ";
|
||||
case FMOD_ERR_INVALID_FLOAT: return "Value passed in was a NaN, Inf or denormalized float. ";
|
||||
case FMOD_ERR_INVALID_HANDLE: return "An invalid object handle was used. ";
|
||||
case FMOD_ERR_INVALID_PARAM: return "An invalid parameter was passed to this function. ";
|
||||
case FMOD_ERR_INVALID_POSITION: return "An invalid seek position was passed to this function. ";
|
||||
case FMOD_ERR_INVALID_SPEAKER: return "An invalid speaker was passed to this function based on the current speaker mode. ";
|
||||
case FMOD_ERR_INVALID_SYNCPOINT: return "The syncpoint did not come from this sound handle. ";
|
||||
case FMOD_ERR_INVALID_VECTOR: return "The vectors passed in are not unit length, or perpendicular. ";
|
||||
case FMOD_ERR_MAXAUDIBLE: return "Reached maximum audible playback count for this sound's soundgroup. ";
|
||||
case FMOD_ERR_MEMORY: return "Not enough memory or resources. ";
|
||||
case FMOD_ERR_MEMORY_CANTPOINT: return "Can't use FMOD_OPENMEMORY_POINT on non PCM source data, or non mp3/xma/adpcm data if FMOD_CREATECOMPRESSEDSAMPLE was used. ";
|
||||
case FMOD_ERR_MEMORY_SRAM: return "Not enough memory or resources on console sound ram. ";
|
||||
case FMOD_ERR_MUSIC_NOCALLBACK: return "The music callback is required, but it has not been set. ";
|
||||
case FMOD_ERR_MUSIC_NOTFOUND: return "The requested music entity could not be found. ";
|
||||
case FMOD_ERR_MUSIC_UNINITIALIZED: return "Music system is not initialized probably because no music data is loaded. ";
|
||||
case FMOD_ERR_NEEDS2D: return "Tried to call a command on a 3d sound when the command was meant for 2d sound. ";
|
||||
case FMOD_ERR_NEEDS3D: return "Tried to call a command on a 2d sound when the command was meant for 3d sound. ";
|
||||
case FMOD_ERR_NEEDSHARDWARE: return "Tried to use a feature that requires hardware support. (ie trying to play a GCADPCM compressed sound in software on Wii). ";
|
||||
case FMOD_ERR_NEEDSSOFTWARE: return "Tried to use a feature that requires the software engine. Software engine has either been turned off, or command was executed on a hardware channel which does not support this feature. ";
|
||||
case FMOD_ERR_NET_CONNECT: return "Couldn't connect to the specified host. ";
|
||||
case FMOD_ERR_NET_SOCKET_ERROR: return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere. ";
|
||||
case FMOD_ERR_NET_URL: return "The specified URL couldn't be resolved. ";
|
||||
case FMOD_ERR_NET_WOULD_BLOCK: return "Operation on a non-blocking socket could not complete immediately. ";
|
||||
case FMOD_ERR_NOTREADY: return "Operation could not be performed because specified sound/DSP connection is not ready. ";
|
||||
case FMOD_ERR_OUTPUT_ALLOCATED: return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused. ";
|
||||
case FMOD_ERR_OUTPUT_CREATEBUFFER: return "Error creating hardware sound buffer. ";
|
||||
case FMOD_ERR_OUTPUT_DRIVERCALL: return "A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted. ";
|
||||
case FMOD_ERR_OUTPUT_ENUMERATION: return "Error enumerating the available driver list. List may be inconsistent due to a recent device addition or removal. ";
|
||||
case FMOD_ERR_OUTPUT_FORMAT: return "Soundcard does not support the minimum features needed for this soundsystem (16bit stereo output). ";
|
||||
case FMOD_ERR_OUTPUT_INIT: return "Error initializing output device. ";
|
||||
case FMOD_ERR_OUTPUT_NOHARDWARE: return "FMOD_HARDWARE was specified but the sound card does not have the resources necessary to play it. ";
|
||||
case FMOD_ERR_OUTPUT_NOSOFTWARE: return "Attempted to create a software sound but no software channels were specified in System::init. ";
|
||||
case FMOD_ERR_PAN: return "Panning only works with mono or stereo sound sources. ";
|
||||
case FMOD_ERR_PLUGIN: return "An unspecified error has been returned from a 3rd party plugin. ";
|
||||
case FMOD_ERR_PLUGIN_INSTANCES: return "The number of allowed instances of a plugin has been exceeded. ";
|
||||
case FMOD_ERR_PLUGIN_MISSING: return "A requested output, dsp unit type or codec was not available. ";
|
||||
case FMOD_ERR_PLUGIN_RESOURCE: return "A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback) ";
|
||||
case FMOD_ERR_PRELOADED: return "The specified sound is still in use by the event system, call EventSystem::unloadFSB before trying to release it. ";
|
||||
case FMOD_ERR_PROGRAMMERSOUND: return "The specified sound is still in use by the event system, wait for the event which is using it finish with it. ";
|
||||
case FMOD_ERR_RECORD: return "An error occured trying to initialize the recording device. ";
|
||||
case FMOD_ERR_REVERB_INSTANCE: return "Specified instance in FMOD_REVERB_PROPERTIES couldn't be set. Most likely because it is an invalid instance number or the reverb doesnt exist. ";
|
||||
case FMOD_ERR_SUBSOUNDS: return "The error occured because the sound referenced contains subsounds when it shouldn't have, or it doesn't contain subsounds when it should have. The operation may also not be able to be performed on a parent sound, or a parent sound was played without setting up a sentence first. ";
|
||||
case FMOD_ERR_SUBSOUND_ALLOCATED: return "This subsound is already being used by another sound, you cannot have more than one parent to a sound. Null out the other parent's entry first. ";
|
||||
case FMOD_ERR_SUBSOUND_CANTMOVE: return "Shared subsounds cannot be replaced or moved from their parent stream, such as when the parent stream is an FSB file. ";
|
||||
case FMOD_ERR_SUBSOUND_MODE: return "The subsound's mode bits do not match with the parent sound's mode bits. See documentation for function that it was called with. ";
|
||||
case FMOD_ERR_TAGNOTFOUND: return "The specified tag could not be found or there are no tags. ";
|
||||
case FMOD_ERR_TOOMANYCHANNELS: return "The sound created exceeds the allowable input channel count. This can be increased using the maxinputchannels parameter in System::setSoftwareFormat. ";
|
||||
case FMOD_ERR_UNIMPLEMENTED: return "Something in FMOD hasn't been implemented when it should be! contact support! ";
|
||||
case FMOD_ERR_UNINITIALIZED: return "This command failed because System::init or System::setDriver was not called. ";
|
||||
case FMOD_ERR_UNSUPPORTED: return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified. ";
|
||||
case FMOD_ERR_UPDATE: return "An error caused by System::update occured. ";
|
||||
case FMOD_ERR_VERSION: return "The version number of this file format is not supported. ";
|
||||
case FMOD_OK: return "No errors.";
|
||||
default : return "Unknown error.";
|
||||
/*$ preserve start $*/
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
/*$ preserve end $*/
|
|
@ -0,0 +1,201 @@
|
|||
/* ============================================================================================= */
|
||||
/* FMOD Ex - Memory info header file. Copyright (c), Firelight Technologies Pty, Ltd. 2008-2011. */
|
||||
/* */
|
||||
/* Use this header if you are interested in getting detailed information on FMOD's memory */
|
||||
/* usage. See the documentation for more details. */
|
||||
/* */
|
||||
/* ============================================================================================= */
|
||||
|
||||
#ifndef _FMOD_MEMORYINFO_H
|
||||
#define _FMOD_MEMORYINFO_H
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Structure to be filled with detailed memory usage information of an FMOD object
|
||||
|
||||
[REMARKS]
|
||||
Every public FMOD class has a getMemoryInfo function which can be used to get detailed information on what memory resources are associated with the object in question.
|
||||
On return from getMemoryInfo, each member of this structure will hold the amount of memory used for its type in bytes.<br>
|
||||
<br>
|
||||
Members marked with [in] mean the user sets the value before passing it to the function.<br>
|
||||
Members marked with [out] mean FMOD sets the value to be used after the function exits.<br>
|
||||
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
System::getMemoryInfo
|
||||
EventSystem::getMemoryInfo
|
||||
FMOD_MEMBITS
|
||||
FMOD_EVENT_MEMBITS
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_MEMORY_USAGE_DETAILS
|
||||
{
|
||||
unsigned int other; /* [out] Memory not accounted for by other types */
|
||||
unsigned int string; /* [out] String data */
|
||||
unsigned int system; /* [out] System object and various internals */
|
||||
unsigned int plugins; /* [out] Plugin objects and internals */
|
||||
unsigned int output; /* [out] Output module object and internals */
|
||||
unsigned int channel; /* [out] Channel related memory */
|
||||
unsigned int channelgroup; /* [out] ChannelGroup objects and internals */
|
||||
unsigned int codec; /* [out] Codecs allocated for streaming */
|
||||
unsigned int file; /* [out] File buffers and structures */
|
||||
unsigned int sound; /* [out] Sound objects and internals */
|
||||
unsigned int secondaryram; /* [out] Sound data stored in secondary RAM */
|
||||
unsigned int soundgroup; /* [out] SoundGroup objects and internals */
|
||||
unsigned int streambuffer; /* [out] Stream buffer memory */
|
||||
unsigned int dspconnection; /* [out] DSPConnection objects and internals */
|
||||
unsigned int dsp; /* [out] DSP implementation objects */
|
||||
unsigned int dspcodec; /* [out] Realtime file format decoding DSP objects */
|
||||
unsigned int profile; /* [out] Profiler memory footprint. */
|
||||
unsigned int recordbuffer; /* [out] Buffer used to store recorded data from microphone */
|
||||
unsigned int reverb; /* [out] Reverb implementation objects */
|
||||
unsigned int reverbchannelprops; /* [out] Reverb channel properties structs */
|
||||
unsigned int geometry; /* [out] Geometry objects and internals */
|
||||
unsigned int syncpoint; /* [out] Sync point memory. */
|
||||
unsigned int eventsystem; /* [out] EventSystem and various internals */
|
||||
unsigned int musicsystem; /* [out] MusicSystem and various internals */
|
||||
unsigned int fev; /* [out] Definition of objects contained in all loaded projects e.g. events, groups, categories */
|
||||
unsigned int memoryfsb; /* [out] Data loaded with preloadFSB */
|
||||
unsigned int eventproject; /* [out] EventProject objects and internals */
|
||||
unsigned int eventgroupi; /* [out] EventGroup objects and internals */
|
||||
unsigned int soundbankclass; /* [out] Objects used to manage wave banks */
|
||||
unsigned int soundbanklist; /* [out] Data used to manage lists of wave bank usage */
|
||||
unsigned int streaminstance; /* [out] Stream objects and internals */
|
||||
unsigned int sounddefclass; /* [out] Sound definition objects */
|
||||
unsigned int sounddefdefclass; /* [out] Sound definition static data objects */
|
||||
unsigned int sounddefpool; /* [out] Sound definition pool data */
|
||||
unsigned int reverbdef; /* [out] Reverb definition objects */
|
||||
unsigned int eventreverb; /* [out] Reverb objects */
|
||||
unsigned int userproperty; /* [out] User property objects */
|
||||
unsigned int eventinstance; /* [out] Event instance base objects */
|
||||
unsigned int eventinstance_complex; /* [out] Complex event instance objects */
|
||||
unsigned int eventinstance_simple; /* [out] Simple event instance objects */
|
||||
unsigned int eventinstance_layer; /* [out] Event layer instance objects */
|
||||
unsigned int eventinstance_sound; /* [out] Event sound instance objects */
|
||||
unsigned int eventenvelope; /* [out] Event envelope objects */
|
||||
unsigned int eventenvelopedef; /* [out] Event envelope definition objects */
|
||||
unsigned int eventparameter; /* [out] Event parameter objects */
|
||||
unsigned int eventcategory; /* [out] Event category objects */
|
||||
unsigned int eventenvelopepoint; /* [out] Event envelope point objects */
|
||||
unsigned int eventinstancepool; /* [out] Event instance pool memory */
|
||||
} FMOD_MEMORY_USAGE_DETAILS;
|
||||
|
||||
|
||||
/*
|
||||
[DEFINE]
|
||||
[
|
||||
[NAME]
|
||||
FMOD_MEMBITS
|
||||
|
||||
[DESCRIPTION]
|
||||
Bitfield used to request specific memory usage information from the getMemoryInfo function of every public FMOD Ex class.
|
||||
Use with the "memorybits" parameter of getMemoryInfo to get information on FMOD Ex memory usage.
|
||||
|
||||
[REMARKS]
|
||||
Every public FMOD class has a getMemoryInfo function which can be used to get detailed information on what memory resources are associated with the object in question.
|
||||
The FMOD_MEMBITS defines can be OR'd together to specify precisely what memory usage you'd like to get information on. See System::getMemoryInfo for an example.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_EVENT_MEMBITS
|
||||
System::getMemoryInfo
|
||||
]
|
||||
*/
|
||||
#define FMOD_MEMBITS_OTHER 0x00000001 /* Memory not accounted for by other types */
|
||||
#define FMOD_MEMBITS_STRING 0x00000002 /* String data */
|
||||
|
||||
#define FMOD_MEMBITS_SYSTEM 0x00000004 /* System object and various internals */
|
||||
#define FMOD_MEMBITS_PLUGINS 0x00000008 /* Plugin objects and internals */
|
||||
#define FMOD_MEMBITS_OUTPUT 0x00000010 /* Output module object and internals */
|
||||
#define FMOD_MEMBITS_CHANNEL 0x00000020 /* Channel related memory */
|
||||
#define FMOD_MEMBITS_CHANNELGROUP 0x00000040 /* ChannelGroup objects and internals */
|
||||
#define FMOD_MEMBITS_CODEC 0x00000080 /* Codecs allocated for streaming */
|
||||
#define FMOD_MEMBITS_FILE 0x00000100 /* Codecs allocated for streaming */
|
||||
#define FMOD_MEMBITS_SOUND 0x00000200 /* Sound objects and internals */
|
||||
#define FMOD_MEMBITS_SOUND_SECONDARYRAM 0x00000400 /* Sound data stored in secondary RAM */
|
||||
#define FMOD_MEMBITS_SOUNDGROUP 0x00000800 /* SoundGroup objects and internals */
|
||||
#define FMOD_MEMBITS_STREAMBUFFER 0x00001000 /* Stream buffer memory */
|
||||
#define FMOD_MEMBITS_DSPCONNECTION 0x00002000 /* DSPConnection objects and internals */
|
||||
#define FMOD_MEMBITS_DSP 0x00004000 /* DSP implementation objects */
|
||||
#define FMOD_MEMBITS_DSPCODEC 0x00008000 /* Realtime file format decoding DSP objects */
|
||||
#define FMOD_MEMBITS_PROFILE 0x00010000 /* Profiler memory footprint. */
|
||||
#define FMOD_MEMBITS_RECORDBUFFER 0x00020000 /* Buffer used to store recorded data from microphone */
|
||||
#define FMOD_MEMBITS_REVERB 0x00040000 /* Reverb implementation objects */
|
||||
#define FMOD_MEMBITS_REVERBCHANNELPROPS 0x00080000 /* Reverb channel properties structs */
|
||||
#define FMOD_MEMBITS_GEOMETRY 0x00100000 /* Geometry objects and internals */
|
||||
#define FMOD_MEMBITS_SYNCPOINT 0x00200000 /* Sync point memory. */
|
||||
#define FMOD_MEMBITS_ALL 0xffffffff /* All memory used by FMOD Ex */
|
||||
/* [DEFINE_END] */
|
||||
|
||||
|
||||
/*
|
||||
[DEFINE]
|
||||
[
|
||||
[NAME]
|
||||
FMOD_EVENT_MEMBITS
|
||||
|
||||
[DESCRIPTION]
|
||||
Bitfield used to request specific memory usage information from the getMemoryInfo function of every public FMOD Event System class.
|
||||
Use with the "event_memorybits" parameter of getMemoryInfo to get information on FMOD Event System memory usage.
|
||||
|
||||
[REMARKS]
|
||||
Every public FMOD Event System class has a getMemoryInfo function which can be used to get detailed information on what memory resources are associated with the object in question.
|
||||
The FMOD_EVENT_MEMBITS defines can be OR'd together to specify precisely what memory usage you'd like to get information on. See EventSystem::getMemoryInfo for an example.
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_MEMBITS
|
||||
System::getMemoryInfo
|
||||
]
|
||||
*/
|
||||
#define FMOD_EVENT_MEMBITS_EVENTSYSTEM 0x00000001 /* EventSystem and various internals */
|
||||
#define FMOD_EVENT_MEMBITS_MUSICSYSTEM 0x00000002 /* MusicSystem and various internals */
|
||||
#define FMOD_EVENT_MEMBITS_FEV 0x00000004 /* Definition of objects contained in all loaded projects e.g. events, groups, categories */
|
||||
#define FMOD_EVENT_MEMBITS_MEMORYFSB 0x00000008 /* Data loaded with preloadFSB */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTPROJECT 0x00000010 /* EventProject objects and internals */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTGROUPI 0x00000020 /* EventGroup objects and internals */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDBANKCLASS 0x00000040 /* Objects used to manage wave banks */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDBANKLIST 0x00000080 /* Data used to manage lists of wave bank usage */
|
||||
#define FMOD_EVENT_MEMBITS_STREAMINSTANCE 0x00000100 /* Stream objects and internals */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDDEFCLASS 0x00000200 /* Sound definition objects */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDDEFDEFCLASS 0x00000400 /* Sound definition static data objects */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDDEFPOOL 0x00000800 /* Sound definition pool data */
|
||||
#define FMOD_EVENT_MEMBITS_REVERBDEF 0x00001000 /* Reverb definition objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTREVERB 0x00002000 /* Reverb objects */
|
||||
#define FMOD_EVENT_MEMBITS_USERPROPERTY 0x00004000 /* User property objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE 0x00008000 /* Event instance base objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE_COMPLEX 0x00010000 /* Complex event instance objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE_SIMPLE 0x00020000 /* Simple event instance objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE_LAYER 0x00040000 /* Event layer instance objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE_SOUND 0x00080000 /* Event sound instance objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTENVELOPE 0x00100000 /* Event envelope objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTENVELOPEDEF 0x00200000 /* Event envelope definition objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTPARAMETER 0x00400000 /* Event parameter objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTCATEGORY 0x00800000 /* Event category objects */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTENVELOPEPOINT 0x01000000 /* Event envelope point object+s */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCEPOOL 0x02000000 /* Event instance pool data */
|
||||
#define FMOD_EVENT_MEMBITS_ALL 0xffffffff /* All memory used by FMOD Event System */
|
||||
|
||||
/* All event instance memory */
|
||||
#define FMOD_EVENT_MEMBITS_EVENTINSTANCE_GROUP (FMOD_EVENT_MEMBITS_EVENTINSTANCE | \
|
||||
FMOD_EVENT_MEMBITS_EVENTINSTANCE_COMPLEX | \
|
||||
FMOD_EVENT_MEMBITS_EVENTINSTANCE_SIMPLE | \
|
||||
FMOD_EVENT_MEMBITS_EVENTINSTANCE_LAYER | \
|
||||
FMOD_EVENT_MEMBITS_EVENTINSTANCE_SOUND)
|
||||
|
||||
/* All sound definition memory */
|
||||
#define FMOD_EVENT_MEMBITS_SOUNDDEF_GROUP (FMOD_EVENT_MEMBITS_SOUNDDEFCLASS | \
|
||||
FMOD_EVENT_MEMBITS_SOUNDDEFDEFCLASS | \
|
||||
FMOD_EVENT_MEMBITS_SOUNDDEFPOOL)
|
||||
/* [DEFINE_END] */
|
||||
|
||||
#endif
|
|
@ -0,0 +1,93 @@
|
|||
/* ==================================================================================================== */
|
||||
/* FMOD Ex - output development header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2011. */
|
||||
/* */
|
||||
/* Use this header if you are wanting to develop your own output plugin to use with */
|
||||
/* FMOD's output system. With this header you can make your own output plugin that FMOD */
|
||||
/* can register and use. See the documentation and examples on how to make a working plugin. */
|
||||
/* */
|
||||
/* ==================================================================================================== */
|
||||
|
||||
#ifndef _FMOD_OUTPUT_H
|
||||
#define _FMOD_OUTPUT_H
|
||||
|
||||
#include "fmod.h"
|
||||
|
||||
typedef struct FMOD_OUTPUT_STATE FMOD_OUTPUT_STATE;
|
||||
|
||||
/*
|
||||
Output callbacks
|
||||
*/
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETNUMDRIVERSCALLBACK)(FMOD_OUTPUT_STATE *output_state, int *numdrivers);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETDRIVERNAMECALLBACK)(FMOD_OUTPUT_STATE *output_state, int id, char *name, int namelen);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETDRIVERCAPSCALLBACK)(FMOD_OUTPUT_STATE *output_state, int id, FMOD_CAPS *caps);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_INITCALLBACK) (FMOD_OUTPUT_STATE *output_state, int selecteddriver, FMOD_INITFLAGS flags, int *outputrate, int outputchannels, FMOD_SOUND_FORMAT *outputformat, int dspbufferlength, int dspnumbuffers, void *extradriverdata);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_CLOSECALLBACK) (FMOD_OUTPUT_STATE *output_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UPDATECALLBACK) (FMOD_OUTPUT_STATE *output_state);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETHANDLECALLBACK) (FMOD_OUTPUT_STATE *output_state, void **handle);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETPOSITIONCALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int *pcm);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_LOCKCALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UNLOCKCALLBACK) (FMOD_OUTPUT_STATE *output_state, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
|
||||
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_READFROMMIXER) (FMOD_OUTPUT_STATE *output_state, void *buffer, unsigned int length);
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
When creating an output, declare one of these and provide the relevant callbacks and name for FMOD to use when it opens and reads a file of this type.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
|
||||
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_OUTPUT_STATE
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_OUTPUT_DESCRIPTION
|
||||
{
|
||||
const char *name; /* [in] Name of the output. */
|
||||
unsigned int version; /* [in] Plugin writer's version number. */
|
||||
int polling; /* [in] If TRUE (non zero), this tells FMOD to start a thread and call getposition / lock / unlock for feeding data. If 0, the output is probably callback based, so all the plugin needs to do is call readfrommixer to the appropriate pointer. */
|
||||
FMOD_OUTPUT_GETNUMDRIVERSCALLBACK getnumdrivers; /* [in] For sound device enumeration. This callback is to give System::getNumDrivers somthing to return. */
|
||||
FMOD_OUTPUT_GETDRIVERNAMECALLBACK getdrivername; /* [in] For sound device enumeration. This callback is to give System::getDriverName somthing to return. */
|
||||
FMOD_OUTPUT_GETDRIVERCAPSCALLBACK getdrivercaps; /* [in] For sound device enumeration. This callback is to give System::getDriverCaps somthing to return. */
|
||||
FMOD_OUTPUT_INITCALLBACK init; /* [in] Initialization function for the output device. This is called from System::init. */
|
||||
FMOD_OUTPUT_CLOSECALLBACK close; /* [in] Cleanup / close down function for the output device. This is called from System::close. */
|
||||
FMOD_OUTPUT_UPDATECALLBACK update; /* [in] Update function that is called once a frame by the user. This is called from System::update. */
|
||||
FMOD_OUTPUT_GETHANDLECALLBACK gethandle; /* [in] This is called from System::getOutputHandle. This is just to return a pointer to the internal system device object that the system may be using.*/
|
||||
FMOD_OUTPUT_GETPOSITIONCALLBACK getposition; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This returns a position value in samples so that FMOD knows where and when to fill its buffer. */
|
||||
FMOD_OUTPUT_LOCKCALLBACK lock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This function provides a pointer to data that FMOD can write to when software mixing. */
|
||||
FMOD_OUTPUT_UNLOCKCALLBACK unlock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This optional function accepts the data that has been mixed and copies it or does whatever it needs to before sending it to the hardware. */
|
||||
} FMOD_OUTPUT_DESCRIPTION;
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Output plugin structure that is passed into each callback.
|
||||
|
||||
[REMARKS]
|
||||
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
|
||||
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
|
||||
|
||||
[PLATFORMS]
|
||||
Win32, Win64, Linux, Linux64, Macintosh, Xbox360, PlayStation Portable, PlayStation 3, Wii, iPhone, 3GS, NGP, Android
|
||||
|
||||
[SEE_ALSO]
|
||||
FMOD_OUTPUT_DESCRIPTION
|
||||
]
|
||||
*/
|
||||
struct FMOD_OUTPUT_STATE
|
||||
{
|
||||
void *plugindata; /* [in] Plugin writer created data the output author wants to attach to this object. */
|
||||
FMOD_OUTPUT_READFROMMIXER readfrommixer; /* [out] Function to update mixer and write the result to the provided pointer. Used from callback based output only. Polling based output uses lock/unlock/getposition. */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/* =========================================================================================== */
|
||||
/* FMOD Linux Specific header file. Copyright (c), Firelight Technologies Pty, Ltd. 2005-2011. */
|
||||
/* =========================================================================================== */
|
||||
|
||||
#ifndef _FMODLINUX_H
|
||||
#define _FMODLINUX_H
|
||||
|
||||
#include "fmod.h"
|
||||
|
||||
|
||||
/*
|
||||
[STRUCTURE]
|
||||
[
|
||||
[DESCRIPTION]
|
||||
Use this structure with System::init to set the information required for linux
|
||||
initialisation.
|
||||
|
||||
Pass this structure in as the "extradriverdata" parameter in System::init.
|
||||
|
||||
[REMARKS]
|
||||
|
||||
[PLATFORMS]
|
||||
Linux, Linux64
|
||||
|
||||
[SEE_ALSO]
|
||||
System::init
|
||||
]
|
||||
*/
|
||||
typedef struct FMOD_LINUX_EXTRADRIVERDATA
|
||||
{
|
||||
const char *output_driver_arguments; /* ALSA Only - Arguments to apply to the selected output driver */
|
||||
const char *record_driver_arguments; /* ALSA Only - Arguments to apply to the selected input (record) driver */
|
||||
} FMOD_LINUX_EXTRADRIVERDATA;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1 @@
|
|||
5e11b3b6168668e874105ed574b60c39c48db02b
|
|
@ -0,0 +1 @@
|
|||
5e11b3b6168668e874105ed574b60c39c48db02b
|
|
@ -0,0 +1 @@
|
|||
c3663fea3c08b4112bd92639963b102b9aa42cb8
|
|
@ -0,0 +1 @@
|
|||
c3663fea3c08b4112bd92639963b102b9aa42cb8
|
|
@ -0,0 +1 @@
|
|||
fe25757fdb0cc2e48002bf130522902794158965
|
|
@ -0,0 +1 @@
|
|||
2b6d571d132326e599c4790cc0a24aaaa940f721
|
|
@ -0,0 +1,85 @@
|
|||
FMOD Ex SoundSystem Copyright © 2005-2011 Firelight Technologies Pty, Ltd.
|
||||
|
||||
FMOD NON-COMMERCIAL LICENSE
|
||||
------------------------------------
|
||||
IF YOUR PRODUCT IS NOT INTENDED FOR COMMERCIAL GAIN AND DOES NOT
|
||||
INCLUDE THE FMOD LIBRARY FOR RESALE, LICENSE OR OTHER COMMERCIAL
|
||||
DISTRIBUTION, THEN USE OF FMOD IS FREE OF CHARGE. THERE ARE NO
|
||||
LICENSE FEES FOR NON-COMMERCIAL APPLICATIONS.
|
||||
|
||||
CONDITIONS/LIMITATIONS:
|
||||
- WHEN USING THIS LICENSE, THE FMOD LIBRARY CANNOT BE USED FOR
|
||||
RESALE OR OTHER COMMERCIAL DISTRIBUTION
|
||||
- THIS LICENSE CANNOT BE USED FOR PRODUCTS WHICH DO NOT MAKE
|
||||
PROFIT BUT ARE STILL COMMERCIALLY RELEASED
|
||||
- THIS LICENSE CANNOT BE USED FOR COMMERCIAL SERVICES, WHERE THE
|
||||
EXECUTABLE CONTAINING FMOD IS NOT SOLD, BUT THE DATA IS.
|
||||
- WHEN USING FMOD, A CREDIT LINE IS REQUIRED IN EITHER DOCUMENTATION,
|
||||
OR 'ON SCREEN' FORMAT (IF POSSIBLE). IT SHOULD CONTAIN AT LEAST
|
||||
THE WORDS FMOD SOUND SYSTEM AND FIRELIGHT TECHNOLOGIES.
|
||||
LOGOS ARE AVAILABLE FOR BOX OR MANUAL ART, BUT ARE NOT MANDANTORY.
|
||||
AN EXAMPLE CREDIT COULD BE:
|
||||
|
||||
FMOD Sound System, copyright © Firelight Technologies Pty, Ltd., 1994-2011.
|
||||
|
||||
NOTE THIS IN ADVANCE, AS IT MUST BE DONE BEFORE SHIPPING YOUR
|
||||
PRODUCT WITH FMOD.
|
||||
|
||||
Uses Ogg Vorbis codec. BSD license.
|
||||
------------------------------------
|
||||
Copyright (c) 2002, Xiph.org Foundation
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- 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.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``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 FOUNDATION
|
||||
OR CONTRIBUTORS 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.
|
||||
|
||||
For Android platform code.
|
||||
--------------------------
|
||||
Copyright (C) 2010 The Android Open Source Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* 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.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"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
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS 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.
|
1
CocosDenshion/third_party/fmod/documentation/fmod-profiler.pdf.REMOVED.git-id
vendored
Normal file
1
CocosDenshion/third_party/fmod/documentation/fmod-profiler.pdf.REMOVED.git-id
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
fe3d4e47687a4bc181a1b3e1d71459b13f8d1ebc
|
|
@ -0,0 +1 @@
|
|||
ea6ff436eda933873fe871fb22523eebdfcccbca
|
|
@ -0,0 +1 @@
|
|||
2e5bd5bfc4d59acfe03fe0d7fd67187dd7281171
|
|
@ -0,0 +1,11 @@
|
|||
3d_cpp: main.cpp
|
||||
g++ -O3 -o 3d main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
3d_c: main.c
|
||||
g++ -O3 -o 3d main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./3d
|
||||
|
||||
clean:
|
||||
rm -f 3d
|
|
@ -0,0 +1,254 @@
|
|||
/*===============================================================================================
|
||||
3d Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to basic 3d positioning
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
const int INTERFACE_UPDATETIME = 50; // 50ms update for interface
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound1, *sound2, *sound3;
|
||||
FMOD_CHANNEL *channel1 = 0, *channel2 = 0, *channel3 = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
int listenerflag = TRUE;
|
||||
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, 0.0f };
|
||||
unsigned int version;
|
||||
|
||||
printf("===============================================================\n");
|
||||
printf("3d Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===============================================================\n");
|
||||
printf("This example plays 2 3D sounds in software. Optionally you can\n");
|
||||
printf("play a 2D software sound as well.\n");
|
||||
printf("Hardware sounds are not supported on Linux\n");
|
||||
printf("===============================================================\n\n");
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 10, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Load some sounds
|
||||
*/
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_3D, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Set3DMinMaxDistance(sound1, 4.0f, 10000.0f);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_SOFTWARE | FMOD_3D, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Set3DMinMaxDistance(sound2, 4.0f, 10000.0f);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_SetMode(sound2, FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Play sounds at certain positions
|
||||
*/
|
||||
{
|
||||
FMOD_VECTOR pos = { -10.0f, -0.0f, 0.0f };
|
||||
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_Set3DAttributes(channel1, &pos, &vel);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_SetPaused(channel1, FALSE);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
{
|
||||
FMOD_VECTOR pos = { 15.0f, -0.0f, -0.0f };
|
||||
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_Set3DAttributes(channel2, &pos, &vel);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_SetPaused(channel2, FALSE);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Display help
|
||||
*/
|
||||
{
|
||||
int numchannels;
|
||||
|
||||
result = FMOD_System_GetHardwareChannels(system, &numchannels);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Hardware channels : %d\n", numchannels);
|
||||
}
|
||||
|
||||
printf("=========================================================================\n");
|
||||
printf("Press 1 Pause/Unpause 16bit 3D sound at any time\n");
|
||||
printf(" 2 Pause/Unpause 8bit 3D sound at any time\n");
|
||||
printf(" 3 Play 16bit STEREO 2D sound at any time\n");
|
||||
printf(" < Move listener left (in still mode)\n");
|
||||
printf(" > Move listener right (in still mode)\n");
|
||||
printf(" SPACE Stop/Start listener automatic movement\n");
|
||||
printf(" ESC Quit\n");
|
||||
printf("=========================================================================\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
if (key == '1')
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel1, &paused);
|
||||
FMOD_Channel_SetPaused(channel1, !paused);
|
||||
}
|
||||
|
||||
if (key == '2')
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel2, &paused);
|
||||
FMOD_Channel_SetPaused(channel2, !paused);
|
||||
}
|
||||
|
||||
if (key == '3')
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound3, FALSE, &channel3);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
if (key == ' ')
|
||||
{
|
||||
listenerflag = !listenerflag;
|
||||
}
|
||||
|
||||
if (!listenerflag)
|
||||
{
|
||||
if (key == '<')
|
||||
{
|
||||
listenerpos.x -= 1.0f;
|
||||
if (listenerpos.x < -35)
|
||||
{
|
||||
listenerpos.x = -35;
|
||||
}
|
||||
}
|
||||
if (key == '>')
|
||||
{
|
||||
listenerpos.x += 1.0f;
|
||||
if (listenerpos.x > 30)
|
||||
{
|
||||
listenerpos.x = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================================================
|
||||
// UPDATE THE LISTENER
|
||||
// ==========================================================================================
|
||||
{
|
||||
static float t = 0;
|
||||
static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
|
||||
FMOD_VECTOR forward = { 0.0f, 0.0f, 1.0f };
|
||||
FMOD_VECTOR up = { 0.0f, 1.0f, 0.0f };
|
||||
FMOD_VECTOR vel;
|
||||
|
||||
if (listenerflag)
|
||||
{
|
||||
listenerpos.x = ((float)sin(t * 0.05f) * 33.0f); // left right pingpong
|
||||
}
|
||||
|
||||
// ********* NOTE ******* READ NEXT COMMENT!!!!!
|
||||
// vel = how far we moved last FRAME (m/f), then time compensate it to SECONDS (m/s).
|
||||
vel.x = (listenerpos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
|
||||
vel.y = (listenerpos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
|
||||
vel.z = (listenerpos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);
|
||||
|
||||
// store pos for next time
|
||||
lastpos = listenerpos;
|
||||
|
||||
result = FMOD_System_Set3DListenerAttributes(system, 0, &listenerpos, &vel, &forward, &up);
|
||||
ERRCHECK(result);
|
||||
|
||||
t += (30 * (1.0f / (float)INTERFACE_UPDATETIME)); // t is just a time value .. it increments in 30m/s steps in this example
|
||||
|
||||
// print out a small visual display
|
||||
{
|
||||
char s[80];
|
||||
|
||||
sprintf(s, "|.......................<1>......................<2>....................|");
|
||||
|
||||
s[(int)(listenerpos.x) + 35] = 'L';
|
||||
printf("%s\r", s);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
Sleep(INTERFACE_UPDATETIME - 1);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
/*===============================================================================================
|
||||
3d Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to basic 3d positioning
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
const int INTERFACE_UPDATETIME = 50; // 50ms update for interface
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound1, *sound2, *sound3;
|
||||
FMOD::Channel *channel1 = 0, *channel2 = 0, *channel3 = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
bool listenerflag = true;
|
||||
FMOD_VECTOR listenerpos = { 0.0f, 0.0f, 0.0f };
|
||||
unsigned int version;
|
||||
|
||||
printf("===============================================================\n");
|
||||
printf("3d Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===============================================================\n\n");
|
||||
printf("This example plays 2 3D sounds in software. Optionally you can\n");
|
||||
printf("play a 2D software sound as well.\n");
|
||||
printf("Hardware sounds are not supported on Linux\n");
|
||||
printf("===============================================================\n\n");
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(10, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Load some sounds
|
||||
*/
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE | FMOD_3D, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = sound1->set3DMinMaxDistance(4.0f, 10000.0f);
|
||||
ERRCHECK(result);
|
||||
result = sound1->setMode(FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/jaguar.wav", FMOD_SOFTWARE | FMOD_3D, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
result = sound2->set3DMinMaxDistance(4.0f, 10000.0f);
|
||||
ERRCHECK(result);
|
||||
result = sound2->setMode(FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/swish.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Play sounds at certain positions
|
||||
*/
|
||||
{
|
||||
FMOD_VECTOR pos = { -10.0f, -0.0f, 0.0f };
|
||||
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel1);
|
||||
ERRCHECK(result);
|
||||
result = channel1->set3DAttributes(&pos, &vel);
|
||||
ERRCHECK(result);
|
||||
result = channel1->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
{
|
||||
FMOD_VECTOR pos = { 15.0f, -0.0f, -0.0f };
|
||||
FMOD_VECTOR vel = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, true, &channel2);
|
||||
ERRCHECK(result);
|
||||
result = channel2->set3DAttributes(&pos, &vel);
|
||||
ERRCHECK(result);
|
||||
result = channel2->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Display help
|
||||
*/
|
||||
{
|
||||
int numchannels = 0;
|
||||
|
||||
result = system->getHardwareChannels(&numchannels);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Hardware channels : %d\n", numchannels);
|
||||
}
|
||||
|
||||
printf("=========================================================================\n");
|
||||
printf("Press 1 Pause/Unpause 16bit 3D sound at any time\n");
|
||||
printf(" 2 Pause/Unpause 8bit 3D sound at any time\n");
|
||||
printf(" 3 Play 16bit STEREO 2D sound at any time\n");
|
||||
printf(" < Move listener left (in still mode)\n");
|
||||
printf(" > Move listener right (in still mode)\n");
|
||||
printf(" SPACE Stop/Start listener automatic movement\n");
|
||||
printf(" ESC Quit\n");
|
||||
printf("=========================================================================\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
if (key == '1')
|
||||
{
|
||||
bool paused;
|
||||
channel1->getPaused(&paused);
|
||||
channel1->setPaused(!paused);
|
||||
}
|
||||
|
||||
if (key == '2')
|
||||
{
|
||||
bool paused;
|
||||
channel2->getPaused(&paused);
|
||||
channel2->setPaused(!paused);
|
||||
}
|
||||
|
||||
if (key == '3')
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound3, false, &channel3);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
if (key == ' ')
|
||||
{
|
||||
listenerflag = !listenerflag;
|
||||
}
|
||||
|
||||
if (!listenerflag)
|
||||
{
|
||||
if (key == '<')
|
||||
{
|
||||
listenerpos.x -= 1.0f;
|
||||
if (listenerpos.x < -35)
|
||||
{
|
||||
listenerpos.x = -35;
|
||||
}
|
||||
}
|
||||
if (key == '>')
|
||||
{
|
||||
listenerpos.x += 1.0f;
|
||||
if (listenerpos.x > 30)
|
||||
{
|
||||
listenerpos.x = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================================================================
|
||||
// UPDATE THE LISTENER
|
||||
// ==========================================================================================
|
||||
{
|
||||
static float t = 0;
|
||||
static FMOD_VECTOR lastpos = { 0.0f, 0.0f, 0.0f };
|
||||
FMOD_VECTOR forward = { 0.0f, 0.0f, 1.0f };
|
||||
FMOD_VECTOR up = { 0.0f, 1.0f, 0.0f };
|
||||
FMOD_VECTOR vel;
|
||||
|
||||
if (listenerflag)
|
||||
{
|
||||
listenerpos.x = ((float)sin(t * 0.05f) * 33.0f); // left right pingpong
|
||||
}
|
||||
|
||||
// ********* NOTE ******* READ NEXT COMMENT!!!!!
|
||||
// vel = how far we moved last FRAME (m/f), then time compensate it to SECONDS (m/s).
|
||||
vel.x = (listenerpos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
|
||||
vel.y = (listenerpos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
|
||||
vel.z = (listenerpos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);
|
||||
|
||||
// store pos for next time
|
||||
lastpos = listenerpos;
|
||||
|
||||
result = system->set3DListenerAttributes(0, &listenerpos, &vel, &forward, &up);
|
||||
ERRCHECK(result);
|
||||
|
||||
t += (30 * (1.0f / (float)INTERFACE_UPDATETIME)); // t is just a time value .. it increments in 30m/s steps in this example
|
||||
|
||||
// print out a small visual display
|
||||
{
|
||||
char s[80];
|
||||
|
||||
sprintf(s, "|.......................<1>......................<2>....................|");
|
||||
|
||||
s[(int)(listenerpos.x) + 35] = 'L';
|
||||
printf("%s\r", s);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
Sleep(INTERFACE_UPDATETIME - 1);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound1->release();
|
||||
ERRCHECK(result);
|
||||
result = sound2->release();
|
||||
ERRCHECK(result);
|
||||
result = sound3->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
cdplayer_cpp: main.cpp
|
||||
g++ -O3 -o cdplayer main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
cdplayer_c: main.c
|
||||
g++ -O3 -o cdplayer main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./cdplayer
|
||||
|
||||
clean:
|
||||
rm -f cdplayer
|
Binary file not shown.
|
@ -0,0 +1,236 @@
|
|||
/*===============================================================================================
|
||||
CDPlayer Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play CD tracks digitally and generate a CDDB query
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int cddb_sum(int n)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
ret += (n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long cddb_discid(FMOD_CDTOC *toc)
|
||||
{
|
||||
int i, t, n = 0;
|
||||
|
||||
for (i = 0; i < toc->numtracks; i++)
|
||||
{
|
||||
n += cddb_sum((toc->min[i] * 60) + toc->sec[i]);
|
||||
}
|
||||
|
||||
t = ((toc->min[toc->numtracks] * 60) + toc->sec[toc->numtracks]) - ((toc->min[0] * 60) + toc->sec[0]);
|
||||
|
||||
return ((n % 0xff) << 24 | t << 8 | toc->numtracks);
|
||||
}
|
||||
|
||||
void dump_cddb_query(FMOD_CDTOC *toc)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("cddb query %08x %d", cddb_discid(toc), toc->numtracks);
|
||||
|
||||
for (i = 0; i < toc->numtracks; i++)
|
||||
{
|
||||
printf(" %d", (toc->min[i] * (60 * 75)) + (toc->sec[i] * 75) + toc->frame[i]);
|
||||
}
|
||||
|
||||
printf(" %d\n", (toc->min[toc->numtracks] * 60) + toc->sec[toc->numtracks]);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *cdsound;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key, numtracks, currenttrack = 0;
|
||||
unsigned int version;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Usage: cdplayer <drivepath>\n");
|
||||
printf("Example: cdplayer /dev/cdrom\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("==================================================================\n");
|
||||
printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==================================================================\n\n");
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
|
||||
*/
|
||||
result = FMOD_System_SetStreamBufferSize(system, 64*1024, FMOD_TIMEUNIT_RAWBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateStream(system, argv[1], FMOD_OPENONLY, 0, &cdsound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_GetNumSubSounds(cdsound, &numtracks);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_GetSubSound(cdsound, currenttrack, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
FMOD_TAG tag;
|
||||
|
||||
if (FMOD_Sound_GetTag(cdsound, 0, -1, &tag) != FMOD_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
|
||||
{
|
||||
dump_cddb_query((FMOD_CDTOC *)tag.data);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n========================================\n");
|
||||
printf("Press SPACE to pause\n");
|
||||
printf(" n to skip to next track\n");
|
||||
printf(" ESC to exit\n");
|
||||
printf("========================================\n\n");
|
||||
|
||||
/*
|
||||
Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
|
||||
*/
|
||||
{
|
||||
unsigned int lenms;
|
||||
|
||||
result = FMOD_Sound_GetLength(cdsound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
|
||||
}
|
||||
|
||||
/*
|
||||
Play a CD track
|
||||
*/
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
FMOD_Channel_SetPaused(channel, !paused);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n' :
|
||||
{
|
||||
currenttrack++;
|
||||
if (currenttrack >= numtracks)
|
||||
{
|
||||
currenttrack = 0;
|
||||
}
|
||||
result = FMOD_Sound_GetSubSound(cdsound, currenttrack, &sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms, lenms, percent = 0;
|
||||
FMOD_BOOL playing;
|
||||
FMOD_BOOL paused;
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = FMOD_Sound_GetLength(sound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Track %d/%d : %02d:%02d:%02d/%02d:%02d:%02d : %s\r", currenttrack + 1, numtracks, ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,238 @@
|
|||
/*===============================================================================================
|
||||
CDPlayer Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play CD tracks digitally and generate a CDDB query
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int cddb_sum(int n)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
ret += (n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long cddb_discid(FMOD_CDTOC *toc)
|
||||
{
|
||||
int i, t, n = 0;
|
||||
|
||||
for (i = 0; i < toc->numtracks; i++)
|
||||
{
|
||||
n += cddb_sum((toc->min[i] * 60) + toc->sec[i]);
|
||||
}
|
||||
|
||||
t = ((toc->min[toc->numtracks] * 60) + toc->sec[toc->numtracks]) - ((toc->min[0] * 60) + toc->sec[0]);
|
||||
|
||||
return ((n % 0xff) << 24 | t << 8 | toc->numtracks);
|
||||
}
|
||||
|
||||
void dump_cddb_query(FMOD_CDTOC *toc)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("cddb query %08x %d", cddb_discid(toc), toc->numtracks);
|
||||
|
||||
for (i = 0; i < toc->numtracks; i++)
|
||||
{
|
||||
printf(" %d", (toc->min[i] * (60 * 75)) + (toc->sec[i] * 75) + toc->frame[i]);
|
||||
}
|
||||
|
||||
printf(" %d\n", (toc->min[toc->numtracks] * 60) + toc->sec[toc->numtracks]);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *cdsound;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key, numtracks, currenttrack = 0;
|
||||
unsigned int version;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Usage: cdplayer <drivepath>\n");
|
||||
printf("Example: cdplayer /dev/cdrom\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("==================================================================\n");
|
||||
printf("CDPlayer Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==================================================================\n\n");
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Bump up the file buffer size a bit from the 16k default for CDDA, because it is a slower medium.
|
||||
*/
|
||||
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createStream(argv[1], FMOD_OPENONLY, 0, &cdsound);
|
||||
ERRCHECK(result);
|
||||
result = cdsound->getNumSubSounds(&numtracks);
|
||||
ERRCHECK(result);
|
||||
result = cdsound->getSubSound(currenttrack, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
FMOD_TAG tag;
|
||||
|
||||
if (cdsound->getTag(0, -1, &tag) != FMOD_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_CDTOC)
|
||||
{
|
||||
dump_cddb_query((FMOD_CDTOC *)tag.data);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n========================================\n");
|
||||
printf("Press SPACE to pause\n");
|
||||
printf(" n to skip to next track\n");
|
||||
printf(" ESC to exit\n");
|
||||
printf("========================================\n\n");
|
||||
|
||||
/*
|
||||
Print out length of entire CD. Did you know you can also play 'cdsound' and it will play the whole CD without gaps?
|
||||
*/
|
||||
{
|
||||
unsigned int lenms;
|
||||
|
||||
result = cdsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Total CD length %02d:%02d\n\n", lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Play a CD track
|
||||
*/
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
bool paused;
|
||||
channel->getPaused(&paused);
|
||||
channel->setPaused(!paused);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n' :
|
||||
{
|
||||
currenttrack++;
|
||||
if (currenttrack >= numtracks)
|
||||
{
|
||||
currenttrack = 0;
|
||||
}
|
||||
result = cdsound->getSubSound(currenttrack, &sound);
|
||||
ERRCHECK(result);
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms;
|
||||
unsigned int lenms;
|
||||
bool playing;
|
||||
bool paused;
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Track %d/%d : %02d:%02d:%02d/%02d:%02d:%02d : %s\r", currenttrack + 1, numtracks, ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
channelgroups_cpp: main.cpp
|
||||
g++ -O3 -o channelgroups main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
channelgroups_c: main.c
|
||||
g++ -O3 -o channelgroups main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./channelgroups
|
||||
|
||||
clean:
|
||||
rm -f channelgroups
|
|
@ -0,0 +1,226 @@
|
|||
/*===============================================================================================
|
||||
ChannelGroups Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to put channels into channel groups, so that you can affect a group
|
||||
of channels at a time instead of just one channel at a time.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound[6];
|
||||
FMOD_CHANNEL *channel[6];
|
||||
FMOD_CHANNELGROUP *groupA, *groupB, *masterGroup;
|
||||
FMOD_RESULT result;
|
||||
int key, count;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_LOOP_NORMAL, 0, &sound[0]);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_LOOP_NORMAL, 0, &sound[1]);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_LOOP_NORMAL, 0, &sound[2]);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateSound(system, "../media/c.ogg", FMOD_LOOP_NORMAL, 0, &sound[3]);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateSound(system, "../media/d.ogg", FMOD_LOOP_NORMAL, 0, &sound[4]);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateSound(system, "../media/e.ogg", FMOD_LOOP_NORMAL, 0, &sound[5]);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateChannelGroup(system, "Group A", &groupA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateChannelGroup(system, "Group B", &groupB);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetMasterChannelGroup(system, &masterGroup);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("=======================================================================\n");
|
||||
printf("ChannelGroups Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=======================================================================\n");
|
||||
printf("\n");
|
||||
printf("Group A : drumloop.wav, jaguar.wav, swish.wav\n");
|
||||
printf("Group B : c.ogg, d.ogg, e.ogg\n");
|
||||
printf("\n");
|
||||
printf("Press 'A' to mute/unmute group A\n");
|
||||
printf("Press 'B' to mute/unmute group B\n");
|
||||
printf("Press 'C' to mute/unmute group A and B (master group)\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Instead of being independent, set the group A and B to be children of the master group.
|
||||
*/
|
||||
result = FMOD_ChannelGroup_AddGroup(masterGroup, groupA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_ChannelGroup_AddGroup(masterGroup, groupB);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Start all the sounds!
|
||||
*/
|
||||
for (count = 0; count < 6; count++)
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound[count], TRUE, &channel[count]);
|
||||
ERRCHECK(result);
|
||||
if (count < 3)
|
||||
{
|
||||
result = FMOD_Channel_SetChannelGroup(channel[count], groupA);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_Channel_SetChannelGroup(channel[count], groupB);
|
||||
}
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_SetPaused(channel[count], FALSE);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Change the volume of each group, just because we can! (And makes it less of a loud noise).
|
||||
*/
|
||||
result = FMOD_ChannelGroup_SetVolume(groupA, 0.5f);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_ChannelGroup_SetVolume(groupB, 0.5f);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'a' :
|
||||
case 'A' :
|
||||
{
|
||||
static int mute = TRUE;
|
||||
|
||||
FMOD_ChannelGroup_SetMute(groupA, mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
case 'b' :
|
||||
case 'B' :
|
||||
{
|
||||
static int mute = TRUE;
|
||||
|
||||
FMOD_ChannelGroup_SetMute(groupB, mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
case 'c' :
|
||||
case 'C' :
|
||||
{
|
||||
static int mute = TRUE;
|
||||
|
||||
FMOD_ChannelGroup_SetMute(masterGroup, mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
int channelsplaying = 0;
|
||||
|
||||
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
|
||||
|
||||
printf("Channels Playing %2d\r", channelsplaying);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
A little fade out. (over 2 seconds)
|
||||
*/
|
||||
printf("Goodbye!\n");
|
||||
{
|
||||
float pitch = 1.0f;
|
||||
float vol = 1.0f;
|
||||
|
||||
for (count = 0; count < 200; count++)
|
||||
{
|
||||
FMOD_ChannelGroup_SetPitch(masterGroup, pitch);
|
||||
FMOD_ChannelGroup_SetVolume(masterGroup, vol);
|
||||
|
||||
vol -= (1.0f / 200.0f);
|
||||
pitch -= (0.5f / 200.0f);
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
for (count = 0; count < 6; count++)
|
||||
{
|
||||
result = FMOD_Sound_Release(sound[count]);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_ChannelGroup_Release(groupA);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_ChannelGroup_Release(groupB);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
/*===============================================================================================
|
||||
ChannelGroups Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to put channels into channel groups, so that you can affect a group
|
||||
of channels at a time instead of just one channel at a time.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound[6];
|
||||
FMOD::Channel *channel[6];
|
||||
FMOD::ChannelGroup *groupA, *groupB, *masterGroup;
|
||||
FMOD_RESULT result;
|
||||
int key, count;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_LOOP_NORMAL, 0, &sound[0]);
|
||||
ERRCHECK(result);
|
||||
result = system->createSound("../media/jaguar.wav", FMOD_LOOP_NORMAL, 0, &sound[1]);
|
||||
ERRCHECK(result);
|
||||
result = system->createSound("../media/swish.wav", FMOD_LOOP_NORMAL, 0, &sound[2]);
|
||||
ERRCHECK(result);
|
||||
result = system->createSound("../media/c.ogg", FMOD_LOOP_NORMAL, 0, &sound[3]);
|
||||
ERRCHECK(result);
|
||||
result = system->createSound("../media/d.ogg", FMOD_LOOP_NORMAL, 0, &sound[4]);
|
||||
ERRCHECK(result);
|
||||
result = system->createSound("../media/e.ogg", FMOD_LOOP_NORMAL, 0, &sound[5]);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createChannelGroup("Group A", &groupA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createChannelGroup("Group B", &groupB);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getMasterChannelGroup(&masterGroup);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("=======================================================================\n");
|
||||
printf("ChannelGroups Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=======================================================================\n");
|
||||
printf("\n");
|
||||
printf("Group A : drumloop.wav, jaguar.wav, swish.wav\n");
|
||||
printf("Group B : c.ogg, d.ogg, e.ogg\n");
|
||||
printf("\n");
|
||||
printf("Press 'A' to mute/unmute group A\n");
|
||||
printf("Press 'B' to mute/unmute group B\n");
|
||||
printf("Press 'C' to mute/unmute group A and B (master group)\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Instead of being independent, set the group A and B to be children of the master group.
|
||||
*/
|
||||
result = masterGroup->addGroup(groupA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = masterGroup->addGroup(groupB);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Start all the sounds!
|
||||
*/
|
||||
for (count = 0; count < 6; count++)
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound[count], true, &channel[count]);
|
||||
ERRCHECK(result);
|
||||
if (count < 3)
|
||||
{
|
||||
result = channel[count]->setChannelGroup(groupA);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = channel[count]->setChannelGroup(groupB);
|
||||
}
|
||||
ERRCHECK(result);
|
||||
result = channel[count]->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Change the volume of each group, just because we can! (And makes it less noise).
|
||||
*/
|
||||
result = groupA->setVolume(0.5f);
|
||||
ERRCHECK(result);
|
||||
result = groupB->setVolume(0.5f);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'a' :
|
||||
case 'A' :
|
||||
{
|
||||
static bool mute = true;
|
||||
|
||||
groupA->setMute(mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
case 'b' :
|
||||
case 'B' :
|
||||
{
|
||||
static bool mute = true;
|
||||
|
||||
groupB->setMute(mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
case 'c' :
|
||||
case 'C' :
|
||||
{
|
||||
static bool mute = true;
|
||||
|
||||
masterGroup->setMute(mute);
|
||||
|
||||
mute = !mute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
int channelsplaying = 0;
|
||||
|
||||
system->getChannelsPlaying(&channelsplaying);
|
||||
|
||||
printf("Channels Playing %2d\r", channelsplaying);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
A little fade out. (over 2 seconds)
|
||||
*/
|
||||
printf("Goodbye!\n");
|
||||
{
|
||||
float pitch = 1.0f;
|
||||
float vol = 1.0f;
|
||||
|
||||
for (count = 0; count < 200; count++)
|
||||
{
|
||||
masterGroup->setPitch(pitch);
|
||||
masterGroup->setVolume(vol);
|
||||
|
||||
vol -= (1.0f / 200.0f);
|
||||
pitch -= (0.5f / 200.0f);
|
||||
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
for (count = 0; count < 6; count++)
|
||||
{
|
||||
result = sound[count]->release();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = groupA->release();
|
||||
ERRCHECK(result);
|
||||
result = groupB->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
#if !defined(WINCOMPAT_INCLUDED) && !defined(PLATFORM_WINDOWS) && !defined(WIN32) && !defined(WINDOWS) && !defined(__WIN32__)
|
||||
#define WINCOMPAT_INCLUDED
|
||||
|
||||
/**
|
||||
*
|
||||
* Author: Magnus Naeslund (mag@fbab.net, mag@bahnhof.se)
|
||||
* (c) 2000 Magnus Naeslund, all rights reserved
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define _kbhit kbhit
|
||||
#define _getch getch
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
|
||||
#define Sleep(x) usleep((x)*1000)
|
||||
|
||||
static int inited=0;
|
||||
static struct termios ori;
|
||||
|
||||
static void tcatexit(){
|
||||
tcsetattr(0,TCSANOW,&ori);
|
||||
}
|
||||
|
||||
static void init_terminal(){
|
||||
struct termios t;
|
||||
tcgetattr(0,&t);
|
||||
tcgetattr(0,&ori);
|
||||
t.c_lflag &= ~(ICANON);
|
||||
t.c_lflag &= ~(ECHO);
|
||||
tcsetattr(0,TCSANOW,&t);
|
||||
atexit(tcatexit);
|
||||
}
|
||||
|
||||
static inline int kbhit(){
|
||||
fd_set rfds;
|
||||
struct timeval tv;
|
||||
|
||||
if (!inited){
|
||||
inited=1;
|
||||
init_terminal();
|
||||
}
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(0, &rfds);
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 10*1000;
|
||||
return select(1, &rfds, NULL, NULL, &tv)>0;
|
||||
}
|
||||
|
||||
static inline int getch(){
|
||||
fd_set rfds;
|
||||
|
||||
if (!inited){
|
||||
inited=1;
|
||||
init_terminal();
|
||||
}
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(0, &rfds);
|
||||
if (select(1, &rfds, NULL, NULL, NULL)>0)
|
||||
return getchar();
|
||||
else{
|
||||
printf("wincompat.h: select() on fd 0 failed\n");
|
||||
return 0xDeadBeef;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
dsp_custom_cpp: main.cpp
|
||||
g++ -O3 -o dsp_custom main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
dsp_custom_c: main.c
|
||||
g++ -O3 -o dsp_custom main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./dsp_custom
|
||||
|
||||
clean:
|
||||
rm -f dsp_custom
|
|
@ -0,0 +1,185 @@
|
|||
/*===============================================================================================
|
||||
Custom DSP Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to add a user created DSP callback to process audio data.
|
||||
A read callback is generated at runtime, and can be added anywhere in the DSP network.
|
||||
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FMOD_RESULT F_CALLBACK myDSPCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels)
|
||||
{
|
||||
unsigned int count, userdata;
|
||||
int count2;
|
||||
char name[256];
|
||||
FMOD_DSP *thisdsp = dsp_state->instance;
|
||||
|
||||
/*
|
||||
This redundant call just shows using the instance parameter of FMOD_DSP_STATE and using it to
|
||||
call a DSP information function.
|
||||
*/
|
||||
FMOD_DSP_GetInfo(thisdsp, name, 0, 0, 0, 0);
|
||||
|
||||
FMOD_DSP_GetUserData(thisdsp, (void **)&userdata);
|
||||
|
||||
/*
|
||||
This loop assumes inchannels = outchannels, which it will be if the DSP is created with '0'
|
||||
as the number of channels in FMOD_DSP_DESCRIPTION.
|
||||
Specifying an actual channel count will mean you have to take care of any number of channels coming in,
|
||||
but outputting the number of channels specified. Generally it is best to keep the channel
|
||||
count at 0 for maximum compatibility.
|
||||
*/
|
||||
for (count = 0; count < length; count++)
|
||||
{
|
||||
/*
|
||||
Feel free to unroll this.
|
||||
*/
|
||||
for (count2 = 0; count2 < outchannels; count2++)
|
||||
{
|
||||
/*
|
||||
This DSP filter just halves the volume!
|
||||
Input is modified, and sent to output.
|
||||
*/
|
||||
outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2] * 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel;
|
||||
FMOD_DSP *mydsp;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
float pan = 0;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===============================================================================\n");
|
||||
printf("Custom DSP example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===============================================================================\n");
|
||||
printf("Press 'f' to activate, deactivate user filter\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create the DSP effects.
|
||||
*/
|
||||
{
|
||||
FMOD_DSP_DESCRIPTION dspdesc;
|
||||
|
||||
memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION));
|
||||
|
||||
strcpy(dspdesc.name, "My first DSP unit");
|
||||
dspdesc.channels = 0; // 0 = whatever comes in, else specify.
|
||||
dspdesc.read = myDSPCallback;
|
||||
dspdesc.userdata = (void *)0x12345678;
|
||||
|
||||
result = FMOD_System_CreateDSP(system, &dspdesc, &mydsp);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Inactive by default.
|
||||
*/
|
||||
FMOD_DSP_SetBypass(mydsp, TRUE);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
result = FMOD_System_AddDSP(system, mydsp, 0);
|
||||
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'f' :
|
||||
case 'F' :
|
||||
{
|
||||
static int active = FALSE;
|
||||
|
||||
FMOD_DSP_SetBypass(mydsp, active);
|
||||
|
||||
active = !active;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_Release(mydsp);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
/*===============================================================================================
|
||||
Custom DSP Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to add a user created DSP callback to process audio data.
|
||||
A read callback is generated at runtime, and can be added anywhere in the DSP network.
|
||||
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FMOD_RESULT F_CALLBACK myDSPCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels)
|
||||
{
|
||||
unsigned int count, userdata;
|
||||
int count2;
|
||||
char name[256];
|
||||
FMOD::DSP *thisdsp = (FMOD::DSP *)dsp_state->instance;
|
||||
|
||||
/*
|
||||
This redundant call just shows using the instance parameter of FMOD_DSP_STATE and using it to
|
||||
call a DSP information function.
|
||||
*/
|
||||
thisdsp->getInfo(name, 0, 0, 0, 0);
|
||||
|
||||
thisdsp->getUserData((void **)&userdata);
|
||||
|
||||
/*
|
||||
This loop assumes inchannels = outchannels, which it will be if the DSP is created with '0'
|
||||
as the number of channels in FMOD_DSP_DESCRIPTION.
|
||||
Specifying an actual channel count will mean you have to take care of any number of channels coming in,
|
||||
but outputting the number of channels specified. Generally it is best to keep the channel
|
||||
count at 0 for maximum compatibility.
|
||||
*/
|
||||
for (count = 0; count < length; count++)
|
||||
{
|
||||
/*
|
||||
Feel free to unroll this.
|
||||
*/
|
||||
for (count2 = 0; count2 < outchannels; count2++)
|
||||
{
|
||||
/*
|
||||
This DSP filter just halves the volume!
|
||||
Input is modified, and sent to output.
|
||||
*/
|
||||
outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2] * 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel;
|
||||
FMOD::DSP *mydsp;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
float pan = 0;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("Custom DSP example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n");
|
||||
printf("Press 'f' to activate, deactivate user filter\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create the DSP effects.
|
||||
*/
|
||||
{
|
||||
FMOD_DSP_DESCRIPTION dspdesc;
|
||||
|
||||
memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION));
|
||||
|
||||
strcpy(dspdesc.name, "My first DSP unit");
|
||||
dspdesc.channels = 0; // 0 = whatever comes in, else specify.
|
||||
dspdesc.read = myDSPCallback;
|
||||
dspdesc.userdata = (void *)0x12345678;
|
||||
|
||||
result = system->createDSP(&dspdesc, &mydsp);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
Inactive by default.
|
||||
*/
|
||||
mydsp->setBypass(true);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
result = system->addDSP(mydsp, 0);
|
||||
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'f' :
|
||||
case 'F' :
|
||||
{
|
||||
static bool active = false;
|
||||
|
||||
mydsp->setBypass(active);
|
||||
|
||||
active = !active;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = mydsp->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
dsp_effectperspeaker_cpp: main.cpp
|
||||
g++ -O3 -o dsp_effectperspeaker main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
dsp_effectperspeaker_c: main.c
|
||||
g++ -O3 -o dsp_effectperspeaker main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./dsp_effectperspeaker
|
||||
|
||||
clean:
|
||||
rm -f dsp_effectperspeaker
|
|
@ -0,0 +1,268 @@
|
|||
/*===============================================================================================
|
||||
DSP Effect per speaker Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to manipulate a DSP network and as an example, creates 2 dsp effects,
|
||||
and splits a single sound into 2 audio paths, which it then filters seperately.
|
||||
To only have each audio path come out of one speaker each, FMOD_DSPConnection_setLevels is used just
|
||||
before the 2 branches merge back together again.
|
||||
|
||||
For more speakers:
|
||||
1. Use FMOD_System_SetSpeakerMode or FMOD_System_SetOutputFormat.
|
||||
2. Create more effects, currently 2 for stereo (reverb and chorus), create one per speaker.
|
||||
3. Under the 'Now connect the 2 effects to channeldsp head.' section, connect the extra effects
|
||||
by duplicating the code more times.
|
||||
4. Filter each effect to each speaker by calling FMOD_DSP_SetInputLevels. Expand the existing code
|
||||
by extending the level arrays from 2 to the number of speakers you require, and change the
|
||||
numlevels parameter in FMOD_DSP_SetInputLevels from 2 to the correct number accordingly.
|
||||
|
||||
===============================================================================================*/
|
||||
#include "../common/wincompat.h"
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel;
|
||||
FMOD_DSP *dsplowpass, *dspchorus, *dsphead, *dspchannelmixer;
|
||||
FMOD_DSPCONNECTION *dsplowpassconnection, *dspchorusconnection;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
float pan = 0;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===============================================================================\n");
|
||||
printf("DSP Effect per speaker example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===============================================================================\n");
|
||||
printf("Press 'L' to toggle reverb on/off on left speaker only\n");
|
||||
printf("Press 'R' to toggle chorus on/off on right speaker only\n");
|
||||
printf("Press '[' to pan sound left\n");
|
||||
printf("Press ']' to pan sound right\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create the DSP effects.
|
||||
*/
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_REVERB, &dsplowpass);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_CHORUS, &dspchorus);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Connect up the DSP network
|
||||
*/
|
||||
|
||||
/*
|
||||
When a sound is played, a subnetwork is set up in the DSP network which looks like this.
|
||||
Wavetable is the drumloop sound, and it feeds its data from right to left.
|
||||
|
||||
[DSPHEAD]<------------[DSPCHANNELMIXER]
|
||||
*/
|
||||
result = FMOD_System_GetDSPHead(system, &dsphead);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_GetInput(dsphead, 0, &dspchannelmixer, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now disconnect channeldsp head from wavetable to look like this.
|
||||
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
*/
|
||||
result = FMOD_DSP_DisconnectFrom(dsphead, dspchannelmixer);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now connect the 2 effects to channeldsp head.
|
||||
Store the 2 connections this makes so we can set their speakerlevels later.
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
result = FMOD_DSP_AddInput(dsphead, dsplowpass, &dsplowpassconnection); /* x = dsplowpassconnection */
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSP_AddInput(dsphead, dspchorus, &dspchorusconnection); /* y = dspchorusconnection */
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now connect the wavetable to the 2 effects
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x \
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y /
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
result = FMOD_DSP_AddInput(dsplowpass, dspchannelmixer, NULL); /* Null for connection - we dont care about it. */
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSP_AddInput(dspchorus, dspchannelmixer, NULL); /* Null for connection - we dont care about it. */
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now the drumloop will be twice as loud, because it is being split into 2, then recombined at the end.
|
||||
What we really want is to only feed the dspchannelmixer->dsplowpass through the left speaker, and
|
||||
dspchannelmixer->dspchorus to the right speaker.
|
||||
We can do that simply by setting the pan, or speaker levels of the connections.
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x=1,0 \
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y=0,1 /
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
{
|
||||
float leftinputon[2] = { 1.0f, 0.0f };
|
||||
float rightinputon[2] = { 0.0f, 1.0f };
|
||||
float inputsoff[2] = { 0.0f, 0.0f };
|
||||
|
||||
result = FMOD_DSPConnection_SetLevels(dsplowpassconnection, FMOD_SPEAKER_FRONT_LEFT, leftinputon, 2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSPConnection_SetLevels(dsplowpassconnection, FMOD_SPEAKER_FRONT_RIGHT, inputsoff, 2);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSPConnection_SetLevels(dspchorusconnection, FMOD_SPEAKER_FRONT_LEFT, inputsoff, 2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSPConnection_SetLevels(dspchorusconnection, FMOD_SPEAKER_FRONT_RIGHT, rightinputon, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_DSP_SetBypass(dsplowpass, TRUE);
|
||||
result = FMOD_DSP_SetBypass(dspchorus, TRUE);
|
||||
|
||||
result = FMOD_DSP_SetActive(dsplowpass, TRUE);
|
||||
result = FMOD_DSP_SetActive(dspchorus, TRUE);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'l' :
|
||||
case 'L' :
|
||||
{
|
||||
static int reverb = FALSE;
|
||||
|
||||
FMOD_DSP_SetBypass(dsplowpass, reverb);
|
||||
|
||||
reverb = !reverb;
|
||||
break;
|
||||
}
|
||||
case 'r' :
|
||||
case 'R' :
|
||||
{
|
||||
static int chorus = FALSE;
|
||||
|
||||
FMOD_DSP_SetBypass(dspchorus, chorus);
|
||||
|
||||
chorus = !chorus;
|
||||
break;
|
||||
}
|
||||
case '[' :
|
||||
{
|
||||
FMOD_Channel_GetPan(channel, &pan);
|
||||
pan -= 0.1f;
|
||||
if (pan < -1)
|
||||
{
|
||||
pan = -1;
|
||||
}
|
||||
FMOD_Channel_SetPan(channel, pan);
|
||||
break;
|
||||
}
|
||||
case ']' :
|
||||
{
|
||||
FMOD_Channel_GetPan(channel, &pan);
|
||||
pan += 0.1f;
|
||||
if (pan > 1)
|
||||
{
|
||||
pan = 1;
|
||||
}
|
||||
FMOD_Channel_SetPan(channel, pan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
int channelsplaying = 0;
|
||||
|
||||
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
|
||||
|
||||
printf("Channels Playing %2d : Pan = %.02f\r", channelsplaying, pan);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_Release(dsplowpass);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSP_Release(dspchorus);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/*===============================================================================================
|
||||
DSP Effect per speaker Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to manipulate a DSP network and as an example, creates 2 dsp effects,
|
||||
and splits a single sound into 2 audio paths, which it then filters seperately.
|
||||
To only have each audio path come out of one speaker each, DSPConnection::setLevels is used just
|
||||
before the 2 branches merge back together again.
|
||||
|
||||
For more speakers:
|
||||
1. Use System::setSpeakerMode or System::setOutputFormat.
|
||||
2. Create more effects, currently 2 for stereo (lowpass and chorus), create one per speaker.
|
||||
3. Under the 'Now connect the 2 effects to channeldsp head.' section, connect the extra effects
|
||||
by duplicating the code more times.
|
||||
4. Filter each effect to each speaker by calling DSP::setInputLevels. Expand the existing code
|
||||
by extending the level arrays from 2 to the number of speakers you require, and change the
|
||||
numlevels parameter in DSP::setInputLevels from 2 to the correct number accordingly.
|
||||
|
||||
===============================================================================================*/
|
||||
#include "../common/wincompat.h"
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel;
|
||||
FMOD::DSP *dsplowpass, *dspchorus, *dsphead, *dspchannelmixer;
|
||||
FMOD::DSPConnection *dsplowpassconnection, *dspchorusconnection;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
float pan = 0;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE | FMOD_LOOP_NORMAL, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===============================================================================\n");
|
||||
printf("DSP effect per speaker example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===============================================================================\n");
|
||||
printf("Press 'L' to toggle lowpass on/off on left speaker only\n");
|
||||
printf("Press 'R' to toggle chorus on/off on right speaker only\n");
|
||||
printf("Press '[' to pan sound left\n");
|
||||
printf("Press ']' to pan sound right\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create the DSP effects.
|
||||
*/
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &dsplowpass);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_CHORUS, &dspchorus);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Connect up the DSP network
|
||||
*/
|
||||
|
||||
/*
|
||||
When a sound is played, a subnetwork is set up in the DSP network which looks like this.
|
||||
Wavetable is the drumloop sound, and it feeds its data from right to left.
|
||||
|
||||
[DSPHEAD]<------------[DSPCHANNELMIXER]
|
||||
*/
|
||||
result = system->getDSPHead(&dsphead);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dsphead->getInput(0, &dspchannelmixer, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now disconnect channeldsp head from wavetable to look like this.
|
||||
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
*/
|
||||
result = dsphead->disconnectFrom(dspchannelmixer);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now connect the 2 effects to channeldsp head.
|
||||
Store the 2 connections this makes so we can set their speakerlevels later.
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
result = dsphead->addInput(dsplowpass, &dsplowpassconnection); /* x = dsplowpassconnection */
|
||||
ERRCHECK(result);
|
||||
result = dsphead->addInput(dspchorus, &dspchorusconnection); /* y = dspchorusconnection */
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now connect the wavetable to the 2 effects
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x \
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y /
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
result = dsplowpass->addInput(dspchannelmixer, 0); /* Null for connection - we dont care about it. */
|
||||
ERRCHECK(result);
|
||||
result = dspchorus->addInput(dspchannelmixer, 0); /* Null for connection - we dont care about it. */
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Now the drumloop will be twice as loud, because it is being split into 2, then recombined at the end.
|
||||
What we really want is to only feed the dspchannelmixer->dsplowpass through the left speaker, and
|
||||
dspchannelmixer->dspchorus to the right speaker.
|
||||
We can do that simply by setting the pan, or speaker levels of the connections.
|
||||
|
||||
[DSPLOWPASS]
|
||||
/x=1,0 \
|
||||
[DSPHEAD] [DSPCHANNELMIXER]
|
||||
\y=0,1 /
|
||||
[DSPCHORUS]
|
||||
*/
|
||||
{
|
||||
float leftinputon[2] = { 1.0f, 0.0f };
|
||||
float rightinputon[2] = { 0.0f, 1.0f };
|
||||
float inputsoff[2] = { 0.0f, 0.0f };
|
||||
|
||||
result = dsplowpassconnection->setLevels(FMOD_SPEAKER_FRONT_LEFT, leftinputon, 2);
|
||||
ERRCHECK(result);
|
||||
result = dsplowpassconnection->setLevels(FMOD_SPEAKER_FRONT_RIGHT, inputsoff, 2);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dspchorusconnection->setLevels(FMOD_SPEAKER_FRONT_LEFT, inputsoff, 2);
|
||||
ERRCHECK(result);
|
||||
result = dspchorusconnection->setLevels(FMOD_SPEAKER_FRONT_RIGHT, rightinputon, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = dsplowpass->setBypass(true);
|
||||
result = dspchorus->setBypass(true);
|
||||
|
||||
result = dsplowpass->setActive(true);
|
||||
result = dspchorus->setActive(true);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'l' :
|
||||
case 'L' :
|
||||
{
|
||||
static bool lowpass = false;
|
||||
|
||||
dsplowpass->setBypass(lowpass);
|
||||
|
||||
lowpass = !lowpass;
|
||||
break;
|
||||
}
|
||||
case 'r' :
|
||||
case 'R' :
|
||||
{
|
||||
static bool chorus = false;
|
||||
|
||||
dspchorus->setBypass(chorus);
|
||||
|
||||
chorus = !chorus;
|
||||
break;
|
||||
}
|
||||
case '[' :
|
||||
{
|
||||
channel->getPan(&pan);
|
||||
pan -= 0.1f;
|
||||
if (pan < -1)
|
||||
{
|
||||
pan = -1;
|
||||
}
|
||||
channel->setPan(pan);
|
||||
break;
|
||||
}
|
||||
case ']' :
|
||||
{
|
||||
channel->getPan(&pan);
|
||||
pan += 0.1f;
|
||||
if (pan > 1)
|
||||
{
|
||||
pan = 1;
|
||||
}
|
||||
channel->setPan(pan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
int channelsplaying = 0;
|
||||
|
||||
system->getChannelsPlaying(&channelsplaying);
|
||||
|
||||
printf("Channels Playing %2d : Pan = %.02f\r", channelsplaying, pan);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dsplowpass->release();
|
||||
ERRCHECK(result);
|
||||
result = dspchorus->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
effects_cpp: main.cpp
|
||||
g++ -O3 -o effects main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
effects_c: main.c
|
||||
g++ -O3 -o effects main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./effects
|
||||
|
||||
clean:
|
||||
rm -f effects
|
Binary file not shown.
|
@ -0,0 +1,333 @@
|
|||
/*===============================================================================================
|
||||
Effects Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to apply some of the built in software effects to sounds.
|
||||
This example filters the global mix. All software sounds played here would be filtered in the
|
||||
same way.
|
||||
To filter per channel, and not have other channels affected, simply replace FMOD_System_AddDSP with
|
||||
FMOD_Channel_AddDSP.
|
||||
Note in this example you don't have to add and remove units each time, you could simply add them
|
||||
all at the start then use FMOD_DSP_SetActive to toggle them on and off.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_dsp.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system = 0;
|
||||
FMOD_SOUND *sound = 0;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_DSP *dsplowpass = 0;
|
||||
FMOD_DSP *dsphighpass = 0;
|
||||
FMOD_DSP *dspecho = 0;
|
||||
FMOD_DSP *dspflange = 0;
|
||||
FMOD_DSP *dspdistortion = 0;
|
||||
FMOD_DSP *dspchorus = 0;
|
||||
FMOD_DSP *dspparameq = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("=================================================================\n");
|
||||
printf("Effects Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press SPACE to paused/unpause sound.\n");
|
||||
printf("Press 1 to toggle dsplowpass effect.\n");
|
||||
printf("Press 2 to toggle dsphighpass effect.\n");
|
||||
printf("Press 3 to toggle dspecho effect.\n");
|
||||
printf("Press 4 to toggle dspflange effect.\n");
|
||||
printf("Press 5 to toggle dspdistortion effect.\n");
|
||||
printf("Press 6 to toggle dspchorus effect.\n");
|
||||
printf("Press 7 to toggle dspparameq effect.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create some effects to play with.
|
||||
*/
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_LOWPASS, &dsplowpass);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_HIGHPASS, &dsphighpass);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_ECHO, &dspecho);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_FLANGE, &dspflange);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_DISTORTION, &dspdistortion);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_CHORUS, &dspchorus);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_PARAMEQ, &dspparameq);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
int paused;
|
||||
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
ERRCHECK(result);
|
||||
|
||||
paused = !paused;
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, paused);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '1' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dsplowpass, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dsplowpass);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dsplowpass, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dsphighpass, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dsphighpass);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dsphighpass, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dspecho, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dspecho);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dspecho, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_SetParameter(dspecho, FMOD_DSP_ECHO_DELAY, 50.0f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dspflange, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dspflange);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dspflange, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dspdistortion, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dspdistortion);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dspdistortion, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_SetParameter(dspdistortion, FMOD_DSP_DISTORTION_LEVEL, 0.8f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '6' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dspchorus, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dspchorus);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dspchorus, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '7' :
|
||||
{
|
||||
int active;
|
||||
|
||||
result = FMOD_DSP_GetActive(dspparameq, &active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = FMOD_DSP_Remove(dspparameq);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = FMOD_System_AddDSP(system, dspparameq, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_DSP_SetParameter(dspparameq, FMOD_DSP_PARAMEQ_CENTER, 5000.0f);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSP_SetParameter(dspparameq, FMOD_DSP_PARAMEQ_GAIN, 0.0f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
int paused = 0;
|
||||
int dsplowpass_active;
|
||||
int dsphighpass_active;
|
||||
int dspecho_active;
|
||||
int dspflange_active;
|
||||
int dspdistortion_active;
|
||||
int dspchorus_active;
|
||||
int dspparameq_active;
|
||||
|
||||
FMOD_DSP_GetActive(dsplowpass , &dsplowpass_active);
|
||||
FMOD_DSP_GetActive(dsphighpass , &dsphighpass_active);
|
||||
FMOD_DSP_GetActive(dspecho , &dspecho_active);
|
||||
FMOD_DSP_GetActive(dspflange , &dspflange_active);
|
||||
FMOD_DSP_GetActive(dspdistortion, &dspdistortion_active);
|
||||
FMOD_DSP_GetActive(dspchorus , &dspchorus_active);
|
||||
FMOD_DSP_GetActive(dspparameq , &dspparameq_active);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s : lowpass[%c] highpass[%c] echo[%c] flange[%c] dist[%c] chorus[%c] parameq[%c]\r",
|
||||
paused ? "Paused " : "Playing",
|
||||
dsplowpass_active ? 'x' : ' ',
|
||||
dsphighpass_active ? 'x' : ' ',
|
||||
dspecho_active ? 'x' : ' ',
|
||||
dspflange_active ? 'x' : ' ',
|
||||
dspdistortion_active ? 'x' : ' ',
|
||||
dspchorus_active ? 'x' : ' ',
|
||||
dspparameq_active ? 'x' : ' ');
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,333 @@
|
|||
/*===============================================================================================
|
||||
Effects Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to apply some of the built in software effects to sounds.
|
||||
This example filters the global mix. All software sounds played here would be filtered in the
|
||||
same way.
|
||||
To filter per channel, and not have other channels affected, simply replace system->addDSP with
|
||||
channel->addDSP.
|
||||
Note in this example you don't have to add and remove units each time, you could simply add them
|
||||
all at the start then use DSP::setActive to toggle them on and off.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_dsp.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system = 0;
|
||||
FMOD::Sound *sound = 0;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD::DSP *dsplowpass = 0;
|
||||
FMOD::DSP *dsphighpass = 0;
|
||||
FMOD::DSP *dspecho = 0;
|
||||
FMOD::DSP *dspflange = 0;
|
||||
FMOD::DSP *dspdistortion = 0;
|
||||
FMOD::DSP *dspchorus = 0;
|
||||
FMOD::DSP *dspparameq = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("=================================================================\n");
|
||||
printf("Effects Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press SPACE to paused/unpause sound.\n");
|
||||
printf("Press 1 to toggle dsplowpass effect.\n");
|
||||
printf("Press 2 to toggle dsphighpass effect.\n");
|
||||
printf("Press 3 to toggle dspecho effect.\n");
|
||||
printf("Press 4 to toggle dspflange effect.\n");
|
||||
printf("Press 5 to toggle dspdistortion effect.\n");
|
||||
printf("Press 6 to toggle dspchorus effect.\n");
|
||||
printf("Press 7 to toggle dspparameq effect.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create some effects to play with.
|
||||
*/
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &dsplowpass);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_HIGHPASS, &dsphighpass);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_ECHO, &dspecho);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_FLANGE, &dspflange);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_DISTORTION, &dspdistortion);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_CHORUS, &dspchorus);
|
||||
ERRCHECK(result);
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_PARAMEQ, &dspparameq);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
bool paused;
|
||||
|
||||
channel->getPaused(&paused);
|
||||
ERRCHECK(result);
|
||||
|
||||
paused = !paused;
|
||||
|
||||
result = channel->setPaused(paused);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '1' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dsplowpass->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dsplowpass->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dsplowpass, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dsphighpass->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dsphighpass->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dsphighpass, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dspecho->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dspecho->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dspecho, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dspecho->setParameter(FMOD_DSP_ECHO_DELAY, 50.0f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dspflange->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dspflange->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dspflange, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dspdistortion->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dspdistortion->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dspdistortion, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dspdistortion->setParameter(FMOD_DSP_DISTORTION_LEVEL, 0.8f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '6' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dspchorus->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dspchorus->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dspchorus, 0);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '7' :
|
||||
{
|
||||
bool active;
|
||||
|
||||
result = dspparameq->getActive(&active);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (active)
|
||||
{
|
||||
result = dspparameq->remove();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = system->addDSP(dspparameq, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = dspparameq->setParameter(FMOD_DSP_PARAMEQ_CENTER, 5000.0f);
|
||||
ERRCHECK(result);
|
||||
result = dspparameq->setParameter(FMOD_DSP_PARAMEQ_GAIN, 0.0f);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
bool paused = 0;
|
||||
bool dsplowpass_active;
|
||||
bool dsphighpass_active;
|
||||
bool dspecho_active;
|
||||
bool dspflange_active;
|
||||
bool dspdistortion_active;
|
||||
bool dspchorus_active;
|
||||
bool dspparameq_active;
|
||||
|
||||
dsplowpass ->getActive(&dsplowpass_active);
|
||||
dsphighpass ->getActive(&dsphighpass_active);
|
||||
dspecho ->getActive(&dspecho_active);
|
||||
dspflange ->getActive(&dspflange_active);
|
||||
dspdistortion->getActive(&dspdistortion_active);
|
||||
dspchorus ->getActive(&dspchorus_active);
|
||||
dspparameq ->getActive(&dspparameq_active);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s : lowpass[%c] highpass[%c] echo[%c] flange[%c] dist[%c] chorus[%c] parameq[%c]\r",
|
||||
paused ? "Paused " : "Playing",
|
||||
dsplowpass_active ? 'x' : ' ',
|
||||
dsphighpass_active ? 'x' : ' ',
|
||||
dspecho_active ? 'x' : ' ',
|
||||
dspflange_active ? 'x' : ' ',
|
||||
dspdistortion_active ? 'x' : ' ',
|
||||
dspchorus_active ? 'x' : ' ',
|
||||
dspparameq_active ? 'x' : ' ');
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
filecallbacks_cpp: main.cpp
|
||||
g++ -O3 -o filecallbacks main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
filecallbacks_c: main.c
|
||||
g++ -O3 -o filecallbacks main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./filecallbacks
|
||||
|
||||
clean:
|
||||
rm -f filecallbacks
|
|
@ -0,0 +1,230 @@
|
|||
/*===============================================================================================
|
||||
File Callbacks Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example is a modified version of the playstream example.
|
||||
It shows the correct way declare and handle fmod file callbacks with System::setFileSystem.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TIPS:
|
||||
|
||||
1. use F_CALLBACK. Do NOT force cast your own function to fmod's callback type.
|
||||
2. return FMOD_ERR_FILE_NOTFOUND in open as required.
|
||||
3. return number of bytes read in read callback. Do not get the size and count
|
||||
around the wrong way in fread for example, this would return 1 instead of the number of bytes read.
|
||||
|
||||
QUESTIONS:
|
||||
|
||||
1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags.
|
||||
Use FMOD_IGNORETAGS in FMOD_System_CreateSound / FMOD_System_CreateStream if you don't like this behaviour.
|
||||
*/
|
||||
|
||||
FMOD_RESULT F_CALLBACK myopen(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
return FMOD_ERR_FILE_NOTFOUND;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*filesize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
*userdata = (void *)0x12345678;
|
||||
*handle = fp;
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myclose(void *handle, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
fclose((FILE *)handle);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myread(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (bytesread)
|
||||
{
|
||||
*bytesread = (int)fread(buffer, 1, sizebytes, (FILE *)handle);
|
||||
|
||||
if (*bytesread < sizebytes)
|
||||
{
|
||||
return FMOD_ERR_FILE_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
fseek((FILE *)handle, pos, SEEK_SET);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_SetFileSystem(system, myopen, myclose, myread, myseek, 0, 0, 2048);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateStream(system, "../media/wave.mp3", FMOD_HARDWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("====================================================================\n");
|
||||
printf("PlayStream Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("====================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press space to pause, Esc to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Play the sound.
|
||||
*/
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
FMOD_Channel_SetPaused(channel, !paused);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms;
|
||||
unsigned int lenms;
|
||||
int playing;
|
||||
int paused;
|
||||
|
||||
FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetLength(sound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,229 @@
|
|||
/*===============================================================================================
|
||||
File Callbacks Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example is a modified version of the playstream example.
|
||||
It shows the correct way declare and handle fmod file callbacks with System::setFileSystem.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TIPS:
|
||||
|
||||
1. use F_CALLBACK. Do NOT force cast your own function to fmod's callback type.
|
||||
2. return FMOD_ERR_FILE_NOTFOUND in open as required.
|
||||
3. return number of bytes read in read callback. Do not get the size and count
|
||||
around the wrong way in fread for example, this would return 1 instead of the number of bytes read.
|
||||
|
||||
QUESTIONS:
|
||||
|
||||
1. Why does fmod seek to the end and read? Because it is looking for ID3V1 tags.
|
||||
Use FMOD_IGNORETAGS in System::createSound / System::createStream if you don't like this behaviour.
|
||||
|
||||
*/
|
||||
|
||||
FMOD_RESULT F_CALLBACK myopen(const char *name, int unicode, unsigned int *filesize, void **handle, void **userdata)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(name, "rb");
|
||||
if (!fp)
|
||||
{
|
||||
return FMOD_ERR_FILE_NOTFOUND;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*filesize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
*userdata = (void *)0x12345678;
|
||||
*handle = fp;
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myclose(void *handle, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
fclose((FILE *)handle);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myread(void *handle, void *buffer, unsigned int sizebytes, unsigned int *bytesread, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (bytesread)
|
||||
{
|
||||
*bytesread = (int)fread(buffer, 1, sizebytes, (FILE *)handle);
|
||||
|
||||
if (*bytesread < sizebytes)
|
||||
{
|
||||
return FMOD_ERR_FILE_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK myseek(void *handle, unsigned int pos, void *userdata)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return FMOD_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
fseek((FILE *)handle, pos, SEEK_SET);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->setFileSystem(myopen, myclose, myread, myseek, 0, 0, 2048);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createStream("../media/wave.mp3", FMOD_HARDWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("========================================================================\n");
|
||||
printf("File Callbacks Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("========================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press space to pause, Esc to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Play the sound.
|
||||
*/
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
bool paused;
|
||||
channel->getPaused(&paused);
|
||||
channel->setPaused(!paused);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms;
|
||||
unsigned int lenms;
|
||||
bool playing;
|
||||
bool paused;
|
||||
|
||||
channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
generatetone_cpp: main.cpp
|
||||
g++ -O3 -o generatetone main.cpp ../../api/lib/libfmodex.so
|
||||
|
||||
generatetone_c: main.c
|
||||
g++ -O3 -o generatetone main.c ../../api/lib/libfmodex.so
|
||||
|
||||
run:
|
||||
./generatetone
|
||||
|
||||
clean:
|
||||
rm -f generatetone
|
|
@ -0,0 +1,230 @@
|
|||
/*===============================================================================================
|
||||
GenerateTone Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how simply play generated tones using FMOD_System_PlayDSP instead of
|
||||
manually connecting and disconnecting DSP units.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_DSP *dsp = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create DSP units for each type of noise we want.
|
||||
*/
|
||||
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_OSCILLATOR, &dsp);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_RATE, 440.0f);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("======================================================================\n");
|
||||
printf("GenerateTone Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("======================================================================\n\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a sine wave\n");
|
||||
printf("Press '2' to play a square wave\n");
|
||||
printf("Press '3' to play a triangle wave\n");
|
||||
printf("Press '4' to play a saw wave\n");
|
||||
printf("Press '5' to play a white noise\n");
|
||||
printf("Press 's' to stop channel\n");
|
||||
printf("\n");
|
||||
printf("Press 'v'/'V' to change channel volume\n");
|
||||
printf("Press 'f'/'F' to change channel frequency\n");
|
||||
printf("Press '['/']' to change channel pan\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
|
||||
|
||||
FMOD_Channel_SetVolume(channel, 0.5f);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 0);
|
||||
ERRCHECK(result);
|
||||
FMOD_Channel_SetPaused(channel, FALSE);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
|
||||
FMOD_Channel_SetVolume(channel, 0.125f);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 1);
|
||||
ERRCHECK(result);
|
||||
FMOD_Channel_SetPaused(channel, FALSE);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
|
||||
FMOD_Channel_SetVolume(channel, 0.5f);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 2);
|
||||
ERRCHECK(result);
|
||||
FMOD_Channel_SetPaused(channel, FALSE);
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
|
||||
FMOD_Channel_SetVolume(channel, 0.125f);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 4);
|
||||
ERRCHECK(result);
|
||||
FMOD_Channel_SetPaused(channel, FALSE);
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
|
||||
FMOD_Channel_SetVolume(channel, 0.25f);
|
||||
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 5);
|
||||
ERRCHECK(result);
|
||||
FMOD_Channel_SetPaused(channel, FALSE);
|
||||
break;
|
||||
}
|
||||
case 's' :
|
||||
{
|
||||
FMOD_Channel_Stop(channel);
|
||||
break;
|
||||
}
|
||||
case 'v' :
|
||||
{
|
||||
float volume;
|
||||
|
||||
FMOD_Channel_GetVolume(channel, &volume);
|
||||
volume -= 0.1f;
|
||||
FMOD_Channel_SetVolume(channel, volume);
|
||||
break;
|
||||
}
|
||||
case 'V' :
|
||||
{
|
||||
float volume;
|
||||
|
||||
FMOD_Channel_GetVolume(channel, &volume);
|
||||
volume += 0.1f;
|
||||
FMOD_Channel_SetVolume(channel, volume);
|
||||
break;
|
||||
}
|
||||
case 'f' :
|
||||
{
|
||||
float frequency;
|
||||
|
||||
FMOD_Channel_GetFrequency(channel, &frequency);
|
||||
frequency -= 500.0f;
|
||||
FMOD_Channel_SetFrequency(channel, frequency);
|
||||
break;
|
||||
}
|
||||
case 'F' :
|
||||
{
|
||||
float frequency;
|
||||
|
||||
FMOD_Channel_GetFrequency(channel, &frequency);
|
||||
frequency += 500.0f;
|
||||
FMOD_Channel_SetFrequency(channel, frequency);
|
||||
break;
|
||||
}
|
||||
case '[' :
|
||||
{
|
||||
float pan;
|
||||
|
||||
FMOD_Channel_GetPan(channel, &pan);
|
||||
pan -= 0.1f;
|
||||
FMOD_Channel_SetPan(channel, pan);
|
||||
break;
|
||||
}
|
||||
case ']' :
|
||||
{
|
||||
float pan;
|
||||
|
||||
FMOD_Channel_GetPan(channel, &pan);
|
||||
pan += 0.1f;
|
||||
FMOD_Channel_SetPan(channel, pan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
float frequency = 0, volume = 0, pan = 0;
|
||||
int playing = FALSE;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD_Channel_GetFrequency(channel, &frequency);
|
||||
FMOD_Channel_GetVolume(channel, &volume);
|
||||
FMOD_Channel_GetPan(channel, &pan);
|
||||
FMOD_Channel_IsPlaying(channel, &playing);
|
||||
}
|
||||
|
||||
printf("Channel %s : Frequency %.1f Volume %.1f Pan %.1f \r", playing ? "playing" : "stopped", frequency, volume, pan);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_DSP_Release(dsp);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
/*===============================================================================================
|
||||
GenerateTone Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how simply play generated tones using FMOD::System::payDSP instead of
|
||||
manually connecting and disconnecting DSP units.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD::DSP *dsp = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create an oscillator DSP unit for the tone.
|
||||
*/
|
||||
result = system->createDSPByType(FMOD_DSP_TYPE_OSCILLATOR, &dsp);
|
||||
ERRCHECK(result);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_RATE, 440.0f);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("======================================================================\n");
|
||||
printf("GenerateTone Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("======================================================================\n\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a sine wave\n");
|
||||
printf("Press '2' to play a square wave\n");
|
||||
printf("Press '3' to play a triangle wave\n");
|
||||
printf("Press '4' to play a saw wave\n");
|
||||
printf("Press '5' to play a white noise\n");
|
||||
printf("Press 's' to stop channel\n");
|
||||
printf("\n");
|
||||
printf("Press 'v'/'V' to change channel volume\n");
|
||||
printf("Press 'f'/'F' to change channel frequency\n");
|
||||
printf("Press '['/']' to change channel pan\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);
|
||||
|
||||
channel->setVolume(0.5f);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 0);
|
||||
ERRCHECK(result);
|
||||
channel->setPaused(false);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);
|
||||
|
||||
channel->setVolume(0.125f);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 1);
|
||||
ERRCHECK(result);
|
||||
channel->setPaused(false);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);
|
||||
|
||||
channel->setVolume(0.5f);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 2);
|
||||
ERRCHECK(result);
|
||||
channel->setPaused(false);
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);
|
||||
|
||||
channel->setVolume(0.125f);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 4);
|
||||
ERRCHECK(result);
|
||||
channel->setPaused(false);
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
result = system->playDSP(FMOD_CHANNEL_REUSE, dsp, true, &channel);
|
||||
|
||||
channel->setVolume(0.25f);
|
||||
result = dsp->setParameter(FMOD_DSP_OSCILLATOR_TYPE, 5);
|
||||
ERRCHECK(result);
|
||||
channel->setPaused(false);
|
||||
break;
|
||||
}
|
||||
case 's' :
|
||||
{
|
||||
channel->stop();
|
||||
break;
|
||||
}
|
||||
case 'v' :
|
||||
{
|
||||
float volume;
|
||||
|
||||
channel->getVolume(&volume);
|
||||
volume -= 0.1f;
|
||||
channel->setVolume(volume);
|
||||
break;
|
||||
}
|
||||
case 'V' :
|
||||
{
|
||||
float volume;
|
||||
|
||||
channel->getVolume(&volume);
|
||||
volume += 0.1f;
|
||||
channel->setVolume(volume);
|
||||
break;
|
||||
}
|
||||
case 'f' :
|
||||
{
|
||||
float frequency;
|
||||
|
||||
channel->getFrequency(&frequency);
|
||||
frequency -= 500.0f;
|
||||
channel->setFrequency(frequency);
|
||||
break;
|
||||
}
|
||||
case 'F' :
|
||||
{
|
||||
float frequency;
|
||||
|
||||
channel->getFrequency(&frequency);
|
||||
frequency += 500.0f;
|
||||
channel->setFrequency(frequency);
|
||||
break;
|
||||
}
|
||||
case '[' :
|
||||
{
|
||||
float pan;
|
||||
|
||||
channel->getPan(&pan);
|
||||
pan -= 0.1f;
|
||||
channel->setPan(pan);
|
||||
break;
|
||||
}
|
||||
case ']' :
|
||||
{
|
||||
float pan;
|
||||
|
||||
channel->getPan(&pan);
|
||||
pan += 0.1f;
|
||||
channel->setPan(pan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
float frequency = 0, volume = 0, pan = 0;
|
||||
bool playing = false;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
channel->getFrequency(&frequency);
|
||||
channel->getVolume(&volume);
|
||||
channel->getPan(&pan);
|
||||
channel->isPlaying(&playing);
|
||||
}
|
||||
|
||||
printf("Channel %s : Frequency %.1f Volume %.1f Pan %.1f \r", playing ? "playing" : "stopped", frequency, volume, pan);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = dsp->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
loadfrommemory_cpp: main.cpp
|
||||
g++ -O3 -o loadfrommemory main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
loadfrommemory_c: main.c
|
||||
g++ -O3 -o loadfrommemory main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./loadfrommemory
|
||||
|
||||
clean:
|
||||
rm -f loadfrommemory
|
|
@ -0,0 +1,219 @@
|
|||
/*===============================================================================================
|
||||
Load from memory example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example is simply a variant of the play sound example, but it loads the data into memory
|
||||
then uses the 'load from memory' feature of System::createSound.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadFileIntoMemory(const char *name, void **buff, int *length)
|
||||
{
|
||||
FILE *fp = fopen(name, "rb");
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*length = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
*buff = malloc(*length);
|
||||
fread(*buff, *length, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound1, *sound2, *sound3;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
void *buff = 0;
|
||||
int length = 0;
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
LoadFileIntoMemory("../media/drumloop.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = FMOD_System_CreateSound(system, (const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &sound1);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
LoadFileIntoMemory("../media/jaguar.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = FMOD_System_CreateSound(system, (const char *)buff, FMOD_SOFTWARE | FMOD_OPENMEMORY, &exinfo, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
LoadFileIntoMemory("../media/swish.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = FMOD_System_CreateSound(system, (const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
printf("==========================================================================\n");
|
||||
printf("Load from memory example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==========================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a mono sound using hardware mixing\n");
|
||||
printf("Press '2' to play a mono sound using software mixing\n");
|
||||
printf("Press '3' to play a stereo sound using hardware mixing\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound3, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
int playing = 0;
|
||||
int paused = 0;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD_SOUND *currentsound = 0;
|
||||
|
||||
result = FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
FMOD_Channel_GetCurrentSound(channel, ¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetLength(sound1, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound3);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
/*===============================================================================================
|
||||
Load from memory example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example is simply a variant of the play sound example, but it loads the data into memory
|
||||
then uses the 'load from memory' feature of System::createSound.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadFileIntoMemory(const char *name, void **buff, int *length)
|
||||
{
|
||||
FILE *fp = fopen(name, "rb");
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*length = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
*buff = malloc(*length);
|
||||
fread(*buff, *length, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound1, *sound2, *sound3;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
void *buff = 0;
|
||||
int length = 0;
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
LoadFileIntoMemory("../media/drumloop.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = system->createSound((const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &sound1);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = sound1->setMode(FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
LoadFileIntoMemory("../media/jaguar.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = system->createSound((const char *)buff, FMOD_SOFTWARE | FMOD_OPENMEMORY, &exinfo, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
LoadFileIntoMemory("../media/swish.wav", &buff, &length);
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.length = length;
|
||||
|
||||
result = system->createSound((const char *)buff, FMOD_HARDWARE | FMOD_OPENMEMORY, &exinfo, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
free(buff); // don't need the original memory any more. Note! If loading as a stream, the memory must stay active so do not free it!
|
||||
|
||||
printf("==========================================================================\n");
|
||||
printf("Load from memory example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==========================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a mono sound using hardware mixing\n");
|
||||
printf("Press '2' to play a mono sound using software mixing\n");
|
||||
printf("Press '3' to play a stereo sound using hardware mixing\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, false, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, false, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound3, false, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
bool playing = 0;
|
||||
bool paused = 0;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD::Sound *currentsound = 0;
|
||||
|
||||
result = channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
channel->getCurrentSound(¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->getChannelsPlaying(&channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound1->release();
|
||||
ERRCHECK(result);
|
||||
result = sound2->release();
|
||||
ERRCHECK(result);
|
||||
result = sound3->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#EXTM3U
|
||||
#EXTINF:11,Unknown - FMOD example wave
|
||||
wave.mp3
|
||||
#EXTINF:1,swish
|
||||
swish.wav
|
||||
#EXTINF:2,stereo
|
||||
stereo.ogg
|
||||
#EXTINF:1,jaguar
|
||||
jaguar.wav
|
||||
#EXTINF:0,drumloop
|
||||
drumloop.wav
|
|
@ -0,0 +1 @@
|
|||
400b6a591c4687406c5b5943181e083952872de7
|
|
@ -0,0 +1,11 @@
|
|||
multiplesoundcard_cpp: main.cpp
|
||||
g++ -O3 -o multiplesoundcard main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
multiplesoundcard_c: main.c
|
||||
g++ -O3 -o multiplesoundcard main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./multiplesoundcard
|
||||
|
||||
clean:
|
||||
rm -f multiplesoundcard
|
|
@ -0,0 +1,226 @@
|
|||
/*===============================================================================================
|
||||
MultipleSoundCard Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to simply load and play multiple sounds. This is about the simplest
|
||||
use of FMOD.
|
||||
This makes FMOD decode the into memory when it loads. If the sounds are big and possibly take
|
||||
up a lot of ram, then it would be better to use the FMOD_CREATESTREAM flag so that it is
|
||||
streamed in realtime as it plays.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *systemA, *systemB;
|
||||
FMOD_SOUND *soundA, *soundB;
|
||||
FMOD_CHANNEL *channelA = 0, *channelB = 0;
|
||||
FMOD_RESULT result;
|
||||
int key, count, numdrivers, driver;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create Sound Card A
|
||||
*/
|
||||
result = FMOD_System_Create(&systemA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(systemA, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_GetNumDrivers(systemA, &numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select soundcard A\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = FMOD_System_GetDriverInfo(systemA, count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_SetDriver(systemA, driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Init(systemA, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Create Sound Card B
|
||||
*/
|
||||
result = FMOD_System_Create(&systemB);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(systemB, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_GetNumDrivers(systemB, &numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select soundcard B\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = FMOD_System_GetDriverInfo(systemB, count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_SetDriver(systemB, driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Init(systemB, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
|
||||
/*
|
||||
Load 1 sample into each soundcard.
|
||||
*/
|
||||
result = FMOD_System_CreateSound(systemA, "../media/drumloop.wav", FMOD_HARDWARE, 0, &soundA);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_SetMode(soundA, FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(systemB, "../media/jaguar.wav", FMOD_HARDWARE, 0,&soundB);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("======================================================================\n");
|
||||
printf("MultipleSoundCard Example. Copyright (c) Firelight Technologies 2004.\n");
|
||||
printf("======================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a sound on soundcard A\n");
|
||||
printf("Press '2' to play a sound on soundcard B\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
int channelsplayingA = 0;
|
||||
int channelsplayingB = 0;
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(systemA, FMOD_CHANNEL_FREE, soundA, 0, &channelA);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(systemB, FMOD_CHANNEL_FREE, soundB, 0, &channelB);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(systemA);
|
||||
FMOD_System_Update(systemB);
|
||||
|
||||
FMOD_System_GetChannelsPlaying(systemA, &channelsplayingA);
|
||||
FMOD_System_GetChannelsPlaying(systemB, &channelsplayingB);
|
||||
|
||||
printf("Channels Playing on A %2d. Channels Playing on B %2d.\r", channelsplayingA, channelsplayingB);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(soundA);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(systemA);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(systemA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Sound_Release(soundB);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(systemB);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(systemB);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
/*===============================================================================================
|
||||
MultipleSoundCard Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play sounds on 2 different sound cards from the same application.
|
||||
It creates 2 FMOD::System objects, selects a different sound device for each, then allows
|
||||
the user to play 1 sound on 1 soundcard and another sound on another soundcard.
|
||||
|
||||
Note that sounds created on device A cannot be played on device B and vice versa.
|
||||
You will have to each sound separately for each sound card. Device A might load the sound
|
||||
into its own memory so obviously device B wouldnt be able to play it.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *systemA, *systemB;
|
||||
FMOD::Sound *soundA, *soundB;
|
||||
FMOD::Channel *channelA = 0, *channelB = 0;;
|
||||
FMOD_RESULT result;
|
||||
int key, count, numdrivers, driver;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create Sound Card A
|
||||
*/
|
||||
result = FMOD::System_Create(&systemA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = systemA->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = systemA->getNumDrivers(&numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select soundcard A\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = systemA->getDriverInfo(count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = systemA->setDriver(driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = systemA->init(32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Create Sound Card B
|
||||
*/
|
||||
result = FMOD::System_Create(&systemB);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = systemB->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = systemB->getNumDrivers(&numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select soundcard B\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = systemB->getDriverInfo(count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = systemB->setDriver(driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = systemB->init(32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
|
||||
/*
|
||||
Load 1 sample into each soundcard.
|
||||
*/
|
||||
result = systemA->createSound("../media/drumloop.wav", FMOD_HARDWARE, 0, &soundA);
|
||||
ERRCHECK(result);
|
||||
result = soundA->setMode(FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = systemB->createSound("../media/jaguar.wav", FMOD_HARDWARE, 0, &soundB);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("======================================================================\n");
|
||||
printf("MultipleSoundCard Example. Copyright (c) Firelight Technologies 2004.\n");
|
||||
printf("======================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a sound on soundcard A\n");
|
||||
printf("Press '2' to play a sound on soundcard B\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
int channelsplayingA = 0;
|
||||
int channelsplayingB = 0;
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = systemA->playSound(FMOD_CHANNEL_FREE, soundA, 0, &channelA);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = systemB->playSound(FMOD_CHANNEL_FREE, soundB, 0, &channelB);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
systemA->update();
|
||||
systemB->update();
|
||||
|
||||
systemA->getChannelsPlaying(&channelsplayingA);
|
||||
systemB->getChannelsPlaying(&channelsplayingB);
|
||||
|
||||
printf("Channels Playing on A %2d. Channels Playing on B %2d.\r", channelsplayingA, channelsplayingB);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = soundA->release();
|
||||
ERRCHECK(result);
|
||||
result = systemA->close();
|
||||
ERRCHECK(result);
|
||||
result = systemA->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = soundB->release();
|
||||
ERRCHECK(result);
|
||||
result = systemB->close();
|
||||
ERRCHECK(result);
|
||||
result = systemB->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
multispeakeroutput_cpp: main.cpp
|
||||
g++ -O3 -o multispeakeroutput main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
multispeakeroutput_c: main.c
|
||||
g++ -O3 -o multispeakeroutput main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./multispeakeroutput
|
||||
|
||||
clean:
|
||||
rm -f multispeakeroutput
|
|
@ -0,0 +1,335 @@
|
|||
/*===============================================================================================
|
||||
Multi Speaker Output Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play sounds in multiple speakers, and also how to even assign
|
||||
sound subchannels, such as those in a stereo sound to different individual speakers.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound1, *sound2;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Multichannel only supported in ALSA mode in 5.1 and 7.1.
|
||||
If the user doesn't have 5.1 speakers then only the speakers
|
||||
they have will be audible.
|
||||
*/
|
||||
|
||||
result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ALSA);
|
||||
ERRCHECK(result);
|
||||
|
||||
FMOD_System_SetSpeakerMode(system, FMOD_SPEAKERMODE_5POINT1);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_OFF);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/stereo.ogg", FMOD_SOFTWARE | FMOD_2D, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("==============================================================================\n");
|
||||
printf("Multi Speaker Output Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==============================================================================\n");
|
||||
printf("\n");
|
||||
printf("Note! You must have your speaker configuration set up correctly\n");
|
||||
printf(" in the windows control panel for this to work properly.\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a mono sound on the FRONT LEFT speaker.\n");
|
||||
printf("Press '2' to play a mono sound on the FRONT RIGHT speaker.\n");
|
||||
printf("Press '3' to play a mono sound on the CENTER speaker.\n");
|
||||
printf("Press '4' to play a mono sound on the REAR LEFT speaker.\n");
|
||||
printf("Press '5' to play a mono sound on the REAR RIGHT speaker.\n");
|
||||
printf("Press '6' to play a mono sound on the SIDE LEFT speaker.\n");
|
||||
printf("Press '7' to play a mono sound on the SIDE RIGHT speaker.\n");
|
||||
printf("Press '8' to play a stereo sound on the front speakers.\n");
|
||||
printf("Press '9' to play a stereo sound on the front speakers but channel swapped.\n");
|
||||
printf("Press '0' to play the right part of a stereo sound on the CENTER speaker.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 1.0f, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 1.0f, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 1.0f, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 1.0f, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 1.0f, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '6' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 1.0f, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '7' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 1.0f);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '8' :
|
||||
{
|
||||
float levels[2] = { 0, 1.0f };
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
By default a stereo sound would play in all right and all left speakers, so this forces it to just the front.
|
||||
*/
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 1.0f, 1.0f, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '9' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Clear out all speakers first.
|
||||
*/
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Put the left channel of the sound in the right speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_LEFT, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
/*
|
||||
Put the right channel of the sound in the left speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 1.0f, 0 }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_RIGHT, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '0' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, TRUE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Clear out all speakers first.
|
||||
*/
|
||||
result = FMOD_Channel_SetSpeakerMix(channel, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Put the left channel of the sound in the right speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = FMOD_Channel_SetSpeakerLevels(channel, FMOD_SPEAKER_FRONT_CENTER, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_SetPaused(channel, FALSE);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
int playing = FALSE;
|
||||
int paused = FALSE;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD_SOUND *currentsound = 0;
|
||||
|
||||
result = FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
FMOD_Channel_GetCurrentSound(channel, ¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
/*===============================================================================================
|
||||
Multi Speaker Output Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play sounds in multiple speakers, and also how to even assign
|
||||
sound subchannels, such as those in a stereo sound to different individual speakers.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound1, *sound2;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Multichannel only supported in ALSA mode in 5.1 and 7.1.
|
||||
If the user doesn't have 5.1 speakers then only the speakers
|
||||
they have will be audible.
|
||||
*/
|
||||
|
||||
result = system->setOutput(FMOD_OUTPUTTYPE_ALSA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE | FMOD_2D, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = sound1->setMode(FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
|
||||
result = system->createSound("../media/stereo.ogg", FMOD_SOFTWARE | FMOD_2D, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("==============================================================================\n");
|
||||
printf("Multi Speaker Output Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==============================================================================\n");
|
||||
printf("\n");
|
||||
printf("Note! You must have your speaker configuration set up correctly\n");
|
||||
printf(" in the windows control panel for this to work properly.\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to play a mono sound on the FRONT LEFT speaker.\n");
|
||||
printf("Press '2' to play a mono sound on the FRONT RIGHT speaker.\n");
|
||||
printf("Press '3' to play a mono sound on the CENTER speaker.\n");
|
||||
printf("Press '4' to play a mono sound on the REAR LEFT speaker.\n");
|
||||
printf("Press '5' to play a mono sound on the REAR RIGHT speaker.\n");
|
||||
printf("Press '6' to play a mono sound on the SIDE LEFT speaker.\n");
|
||||
printf("Press '7' to play a mono sound on the SIDE RIGHT speaker.\n");
|
||||
printf("Press '8' to play a stereo sound on the front speakers.\n");
|
||||
printf("Press '9' to play a stereo sound on the front speakers but channel swapped.\n");
|
||||
printf("Press '0' to play the right part of a stereo sound on the CENTER speaker.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(1.0f, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 1.0f, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 0, 1.0f, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '4' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 1.0f, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '5' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 0, 1.0f, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '6' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 0, 0, 1.0f, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '7' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 1.0f);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '8' :
|
||||
{
|
||||
float levels[2] = { 0, 1.0f };
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
By default a stereo sound would play in all right and all left speakers, so this forces it to just the front.
|
||||
*/
|
||||
result = channel->setSpeakerMix(1.0f, 1.0f, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '9' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Clear out all speakers first.
|
||||
*/
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Put the left channel of the sound in the right speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = channel->setSpeakerLevels(FMOD_SPEAKER_FRONT_LEFT, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
/*
|
||||
Put the right channel of the sound in the left speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 1.0f, 0 }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = channel->setSpeakerLevels(FMOD_SPEAKER_FRONT_RIGHT, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
case '0' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, true, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Clear out all speakers first.
|
||||
*/
|
||||
result = channel->setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Put the left channel of the sound in the right speaker.
|
||||
*/
|
||||
{
|
||||
float levels[2] = { 0, 1.0f }; /* This array represents the source stereo sound. l/r */
|
||||
|
||||
result = channel->setSpeakerLevels(FMOD_SPEAKER_FRONT_CENTER, levels, 2);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->setPaused(false);
|
||||
ERRCHECK(result);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
bool playing = false;
|
||||
bool paused = false;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD::Sound *currentsound = 0;
|
||||
|
||||
result = channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
channel->getCurrentSound(¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->getChannelsPlaying(&channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound1->release();
|
||||
ERRCHECK(result);
|
||||
result = sound2->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
netstream_cpp: main.cpp
|
||||
g++ -O3 -o netstream main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
netstream_c: main.c
|
||||
g++ -O3 -o netstream main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./netstream
|
||||
|
||||
clean:
|
||||
rm -f netstream
|
|
@ -0,0 +1,174 @@
|
|||
/*===============================================================================================
|
||||
NetStream Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play streaming audio from the internet
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("NetStream Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n\n");
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Usage: netstream <url>\n");
|
||||
printf("Example: netstream http://www.fmod.org/stream.mp3\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system,&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Bump up the file buffer size a little bit for netstreams (to account for lag). Decode buffer is left at default.
|
||||
*/
|
||||
result = FMOD_System_SetStreamBufferSize(system, 64*1024, FMOD_TIMEUNIT_RAWBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Press space to pause, Esc to quit\n\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
unsigned int ms = 0, percent = 0;
|
||||
int playing = FALSE;
|
||||
int paused = FALSE;
|
||||
int starving = FALSE;
|
||||
FMOD_OPENSTATE openstate;
|
||||
|
||||
if (!channel)
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, FALSE, &channel);
|
||||
}
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
FMOD_Channel_SetPaused(channel, !paused);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
FMOD_TAG tag;
|
||||
if (FMOD_Sound_GetTag(sound, 0, -1, &tag) != FMOD_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
|
||||
{
|
||||
printf("%s = %s (%d bytes)\n", tag.name, tag.data, tag.datalen);
|
||||
}
|
||||
}
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_IsPlaying(channel, &playing);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetOpenState(sound, &openstate, &percent, &starving, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Time %02d:%02d:%02d : %s : (%3d%%%) %s \r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, openstate == FMOD_OPENSTATE_BUFFERING ? "Buffering..." : openstate == FMOD_OPENSTATE_CONNECTING ? "Connecting..." : paused ? "Paused " : playing ? "Playing " : "Stopped ", percent, starving ? "STARVING" : " ");
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("Shutting down.\n");
|
||||
|
||||
/*
|
||||
If we pressed escape before it is ready, wait for it to finish opening before we release it.
|
||||
*/
|
||||
do
|
||||
{
|
||||
FMOD_OPENSTATE openstate;
|
||||
|
||||
result = FMOD_Sound_GetOpenState(sound, &openstate, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (openstate == FMOD_OPENSTATE_READY)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Waiting for sound to finish opening before trying to release it....\r");
|
||||
|
||||
Sleep(10);
|
||||
} while (1);
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,186 @@
|
|||
/*===============================================================================================
|
||||
NetStream Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to play streaming audio from the internet
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("NetStream Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n\n");
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Usage: netstream <url>\n");
|
||||
printf("Example: netstream http://www.fmod.org/stream.mp3\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Bump up the file buffer size a little bit for netstreams (to account for lag). Decode buffer is left at default.
|
||||
*/
|
||||
result = system->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound(argv[1], FMOD_HARDWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_NONBLOCKING, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Press space to pause, Esc to quit\n\n");
|
||||
|
||||
/*
|
||||
Main loop
|
||||
*/
|
||||
do
|
||||
{
|
||||
unsigned int ms = 0, percent = 0;
|
||||
bool playing = false;
|
||||
bool paused = false;
|
||||
bool starving = false;
|
||||
FMOD_OPENSTATE openstate;
|
||||
|
||||
if (!channel)
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
}
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
bool paused;
|
||||
channel->getPaused(&paused);
|
||||
channel->setPaused(!paused);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
if (channel)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
FMOD_TAG tag;
|
||||
if (sound->getTag(0, -1, &tag) != FMOD_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
|
||||
{
|
||||
printf("%s = %s (%d bytes)\n", tag.name, (char *)tag.data, tag.datalen);
|
||||
}
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
ERRCHECK(result);
|
||||
result = channel->isPlaying(&playing);
|
||||
ERRCHECK(result);
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = sound->getOpenState(&openstate, &percent, &starving, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
channel->setMute(starving);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("Time %02d:%02d:%02d : %s : (%3d%%) %s \r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, openstate == FMOD_OPENSTATE_BUFFERING ? "Buffering..." : openstate == FMOD_OPENSTATE_CONNECTING ? "Connecting..." : paused ? "Paused " : playing ? "Playing " : "Stopped ", percent, starving ? "STARVING" : " ");
|
||||
fflush(stdout);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
printf("Shutting down.\n");
|
||||
|
||||
if (channel)
|
||||
{
|
||||
result = channel->stop();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
/*
|
||||
If we pressed escape before it is ready, wait for it to finish opening before we release it.
|
||||
*/
|
||||
do
|
||||
{
|
||||
FMOD_OPENSTATE openstate;
|
||||
|
||||
result = sound->getOpenState(&openstate, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (openstate == FMOD_OPENSTATE_READY)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Waiting for sound to finish opening before trying to release it....\r");
|
||||
fflush(stdout);
|
||||
|
||||
Sleep(10);
|
||||
} while (1);
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
offlinedecoding_cpp: main.cpp
|
||||
g++ -O3 -o offlinedecoding main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
offlinedecoding_c: main.c
|
||||
g++ -O3 -o offlinedecoding main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./offlinedecoding
|
||||
|
||||
clean:
|
||||
rm -f offlinedecoding
|
|
@ -0,0 +1,137 @@
|
|||
/*===============================================================================================
|
||||
Offline Decoding Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how decode a file to PCM, without playing it.
|
||||
It writes out the data as a raw data file.
|
||||
The FMOD_System_CreateSound function uses FMOD_OPENONLY so that FMOD does not read any data
|
||||
itself.
|
||||
If this is uses then it is up to the user to use FMOD_Sound_ReadData to get the data out of
|
||||
the file and into the destination buffer.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_RESULT result;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateStream(system, "../media/wave.mp3", FMOD_OPENONLY | FMOD_ACCURATETIME, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("==========================================================================\n");
|
||||
printf("Offline Decoding Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==========================================================================\n");
|
||||
printf("\n");
|
||||
printf("This program will open wave.mp3 and decode it into wave.raw using the\n");
|
||||
printf("FMOD_Sound_ReadData function.\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Decode the sound and write it to a .raw file.
|
||||
*/
|
||||
{
|
||||
void *data;
|
||||
unsigned int length = 0, read;
|
||||
unsigned int bytesread;
|
||||
FILE *outfp;
|
||||
|
||||
#define CHUNKSIZE 4096
|
||||
|
||||
result = FMOD_Sound_GetLength(sound, &length, FMOD_TIMEUNIT_PCMBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
outfp = fopen("output.raw", "wb");
|
||||
if (!outfp)
|
||||
{
|
||||
printf("Error! Could not open output.raw output file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = malloc(CHUNKSIZE);
|
||||
if (!data)
|
||||
{
|
||||
printf("Error! Failed to allocate %d bytes.\n", CHUNKSIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytesread = 0;
|
||||
do
|
||||
{
|
||||
result = FMOD_Sound_ReadData(sound, (char *)data, CHUNKSIZE, &read);
|
||||
|
||||
fwrite((char *)data, read, 1, outfp);
|
||||
|
||||
bytesread += read;
|
||||
|
||||
printf("writing %d bytes of %d to output.raw\r", bytesread, length);
|
||||
}
|
||||
while (result == FMOD_OK && read == CHUNKSIZE);
|
||||
|
||||
/*
|
||||
Loop terminates when either
|
||||
1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc).
|
||||
2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi).
|
||||
|
||||
If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size,
|
||||
but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats)
|
||||
*/
|
||||
|
||||
printf("\n");
|
||||
|
||||
if (outfp)
|
||||
{
|
||||
fclose(outfp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*===============================================================================================
|
||||
Offline Decoding Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how decode a file to PCM, without playing it.
|
||||
It writes out the data as a raw data file.
|
||||
The System::createSound function uses FMOD_OPENONLY so that FMOD does not read any data
|
||||
itself.
|
||||
If this is uses then it is up to the user to use Sound::readData to get the data out of
|
||||
the file and into the destination buffer.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD_RESULT result;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createStream("../media/wave.mp3", FMOD_OPENONLY | FMOD_ACCURATETIME, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("==========================================================================\n");
|
||||
printf("Offline Decoding Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==========================================================================\n");
|
||||
printf("\n");
|
||||
printf("This program will open wave.mp3 and decode it into wave.raw using the\n");
|
||||
printf("Sound::readData function.\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Decode the sound and write it to a .raw file.
|
||||
*/
|
||||
{
|
||||
void *data;
|
||||
unsigned int length = 0, read;
|
||||
unsigned int bytesread;
|
||||
FILE *outfp;
|
||||
|
||||
#define CHUNKSIZE 4096
|
||||
|
||||
result = sound->getLength(&length, FMOD_TIMEUNIT_PCMBYTES);
|
||||
ERRCHECK(result);
|
||||
|
||||
outfp = fopen("output.raw", "wb");
|
||||
if (!outfp)
|
||||
{
|
||||
printf("Error! Could not open output.raw output file.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
data = malloc(CHUNKSIZE);
|
||||
if (!data)
|
||||
{
|
||||
printf("Error! Failed to allocate %d bytes.\n", CHUNKSIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytesread = 0;
|
||||
do
|
||||
{
|
||||
result = sound->readData((char *)data, CHUNKSIZE, &read);
|
||||
|
||||
fwrite((char *)data, read, 1, outfp);
|
||||
|
||||
bytesread += read;
|
||||
|
||||
printf("writing %d bytes of %d to output.raw\r", bytesread, length);
|
||||
}
|
||||
while (result == FMOD_OK && read == CHUNKSIZE);
|
||||
|
||||
/*
|
||||
Loop terminates when either
|
||||
1. the read function returns an error. (ie FMOD_ERR_FILE_EOF etc).
|
||||
2. the amount requested was different to the amount returned. (somehow got an EOF without the file error, maybe a non stream file format like mod/s3m/xm/it/midi).
|
||||
|
||||
If 'bytesread' is bigger than 'length' then it just means that FMOD miscalculated the size,
|
||||
but this will not usually happen if FMOD_ACCURATETIME is used. (this will give the correct length for VBR formats)
|
||||
*/
|
||||
|
||||
printf("\n");
|
||||
|
||||
if (outfp)
|
||||
{
|
||||
fclose(outfp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
pitchdetection_cpp: main.cpp
|
||||
g++ -O3 -o pitchdetection main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
pitchdetection_c: main.c
|
||||
g++ -O3 -o pitchdetection main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./pitchdetection
|
||||
|
||||
clean:
|
||||
rm -f pitchdetection
|
|
@ -0,0 +1,309 @@
|
|||
/*===============================================================================================
|
||||
Pitch detection example.
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example combines recording with spectrum analysis to determine the pitch of the sound
|
||||
being recorded.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *note[120] =
|
||||
{
|
||||
"C 0", "C#0", "D 0", "D#0", "E 0", "F 0", "F#0", "G 0", "G#0", "A 0", "A#0", "B 0",
|
||||
"C 1", "C#1", "D 1", "D#1", "E 1", "F 1", "F#1", "G 1", "G#1", "A 1", "A#1", "B 1",
|
||||
"C 2", "C#2", "D 2", "D#2", "E 2", "F 2", "F#2", "G 2", "G#2", "A 2", "A#2", "B 2",
|
||||
"C 3", "C#3", "D 3", "D#3", "E 3", "F 3", "F#3", "G 3", "G#3", "A 3", "A#3", "B 3",
|
||||
"C 4", "C#4", "D 4", "D#4", "E 4", "F 4", "F#4", "G 4", "G#4", "A 4", "A#4", "B 4",
|
||||
"C 5", "C#5", "D 5", "D#5", "E 5", "F 5", "F#5", "G 5", "G#5", "A 5", "A#5", "B 5",
|
||||
"C 6", "C#6", "D 6", "D#6", "E 6", "F 6", "F#6", "G 6", "G#6", "A 6", "A#6", "B 6",
|
||||
"C 7", "C#7", "D 7", "D#7", "E 7", "F 7", "F#7", "G 7", "G#7", "A 7", "A#7", "B 7",
|
||||
"C 8", "C#8", "D 8", "D#8", "E 8", "F 8", "F#8", "G 8", "G#8", "A 8", "A#8", "B 8",
|
||||
"C 9", "C#9", "D 9", "D#9", "E 9", "F 9", "F#9", "G 9", "G#9", "A 9", "A#9", "B 9"
|
||||
};
|
||||
|
||||
static const float notefreq[120] =
|
||||
{
|
||||
16.35f, 17.32f, 18.35f, 19.45f, 20.60f, 21.83f, 23.12f, 24.50f, 25.96f, 27.50f, 29.14f, 30.87f,
|
||||
32.70f, 34.65f, 36.71f, 38.89f, 41.20f, 43.65f, 46.25f, 49.00f, 51.91f, 55.00f, 58.27f, 61.74f,
|
||||
65.41f, 69.30f, 73.42f, 77.78f, 82.41f, 87.31f, 92.50f, 98.00f, 103.83f, 110.00f, 116.54f, 123.47f,
|
||||
130.81f, 138.59f, 146.83f, 155.56f, 164.81f, 174.61f, 185.00f, 196.00f, 207.65f, 220.00f, 233.08f, 246.94f,
|
||||
261.63f, 277.18f, 293.66f, 311.13f, 329.63f, 349.23f, 369.99f, 392.00f, 415.30f, 440.00f, 466.16f, 493.88f,
|
||||
523.25f, 554.37f, 587.33f, 622.25f, 659.26f, 698.46f, 739.99f, 783.99f, 830.61f, 880.00f, 932.33f, 987.77f,
|
||||
1046.50f, 1108.73f, 1174.66f, 1244.51f, 1318.51f, 1396.91f, 1479.98f, 1567.98f, 1661.22f, 1760.00f, 1864.66f, 1975.53f,
|
||||
2093.00f, 2217.46f, 2349.32f, 2489.02f, 2637.02f, 2793.83f, 2959.96f, 3135.96f, 3322.44f, 3520.00f, 3729.31f, 3951.07f,
|
||||
4186.01f, 4434.92f, 4698.64f, 4978.03f, 5274.04f, 5587.65f, 5919.91f, 6271.92f, 6644.87f, 7040.00f, 7458.62f, 7902.13f,
|
||||
8372.01f, 8869.84f, 9397.27f, 9956.06f, 10548.08f, 11175.30f, 11839.82f, 12543.85f, 13289.75f, 14080.00f, 14917.24f, 15804.26f
|
||||
};
|
||||
|
||||
#define OUTPUTRATE 48000
|
||||
#define SPECTRUMSIZE 8192
|
||||
#define SPECTRUMRANGE ((float)OUTPUTRATE / 2.0f) /* 0 to nyquist */
|
||||
|
||||
#define BINSIZE (SPECTRUMRANGE / (float)SPECTRUMSIZE)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system = 0;
|
||||
FMOD_SOUND *sound = 0;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
int key, driver, recorddriver, numdrivers, count, outputfreq, bin;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
System initialization
|
||||
*/
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select OUTPUT type\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("1 : OSS - Open Sound System\n");
|
||||
printf("2 : ALSA - Advanced Linux Sound Architecture\n");
|
||||
printf("3 : ESD - Enlightenment Sound Daemon\n");
|
||||
printf("4 : PULSEAUDIO - Pulse Audio Sound Server\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
} while (key != 27 && key < '1' && key > '5');
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_OSS);
|
||||
break;
|
||||
case '2' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ALSA);
|
||||
break;
|
||||
case '3' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ESD);
|
||||
break;
|
||||
case '4' : result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_PULSEAUDIO);
|
||||
break;
|
||||
default : return 1;
|
||||
}
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Enumerate playback devices
|
||||
*/
|
||||
|
||||
result = FMOD_System_GetNumDrivers(system, &numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Choose a PLAYBACK driver\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = FMOD_System_GetDriverInfo(system, count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
result = FMOD_System_SetDriver(system, driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Enumerate record devices
|
||||
*/
|
||||
|
||||
result = FMOD_System_GetRecordNumDrivers(system, &numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Choose a RECORD driver\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = FMOD_System_GetRecordDriverInfo(system, count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
recorddriver = 0;
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
recorddriver = key - '1';
|
||||
} while (recorddriver < 0 || recorddriver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_SetSoftwareFormat(system, OUTPUTRATE, FMOD_SOUND_FORMAT_PCM16, 1, 0, FMOD_DSP_RESAMPLER_LINEAR);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
FMOD_System_GetSoftwareFormat(system, &outputfreq, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create a sound to record to.
|
||||
*/
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.numchannels = 1;
|
||||
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
|
||||
exinfo.defaultfrequency = OUTPUTRATE;
|
||||
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5;
|
||||
|
||||
result = FMOD_System_CreateSound(system, 0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Start the interface
|
||||
*/
|
||||
printf("=========================================================================\n");
|
||||
printf("Pitch detection example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=========================================================================\n");
|
||||
printf("\n");
|
||||
printf("Record something through the selected recording device and FMOD will\n");
|
||||
printf("Determine the pitch. Sustain the tone for at least a second to get an\n");
|
||||
printf("accurate reading.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = FMOD_System_RecordStart(system, recorddriver, sound, TRUE);
|
||||
ERRCHECK(result);
|
||||
|
||||
Sleep(200); /* Give it some time to record something */
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_REUSE, sound, FALSE, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/* Dont hear what is being recorded otherwise it will feedback. Spectrum analysis is done before volume scaling in the DSP chain */
|
||||
result = FMOD_Channel_SetVolume(channel, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
bin = 0;
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
static float spectrum[SPECTRUMSIZE];
|
||||
float dominanthz = 0;
|
||||
float max;
|
||||
int dominantnote = 0;
|
||||
float binsize = BINSIZE;
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetSpectrum(channel, spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);
|
||||
ERRCHECK(result);
|
||||
|
||||
max = 0;
|
||||
|
||||
for (count = 0; count < SPECTRUMSIZE; count++)
|
||||
{
|
||||
if (spectrum[count] > 0.01f && spectrum[count] > max)
|
||||
{
|
||||
max = spectrum[count];
|
||||
bin = count;
|
||||
}
|
||||
}
|
||||
|
||||
dominanthz = (float)bin * BINSIZE; /* dominant frequency min */
|
||||
|
||||
dominantnote = 0;
|
||||
for (count = 0; count < 120; count++)
|
||||
{
|
||||
if (dominanthz >= notefreq[count] && dominanthz < notefreq[count + 1])
|
||||
{
|
||||
/* which is it closer to. This note or the next note */
|
||||
if (fabs(dominanthz - notefreq[count]) < fabs(dominanthz - notefreq[count+1]))
|
||||
{
|
||||
dominantnote = count;
|
||||
}
|
||||
else
|
||||
{
|
||||
dominantnote = count + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Detected rate : %7.1f -> %7.1f hz. Detected musical note. %-3s (%7.1f hz)\r", dominanthz, ((float)bin + 0.99f) * BINSIZE, note[dominantnote], notefreq[dominantnote]);
|
||||
fflush(stdout);
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
/*===============================================================================================
|
||||
Pitch detection example.
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example combines recording with spectrum analysis to determine the pitch of the sound
|
||||
being recorded.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *note[120] =
|
||||
{
|
||||
"C 0", "C#0", "D 0", "D#0", "E 0", "F 0", "F#0", "G 0", "G#0", "A 0", "A#0", "B 0",
|
||||
"C 1", "C#1", "D 1", "D#1", "E 1", "F 1", "F#1", "G 1", "G#1", "A 1", "A#1", "B 1",
|
||||
"C 2", "C#2", "D 2", "D#2", "E 2", "F 2", "F#2", "G 2", "G#2", "A 2", "A#2", "B 2",
|
||||
"C 3", "C#3", "D 3", "D#3", "E 3", "F 3", "F#3", "G 3", "G#3", "A 3", "A#3", "B 3",
|
||||
"C 4", "C#4", "D 4", "D#4", "E 4", "F 4", "F#4", "G 4", "G#4", "A 4", "A#4", "B 4",
|
||||
"C 5", "C#5", "D 5", "D#5", "E 5", "F 5", "F#5", "G 5", "G#5", "A 5", "A#5", "B 5",
|
||||
"C 6", "C#6", "D 6", "D#6", "E 6", "F 6", "F#6", "G 6", "G#6", "A 6", "A#6", "B 6",
|
||||
"C 7", "C#7", "D 7", "D#7", "E 7", "F 7", "F#7", "G 7", "G#7", "A 7", "A#7", "B 7",
|
||||
"C 8", "C#8", "D 8", "D#8", "E 8", "F 8", "F#8", "G 8", "G#8", "A 8", "A#8", "B 8",
|
||||
"C 9", "C#9", "D 9", "D#9", "E 9", "F 9", "F#9", "G 9", "G#9", "A 9", "A#9", "B 9"
|
||||
};
|
||||
|
||||
static const float notefreq[120] =
|
||||
{
|
||||
16.35f, 17.32f, 18.35f, 19.45f, 20.60f, 21.83f, 23.12f, 24.50f, 25.96f, 27.50f, 29.14f, 30.87f,
|
||||
32.70f, 34.65f, 36.71f, 38.89f, 41.20f, 43.65f, 46.25f, 49.00f, 51.91f, 55.00f, 58.27f, 61.74f,
|
||||
65.41f, 69.30f, 73.42f, 77.78f, 82.41f, 87.31f, 92.50f, 98.00f, 103.83f, 110.00f, 116.54f, 123.47f,
|
||||
130.81f, 138.59f, 146.83f, 155.56f, 164.81f, 174.61f, 185.00f, 196.00f, 207.65f, 220.00f, 233.08f, 246.94f,
|
||||
261.63f, 277.18f, 293.66f, 311.13f, 329.63f, 349.23f, 369.99f, 392.00f, 415.30f, 440.00f, 466.16f, 493.88f,
|
||||
523.25f, 554.37f, 587.33f, 622.25f, 659.26f, 698.46f, 739.99f, 783.99f, 830.61f, 880.00f, 932.33f, 987.77f,
|
||||
1046.50f, 1108.73f, 1174.66f, 1244.51f, 1318.51f, 1396.91f, 1479.98f, 1567.98f, 1661.22f, 1760.00f, 1864.66f, 1975.53f,
|
||||
2093.00f, 2217.46f, 2349.32f, 2489.02f, 2637.02f, 2793.83f, 2959.96f, 3135.96f, 3322.44f, 3520.00f, 3729.31f, 3951.07f,
|
||||
4186.01f, 4434.92f, 4698.64f, 4978.03f, 5274.04f, 5587.65f, 5919.91f, 6271.92f, 6644.87f, 7040.00f, 7458.62f, 7902.13f,
|
||||
8372.01f, 8869.84f, 9397.27f, 9956.06f, 10548.08f, 11175.30f, 11839.82f, 12543.85f, 13289.75f, 14080.00f, 14917.24f, 15804.26f
|
||||
};
|
||||
|
||||
#define OUTPUTRATE 48000
|
||||
#define SPECTRUMSIZE 8192
|
||||
#define SPECTRUMRANGE ((float)OUTPUTRATE / 2.0f) /* 0 to nyquist */
|
||||
|
||||
#define BINSIZE (SPECTRUMRANGE / (float)SPECTRUMSIZE)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system = 0;
|
||||
FMOD::Sound *sound = 0;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
FMOD_CREATESOUNDEXINFO exinfo;
|
||||
int key, driver, recorddriver, numdrivers, count, outputfreq, bin;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
System initialization
|
||||
*/
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Select OUTPUT type\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("1 : OSS - Open Sound System\n");
|
||||
printf("2 : ALSA - Advanced Linux Sound Architecture\n");
|
||||
printf("3 : ESD - Enlightenment Sound Daemon\n");
|
||||
printf("4 : PULSEAUDIO - Pulse Audio Sound Server\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
} while (key != 27 && key < '1' && key > '5');
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' : result = system->setOutput(FMOD_OUTPUTTYPE_OSS);
|
||||
break;
|
||||
case '2' : result = system->setOutput(FMOD_OUTPUTTYPE_ALSA);
|
||||
break;
|
||||
case '3' : result = system->setOutput(FMOD_OUTPUTTYPE_ESD);
|
||||
break;
|
||||
case '4' : result = system->setOutput(FMOD_OUTPUTTYPE_PULSEAUDIO);
|
||||
break;
|
||||
default : return 1;
|
||||
}
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Enumerate playback devices
|
||||
*/
|
||||
|
||||
result = system->getNumDrivers(&numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Choose a PLAYBACK driver\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = system->getDriverInfo(count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
driver = key - '1';
|
||||
} while (driver < 0 || driver >= numdrivers);
|
||||
|
||||
result = system->setDriver(driver);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Enumerate record devices
|
||||
*/
|
||||
|
||||
result = system->getRecordNumDrivers(&numdrivers);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Choose a RECORD driver\n");
|
||||
printf("---------------------------------------------------------\n");
|
||||
for (count=0; count < numdrivers; count++)
|
||||
{
|
||||
char name[256];
|
||||
|
||||
result = system->getRecordDriverInfo(count, name, 256, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("%d : %s\n", count + 1, name);
|
||||
}
|
||||
printf("---------------------------------------------------------\n");
|
||||
printf("Press a corresponding number or ESC to quit\n");
|
||||
|
||||
recorddriver = 0;
|
||||
do
|
||||
{
|
||||
key = getch();
|
||||
if (key == 27)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
recorddriver = key - '1';
|
||||
} while (recorddriver < 0 || recorddriver >= numdrivers);
|
||||
|
||||
printf("\n");
|
||||
|
||||
result = system->setSoftwareFormat(OUTPUTRATE, FMOD_SOUND_FORMAT_PCM16, 1, 0, FMOD_DSP_RESAMPLER_LINEAR);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
system->getSoftwareFormat(&outputfreq, 0, 0, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Create a sound to record to.
|
||||
*/
|
||||
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
|
||||
|
||||
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
|
||||
exinfo.numchannels = 1;
|
||||
exinfo.format = FMOD_SOUND_FORMAT_PCM16;
|
||||
exinfo.defaultfrequency = OUTPUTRATE;
|
||||
exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5;
|
||||
|
||||
result = system->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Start the interface
|
||||
*/
|
||||
printf("=========================================================================\n");
|
||||
printf("Pitch detection example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("=========================================================================\n");
|
||||
printf("\n");
|
||||
printf("Record something through the selected recording device and FMOD will\n");
|
||||
printf("Determine the pitch. Sustain the tone for at least a second to get an\n");
|
||||
printf("accurate reading.\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
result = system->recordStart(recorddriver, sound, true);
|
||||
ERRCHECK(result);
|
||||
|
||||
Sleep(200); /* Give it some time to record something */
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_REUSE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/* Dont hear what is being recorded otherwise it will feedback. Spectrum analysis is done before volume scaling in the DSP chain */
|
||||
result = channel->setVolume(0);
|
||||
ERRCHECK(result);
|
||||
|
||||
bin = 0;
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
static float spectrum[SPECTRUMSIZE];
|
||||
float dominanthz = 0;
|
||||
float max;
|
||||
int dominantnote = 0;
|
||||
float binsize = BINSIZE;
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
}
|
||||
|
||||
result = channel->getSpectrum(spectrum, SPECTRUMSIZE, 0, FMOD_DSP_FFT_WINDOW_TRIANGLE);
|
||||
ERRCHECK(result);
|
||||
|
||||
max = 0;
|
||||
|
||||
for (count = 0; count < SPECTRUMSIZE; count++)
|
||||
{
|
||||
if (spectrum[count] > 0.01f && spectrum[count] > max)
|
||||
{
|
||||
max = spectrum[count];
|
||||
bin = count;
|
||||
}
|
||||
}
|
||||
|
||||
dominanthz = (float)bin * BINSIZE; /* dominant frequency min */
|
||||
|
||||
dominantnote = 0;
|
||||
for (count = 0; count < 120; count++)
|
||||
{
|
||||
if (dominanthz >= notefreq[count] && dominanthz < notefreq[count + 1])
|
||||
{
|
||||
/* which is it closer to. This note or the next note */
|
||||
if (fabs(dominanthz - notefreq[count]) < fabs(dominanthz - notefreq[count+1]))
|
||||
{
|
||||
dominantnote = count;
|
||||
}
|
||||
else
|
||||
{
|
||||
dominantnote = count + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Detected rate : %7.1f -> %7.1f hz. Detected musical note. %-3s (%7.1f hz)\r", dominanthz, ((float)bin + 0.99f) * BINSIZE, note[dominantnote], notefreq[dominantnote]);
|
||||
fflush(stdout);
|
||||
|
||||
system->update();
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
playlist_cpp: main.cpp
|
||||
g++ -O3 -o playlist main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
playlist_c: main.c
|
||||
g++ -O3 -o playlist main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./playlist
|
||||
|
||||
clean:
|
||||
rm -f playlist
|
|
@ -0,0 +1,254 @@
|
|||
/*===============================================================================================
|
||||
PlayList Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to load a playlist and play the sounds in a playlist.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system = 0;
|
||||
FMOD_SOUND *playlist = 0;
|
||||
FMOD_SOUND *sound = 0;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_TAG tag;
|
||||
FMOD_RESULT result;
|
||||
FMOD_SOUND_TYPE soundtype;
|
||||
FMOD_BOOL isplaylist = 0;
|
||||
char *title = NULL;
|
||||
int count = 0;
|
||||
int key;
|
||||
unsigned int version;
|
||||
char file[128];
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/playlist.m3u", FMOD_DEFAULT, 0, &playlist);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_Sound_GetFormat(playlist, &soundtype, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
isplaylist = (soundtype == FMOD_SOUND_TYPE_PLAYLIST);
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("PlayList Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press 'n' to play next sound in playlist\n");
|
||||
printf("Press 'space' to pause/unpause current sound\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
if (isplaylist)
|
||||
{
|
||||
printf("PLAYLIST loaded.\n");
|
||||
/*
|
||||
Get the first song in the playlist, create the sound and then play it.
|
||||
*/
|
||||
result = FMOD_Sound_GetTag(playlist, "FILE", count, &tag);
|
||||
ERRCHECK(result);
|
||||
|
||||
sprintf(file, "../media/%s", (char *)tag.data);
|
||||
|
||||
result = FMOD_System_CreateSound(system, file, FMOD_DEFAULT, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
FMOD_Sound_GetTag(playlist, "TITLE", count, &tag);
|
||||
title = (char *)tag.data;
|
||||
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("SOUND loaded.\n");
|
||||
|
||||
/*
|
||||
This is just a normal sound, so just play it.
|
||||
*/
|
||||
sound = playlist;
|
||||
|
||||
result = FMOD_Sound_SetMode(sound, FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
FMOD_BOOL isplaying = 0;
|
||||
|
||||
if (channel && isplaylist)
|
||||
{
|
||||
/*
|
||||
When sound has finished playing, play the next sound in the playlist
|
||||
*/
|
||||
|
||||
FMOD_Channel_IsPlaying(channel, &isplaying);
|
||||
if (!isplaying)
|
||||
{
|
||||
if (sound)
|
||||
{
|
||||
FMOD_Sound_Release(sound);
|
||||
|
||||
sound = NULL;
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetTag(playlist, "FILE", count, &tag);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("playing next song in playlist...\n");
|
||||
|
||||
sprintf(file, "../media/%s", (char *)tag.data);
|
||||
|
||||
result = FMOD_System_CreateSound(system, file, FMOD_DEFAULT, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
FMOD_Sound_GetTag(playlist, "TITLE", count, &tag);
|
||||
title = (char *)tag.data;
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'n' :
|
||||
{
|
||||
/*
|
||||
Play the next song in the playlist
|
||||
*/
|
||||
if (channel && isplaylist)
|
||||
{
|
||||
FMOD_Channel_Stop(channel);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ' ' :
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
FMOD_BOOL paused;
|
||||
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
FMOD_Channel_SetPaused(channel, !paused);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
FMOD_BOOL paused = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
if (sound)
|
||||
{
|
||||
result = FMOD_Sound_GetLength(sound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : "Playing ", title);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
if (sound)
|
||||
{
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
if (isplaylist)
|
||||
{
|
||||
result = FMOD_Sound_Release(playlist);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
/*===============================================================================================
|
||||
PlayList Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to load a playlist and play the sounds in a playlist.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system = 0;
|
||||
FMOD::Sound *playlist = 0;
|
||||
FMOD::Sound *sound = 0;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_TAG tag;
|
||||
FMOD_RESULT result;
|
||||
FMOD_SOUND_TYPE soundtype;
|
||||
bool isplaylist = false;
|
||||
char *title = NULL;
|
||||
int count = 0;
|
||||
int key;
|
||||
unsigned int version;
|
||||
char file[128];
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/playlist.m3u", FMOD_DEFAULT, 0, &playlist);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = playlist->getFormat(&soundtype, 0, 0, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
isplaylist = (soundtype == FMOD_SOUND_TYPE_PLAYLIST);
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("PlayList Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press 'n' to play next sound in playlist\n");
|
||||
printf("Press 'space' to pause/unpause current sound\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
if (isplaylist)
|
||||
{
|
||||
printf("PLAYLIST loaded.\n");
|
||||
/*
|
||||
Get the first song in the playlist, create the sound and then play it.
|
||||
*/
|
||||
result = playlist->getTag("FILE", count, &tag);
|
||||
ERRCHECK(result);
|
||||
|
||||
sprintf(file, "../media/%s", (char *)tag.data);
|
||||
|
||||
result = system->createSound(file, FMOD_DEFAULT, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
playlist->getTag("TITLE", count, &tag);
|
||||
title = (char *)tag.data;
|
||||
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("SOUND loaded.\n");
|
||||
|
||||
/*
|
||||
This is just a normal sound, so just play it.
|
||||
*/
|
||||
sound = playlist;
|
||||
|
||||
result = sound->setMode(FMOD_LOOP_NORMAL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
bool isplaying = false;
|
||||
|
||||
if (channel && isplaylist)
|
||||
{
|
||||
/*
|
||||
When sound has finished playing, play the next sound in the playlist
|
||||
*/
|
||||
|
||||
channel->isPlaying(&isplaying);
|
||||
if (!isplaying)
|
||||
{
|
||||
if (sound)
|
||||
{
|
||||
sound->release();
|
||||
|
||||
sound = NULL;
|
||||
}
|
||||
|
||||
result = playlist->getTag("FILE", count, &tag);
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("playing next song in playlist...\n");
|
||||
|
||||
sprintf(file, "../media/%s", (char *)tag.data);
|
||||
|
||||
result = system->createSound(file, FMOD_DEFAULT, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
playlist->getTag("TITLE", count, &tag);
|
||||
title = (char *)tag.data;
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'n' :
|
||||
{
|
||||
/*
|
||||
Play the next song in the playlist
|
||||
*/
|
||||
if (channel && isplaylist)
|
||||
{
|
||||
channel->stop();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ' ' :
|
||||
{
|
||||
if (channel)
|
||||
{
|
||||
bool paused;
|
||||
|
||||
channel->getPaused(&paused);
|
||||
channel->setPaused(!paused);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
bool paused = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
if (sound)
|
||||
{
|
||||
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : "Playing ", title);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
if (sound)
|
||||
{
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
if (isplaylist)
|
||||
{
|
||||
result = playlist->release();
|
||||
ERRCHECK(result);
|
||||
}
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
playsound_cpp: main.cpp
|
||||
g++ -O3 -o playsound main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
playsound_c: main.c
|
||||
gcc -O3 -o playsound main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./playsound
|
||||
|
||||
clean:
|
||||
rm -f playsound
|
|
@ -0,0 +1,184 @@
|
|||
/*===============================================================================================
|
||||
PlaySound Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to simply load and play multiple sounds. This is about the simplest
|
||||
use of FMOD.
|
||||
This makes FMOD decode the into memory when it loads. If the sounds are big and possibly take
|
||||
up a lot of ram, then it would be better to use the FMOD_CREATESTREAM flag so that it is
|
||||
streamed in realtime as it plays.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound1, *sound2, *sound3;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/drumloop.wav", FMOD_SOFTWARE, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_SetMode(sound1, FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/jaguar.wav", FMOD_SOFTWARE, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/swish.wav", FMOD_SOFTWARE, 0, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("PlaySound Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to Play a mono sound using hardware mixing\n");
|
||||
printf("Press '2' to Play a mono sound using software mixing\n");
|
||||
printf("Press '3' to Play a stereo sound using hardware mixing\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound1, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound2, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound3, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
int playing = 0;
|
||||
int paused = 0;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD_SOUND *currentsound = 0;
|
||||
|
||||
result = FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
FMOD_Channel_GetCurrentSound(channel, ¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = FMOD_Sound_GetLength(currentsound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetLength(sound1, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
FMOD_System_GetChannelsPlaying(system, &channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound1);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound2);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_Sound_Release(sound3);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
/*===============================================================================================
|
||||
PlaySound Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to simply load and play multiple sounds. This is about the simplest
|
||||
use of FMOD.
|
||||
This makes FMOD decode the into memory when it loads. If the sounds are big and possibly take
|
||||
up a lot of ram, then it would be better to use the FMOD_CREATESTREAM flag so that it is
|
||||
streamed in realtime as it plays.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound1, *sound2, *sound3;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->setOutput(FMOD_OUTPUTTYPE_ALSA);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->init(32, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/drumloop.wav", FMOD_SOFTWARE, 0, &sound1);
|
||||
ERRCHECK(result);
|
||||
result = sound1->setMode(FMOD_LOOP_OFF);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/jaguar.wav", FMOD_SOFTWARE, 0, &sound2);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/swish.wav", FMOD_SOFTWARE, 0, &sound3);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("===================================================================\n");
|
||||
printf("PlaySound Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("===================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press '1' to Play a mono sound using software mixing\n");
|
||||
printf("Press '2' to Play a mono sound using software mixing\n");
|
||||
printf("Press '3' to Play a stereo sound using software mixing\n");
|
||||
printf("Press 'Esc' to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound1, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '2' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound2, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
case '3' :
|
||||
{
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound3, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
{
|
||||
unsigned int ms = 0;
|
||||
unsigned int lenms = 0;
|
||||
bool playing = 0;
|
||||
bool paused = 0;
|
||||
int channelsplaying = 0;
|
||||
|
||||
if (channel)
|
||||
{
|
||||
FMOD::Sound *currentsound = 0;
|
||||
|
||||
result = channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
channel->getCurrentSound(¤tsound);
|
||||
if (currentsound)
|
||||
{
|
||||
result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->getChannelsPlaying(&channelsplaying);
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound1->release();
|
||||
ERRCHECK(result);
|
||||
result = sound2->release();
|
||||
ERRCHECK(result);
|
||||
result = sound3->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
playstream_cpp: main.cpp
|
||||
g++ -O3 -o playstream main.cpp ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
playstream_c: main.c
|
||||
g++ -O3 -o playstream main.c ../../api/lib/libfmodex.so -pthread
|
||||
|
||||
run:
|
||||
./playstream
|
||||
|
||||
clean:
|
||||
rm -f playstream
|
|
@ -0,0 +1,149 @@
|
|||
/*===============================================================================================
|
||||
PlayStream Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to simply play a stream, such as an mp3 or wav.
|
||||
The stream behaviour is achieved by specifying FMOD_CREATESTREAM in the call to
|
||||
FMOD_System_CreateSound.
|
||||
This makes FMOD decode the file in realtime as it plays, instead of loading it all at once.
|
||||
This uses far less memory, in exchange for a small runtime cpu hit.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_CHANNEL *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_CreateSound(system, "../media/wave.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("====================================================================\n");
|
||||
printf("PlayStream Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("====================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press space to pause, Esc to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Play the sound.
|
||||
*/
|
||||
|
||||
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
int paused;
|
||||
FMOD_Channel_GetPaused(channel, &paused);
|
||||
FMOD_Channel_SetPaused(channel, !paused);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FMOD_System_Update(system);
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms;
|
||||
unsigned int lenms;
|
||||
int playing;
|
||||
int paused;
|
||||
|
||||
FMOD_Channel_IsPlaying(channel, &playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPaused(channel, &paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Channel_GetPosition(channel, &ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = FMOD_Sound_GetLength(sound, &lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/*===============================================================================================
|
||||
PlayStream Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to simply play a stream, such as an mp3 or wav.
|
||||
The stream behaviour is achieved by specifying FMOD_CREATESTREAM in the call to
|
||||
System::createSound.
|
||||
This makes FMOD decode the file in realtime as it plays, instead of loading it all at once.
|
||||
This uses far less memory, in exchange for a small runtime cpu hit.
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.hpp"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD::System *system;
|
||||
FMOD::Sound *sound;
|
||||
FMOD::Channel *channel = 0;
|
||||
FMOD_RESULT result;
|
||||
int key;
|
||||
unsigned int version;
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD::System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->getVersion(&version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = system->init(1, FMOD_INIT_NORMAL, 0);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = system->createSound("../media/wave.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
printf("====================================================================\n");
|
||||
printf("PlayStream Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("====================================================================\n");
|
||||
printf("\n");
|
||||
printf("Press space to pause, Esc to quit\n");
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Play the sound.
|
||||
*/
|
||||
|
||||
result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Main loop.
|
||||
*/
|
||||
do
|
||||
{
|
||||
if (kbhit())
|
||||
{
|
||||
key = getch();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case ' ' :
|
||||
{
|
||||
bool paused;
|
||||
channel->getPaused(&paused);
|
||||
channel->setPaused(!paused);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system->update();
|
||||
|
||||
if (channel)
|
||||
{
|
||||
unsigned int ms;
|
||||
unsigned int lenms;
|
||||
bool playing;
|
||||
bool paused;
|
||||
|
||||
channel->isPlaying(&playing);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPaused(&paused);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
result = sound->getLength(&lenms, FMOD_TIMEUNIT_MS);
|
||||
if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
|
||||
{
|
||||
ERRCHECK(result);
|
||||
}
|
||||
|
||||
printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
} while (key != 27);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = sound->release();
|
||||
ERRCHECK(result);
|
||||
result = system->close();
|
||||
ERRCHECK(result);
|
||||
result = system->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
all:
|
||||
g++ -shared -fPIC -o codec_raw.so main.c
|
||||
|
||||
clean:
|
||||
rm -f codec_raw.so
|
|
@ -0,0 +1,96 @@
|
|||
/*===============================================================================================
|
||||
CODEC_RAW.SO
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2006-2011.
|
||||
|
||||
===============================================================================================*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../../../api/inc/fmod.h"
|
||||
#include "../../../api/inc/fmod_errors.h"
|
||||
|
||||
FMOD_RESULT F_CALLBACK rawopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
|
||||
FMOD_RESULT F_CALLBACK rawclose(FMOD_CODEC_STATE *codec);
|
||||
FMOD_RESULT F_CALLBACK rawread(FMOD_CODEC_STATE *codec, void *buffer, unsigned int size, unsigned int *read);
|
||||
FMOD_RESULT F_CALLBACK rawsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
|
||||
|
||||
FMOD_CODEC_DESCRIPTION rawcodec =
|
||||
{
|
||||
"FMOD Raw player plugin example", // Name.
|
||||
0x00010000, // Version 0xAAAABBBB A = major, B = minor.
|
||||
0, // Don't force everything using this codec to be a stream
|
||||
FMOD_TIMEUNIT_PCMBYTES, // The time format we would like to accept into setposition/getposition.
|
||||
&rawopen, // Open callback.
|
||||
&rawclose, // Close callback.
|
||||
&rawread, // Read callback.
|
||||
0, // Getlength callback. (If not specified FMOD return the length in FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS or FMOD_TIMEUNIT_PCMBYTES units based on the lengthpcm member of the FMOD_CODEC structure).
|
||||
&rawsetposition, // Setposition callback.
|
||||
0, // Getposition callback. (only used for timeunit types that are not FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_MS and FMOD_TIMEUNIT_PCMBYTES).
|
||||
0 // Sound create callback (don't need it)
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
FMODGetCodecDescription is mandatory for every fmod plugin. This is the symbol the registerplugin function searches for.
|
||||
Must be declared with F_API to make it export as stdcall.
|
||||
MUST BE EXTERN'ED AS C! C++ functions will be mangled incorrectly and not load in fmod.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
F_DECLSPEC F_DLLEXPORT FMOD_CODEC_DESCRIPTION * F_API FMODGetCodecDescription()
|
||||
{
|
||||
return &rawcodec;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static FMOD_CODEC_WAVEFORMAT rawwaveformat;
|
||||
|
||||
/*
|
||||
The actual codec code.
|
||||
|
||||
Note that the callbacks uses FMOD's supplied file system callbacks.
|
||||
|
||||
This is important as even though you might want to open the file yourself, you would lose the following benefits.
|
||||
1. Automatic support of memory files, CDDA based files, and HTTP/TCPIP based files.
|
||||
2. "fileoffset" / "length" support when user calls System::createSound with FMOD_CREATESOUNDEXINFO structure.
|
||||
3. Buffered file access.
|
||||
FMOD files are high level abstracts that support all sorts of 'file', they are not just disk file handles.
|
||||
If you want FMOD to use your own filesystem (and potentially lose the above benefits) use System::setFileSystem.
|
||||
*/
|
||||
|
||||
FMOD_RESULT F_CALLBACK rawopen(FMOD_CODEC_STATE *codec, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo)
|
||||
{
|
||||
rawwaveformat.channels = 2;
|
||||
rawwaveformat.format = FMOD_SOUND_FORMAT_PCM16;
|
||||
rawwaveformat.frequency = 44100;
|
||||
rawwaveformat.blockalign = rawwaveformat.channels * 2; /* 2 = 16bit pcm */
|
||||
rawwaveformat.lengthpcm = codec->filesize / rawwaveformat.blockalign; /* bytes converted to PCM samples */;
|
||||
|
||||
codec->numsubsounds = 0; /* number of 'subsounds' in this sound. For most codecs this is 0, only multi sound codecs such as FSB or CDDA have subsounds. */
|
||||
codec->waveformat = &rawwaveformat;
|
||||
codec->plugindata = 0; /* user data value */
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK rawclose(FMOD_CODEC_STATE *codec)
|
||||
{
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK rawread(FMOD_CODEC_STATE *codec, void *buffer, unsigned int size, unsigned int *read)
|
||||
{
|
||||
return codec->fileread(codec->filehandle, buffer, size, read, 0);
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK rawsetposition(FMOD_CODEC_STATE *codec, int subsound, unsigned int position, FMOD_TIMEUNIT postype)
|
||||
{
|
||||
return codec->fileseek(codec->filehandle, position, 0);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
all:
|
||||
g++ -shared -fPIC -o dsp_gain.so main.c
|
||||
|
||||
clean:
|
||||
rm -f dsp_gain.so
|
|
@ -0,0 +1,181 @@
|
|||
/*===============================================================================================
|
||||
DSP_GAIN.SO
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2006-2011.
|
||||
|
||||
===============================================================================================*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../../api/inc/fmod.h"
|
||||
#include "../../../api/inc/fmod_errors.h"
|
||||
|
||||
FMOD_RESULT F_CALLBACK dspcreate (FMOD_DSP_STATE *dsp);
|
||||
FMOD_RESULT F_CALLBACK dsprelease (FMOD_DSP_STATE *dsp);
|
||||
FMOD_RESULT F_CALLBACK dspreset (FMOD_DSP_STATE *dsp);
|
||||
FMOD_RESULT F_CALLBACK dspread (FMOD_DSP_STATE *dsp, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels);
|
||||
FMOD_RESULT F_CALLBACK dspsetparam(FMOD_DSP_STATE *dsp, int index, float value);
|
||||
FMOD_RESULT F_CALLBACK dspgetparam(FMOD_DSP_STATE *dsp, int index, float *value, char *valuestr);
|
||||
|
||||
|
||||
/*
|
||||
DSP Parameter list.
|
||||
*/
|
||||
FMOD_DSP_PARAMETERDESC dspparam[1] =
|
||||
{
|
||||
{ 0.0f, 1.0f, 1.0, "Level", "%", "Gain level" },
|
||||
};
|
||||
|
||||
|
||||
FMOD_DSP_DESCRIPTION dspgaindesc =
|
||||
{
|
||||
"FMOD gain example", // name
|
||||
0x00010000, // version 0xAAAABBBB A = major, B = minor.
|
||||
0, // 0 = we can filter whatever you throw at us. To be most user friendly, always write a filter like this.
|
||||
dspcreate, //
|
||||
dsprelease, //
|
||||
dspreset, //
|
||||
dspread, //
|
||||
0, // This is for if you want to allow the plugin to seek, which doesnt really make sense in a gain filter so we'll just leave it out.
|
||||
1, // 1 parameter. "level"
|
||||
dspparam, // pointer to the parameter list definition.
|
||||
dspsetparam, //
|
||||
dspgetparam, //
|
||||
0, // This is for if you want to pop up a dialog box to configure the plugin. Not doing that here.
|
||||
0, // This is for if you want to pop up a dialog box to configure the plugin. Not doing that here.
|
||||
0, // This is for if you want to pop up a dialog box to configure the plugin. Not doing that here.
|
||||
};
|
||||
|
||||
/*
|
||||
FMODGetDSPDescription is mandantory for every fmod plugin. This is the symbol the registerplugin function searches for.
|
||||
Must be declared with F_API to make it export as stdcall.
|
||||
MUST BE EXTERN'ED AS C! C++ functions will be mangled incorrectly and not load in fmod.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
F_DECLSPEC F_DLLEXPORT FMOD_DSP_DESCRIPTION * F_API FMODGetDSPDescription()
|
||||
{
|
||||
return &dspgaindesc;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct dspgain_state
|
||||
{
|
||||
float gain;
|
||||
} dspgain_state;
|
||||
|
||||
|
||||
FMOD_RESULT F_CALLBACK dspcreate(FMOD_DSP_STATE *dsp)
|
||||
{
|
||||
dspgain_state *state;
|
||||
|
||||
/*
|
||||
If we were allocating memory for buffers etc, it would be done in this function.
|
||||
*/
|
||||
|
||||
state = (dspgain_state *)malloc(sizeof(dspgain_state));
|
||||
if (!state)
|
||||
{
|
||||
return FMOD_ERR_MEMORY;
|
||||
}
|
||||
|
||||
state->gain = dspparam[0].defaultval;
|
||||
|
||||
dsp->plugindata = state;
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
FMOD_RESULT F_CALLBACK dsprelease(FMOD_DSP_STATE *dsp)
|
||||
{
|
||||
dspgain_state *state = (dspgain_state *)dsp->plugindata;
|
||||
|
||||
/*
|
||||
If memory was allocated in create, it would be freed in this function.
|
||||
*/
|
||||
|
||||
free(state);
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
FMOD_RESULT F_CALLBACK dspreset(FMOD_DSP_STATE *dsp)
|
||||
{
|
||||
dspgain_state *state = (dspgain_state *)dsp->plugindata;
|
||||
|
||||
/*
|
||||
This isnt really needed here. It is used to reset a filter back to it's default state.
|
||||
*/
|
||||
|
||||
state->gain = dspparam[0].defaultval;
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This callback does the work. Modify data from inbuffer and send it to outbuffer.
|
||||
*/
|
||||
FMOD_RESULT F_CALLBACK dspread(FMOD_DSP_STATE *dsp, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int outchannels)
|
||||
{
|
||||
dspgain_state *state = (dspgain_state *)dsp->plugindata;
|
||||
unsigned int count;
|
||||
int count2;
|
||||
int channels = inchannels; // outchannels and inchannels will always be the same because this is a flexible filter.
|
||||
|
||||
for (count = 0; count < length; count++)
|
||||
{
|
||||
for (count2 = 0; count2 < channels; count2++)
|
||||
{
|
||||
outbuffer[(count * channels) + count2] = inbuffer[(count * channels) + count2] * state->gain;
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
This callback is for when the user sets a parameter. It is automatically clamped between 0 and 1.
|
||||
*/
|
||||
FMOD_RESULT F_CALLBACK dspsetparam(FMOD_DSP_STATE *dsp, int index, float value)
|
||||
{
|
||||
dspgain_state *state = (dspgain_state *)dsp->plugindata;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
state->gain = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
This callback is for when the user gets a parameter. The label for our only parameter is percent,
|
||||
so when the string is requested print it out as 0 to 100.
|
||||
*/
|
||||
FMOD_RESULT F_CALLBACK dspgetparam(FMOD_DSP_STATE *dsp, int index, float *value, char *valuestr)
|
||||
{
|
||||
dspgain_state *state = (dspgain_state *)dsp->plugindata;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
*value = state->gain;
|
||||
sprintf(valuestr, "%.02f", state->gain * 100.0f); // our units are '%', so print it out as 0 to 100.
|
||||
}
|
||||
}
|
||||
|
||||
return FMOD_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
readtags_cpp: main.cpp
|
||||
g++ -O3 -o readtags main.cpp ../../api/lib/libfmodex.so
|
||||
|
||||
readtags_c: main.c
|
||||
g++ -O3 -o readtags main.c ../../api/lib/libfmodex.so
|
||||
|
||||
run:
|
||||
./readtags
|
||||
|
||||
clean:
|
||||
rm -f readtags
|
|
@ -0,0 +1,165 @@
|
|||
/*===============================================================================================
|
||||
ReadTags Example
|
||||
Copyright (c), Firelight Technologies Pty, Ltd 2004-2011.
|
||||
|
||||
This example shows how to read tags from sound files
|
||||
===============================================================================================*/
|
||||
#include "../../api/inc/fmod.h"
|
||||
#include "../../api/inc/fmod_errors.h"
|
||||
#include "../common/wincompat.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ERRCHECK(FMOD_RESULT result)
|
||||
{
|
||||
if (result != FMOD_OK)
|
||||
{
|
||||
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FMOD_SYSTEM *system;
|
||||
FMOD_SOUND *sound;
|
||||
FMOD_RESULT result;
|
||||
FMOD_TAG tag;
|
||||
int numtags, numtagsupdated, count;
|
||||
unsigned int version;
|
||||
|
||||
printf("==================================================================\n");
|
||||
printf("ReadTags Example. Copyright (c) Firelight Technologies 2004-2011.\n");
|
||||
printf("==================================================================\n\n");
|
||||
|
||||
/*
|
||||
Create a System object and initialize.
|
||||
*/
|
||||
result = FMOD_System_Create(&system);
|
||||
ERRCHECK(result);
|
||||
|
||||
result = FMOD_System_GetVersion(system, &version);
|
||||
ERRCHECK(result);
|
||||
|
||||
if (version < FMOD_VERSION)
|
||||
{
|
||||
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
|
||||
getch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
result = FMOD_System_Init(system, 100, FMOD_INIT_NORMAL, NULL);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Open the specified file. Use FMOD_CREATESTREAM and FMOD_OPENONLY so it opens quickly
|
||||
*/
|
||||
result = FMOD_System_CreateSound(system, "../media/wave.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_OPENONLY, 0, &sound);
|
||||
ERRCHECK(result);
|
||||
|
||||
/*
|
||||
Read and display all tags associated with this file
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
/*
|
||||
An index of -1 means "get the first tag that's new or updated".
|
||||
If no tags are new or updated then getTag will return FMOD_ERR_TAGNOTFOUND.
|
||||
This is the first time we've read any tags so they'll all be new but after we've read them,
|
||||
they won't be new any more.
|
||||
*/
|
||||
if (FMOD_Sound_GetTag(sound, 0, -1, &tag) != FMOD_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
|
||||
{
|
||||
printf("%s = %s (%d bytes)\n", tag.name, tag.data, tag.datalen);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s = <binary> (%d bytes)\n", tag.name, tag.datalen);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Read all the tags regardless of whether they're updated or not. Also show the tag type.
|
||||
*/
|
||||
result = FMOD_Sound_GetNumTags(sound, &numtags, &numtagsupdated);
|
||||
ERRCHECK(result);
|
||||
for (count=0; count < numtags; count++)
|
||||
{
|
||||
result = FMOD_Sound_GetTag(sound, 0, count, &tag);
|
||||
ERRCHECK(result);
|
||||
|
||||
switch (tag.type)
|
||||
{
|
||||
case FMOD_TAGTYPE_UNKNOWN :
|
||||
printf("FMOD_TAGTYPE_UNKNOWN ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_ID3V1 :
|
||||
printf("FMOD_TAGTYPE_ID3V1 ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_ID3V2 :
|
||||
printf("FMOD_TAGTYPE_ID3V2 ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_VORBISCOMMENT :
|
||||
printf("FMOD_TAGTYPE_VORBISCOMMENT ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_SHOUTCAST :
|
||||
printf("FMOD_TAGTYPE_SHOUTCAST ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_ICECAST :
|
||||
printf("FMOD_TAGTYPE_ICECAST ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_ASF :
|
||||
printf("FMOD_TAGTYPE_ASF ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_FMOD :
|
||||
printf("FMOD_TAGTYPE_FMOD ");
|
||||
break;
|
||||
|
||||
case FMOD_TAGTYPE_USER :
|
||||
printf("FMOD_TAGTYPE_USER ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (tag.datatype == FMOD_TAGDATATYPE_STRING)
|
||||
{
|
||||
printf("%s = %s (%d bytes)\n", tag.name, tag.data, tag.datalen);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s = ??? (%d bytes)\n", tag.name, tag.datalen);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Find a specific tag by name. Specify an index > 0 to get access to multiple tags of the same name.
|
||||
*/
|
||||
result = FMOD_Sound_GetTag(sound, "ARTIST", 0, &tag);
|
||||
ERRCHECK(result);
|
||||
printf("%s = %s (%d bytes)\n", tag.name, tag.data, tag.datalen);
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
Shut down
|
||||
*/
|
||||
result = FMOD_Sound_Release(sound);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Close(system);
|
||||
ERRCHECK(result);
|
||||
result = FMOD_System_Release(system);
|
||||
ERRCHECK(result);
|
||||
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue