From 8aac6060d36c5dca48c02988b654d4646b175e64 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 4 May 2020 20:33:48 +0300 Subject: oal upd --- src/audio/AudioManager.cpp | 4 +- src/audio/AudioManager.h | 4 +- src/audio/DMAudio.cpp | 23 + src/audio/DMAudio.h | 2 + src/audio/miles/sampman_mss.cpp | 2257 -------------------------------------- src/audio/miles/sampman_mss.h | 339 ------ src/audio/oal/aldlist.cpp | 329 ++++++ src/audio/oal/aldlist.h | 49 + src/audio/oal/channel.cpp | 209 ++++ src/audio/oal/channel.h | 51 + src/audio/oal/oal_utils.cpp | 176 +++ src/audio/oal/oal_utils.h | 48 + src/audio/oal/stream.cpp | 118 ++ src/audio/oal/stream.h | 57 + src/audio/openal/samp_oal.cpp | 1404 ------------------------ src/audio/openal/samp_oal.h | 340 ------ src/audio/sampman.cpp | 7 - src/audio/sampman.h | 348 +++++- src/audio/sampman_miles.cpp | 2311 +++++++++++++++++++++++++++++++++++++++ src/audio/sampman_oal.cpp | 1372 +++++++++++++++++++++++ src/core/Game.cpp | 19 +- src/core/config.h | 3 +- src/skel/win/win.cpp | 3 +- 23 files changed, 5099 insertions(+), 4374 deletions(-) delete mode 100644 src/audio/miles/sampman_mss.cpp delete mode 100644 src/audio/miles/sampman_mss.h create mode 100644 src/audio/oal/aldlist.cpp create mode 100644 src/audio/oal/aldlist.h create mode 100644 src/audio/oal/channel.cpp create mode 100644 src/audio/oal/channel.h create mode 100644 src/audio/oal/oal_utils.cpp create mode 100644 src/audio/oal/oal_utils.h create mode 100644 src/audio/oal/stream.cpp create mode 100644 src/audio/oal/stream.h delete mode 100644 src/audio/openal/samp_oal.cpp delete mode 100644 src/audio/openal/samp_oal.h delete mode 100644 src/audio/sampman.cpp create mode 100644 src/audio/sampman_miles.cpp create mode 100644 src/audio/sampman_oal.cpp diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index 4f015915..72d1fe30 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -9361,7 +9361,7 @@ cAudioManager::ResetTimers(uint32 time) SampleManager.SetEffectsFadeVolume(0); SampleManager.SetMusicFadeVolume(0); MusicManager.ResetMusicAfterReload(); -#ifdef OPENAL +#ifdef AUDIO_OAL SampleManager.Service(); #endif } @@ -9419,7 +9419,7 @@ cAudioManager::ServiceSoundEffects() ProcessMissionAudio(); AdjustSamplesVolume(); ProcessActiveQueues(); -#ifdef OPENAL +#ifdef AUDIO_OAL SampleManager.Service(); #endif for(int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) { diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 9479d1cd..8fc13ed8 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -600,6 +600,8 @@ public: uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, float dist); }; -//dstatic_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); +#ifdef AUDIO_MSS +static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); +#endif extern cAudioManager AudioManager; diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 11c85dbd..8681f345 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -5,6 +5,7 @@ #include "AudioManager.h" #include "AudioScriptObject.h" #include "sampman.h" +#include "Text.h" cDMAudio DMAudio; @@ -104,6 +105,28 @@ cDMAudio::Get3DProviderName(uint8 id) return AudioManager.Get3DProviderName(id); } +int8 cDMAudio::AutoDetect3DProviders(void) +{ + for ( int32 i = 0; i < GetNum3DProvidersAvailable(); i++ ) + { + wchar buff[64]; + + char *name = Get3DProviderName(i); + AsciiToUnicode(name, buff); + char *providername = UnicodeToAscii(buff); + strupr(providername); +#if defined(AUDIO_MSS) + if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") ) + return i; +#elif defined(AUDIO_OAL) + if ( !strcmp(providername, "OPEANAL SOFT") ) + return i; +#endif + } + + return -1; +} + int8 cDMAudio::GetCurrent3DProviderIndex(void) { diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h index 42688fa6..6a94d57f 100644 --- a/src/audio/DMAudio.h +++ b/src/audio/DMAudio.h @@ -205,6 +205,8 @@ public: uint8 GetNum3DProvidersAvailable(void); char *Get3DProviderName(uint8 id); + int8 AutoDetect3DProviders(void); + int8 GetCurrent3DProviderIndex(void); int8 SetCurrent3DProvider(uint8 which); diff --git a/src/audio/miles/sampman_mss.cpp b/src/audio/miles/sampman_mss.cpp deleted file mode 100644 index f3a6ba80..00000000 --- a/src/audio/miles/sampman_mss.cpp +++ /dev/null @@ -1,2257 +0,0 @@ -#include -#include -#include - -#include - -#include "eax.h" -#include "eax-util.h" -#include "mss.h" - -#include "sampman_mss.h" -#include "AudioManager.h" -#include "MusicManager.h" -#include "Frontend.h" -#include "Timer.h" - - -#pragma comment( lib, "mss32.lib" ) - -cSampleManager SampleManager; -int32 BankStartOffset[MAX_SAMPLEBANKS]; -/////////////////////////////////////////////////////////////// - -char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; -char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; - -FILE *fpSampleDescHandle; -FILE *fpSampleDataHandle; -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; -int32 _nSampleDataEndOffset; - -int32 nPedSlotSfx [MAX_PEDSFX]; -int32 nPedSlotSfxAddr[MAX_PEDSFX]; -uint8 nCurrentPedSlot; - -uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; - -uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; - -/////////////////////////////////////////////////////////////// -struct tMP3Entry -{ - char aFilename[MAX_PATH]; - - uint32 nTrackLength; - uint32 nTrackStreamPos; - - tMP3Entry *pNext; - char *pLinkPath; -}; - -uint32 nNumMP3s; -tMP3Entry *_pMP3List; -char _mp3DirectoryPath[MAX_PATH]; -HSTREAM mp3Stream [MAX_MP3STREAMS]; -int8 nStreamPan [MAX_MP3STREAMS]; -int8 nStreamVolume[MAX_MP3STREAMS]; -uint32 _CurMP3Index; -int32 _CurMP3Pos; -bool _bIsMp3Active; - -#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) -bool _bUseHDDAudio; -char _aHDDPath[MAX_PATH]; -#endif -/////////////////////////////////////////////////////////////// - - -bool _bSampmanInitialised = false; - -// -// Miscellaneous globals / defines - -// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS - -EAXLISTENERPROPERTIES StartEAX3 = - {26, 1.7f, 0.8f, -1000, -1000, -100, 4.42f, 0.14f, 1.00f, 429, 0.014f, 0.00f,0.00f,0.00f, 1023, 0.021f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2727.1f, 250.0f, 0.00f, 0x3f }; - -EAXLISTENERPROPERTIES FinishEAX3 = - {26, 100.0f, 1.0f, 0, -1000, -2200, 20.0f, 1.39f, 1.00f, 1000, 0.069f, 0.00f,0.00f,0.00f, 400, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 3.982f, 0.000f, -18.0f, 3530.8f, 417.9f, 6.70f, 0x3f }; - -EAXLISTENERPROPERTIES EAX3Params; - -S32 prevprovider=-1; -S32 curprovider=-1; -S32 usingEAX=0; -S32 usingEAX3=0; -HPROVIDER opened_provider=0; -H3DSAMPLE opened_samples[MAXCHANNELS] = {0}; -HSAMPLE opened_2dsamples[MAX2DCHANNELS] = {0}; -HDIGDRIVER DIG; -S32 speaker_type=0; - -U32 _maxSamples; -float _fPrevEaxRatioDestination; -bool _usingMilesFast2D; -float _fEffectsLevel; - - -struct -{ - HPROVIDER id; - char name[80]; -}providers[MAXPROVIDERS]; - -typedef struct provider_stuff -{ - char* name; - HPROVIDER id; -} provider_stuff; - - -static int __cdecl comp(const provider_stuff*s1,const provider_stuff*s2) -{ - return( _stricmp(s1->name,s2->name) ); -} - -static void -add_providers() -{ - provider_stuff pi[MAXPROVIDERS]; - U32 n,i,j; - - SampleManager.SetNum3DProvidersAvailable(0); - - HPROENUM next = HPROENUM_FIRST; - - n=0; - while (AIL_enumerate_3D_providers(&next, &pi[n].id, &pi[n].name) && (n MAXCHANNELS ) - _maxSamples = MAXCHANNELS; - - SampleManager.SetSpeakerConfig(speaker_type); - - //obtain a 3D sample handles - for ( U32 i = 0; i < _maxSamples; ++i ) - { - opened_samples[i] = AIL_allocate_3D_sample_handle(opened_provider); - if ( opened_samples[i] != NULL ) - AIL_set_3D_sample_effects_level(opened_samples[i], 0.0f); - } - - return true; - } - } - - return false; -} - -void -cSampleManager::SetSpeakerConfig(int32 which) -{ - switch ( which ) - { - case 1: - speaker_type=AIL_3D_2_SPEAKER; - break; - - case 2: - speaker_type=AIL_3D_HEADPHONE; - break; - - case 3: - speaker_type=AIL_3D_4_SPEAKER; - break; - - default: - return; - break; - } - - if (opened_provider) - AIL_set_3D_speaker_type(opened_provider, speaker_type); -} - -uint32 -cSampleManager::GetMaximumSupportedChannels(void) -{ - if ( _maxSamples > MAXCHANNELS ) - return MAXCHANNELS; - - return _maxSamples; -} - -int8 -cSampleManager::GetCurrent3DProviderIndex(void) -{ - return curprovider; -} - -int8 -cSampleManager::SetCurrent3DProvider(uint8 nProvider) -{ - S32 savedprovider = curprovider; - - if ( nProvider < m_nNumberOfProviders ) - { - if ( set_new_provider(nProvider) ) - return curprovider; - else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) ) - return curprovider; - else - return -1; - } - else - return curprovider; -} - -static bool -_ResolveLink(char const *path, char *out) -{ - IShellLink* psl; - WIN32_FIND_DATA fd; - char filepath[MAX_PATH]; - - CoInitialize(NULL); - - if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl ) )) - { - IPersistFile *ppf; - - if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf))) - { - WCHAR wpath[MAX_PATH]; - - MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH); - - if (SUCCEEDED(ppf->Load(wpath, STGM_READ))) - { - /* Resolve the link */ - if (SUCCEEDED(psl->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI|SLR_NOSEARCH))) - { - strcpy(filepath, path); - - if (SUCCEEDED(psl->GetPath(filepath, MAX_PATH, &fd, SLGP_UNCPRIORITY))) - { - OutputDebugString(fd.cFileName); - - strcpy(out, filepath); - // FIX: Release the objects. Taken from SA. -#ifdef FIX_BUGS - ppf->Release(); - psl->Release(); -#endif - return true; - } - } - } - - ppf->Release(); - } - psl->Release(); - } - - return false; -} - -static void -_FindMP3s(void) -{ - tMP3Entry *pList; - bool bShortcut; - bool bInitFirstEntry; - HANDLE hFind; - char path[MAX_PATH]; - char filepath[MAX_PATH*2]; - S32 total_ms; - WIN32_FIND_DATA fd; - - - if ( GetCurrentDirectory(MAX_PATH, _mp3DirectoryPath) == 0 ) - { - GetLastError(); - return; - } - - OutputDebugString("Finding MP3s..."); - strcpy(path, _mp3DirectoryPath); - strcat(path, "\\MP3\\"); - - strcpy(_mp3DirectoryPath, path); - OutputDebugString(_mp3DirectoryPath); - - strcat(path, "*"); - - hFind = FindFirstFile(path, &fd); - - if ( hFind == INVALID_HANDLE_VALUE ) - { - GetLastError(); - return; - } - - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - int32 filepathlen = strlen(filepath); - - if ( filepathlen <= 0) - { - FindClose(hFind); - return; - } - - FILE *f = fopen("MP3\\MP3Report.txt", "w"); - - if ( f ) - { - fprintf(f, "MP3 Report File\n\n"); - fprintf(f, "\"%s\"", fd.cFileName); - } - - - if ( filepathlen > 4 ) - { - if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) - { - if ( _ResolveLink(filepath, filepath) ) - { - OutputDebugString("Resolving Link"); - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); - } - else - { - if ( f ) fprintf(f, " - couldn't resolve shortcut"); - } - - bShortcut = true; - } - else - bShortcut = false; - } - - mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); - if ( mp3Stream[0] ) - { - AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); - - AIL_close_stream(mp3Stream[0]); - mp3Stream[0] = NULL; - - OutputDebugString(fd.cFileName); - - _pMP3List = new tMP3Entry; - - if ( _pMP3List == NULL ) - { - FindClose(hFind); - - if ( f ) - fclose(f); - - return; - } - - nNumMP3s = 1; - - strcpy(_pMP3List->aFilename, fd.cFileName); - - _pMP3List->nTrackLength = total_ms; - - _pMP3List->pNext = NULL; - - pList = _pMP3List; - - if ( bShortcut ) - { - _pMP3List->pLinkPath = new char[MAX_PATH*2]; - strcpy(_pMP3List->pLinkPath, filepath); - } - else - { - _pMP3List->pLinkPath = NULL; - } - - if ( f ) fprintf(f, " - OK\n"); - - bInitFirstEntry = false; - } - else - { - strcat(filepath, " - NOT A VALID MP3"); - - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); - - bInitFirstEntry = true; - } - - while ( true ) - { - if ( !FindNextFile(hFind, &fd) ) - break; - - if ( bInitFirstEntry ) - { - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - int32 filepathlen = strlen(filepath); - - if ( f ) fprintf(f, "\"%s\"", fd.cFileName); - - if ( filepathlen > 0 ) - { - if ( filepathlen > 4 ) - { - if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) - { - if ( _ResolveLink(filepath, filepath) ) - { - OutputDebugString("Resolving Link"); - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); - } - else - { - if ( f ) fprintf(f, " - couldn't resolve shortcut"); - } - - bShortcut = true; - } - else - { - bShortcut = false; - - if ( filepathlen > MAX_PATH ) - { - if ( f ) fprintf(f, " - Filename and path too long - %s - IGNORED)\n", filepath); - - continue; - } - } - } - - mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); - if ( mp3Stream[0] ) - { - AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); - - AIL_close_stream(mp3Stream[0]); - mp3Stream[0] = NULL; - - OutputDebugString(fd.cFileName); - - _pMP3List = new tMP3Entry; - - if ( _pMP3List == NULL) - break; - - nNumMP3s = 1; - - strcpy(_pMP3List->aFilename, fd.cFileName); - - _pMP3List->nTrackLength = total_ms; - _pMP3List->pNext = NULL; - - if ( bShortcut ) - { - _pMP3List->pLinkPath = new char [MAX_PATH*2]; - strcpy(_pMP3List->pLinkPath, filepath); - } - else - { - _pMP3List->pLinkPath = NULL; - } - - pList = _pMP3List; - - if ( f ) fprintf(f, " - OK\n"); - - bInitFirstEntry = false; - } - else - { - strcat(filepath, " - NOT A VALID MP3"); - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); - } - } - } - else - { - strcpy(filepath, _mp3DirectoryPath); - strcat(filepath, fd.cFileName); - - int32 filepathlen = strlen(filepath); - - if ( filepathlen > 0 ) - { - if ( f ) fprintf(f, "\"%s\"", fd.cFileName); - - if ( filepathlen > 4 ) - { - if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) - { - if ( _ResolveLink(filepath, filepath) ) - { - OutputDebugString("Resolving Link"); - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); - } - else - { - if ( f ) fprintf(f, " - couldn't resolve shortcut"); - } - - bShortcut = true; - } - else - { - bShortcut = false; - } - } - - mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); - if ( mp3Stream[0] ) - { - AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); - - AIL_close_stream(mp3Stream[0]); - mp3Stream[0] = NULL; - - pList->pNext = new tMP3Entry; - - tMP3Entry *e = pList->pNext; - - if ( e == NULL ) - break; - - pList = pList->pNext; - - strcpy(e->aFilename, fd.cFileName); - e->nTrackLength = total_ms; - e->pNext = NULL; - - if ( bShortcut ) - { - e->pLinkPath = new char [MAX_PATH*2]; - strcpy(e->pLinkPath, filepath); - } - else - { - e->pLinkPath = NULL; - } - - nNumMP3s++; - - OutputDebugString(fd.cFileName); - - if ( f ) fprintf(f, " - OK\n"); - } - else - { - strcat(filepath, " - NOT A VALID MP3"); - OutputDebugString(filepath); - - if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); - } - } - } - } - - if ( f ) - { - fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s); - fclose(f); - } - - FindClose(hFind); -} - -static void -_DeleteMP3Entries(void) -{ - tMP3Entry *e = _pMP3List; - - while ( e != NULL ) - { - tMP3Entry *next = e->pNext; - - if ( next == NULL ) - next = NULL; - - if ( e->pLinkPath != NULL ) - { -#ifndef FIX_BUGS - delete e->pLinkPath; // BUG: should be delete [] -#else - delete[] e->pLinkPath; -#endif - e->pLinkPath = NULL; - } - - delete e; - - if ( next ) - e = next; - else - e = NULL; - - nNumMP3s--; - } - - - if ( nNumMP3s != 0 ) - { - OutputDebugString("Not all MP3 entries were deleted"); - nNumMP3s = 0; - } - - _pMP3List = NULL; -} - -static tMP3Entry * -_GetMP3EntryByIndex(uint32 idx) -{ - uint32 n = ( idx < nNumMP3s ) ? idx : 0; - - if ( _pMP3List != NULL ) - { - tMP3Entry *e = _pMP3List; - - for ( uint32 i = 0; i < n; i++ ) - e = e->pNext; - - return e; - - } - - return NULL; -} - -static inline bool -_GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) -{ - _CurMP3Index = 0; - - for ( *pEntry = _pMP3List; *pEntry != NULL; *pEntry = (*pEntry)->pNext ) - { - if ( *pPosition >= (*pEntry)->nTrackStreamPos - && *pPosition < (*pEntry)->nTrackLength + (*pEntry)->nTrackStreamPos ) - { - *pPosition -= (*pEntry)->nTrackStreamPos; - _CurMP3Pos = *pPosition; - - return true; - } - - _CurMP3Index++; - } - - *pPosition = 0; - *pEntry = _pMP3List; - _CurMP3Pos = 0; - _CurMP3Index = 0; - - return false; -} - -bool -cSampleManager::IsMP3RadioChannelAvailable(void) -{ - return nNumMP3s != 0; -} - -void -cSampleManager::ReleaseDigitalHandle(void) -{ - if ( DIG ) - { - prevprovider = curprovider; - release_existing(); - curprovider = -1; - AIL_digital_handle_release(DIG); - } -} - -void -cSampleManager::ReacquireDigitalHandle(void) -{ - if ( DIG ) - { - AIL_digital_handle_reacquire(DIG); - if ( prevprovider != -1 ) - set_new_provider(prevprovider); - } -} - -bool -cSampleManager::Initialise(void) -{ - TRACE("start"); - - if ( _bSampmanInitialised ) - return true; - - { - for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) - { - m_aSamples[i].nOffset = 0; - m_aSamples[i].nSize = 0; - m_aSamples[i].nFrequency = 22050; - m_aSamples[i].nLoopStart = 0; - m_aSamples[i].nLoopEnd = -1; - } - - m_nEffectsVolume = MAX_VOLUME; - m_nMusicVolume = MAX_VOLUME; - m_nEffectsFadeVolume = MAX_VOLUME; - m_nMusicFadeVolume = MAX_VOLUME; - - m_nMonoMode = 0; - } - - // miles - TRACE("MILES"); - { - curprovider = -1; - prevprovider = -1; - - _usingMilesFast2D = false; - usingEAX=0; - usingEAX3=0; - - _fEffectsLevel = 0.0f; - - _maxSamples = 0; - - opened_provider = NULL; - DIG = NULL; - - for ( int32 i = 0; i < MAXCHANNELS; i++ ) - opened_samples[i] = NULL; - } - - // banks - TRACE("banks"); - { - fpSampleDescHandle = NULL; - fpSampleDataHandle = NULL; - - _nSampleDataEndOffset = 0; - - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) - { - bSampleBankLoaded[i] = false; - nSampleBankDiscStartOffset[i] = 0; - nSampleBankSize[i] = 0; - nSampleBankMemoryStartAddress[i] = 0; - } - } - - // pedsfx - TRACE("pedsfx"); - { - for ( int32 i = 0; i < MAX_PEDSFX; i++ ) - { - nPedSlotSfx[i] = NO_SAMPLE; - nPedSlotSfxAddr[i] = 0; - } - - nCurrentPedSlot = 0; - } - - // channel volume - TRACE("vol"); - { - for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) - nChannelVolume[i] = 0; - } - - TRACE("mss"); - { - AIL_set_redist_directory( "mss" ); - - AIL_startup(); - - AIL_set_preference(DIG_MIXER_CHANNELS, MAX_DIGITAL_MIXER_CHANNELS); - - DIG = AIL_open_digital_driver(DIGITALRATE, DIGITALBITS, DIGITALCHANNELS, 0); - if ( DIG == NULL ) - { - OutputDebugString(AIL_last_error()); - Terminate(); - return false; - } - - add_providers(); - - if ( !InitialiseSampleBanks() ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SAMPLEBANK_MAIN]); - if ( !nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); - - } - - TRACE("cdrom"); - - S32 tatalms; - char filepath[MAX_PATH]; - - { - m_bInitialised = false; - - while (true) - { - int32 drive = 'C'; - - do - { - char latter[2]; - - latter[0] = drive; - latter[1] = '\0'; - - strcpy(m_szCDRomRootPath, latter); - strcat(m_szCDRomRootPath, ":\\"); - - if ( GetDriveType(m_szCDRomRootPath) == DRIVE_CDROM ) - { - strcpy(filepath, m_szCDRomRootPath); - strcat(filepath, StreamedNameTable[0]); - - FILE *f = fopen(filepath, "rb"); - - if ( f ) - { - fclose(f); - - bool bFileNotFound = false; - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - { - strcpy(filepath, m_szCDRomRootPath); - strcat(filepath, StreamedNameTable[i]); - - mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); - - if ( mp3Stream[0] ) - { - AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL); - - AIL_close_stream(mp3Stream[0]); - mp3Stream[0] = NULL; - - nStreamLength[i] = tatalms; - } - else - { - bFileNotFound = true; - break; - } - } - - if ( !bFileNotFound ) - { - m_bInitialised = true; - break; - } - else - { - m_bInitialised = false; - continue; - } - } - } - - } while ( ++drive <= 'Z' ); - - if ( !m_bInitialised ) - { -#if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) - FrontEndMenuManager.WaitForUserCD(); - if ( FrontEndMenuManager.m_bQuitGameNoCD ) - { - Terminate(); - return false; - } - continue; -#else - m_bInitialised = true; -#endif - } - - break; - } - } - -#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) - // hddaudio - /** - Option for user to play audio files directly from hard disk. - Copy the contents of the PLAY discs Audio directory into your installed Grand Theft Auto III Audio directory. - Grand Theft Auto III still requires the presence of the PLAY disc when started. - This may give better performance on some machines (though worse on others). - **/ - TRACE("hddaudio 1.1 patch"); - { - int32 streamLength[TOTAL_STREAMED_SOUNDS]; - - bool bFileNotFound = false; - char rootpath[MAX_PATH]; - - strcpy(_aHDDPath, m_szCDRomRootPath); - rootpath[0] = '\0'; - - FILE *f = fopen(StreamedNameTable[0], "rb"); - - if ( f ) - { - fclose(f); - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - { - strcpy(filepath, rootpath); - strcat(filepath, StreamedNameTable[i]); - - mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); - - if ( mp3Stream[0] ) - { - AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL); - - AIL_close_stream(mp3Stream[0]); - mp3Stream[0] = NULL; - - streamLength[i] = tatalms; - } - else - { - bFileNotFound = true; - break; - } - } - - } - else - bFileNotFound = true; - - if ( !bFileNotFound ) - { - strcpy(m_szCDRomRootPath, rootpath); - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - nStreamLength[i] = streamLength[i]; - - _bUseHDDAudio = true; - } - else - _bUseHDDAudio = false; - } -#endif - - TRACE("stream"); - { - for ( int32 i = 0; i < MAX_MP3STREAMS; i++ ) - { - mp3Stream [i] = NULL; - nStreamPan [i] = 63; - nStreamVolume[i] = 100; - } - } - - for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) - { - opened_2dsamples[i] = AIL_allocate_sample_handle(DIG); - if ( opened_2dsamples[i] ) - { - AIL_init_sample(opened_2dsamples[i]); - AIL_set_sample_type(opened_2dsamples[i], DIG_F_MONO_16, DIG_PCM_SIGN); - } - } - - TRACE("providerset"); - { - _bSampmanInitialised = true; - - U32 n = 0; - - while ( n < m_nNumberOfProviders ) - { - if ( !strcmp(providers[n].name, "Miles Fast 2D Positional Audio") ) - { - set_new_provider(n); - break; - } - n++; - } - - if ( n == m_nNumberOfProviders ) - { - Terminate(); - return false; - } - } - - TRACE("bank"); - - LoadSampleBank(SAMPLEBANK_MAIN); - - // mp3 - TRACE("mp3"); - { - nNumMP3s = 0; - - _pMP3List = NULL; - - _FindMP3s(); - - if ( nNumMP3s != 0 ) - { - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; - - for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) - { - e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; - nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; - } - - time_t t = time(NULL); - tm *localtm; - bool bUseRandomTable; - - if ( t == -1 ) - bUseRandomTable = true; - else - { - bUseRandomTable = false; - localtm = localtime(&t); - } - - int32 randval; - if ( bUseRandomTable ) - randval = AudioManager.GetRandomNumber(1); - else - randval = localtm->tm_sec * localtm->tm_min; - - _CurMP3Index = randval % nNumMP3s; - - tMP3Entry *randmp3 = _pMP3List; - for ( int32 i = randval % nNumMP3s; i > 0; --i) - randmp3 = randmp3->pNext; - - if ( bUseRandomTable ) - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; - else - { - if ( localtm->tm_sec > 0 ) - { - int32 s = localtm->tm_sec; - _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; - } - else - _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; - } - } - else - _CurMP3Pos = 0; - - _bIsMp3Active = false; - } - - TRACE("end"); - - return true; -} - -void -cSampleManager::Terminate(void) -{ - for ( int32 i = 0; i < MAX_MP3STREAMS; i++ ) - { - if ( mp3Stream[i] ) - { - AIL_pause_stream(mp3Stream[i], 1); - AIL_close_stream(mp3Stream[i]); - mp3Stream[i] = NULL; - } - } - - for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) - { - if ( opened_2dsamples[i] ) - { - AIL_release_sample_handle(opened_2dsamples[i]); - opened_2dsamples[i] = NULL; - } - } - - release_existing(); - - _DeleteMP3Entries(); - - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) - { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; - } - - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) - { - AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; - } - - if ( DIG ) - { - AIL_close_digital_driver(DIG); - DIG = NULL; - } - - AIL_shutdown(); - - _bSampmanInitialised = false; -} - -bool -cSampleManager::CheckForAnAudioFileOnCD(void) -{ -#if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) - char filepath[MAX_PATH]; - -#if defined(GTA3_1_1_PATCH) - if (_bUseHDDAudio) - strcpy(filepath, _aHDDPath); - else - strcpy(filepath, m_szCDRomRootPath); -#else - strcpy(filepath, m_szCDRomRootPath); -#endif // #if defined(GTA3_1_1_PATCH) - - strcat(filepath, StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]); - - FILE *f = fopen(filepath, "rb"); - - if ( f ) - { - fclose(f); - - return true; - } - - return false; - -#else - return true; -#endif // #if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) -} - -char -cSampleManager::GetCDAudioDriveLetter(void) -{ -#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) - if (_bUseHDDAudio) - { - if ( strlen(_aHDDPath) != 0 ) - return _aHDDPath[0]; - else - return '\0'; - } - else - { - if ( strlen(m_szCDRomRootPath) != 0 ) - return m_szCDRomRootPath[0]; - else - return '\0'; - } -#else - if ( strlen(m_szCDRomRootPath) != 0 ) - return m_szCDRomRootPath[0]; - else - return '\0'; -#endif -} - -void -cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuffers ? -{ - if ( _bSampmanInitialised ) - { - for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) - { - if ( i < MAXCHANNELS ) - { - if ( opened_samples[i] && GetChannelUsedFlag(i) ) - { - if ( nChannelVolume[i] ) - { - AIL_set_3D_sample_volume(opened_samples[i], - m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); - } - } - } - else - { - if ( opened_2dsamples[i - MAXCHANNELS] ) - { - if ( GetChannelUsedFlag(i - MAXCHANNELS) ) - { - if ( nChannelVolume[i - MAXCHANNELS] ) - { - AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS], - m_nEffectsFadeVolume * nChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); - } - } - } - } - } - } -} - -void -cSampleManager::SetEffectsMasterVolume(uint8 nVolume) -{ - m_nEffectsVolume = nVolume; - UpdateEffectsVolume(); -} - -void -cSampleManager::SetMusicMasterVolume(uint8 nVolume) -{ - m_nMusicVolume = nVolume; -} - -void -cSampleManager::SetEffectsFadeVolume(uint8 nVolume) -{ - m_nEffectsFadeVolume = nVolume; - UpdateEffectsVolume(); -} - -void -cSampleManager::SetMusicFadeVolume(uint8 nVolume) -{ - m_nMusicFadeVolume = nVolume; -} - -bool -cSampleManager::LoadSampleBank(uint8 nBank) -{ - if ( CTimer::GetIsCodePaused() ) - return false; - - if ( MusicManager.IsInitialised() - && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) - { - return false; - } - - if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - return false; - - if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) - return false; - - bSampleBankLoaded[nBank] = true; - - return true; -} - -void -cSampleManager::UnloadSampleBank(uint8 nBank) -{ - bSampleBankLoaded[nBank] = false; -} - -bool -cSampleManager::IsSampleBankLoaded(uint8 nBank) -{ - return bSampleBankLoaded[nBank]; -} - -bool -cSampleManager::IsPedCommentLoaded(uint32 nComment) -{ - uint8 slot; - - for ( int32 i = 0; i < _TODOCONST(3); i++ ) - { - slot = nCurrentPedSlot - i - 1; - if ( nComment == nPedSlotSfx[slot] ) - return true; - } - - return false; -} - -int32 -cSampleManager::_GetPedCommentSlot(uint32 nComment) -{ - uint8 slot; - - for ( int32 i = 0; i < _TODOCONST(3); i++ ) - { - slot = nCurrentPedSlot - i - 1; - if ( nComment == nPedSlotSfx[slot] ) - return slot; - } - - return -1; -} - -bool -cSampleManager::LoadPedComment(uint32 nComment) -{ - if ( CTimer::GetIsCodePaused() ) - return false; - - // no talking peds during cutsenes or the game end - if ( MusicManager.IsInitialised() ) - { - switch ( MusicManager.GetMusicMode() ) - { - case MUSICMODE_CUTSCENE: - { - return false; - - break; - } - - case MUSICMODE_FRONTEND: - { - if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) - return false; - - break; - } - } - } - - if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) - return false; - - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) - return false; - - nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot; - nPedSlotSfx [nCurrentPedSlot] = nComment; - - if ( ++nCurrentPedSlot >= MAX_PEDSFX ) - nCurrentPedSlot = 0; - - return true; -} - -int32 -cSampleManager::GetSampleBaseFrequency(uint32 nSample) -{ - return m_aSamples[nSample].nFrequency; -} - -int32 -cSampleManager::GetSampleLoopStartOffset(uint32 nSample) -{ - return m_aSamples[nSample].nLoopStart; -} - -int32 -cSampleManager::GetSampleLoopEndOffset(uint32 nSample) -{ - return m_aSamples[nSample].nLoopEnd; -} - -uint32 -cSampleManager::GetSampleLength(uint32 nSample) -{ - return m_aSamples[nSample].nSize >> 1; -} - -bool -cSampleManager::UpdateReverb(void) -{ - if ( !usingEAX ) - return false; - - if ( AudioManager.GetFrameCounter() & 15 ) - return false; - - float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM); - float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT); - float z = AudioManager.GetReflectionsDistance(REFLECTION_UP); - - float normy = norm(y, 5.0f, 40.0f); - float normx = norm(x, 5.0f, 40.0f); - float normz = norm(z, 5.0f, 40.0f); - - float fRatio; - - if ( normy == 0.0f ) - { - if ( normx == 0.0f ) - { - if ( normz == 0.0f ) - fRatio = 0.3f; - else - fRatio = 0.5f; - } - else - { - fRatio = 0.3f; - } - } - else - { - if ( normx == 0.0f ) - { - if ( normz == 0.0f ) - fRatio = 0.3f; - else - fRatio = 0.5f; - } - else - { - if ( normz == 0.0f ) - fRatio = 0.3f; - else - fRatio = (normy+normx+normz) / 3.0f; - } - } - - fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); - - if ( fRatio == _fPrevEaxRatioDestination ) - return false; - - if ( usingEAX3 ) - { - if ( EAX3ListenerInterpolate(&StartEAX3, &FinishEAX3, fRatio, &EAX3Params, false) ) - { - AIL_set_3D_provider_preference(opened_provider, "EAX all parameters", &EAX3Params); - _fEffectsLevel = 1.0f - fRatio * 0.5f; - } - } - else - { - if ( _usingMilesFast2D ) - _fEffectsLevel = (1.0f - fRatio) * 0.4f; - else - _fEffectsLevel = (1.0f - fRatio) * 0.7f; - } - - _fPrevEaxRatioDestination = fRatio; - - return true; -} - -void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( usingEAX ) - { - if ( nReverbFlag != 0 ) - { - if ( !b2d ) - AIL_set_3D_sample_effects_level(opened_samples[nChannel], _fEffectsLevel); - } - else - { - if ( !b2d ) - AIL_set_3D_sample_effects_level(opened_samples[nChannel], 0.0f); - } - } -} - -bool -cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - int32 addr; - - if ( nSfx < SAMPLEBANK_MAX ) - { - if ( !IsSampleBankLoaded(nBank) ) - return false; - - addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; - } - else - { - if ( !IsPedCommentLoaded(nSfx) ) - return false; - - int32 slot = _GetPedCommentSlot(nSfx); - - addr = nPedSlotSfxAddr[slot]; - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - { - AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); - return true; - } - else - return false; - } - else - { - AILSOUNDINFO info; - - info.format = WAVE_FORMAT_PCM; - info.data_ptr = (void *)addr; - info.channels = 1; - info.data_len = m_aSamples[nSfx].nSize; - info.rate = m_aSamples[nSfx].nFrequency; - info.bits = 16; - - if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) - { - OutputDebugString(AIL_last_error()); - return false; - } - - return true; - } -} - -void -cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) -{ - uint32 vol = nVolume; - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - - nChannelVolume[nChannel] = vol; - - // increase the volume for JB.MP3 and S4_BDBD.MP3 - if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) - { - nChannelVolume[nChannel] >>= 2; - } - - if ( opened_samples[nChannel] ) - AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); - -} - -void -cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) -{ - if ( opened_samples[nChannel] ) - AIL_set_3D_position(opened_samples[nChannel], -fX, fY, fZ); -} - -void -cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) -{ - if ( opened_samples[nChannel] ) - AIL_set_3D_sample_distances(opened_samples[nChannel], fMax, fMin); -} - -void -cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) -{ - uint32 vol = nVolume; - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - - switch ( nChannel ) - { - case CHANNEL2D: - { - nChannelVolume[nChannel] = vol; - - // increase the volume for JB.MP3 and S4_BDBD.MP3 - if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) - { - nChannelVolume[nChannel] >>= 2; - } - - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - { - AIL_set_sample_volume(opened_2dsamples[nChannel - MAXCHANNELS], - m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); - } - - break; - } - } -} - -void -cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) -{ - switch ( nChannel ) - { - case CHANNEL2D: - { -#ifndef FIX_BUGS - if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG -#else - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) -#endif - AIL_set_sample_pan(opened_2dsamples[nChannel - MAXCHANNELS], nPan); - - break; - } - } -} - -void -cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - AIL_set_sample_playback_rate(opened_2dsamples[nChannel - MAXCHANNELS], nFreq); - } - else - { - if ( opened_samples[nChannel] ) - AIL_set_3D_sample_playback_rate(opened_samples[nChannel], nFreq); - } -} - -void -cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - AIL_set_sample_loop_block(opened_2dsamples[nChannel - MAXCHANNELS], nLoopStart, nLoopEnd); - } - else - { - if ( opened_samples[nChannel] ) - AIL_set_3D_sample_loop_block(opened_samples[nChannel], nLoopStart, nLoopEnd); - } -} - -void -cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - AIL_set_sample_loop_count(opened_2dsamples[nChannel - MAXCHANNELS], nLoopCount); - } - else - { - if ( opened_samples[nChannel] ) - AIL_set_3D_sample_loop_count(opened_samples[nChannel], nLoopCount); - } -} - -bool -cSampleManager::GetChannelUsedFlag(uint32 nChannel) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - return AIL_sample_status(opened_2dsamples[nChannel - MAXCHANNELS]) == SMP_PLAYING; - else - return false; - } - else - { - if ( opened_samples[nChannel] ) - return AIL_3D_sample_status(opened_samples[nChannel]) == SMP_PLAYING; - else - return false; - } - -} - -void -cSampleManager::StartChannel(uint32 nChannel) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - AIL_start_sample(opened_2dsamples[nChannel - MAXCHANNELS]); - } - else - { - if ( opened_samples[nChannel] ) - AIL_start_3D_sample(opened_samples[nChannel]); - } -} - -void -cSampleManager::StopChannel(uint32 nChannel) -{ - bool b2d = false; - - switch ( nChannel ) - { - case CHANNEL2D: - { - b2d = true; - break; - } - } - - if ( b2d ) - { - if ( opened_2dsamples[nChannel - MAXCHANNELS] ) - AIL_end_sample(opened_2dsamples[nChannel - MAXCHANNELS]); - } - else - { - if ( opened_samples[nChannel] ) - { - if ( AIL_3D_sample_status(opened_samples[nChannel]) == SMP_PLAYING ) - AIL_end_3D_sample(opened_samples[nChannel]); - } - } -} - -void -cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) -{ - if ( m_bInitialised ) - { - if ( nFile < TOTAL_STREAMED_SOUNDS ) - { - if ( mp3Stream[nStream] ) - { - AIL_pause_stream(mp3Stream[nStream], 1); - AIL_close_stream(mp3Stream[nStream]); - } - - char filepath[MAX_PATH]; - - strcpy(filepath, m_szCDRomRootPath); - strcat(filepath, StreamedNameTable[nFile]); - - mp3Stream[nStream] = AIL_open_stream(DIG, filepath, 0); - - if ( mp3Stream[nStream] ) - { - AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_service_stream(mp3Stream[nStream], 1); - } - else - OutputDebugString(AIL_last_error()); - } - } -} - -void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) -{ - if ( m_bInitialised ) - { - if ( mp3Stream[nStream] ) - AIL_pause_stream(mp3Stream[nStream], nPauseFlag != 0); - } -} - -void -cSampleManager::StartPreloadedStreamedFile(uint8 nStream) -{ - if ( m_bInitialised ) - { - if ( mp3Stream[nStream] ) - AIL_start_stream(mp3Stream[nStream]); - } -} - -bool -cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) -{ - uint32 position = nPos; - char filename[MAX_PATH]; - - if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS ) - { - if ( mp3Stream[nStream] ) - { - AIL_pause_stream(mp3Stream[nStream], 1); - AIL_close_stream(mp3Stream[nStream]); - } - - if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) - { - uint32 i = 0; - do { - if(i != 0 || _bIsMp3Active) { - if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; - - _CurMP3Pos = 0; - - tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); - - if(mp3) { - mp3 = _pMP3List; - if(mp3 == NULL) { - _bIsMp3Active = false; - nFile = 0; - strcpy(filename, m_szCDRomRootPath); - strcat(filename, StreamedNameTable[nFile]); - - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count( - mp3Stream[nStream], 1); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], - 0); - return true; - } - - return false; - } - } - - if(mp3->pLinkPath != NULL) - mp3Stream[nStream] = - AIL_open_stream(DIG, mp3->pLinkPath, 0); - else { - strcpy(filename, _mp3DirectoryPath); - strcat(filename, mp3->aFilename); - - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - } - - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], 0); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; - } - - _bIsMp3Active = false; - continue; - } - if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) - position = 0; - - tMP3Entry *e; - if ( !_GetMP3PosFromStreamPos(&position, &e) ) - { - if ( e == NULL ) - { - nFile = 0; - strcpy(filename, m_szCDRomRootPath); - strcat(filename, StreamedNameTable[nFile]); - mp3Stream[nStream] = - AIL_open_stream(DIG, filename, 0); - if(mp3Stream[nStream]) { - AIL_set_stream_loop_count( - mp3Stream[nStream], 1); - AIL_set_stream_ms_position( - mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; - } - - return false; - } - } - - if ( e->pLinkPath != NULL ) - mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0); - else - { - strcpy(filename, _mp3DirectoryPath); - strcat(filename, e->aFilename); - - mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); - } - - if ( mp3Stream[nStream] ) - { - AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], 0); - - _bIsMp3Active = true; - - return true; - } - - _bIsMp3Active = false; - - } while(++i < nNumMP3s); - - position = 0; - nFile = 0; - } - - strcpy(filename, m_szCDRomRootPath); - strcat(filename, StreamedNameTable[nFile]); - - mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); - if ( mp3Stream[nStream] ) - { - AIL_set_stream_loop_count(mp3Stream[nStream], 1); - AIL_set_stream_ms_position(mp3Stream[nStream], position); - AIL_pause_stream(mp3Stream[nStream], 0); - return true; - } - } - - return false; -} - -void -cSampleManager::StopStreamedFile(uint8 nStream) -{ - if ( m_bInitialised ) - { - if ( mp3Stream[nStream] ) - { - AIL_pause_stream(mp3Stream[nStream], 1); - - AIL_close_stream(mp3Stream[nStream]); - mp3Stream[nStream] = NULL; - - if ( nStream == 0 ) - _bIsMp3Active = false; - } - } -} - -int32 -cSampleManager::GetStreamedFilePosition(uint8 nStream) -{ - S32 currentms; - - if ( m_bInitialised ) - { - if ( mp3Stream[nStream] ) - { - if ( _bIsMp3Active ) - { - tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); - - if ( mp3 != NULL ) - { - AIL_stream_ms_position(mp3Stream[nStream], NULL, ¤tms); - return currentms + mp3->nTrackStreamPos; - } - else - return 0; - } - else - { - AIL_stream_ms_position(mp3Stream[nStream], NULL, ¤tms); - return currentms; - } - } - } - - return 0; -} - -void -cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) -{ - uint8 vol = nVolume; - - if ( m_bInitialised ) - { - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - - nStreamVolume[nStream] = vol; - nStreamPan[nStream] = nPan; - - if ( mp3Stream[nStream] ) - { - if ( nEffectFlag ) - AIL_set_stream_volume(mp3Stream[nStream], m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); - else - AIL_set_stream_volume(mp3Stream[nStream], m_nMusicFadeVolume*vol*m_nMusicVolume >> 14); - - AIL_set_stream_pan(mp3Stream[nStream], nPan); - } - } -} - -int32 -cSampleManager::GetStreamedFileLength(uint8 nStream) -{ - if ( m_bInitialised ) - return nStreamLength[nStream]; - - return 0; -} - -bool -cSampleManager::IsStreamPlaying(uint8 nStream) -{ - if ( m_bInitialised ) - { - if ( mp3Stream[nStream] ) - { - if ( AIL_stream_status(mp3Stream[nStream]) == SMP_PLAYING ) - return true; - else - return false; - } - } - - return false; -} - -bool -cSampleManager::InitialiseSampleBanks(void) -{ - int32 nBank = SAMPLEBANK_MAIN; - - fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); - if ( fpSampleDescHandle == NULL ) - return false; - - fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); - if ( fpSampleDataHandle == NULL ) - { - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; - - return false; - } - - fseek(fpSampleDataHandle, 0, SEEK_END); - _nSampleDataEndOffset = ftell(fpSampleDataHandle); - rewind(fpSampleDataHandle); - - fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); - - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; - - for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) - { -#ifdef FIX_BUGS - if (nBank >= MAX_SAMPLEBANKS) break; -#endif - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) - { - nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; - nBank++; - } - } - - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; - - return true; -} diff --git a/src/audio/miles/sampman_mss.h b/src/audio/miles/sampman_mss.h deleted file mode 100644 index ebedfb63..00000000 --- a/src/audio/miles/sampman_mss.h +++ /dev/null @@ -1,339 +0,0 @@ -#pragma once -#include "common.h" -#include "AudioSamples.h" - -#define MAX_VOLUME 127 - -struct tSample { - int32 nOffset; - uint32 nSize; - int32 nFrequency; - int32 nLoopStart; - int32 nLoopEnd; -}; - -enum -{ - SAMPLEBANK_MAIN, - SAMPLEBANK_PED, - MAX_SAMPLEBANKS, - SAMPLEBANK_INVALID -}; - -#define MAX_PEDSFX 7 -#define PED_BLOCKSIZE 79000 - -#define MAXPROVIDERS 64 - -#define MAXCHANNELS 28 -#define MAXCHANNELS_SURROUND 24 -#define MAX2DCHANNELS 1 -#define CHANNEL2D MAXCHANNELS - -#define MAX_MP3STREAMS 2 - -#define DIGITALRATE 32000 -#define DIGITALBITS 16 -#define DIGITALCHANNELS 2 - -#define MAX_DIGITAL_MIXER_CHANNELS 32 - -class cSampleManager -{ - uint8 m_nEffectsVolume; - uint8 m_nMusicVolume; - uint8 m_nEffectsFadeVolume; - uint8 m_nMusicFadeVolume; - uint8 m_nMonoMode; - char unk; - char m_szCDRomRootPath[80]; - bool m_bInitialised; - uint8 m_nNumberOfProviders; - char *m_aAudioProviders[MAXPROVIDERS]; - tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; - -public: - - - - cSampleManager(void) : - m_nNumberOfProviders(0) - { } - - ~cSampleManager(void) - { } - - void SetSpeakerConfig(int32 nConfig); - uint32 GetMaximumSupportedChannels(void); - - uint32 GetNum3DProvidersAvailable() { return m_nNumberOfProviders; } - void SetNum3DProvidersAvailable(uint32 num) { m_nNumberOfProviders = num; } - - char *Get3DProviderName(uint8 id) { return m_aAudioProviders[id]; } - void Set3DProviderName(uint8 id, char *name) { m_aAudioProviders[id] = name; } - - int8 GetCurrent3DProviderIndex(void); - int8 SetCurrent3DProvider(uint8 which); - - bool IsMP3RadioChannelAvailable(void); - - void ReleaseDigitalHandle (void); - void ReacquireDigitalHandle(void); - - bool Initialise(void); - void Terminate (void); - - bool CheckForAnAudioFileOnCD(void); - char GetCDAudioDriveLetter (void); - - void UpdateEffectsVolume(void); - - void SetEffectsMasterVolume(uint8 nVolume); - void SetMusicMasterVolume (uint8 nVolume); - void SetEffectsFadeVolume (uint8 nVolume); - void SetMusicFadeVolume (uint8 nVolume); - - bool LoadSampleBank (uint8 nBank); - void UnloadSampleBank (uint8 nBank); - bool IsSampleBankLoaded(uint8 nBank); - - bool IsPedCommentLoaded(uint32 nComment); - bool LoadPedComment (uint32 nComment); - - int32 _GetPedCommentSlot(uint32 nComment); - - int32 GetSampleBaseFrequency (uint32 nSample); - int32 GetSampleLoopStartOffset(uint32 nSample); - int32 GetSampleLoopEndOffset (uint32 nSample); - uint32 GetSampleLength (uint32 nSample); - - bool UpdateReverb(void); - - void SetChannelReverbFlag (uint32 nChannel, uint8 nReverbFlag); - bool InitialiseChannel (uint32 nChannel, uint32 nSfx, uint8 nBank); - void SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume); - void SetChannel3DPosition (uint32 nChannel, float fX, float fY, float fZ); - void SetChannel3DDistances (uint32 nChannel, float fMax, float fMin); - void SetChannelVolume (uint32 nChannel, uint32 nVolume); - void SetChannelPan (uint32 nChannel, uint32 nPan); - void SetChannelFrequency (uint32 nChannel, uint32 nFreq); - void SetChannelLoopPoints (uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd); - void SetChannelLoopCount (uint32 nChannel, uint32 nLoopCount); - bool GetChannelUsedFlag (uint32 nChannel); - void StartChannel (uint32 nChannel); - void StopChannel (uint32 nChannel); - - void PreloadStreamedFile (uint8 nFile, uint8 nStream); - void PauseStream (uint8 nPauseFlag, uint8 nStream); - void StartPreloadedStreamedFile (uint8 nStream); - bool StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); - void StopStreamedFile (uint8 nStream); - int32 GetStreamedFilePosition (uint8 nStream); - void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream); - int32 GetStreamedFileLength (uint8 nStream); - bool IsStreamPlaying (uint8 nStream); - bool InitialiseSampleBanks(void); -}; - -extern cSampleManager SampleManager; -extern int32 BankStartOffset[MAX_SAMPLEBANKS]; - -static char StreamedNameTable[][25]= -{ - "AUDIO\\HEAD.WAV", - "AUDIO\\CLASS.WAV", - "AUDIO\\KJAH.WAV", - "AUDIO\\RISE.WAV", - "AUDIO\\LIPS.WAV", - "AUDIO\\GAME.WAV", - "AUDIO\\MSX.WAV", - "AUDIO\\FLASH.WAV", - "AUDIO\\CHAT.WAV", - "AUDIO\\HEAD.WAV", - "AUDIO\\POLICE.WAV", - "AUDIO\\CITY.WAV", - "AUDIO\\WATER.WAV", - "AUDIO\\COMOPEN.WAV", - "AUDIO\\SUBOPEN.WAV", - "AUDIO\\JB.MP3", - "AUDIO\\BET.MP3", - "AUDIO\\L1_LG.MP3", - "AUDIO\\L2_DSB.MP3", - "AUDIO\\L3_DM.MP3", - "AUDIO\\L4_PAP.MP3", - "AUDIO\\L5_TFB.MP3", - "AUDIO\\J0_DM2.MP3", - "AUDIO\\J1_LFL.MP3", - "AUDIO\\J2_KCL.MP3", - "AUDIO\\J3_VH.MP3", - "AUDIO\\J4_ETH.MP3", - "AUDIO\\J5_DST.MP3", - "AUDIO\\J6_TBJ.MP3", - "AUDIO\\T1_TOL.MP3", - "AUDIO\\T2_TPU.MP3", - "AUDIO\\T3_MAS.MP3", - "AUDIO\\T4_TAT.MP3", - "AUDIO\\T5_BF.MP3", - "AUDIO\\S0_MAS.MP3", - "AUDIO\\S1_PF.MP3", - "AUDIO\\S2_CTG.MP3", - "AUDIO\\S3_RTC.MP3", - "AUDIO\\S5_LRQ.MP3", - "AUDIO\\S4_BDBA.MP3", - "AUDIO\\S4_BDBB.MP3", - "AUDIO\\S2_CTG2.MP3", - "AUDIO\\S4_BDBD.MP3", - "AUDIO\\S5_LRQB.MP3", - "AUDIO\\S5_LRQC.MP3", - "AUDIO\\A1_SSO.WAV", - "AUDIO\\A2_PP.WAV", - "AUDIO\\A3_SS.WAV", - "AUDIO\\A4_PDR.WAV", - "AUDIO\\A5_K2FT.WAV", - "AUDIO\\K1_KBO.MP3", - "AUDIO\\K2_GIS.MP3", - "AUDIO\\K3_DS.MP3", - "AUDIO\\K4_SHI.MP3", - "AUDIO\\K5_SD.MP3", - "AUDIO\\R0_PDR2.MP3", - "AUDIO\\R1_SW.MP3", - "AUDIO\\R2_AP.MP3", - "AUDIO\\R3_ED.MP3", - "AUDIO\\R4_GF.MP3", - "AUDIO\\R5_PB.MP3", - "AUDIO\\R6_MM.MP3", - "AUDIO\\D1_STOG.MP3", - "AUDIO\\D2_KK.MP3", - "AUDIO\\D3_ADO.MP3", - "AUDIO\\D5_ES.MP3", - "AUDIO\\D7_MLD.MP3", - "AUDIO\\D4_GTA.MP3", - "AUDIO\\D4_GTA2.MP3", - "AUDIO\\D6_STS.MP3", - "AUDIO\\A6_BAIT.WAV", - "AUDIO\\A7_ETG.WAV", - "AUDIO\\A8_PS.WAV", - "AUDIO\\A9_ASD.WAV", - "AUDIO\\K4_SHI2.MP3", - "AUDIO\\C1_TEX.MP3", - "AUDIO\\EL_PH1.MP3", - "AUDIO\\EL_PH2.MP3", - "AUDIO\\EL_PH3.MP3", - "AUDIO\\EL_PH4.MP3", - "AUDIO\\YD_PH1.MP3", - "AUDIO\\YD_PH2.MP3", - "AUDIO\\YD_PH3.MP3", - "AUDIO\\YD_PH4.MP3", - "AUDIO\\HD_PH1.MP3", - "AUDIO\\HD_PH2.MP3", - "AUDIO\\HD_PH3.MP3", - "AUDIO\\HD_PH4.MP3", - "AUDIO\\HD_PH5.MP3", - "AUDIO\\MT_PH1.MP3", - "AUDIO\\MT_PH2.MP3", - "AUDIO\\MT_PH3.MP3", - "AUDIO\\MT_PH4.MP3", - "AUDIO\\MISCOM.WAV", - "AUDIO\\END.MP3", - "AUDIO\\lib_a1.WAV", - "AUDIO\\lib_a2.WAV", - "AUDIO\\lib_a.WAV", - "AUDIO\\lib_b.WAV", - "AUDIO\\lib_c.WAV", - "AUDIO\\lib_d.WAV", - "AUDIO\\l2_a.WAV", - "AUDIO\\j4t_1.WAV", - "AUDIO\\j4t_2.WAV", - "AUDIO\\j4t_3.WAV", - "AUDIO\\j4t_4.WAV", - "AUDIO\\j4_a.WAV", - "AUDIO\\j4_b.WAV", - "AUDIO\\j4_c.WAV", - "AUDIO\\j4_d.WAV", - "AUDIO\\j4_e.WAV", - "AUDIO\\j4_f.WAV", - "AUDIO\\j6_1.WAV", - "AUDIO\\j6_a.WAV", - "AUDIO\\j6_b.WAV", - "AUDIO\\j6_c.WAV", - "AUDIO\\j6_d.WAV", - "AUDIO\\t4_a.WAV", - "AUDIO\\s1_a.WAV", - "AUDIO\\s1_a1.WAV", - "AUDIO\\s1_b.WAV", - "AUDIO\\s1_c.WAV", - "AUDIO\\s1_c1.WAV", - "AUDIO\\s1_d.WAV", - "AUDIO\\s1_e.WAV", - "AUDIO\\s1_f.WAV", - "AUDIO\\s1_g.WAV", - "AUDIO\\s1_h.WAV", - "AUDIO\\s1_i.WAV", - "AUDIO\\s1_j.WAV", - "AUDIO\\s1_k.WAV", - "AUDIO\\s1_l.WAV", - "AUDIO\\s3_a.WAV", - "AUDIO\\s3_b.WAV", - "AUDIO\\el3_a.WAV", - "AUDIO\\mf1_a.WAV", - "AUDIO\\mf2_a.WAV", - "AUDIO\\mf3_a.WAV", - "AUDIO\\mf3_b.WAV", - "AUDIO\\mf3_b1.WAV", - "AUDIO\\mf3_c.WAV", - "AUDIO\\mf4_a.WAV", - "AUDIO\\mf4_b.WAV", - "AUDIO\\mf4_c.WAV", - "AUDIO\\a1_a.WAV", - "AUDIO\\a3_a.WAV", - "AUDIO\\a5_a.WAV", - "AUDIO\\a4_a.WAV", - "AUDIO\\a4_b.WAV", - "AUDIO\\a4_c.WAV", - "AUDIO\\a4_d.WAV", - "AUDIO\\k1_a.WAV", - "AUDIO\\k3_a.WAV", - "AUDIO\\r1_a.WAV", - "AUDIO\\r2_a.WAV", - "AUDIO\\r2_b.WAV", - "AUDIO\\r2_c.WAV", - "AUDIO\\r2_d.WAV", - "AUDIO\\r2_e.WAV", - "AUDIO\\r2_f.WAV", - "AUDIO\\r2_g.WAV", - "AUDIO\\r2_h.WAV", - "AUDIO\\r5_a.WAV", - "AUDIO\\r6_a.WAV", - "AUDIO\\r6_a1.WAV", - "AUDIO\\r6_b.WAV", - "AUDIO\\lo2_a.WAV", - "AUDIO\\lo6_a.WAV", - "AUDIO\\yd2_a.WAV", - "AUDIO\\yd2_b.WAV", - "AUDIO\\yd2_c.WAV", - "AUDIO\\yd2_c1.WAV", - "AUDIO\\yd2_d.WAV", - "AUDIO\\yd2_e.WAV", - "AUDIO\\yd2_f.WAV", - "AUDIO\\yd2_g.WAV", - "AUDIO\\yd2_h.WAV", - "AUDIO\\yd2_ass.WAV", - "AUDIO\\yd2_ok.WAV", - "AUDIO\\h5_a.WAV", - "AUDIO\\h5_b.WAV", - "AUDIO\\h5_c.WAV", - "AUDIO\\ammu_a.WAV", - "AUDIO\\ammu_b.WAV", - "AUDIO\\ammu_c.WAV", - "AUDIO\\door_1.WAV", - "AUDIO\\door_2.WAV", - "AUDIO\\door_3.WAV", - "AUDIO\\door_4.WAV", - "AUDIO\\door_5.WAV", - "AUDIO\\door_6.WAV", - "AUDIO\\t3_a.WAV", - "AUDIO\\t3_b.WAV", - "AUDIO\\t3_c.WAV", - "AUDIO\\k1_b.WAV", - "AUDIO\\cat1.WAV" -}; diff --git a/src/audio/oal/aldlist.cpp b/src/audio/oal/aldlist.cpp new file mode 100644 index 00000000..2c2f13a8 --- /dev/null +++ b/src/audio/oal/aldlist.cpp @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2006, Creative Labs Inc. + * 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. + * * Neither the name of Creative Labs Inc. 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 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. + */ + +#include "aldlist.h" +#ifdef AUDIO_OAL +/* + * Init call + */ +ALDeviceList::ALDeviceList() +{ + ALDEVICEINFO ALDeviceInfo; + char *devices; + int index; + const char *defaultDeviceName; + const char *actualDeviceName; + + // DeviceInfo vector stores, for each enumerated device, it's device name, selection status, spec version #, and extension support + vDeviceInfo.empty(); + vDeviceInfo.reserve(10); + + defaultDeviceIndex = 0; + + if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { + devices = (char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); + defaultDeviceName = (char *)alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); + + index = 0; + // go through device list (each device terminated with a single NULL, list terminated with double NULL) + while (*devices != NULL) { + if (strcmp(defaultDeviceName, devices) == 0) { + defaultDeviceIndex = index; + } + ALCdevice *device = alcOpenDevice(devices); + if (device) { + ALCcontext *context = alcCreateContext(device, NULL); + if (context) { + alcMakeContextCurrent(context); + // if new actual device name isn't already in the list, then add it... + actualDeviceName = alcGetString(device, ALC_DEVICE_SPECIFIER); + bool bNewName = true; + for (int i = 0; i < GetNumDevices(); i++) { + if (strcmp(GetDeviceName(i), actualDeviceName) == 0) { + bNewName = false; + } + } + if ((bNewName) && (actualDeviceName != NULL) && (strlen(actualDeviceName) > 0)) { + memset(&ALDeviceInfo, 0, sizeof(ALDEVICEINFO)); + ALDeviceInfo.bSelected = true; + ALDeviceInfo.strDeviceName = std::string(actualDeviceName, strlen(actualDeviceName)); + alcGetIntegerv(device, ALC_MAJOR_VERSION, sizeof(int), &ALDeviceInfo.iMajorVersion); + alcGetIntegerv(device, ALC_MINOR_VERSION, sizeof(int), &ALDeviceInfo.iMinorVersion); + + ALDeviceInfo.pvstrExtensions = new std::vector; + + // Check for ALC Extensions + if (alcIsExtensionPresent(device, "ALC_EXT_CAPTURE") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_CAPTURE"); + if (alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("ALC_EXT_EFX"); + + // Check for AL Extensions + if (alIsExtensionPresent("AL_EXT_OFFSET") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_OFFSET"); + + if (alIsExtensionPresent("AL_EXT_LINEAR_DISTANCE") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_LINEAR_DISTANCE"); + if (alIsExtensionPresent("AL_EXT_EXPONENT_DISTANCE") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("AL_EXT_EXPONENT_DISTANCE"); + + if (alIsExtensionPresent("EAX2.0") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("EAX2.0"); + if (alIsExtensionPresent("EAX3.0") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("EAX3.0"); + if (alIsExtensionPresent("EAX4.0") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("EAX4.0"); + if (alIsExtensionPresent("EAX5.0") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("EAX5.0"); + + if (alIsExtensionPresent("EAX-RAM") == AL_TRUE) + ALDeviceInfo.pvstrExtensions->push_back("EAX-RAM"); + + // Get Source Count + ALDeviceInfo.uiSourceCount = GetMaxNumSources(); + + vDeviceInfo.push_back(ALDeviceInfo); + } + alcMakeContextCurrent(NULL); + alcDestroyContext(context); + } + alcCloseDevice(device); + } + devices += strlen(devices) + 1; + index += 1; + } + } + + ResetFilters(); +} + +/* + * Exit call + */ +ALDeviceList::~ALDeviceList() +{ + for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + if (vDeviceInfo[i].pvstrExtensions) { + vDeviceInfo[i].pvstrExtensions->empty(); + delete vDeviceInfo[i].pvstrExtensions; + } + } + + vDeviceInfo.empty(); +} + +/* + * Returns the number of devices in the complete device list + */ +int ALDeviceList::GetNumDevices() +{ + return (int)vDeviceInfo.size(); +} + +/* + * Returns the device name at an index in the complete device list + */ +char * ALDeviceList::GetDeviceName(int index) +{ + if (index < GetNumDevices()) + return (char *)vDeviceInfo[index].strDeviceName.c_str(); + else + return NULL; +} + +/* + * Returns the major and minor version numbers for a device at a specified index in the complete list + */ +void ALDeviceList::GetDeviceVersion(int index, int *major, int *minor) +{ + if (index < GetNumDevices()) { + if (major) + *major = vDeviceInfo[index].iMajorVersion; + if (minor) + *minor = vDeviceInfo[index].iMinorVersion; + } + return; +} + +/* + * Returns the maximum number of Sources that can be generate on the given device + */ +unsigned int ALDeviceList::GetMaxNumSources(int index) +{ + if (index < GetNumDevices()) + return vDeviceInfo[index].uiSourceCount; + else + return 0; +} + +/* + * Checks if the extension is supported on the given device + */ +bool ALDeviceList::IsExtensionSupported(int index, char *szExtName) +{ + bool bReturn = false; + + if (index < GetNumDevices()) { + for (unsigned int i = 0; i < vDeviceInfo[index].pvstrExtensions->size(); i++) { + if (!_stricmp(vDeviceInfo[index].pvstrExtensions->at(i).c_str(), szExtName)) { + bReturn = true; + break; + } + } + } + + return bReturn; +} + +/* + * returns the index of the default device in the complete device list + */ +int ALDeviceList::GetDefaultDevice() +{ + return defaultDeviceIndex; +} + +/* + * Deselects devices which don't have the specified minimum version + */ +void ALDeviceList::FilterDevicesMinVer(int major, int minor) +{ + int dMajor, dMinor; + for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + GetDeviceVersion(i, &dMajor, &dMinor); + if ((dMajor < major) || ((dMajor == major) && (dMinor < minor))) { + vDeviceInfo[i].bSelected = false; + } + } +} + +/* + * Deselects devices which don't have the specified maximum version + */ +void ALDeviceList::FilterDevicesMaxVer(int major, int minor) +{ + int dMajor, dMinor; + for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + GetDeviceVersion(i, &dMajor, &dMinor); + if ((dMajor > major) || ((dMajor == major) && (dMinor > minor))) { + vDeviceInfo[i].bSelected = false; + } + } +} + +/* + * Deselects device which don't support the given extension name + */ +void ALDeviceList::FilterDevicesExtension(char *szExtName) +{ + bool bFound; + + for (unsigned int i = 0; i < vDeviceInfo.size(); i++) { + bFound = false; + for (unsigned int j = 0; j < vDeviceInfo[i].pvstrExtensions->size(); j++) { + if (!_stricmp(vDeviceInfo[i].pvstrExtensions->at(j).c_str(), szExtName)) { + bFound = true; + break; + } + } + if (!bFound) + vDeviceInfo[i].bSelected = false; + } +} + +/* + * Resets all filtering, such that all devices are in the list + */ +void ALDeviceList::ResetFilters() +{ + for (int i = 0; i < GetNumDevices(); i++) { + vDeviceInfo[i].bSelected = true; + } + filterIndex = 0; +} + +/* + * Gets index of first filtered device + */ +int ALDeviceList::GetFirstFilteredDevice() +{ + int i; + + for (i = 0; i < GetNumDevices(); i++) { + if (vDeviceInfo[i].bSelected == true) { + break; + } + } + filterIndex = i + 1; + return i; +} + +/* + * Gets index of next filtered device + */ +int ALDeviceList::GetNextFilteredDevice() +{ + int i; + + for (i = filterIndex; i < GetNumDevices(); i++) { + if (vDeviceInfo[i].bSelected == true) { + break; + } + } + filterIndex = i + 1; + return i; +} + +/* + * Internal function to detemine max number of Sources that can be generated + */ +unsigned int ALDeviceList::GetMaxNumSources() +{ + ALuint uiSources[256]; + unsigned int iSourceCount = 0; + + // Clear AL Error Code + alGetError(); + + // Generate up to 256 Sources, checking for any errors + for (iSourceCount = 0; iSourceCount < 256; iSourceCount++) + { + alGenSources(1, &uiSources[iSourceCount]); + if (alGetError() != AL_NO_ERROR) + break; + } + + // Release the Sources + alDeleteSources(iSourceCount, uiSources); + if (alGetError() != AL_NO_ERROR) + { + for (unsigned int i = 0; i < 256; i++) + { + alDeleteSources(1, &uiSources[i]); + } + } + + return iSourceCount; +} +#endif \ No newline at end of file diff --git a/src/audio/oal/aldlist.h b/src/audio/oal/aldlist.h new file mode 100644 index 00000000..b8f1b31a --- /dev/null +++ b/src/audio/oal/aldlist.h @@ -0,0 +1,49 @@ +#ifndef ALDEVICELIST_H +#define ALDEVICELIST_H + +#include "oal_utils.h" + +#ifdef AUDIO_OAL +#pragma warning(disable: 4786) //disable warning "identifier was truncated to '255' characters in the browser information" +#include +#include + +typedef struct +{ + std::string strDeviceName; + int iMajorVersion; + int iMinorVersion; + unsigned int uiSourceCount; + std::vector *pvstrExtensions; + bool bSelected; +} ALDEVICEINFO, *LPALDEVICEINFO; + +class ALDeviceList +{ +private: + std::vector vDeviceInfo; + int defaultDeviceIndex; + int filterIndex; + +public: + ALDeviceList (); + ~ALDeviceList (); + int GetNumDevices(); + char *GetDeviceName(int index); + void GetDeviceVersion(int index, int *major, int *minor); + unsigned int GetMaxNumSources(int index); + bool IsExtensionSupported(int index, char *szExtName); + int GetDefaultDevice(); + void FilterDevicesMinVer(int major, int minor); + void FilterDevicesMaxVer(int major, int minor); + void FilterDevicesExtension(char *szExtName); + void ResetFilters(); + int GetFirstFilteredDevice(); + int GetNextFilteredDevice(); + +private: + unsigned int GetMaxNumSources(); +}; +#endif + +#endif // ALDEVICELIST_H \ No newline at end of file diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp new file mode 100644 index 00000000..d8b50161 --- /dev/null +++ b/src/audio/oal/channel.cpp @@ -0,0 +1,209 @@ +#include "channel.h" + +#ifdef AUDIO_OAL +#include "sampman.h" + +extern bool IsFXSupported(); + +CChannel::CChannel() +{ + alChannel = AL_NONE; + alFilter = AL_FILTER_NULL; + SetDefault(); +} + +void CChannel::SetDefault() +{ + Buffer = AL_NONE; + + Pitch = 1.0f; + Gain = 1.0f; + Mix = 0.0f; + + Position[0] = 0.0f; Position[1] = 0.0f; Position[2] = 0.0f; + Distances[0] = 0.0f; Distances[1] = FLT_MAX; + LoopCount = 1; + LoopPoints[0] = 0; LoopPoints[1] = -1; + + Frequency = MAX_FREQ; +} + +void CChannel::Reset() +{ + ClearBuffer(); + SetDefault(); +} + +void CChannel::Init(bool Is2D) +{ + ASSERT(!HasSource()); + alGenSources(1, &alChannel); + if ( HasSource() ) + { + alSourcei(alChannel, AL_SOURCE_RELATIVE, AL_TRUE); + if ( IsFXSupported() ) + alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + + if ( Is2D ) + { + alSource3f(alChannel, AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef (alChannel, AL_GAIN, 1.0f); + } + else + { + if ( IsFXSupported() ) + alGenFilters(1,&alFilter); + } + } +} + +void CChannel::Term() +{ + Stop(); + if ( HasSource() ) + { + if ( IsFXSupported() ) + { + alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + + if(alFilter != AL_FILTER_NULL) + alDeleteFilters(1,&alFilter); + } + + alDeleteSources(1, &alChannel); + } + alChannel = AL_NONE; + alFilter = AL_FILTER_NULL; +} + +void CChannel::Start() +{ + if ( !HasSource() ) return; + + if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 ) + alBufferiv(Buffer, AL_LOOP_POINTS_SOFT, LoopPoints); + alSourcei (alChannel, AL_BUFFER, Buffer); + alSourcePlay(alChannel); +} + +void CChannel::Stop() +{ + if ( HasSource() ) + alSourceStop(alChannel); + + Reset(); +} + +bool CChannel::HasSource() +{ + return alChannel != AL_NONE; +} + +bool CChannel::IsUsed() +{ + if ( HasSource() ) + { + ALint sourceState; + alGetSourcei(alChannel, AL_SOURCE_STATE, &sourceState); + return sourceState == AL_PLAYING; + } + return false; +} + +void CChannel::SetPitch(float pitch) +{ + if ( !HasSource() ) return; + alSourcef(alChannel, AL_PITCH, pitch); +} + +void CChannel::SetGain(float gain) +{ + if ( !HasSource() ) return; + alSourcef(alChannel, AL_GAIN, gain); +} + +void CChannel::SetVolume(int32 vol) +{ + SetGain(ALfloat(vol) / MAX_VOLUME); +} + +void CChannel::SetSampleID(uint32 nSfx) +{ + Sample = nSfx; +} + +void CChannel::SetFreq(int32 freq) +{ + Frequency = freq; +} + +void CChannel::SetCurrentFreq(uint32 freq) +{ + SetPitch(ALfloat(freq) / Frequency); +} + +void CChannel::SetLoopCount(int32 loopCount) // fake. TODO: +{ + if ( !HasSource() ) return; + alSourcei(alChannel, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); +} + +void CChannel::SetLoopPoints(ALint start, ALint end) +{ + LoopPoints[0] = start; + LoopPoints[1] = end; +} + +void CChannel::SetPosition(float x, float y, float z) +{ + if ( !HasSource() ) return; + alSource3f(alChannel, AL_POSITION, x, y, z); +} + +void CChannel::SetDistances(float max, float min) +{ + if ( !HasSource() ) return; + alSourcef (alChannel, AL_MAX_DISTANCE, max); + alSourcef (alChannel, AL_REFERENCE_DISTANCE, min); + alSourcef (alChannel, AL_MAX_GAIN, 1.0f); + alSourcef (alChannel, AL_ROLLOFF_FACTOR, 1.0f); +} + +void CChannel::SetPan(uint32 pan) +{ + SetPosition((pan-63)/64.0f, 0.0f, sqrtf(1.0f-SQR((pan-63)/64.0f))); +} + +void CChannel::SetBuffer(ALuint buffer) +{ + Buffer = buffer; +} + +void CChannel::ClearBuffer() +{ + if ( !HasSource() ) return; + SetBuffer(AL_NONE); + alSourcei(alChannel, AL_BUFFER, AL_NONE); +} + +void CChannel::SetReverbMix(ALuint slot, float mix) +{ + if ( !IsFXSupported() ) return; + if ( !HasSource() ) return; + if ( alFilter == AL_FILTER_NULL ) return; + + Mix = mix; + EAX3_SetReverbMix(alFilter, mix); + alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); +} + +void CChannel::UpdateReverb(ALuint slot) +{ + if ( !IsFXSupported() ) return; + if ( !HasSource() ) return; + if ( alFilter == AL_FILTER_NULL ) return; + EAX3_SetReverbMix(alFilter, Mix); + alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); +} + +#endif \ No newline at end of file diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h new file mode 100644 index 00000000..d9ffea22 --- /dev/null +++ b/src/audio/oal/channel.h @@ -0,0 +1,51 @@ +#pragma once +#include "common.h" + +#ifdef AUDIO_OAL +#include "oal/oal_utils.h" +#include +#include +#include + + +class CChannel +{ + ALuint alChannel; + ALuint alFilter; + ALuint Buffer; + float Pitch, Gain; + float Mix; + int32 Frequency; + float Position[3]; + float Distances[2]; + int32 LoopCount; + ALint LoopPoints[2]; + uint32 Sample; +public: + CChannel(); + void SetDefault(); + void Reset(); + void Init(bool Is2D = false); + void Term(); + void Start(); + void Stop(); + bool HasSource(); + bool IsUsed(); + void SetPitch(float pitch); + void SetGain(float gain); + void SetVolume(int32 vol); + void SetSampleID(uint32 nSfx); + void SetFreq(int32 freq); + void SetCurrentFreq(uint32 freq); + void SetLoopCount(int32 loopCount); // fake + void SetLoopPoints(ALint start, ALint end); + void SetPosition(float x, float y, float z); + void SetDistances(float max, float min); + void SetPan(uint32 pan); + void SetBuffer(ALuint buffer); + void ClearBuffer(); + void SetReverbMix(ALuint slot, float mix); + void UpdateReverb(ALuint slot); +}; + +#endif \ No newline at end of file diff --git a/src/audio/oal/oal_utils.cpp b/src/audio/oal/oal_utils.cpp new file mode 100644 index 00000000..a2df61c1 --- /dev/null +++ b/src/audio/oal/oal_utils.cpp @@ -0,0 +1,176 @@ +#include "oal_utils.h" + +#ifdef AUDIO_OAL + +LPALGENEFFECTS alGenEffects; +LPALDELETEEFFECTS alDeleteEffects; +LPALISEFFECT alIsEffect; +LPALEFFECTI alEffecti; +LPALEFFECTIV alEffectiv; +LPALEFFECTF alEffectf; +LPALEFFECTFV alEffectfv; +LPALGETEFFECTI alGetEffecti; +LPALGETEFFECTIV alGetEffectiv; +LPALGETEFFECTF alGetEffectf; +LPALGETEFFECTFV alGetEffectfv; +LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; +LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; +LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; +LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; +LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; +LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; +LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; +LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; +LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; +LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; +LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; +LPALGENFILTERS alGenFilters; +LPALDELETEFILTERS alDeleteFilters; +LPALISFILTER alIsFilter; +LPALFILTERI alFilteri; +LPALFILTERIV alFilteriv; +LPALFILTERF alFilterf; +LPALFILTERFV alFilterfv; +LPALGETFILTERI alGetFilteri; +LPALGETFILTERIV alGetFilteriv; +LPALGETFILTERF alGetFilterf; +LPALGETFILTERFV alGetFilterfv; + + +void EFXInit() +{ + if (alIsExtensionPresent((ALchar*)"EAX3.0")) + DEV("\nBIG EAX IN TOWN\n"); + else + DEV("\nNO EAX\n"); + + + /* Define a macro to help load the function pointers. */ +#define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x)) + LOAD_PROC(LPALGENEFFECTS, alGenEffects); + LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); + LOAD_PROC(LPALISEFFECT, alIsEffect); + LOAD_PROC(LPALEFFECTI, alEffecti); + LOAD_PROC(LPALEFFECTIV, alEffectiv); + LOAD_PROC(LPALEFFECTF, alEffectf); + LOAD_PROC(LPALEFFECTFV, alEffectfv); + LOAD_PROC(LPALGETEFFECTI, alGetEffecti); + LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv); + LOAD_PROC(LPALGETEFFECTF, alGetEffectf); + LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv); + + LOAD_PROC(LPALGENFILTERS, alGenFilters); + LOAD_PROC(LPALDELETEFILTERS, alDeleteFilters); + LOAD_PROC(LPALISFILTER, alIsFilter); + LOAD_PROC(LPALFILTERI, alFilteri); + LOAD_PROC(LPALFILTERIV, alFilteriv); + LOAD_PROC(LPALFILTERF, alFilterf); + LOAD_PROC(LPALFILTERFV, alFilterfv); + LOAD_PROC(LPALGETFILTERI, alGetFilteri); + LOAD_PROC(LPALGETFILTERIV, alGetFilteriv); + LOAD_PROC(LPALGETFILTERF, alGetFilterf); + LOAD_PROC(LPALGETFILTERFV, alGetFilterfv); + + LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots); + LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots); + LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv); +#undef LOAD_PROC +} + + +void SetEffectsLevel(ALuint uiFilter, float level) +{ + alFilteri(uiFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); + alFilterf(uiFilter, AL_LOWPASS_GAIN, 1.0f); + alFilterf(uiFilter, AL_LOWPASS_GAINHF, level); +} + +static inline float gain_to_mB(float gain) +{ + return (gain > 1e-5f) ? (float)(log10f(gain) * 2000.0f) : -10000l; +} + +static inline float mB_to_gain(float millibels) +{ + return (millibels > -10000.0f) ? powf(10.0f, millibels/2000.0f) : 0.0f; +} + +static inline FLOAT clampF(FLOAT val, FLOAT minval, FLOAT maxval) +{ + if(val >= maxval) return maxval; + if(val <= minval) return minval; + return val; +} + +void EAX3_Set(ALuint effect, const EAXLISTENERPROPERTIES *props) +{ + alEffecti (effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); + alEffectf (effect, AL_EAXREVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)); + alEffectf (effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion); + alEffectf (effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom)); + alEffectf (effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF)); + alEffectf (effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF)); + alEffectf (effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime); + alEffectf (effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio); + alEffectf (effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio); + alEffectf (effect, AL_EAXREVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN)); + alEffectf (effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay); + alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x); + alEffectf (effect, AL_EAXREVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN)); + alEffectf (effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay); + alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x); + alEffectf (effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime); + alEffectf (effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth); + alEffectf (effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime); + alEffectf (effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth); + alEffectf (effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)); + alEffectf (effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference); + alEffectf (effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference); + alEffectf (effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor); + alEffecti (effect, AL_EAXREVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE); +} + +void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props) +{ + alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); + + alEffectf(effect, AL_REVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)); + alEffectf(effect, AL_REVERB_DIFFUSION, props->flEnvironmentDiffusion); + alEffectf(effect, AL_REVERB_GAIN, mB_to_gain((float)props->lRoom)); + alEffectf(effect, AL_REVERB_GAINHF, mB_to_gain((float)props->lRoomHF)); + alEffectf(effect, AL_REVERB_DECAY_TIME, props->flDecayTime); + alEffectf(effect, AL_REVERB_DECAY_HFRATIO, props->flDecayHFRatio); + alEffectf(effect, AL_REVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN)); + alEffectf(effect, AL_REVERB_REFLECTIONS_DELAY, props->flReflectionsDelay); + alEffectf(effect, AL_REVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN)); + alEffectf(effect, AL_REVERB_LATE_REVERB_DELAY, props->flReverbDelay); + alEffectf(effect, AL_REVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)); + alEffectf(effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor); + alEffecti(effect, AL_REVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE); +} + +void EAX3_SetReverbMix(ALuint filter, float mix) +{ + //long vol=(long)linear_to_dB(mix); + //DSPROPERTY_EAXBUFFER_ROOMHF, + //DSPROPERTY_EAXBUFFER_ROOM, + //DSPROPERTY_EAXBUFFER_REVERBMIX, + + long mbvol = gain_to_mB(mix); + float mb = mbvol; + float mbhf = mbvol; + + alFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); + alFilterf(filter, AL_LOWPASS_GAIN, mB_to_gain(Min(mb, 0.0f))); + alFilterf(filter, AL_LOWPASS_GAINHF, mB_to_gain(mbhf)); +} + +#endif \ No newline at end of file diff --git a/src/audio/oal/oal_utils.h b/src/audio/oal/oal_utils.h new file mode 100644 index 00000000..af45a944 --- /dev/null +++ b/src/audio/oal/oal_utils.h @@ -0,0 +1,48 @@ +#pragma once +#include "common.h" + +#ifdef AUDIO_OAL +#include "eax.h" +#include "AL/efx.h" + + +void EFXInit(); +void EAX3_Set(ALuint effect, const EAXLISTENERPROPERTIES *props); +void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props); +void EAX3_SetReverbMix(ALuint filter, float mix); +void SetEffectsLevel(ALuint uiFilter, float level); + +extern LPALGENEFFECTS alGenEffects; +extern LPALDELETEEFFECTS alDeleteEffects; +extern LPALISEFFECT alIsEffect; +extern LPALEFFECTI alEffecti; +extern LPALEFFECTIV alEffectiv; +extern LPALEFFECTF alEffectf; +extern LPALEFFECTFV alEffectfv; +extern LPALGETEFFECTI alGetEffecti; +extern LPALGETEFFECTIV alGetEffectiv; +extern LPALGETEFFECTF alGetEffectf; +extern LPALGETEFFECTFV alGetEffectfv; +extern LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; +extern LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; +extern LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; +extern LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; +extern LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; +extern LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; +extern LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; +extern LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; +extern LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; +extern LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; +extern LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; +extern LPALGENFILTERS alGenFilters; +extern LPALDELETEFILTERS alDeleteFilters; +extern LPALISFILTER alIsFilter; +extern LPALFILTERI alFilteri; +extern LPALFILTERIV alFilteriv; +extern LPALFILTERF alFilterf; +extern LPALFILTERFV alFilterfv; +extern LPALGETFILTERI alGetFilteri; +extern LPALGETFILTERIV alGetFilteriv; +extern LPALGETFILTERF alGetFilterf; +extern LPALGETFILTERFV alGetFilterfv; +#endif diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp new file mode 100644 index 00000000..a65c9794 --- /dev/null +++ b/src/audio/oal/stream.cpp @@ -0,0 +1,118 @@ +#include "stream.h" +#include "common.h" + +#ifdef AUDIO_OAL + +void CStream::Initialise() +{ + //mpg123_init(); +} + +void CStream::Terminate() +{ + //mpg123_exit(); +} + +CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) : + m_alSource(source), + m_alBuffers(buffers), + m_nBitRate(0), + m_nFormat(0), + m_nFreq(0), + m_nLength(0), + m_nLengthMS(0), + m_nBufferSize(0), + m_pBuffer(NULL), + m_bIsOpened(false), + m_bPaused(true) + +{ + strcpy(m_aFilename, filename); + + //DEV("Stream %s\n", m_aFilename); + + /* + if ( true ) + { + m_nBitRate = (wBitsPerSample * nChannels * wfex.nSamplesPerSec)/1000; + m_nLength = ulDataSize; + m_nLengthMS = m_nLength*8 / m_nBitRate; + m_nBufferSize = nAvgBytesPerSec >> 2; + m_nBufferSize -= (m_nLength % wfex.nBlockAlign); + m_pBuffer = malloc(m_nBufferSize); + m_bIsOpened = true; + return; + }*/ +} + +CStream::~CStream() +{ + Delete(); +} + +void CStream::Delete() +{ + if ( m_pBuffer ) + { + free(m_pBuffer); + m_pBuffer = NULL; + } +} + +bool CStream::IsOpened() +{ + return m_bIsOpened; +} + +bool CStream::IsPlaying() +{ + return false; +} + +void CStream::SetPause(bool bPause) +{ +} + +void CStream::SetVolume(uint32 nVol) +{ + +} + +void CStream::SetPan(uint8 nPan) +{ +} + +void CStream::SetPos(uint32 nPos) +{ +} + +uint32 CStream::GetPos() +{ + return 0; +} + +uint32 CStream::GetLength() +{ + return m_nLengthMS; +} + +bool CStream::Setup() +{ + if ( !IsOpened() ) + return false; + + return IsOpened(); +} + +void CStream::Start() +{ + +} + +void CStream::Update() +{ + if ( !IsOpened() ) + return; +} + +#endif \ No newline at end of file diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h new file mode 100644 index 00000000..666d42e0 --- /dev/null +++ b/src/audio/oal/stream.h @@ -0,0 +1,57 @@ +#pragma once +#include "common.h" + +#ifdef AUDIO_OAL +#include + +#define NUM_STREAMBUFFERS 5 +#define STREAMBUFFER_SIZE 0x4000 + +class CStream +{ + char m_aFilename[128]; + ALuint &m_alSource; + ALuint (&m_alBuffers)[NUM_STREAMBUFFERS]; + + bool m_bIsOpened; + bool m_bPaused; + + uint32 m_nLength; + uint32 m_nLengthMS; + uint32 m_nBitRate; + + unsigned long m_nFormat; + unsigned long m_nFreq; + + uint32 m_nBufferSize; + void *m_pBuffer; + + ALint iTotalBuffersProcessed; + + bool FillBuffer(ALuint alBuffer); + int32 FillBuffers(); +public: + static void Initialise(); + static void Terminate(); + + CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]); + ~CStream(); + + void Delete(); + + bool IsOpened(); + bool IsPlaying(); + void SetPause (bool bPause); + void SetVolume(uint32 nVol); + void SetPan (uint8 nPan); + void SetPos (uint32 nPos); + + uint32 GetPos(); + uint32 GetLength(); + + bool Setup(); + void Start(); + void Update(void); +}; + +#endif \ No newline at end of file diff --git a/src/audio/openal/samp_oal.cpp b/src/audio/openal/samp_oal.cpp deleted file mode 100644 index e8213cd9..00000000 --- a/src/audio/openal/samp_oal.cpp +++ /dev/null @@ -1,1404 +0,0 @@ -#include -#include -#include -//#include -#include -#include -#include "samp_oal.h" -#include "AudioManager.h" -#include "MusicManager.h" -#include "Frontend.h" -#include "Timer.h" - -#pragma comment( lib, "libmpg123.lib" ) -#pragma comment( lib, "OpenAL32.lib" ) - -cSampleManager SampleManager; -int32 BankStartOffset[MAX_SAMPLEBANKS]; - - -/////////////////////////////////////////////////////////////// -class MP3Stream -{ -public: - mpg123_handle *m_pMPG; - FILE *m_fpFile; - unsigned char *m_pBuf; - char m_aFilename[128]; - size_t m_nBufSize; - size_t m_nLengthInBytes; - long m_nRate; - int m_nBitRate; - int m_nChannels; - int m_nEncoding; - int m_nLength; - int m_nBlockSize; - int m_nNumBlocks; - ALuint m_alSource; - ALuint m_alBuffers[5]; - unsigned char *m_pBlocks; - bool m_bIsFree; - bool m_bIsOpened; - bool m_bIsPaused; - int m_nVolume; - - void Initialize(void); - bool FillBuffer(ALuint alBuffer); - void Update(void); - void SetPos(uint32 nPos); - int32 FillBuffers(); - MP3Stream(char *filename, ALuint source, ALuint *buffers); - ~MP3Stream() { Delete(); } - void Delete(); - -}; -/////////////////////////////////////////////////////////////// - -char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; -char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; - -FILE *fpSampleDescHandle; -FILE *fpSampleDataHandle; -bool bSampleBankLoaded [MAX_SAMPLEBANKS]; -int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; -int32 nSampleBankSize [MAX_SAMPLEBANKS]; -int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; -int32 _nSampleDataEndOffset; - -int32 nPedSlotSfx [MAX_PEDSFX]; -int32 nPedSlotSfxAddr[MAX_PEDSFX]; -uint8 nCurrentPedSlot; - - - -uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; - -/////////////////////////////////////////////////////////////// -ALuint alChannel[MAXCHANNELS+MAX2DCHANNELS]; -ALuint ALStreamSources[MAX_STREAMS]; -ALuint ALStreamBuffers[MAX_STREAMS][5]; -struct -{ - ALuint buffer; - ALuint timer; -}ALBuffers[SAMPLEBANK_MAX]; - -ALuint pedBuffers[MAX_PEDSFX]; -//bank0Buffers - -uint32 nNumMP3s; - -MP3Stream *mp3Stream[MAX_STREAMS]; -int8 nStreamPan [MAX_STREAMS]; -int8 nStreamVolume[MAX_STREAMS]; - -float ChannelPitch[MAXCHANNELS+MAX2DCHANNELS]; -uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; -uint32 ChannelSample[MAXCHANNELS+MAX2DCHANNELS]; -int32 currentChannelMaxFrontDistance[MAXCHANNELS+MAX2DCHANNELS]; -int32 currentChannelFrequency[MAXCHANNELS+MAX2DCHANNELS]; -int32 currentChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; - - -cSampleManager::cSampleManager(void) -{ - ; -} - -cSampleManager::~cSampleManager(void) -{ - ASSERT((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED] == NULL); - free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); - - if ( fpSampleDescHandle != NULL ) - { - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; - } - - if ( fpSampleDataHandle != NULL ) - { - fclose(fpSampleDataHandle); - fpSampleDataHandle = NULL; - } -} - -void cSampleManager::SetSpeakerConfig(int32 nConfig) -{ - -} - -uint32 cSampleManager::GetMaximumSupportedChannels(void) -{ - return 20; -} - -uint32 cSampleManager::GetNum3DProvidersAvailable() -{ - return 1; -} - -void cSampleManager::SetNum3DProvidersAvailable(uint32 num) -{ - ; -} - -char *cSampleManager::Get3DProviderName(uint8 id) -{ - static char PROVIDER[256] = "OpenAL"; - return PROVIDER; -} - -void cSampleManager::Set3DProviderName(uint8 id, char *name) -{ - ; -} - -int8 cSampleManager::GetCurrent3DProviderIndex(void) -{ - return 0; -} - -int8 cSampleManager::SetCurrent3DProvider(uint8 which) -{ - return 0; -} - -bool -cSampleManager::IsMP3RadioChannelAvailable(void) -{ - return nNumMP3s != 0; -} - - -void cSampleManager::ReleaseDigitalHandle(void) -{ - -} - -void cSampleManager::ReacquireDigitalHandle(void) -{ - -} - -bool -cSampleManager::Initialise(void) -{ - ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0}; - - m_pDevice = alcOpenDevice(NULL); - ASSERT(m_pDevice != NULL); - - m_pContext = alcCreateContext(m_pDevice, attr); - ASSERT(m_pContext != NULL); - - alcMakeContextCurrent(m_pContext); - - mpg123_init(); - - - - for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) - { - m_aSamples[i].nOffset = 0; - m_aSamples[i].nSize = 0; - m_aSamples[i].nFrequency = MAX_FREQ; - m_aSamples[i].nLoopStart = 0; - m_aSamples[i].nLoopEnd = -1; - } - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - nStreamLength[i] = 3600000; - - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - mp3Stream[i] = NULL; - nStreamVolume[i] = 100; - nStreamPan[i] = 63; - } - - alGenSources(MAX_STREAMS, (ALuint *)ALStreamSources); - alGenBuffers(MAX_STREAMS*5, (ALuint *)ALStreamBuffers); - - m_nMonoMode = 0; - - m_nEffectsVolume = MAX_VOLUME; - m_nMusicVolume = MAX_VOLUME; - m_nEffectsFadeVolume = MAX_VOLUME; - m_nMusicFadeVolume = MAX_VOLUME; - - - memset(alChannel, 0, sizeof(alChannel)); - memset(nChannelVolume, 0, sizeof(nChannelVolume)); - memset(ChannelSample, 0, sizeof(ChannelSample)); - - for ( int32 i = 0; i < ARRAY_SIZE(ChannelPitch); i++ ) - ChannelPitch[i] = 1.0f; - - - fpSampleDescHandle = NULL; - fpSampleDataHandle = NULL; - - for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) - { - bSampleBankLoaded[i] = false; - nSampleBankDiscStartOffset[i] = 0; - nSampleBankSize[i] = 0; - nSampleBankMemoryStartAddress[i] = 0; - } - - alGenBuffers(MAX_PEDSFX, pedBuffers); - - for ( int32 i = 0; i < MAX_PEDSFX; i++ ) - { - nPedSlotSfx[i] = NO_SAMPLE; - nPedSlotSfxAddr[i] = 0; - } - - nCurrentPedSlot = 0; - - for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) - { - ALBuffers[i].buffer = 0; - ALBuffers[i].timer = 0; - } - - alListenerf (AL_GAIN, 1.0f); - alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); - alListener3f(AL_VELOCITY, 0.0f, 0.0f, 0.0f); - ALfloat orientation[6] = { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; - alListenerfv(AL_ORIENTATION, orientation); - - if ( !InitialiseSampleBanks() ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != NULL); - - if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == NULL ) - { - Terminate(); - return false; - } - - nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)malloc(PED_BLOCKSIZE*MAX_PEDSFX); - ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != NULL); - - alGenSources(MAXCHANNELS, alChannel); - for ( int32 i = 0; i < MAXCHANNELS; i++ ) - { - if ( alChannel[i] ) - alSourcei(alChannel[i], AL_SOURCE_RELATIVE, AL_TRUE); - } - - alGenSources(MAX2DCHANNELS, &alChannel[CHANNEL2D]); - if ( alChannel[CHANNEL2D] ) - { - alSourcei (alChannel[CHANNEL2D], AL_SOURCE_RELATIVE, AL_TRUE); - alSource3f(alChannel[CHANNEL2D], AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef (alChannel[CHANNEL2D], AL_GAIN, 1.0f); - } - - LoadSampleBank(SAMPLEBANK_MAIN); - - return true; -} - -void -cSampleManager::Terminate(void) -{ - mpg123_exit(); - alcMakeContextCurrent(NULL); - alcDestroyContext(m_pContext); - alcCloseDevice(m_pDevice); -} - -void -cSampleManager::UpdateSoundBuffers(void) -{ - for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) - { - if ( ALBuffers[i].timer > 0 ) - { - ALBuffers[i].timer -= ALuint(CTimer::GetTimeStep() * 20.0f); - - if ( ALBuffers[i].timer <= 0 ) - { - if ( ALBuffers[i].buffer != 0 && alIsBuffer(ALBuffers[i].buffer) ) - { - alDeleteBuffers(1, &ALBuffers[i].buffer); - - if ( alGetError() == AL_NO_ERROR ) - ALBuffers[i].buffer = 0; - else - ALBuffers[i].buffer = 120000; - } - } - } - } -} - -bool cSampleManager::CheckForAnAudioFileOnCD(void) -{ - return true; -} - -char cSampleManager::GetCDAudioDriveLetter(void) -{ - return '\0'; -} - -void -cSampleManager::SetEffectsMasterVolume(uint8 nVolume) -{ - m_nEffectsVolume = nVolume; -} - -void -cSampleManager::SetMusicMasterVolume(uint8 nVolume) -{ - m_nMusicVolume = nVolume; -} - -void -cSampleManager::SetEffectsFadeVolume(uint8 nVolume) -{ - m_nEffectsFadeVolume = nVolume; -} - -void -cSampleManager::SetMusicFadeVolume(uint8 nVolume) -{ - m_nMusicFadeVolume = nVolume; -} - -void -cSampleManager::SetMonoMode(uint8 nMode) -{ - m_nMonoMode = nMode; -} - -bool -cSampleManager::LoadSampleBank(uint8 nBank) -{ - ASSERT( nBank < MAX_SAMPLEBANKS ); - - if ( CTimer::GetIsCodePaused() ) - return false; - - if ( MusicManager.IsInitialised() - && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && nBank != SAMPLEBANK_MAIN ) - { - return false; - } - - if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - return false; - - if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) - return false; - - bSampleBankLoaded[nBank] = true; - - return true; -} - -void -cSampleManager::UnloadSampleBank(uint8 nBank) -{ - ASSERT( nBank < MAX_SAMPLEBANKS ); - - ; // NOIMP -} - -bool -cSampleManager::IsSampleBankLoaded(uint8 nBank) -{ - ASSERT( nBank < MAX_SAMPLEBANKS ); - return true; -} - -bool -cSampleManager::IsPedCommentLoaded(uint32 nComment) -{ - ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); - - uint8 slot; - - for ( int32 i = 0; i < _TODOCONST(3); i++ ) - { - slot = nCurrentPedSlot - i - 1; - if ( nComment == nPedSlotSfx[slot] ) - return true; - } - - return false; -} - - -int32 -cSampleManager::_GetPedCommentSlot(uint32 nComment) -{ - uint8 slot; - - for (int32 i = 0; i < _TODOCONST(3); i++) - { - slot = nCurrentPedSlot - i - 1; - if (nComment == nPedSlotSfx[slot]) - return slot; - } - - return -1; -} - -bool -cSampleManager::LoadPedComment(uint32 nComment) -{ - ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); - - if ( CTimer::GetIsCodePaused() ) - return false; - - // no talking peds during cutsenes or the game end - if ( MusicManager.IsInitialised() ) - { - switch ( MusicManager.GetMusicMode() ) - { - case MUSICMODE_CUTSCENE: - { - return false; - - break; - } - - case MUSICMODE_FRONTEND: - { - if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) - return false; - - break; - } - } - } - - if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) - return false; - - if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) - return false; - - nPedSlotSfx[nCurrentPedSlot] = nComment; - - alBufferData(pedBuffers[nCurrentPedSlot], - AL_FORMAT_MONO16, - (void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), - m_aSamples[nComment].nSize, - MAX_FREQ); - - if ( ++nCurrentPedSlot >= MAX_PEDSFX ) - nCurrentPedSlot = 0; - - return true; -} - -int32 -cSampleManager::GetBankContainingSound(uint32 offset) -{ - if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) - return SAMPLEBANK_PED; - - if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) - return SAMPLEBANK_MAIN; - - return SAMPLEBANK_INVALID; -} - -int32 -cSampleManager::GetSampleBaseFrequency(uint32 nSample) -{ - ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nFrequency; -} - -int32 -cSampleManager::GetSampleLoopStartOffset(uint32 nSample) -{ - ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nLoopStart; -} - -int32 -cSampleManager::GetSampleLoopEndOffset(uint32 nSample) -{ - ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nLoopEnd; -} - -uint32 -cSampleManager::GetSampleLength(uint32 nSample) -{ - ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nSize >> 1; -} - -bool cSampleManager::UpdateReverb(void) -{ - return false; -} - -void -cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) -{ - ; // NOIMP -} - -bool -cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - ALuint buffer; - - if ( nSfx < SAMPLEBANK_MAX ) - { - int32 offset = (m_aSamples[nSfx].nLoopStart > 0) ? (m_aSamples[nSfx].nOffset - m_aSamples[nSfx].nLoopStart) : m_aSamples[nSfx].nOffset; - int32 size = (m_aSamples[nSfx].nLoopStart > 0) ? (m_aSamples[nSfx].nLoopEnd - m_aSamples[nSfx].nLoopStart) : m_aSamples[nSfx].nSize; - - void *data = malloc(size); - ASSERT(data != NULL); - - if ( fseek(fpSampleDataHandle, offset + nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) - { - free(data); - return false; - } - - if ( fread(data, 1, size, fpSampleDataHandle) != size ) - { - free(data); - return false; - } - - ALuint buf; - alGenBuffers(1, &buf); - alBufferData(buf, AL_FORMAT_MONO16, data, size, MAX_FREQ); - free(data); - - if ( !IsSampleBankLoaded(nBank) ) - return false; - - ALBuffers[nSfx].buffer = buf; - ALBuffers[nSfx].timer = 120000; - - buffer = ALBuffers[nSfx].buffer; - - ChannelSample[nChannel] = nSfx; - } - else - { - if ( !IsPedCommentLoaded(nSfx) ) - return false; - - int32 slot = _GetPedCommentSlot(nSfx); - - buffer = pedBuffers[slot]; - } - - if ( buffer == 0 ) - { - TRACE("No buffer to play id %d", nSfx); - return false; - } - - if ( GetChannelUsedFlag(nChannel) ) - { - TRACE("Stopping channel %d - really!!!", nChannel); - StopChannel(nChannel); - } - - alSourcei(alChannel[nChannel], AL_BUFFER, 0); - currentChannelVolume [nChannel] = -1; - currentChannelFrequency [nChannel] = -1; - currentChannelMaxFrontDistance[nChannel] = -1; - - if ( alChannel[nChannel] ) - { - alSourcei(alChannel[nChannel], AL_BUFFER, buffer); - alSourcef(alChannel[nChannel], AL_PITCH, 1.0f); - ChannelPitch[nChannel] = 1.0f; - return true; - } - - return false; -} - -void -cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - uint32 vol = nVolume; - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - - nChannelVolume[nChannel] = vol; - - // reduce the volume for JB.MP3 and S4_BDBD.MP3 - if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) - { - nChannelVolume[nChannel] >>= 2; - } - - uint32 channelVol = m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14; - if ( ChannelSample[nChannel] >= SFX_CAR_REV_1 && SFX_CAR_REV_10 >= ChannelSample[nChannel] ) // nice hack - channelVol >>= 1; - - if ( alChannel[nChannel] ) - { - if ( currentChannelVolume[nChannel] != channelVol ) - { - ALfloat gain = ALfloat(channelVol) / MAX_VOLUME; - alSourcef(alChannel[nChannel], AL_GAIN, gain); - currentChannelVolume[nChannel] = channelVol; - } - } -} - -void -cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - alSource3f(alChannel[nChannel], AL_POSITION, -fX, fY, fZ); - } -} - -void -cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - if ( float(currentChannelMaxFrontDistance[nChannel]) != fMax ) - { - alSourcef(alChannel[nChannel], AL_MAX_DISTANCE, fMax); - alSourcef(alChannel[nChannel], AL_REFERENCE_DISTANCE, 5.0f); - alSourcef(alChannel[nChannel], AL_MAX_GAIN, 1.0f); - currentChannelMaxFrontDistance[nChannel] = int32(fMax); - } - } -} - -void -cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( nChannel == CHANNEL2D ) - { - uint32 vol = nVolume; - if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; - - nChannelVolume[nChannel] = vol; - - // increase the volume for JB.MP3 and S4_BDBD.MP3 - if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) - { - nChannelVolume[nChannel] >>= 2; - } - - uint32 channelVol = m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14; - if ( ChannelSample[nChannel] >= SFX_CAR_REV_1 && SFX_CAR_IDLE_10 >= ChannelSample[nChannel] ) // nice hack - channelVol >>= 1; - - if ( alChannel[nChannel] ) - { - if ( currentChannelVolume[nChannel] != channelVol ) - { - ALfloat gain = ALfloat(channelVol) / MAX_VOLUME; - alSourcef(alChannel[nChannel], AL_GAIN, gain); - currentChannelVolume[nChannel] = channelVol; - } - } - } -} - -void -cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - ; // NOIMP -} - -void -cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - if ( currentChannelFrequency[nChannel] != nFreq ) - { - ALfloat pitch = ALfloat(nFreq) / MAX_FREQ; - alSourcef(alChannel[nChannel], AL_PITCH, pitch); - currentChannelFrequency[nChannel] = nFreq; - - if ( Abs(1.0f - pitch) < 0.01f ) - ChannelPitch[nChannel] = 1.0f; - else - ChannelPitch[nChannel] = pitch; - } - } -} - -void -cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - ; // NOIMP -} - -void -cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( nLoopCount != 0 ) - alSourcei(alChannel[nChannel], AL_LOOPING, AL_FALSE); - else - alSourcei(alChannel[nChannel], AL_LOOPING, AL_TRUE); -} - -bool -cSampleManager::GetChannelUsedFlag(uint32 nChannel) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - ALint sourceState; - alGetSourcei(alChannel[nChannel], AL_SOURCE_STATE, &sourceState); - return sourceState == AL_PLAYING; - } - - return false; -} - -void -cSampleManager::StartChannel(uint32 nChannel) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - if ( ChannelSample[nChannel] > SAMPLEBANK_END ) // PED's Bank - { - if ( ChannelPitch[nChannel] != 1.0f ) - ChannelPitch[nChannel] = 1.0f; - } - - alSourcef (alChannel[nChannel], AL_PITCH, ChannelPitch[nChannel]); - alSourcePlay(alChannel[nChannel]); - } -} - -void -cSampleManager::StopChannel(uint32 nChannel) -{ - ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); - - if ( alChannel[nChannel] ) - { - alSourceStop(alChannel[nChannel]); - - currentChannelVolume [nChannel] = -1; - currentChannelFrequency [nChannel] = -1; - currentChannelMaxFrontDistance[nChannel] = -1; - ChannelPitch [nChannel] = 1.0f; - } -} - -void -cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) -{ - char filename[256]; - - ASSERT( nStream < MAX_STREAMS ); - - if ( nFile < TOTAL_STREAMED_SOUNDS ) - { - if ( mp3Stream[nStream] ) - { - delete mp3Stream[nStream]; - mp3Stream[nStream] = NULL; - } - - strcpy(filename, StreamedNameTable[nFile]); - - MP3Stream *stream = new MP3Stream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); - ASSERT(stream != NULL); - - mp3Stream[nStream] = stream; - - if ( stream->m_bIsOpened ) - { - ; - } - else - { - delete stream; - mp3Stream[nStream] = NULL; - } - } -} - -void -cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream ) - { - if ( nPauseFlag != 0 ) - { - if ( !stream->m_bIsPaused ) - { - alSourcePause(stream->m_alSource); - stream->m_bIsPaused = true; - } - } - else - { - if ( stream->m_bIsPaused ) - { - alSourcef(stream->m_alSource, AL_PITCH, 1.0f); - alSourcePlay(stream->m_alSource); - stream->m_bIsPaused = false; - } - } - } -} - -void -cSampleManager::StartPreloadedStreamedFile(uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream ) - { - stream->Initialize(); - if ( stream->m_bIsOpened ) - { - //NOTE: set pos here on mobile - - if ( stream->FillBuffers() != 0 ) - { - alSourcef(stream->m_alSource, AL_PITCH, 1.0f); - alSourcePlay(stream->m_alSource); - stream->m_bIsFree = false; - } - } - } -} - -bool -cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) -{ - char filename[256]; - - ASSERT( nStream < MAX_STREAMS ); - - if ( nFile < TOTAL_STREAMED_SOUNDS ) - { - if ( mp3Stream[nStream] ) - { - delete mp3Stream[nStream]; - mp3Stream[nStream] = NULL; - } - - strcpy(filename, StreamedNameTable[nFile]); - - MP3Stream *stream = new MP3Stream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); - ASSERT(stream != NULL); - - mp3Stream[nStream] = stream; - - if ( stream->m_bIsOpened ) - { - stream->Initialize(); - nStreamLength[nFile] = stream->m_nLength; - //MusicManager.SetTrackInfoLength(nFile, stream->m_nLength); - - if ( stream->m_bIsOpened ) - { - if ( nPos != 0 ) - { - stream->SetPos(nPos); - } - - if ( stream->FillBuffers() != 0 ) - { - alSourcef(stream->m_alSource, AL_PITCH, 1.0f); - alSourcePlay(stream->m_alSource); - stream->m_bIsFree = false; - } - } - - return true; - } - else - { - delete stream; - mp3Stream[nStream] = NULL; - } - } - - return false; -} - -void -cSampleManager::StopStreamedFile(uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream ) - { - delete stream; - mp3Stream[nStream] = NULL; - } -} - -int32 -cSampleManager::GetStreamedFilePosition(uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream ) - { - return (ftell(stream->m_fpFile) * 8) / stream->m_nBitRate; - } - - return 0; -} - -void -cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - if ( nVolume > MAX_VOLUME ) - nVolume = MAX_VOLUME; - - if ( nPan > MAX_VOLUME ) - nPan = MAX_VOLUME; - - nStreamVolume[nStream] = m_nMusicFadeVolume * nVolume; - nStreamPan [nStream] = nPan; - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream ) - { - uint32 vol; - if ( nEffectFlag ) - vol = m_nEffectsFadeVolume*nVolume*m_nEffectsVolume >> 14; - else - vol = m_nMusicFadeVolume*nVolume*m_nMusicVolume >> 14; - - if ( stream->m_nVolume != vol ) - { - if ( stream->m_bIsOpened ) - { - ALuint source = stream->m_alSource; - if ( source ) - { - ALfloat gain = ALfloat(vol) / MAX_VOLUME; - alSourcef(source, AL_GAIN, gain); - stream = mp3Stream[nStream]; - } - } - - stream->m_nVolume = vol; - } - } -} - -int32 -cSampleManager::GetStreamedFileLength(uint8 nStream) -{ - ASSERT( nStream < TOTAL_STREAMED_SOUNDS ); - - return nStreamLength[nStream]; -} - -bool -cSampleManager::IsStreamPlaying(uint8 nStream) -{ - ASSERT( nStream < MAX_STREAMS ); - - MP3Stream *stream = mp3Stream[nStream]; - - if ( stream && stream->m_bIsOpened && !stream->m_bIsPaused ) - { - ALint sourceState; - alGetSourcei(stream->m_alSource, AL_SOURCE_STATE, &sourceState); - if ( !stream->m_bIsFree || sourceState == AL_PLAYING ) - return true; - } - - return false; -} - -void -cSampleManager::Service(void) -{ - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - if ( mp3Stream[i] ) - mp3Stream[i]->Update(); - } - - UpdateSoundBuffers(); -} - -bool -cSampleManager::InitialiseSampleBanks(void) -{ - int32 nBank = SAMPLEBANK_MAIN; - - fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); - if ( fpSampleDescHandle == NULL ) - return false; - - fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); - if ( fpSampleDataHandle == NULL ) - { - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; - - return false; - } - - fseek(fpSampleDataHandle, 0, SEEK_END); - int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); - rewind(fpSampleDataHandle); - - fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); - - fclose(fpSampleDescHandle); - fpSampleDescHandle = NULL; - - for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) - { - if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) - { - nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; - nBank++; - } - } - - nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; - nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; - - return true; -} - -/* -sub_1D8D40 -PreloadSoundBank(tSample *,uchar) -CheckOpenALChannels(void) -*/ - -void MP3Stream::Initialize(void) -{ - if ( !m_bIsOpened ) - return; - - mpg123_format_none(m_pMPG); - - mpg123_format(m_pMPG, 11000, MPG123_MONO|MPG123_STEREO, MPG123_ENC_SIGNED_16); - mpg123_format(m_pMPG, 24000, MPG123_MONO|MPG123_STEREO, MPG123_ENC_SIGNED_16); - mpg123_format(m_pMPG, 32000, MPG123_MONO|MPG123_STEREO, MPG123_ENC_SIGNED_16); - mpg123_format(m_pMPG, 44100, MPG123_MONO|MPG123_STEREO, MPG123_ENC_SIGNED_16); - - if ( mpg123_open_feed(m_pMPG) != MPG123_OK ) - return; - - const uint32 CHUNK_SIZE = 1024*5; - - if ( fread(m_pBuf, 1, CHUNK_SIZE, m_fpFile) != CHUNK_SIZE ) - { - Delete(); - return; - } - - m_nBufSize -= CHUNK_SIZE; - - mpg123_feed(m_pMPG, m_pBuf, CHUNK_SIZE); - - if ( mpg123_getformat(m_pMPG, &m_nRate, &m_nChannels, &m_nEncoding) != MPG123_OK ) - { - Delete(); - return; - } - - mpg123_frameinfo info; - if ( mpg123_info(m_pMPG, &info) != MPG123_OK ) - { - Delete(); - return; - } - - m_nBitRate = info.bitrate; - m_nLength = 8 * m_nLengthInBytes / info.bitrate; - m_nBlockSize = mpg123_outblock(m_pMPG); - m_nNumBlocks = 5; - m_pBlocks = (unsigned char *)malloc(m_nNumBlocks * m_nBlockSize); -} - -bool MP3Stream::FillBuffer(ALuint alBuffer) -{ - size_t done; - - uint8 *pBlockBuff = (uint8 *)m_pBlocks; - - bool fail = !(m_nBufSize > 1); - - int err = mpg123_read(m_pMPG, m_pBlocks, m_nBlockSize, &done); - if ( alBuffer == 0 ) - { - if ( err == MPG123_OK ) - { - while ( mpg123_read(m_pMPG, pBlockBuff, m_nBlockSize, &done) == MPG123_OK ) - ; - } - - return true; - } - - int32 blocks = 0; - for ( blocks = 0; blocks < m_nNumBlocks; blocks++ ) - { - if ( err == MPG123_NEED_MORE ) - { - if ( fail ) - break; - - size_t readSize = m_nBufSize; - if ( readSize > 0x4000 ) - { - if ( fread(m_pBuf, 1, 0x4000, m_fpFile) != 0x4000 ) - { - fail = true; - TRACE("MP3 ************* : MP3 read unsuccessful mid file, stopping queuing"); - break; - } - - m_nBufSize -= 0x4000; - mpg123_feed(m_pMPG, m_pBuf, 0x4000); - } - else - { - if ( fread(m_pBuf, 1, readSize, m_fpFile) != readSize ) - { - fail = true; - break; - } - - m_nBufSize -= readSize; - mpg123_feed(m_pMPG, m_pBuf, readSize); - } - } - else if ( err == MPG123_OK ) - { - pBlockBuff += m_nBlockSize; - } - else - { - fail = true; - break; - } - - err = mpg123_read(m_pMPG, pBlockBuff, m_nBlockSize, &done); - } - - if ( blocks != 0 ) - { - if ( m_nChannels == 1 ) - alBufferData(alBuffer, AL_FORMAT_MONO16, m_pBlocks, m_nBlockSize*blocks, m_nRate); - else - alBufferData(alBuffer, AL_FORMAT_STEREO16, m_pBlocks, m_nBlockSize*blocks, m_nRate); - } - - if ( fail && blocks < m_nNumBlocks ) - m_bIsFree = true; - - return blocks != 0; -} - -void MP3Stream::Update(void) -{ - if ( !m_bIsOpened ) - return; - - if ( m_bIsFree ) - return; - - if ( !m_bIsPaused ) - { - ALint sourceState; - ALint buffersProcessed = 0; - - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); - alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed); - - ALint looping = AL_FALSE; - alGetSourcei(m_alSource, AL_LOOPING, &looping); - - if ( looping == AL_TRUE ) - { - TRACE("stream set looping"); - alSourcei(m_alSource, AL_LOOPING, AL_TRUE); - } - - while( buffersProcessed-- ) - { - ALuint buffer; - - alSourceUnqueueBuffers(m_alSource, 1, &buffer); - - if ( !m_bIsFree && FillBuffer(buffer) ) - alSourceQueueBuffers(m_alSource, 1, &buffer); - } - - if ( sourceState != AL_PLAYING ) - { - alSourcef(m_alSource, AL_PITCH, 1.0f); - alSourcePlay(m_alSource); - } - } -} - -void MP3Stream::SetPos(uint32 nPos) -{ - uint32 pos = nPos; - if ( nPos > m_nLength ) - pos %= m_nLength; - - uint32 blockPos = m_nBitRate * pos / 8; - if ( blockPos > m_nLengthInBytes ) - blockPos %= m_nLengthInBytes; - - fseek(m_fpFile, blockPos, SEEK_SET); - - size_t done; - while ( mpg123_read(m_pMPG, m_pBlocks, m_nBlockSize, &done) == MPG123_OK ) - ; -} - -int32 MP3Stream::FillBuffers() -{ - int32 i = 0; - for ( i = 0; i < ARRAY_SIZE(m_alBuffers); i++ ) - { - if ( !FillBuffer(m_alBuffers[i]) ) - break; - alSourceQueueBuffers(m_alSource, 1, &m_alBuffers[i]); - } - - return i; -} - -MP3Stream::MP3Stream(char *filename, ALuint source, ALuint *buffers) -{ - strcpy(m_aFilename, filename); - memset(m_alBuffers, 0, sizeof(m_alBuffers)); - m_alSource = source; - memcpy(m_alBuffers, buffers, sizeof(m_alBuffers)); - m_nVolume = -1; - m_pBlocks = NULL; - m_pBuf = NULL; - m_pMPG = NULL; - m_bIsPaused = false; - m_bIsOpened = true; - m_bIsFree = true; - m_fpFile = fopen(m_aFilename, "rb"); - - if ( m_fpFile ) - { - m_nBufSize = filelength(fileno(m_fpFile)); - m_nLengthInBytes = m_nBufSize; - m_pMPG = mpg123_new(NULL, NULL); - m_pBuf = (unsigned char *)malloc(0x4000); - } - else - { - m_bIsOpened = false; - Delete(); - } -} - -void MP3Stream::Delete() -{ - if ( m_pMPG ) - { - mpg123_delete(m_pMPG); - m_pMPG = NULL; - } - - if ( m_fpFile ) - { - fclose(m_fpFile); - m_fpFile = NULL; - } - - if ( m_alSource ) - { - ALint sourceState = AL_STOPPED; - alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); - if (sourceState != AL_STOPPED ) - alSourceStop(m_alSource); - - ALint buffersQueued; - alGetSourcei(m_alSource, AL_BUFFERS_QUEUED, &buffersQueued); - - ALuint value; - while (buffersQueued--) - alSourceUnqueueBuffers(m_alSource, 1, &value); - - m_alSource = 0; - } - - if ( m_pBlocks ) - { - free(m_pBlocks); - m_pBlocks = NULL; - } - - if ( m_pBuf ) - { - free(m_pBuf); - m_pBuf = NULL; - } - - m_bIsOpened = false; -} \ No newline at end of file diff --git a/src/audio/openal/samp_oal.h b/src/audio/openal/samp_oal.h deleted file mode 100644 index 8bbdbcc9..00000000 --- a/src/audio/openal/samp_oal.h +++ /dev/null @@ -1,340 +0,0 @@ -#pragma once -#include "common.h" -#include "AudioSamples.h" - -#define MAX_VOLUME 127 -//#define MAX_FREQ 22050 -#define MAX_FREQ 32000 - -struct tSample { - int32 nOffset; - uint32 nSize; - int32 nFrequency; - int32 nLoopStart; - int32 nLoopEnd; -}; - -enum -{ - SAMPLEBANK_MAIN, - SAMPLEBANK_PED, - MAX_SAMPLEBANKS, - SAMPLEBANK_INVALID -}; - -#define MAX_PEDSFX 7 -#define PED_BLOCKSIZE 79000 - - -//#define MAXCHANNELS 21 android -#define MAXCHANNELS 28 -#define MAX2DCHANNELS 1 -#define CHANNEL2D MAXCHANNELS - -#define MAX_STREAMS 2 - -struct ALCdevice_struct; -struct ALCcontext_struct; -typedef struct ALCdevice_struct ALCdevice; -typedef struct ALCcontext_struct ALCcontext; - -class cSampleManager -{ - int field_0; - ALCdevice *m_pDevice; - ALCcontext *m_pContext; - - uint8 m_nEffectsVolume; - uint8 m_nMusicVolume; - uint8 m_nEffectsFadeVolume; - uint8 m_nMusicFadeVolume; - uint8 m_nMonoMode; - char _pad0[3]; - tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; - -public: - - - - cSampleManager(void); - ~cSampleManager(void); - - void SetSpeakerConfig(int32 nConfig); - uint32 GetMaximumSupportedChannels(void); - - uint32 GetNum3DProvidersAvailable(); - void SetNum3DProvidersAvailable(uint32 num); - - char *Get3DProviderName(uint8 id); - void Set3DProviderName(uint8 id, char *name); - - int8 GetCurrent3DProviderIndex(void); - int8 SetCurrent3DProvider(uint8 which); - - bool IsMP3RadioChannelAvailable(void); - - void ReleaseDigitalHandle (void); - void ReacquireDigitalHandle(void); - - bool Initialise(void); - void Terminate (void); - - void UpdateSoundBuffers(void); - - bool CheckForAnAudioFileOnCD(void); - char GetCDAudioDriveLetter (void); - - void UpdateEffectsVolume(void); - - void SetEffectsMasterVolume(uint8 nVolume); - void SetMusicMasterVolume (uint8 nVolume); - void SetEffectsFadeVolume (uint8 nVolume); - void SetMusicFadeVolume (uint8 nVolume); - void SetMonoMode (uint8 nMode); - - bool LoadSampleBank (uint8 nBank); - void UnloadSampleBank (uint8 nBank); - bool IsSampleBankLoaded(uint8 nBank); - - bool IsPedCommentLoaded(uint32 nComment); - bool LoadPedComment (uint32 nComment); - int32 GetBankContainingSound(uint32 offset); - - int32 _GetPedCommentSlot(uint32 nComment); - - int32 GetSampleBaseFrequency (uint32 nSample); - int32 GetSampleLoopStartOffset(uint32 nSample); - int32 GetSampleLoopEndOffset (uint32 nSample); - uint32 GetSampleLength (uint32 nSample); - - bool UpdateReverb(void); - - void SetChannelReverbFlag (uint32 nChannel, uint8 nReverbFlag); - bool InitialiseChannel (uint32 nChannel, uint32 nSfx, uint8 nBank); - void SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume); - void SetChannel3DPosition (uint32 nChannel, float fX, float fY, float fZ); - void SetChannel3DDistances (uint32 nChannel, float fMax, float fMin); - void SetChannelVolume (uint32 nChannel, uint32 nVolume); - void SetChannelPan (uint32 nChannel, uint32 nPan); - void SetChannelFrequency (uint32 nChannel, uint32 nFreq); - void SetChannelLoopPoints (uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd); - void SetChannelLoopCount (uint32 nChannel, uint32 nLoopCount); - bool GetChannelUsedFlag (uint32 nChannel); - void StartChannel (uint32 nChannel); - void StopChannel (uint32 nChannel); - - void PreloadStreamedFile (uint8 nFile, uint8 nStream); - void PauseStream (uint8 nPauseFlag, uint8 nStream); - void StartPreloadedStreamedFile (uint8 nStream); - bool StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); - void StopStreamedFile (uint8 nStream); - int32 GetStreamedFilePosition (uint8 nStream); - void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream); - int32 GetStreamedFileLength (uint8 nStream); - bool IsStreamPlaying (uint8 nStream); - void Service(void); - bool InitialiseSampleBanks(void); -}; - -extern cSampleManager SampleManager; -extern int32 BankStartOffset[MAX_SAMPLEBANKS]; - -static char StreamedNameTable[][25]= -{ - "AUDIO\\HEAD.MP3", - "AUDIO\\CLASS.MP3", - "AUDIO\\KJAH.MP3", - "AUDIO\\RISE.MP3", - "AUDIO\\LIPS.MP3", - "AUDIO\\GAME.MP3", - "AUDIO\\MSX.MP3", - "AUDIO\\FLASH.MP3", - "AUDIO\\CHAT.MP3", - "AUDIO\\HEAD.MP3", - "AUDIO\\POLICE.MP3", - "AUDIO\\CITY.MP3", - "AUDIO\\WATER.MP3", - "AUDIO\\COMOPEN.MP3", - "AUDIO\\SUBOPEN.MP3", - "AUDIO\\JB.MP3", - "AUDIO\\BET.MP3", - "AUDIO\\L1_LG.MP3", - "AUDIO\\L2_DSB.MP3", - "AUDIO\\L3_DM.MP3", - "AUDIO\\L4_PAP.MP3", - "AUDIO\\L5_TFB.MP3", - "AUDIO\\J0_DM2.MP3", - "AUDIO\\J1_LFL.MP3", - "AUDIO\\J2_KCL.MP3", - "AUDIO\\J3_VH.MP3", - "AUDIO\\J4_ETH.MP3", - "AUDIO\\J5_DST.MP3", - "AUDIO\\J6_TBJ.MP3", - "AUDIO\\T1_TOL.MP3", - "AUDIO\\T2_TPU.MP3", - "AUDIO\\T3_MAS.MP3", - "AUDIO\\T4_TAT.MP3", - "AUDIO\\T5_BF.MP3", - "AUDIO\\S0_MAS.MP3", - "AUDIO\\S1_PF.MP3", - "AUDIO\\S2_CTG.MP3", - "AUDIO\\S3_RTC.MP3", - "AUDIO\\S5_LRQ.MP3", - "AUDIO\\S4_BDBA.MP3", - "AUDIO\\S4_BDBB.MP3", - "AUDIO\\S2_CTG2.MP3", - "AUDIO\\S4_BDBD.MP3", - "AUDIO\\S5_LRQB.MP3", - "AUDIO\\S5_LRQC.MP3", - "AUDIO\\A1_SSO.MP3", - "AUDIO\\A2_PP.MP3", - "AUDIO\\A3_SS.MP3", - "AUDIO\\A4_PDR.MP3", - "AUDIO\\A5_K2FT.MP3", - "AUDIO\\K1_KBO.MP3", - "AUDIO\\K2_GIS.MP3", - "AUDIO\\K3_DS.MP3", - "AUDIO\\K4_SHI.MP3", - "AUDIO\\K5_SD.MP3", - "AUDIO\\R0_PDR2.MP3", - "AUDIO\\R1_SW.MP3", - "AUDIO\\R2_AP.MP3", - "AUDIO\\R3_ED.MP3", - "AUDIO\\R4_GF.MP3", - "AUDIO\\R5_PB.MP3", - "AUDIO\\R6_MM.MP3", - "AUDIO\\D1_STOG.MP3", - "AUDIO\\D2_KK.MP3", - "AUDIO\\D3_ADO.MP3", - "AUDIO\\D5_ES.MP3", - "AUDIO\\D7_MLD.MP3", - "AUDIO\\D4_GTA.MP3", - "AUDIO\\D4_GTA2.MP3", - "AUDIO\\D6_STS.MP3", - "AUDIO\\A6_BAIT.MP3", - "AUDIO\\A7_ETG.MP3", - "AUDIO\\A8_PS.MP3", - "AUDIO\\A9_ASD.MP3", - "AUDIO\\K4_SHI2.MP3", - "AUDIO\\C1_TEX.MP3", - "AUDIO\\EL_PH1.MP3", - "AUDIO\\EL_PH2.MP3", - "AUDIO\\EL_PH3.MP3", - "AUDIO\\EL_PH4.MP3", - "AUDIO\\YD_PH1.MP3", - "AUDIO\\YD_PH2.MP3", - "AUDIO\\YD_PH3.MP3", - "AUDIO\\YD_PH4.MP3", - "AUDIO\\HD_PH1.MP3", - "AUDIO\\HD_PH2.MP3", - "AUDIO\\HD_PH3.MP3", - "AUDIO\\HD_PH4.MP3", - "AUDIO\\HD_PH5.MP3", - "AUDIO\\MT_PH1.MP3", - "AUDIO\\MT_PH2.MP3", - "AUDIO\\MT_PH3.MP3", - "AUDIO\\MT_PH4.MP3", - "AUDIO\\MISCOM.MP3", - "AUDIO\\END.MP3", - "AUDIO\\lib_a1.MP3", - "AUDIO\\lib_a2.MP3", - "AUDIO\\lib_a.MP3", - "AUDIO\\lib_b.MP3", - "AUDIO\\lib_c.MP3", - "AUDIO\\lib_d.MP3", - "AUDIO\\l2_a.MP3", - "AUDIO\\j4t_1.MP3", - "AUDIO\\j4t_2.MP3", - "AUDIO\\j4t_3.MP3", - "AUDIO\\j4t_4.MP3", - "AUDIO\\j4_a.MP3", - "AUDIO\\j4_b.MP3", - "AUDIO\\j4_c.MP3", - "AUDIO\\j4_d.MP3", - "AUDIO\\j4_e.MP3", - "AUDIO\\j4_f.MP3", - "AUDIO\\j6_1.MP3", - "AUDIO\\j6_a.MP3", - "AUDIO\\j6_b.MP3", - "AUDIO\\j6_c.MP3", - "AUDIO\\j6_d.MP3", - "AUDIO\\t4_a.MP3", - "AUDIO\\s1_a.MP3", - "AUDIO\\s1_a1.MP3", - "AUDIO\\s1_b.MP3", - "AUDIO\\s1_c.MP3", - "AUDIO\\s1_c1.MP3", - "AUDIO\\s1_d.MP3", - "AUDIO\\s1_e.MP3", - "AUDIO\\s1_f.MP3", - "AUDIO\\s1_g.MP3", - "AUDIO\\s1_h.MP3", - "AUDIO\\s1_i.MP3", - "AUDIO\\s1_j.MP3", - "AUDIO\\s1_k.MP3", - "AUDIO\\s1_l.MP3", - "AUDIO\\s3_a.MP3", - "AUDIO\\s3_b.MP3", - "AUDIO\\el3_a.MP3", - "AUDIO\\mf1_a.MP3", - "AUDIO\\mf2_a.MP3", - "AUDIO\\mf3_a.MP3", - "AUDIO\\mf3_b.MP3", - "AUDIO\\mf3_b1.MP3", - "AUDIO\\mf3_c.MP3", - "AUDIO\\mf4_a.MP3", - "AUDIO\\mf4_b.MP3", - "AUDIO\\mf4_c.MP3", - "AUDIO\\a1_a.MP3", - "AUDIO\\a3_a.MP3", - "AUDIO\\a5_a.MP3", - "AUDIO\\a4_a.MP3", - "AUDIO\\a4_b.MP3", - "AUDIO\\a4_c.MP3", - "AUDIO\\a4_d.MP3", - "AUDIO\\k1_a.MP3", - "AUDIO\\k3_a.MP3", - "AUDIO\\r1_a.MP3", - "AUDIO\\r2_a.MP3", - "AUDIO\\r2_b.MP3", - "AUDIO\\r2_c.MP3", - "AUDIO\\r2_d.MP3", - "AUDIO\\r2_e.MP3", - "AUDIO\\r2_f.MP3", - "AUDIO\\r2_g.MP3", - "AUDIO\\r2_h.MP3", - "AUDIO\\r5_a.MP3", - "AUDIO\\r6_a.MP3", - "AUDIO\\r6_a1.MP3", - "AUDIO\\r6_b.MP3", - "AUDIO\\lo2_a.MP3", - "AUDIO\\lo6_a.MP3", - "AUDIO\\yd2_a.MP3", - "AUDIO\\yd2_b.MP3", - "AUDIO\\yd2_c.MP3", - "AUDIO\\yd2_c1.MP3", - "AUDIO\\yd2_d.MP3", - "AUDIO\\yd2_e.MP3", - "AUDIO\\yd2_f.MP3", - "AUDIO\\yd2_g.MP3", - "AUDIO\\yd2_h.MP3", - "AUDIO\\yd2_ass.MP3", - "AUDIO\\yd2_ok.MP3", - "AUDIO\\h5_a.MP3", - "AUDIO\\h5_b.MP3", - "AUDIO\\h5_c.MP3", - "AUDIO\\ammu_a.MP3", - "AUDIO\\ammu_b.MP3", - "AUDIO\\ammu_c.MP3", - "AUDIO\\door_1.MP3", - "AUDIO\\door_2.MP3", - "AUDIO\\door_3.MP3", - "AUDIO\\door_4.MP3", - "AUDIO\\door_5.MP3", - "AUDIO\\door_6.MP3", - "AUDIO\\t3_a.MP3", - "AUDIO\\t3_b.MP3", - "AUDIO\\t3_c.MP3", - "AUDIO\\k1_b.MP3", - "AUDIO\\cat1.MP3" -}; diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp deleted file mode 100644 index aa6b67dc..00000000 --- a/src/audio/sampman.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include "common.h" -#ifndef OPENAL -#include "miles\sampman_mss.cpp" -#else -#include "openal\samp_oal.cpp" -#endif \ No newline at end of file diff --git a/src/audio/sampman.h b/src/audio/sampman.h index f454d236..d3c82943 100644 --- a/src/audio/sampman.h +++ b/src/audio/sampman.h @@ -1,7 +1,345 @@ #pragma once #include "common.h" -#ifndef OPENAL -#include "miles\sampman_mss.h" -#else -#include "openal\samp_oal.h" -#endif \ No newline at end of file +#include "AudioSamples.h" + +#define MAX_VOLUME 127 +#define MAX_FREQ 22050 + +struct tSample { + int32 nOffset; + uint32 nSize; + int32 nFrequency; + int32 nLoopStart; + int32 nLoopEnd; +}; + +enum +{ + SAMPLEBANK_MAIN, + SAMPLEBANK_PED, + MAX_SAMPLEBANKS, + SAMPLEBANK_INVALID +}; + +#define MAX_PEDSFX 7 +#define PED_BLOCKSIZE 79000 + +#define MAXPROVIDERS 64 + +#define MAXCHANNELS 28 +#define MAXCHANNELS_SURROUND 24 +#define MAX2DCHANNELS 1 +#define CHANNEL2D MAXCHANNELS + +#define MAX_STREAMS 2 + +#define DIGITALRATE 32000 +#define DIGITALBITS 16 +#define DIGITALCHANNELS 2 + +#define MAX_DIGITAL_MIXER_CHANNELS 32 + +class cSampleManager +{ + uint8 m_nEffectsVolume; + uint8 m_nMusicVolume; + uint8 m_nEffectsFadeVolume; + uint8 m_nMusicFadeVolume; + uint8 m_nMonoMode; + char unk; + char m_szCDRomRootPath[80]; + bool m_bInitialised; + uint8 m_nNumberOfProviders; + char *m_aAudioProviders[MAXPROVIDERS]; + tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; + +public: + + + + cSampleManager(void); + ~cSampleManager(void); + + void SetSpeakerConfig(int32 nConfig); + uint32 GetMaximumSupportedChannels(void); + + uint32 GetNum3DProvidersAvailable(void); + void SetNum3DProvidersAvailable(uint32 num); + + char *Get3DProviderName(uint8 id); + void Set3DProviderName(uint8 id, char *name); + + int8 GetCurrent3DProviderIndex(void); + int8 SetCurrent3DProvider(uint8 which); + + bool IsMP3RadioChannelAvailable(void); + + void ReleaseDigitalHandle (void); + void ReacquireDigitalHandle(void); + + bool Initialise(void); + void Terminate (void); + +#ifdef AUDIO_OAL + void UpdateSoundBuffers(void); +#endif + + bool CheckForAnAudioFileOnCD(void); + char GetCDAudioDriveLetter (void); + + void UpdateEffectsVolume(void); + + void SetEffectsMasterVolume(uint8 nVolume); + void SetMusicMasterVolume (uint8 nVolume); + void SetEffectsFadeVolume (uint8 nVolume); + void SetMusicFadeVolume (uint8 nVolume); + void SetMonoMode (uint8 nMode); + + bool LoadSampleBank (uint8 nBank); + void UnloadSampleBank (uint8 nBank); + bool IsSampleBankLoaded(uint8 nBank); + + bool IsPedCommentLoaded(uint32 nComment); + bool LoadPedComment (uint32 nComment); + int32 GetBankContainingSound(uint32 offset); + + int32 _GetPedCommentSlot(uint32 nComment); + + int32 GetSampleBaseFrequency (uint32 nSample); + int32 GetSampleLoopStartOffset(uint32 nSample); + int32 GetSampleLoopEndOffset (uint32 nSample); + uint32 GetSampleLength (uint32 nSample); + + bool UpdateReverb(void); + + void SetChannelReverbFlag (uint32 nChannel, uint8 nReverbFlag); + bool InitialiseChannel (uint32 nChannel, uint32 nSfx, uint8 nBank); + void SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume); + void SetChannel3DPosition (uint32 nChannel, float fX, float fY, float fZ); + void SetChannel3DDistances (uint32 nChannel, float fMax, float fMin); + void SetChannelVolume (uint32 nChannel, uint32 nVolume); + void SetChannelPan (uint32 nChannel, uint32 nPan); + void SetChannelFrequency (uint32 nChannel, uint32 nFreq); + void SetChannelLoopPoints (uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd); + void SetChannelLoopCount (uint32 nChannel, uint32 nLoopCount); + bool GetChannelUsedFlag (uint32 nChannel); + void StartChannel (uint32 nChannel); + void StopChannel (uint32 nChannel); + + void PreloadStreamedFile (uint8 nFile, uint8 nStream); + void PauseStream (uint8 nPauseFlag, uint8 nStream); + void StartPreloadedStreamedFile (uint8 nStream); + bool StartStreamedFile (uint8 nFile, uint32 nPos, uint8 nStream); + void StopStreamedFile (uint8 nStream); + int32 GetStreamedFilePosition (uint8 nStream); + void SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream); + int32 GetStreamedFileLength (uint8 nStream); + bool IsStreamPlaying (uint8 nStream); +#ifdef AUDIO_OAL + void Service(void); +#endif + bool InitialiseSampleBanks(void); +}; + +extern cSampleManager SampleManager; +extern uint32 BankStartOffset[MAX_SAMPLEBANKS]; + +static char StreamedNameTable[][25]= +{ + "AUDIO\\HEAD.WAV", + "AUDIO\\CLASS.WAV", + "AUDIO\\KJAH.WAV", + "AUDIO\\RISE.WAV", + "AUDIO\\LIPS.WAV", + "AUDIO\\GAME.WAV", + "AUDIO\\MSX.WAV", + "AUDIO\\FLASH.WAV", + "AUDIO\\CHAT.WAV", + "AUDIO\\HEAD.WAV", + "AUDIO\\POLICE.WAV", + "AUDIO\\CITY.WAV", + "AUDIO\\WATER.WAV", + "AUDIO\\COMOPEN.WAV", + "AUDIO\\SUBOPEN.WAV", + "AUDIO\\JB.MP3", + "AUDIO\\BET.MP3", + "AUDIO\\L1_LG.MP3", + "AUDIO\\L2_DSB.MP3", + "AUDIO\\L3_DM.MP3", + "AUDIO\\L4_PAP.MP3", + "AUDIO\\L5_TFB.MP3", + "AUDIO\\J0_DM2.MP3", + "AUDIO\\J1_LFL.MP3", + "AUDIO\\J2_KCL.MP3", + "AUDIO\\J3_VH.MP3", + "AUDIO\\J4_ETH.MP3", + "AUDIO\\J5_DST.MP3", + "AUDIO\\J6_TBJ.MP3", + "AUDIO\\T1_TOL.MP3", + "AUDIO\\T2_TPU.MP3", + "AUDIO\\T3_MAS.MP3", + "AUDIO\\T4_TAT.MP3", + "AUDIO\\T5_BF.MP3", + "AUDIO\\S0_MAS.MP3", + "AUDIO\\S1_PF.MP3", + "AUDIO\\S2_CTG.MP3", + "AUDIO\\S3_RTC.MP3", + "AUDIO\\S5_LRQ.MP3", + "AUDIO\\S4_BDBA.MP3", + "AUDIO\\S4_BDBB.MP3", + "AUDIO\\S2_CTG2.MP3", + "AUDIO\\S4_BDBD.MP3", + "AUDIO\\S5_LRQB.MP3", + "AUDIO\\S5_LRQC.MP3", + "AUDIO\\A1_SSO.WAV", + "AUDIO\\A2_PP.WAV", + "AUDIO\\A3_SS.WAV", + "AUDIO\\A4_PDR.WAV", + "AUDIO\\A5_K2FT.WAV", + "AUDIO\\K1_KBO.MP3", + "AUDIO\\K2_GIS.MP3", + "AUDIO\\K3_DS.MP3", + "AUDIO\\K4_SHI.MP3", + "AUDIO\\K5_SD.MP3", + "AUDIO\\R0_PDR2.MP3", + "AUDIO\\R1_SW.MP3", + "AUDIO\\R2_AP.MP3", + "AUDIO\\R3_ED.MP3", + "AUDIO\\R4_GF.MP3", + "AUDIO\\R5_PB.MP3", + "AUDIO\\R6_MM.MP3", + "AUDIO\\D1_STOG.MP3", + "AUDIO\\D2_KK.MP3", + "AUDIO\\D3_ADO.MP3", + "AUDIO\\D5_ES.MP3", + "AUDIO\\D7_MLD.MP3", + "AUDIO\\D4_GTA.MP3", + "AUDIO\\D4_GTA2.MP3", + "AUDIO\\D6_STS.MP3", + "AUDIO\\A6_BAIT.WAV", + "AUDIO\\A7_ETG.WAV", + "AUDIO\\A8_PS.WAV", + "AUDIO\\A9_ASD.WAV", + "AUDIO\\K4_SHI2.MP3", + "AUDIO\\C1_TEX.MP3", + "AUDIO\\EL_PH1.MP3", + "AUDIO\\EL_PH2.MP3", + "AUDIO\\EL_PH3.MP3", + "AUDIO\\EL_PH4.MP3", + "AUDIO\\YD_PH1.MP3", + "AUDIO\\YD_PH2.MP3", + "AUDIO\\YD_PH3.MP3", + "AUDIO\\YD_PH4.MP3", + "AUDIO\\HD_PH1.MP3", + "AUDIO\\HD_PH2.MP3", + "AUDIO\\HD_PH3.MP3", + "AUDIO\\HD_PH4.MP3", + "AUDIO\\HD_PH5.MP3", + "AUDIO\\MT_PH1.MP3", + "AUDIO\\MT_PH2.MP3", + "AUDIO\\MT_PH3.MP3", + "AUDIO\\MT_PH4.MP3", + "AUDIO\\MISCOM.WAV", + "AUDIO\\END.MP3", + "AUDIO\\lib_a1.WAV", + "AUDIO\\lib_a2.WAV", + "AUDIO\\lib_a.WAV", + "AUDIO\\lib_b.WAV", + "AUDIO\\lib_c.WAV", + "AUDIO\\lib_d.WAV", + "AUDIO\\l2_a.WAV", + "AUDIO\\j4t_1.WAV", + "AUDIO\\j4t_2.WAV", + "AUDIO\\j4t_3.WAV", + "AUDIO\\j4t_4.WAV", + "AUDIO\\j4_a.WAV", + "AUDIO\\j4_b.WAV", + "AUDIO\\j4_c.WAV", + "AUDIO\\j4_d.WAV", + "AUDIO\\j4_e.WAV", + "AUDIO\\j4_f.WAV", + "AUDIO\\j6_1.WAV", + "AUDIO\\j6_a.WAV", + "AUDIO\\j6_b.WAV", + "AUDIO\\j6_c.WAV", + "AUDIO\\j6_d.WAV", + "AUDIO\\t4_a.WAV", + "AUDIO\\s1_a.WAV", + "AUDIO\\s1_a1.WAV", + "AUDIO\\s1_b.WAV", + "AUDIO\\s1_c.WAV", + "AUDIO\\s1_c1.WAV", + "AUDIO\\s1_d.WAV", + "AUDIO\\s1_e.WAV", + "AUDIO\\s1_f.WAV", + "AUDIO\\s1_g.WAV", + "AUDIO\\s1_h.WAV", + "AUDIO\\s1_i.WAV", + "AUDIO\\s1_j.WAV", + "AUDIO\\s1_k.WAV", + "AUDIO\\s1_l.WAV", + "AUDIO\\s3_a.WAV", + "AUDIO\\s3_b.WAV", + "AUDIO\\el3_a.WAV", + "AUDIO\\mf1_a.WAV", + "AUDIO\\mf2_a.WAV", + "AUDIO\\mf3_a.WAV", + "AUDIO\\mf3_b.WAV", + "AUDIO\\mf3_b1.WAV", + "AUDIO\\mf3_c.WAV", + "AUDIO\\mf4_a.WAV", + "AUDIO\\mf4_b.WAV", + "AUDIO\\mf4_c.WAV", + "AUDIO\\a1_a.WAV", + "AUDIO\\a3_a.WAV", + "AUDIO\\a5_a.WAV", + "AUDIO\\a4_a.WAV", + "AUDIO\\a4_b.WAV", + "AUDIO\\a4_c.WAV", + "AUDIO\\a4_d.WAV", + "AUDIO\\k1_a.WAV", + "AUDIO\\k3_a.WAV", + "AUDIO\\r1_a.WAV", + "AUDIO\\r2_a.WAV", + "AUDIO\\r2_b.WAV", + "AUDIO\\r2_c.WAV", + "AUDIO\\r2_d.WAV", + "AUDIO\\r2_e.WAV", + "AUDIO\\r2_f.WAV", + "AUDIO\\r2_g.WAV", + "AUDIO\\r2_h.WAV", + "AUDIO\\r5_a.WAV", + "AUDIO\\r6_a.WAV", + "AUDIO\\r6_a1.WAV", + "AUDIO\\r6_b.WAV", + "AUDIO\\lo2_a.WAV", + "AUDIO\\lo6_a.WAV", + "AUDIO\\yd2_a.WAV", + "AUDIO\\yd2_b.WAV", + "AUDIO\\yd2_c.WAV", + "AUDIO\\yd2_c1.WAV", + "AUDIO\\yd2_d.WAV", + "AUDIO\\yd2_e.WAV", + "AUDIO\\yd2_f.WAV", + "AUDIO\\yd2_g.WAV", + "AUDIO\\yd2_h.WAV", + "AUDIO\\yd2_ass.WAV", + "AUDIO\\yd2_ok.WAV", + "AUDIO\\h5_a.WAV", + "AUDIO\\h5_b.WAV", + "AUDIO\\h5_c.WAV", + "AUDIO\\ammu_a.WAV", + "AUDIO\\ammu_b.WAV", + "AUDIO\\ammu_c.WAV", + "AUDIO\\door_1.WAV", + "AUDIO\\door_2.WAV", + "AUDIO\\door_3.WAV", + "AUDIO\\door_4.WAV", + "AUDIO\\door_5.WAV", + "AUDIO\\door_6.WAV", + "AUDIO\\t3_a.WAV", + "AUDIO\\t3_b.WAV", + "AUDIO\\t3_c.WAV", + "AUDIO\\k1_b.WAV", + "AUDIO\\cat1.WAV" +}; diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp new file mode 100644 index 00000000..caf2917f --- /dev/null +++ b/src/audio/sampman_miles.cpp @@ -0,0 +1,2311 @@ +#include "common.h" + +#ifdef AUDIO_MSS +#include +#include +#include + +#include + +#include "eax.h" +#include "eax-util.h" +#include "mss.h" + +#include "sampman.h" +#include "AudioManager.h" +#include "MusicManager.h" +#include "Frontend.h" +#include "Timer.h" + + +#pragma comment( lib, "mss32.lib" ) + +cSampleManager SampleManager; +uint32 BankStartOffset[MAX_SAMPLEBANKS]; +/////////////////////////////////////////////////////////////// + +char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; +char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; + +FILE *fpSampleDescHandle; +FILE *fpSampleDataHandle; +bool bSampleBankLoaded [MAX_SAMPLEBANKS]; +int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; +int32 nSampleBankSize [MAX_SAMPLEBANKS]; +int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +int32 _nSampleDataEndOffset; + +int32 nPedSlotSfx [MAX_PEDSFX]; +int32 nPedSlotSfxAddr[MAX_PEDSFX]; +uint8 nCurrentPedSlot; + +uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; + +uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; + +/////////////////////////////////////////////////////////////// +struct tMP3Entry +{ + char aFilename[MAX_PATH]; + + uint32 nTrackLength; + uint32 nTrackStreamPos; + + tMP3Entry *pNext; + char *pLinkPath; +}; + +uint32 nNumMP3s; +tMP3Entry *_pMP3List; +char _mp3DirectoryPath[MAX_PATH]; +HSTREAM mp3Stream [MAX_STREAMS]; +int8 nStreamPan [MAX_STREAMS]; +int8 nStreamVolume[MAX_STREAMS]; +uint32 _CurMP3Index; +int32 _CurMP3Pos; +bool _bIsMp3Active; + +#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) +bool _bUseHDDAudio; +char _aHDDPath[MAX_PATH]; +#endif +/////////////////////////////////////////////////////////////// + + +bool _bSampmanInitialised = false; + +// +// Miscellaneous globals / defines + +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS + +EAXLISTENERPROPERTIES StartEAX3 = + {26, 1.7f, 0.8f, -1000, -1000, -100, 4.42f, 0.14f, 1.00f, 429, 0.014f, 0.00f,0.00f,0.00f, 1023, 0.021f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2727.1f, 250.0f, 0.00f, 0x3f }; + +EAXLISTENERPROPERTIES FinishEAX3 = + {26, 100.0f, 1.0f, 0, -1000, -2200, 20.0f, 1.39f, 1.00f, 1000, 0.069f, 0.00f,0.00f,0.00f, 400, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 3.982f, 0.000f, -18.0f, 3530.8f, 417.9f, 6.70f, 0x3f }; + +EAXLISTENERPROPERTIES EAX3Params; + +S32 prevprovider=-1; +S32 curprovider=-1; +S32 usingEAX=0; +S32 usingEAX3=0; +HPROVIDER opened_provider=0; +H3DSAMPLE opened_samples[MAXCHANNELS] = {0}; +HSAMPLE opened_2dsamples[MAX2DCHANNELS] = {0}; +HDIGDRIVER DIG; +S32 speaker_type=0; + +U32 _maxSamples; +float _fPrevEaxRatioDestination; +bool _usingMilesFast2D; +float _fEffectsLevel; + + +struct +{ + HPROVIDER id; + char name[80]; +}providers[MAXPROVIDERS]; + +typedef struct provider_stuff +{ + char* name; + HPROVIDER id; +} provider_stuff; + + +static int __cdecl comp(const provider_stuff*s1,const provider_stuff*s2) +{ + return( _stricmp(s1->name,s2->name) ); +} + +static void +add_providers() +{ + provider_stuff pi[MAXPROVIDERS]; + U32 n,i,j; + + SampleManager.SetNum3DProvidersAvailable(0); + + HPROENUM next = HPROENUM_FIRST; + + n=0; + while (AIL_enumerate_3D_providers(&next, &pi[n].id, &pi[n].name) && (n MAXCHANNELS ) + _maxSamples = MAXCHANNELS; + + SampleManager.SetSpeakerConfig(speaker_type); + + //obtain a 3D sample handles + for ( U32 i = 0; i < _maxSamples; ++i ) + { + opened_samples[i] = AIL_allocate_3D_sample_handle(opened_provider); + if ( opened_samples[i] != NULL ) + AIL_set_3D_sample_effects_level(opened_samples[i], 0.0f); + } + + return true; + } + } + + return false; +} + +cSampleManager::cSampleManager(void) : + m_nNumberOfProviders(0) +{ + ; +} + +cSampleManager::~cSampleManager(void) +{ + +} + +void +cSampleManager::SetSpeakerConfig(int32 which) +{ + switch ( which ) + { + case 1: + speaker_type=AIL_3D_2_SPEAKER; + break; + + case 2: + speaker_type=AIL_3D_HEADPHONE; + break; + + case 3: + speaker_type=AIL_3D_4_SPEAKER; + break; + + default: + return; + break; + } + + if (opened_provider) + AIL_set_3D_speaker_type(opened_provider, speaker_type); +} + +uint32 +cSampleManager::GetMaximumSupportedChannels(void) +{ + if ( _maxSamples > MAXCHANNELS ) + return MAXCHANNELS; + + return _maxSamples; +} + +uint32 cSampleManager::GetNum3DProvidersAvailable() +{ + return m_nNumberOfProviders; +} + +void cSampleManager::SetNum3DProvidersAvailable(uint32 num) +{ + m_nNumberOfProviders = num; +} + +char *cSampleManager::Get3DProviderName(uint8 id) +{ + return m_aAudioProviders[id]; +} + +void cSampleManager::Set3DProviderName(uint8 id, char *name) +{ + m_aAudioProviders[id] = name; +} + +int8 +cSampleManager::GetCurrent3DProviderIndex(void) +{ + return curprovider; +} + +int8 +cSampleManager::SetCurrent3DProvider(uint8 nProvider) +{ + S32 savedprovider = curprovider; + + if ( nProvider < m_nNumberOfProviders ) + { + if ( set_new_provider(nProvider) ) + return curprovider; + else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) ) + return curprovider; + else + return -1; + } + else + return curprovider; +} + +static bool +_ResolveLink(char const *path, char *out) +{ + IShellLink* psl; + WIN32_FIND_DATA fd; + char filepath[MAX_PATH]; + + CoInitialize(NULL); + + if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl ) )) + { + IPersistFile *ppf; + + if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf))) + { + WCHAR wpath[MAX_PATH]; + + MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH); + + if (SUCCEEDED(ppf->Load(wpath, STGM_READ))) + { + /* Resolve the link */ + if (SUCCEEDED(psl->Resolve(NULL, SLR_ANY_MATCH|SLR_NO_UI|SLR_NOSEARCH))) + { + strcpy(filepath, path); + + if (SUCCEEDED(psl->GetPath(filepath, MAX_PATH, &fd, SLGP_UNCPRIORITY))) + { + OutputDebugString(fd.cFileName); + + strcpy(out, filepath); + // FIX: Release the objects. Taken from SA. +#ifdef FIX_BUGS + ppf->Release(); + psl->Release(); +#endif + return true; + } + } + } + + ppf->Release(); + } + psl->Release(); + } + + return false; +} + +static void +_FindMP3s(void) +{ + tMP3Entry *pList; + bool bShortcut; + bool bInitFirstEntry; + HANDLE hFind; + char path[MAX_PATH]; + char filepath[MAX_PATH*2]; + S32 total_ms; + WIN32_FIND_DATA fd; + + + if ( GetCurrentDirectory(MAX_PATH, _mp3DirectoryPath) == 0 ) + { + GetLastError(); + return; + } + + OutputDebugString("Finding MP3s..."); + strcpy(path, _mp3DirectoryPath); + strcat(path, "\\MP3\\"); + + strcpy(_mp3DirectoryPath, path); + OutputDebugString(_mp3DirectoryPath); + + strcat(path, "*"); + + hFind = FindFirstFile(path, &fd); + + if ( hFind == INVALID_HANDLE_VALUE ) + { + GetLastError(); + return; + } + + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + int32 filepathlen = strlen(filepath); + + if ( filepathlen <= 0) + { + FindClose(hFind); + return; + } + + FILE *f = fopen("MP3\\MP3Report.txt", "w"); + + if ( f ) + { + fprintf(f, "MP3 Report File\n\n"); + fprintf(f, "\"%s\"", fd.cFileName); + } + + + if ( filepathlen > 4 ) + { + if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) + { + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); + } + else + { + if ( f ) fprintf(f, " - couldn't resolve shortcut"); + } + + bShortcut = true; + } + else + bShortcut = false; + } + + mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); + if ( mp3Stream[0] ) + { + AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); + + AIL_close_stream(mp3Stream[0]); + mp3Stream[0] = NULL; + + OutputDebugString(fd.cFileName); + + _pMP3List = new tMP3Entry; + + if ( _pMP3List == NULL ) + { + FindClose(hFind); + + if ( f ) + fclose(f); + + return; + } + + nNumMP3s = 1; + + strcpy(_pMP3List->aFilename, fd.cFileName); + + _pMP3List->nTrackLength = total_ms; + + _pMP3List->pNext = NULL; + + pList = _pMP3List; + + if ( bShortcut ) + { + _pMP3List->pLinkPath = new char[MAX_PATH*2]; + strcpy(_pMP3List->pLinkPath, filepath); + } + else + { + _pMP3List->pLinkPath = NULL; + } + + if ( f ) fprintf(f, " - OK\n"); + + bInitFirstEntry = false; + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); + + bInitFirstEntry = true; + } + + while ( true ) + { + if ( !FindNextFile(hFind, &fd) ) + break; + + if ( bInitFirstEntry ) + { + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + int32 filepathlen = strlen(filepath); + + if ( f ) fprintf(f, "\"%s\"", fd.cFileName); + + if ( filepathlen > 0 ) + { + if ( filepathlen > 4 ) + { + if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) + { + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); + } + else + { + if ( f ) fprintf(f, " - couldn't resolve shortcut"); + } + + bShortcut = true; + } + else + { + bShortcut = false; + + if ( filepathlen > MAX_PATH ) + { + if ( f ) fprintf(f, " - Filename and path too long - %s - IGNORED)\n", filepath); + + continue; + } + } + } + + mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); + if ( mp3Stream[0] ) + { + AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); + + AIL_close_stream(mp3Stream[0]); + mp3Stream[0] = NULL; + + OutputDebugString(fd.cFileName); + + _pMP3List = new tMP3Entry; + + if ( _pMP3List == NULL) + break; + + nNumMP3s = 1; + + strcpy(_pMP3List->aFilename, fd.cFileName); + + _pMP3List->nTrackLength = total_ms; + _pMP3List->pNext = NULL; + + if ( bShortcut ) + { + _pMP3List->pLinkPath = new char [MAX_PATH*2]; + strcpy(_pMP3List->pLinkPath, filepath); + } + else + { + _pMP3List->pLinkPath = NULL; + } + + pList = _pMP3List; + + if ( f ) fprintf(f, " - OK\n"); + + bInitFirstEntry = false; + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); + } + } + } + else + { + strcpy(filepath, _mp3DirectoryPath); + strcat(filepath, fd.cFileName); + + int32 filepathlen = strlen(filepath); + + if ( filepathlen > 0 ) + { + if ( f ) fprintf(f, "\"%s\"", fd.cFileName); + + if ( filepathlen > 4 ) + { + if ( !strcmp(&filepath[filepathlen - 4], ".lnk") ) + { + if ( _ResolveLink(filepath, filepath) ) + { + OutputDebugString("Resolving Link"); + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - shortcut to \"%s\"", filepath); + } + else + { + if ( f ) fprintf(f, " - couldn't resolve shortcut"); + } + + bShortcut = true; + } + else + { + bShortcut = false; + } + } + + mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); + if ( mp3Stream[0] ) + { + AIL_stream_ms_position(mp3Stream[0], &total_ms, NULL); + + AIL_close_stream(mp3Stream[0]); + mp3Stream[0] = NULL; + + pList->pNext = new tMP3Entry; + + tMP3Entry *e = pList->pNext; + + if ( e == NULL ) + break; + + pList = pList->pNext; + + strcpy(e->aFilename, fd.cFileName); + e->nTrackLength = total_ms; + e->pNext = NULL; + + if ( bShortcut ) + { + e->pLinkPath = new char [MAX_PATH*2]; + strcpy(e->pLinkPath, filepath); + } + else + { + e->pLinkPath = NULL; + } + + nNumMP3s++; + + OutputDebugString(fd.cFileName); + + if ( f ) fprintf(f, " - OK\n"); + } + else + { + strcat(filepath, " - NOT A VALID MP3"); + OutputDebugString(filepath); + + if ( f ) fprintf(f, " - not an MP3 or supported MP3 type\n"); + } + } + } + } + + if ( f ) + { + fprintf(f, "\nTOTAL SUPPORTED MP3s: %d\n", nNumMP3s); + fclose(f); + } + + FindClose(hFind); +} + +static void +_DeleteMP3Entries(void) +{ + tMP3Entry *e = _pMP3List; + + while ( e != NULL ) + { + tMP3Entry *next = e->pNext; + + if ( next == NULL ) + next = NULL; + + if ( e->pLinkPath != NULL ) + { +#ifndef FIX_BUGS + delete e->pLinkPath; // BUG: should be delete [] +#else + delete[] e->pLinkPath; +#endif + e->pLinkPath = NULL; + } + + delete e; + + if ( next ) + e = next; + else + e = NULL; + + nNumMP3s--; + } + + + if ( nNumMP3s != 0 ) + { + OutputDebugString("Not all MP3 entries were deleted"); + nNumMP3s = 0; + } + + _pMP3List = NULL; +} + +static tMP3Entry * +_GetMP3EntryByIndex(uint32 idx) +{ + uint32 n = ( idx < nNumMP3s ) ? idx : 0; + + if ( _pMP3List != NULL ) + { + tMP3Entry *e = _pMP3List; + + for ( uint32 i = 0; i < n; i++ ) + e = e->pNext; + + return e; + + } + + return NULL; +} + +static inline bool +_GetMP3PosFromStreamPos(uint32 *pPosition, tMP3Entry **pEntry) +{ + _CurMP3Index = 0; + + for ( *pEntry = _pMP3List; *pEntry != NULL; *pEntry = (*pEntry)->pNext ) + { + if ( *pPosition >= (*pEntry)->nTrackStreamPos + && *pPosition < (*pEntry)->nTrackLength + (*pEntry)->nTrackStreamPos ) + { + *pPosition -= (*pEntry)->nTrackStreamPos; + _CurMP3Pos = *pPosition; + + return true; + } + + _CurMP3Index++; + } + + *pPosition = 0; + *pEntry = _pMP3List; + _CurMP3Pos = 0; + _CurMP3Index = 0; + + return false; +} + +bool +cSampleManager::IsMP3RadioChannelAvailable(void) +{ + return nNumMP3s != 0; +} + +void +cSampleManager::ReleaseDigitalHandle(void) +{ + if ( DIG ) + { + prevprovider = curprovider; + release_existing(); + curprovider = -1; + AIL_digital_handle_release(DIG); + } +} + +void +cSampleManager::ReacquireDigitalHandle(void) +{ + if ( DIG ) + { + AIL_digital_handle_reacquire(DIG); + if ( prevprovider != -1 ) + set_new_provider(prevprovider); + } +} + +bool +cSampleManager::Initialise(void) +{ + TRACE("start"); + + if ( _bSampmanInitialised ) + return true; + + { + for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) + { + m_aSamples[i].nOffset = 0; + m_aSamples[i].nSize = 0; + m_aSamples[i].nFrequency = 22050; + m_aSamples[i].nLoopStart = 0; + m_aSamples[i].nLoopEnd = -1; + } + + m_nEffectsVolume = MAX_VOLUME; + m_nMusicVolume = MAX_VOLUME; + m_nEffectsFadeVolume = MAX_VOLUME; + m_nMusicFadeVolume = MAX_VOLUME; + + m_nMonoMode = 0; + } + + // miles + TRACE("MILES"); + { + curprovider = -1; + prevprovider = -1; + + _usingMilesFast2D = false; + usingEAX=0; + usingEAX3=0; + + _fEffectsLevel = 0.0f; + + _maxSamples = 0; + + opened_provider = NULL; + DIG = NULL; + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + opened_samples[i] = NULL; + } + + // banks + TRACE("banks"); + { + fpSampleDescHandle = NULL; + fpSampleDataHandle = NULL; + + _nSampleDataEndOffset = 0; + + for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + { + bSampleBankLoaded[i] = false; + nSampleBankDiscStartOffset[i] = 0; + nSampleBankSize[i] = 0; + nSampleBankMemoryStartAddress[i] = 0; + } + } + + // pedsfx + TRACE("pedsfx"); + { + for ( int32 i = 0; i < MAX_PEDSFX; i++ ) + { + nPedSlotSfx[i] = NO_SAMPLE; + nPedSlotSfxAddr[i] = 0; + } + + nCurrentPedSlot = 0; + } + + // channel volume + TRACE("vol"); + { + for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + nChannelVolume[i] = 0; + } + + TRACE("mss"); + { + AIL_set_redist_directory( "mss" ); + + AIL_startup(); + + AIL_set_preference(DIG_MIXER_CHANNELS, MAX_DIGITAL_MIXER_CHANNELS); + + DIG = AIL_open_digital_driver(DIGITALRATE, DIGITALBITS, DIGITALCHANNELS, 0); + if ( DIG == NULL ) + { + OutputDebugString(AIL_last_error()); + Terminate(); + return false; + } + + add_providers(); + + if ( !InitialiseSampleBanks() ) + { + Terminate(); + return false; + } + + nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SAMPLEBANK_MAIN]); + if ( !nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] ) + { + Terminate(); + return false; + } + + nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); + + } + + TRACE("cdrom"); + + S32 tatalms; + char filepath[MAX_PATH]; + + { + m_bInitialised = false; + + while (true) + { + int32 drive = 'C'; + + do + { + char latter[2]; + + latter[0] = drive; + latter[1] = '\0'; + + strcpy(m_szCDRomRootPath, latter); + strcat(m_szCDRomRootPath, ":\\"); + + if ( GetDriveType(m_szCDRomRootPath) == DRIVE_CDROM ) + { + strcpy(filepath, m_szCDRomRootPath); + strcat(filepath, StreamedNameTable[0]); + + FILE *f = fopen(filepath, "rb"); + + if ( f ) + { + fclose(f); + + bool bFileNotFound = false; + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + { + strcpy(filepath, m_szCDRomRootPath); + strcat(filepath, StreamedNameTable[i]); + + mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); + + if ( mp3Stream[0] ) + { + AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL); + + AIL_close_stream(mp3Stream[0]); + mp3Stream[0] = NULL; + + nStreamLength[i] = tatalms; + } + else + { + bFileNotFound = true; + break; + } + } + + if ( !bFileNotFound ) + { + m_bInitialised = true; + break; + } + else + { + m_bInitialised = false; + continue; + } + } + } + + } while ( ++drive <= 'Z' ); + + if ( !m_bInitialised ) + { +#if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) + FrontEndMenuManager.WaitForUserCD(); + if ( FrontEndMenuManager.m_bQuitGameNoCD ) + { + Terminate(); + return false; + } + continue; +#else + m_bInitialised = true; +#endif + } + + break; + } + } + +#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) + // hddaudio + /** + Option for user to play audio files directly from hard disk. + Copy the contents of the PLAY discs Audio directory into your installed Grand Theft Auto III Audio directory. + Grand Theft Auto III still requires the presence of the PLAY disc when started. + This may give better performance on some machines (though worse on others). + **/ + TRACE("hddaudio 1.1 patch"); + { + int32 streamLength[TOTAL_STREAMED_SOUNDS]; + + bool bFileNotFound = false; + char rootpath[MAX_PATH]; + + strcpy(_aHDDPath, m_szCDRomRootPath); + rootpath[0] = '\0'; + + FILE *f = fopen(StreamedNameTable[0], "rb"); + + if ( f ) + { + fclose(f); + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + { + strcpy(filepath, rootpath); + strcat(filepath, StreamedNameTable[i]); + + mp3Stream[0] = AIL_open_stream(DIG, filepath, 0); + + if ( mp3Stream[0] ) + { + AIL_stream_ms_position(mp3Stream[0], &tatalms, NULL); + + AIL_close_stream(mp3Stream[0]); + mp3Stream[0] = NULL; + + streamLength[i] = tatalms; + } + else + { + bFileNotFound = true; + break; + } + } + + } + else + bFileNotFound = true; + + if ( !bFileNotFound ) + { + strcpy(m_szCDRomRootPath, rootpath); + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + nStreamLength[i] = streamLength[i]; + + _bUseHDDAudio = true; + } + else + _bUseHDDAudio = false; + } +#endif + + TRACE("stream"); + { + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + mp3Stream [i] = NULL; + nStreamPan [i] = 63; + nStreamVolume[i] = 100; + } + } + + for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) + { + opened_2dsamples[i] = AIL_allocate_sample_handle(DIG); + if ( opened_2dsamples[i] ) + { + AIL_init_sample(opened_2dsamples[i]); + AIL_set_sample_type(opened_2dsamples[i], DIG_F_MONO_16, DIG_PCM_SIGN); + } + } + + TRACE("providerset"); + { + _bSampmanInitialised = true; + + U32 n = 0; + + while ( n < m_nNumberOfProviders ) + { + if ( !strcmp(providers[n].name, "Miles Fast 2D Positional Audio") ) + { + set_new_provider(n); + break; + } + n++; + } + + if ( n == m_nNumberOfProviders ) + { + Terminate(); + return false; + } + } + + TRACE("bank"); + + LoadSampleBank(SAMPLEBANK_MAIN); + + // mp3 + TRACE("mp3"); + { + nNumMP3s = 0; + + _pMP3List = NULL; + + _FindMP3s(); + + if ( nNumMP3s != 0 ) + { + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; + + for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) + { + e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; + nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; + } + + time_t t = time(NULL); + tm *localtm; + bool bUseRandomTable; + + if ( t == -1 ) + bUseRandomTable = true; + else + { + bUseRandomTable = false; + localtm = localtime(&t); + } + + int32 randval; + if ( bUseRandomTable ) + randval = AudioManager.GetRandomNumber(1); + else + randval = localtm->tm_sec * localtm->tm_min; + + _CurMP3Index = randval % nNumMP3s; + + tMP3Entry *randmp3 = _pMP3List; + for ( int32 i = randval % nNumMP3s; i > 0; --i) + randmp3 = randmp3->pNext; + + if ( bUseRandomTable ) + _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + else + { + if ( localtm->tm_sec > 0 ) + { + int32 s = localtm->tm_sec; + _CurMP3Pos = s*s*s*s*s*s*s*s % randmp3->nTrackLength; + } + else + _CurMP3Pos = AudioManager.GetRandomNumber(0) % randmp3->nTrackLength; + } + } + else + _CurMP3Pos = 0; + + _bIsMp3Active = false; + } + + TRACE("end"); + + return true; +} + +void +cSampleManager::Terminate(void) +{ + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + if ( mp3Stream[i] ) + { + AIL_pause_stream(mp3Stream[i], 1); + AIL_close_stream(mp3Stream[i]); + mp3Stream[i] = NULL; + } + } + + for ( int32 i = 0; i < MAX2DCHANNELS; i++ ) + { + if ( opened_2dsamples[i] ) + { + AIL_release_sample_handle(opened_2dsamples[i]); + opened_2dsamples[i] = NULL; + } + } + + release_existing(); + + _DeleteMP3Entries(); + + if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + { + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); + nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + } + + if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + { + AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); + nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + } + + if ( DIG ) + { + AIL_close_digital_driver(DIG); + DIG = NULL; + } + + AIL_shutdown(); + + _bSampmanInitialised = false; +} + +bool +cSampleManager::CheckForAnAudioFileOnCD(void) +{ +#if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) + char filepath[MAX_PATH]; + +#if defined(GTA3_1_1_PATCH) + if (_bUseHDDAudio) + strcpy(filepath, _aHDDPath); + else + strcpy(filepath, m_szCDRomRootPath); +#else + strcpy(filepath, m_szCDRomRootPath); +#endif // #if defined(GTA3_1_1_PATCH) + + strcat(filepath, StreamedNameTable[AudioManager.GetRandomNumber(1) % TOTAL_STREAMED_SOUNDS]); + + FILE *f = fopen(filepath, "rb"); + + if ( f ) + { + fclose(f); + + return true; + } + + return false; + +#else + return true; +#endif // #if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) +} + +char +cSampleManager::GetCDAudioDriveLetter(void) +{ +#if defined(GTA3_1_1_PATCH) || defined(GTA3_STEAM_PATCH) || defined(NO_CDCHECK) + if (_bUseHDDAudio) + { + if ( strlen(_aHDDPath) != 0 ) + return _aHDDPath[0]; + else + return '\0'; + } + else + { + if ( strlen(m_szCDRomRootPath) != 0 ) + return m_szCDRomRootPath[0]; + else + return '\0'; + } +#else + if ( strlen(m_szCDRomRootPath) != 0 ) + return m_szCDRomRootPath[0]; + else + return '\0'; +#endif +} + +void +cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuffers ? +{ + if ( _bSampmanInitialised ) + { + for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + { + if ( i < MAXCHANNELS ) + { + if ( opened_samples[i] && GetChannelUsedFlag(i) ) + { + if ( nChannelVolume[i] ) + { + AIL_set_3D_sample_volume(opened_samples[i], + m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); + } + } + } + else + { + if ( opened_2dsamples[i - MAXCHANNELS] ) + { + if ( GetChannelUsedFlag(i - MAXCHANNELS) ) + { + if ( nChannelVolume[i - MAXCHANNELS] ) + { + AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS], + m_nEffectsFadeVolume * nChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); + } + } + } + } + } + } +} + +void +cSampleManager::SetEffectsMasterVolume(uint8 nVolume) +{ + m_nEffectsVolume = nVolume; + UpdateEffectsVolume(); +} + +void +cSampleManager::SetMusicMasterVolume(uint8 nVolume) +{ + m_nMusicVolume = nVolume; +} + +void +cSampleManager::SetEffectsFadeVolume(uint8 nVolume) +{ + m_nEffectsFadeVolume = nVolume; + UpdateEffectsVolume(); +} + +void +cSampleManager::SetMusicFadeVolume(uint8 nVolume) +{ + m_nMusicFadeVolume = nVolume; +} + +void +cSampleManager::SetMonoMode(uint8 nMode) +{ + m_nMonoMode = nMode; +} + +bool +cSampleManager::LoadSampleBank(uint8 nBank) +{ + if ( CTimer::GetIsCodePaused() ) + return false; + + if ( MusicManager.IsInitialised() + && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && nBank != SAMPLEBANK_MAIN ) + { + return false; + } + + if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + return false; + + if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) + return false; + + bSampleBankLoaded[nBank] = true; + + return true; +} + +void +cSampleManager::UnloadSampleBank(uint8 nBank) +{ + bSampleBankLoaded[nBank] = false; +} + +bool +cSampleManager::IsSampleBankLoaded(uint8 nBank) +{ + return bSampleBankLoaded[nBank]; +} + +bool +cSampleManager::IsPedCommentLoaded(uint32 nComment) +{ + uint8 slot; + + for ( int32 i = 0; i < _TODOCONST(3); i++ ) + { + slot = nCurrentPedSlot - i - 1; + if ( nComment == nPedSlotSfx[slot] ) + return true; + } + + return false; +} + +int32 +cSampleManager::_GetPedCommentSlot(uint32 nComment) +{ + uint8 slot; + + for ( int32 i = 0; i < _TODOCONST(3); i++ ) + { + slot = nCurrentPedSlot - i - 1; + if ( nComment == nPedSlotSfx[slot] ) + return slot; + } + + return -1; +} + +bool +cSampleManager::LoadPedComment(uint32 nComment) +{ + if ( CTimer::GetIsCodePaused() ) + return false; + + // no talking peds during cutsenes or the game end + if ( MusicManager.IsInitialised() ) + { + switch ( MusicManager.GetMusicMode() ) + { + case MUSICMODE_CUTSCENE: + { + return false; + + break; + } + + case MUSICMODE_FRONTEND: + { + if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) + return false; + + break; + } + } + } + + if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) + return false; + + if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + return false; + + nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot; + nPedSlotSfx [nCurrentPedSlot] = nComment; + + if ( ++nCurrentPedSlot >= MAX_PEDSFX ) + nCurrentPedSlot = 0; + + return true; +} + +int32 +cSampleManager::GetBankContainingSound(uint32 offset) +{ + if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) + return SAMPLEBANK_PED; + + if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) + return SAMPLEBANK_MAIN; + + return SAMPLEBANK_INVALID; +} + +int32 +cSampleManager::GetSampleBaseFrequency(uint32 nSample) +{ + return m_aSamples[nSample].nFrequency; +} + +int32 +cSampleManager::GetSampleLoopStartOffset(uint32 nSample) +{ + return m_aSamples[nSample].nLoopStart; +} + +int32 +cSampleManager::GetSampleLoopEndOffset(uint32 nSample) +{ + return m_aSamples[nSample].nLoopEnd; +} + +uint32 +cSampleManager::GetSampleLength(uint32 nSample) +{ + return m_aSamples[nSample].nSize >> 1; +} + +bool +cSampleManager::UpdateReverb(void) +{ + if ( !usingEAX ) + return false; + + if ( AudioManager.GetFrameCounter() & 15 ) + return false; + + float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM); + float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT); + float z = AudioManager.GetReflectionsDistance(REFLECTION_UP); + + float normy = norm(y, 5.0f, 40.0f); + float normx = norm(x, 5.0f, 40.0f); + float normz = norm(z, 5.0f, 40.0f); + + float fRatio; + + if ( normy == 0.0f ) + { + if ( normx == 0.0f ) + { + if ( normz == 0.0f ) + fRatio = 0.3f; + else + fRatio = 0.5f; + } + else + { + fRatio = 0.3f; + } + } + else + { + if ( normx == 0.0f ) + { + if ( normz == 0.0f ) + fRatio = 0.3f; + else + fRatio = 0.5f; + } + else + { + if ( normz == 0.0f ) + fRatio = 0.3f; + else + fRatio = (normy+normx+normz) / 3.0f; + } + } + + fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); + + if ( fRatio == _fPrevEaxRatioDestination ) + return false; + + if ( usingEAX3 ) + { + if ( EAX3ListenerInterpolate(&StartEAX3, &FinishEAX3, fRatio, &EAX3Params, false) ) + { + AIL_set_3D_provider_preference(opened_provider, "EAX all parameters", &EAX3Params); + _fEffectsLevel = 1.0f - fRatio * 0.5f; + } + } + else + { + if ( _usingMilesFast2D ) + _fEffectsLevel = (1.0f - fRatio) * 0.4f; + else + _fEffectsLevel = (1.0f - fRatio) * 0.7f; + } + + _fPrevEaxRatioDestination = fRatio; + + return true; +} + +void +cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( usingEAX ) + { + if ( nReverbFlag != 0 ) + { + if ( !b2d ) + AIL_set_3D_sample_effects_level(opened_samples[nChannel], _fEffectsLevel); + } + else + { + if ( !b2d ) + AIL_set_3D_sample_effects_level(opened_samples[nChannel], 0.0f); + } + } +} + +bool +cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + int32 addr; + + if ( nSfx < SAMPLEBANK_MAX ) + { + if ( !IsSampleBankLoaded(nBank) ) + return false; + + addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; + } + else + { + if ( !IsPedCommentLoaded(nSfx) ) + return false; + + int32 slot = _GetPedCommentSlot(nSfx); + + addr = nPedSlotSfxAddr[slot]; + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + { + AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); + return true; + } + else + return false; + } + else + { + AILSOUNDINFO info; + + info.format = WAVE_FORMAT_PCM; + info.data_ptr = (void *)addr; + info.channels = 1; + info.data_len = m_aSamples[nSfx].nSize; + info.rate = m_aSamples[nSfx].nFrequency; + info.bits = 16; + + if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) + { + OutputDebugString(AIL_last_error()); + return false; + } + + return true; + } +} + +void +cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) +{ + uint32 vol = nVolume; + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + + nChannelVolume[nChannel] = vol; + + // increase the volume for JB.MP3 and S4_BDBD.MP3 + if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + { + nChannelVolume[nChannel] >>= 2; + } + + if ( opened_samples[nChannel] ) + AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); + +} + +void +cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) +{ + if ( opened_samples[nChannel] ) + AIL_set_3D_position(opened_samples[nChannel], -fX, fY, fZ); +} + +void +cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) +{ + if ( opened_samples[nChannel] ) + AIL_set_3D_sample_distances(opened_samples[nChannel], fMax, fMin); +} + +void +cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) +{ + uint32 vol = nVolume; + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + + switch ( nChannel ) + { + case CHANNEL2D: + { + nChannelVolume[nChannel] = vol; + + // increase the volume for JB.MP3 and S4_BDBD.MP3 + if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + { + nChannelVolume[nChannel] >>= 2; + } + + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + { + AIL_set_sample_volume(opened_2dsamples[nChannel - MAXCHANNELS], + m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); + } + + break; + } + } +} + +void +cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) +{ + switch ( nChannel ) + { + case CHANNEL2D: + { +#ifndef FIX_BUGS + if ( opened_samples[nChannel - MAXCHANNELS] ) // BUG +#else + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) +#endif + AIL_set_sample_pan(opened_2dsamples[nChannel - MAXCHANNELS], nPan); + + break; + } + } +} + +void +cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + AIL_set_sample_playback_rate(opened_2dsamples[nChannel - MAXCHANNELS], nFreq); + } + else + { + if ( opened_samples[nChannel] ) + AIL_set_3D_sample_playback_rate(opened_samples[nChannel], nFreq); + } +} + +void +cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + AIL_set_sample_loop_block(opened_2dsamples[nChannel - MAXCHANNELS], nLoopStart, nLoopEnd); + } + else + { + if ( opened_samples[nChannel] ) + AIL_set_3D_sample_loop_block(opened_samples[nChannel], nLoopStart, nLoopEnd); + } +} + +void +cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + AIL_set_sample_loop_count(opened_2dsamples[nChannel - MAXCHANNELS], nLoopCount); + } + else + { + if ( opened_samples[nChannel] ) + AIL_set_3D_sample_loop_count(opened_samples[nChannel], nLoopCount); + } +} + +bool +cSampleManager::GetChannelUsedFlag(uint32 nChannel) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + return AIL_sample_status(opened_2dsamples[nChannel - MAXCHANNELS]) == SMP_PLAYING; + else + return false; + } + else + { + if ( opened_samples[nChannel] ) + return AIL_3D_sample_status(opened_samples[nChannel]) == SMP_PLAYING; + else + return false; + } + +} + +void +cSampleManager::StartChannel(uint32 nChannel) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + AIL_start_sample(opened_2dsamples[nChannel - MAXCHANNELS]); + } + else + { + if ( opened_samples[nChannel] ) + AIL_start_3D_sample(opened_samples[nChannel]); + } +} + +void +cSampleManager::StopChannel(uint32 nChannel) +{ + bool b2d = false; + + switch ( nChannel ) + { + case CHANNEL2D: + { + b2d = true; + break; + } + } + + if ( b2d ) + { + if ( opened_2dsamples[nChannel - MAXCHANNELS] ) + AIL_end_sample(opened_2dsamples[nChannel - MAXCHANNELS]); + } + else + { + if ( opened_samples[nChannel] ) + { + if ( AIL_3D_sample_status(opened_samples[nChannel]) == SMP_PLAYING ) + AIL_end_3D_sample(opened_samples[nChannel]); + } + } +} + +void +cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) +{ + if ( m_bInitialised ) + { + if ( nFile < TOTAL_STREAMED_SOUNDS ) + { + if ( mp3Stream[nStream] ) + { + AIL_pause_stream(mp3Stream[nStream], 1); + AIL_close_stream(mp3Stream[nStream]); + } + + char filepath[MAX_PATH]; + + strcpy(filepath, m_szCDRomRootPath); + strcat(filepath, StreamedNameTable[nFile]); + + mp3Stream[nStream] = AIL_open_stream(DIG, filepath, 0); + + if ( mp3Stream[nStream] ) + { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_service_stream(mp3Stream[nStream], 1); + } + else + OutputDebugString(AIL_last_error()); + } + } +} + +void +cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +{ + if ( m_bInitialised ) + { + if ( mp3Stream[nStream] ) + AIL_pause_stream(mp3Stream[nStream], nPauseFlag != 0); + } +} + +void +cSampleManager::StartPreloadedStreamedFile(uint8 nStream) +{ + if ( m_bInitialised ) + { + if ( mp3Stream[nStream] ) + AIL_start_stream(mp3Stream[nStream]); + } +} + +bool +cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) +{ + uint32 position = nPos; + char filename[MAX_PATH]; + + if ( m_bInitialised && nFile < TOTAL_STREAMED_SOUNDS ) + { + if ( mp3Stream[nStream] ) + { + AIL_pause_stream(mp3Stream[nStream], 1); + AIL_close_stream(mp3Stream[nStream]); + } + + if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER ) + { + uint32 i = 0; + do { + if(i != 0 || _bIsMp3Active) { + if(++_CurMP3Index >= nNumMP3s) _CurMP3Index = 0; + + _CurMP3Pos = 0; + + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if(mp3) { + mp3 = _pMP3List; + if(mp3 == NULL) { + _bIsMp3Active = false; + nFile = 0; + strcpy(filename, m_szCDRomRootPath); + strcat(filename, StreamedNameTable[nFile]); + + mp3Stream[nStream] = + AIL_open_stream(DIG, filename, 0); + if(mp3Stream[nStream]) { + AIL_set_stream_loop_count( + mp3Stream[nStream], 1); + AIL_set_stream_ms_position( + mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], + 0); + return true; + } + + return false; + } + } + + if(mp3->pLinkPath != NULL) + mp3Stream[nStream] = + AIL_open_stream(DIG, mp3->pLinkPath, 0); + else { + strcpy(filename, _mp3DirectoryPath); + strcat(filename, mp3->aFilename); + + mp3Stream[nStream] = + AIL_open_stream(DIG, filename, 0); + } + + if(mp3Stream[nStream]) { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_set_stream_ms_position(mp3Stream[nStream], 0); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; + } + + _bIsMp3Active = false; + continue; + } + if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) + position = 0; + + tMP3Entry *e; + if ( !_GetMP3PosFromStreamPos(&position, &e) ) + { + if ( e == NULL ) + { + nFile = 0; + strcpy(filename, m_szCDRomRootPath); + strcat(filename, StreamedNameTable[nFile]); + mp3Stream[nStream] = + AIL_open_stream(DIG, filename, 0); + if(mp3Stream[nStream]) { + AIL_set_stream_loop_count( + mp3Stream[nStream], 1); + AIL_set_stream_ms_position( + mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; + } + + return false; + } + } + + if ( e->pLinkPath != NULL ) + mp3Stream[nStream] = AIL_open_stream(DIG, e->pLinkPath, 0); + else + { + strcpy(filename, _mp3DirectoryPath); + strcat(filename, e->aFilename); + + mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); + } + + if ( mp3Stream[nStream] ) + { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], 0); + + _bIsMp3Active = true; + + return true; + } + + _bIsMp3Active = false; + + } while(++i < nNumMP3s); + + position = 0; + nFile = 0; + } + + strcpy(filename, m_szCDRomRootPath); + strcat(filename, StreamedNameTable[nFile]); + + mp3Stream[nStream] = AIL_open_stream(DIG, filename, 0); + if ( mp3Stream[nStream] ) + { + AIL_set_stream_loop_count(mp3Stream[nStream], 1); + AIL_set_stream_ms_position(mp3Stream[nStream], position); + AIL_pause_stream(mp3Stream[nStream], 0); + return true; + } + } + + return false; +} + +void +cSampleManager::StopStreamedFile(uint8 nStream) +{ + if ( m_bInitialised ) + { + if ( mp3Stream[nStream] ) + { + AIL_pause_stream(mp3Stream[nStream], 1); + + AIL_close_stream(mp3Stream[nStream]); + mp3Stream[nStream] = NULL; + + if ( nStream == 0 ) + _bIsMp3Active = false; + } + } +} + +int32 +cSampleManager::GetStreamedFilePosition(uint8 nStream) +{ + S32 currentms; + + if ( m_bInitialised ) + { + if ( mp3Stream[nStream] ) + { + if ( _bIsMp3Active ) + { + tMP3Entry *mp3 = _GetMP3EntryByIndex(_CurMP3Index); + + if ( mp3 != NULL ) + { + AIL_stream_ms_position(mp3Stream[nStream], NULL, ¤tms); + return currentms + mp3->nTrackStreamPos; + } + else + return 0; + } + else + { + AIL_stream_ms_position(mp3Stream[nStream], NULL, ¤tms); + return currentms; + } + } + } + + return 0; +} + +void +cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) +{ + uint8 vol = nVolume; + + if ( m_bInitialised ) + { + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + + nStreamVolume[nStream] = vol; + nStreamPan[nStream] = nPan; + + if ( mp3Stream[nStream] ) + { + if ( nEffectFlag ) + AIL_set_stream_volume(mp3Stream[nStream], m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); + else + AIL_set_stream_volume(mp3Stream[nStream], m_nMusicFadeVolume*vol*m_nMusicVolume >> 14); + + AIL_set_stream_pan(mp3Stream[nStream], nPan); + } + } +} + +int32 +cSampleManager::GetStreamedFileLength(uint8 nStream) +{ + if ( m_bInitialised ) + return nStreamLength[nStream]; + + return 0; +} + +bool +cSampleManager::IsStreamPlaying(uint8 nStream) +{ + if ( m_bInitialised ) + { + if ( mp3Stream[nStream] ) + { + if ( AIL_stream_status(mp3Stream[nStream]) == SMP_PLAYING ) + return true; + else + return false; + } + } + + return false; +} + +bool +cSampleManager::InitialiseSampleBanks(void) +{ + int32 nBank = SAMPLEBANK_MAIN; + + fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); + if ( fpSampleDescHandle == NULL ) + return false; + + fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); + if ( fpSampleDataHandle == NULL ) + { + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; + + return false; + } + + fseek(fpSampleDataHandle, 0, SEEK_END); + _nSampleDataEndOffset = ftell(fpSampleDataHandle); + rewind(fpSampleDataHandle); + + fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); + + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; + + for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) + { +#ifdef FIX_BUGS + if (nBank >= MAX_SAMPLEBANKS) break; +#endif + if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + { + nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; + nBank++; + } + } + + nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; + nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + + return true; +} + +#endif \ No newline at end of file diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp new file mode 100644 index 00000000..3eb296ae --- /dev/null +++ b/src/audio/sampman_oal.cpp @@ -0,0 +1,1372 @@ +#include "common.h" +//#define JUICY_OAL + +#ifdef AUDIO_OAL +#include "sampman.h" + +#include +#include + +#include "eax.h" +#include "eax-util.h" + +#include +#include +#include +#include +#include + +#include "oal/oal_utils.h" +#include "oal/aldlist.h" +#include "oal/channel.h" +#include "oal/stream.h" + +#include "AudioManager.h" +#include "MusicManager.h" +#include "Frontend.h" +#include "Timer.h" + +//todo max channals +//todo queue +//todo loop count +//todo mp3/wav stream +//todo mp3 player + +#pragma comment( lib, "OpenAL32.lib" ) + +cSampleManager SampleManager; +bool _bSampmanInitialised = false; + +uint32 BankStartOffset[MAX_SAMPLEBANKS]; + +int prevprovider=-1; +int curprovider=-1; +int usingEAX=0; +int usingEAX3=0; +//int speaker_type=0; +ALCdevice *ALDevice = NULL; +ALCcontext *ALContext = NULL; +unsigned int _maxSamples; +float _fPrevEaxRatioDestination; +bool _usingEFX; +float _fEffectsLevel; +ALuint ALEffect = AL_EFFECT_NULL; +ALuint ALEffectSlot = AL_EFFECTSLOT_NULL; +struct +{ + std::string id; + char name[256]; + int sources; +}providers[MAXPROVIDERS]; + +int defaultProvider; + + +char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; +char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; + +FILE *fpSampleDescHandle; +FILE *fpSampleDataHandle; +bool bSampleBankLoaded [MAX_SAMPLEBANKS]; +int32 nSampleBankDiscStartOffset [MAX_SAMPLEBANKS]; +int32 nSampleBankSize [MAX_SAMPLEBANKS]; +int32 nSampleBankMemoryStartAddress[MAX_SAMPLEBANKS]; +int32 _nSampleDataEndOffset; + +int32 nPedSlotSfx [MAX_PEDSFX]; +int32 nPedSlotSfxAddr[MAX_PEDSFX]; +uint8 nCurrentPedSlot; + +ALuint pedBuffers[MAX_PEDSFX]; + +CChannel aChannel[MAXCHANNELS+MAX2DCHANNELS]; +uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; + +uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; +ALuint ALStreamSources[MAX_STREAMS]; +ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; +struct +{ + ALuint buffer; + ALuint timer; +}ALBuffers[SAMPLEBANK_MAX]; + +uint32 nNumMP3s; +CStream *aStream[MAX_STREAMS]; +uint8 nStreamPan [MAX_STREAMS]; +uint8 nStreamVolume[MAX_STREAMS]; + +/////////////////////////////////////////////////////////////// +// Env Size Diffus Room RoomHF RoomLF DecTm DcHF DcLF Refl RefDel Ref Pan Revb RevDel Rev Pan EchTm EchDp ModTm ModDp AirAbs HFRef LFRef RRlOff FLAGS +EAXLISTENERPROPERTIES StartEAX3 = + {26, 1.7f, 0.8f, -1000, -1000, -100, 4.42f, 0.14f, 1.00f, 429, 0.014f, 0.00f,0.00f,0.00f, 1023, 0.021f, 0.00f,0.00f,0.00f, 0.250f, 0.000f, 0.250f, 0.000f, -5.0f, 2727.1f, 250.0f, 0.00f, 0x3f }; + +EAXLISTENERPROPERTIES FinishEAX3 = + {26, 100.0f, 1.0f, 0, -1000, -2200, 20.0f, 1.39f, 1.00f, 1000, 0.069f, 0.00f,0.00f,0.00f, 400, 0.100f, 0.00f,0.00f,0.00f, 0.250f, 1.000f, 3.982f, 0.000f, -18.0f, 3530.8f, 417.9f, 6.70f, 0x3f }; + +EAXLISTENERPROPERTIES EAX3Params; + + +bool IsFXSupported() +{ + return usingEAX || usingEAX3 || _usingEFX; +} + +void EAX_SetAll(const EAXLISTENERPROPERTIES *allparameters) +{ + if ( usingEAX || usingEAX3 ) + EAX3_Set(ALEffect, allparameters); + else + EFX_Set(ALEffect, allparameters); +} + +static void +add_providers() +{ + SampleManager.SetNum3DProvidersAvailable(0); + + ALDeviceList *pDeviceList = NULL; + pDeviceList = new ALDeviceList(); + + if ((pDeviceList) && (pDeviceList->GetNumDevices())) + { + const int devNumber = Min(pDeviceList->GetNumDevices(), MAXPROVIDERS); + int n = 0; + + for (int i = 0; i < devNumber; i++) + { + if ( n < MAXPROVIDERS ) + { + providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); + providers[n].sources = pDeviceList->GetMaxNumSources(i); + SampleManager.Set3DProviderName(n, providers[n].name); + n++; + } + + if ( alGetEnumValue("AL_EFFECT_EAXREVERB") != 0 + || pDeviceList->IsExtensionSupported(i, "EAX2.0") + || pDeviceList->IsExtensionSupported(i, "EAX3.0") + || pDeviceList->IsExtensionSupported(i, "EAX4.0") + || pDeviceList->IsExtensionSupported(i, "EAX5.0") ) + { + if ( n < MAXPROVIDERS ) + { + providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); + strcat(providers[n].name, " EAX"); + providers[n].sources = pDeviceList->GetMaxNumSources(i); + SampleManager.Set3DProviderName(n, providers[n].name); + n++; + } + + if ( n < MAXPROVIDERS ) + { + providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); + strcat(providers[n].name, " EAX3"); + providers[n].sources = pDeviceList->GetMaxNumSources(i); + SampleManager.Set3DProviderName(n, providers[n].name); + n++; + } + } + } + SampleManager.SetNum3DProvidersAvailable(n); + + for(int j=n;jGetDefaultDevice(); + if ( defaultProvider > MAXPROVIDERS ) + defaultProvider = 0; + + delete pDeviceList; + } +} + +static void +release_existing() +{ + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].Term(); + aChannel[CHANNEL2D].Term(); + + if ( IsFXSupported() ) + { + if ( alIsEffect(ALEffect) ) + { + alEffecti(ALEffect, AL_EFFECT_TYPE, AL_EFFECT_NULL); + alDeleteEffects(1, &ALEffect); + ALEffect = AL_EFFECT_NULL; + } + + if (alIsAuxiliaryEffectSlot(ALEffectSlot)) + { + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); + + alDeleteAuxiliaryEffectSlots(1, &ALEffectSlot); + ALEffectSlot = AL_EFFECTSLOT_NULL; + } + } + + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + alDeleteSources(1, &ALStreamSources[i]); + alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + } + + alDeleteBuffers(MAX_PEDSFX, pedBuffers); + + for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) + { + if ( ALBuffers[i].buffer != 0 && alIsBuffer(ALBuffers[i].buffer) ) + alDeleteBuffers(1, &ALBuffers[i].buffer); + + ALBuffers[i].timer = 0; + } + + if ( ALContext ) + { + alcMakeContextCurrent(NULL); + alcSuspendContext(ALContext); + alcDestroyContext(ALContext); + } + if ( ALDevice ) + alcCloseDevice(ALDevice); + + ALDevice = NULL; + ALContext = NULL; + + _fPrevEaxRatioDestination = 0.0f; + _usingEFX = false; + _fEffectsLevel = 0.0f; + + DEV("release_existing()\n"); +} + +static bool +set_new_provider(int index) +{ + if ( curprovider == index ) + return true; + + curprovider = index; + + release_existing(); + + if ( curprovider != -1 ) + { + DEV("set_new_provider()\n"); + + //TODO: + _maxSamples = MAXCHANNELS; + + ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0}; + + ALDevice = alcOpenDevice(providers[index].id.c_str()); + ASSERT(ALDevice != NULL); + + ALContext = alcCreateContext(ALDevice, attr); + ASSERT(ALContext != NULL); + + alcMakeContextCurrent(ALContext); + + const char* ext=(const char*)alGetString(AL_EXTENSIONS); + ASSERT(strstr(ext,"AL_SOFT_loop_points")!=NULL); + if ( strstr(ext,"AL_SOFT_loop_points")==NULL ) + { + curprovider=-1; + release_existing(); + return false; + } + + alListenerf (AL_GAIN, 1.0f); + alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f); + alListener3f(AL_VELOCITY, 0.0f, 0.0f, 0.0f); + ALfloat orientation[6] = { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; + alListenerfv(AL_ORIENTATION, orientation); + + alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); + + if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) + { + alGenAuxiliaryEffectSlots(1, &ALEffectSlot); + alGenEffects(1, &ALEffect); + } + + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + alGenSources(1, &ALStreamSources[i]); + alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + } + + for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) + { + ALBuffers[i].buffer = 0; + ALBuffers[i].timer = 0; + } + + alGenBuffers(MAX_PEDSFX, pedBuffers); + + usingEAX = 0; + usingEAX3 = 0; + _usingEFX = false; + + if ( !strcmp(&providers[index].name[strlen(providers[index].name) - strlen(" EAX3")], " EAX3") + && alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) + { + EAX_SetAll(&FinishEAX3); + + usingEAX = 1; + usingEAX3 = 1; + + DEV("EAX3\n"); + } + else if ( alcIsExtensionPresent(ALDevice, (ALCchar*)ALC_EXT_EFX_NAME) ) + { + EAX_SetAll(&EAX30_ORIGINAL_PRESETS[EAX_ENVIRONMENT_CAVE]); + + if ( !strcmp(&providers[index].name[strlen(providers[index].name) - strlen(" EAX")], " EAX")) + { + usingEAX = 1; + DEV("EAX1\n"); + } + else + { + _usingEFX = true; + DEV("EFX\n"); + } + } + + //SampleManager.SetSpeakerConfig(speaker_type); + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].Init(); + aChannel[CHANNEL2D].Init(true); + + if ( IsFXSupported() ) + { + /**/ + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + /**/ + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].SetReverbMix(ALEffectSlot, 0.0f); + } + + return true; + } + + return false; +} + +cSampleManager::cSampleManager(void) +{ + ; +} + +cSampleManager::~cSampleManager(void) +{ + +} + +void cSampleManager::SetSpeakerConfig(int32 nConfig) +{ + +} + +uint32 cSampleManager::GetMaximumSupportedChannels(void) +{ + if ( _maxSamples > MAXCHANNELS ) + return MAXCHANNELS; + + return _maxSamples; +} + +uint32 cSampleManager::GetNum3DProvidersAvailable() +{ + return m_nNumberOfProviders; +} + +void cSampleManager::SetNum3DProvidersAvailable(uint32 num) +{ + m_nNumberOfProviders = num; +} + +char *cSampleManager::Get3DProviderName(uint8 id) +{ + return m_aAudioProviders[id]; +} + +void cSampleManager::Set3DProviderName(uint8 id, char *name) +{ + m_aAudioProviders[id] = name; +} + +int8 cSampleManager::GetCurrent3DProviderIndex(void) +{ + return curprovider; +} + +int8 cSampleManager::SetCurrent3DProvider(uint8 nProvider) +{ + ASSERT( nProvider < m_nNumberOfProviders ); + int savedprovider = curprovider; + + if ( nProvider < m_nNumberOfProviders ) + { + if ( set_new_provider(nProvider) ) + return curprovider; + else if ( savedprovider != -1 && savedprovider < m_nNumberOfProviders && set_new_provider(savedprovider) ) + return curprovider; + else + return -1; + } + else + return curprovider; +} + +bool +cSampleManager::IsMP3RadioChannelAvailable(void) +{ + return nNumMP3s != 0; +} + + +void cSampleManager::ReleaseDigitalHandle(void) +{ + if ( ALDevice ) + { + prevprovider = curprovider; + release_existing(); + curprovider = -1; + } +} + +void cSampleManager::ReacquireDigitalHandle(void) +{ + if ( ALDevice ) + { + if ( prevprovider != -1 ) + set_new_provider(prevprovider); + } +} + +bool +cSampleManager::Initialise(void) +{ + if ( _bSampmanInitialised ) + return true; + + EFXInit(); + CStream::Initialise(); + + { + for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) + { + m_aSamples[i].nOffset = 0; + m_aSamples[i].nSize = 0; + m_aSamples[i].nFrequency = MAX_FREQ; + m_aSamples[i].nLoopStart = 0; + m_aSamples[i].nLoopEnd = -1; + } + + m_nEffectsVolume = MAX_VOLUME; + m_nMusicVolume = MAX_VOLUME; + m_nEffectsFadeVolume = MAX_VOLUME; + m_nMusicFadeVolume = MAX_VOLUME; + + m_nMonoMode = 0; + } + + { + curprovider = -1; + prevprovider = -1; + + _usingEFX = false; + usingEAX =0; + usingEAX3=0; + + _fEffectsLevel = 0.0f; + + _maxSamples = 0; + + ALDevice = NULL; + ALContext = NULL; + } + + { + fpSampleDescHandle = NULL; + fpSampleDataHandle = NULL; + + for ( int32 i = 0; i < MAX_SAMPLEBANKS; i++ ) + { + bSampleBankLoaded[i] = false; + nSampleBankDiscStartOffset[i] = 0; + nSampleBankSize[i] = 0; + nSampleBankMemoryStartAddress[i] = 0; + } + } + + { + for ( int32 i = 0; i < MAX_PEDSFX; i++ ) + { + nPedSlotSfx[i] = NO_SAMPLE; + nPedSlotSfxAddr[i] = 0; + } + + nCurrentPedSlot = 0; + } + + { + for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + nChannelVolume[i] = 0; + } + + { + add_providers(); + + if ( !InitialiseSampleBanks() ) + { + Terminate(); + return false; + } + + nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = (int32)malloc(nSampleBankSize[SAMPLEBANK_MAIN]); + ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != NULL); + + if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] == NULL ) + { + Terminate(); + return false; + } + + nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = (int32)malloc(PED_BLOCKSIZE*MAX_PEDSFX); + ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != NULL); + } + + { + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + aStream[i] = NULL; + nStreamVolume[i] = 100; + nStreamPan[i] = 63; + } + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + nStreamLength[i] = 3600000; + } + + { + _bSampmanInitialised = true; + + if ( 0 >= defaultProvider && defaultProvider < m_nNumberOfProviders ) + { + set_new_provider(defaultProvider); + } + else + { + Terminate(); + return false; + } + } + + LoadSampleBank(SAMPLEBANK_MAIN); + + return true; +} + +void +cSampleManager::Terminate(void) +{ + release_existing(); + + for (int32 i = 0; i < MAX_STREAMS; i++) + { + CStream *stream = aStream[i]; + if (stream) + { + delete stream; + aStream[i] = NULL; + } + } + + CStream::Terminate(); + + if ( nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] != 0 ) + { + free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN]); + nSampleBankMemoryStartAddress[SAMPLEBANK_MAIN] = 0; + } + + if ( nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != 0 ) + { + free((void *)nSampleBankMemoryStartAddress[SAMPLEBANK_PED]); + nSampleBankMemoryStartAddress[SAMPLEBANK_PED] = 0; + } + + _bSampmanInitialised = false; +} + +void +cSampleManager::UpdateSoundBuffers(void) +{ + for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) + { + if ( ALBuffers[i].timer > 0 ) + { + ALBuffers[i].timer -= ALuint(CTimer::GetTimeStepInMilliseconds()); + + if ( ALBuffers[i].timer <= 0 ) + { + if ( ALBuffers[i].buffer != 0 && alIsBuffer(ALBuffers[i].buffer) ) + { + alDeleteBuffers(1, &ALBuffers[i].buffer); + + if ( alGetError() == AL_NO_ERROR ) + ALBuffers[i].timer = 0; + else + ALBuffers[i].timer = 10000; + } + } + } + } +} + +bool cSampleManager::CheckForAnAudioFileOnCD(void) +{ + return true; +} + +char cSampleManager::GetCDAudioDriveLetter(void) +{ + return '\0'; +} + +void +cSampleManager::UpdateEffectsVolume(void) +{ + if ( _bSampmanInitialised ) + { + for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) + { + if ( GetChannelUsedFlag(i) ) + { + if ( nChannelVolume[i] != 0 ) + aChannel[i].SetVolume(m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); + } + } + } +} + +void +cSampleManager::SetEffectsMasterVolume(uint8 nVolume) +{ + m_nEffectsVolume = nVolume; + UpdateEffectsVolume(); +} + +void +cSampleManager::SetMusicMasterVolume(uint8 nVolume) +{ + m_nMusicVolume = nVolume; +} + +void +cSampleManager::SetEffectsFadeVolume(uint8 nVolume) +{ + m_nEffectsFadeVolume = nVolume; + UpdateEffectsVolume(); +} + +void +cSampleManager::SetMusicFadeVolume(uint8 nVolume) +{ + m_nMusicFadeVolume = nVolume; +} + +void +cSampleManager::SetMonoMode(uint8 nMode) +{ + m_nMonoMode = nMode; +} + +bool +cSampleManager::LoadSampleBank(uint8 nBank) +{ + ASSERT( nBank < MAX_SAMPLEBANKS ); + + if ( CTimer::GetIsCodePaused() ) + return false; + + if ( MusicManager.IsInitialised() + && MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && nBank != SAMPLEBANK_MAIN ) + { + return false; + } + + if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) + return false; + + if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) + return false; + + bSampleBankLoaded[nBank] = true; + + return true; +} + +void +cSampleManager::UnloadSampleBank(uint8 nBank) +{ + ASSERT( nBank < MAX_SAMPLEBANKS ); + + bSampleBankLoaded[nBank] = false; +} + +bool +cSampleManager::IsSampleBankLoaded(uint8 nBank) +{ + ASSERT( nBank < MAX_SAMPLEBANKS ); + + return bSampleBankLoaded[nBank]; +} + +bool +cSampleManager::IsPedCommentLoaded(uint32 nComment) +{ + ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); + + uint8 slot; + + for ( int32 i = 0; i < _TODOCONST(3); i++ ) + { + slot = nCurrentPedSlot - i - 1; + if ( nComment == nPedSlotSfx[slot] ) + return true; + } + + return false; +} + + +int32 +cSampleManager::_GetPedCommentSlot(uint32 nComment) +{ + uint8 slot; + + for (int32 i = 0; i < _TODOCONST(3); i++) + { + slot = nCurrentPedSlot - i - 1; + if (nComment == nPedSlotSfx[slot]) + return slot; + } + + return -1; +} + +bool +cSampleManager::LoadPedComment(uint32 nComment) +{ + ASSERT( nComment < TOTAL_AUDIO_SAMPLES ); + + if ( CTimer::GetIsCodePaused() ) + return false; + + // no talking peds during cutsenes or the game end + if ( MusicManager.IsInitialised() ) + { + switch ( MusicManager.GetMusicMode() ) + { + case MUSICMODE_CUTSCENE: + { + return false; + + break; + } + + case MUSICMODE_FRONTEND: + { + if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) + return false; + + break; + } + } + } + + if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) + return false; + + if ( fread((void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) + return false; + + nPedSlotSfx[nCurrentPedSlot] = nComment; + + alBufferData(pedBuffers[nCurrentPedSlot], + AL_FORMAT_MONO16, + (void *)(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] + PED_BLOCKSIZE*nCurrentPedSlot), + m_aSamples[nComment].nSize, + m_aSamples[nComment].nFrequency); + + if ( ++nCurrentPedSlot >= MAX_PEDSFX ) + nCurrentPedSlot = 0; + + return true; +} + +int32 +cSampleManager::GetBankContainingSound(uint32 offset) +{ + if ( offset >= BankStartOffset[SAMPLEBANK_PED] ) + return SAMPLEBANK_PED; + + if ( offset >= BankStartOffset[SAMPLEBANK_MAIN] ) + return SAMPLEBANK_MAIN; + + return SAMPLEBANK_INVALID; +} + +int32 +cSampleManager::GetSampleBaseFrequency(uint32 nSample) +{ + ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); + return m_aSamples[nSample].nFrequency; +} + +int32 +cSampleManager::GetSampleLoopStartOffset(uint32 nSample) +{ + ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); + return m_aSamples[nSample].nLoopStart; +} + +int32 +cSampleManager::GetSampleLoopEndOffset(uint32 nSample) +{ + ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); + return m_aSamples[nSample].nLoopEnd; +} + +uint32 +cSampleManager::GetSampleLength(uint32 nSample) +{ + ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); + return m_aSamples[nSample].nSize >> 1; +} + +bool cSampleManager::UpdateReverb(void) +{ + if ( !usingEAX && !_usingEFX ) + return false; + + if ( AudioManager.GetFrameCounter() & 15 ) + return false; + + float y = AudioManager.GetReflectionsDistance(REFLECTION_TOP) + AudioManager.GetReflectionsDistance(REFLECTION_BOTTOM); + float x = AudioManager.GetReflectionsDistance(REFLECTION_LEFT) + AudioManager.GetReflectionsDistance(REFLECTION_RIGHT); + float z = AudioManager.GetReflectionsDistance(REFLECTION_UP); + + float normy = norm(y, 5.0f, 40.0f); + float normx = norm(x, 5.0f, 40.0f); + float normz = norm(z, 5.0f, 40.0f); + + #define ZR(v, a, b) (((v)==0)?(a):(b)) + #define CALCRATIO(x,y,z,min,max,val) (ZR(y, ZR(x, ZR(z, min, max), min), ZR(x, ZR(z, min, max), ZR(z, min, val)))) + + float fRatio = CALCRATIO(normx, normy, normz, 0.3f, 0.5f, (normy+normx+normz)/3.0f); + + #undef CALCRATIO + #undef ZE + + fRatio = clamp(fRatio, usingEAX3==1 ? 0.0f : 0.30f, 1.0f); + + if ( fRatio == _fPrevEaxRatioDestination ) + return false; + +#ifdef JUICY_OAL + if ( usingEAX3 || _usingEFX ) +#else + if ( usingEAX3 ) +#endif + { + if ( EAX3ListenerInterpolate(&StartEAX3, &FinishEAX3, fRatio, &EAX3Params, false) ) + { + EAX_SetAll(&EAX3Params); + + /* + if ( IsFXSupported() ) + { + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + + for ( int32 i = 0; i < MAXCHANNELS; i++ ) + aChannel[i].UpdateReverb(ALEffectSlot); + } + */ + + _fEffectsLevel = 1.0f - fRatio * 0.5f; + } + } + else + { + if ( _usingEFX ) + _fEffectsLevel = (1.0f - fRatio) * 0.4f; + else + _fEffectsLevel = (1.0f - fRatio) * 0.7f; + } + + _fPrevEaxRatioDestination = fRatio; + + return true; +} + +void +cSampleManager::SetChannelReverbFlag(uint32 nChannel, uint8 nReverbFlag) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + if ( usingEAX || _usingEFX ) + { + if ( IsFXSupported() ) + { + alAuxiliaryEffectSloti(ALEffectSlot, AL_EFFECTSLOT_EFFECT, ALEffect); + + if ( nReverbFlag != 0 ) + aChannel[nChannel].SetReverbMix(ALEffectSlot, _fEffectsLevel); + else + aChannel[nChannel].SetReverbMix(ALEffectSlot, 0.0f); + } + } +} + +bool +cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + ALuint buffer; + + if ( nSfx < SAMPLEBANK_MAX ) + { + if ( !IsSampleBankLoaded(nBank) ) + return false; + + int32 addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; + + if ( ALBuffers[nSfx].timer == 0 ) + { + ALuint buf; + + alGenBuffers(1, &buf); + alBufferData(buf, AL_FORMAT_MONO16, (void *)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); + ALBuffers[nSfx].buffer = buf; + ALBuffers[nSfx].timer = 10000; + } + + buffer = ALBuffers[nSfx].buffer; + } + else + { + if ( !IsPedCommentLoaded(nSfx) ) + return false; + + int32 slot = _GetPedCommentSlot(nSfx); + + buffer = pedBuffers[slot]; + } + + if ( buffer == 0 ) + { + TRACE("No buffer to play id %d", nSfx); + return false; + } + + if ( GetChannelUsedFlag(nChannel) ) + { + TRACE("Stopping channel %d - really!!!", nChannel); + StopChannel(nChannel); + } + + aChannel[nChannel].Reset(); + if ( aChannel[nChannel].HasSource() ) + { + aChannel[nChannel].SetSampleID (nSfx); + aChannel[nChannel].SetFreq (m_aSamples[nSfx].nFrequency); + aChannel[nChannel].SetLoopPoints (0, -1); + aChannel[nChannel].SetBuffer (buffer); + aChannel[nChannel].SetPitch (1.0f); + return true; + } + + return false; +} + +void +cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) +{ + ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + uint32 vol = nVolume; + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + + nChannelVolume[nChannel] = vol; + + // reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing + if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + { + nChannelVolume[nChannel] >>= 2; + } + + // no idea, does this one looks like a bug or it's SetChannelVolume ? + aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); +} + +void +cSampleManager::SetChannel3DPosition(uint32 nChannel, float fX, float fY, float fZ) +{ + ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].SetPosition(-fX, fY, fZ); +} + +void +cSampleManager::SetChannel3DDistances(uint32 nChannel, float fMax, float fMin) +{ + ASSERT( nChannel != CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + aChannel[nChannel].SetDistances(fMax, fMin); +} + +void +cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) +{ + ASSERT( nChannel == CHANNEL2D ); + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + if ( nChannel == CHANNEL2D ) + { + uint32 vol = nVolume; + if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; + + nChannelVolume[nChannel] = vol; + + // reduce the volume for JB.MP3 and S4_BDBD.MP3 + if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + { + nChannelVolume[nChannel] >>= 2; + } + + aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); + } +} + +void +cSampleManager::SetChannelPan(uint32 nChannel, uint32 nPan) +{ + ASSERT(nChannel == CHANNEL2D); + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + if ( nChannel == CHANNEL2D ) + { + aChannel[nChannel].SetPan(nPan); + } +} + +void +cSampleManager::SetChannelFrequency(uint32 nChannel, uint32 nFreq) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].SetCurrentFreq(nFreq); +} + +void +cSampleManager::SetChannelLoopPoints(uint32 nChannel, uint32 nLoopStart, int32 nLoopEnd) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].SetLoopPoints(nLoopStart / (DIGITALBITS / 8), nLoopEnd / (DIGITALBITS / 8)); +} + +void +cSampleManager::SetChannelLoopCount(uint32 nChannel, uint32 nLoopCount) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].SetLoopCount(nLoopCount); +} + +bool +cSampleManager::GetChannelUsedFlag(uint32 nChannel) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + return aChannel[nChannel].IsUsed(); +} + +void +cSampleManager::StartChannel(uint32 nChannel) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].Start(); +} + +void +cSampleManager::StopChannel(uint32 nChannel) +{ + ASSERT( nChannel < MAXCHANNELS+MAX2DCHANNELS ); + + aChannel[nChannel].Stop(); +} + +void +cSampleManager::PreloadStreamedFile(uint8 nFile, uint8 nStream) +{ + char filename[256]; + + ASSERT( nStream < MAX_STREAMS ); + + if ( nFile < TOTAL_STREAMED_SOUNDS ) + { + if ( aStream[nStream] ) + { + delete aStream[nStream]; + aStream[nStream] = NULL; + } + + strcpy(filename, StreamedNameTable[nFile]); + + CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + ASSERT(stream != NULL); + + aStream[nStream] = stream; + if ( !stream->IsOpened() ) + { + delete stream; + aStream[nStream] = NULL; + } + } +} + +void +cSampleManager::PauseStream(uint8 nPauseFlag, uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + stream->SetPause(nPauseFlag != 0); + } +} + +void +cSampleManager::StartPreloadedStreamedFile(uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + if ( stream->Setup() ) + { + stream->Start(); + } + } +} + +bool +cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) +{ + char filename[256]; + + ASSERT( nStream < MAX_STREAMS ); + + if ( nFile < TOTAL_STREAMED_SOUNDS ) + { + if ( aStream[nStream] ) + { + delete aStream[nStream]; + aStream[nStream] = NULL; + } + + strcpy(filename, StreamedNameTable[nFile]); + + CStream *stream = new CStream(filename, ALStreamSources[nStream], ALStreamBuffers[nStream]); + ASSERT(stream != NULL); + + aStream[nStream] = stream; + + if ( stream->IsOpened() ) + { + nStreamLength[nFile] = stream->GetLength(); + if ( stream->Setup() ) + { + if ( nPos != 0 ) + stream->SetPos(nPos); + + stream->Start(); + } + + return true; + } + else + { + delete stream; + aStream[nStream] = NULL; + } + } + + return false; +} + +void +cSampleManager::StopStreamedFile(uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + delete stream; + aStream[nStream] = NULL; + } +} + +int32 +cSampleManager::GetStreamedFilePosition(uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + return stream->GetPos(); + } + + return 0; +} + +void +cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffectFlag, uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + if ( nVolume > MAX_VOLUME ) + nVolume = MAX_VOLUME; + + if ( nPan > MAX_VOLUME ) + nPan = MAX_VOLUME; + + nStreamVolume[nStream] = m_nMusicFadeVolume * nVolume; + nStreamPan [nStream] = nPan; + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + if ( nEffectFlag ) + stream->SetVolume(m_nEffectsFadeVolume*nVolume*m_nEffectsVolume >> 14); + else + stream->SetVolume(m_nMusicFadeVolume*nVolume*m_nMusicVolume >> 14); + + stream->SetPan(nPan); + } +} + +int32 +cSampleManager::GetStreamedFileLength(uint8 nStream) +{ + ASSERT( nStream < TOTAL_STREAMED_SOUNDS ); + + return nStreamLength[nStream]; +} + +bool +cSampleManager::IsStreamPlaying(uint8 nStream) +{ + ASSERT( nStream < MAX_STREAMS ); + + CStream *stream = aStream[nStream]; + + if ( stream ) + { + if ( stream->IsPlaying() ) + return true; + } + + return false; +} + +void +cSampleManager::Service(void) +{ + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + CStream *stream = aStream[i]; + + if ( stream ) + stream->Update(); + } + + UpdateSoundBuffers(); +} + +bool +cSampleManager::InitialiseSampleBanks(void) +{ + int32 nBank = SAMPLEBANK_MAIN; + + fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); + if ( fpSampleDescHandle == NULL ) + return false; + + fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); + if ( fpSampleDataHandle == NULL ) + { + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; + + return false; + } + + fseek(fpSampleDataHandle, 0, SEEK_END); + int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); + rewind(fpSampleDataHandle); + + fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); + + fclose(fpSampleDescHandle); + fpSampleDescHandle = NULL; + + for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) + { +#ifdef FIX_BUGS + if (nBank >= MAX_SAMPLEBANKS) break; +#endif + if ( BankStartOffset[nBank] == BankStartOffset[SAMPLEBANK_MAIN] + i ) + { + nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; + nBank++; + } + } + + nSampleBankSize[SAMPLEBANK_MAIN] = nSampleBankDiscStartOffset[SAMPLEBANK_PED] - nSampleBankDiscStartOffset[SAMPLEBANK_MAIN]; + nSampleBankSize[SAMPLEBANK_PED] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SAMPLEBANK_PED]; + + return true; +} + +#endif \ No newline at end of file diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 8633d222..8ab12e3f 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -220,22 +220,9 @@ bool CGame::InitialiseOnceAfterRW(void) if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 ) { CMenuManager::m_PrefsSpeakers = 0; - - for ( int32 i = 0; i < DMAudio.GetNum3DProvidersAvailable(); i++ ) - { - wchar buff[64]; - - char *name = DMAudio.Get3DProviderName(i); - AsciiToUnicode(name, buff); - char *providername = UnicodeToAscii(buff); - strupr(providername); - - if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") ) - { - FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = i; - break; - } - } + int8 provider = DMAudio.AutoDetect3DProviders(); + if ( provider != -1 ) + FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = provider; } DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex); diff --git a/src/core/config.h b/src/core/config.h index 163af701..23fe9993 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -193,7 +193,8 @@ enum Config { #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define USE_TXD_CDIMAGE // generate and load textures from txd.img //#define USE_TEXTURE_POOL -//#define OPENAL +#define AUDIO_OAL +//#define AUDIO_MSS // Particle //#define PC_PARTICLE diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 288788c0..20e5c49c 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1773,13 +1773,12 @@ WinMain(HINSTANCE instance, StaticPatcher::Apply(); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -/* + // TODO: make this an option somewhere AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); -*/ /* * Initialize the platform independent data. -- cgit v1.2.3 From 0abd0c659b39805a457896427980414cdc552ff8 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 4 May 2020 21:06:14 +0300 Subject: openal-soft added --- openal-soft/COPYING | 437 ++++++++++++++++++ openal-soft/dist/Win32/OpenAL32.dll | Bin 0 -> 2172928 bytes openal-soft/dist/Win64/OpenAL32.dll | Bin 0 -> 2137088 bytes openal-soft/include/AL/al.h | 656 ++++++++++++++++++++++++++ openal-soft/include/AL/alc.h | 237 ++++++++++ openal-soft/include/AL/alext.h | 537 ++++++++++++++++++++++ openal-soft/include/AL/efx-creative.h | 3 + openal-soft/include/AL/efx-presets.h | 402 ++++++++++++++++ openal-soft/include/AL/efx.h | 762 +++++++++++++++++++++++++++++++ openal-soft/libs/Win32/OpenAL32.def | 96 ++++ openal-soft/libs/Win32/OpenAL32.lib | Bin 0 -> 70242 bytes openal-soft/libs/Win32/libOpenAL32.dll.a | Bin 0 -> 60290 bytes openal-soft/libs/Win64/OpenAL32.def | 96 ++++ openal-soft/libs/Win64/OpenAL32.lib | Bin 0 -> 70616 bytes openal-soft/libs/Win64/libOpenAL32.dll.a | Bin 0 -> 58954 bytes openal-soft/readme.txt | 32 ++ src/audio/oal/oal_utils.cpp | 107 ++--- src/audio/sampman_oal.cpp | 10 +- src/core/config.h | 4 +- src/skel/win/win.cpp | 3 +- 20 files changed, 3317 insertions(+), 65 deletions(-) create mode 100644 openal-soft/COPYING create mode 100644 openal-soft/dist/Win32/OpenAL32.dll create mode 100644 openal-soft/dist/Win64/OpenAL32.dll create mode 100644 openal-soft/include/AL/al.h create mode 100644 openal-soft/include/AL/alc.h create mode 100644 openal-soft/include/AL/alext.h create mode 100644 openal-soft/include/AL/efx-creative.h create mode 100644 openal-soft/include/AL/efx-presets.h create mode 100644 openal-soft/include/AL/efx.h create mode 100644 openal-soft/libs/Win32/OpenAL32.def create mode 100644 openal-soft/libs/Win32/OpenAL32.lib create mode 100644 openal-soft/libs/Win32/libOpenAL32.dll.a create mode 100644 openal-soft/libs/Win64/OpenAL32.def create mode 100644 openal-soft/libs/Win64/OpenAL32.lib create mode 100644 openal-soft/libs/Win64/libOpenAL32.dll.a create mode 100644 openal-soft/readme.txt diff --git a/openal-soft/COPYING b/openal-soft/COPYING new file mode 100644 index 00000000..8d5d0000 --- /dev/null +++ b/openal-soft/COPYING @@ -0,0 +1,437 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/openal-soft/dist/Win32/OpenAL32.dll b/openal-soft/dist/Win32/OpenAL32.dll new file mode 100644 index 00000000..6fc789e5 Binary files /dev/null and b/openal-soft/dist/Win32/OpenAL32.dll differ diff --git a/openal-soft/dist/Win64/OpenAL32.dll b/openal-soft/dist/Win64/OpenAL32.dll new file mode 100644 index 00000000..3c631e3a Binary files /dev/null and b/openal-soft/dist/Win64/OpenAL32.dll differ diff --git a/openal-soft/include/AL/al.h b/openal-soft/include/AL/al.h new file mode 100644 index 00000000..413b3833 --- /dev/null +++ b/openal-soft/include/AL/al.h @@ -0,0 +1,656 @@ +#ifndef AL_AL_H +#define AL_AL_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef AL_API + #if defined(AL_LIBTYPE_STATIC) + #define AL_API + #elif defined(_WIN32) + #define AL_API __declspec(dllimport) + #else + #define AL_API extern + #endif +#endif + +#if defined(_WIN32) + #define AL_APIENTRY __cdecl +#else + #define AL_APIENTRY +#endif + + +/** Deprecated macro. */ +#define OPENAL +#define ALAPI AL_API +#define ALAPIENTRY AL_APIENTRY +#define AL_INVALID (-1) +#define AL_ILLEGAL_ENUM AL_INVALID_ENUM +#define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION + +/** Supported AL version. */ +#define AL_VERSION_1_0 +#define AL_VERSION_1_1 + +/** 8-bit boolean */ +typedef char ALboolean; + +/** character */ +typedef char ALchar; + +/** signed 8-bit 2's complement integer */ +typedef signed char ALbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALsizei; + +/** enumerated 32-bit value */ +typedef int ALenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALdouble; + +/** void type (for opaque pointers only) */ +typedef void ALvoid; + + +/* Enumerant values begin at column 50. No tabs. */ + +/** "no distance model" or "no buffer" */ +#define AL_NONE 0 + +/** Boolean False. */ +#define AL_FALSE 0 + +/** Boolean True. */ +#define AL_TRUE 1 + + +/** + * Relative source. + * Type: ALboolean + * Range: [AL_TRUE, AL_FALSE] + * Default: AL_FALSE + * + * Specifies if the Source has relative coordinates. + */ +#define AL_SOURCE_RELATIVE 0x202 + + +/** + * Inner cone angle, in degrees. + * Type: ALint, ALfloat + * Range: [0 - 360] + * Default: 360 + * + * The angle covered by the inner cone, where the source will not attenuate. + */ +#define AL_CONE_INNER_ANGLE 0x1001 + +/** + * Outer cone angle, in degrees. + * Range: [0 - 360] + * Default: 360 + * + * The angle covered by the outer cone, where the source will be fully + * attenuated. + */ +#define AL_CONE_OUTER_ANGLE 0x1002 + +/** + * Source pitch. + * Type: ALfloat + * Range: [0.5 - 2.0] + * Default: 1.0 + * + * A multiplier for the frequency (sample rate) of the source's buffer. + */ +#define AL_PITCH 0x1003 + +/** + * Source or listener position. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * The source or listener location in three dimensional space. + * + * OpenAL, like OpenGL, uses a right handed coordinate system, where in a + * frontal default view X (thumb) points right, Y points up (index finger), and + * Z points towards the viewer/camera (middle finger). + * + * To switch from a left handed coordinate system, flip the sign on the Z + * coordinate. + */ +#define AL_POSITION 0x1004 + +/** + * Source direction. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * Specifies the current direction in local space. + * A zero-length vector specifies an omni-directional source (cone is ignored). + */ +#define AL_DIRECTION 0x1005 + +/** + * Source or listener velocity. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * Specifies the current velocity in local space. + */ +#define AL_VELOCITY 0x1006 + +/** + * Source looping. + * Type: ALboolean + * Range: [AL_TRUE, AL_FALSE] + * Default: AL_FALSE + * + * Specifies whether source is looping. + */ +#define AL_LOOPING 0x1007 + +/** + * Source buffer. + * Type: ALuint + * Range: any valid Buffer. + * + * Specifies the buffer to provide sound samples. + */ +#define AL_BUFFER 0x1009 + +/** + * Source or listener gain. + * Type: ALfloat + * Range: [0.0 - ] + * + * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation + * of about -6dB. Each multiplicaton by 2 equals an amplification of about + * +6dB. + * + * A value of 0.0 is meaningless with respect to a logarithmic scale; it is + * silent. + */ +#define AL_GAIN 0x100A + +/** + * Minimum source gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * The minimum gain allowed for a source, after distance and cone attenation is + * applied (if applicable). + */ +#define AL_MIN_GAIN 0x100D + +/** + * Maximum source gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * The maximum gain allowed for a source, after distance and cone attenation is + * applied (if applicable). + */ +#define AL_MAX_GAIN 0x100E + +/** + * Listener orientation. + * Type: ALfloat[6] + * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0} + * + * Effectively two three dimensional vectors. The first vector is the front (or + * "at") and the second is the top (or "up"). + * + * Both vectors are in local space. + */ +#define AL_ORIENTATION 0x100F + +/** + * Source state (query only). + * Type: ALint + * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED] + */ +#define AL_SOURCE_STATE 0x1010 + +/** Source state value. */ +#define AL_INITIAL 0x1011 +#define AL_PLAYING 0x1012 +#define AL_PAUSED 0x1013 +#define AL_STOPPED 0x1014 + +/** + * Source Buffer Queue size (query only). + * Type: ALint + * + * The number of buffers queued using alSourceQueueBuffers, minus the buffers + * removed with alSourceUnqueueBuffers. + */ +#define AL_BUFFERS_QUEUED 0x1015 + +/** + * Source Buffer Queue processed count (query only). + * Type: ALint + * + * The number of queued buffers that have been fully processed, and can be + * removed with alSourceUnqueueBuffers. + * + * Looping sources will never fully process buffers because they will be set to + * play again for when the source loops. + */ +#define AL_BUFFERS_PROCESSED 0x1016 + +/** + * Source reference distance. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * The distance in units that no attenuation occurs. + * + * At 0.0, no distance attenuation ever occurs on non-linear attenuation models. + */ +#define AL_REFERENCE_DISTANCE 0x1020 + +/** + * Source rolloff factor. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * Multiplier to exaggerate or diminish distance attenuation. + * + * At 0.0, no distance attenuation ever occurs. + */ +#define AL_ROLLOFF_FACTOR 0x1021 + +/** + * Outer cone gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * Default: 0.0 + * + * The gain attenuation applied when the listener is outside of the source's + * outer cone. + */ +#define AL_CONE_OUTER_GAIN 0x1022 + +/** + * Source maximum distance. + * Type: ALfloat + * Range: [0.0 - ] + * Default: +inf + * + * The distance above which the source is not attenuated any further with a + * clamped distance model, or where attenuation reaches 0.0 gain for linear + * distance models with a default rolloff factor. + */ +#define AL_MAX_DISTANCE 0x1023 + +/** Source buffer position, in seconds */ +#define AL_SEC_OFFSET 0x1024 +/** Source buffer position, in sample frames */ +#define AL_SAMPLE_OFFSET 0x1025 +/** Source buffer position, in bytes */ +#define AL_BYTE_OFFSET 0x1026 + +/** + * Source type (query only). + * Type: ALint + * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED] + * + * A Source is Static if a Buffer has been attached using AL_BUFFER. + * + * A Source is Streaming if one or more Buffers have been attached using + * alSourceQueueBuffers. + * + * A Source is Undetermined when it has the NULL buffer attached using + * AL_BUFFER. + */ +#define AL_SOURCE_TYPE 0x1027 + +/** Source type value. */ +#define AL_STATIC 0x1028 +#define AL_STREAMING 0x1029 +#define AL_UNDETERMINED 0x1030 + +/** Buffer format specifier. */ +#define AL_FORMAT_MONO8 0x1100 +#define AL_FORMAT_MONO16 0x1101 +#define AL_FORMAT_STEREO8 0x1102 +#define AL_FORMAT_STEREO16 0x1103 + +/** Buffer frequency (query only). */ +#define AL_FREQUENCY 0x2001 +/** Buffer bits per sample (query only). */ +#define AL_BITS 0x2002 +/** Buffer channel count (query only). */ +#define AL_CHANNELS 0x2003 +/** Buffer data size (query only). */ +#define AL_SIZE 0x2004 + +/** + * Buffer state. + * + * Not for public use. + */ +#define AL_UNUSED 0x2010 +#define AL_PENDING 0x2011 +#define AL_PROCESSED 0x2012 + + +/** No error. */ +#define AL_NO_ERROR 0 + +/** Invalid name paramater passed to AL call. */ +#define AL_INVALID_NAME 0xA001 + +/** Invalid enum parameter passed to AL call. */ +#define AL_INVALID_ENUM 0xA002 + +/** Invalid value parameter passed to AL call. */ +#define AL_INVALID_VALUE 0xA003 + +/** Illegal AL call. */ +#define AL_INVALID_OPERATION 0xA004 + +/** Not enough memory. */ +#define AL_OUT_OF_MEMORY 0xA005 + + +/** Context string: Vendor ID. */ +#define AL_VENDOR 0xB001 +/** Context string: Version. */ +#define AL_VERSION 0xB002 +/** Context string: Renderer ID. */ +#define AL_RENDERER 0xB003 +/** Context string: Space-separated extension list. */ +#define AL_EXTENSIONS 0xB004 + + +/** + * Doppler scale. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * Scale for source and listener velocities. + */ +#define AL_DOPPLER_FACTOR 0xC000 +AL_API void AL_APIENTRY alDopplerFactor(ALfloat value); + +/** + * Doppler velocity (deprecated). + * + * A multiplier applied to the Speed of Sound. + */ +#define AL_DOPPLER_VELOCITY 0xC001 +AL_API void AL_APIENTRY alDopplerVelocity(ALfloat value); + +/** + * Speed of Sound, in units per second. + * Type: ALfloat + * Range: [0.0001 - ] + * Default: 343.3 + * + * The speed at which sound waves are assumed to travel, when calculating the + * doppler effect. + */ +#define AL_SPEED_OF_SOUND 0xC003 +AL_API void AL_APIENTRY alSpeedOfSound(ALfloat value); + +/** + * Distance attenuation model. + * Type: ALint + * Range: [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, + * AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, + * AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED] + * Default: AL_INVERSE_DISTANCE_CLAMPED + * + * The model by which sources attenuate with distance. + * + * None - No distance attenuation. + * Inverse - Doubling the distance halves the source gain. + * Linear - Linear gain scaling between the reference and max distances. + * Exponent - Exponential gain dropoff. + * + * Clamped variations work like the non-clamped counterparts, except the + * distance calculated is clamped between the reference and max distances. + */ +#define AL_DISTANCE_MODEL 0xD000 +AL_API void AL_APIENTRY alDistanceModel(ALenum distanceModel); + +/** Distance model value. */ +#define AL_INVERSE_DISTANCE 0xD001 +#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 +#define AL_LINEAR_DISTANCE 0xD003 +#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 +#define AL_EXPONENT_DISTANCE 0xD005 +#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 + +/** Renderer State management. */ +AL_API void AL_APIENTRY alEnable(ALenum capability); +AL_API void AL_APIENTRY alDisable(ALenum capability); +AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability); + +/** State retrieval. */ +AL_API const ALchar* AL_APIENTRY alGetString(ALenum param); +AL_API void AL_APIENTRY alGetBooleanv(ALenum param, ALboolean *values); +AL_API void AL_APIENTRY alGetIntegerv(ALenum param, ALint *values); +AL_API void AL_APIENTRY alGetFloatv(ALenum param, ALfloat *values); +AL_API void AL_APIENTRY alGetDoublev(ALenum param, ALdouble *values); +AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum param); +AL_API ALint AL_APIENTRY alGetInteger(ALenum param); +AL_API ALfloat AL_APIENTRY alGetFloat(ALenum param); +AL_API ALdouble AL_APIENTRY alGetDouble(ALenum param); + +/** + * Error retrieval. + * + * Obtain the first error generated in the AL context since the last check. + */ +AL_API ALenum AL_APIENTRY alGetError(void); + +/** + * Extension support. + * + * Query for the presence of an extension, and obtain any appropriate function + * pointers and enum values. + */ +AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extname); +AL_API void* AL_APIENTRY alGetProcAddress(const ALchar *fname); +AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *ename); + + +/** Set Listener parameters */ +AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value); +AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values); +AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value); +AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3); +AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values); + +/** Get Listener parameters */ +AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value); +AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values); +AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value); +AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3); +AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values); + + +/** Create Source objects. */ +AL_API void AL_APIENTRY alGenSources(ALsizei n, ALuint *sources); +/** Delete Source objects. */ +AL_API void AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources); +/** Verify a handle is a valid Source. */ +AL_API ALboolean AL_APIENTRY alIsSource(ALuint source); + +/** Set Source parameters. */ +AL_API void AL_APIENTRY alSourcef(ALuint source, ALenum param, ALfloat value); +AL_API void AL_APIENTRY alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +AL_API void AL_APIENTRY alSourcefv(ALuint source, ALenum param, const ALfloat *values); +AL_API void AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value); +AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); +AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum param, const ALint *values); + +/** Get Source parameters. */ +AL_API void AL_APIENTRY alGetSourcef(ALuint source, ALenum param, ALfloat *value); +AL_API void AL_APIENTRY alGetSource3f(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +AL_API void AL_APIENTRY alGetSourcefv(ALuint source, ALenum param, ALfloat *values); +AL_API void AL_APIENTRY alGetSourcei(ALuint source, ALenum param, ALint *value); +AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); +AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum param, ALint *values); + + +/** Play, replay, or resume (if paused) a list of Sources */ +AL_API void AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources); +/** Stop a list of Sources */ +AL_API void AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources); +/** Rewind a list of Sources */ +AL_API void AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources); +/** Pause a list of Sources */ +AL_API void AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources); + +/** Play, replay, or resume a Source */ +AL_API void AL_APIENTRY alSourcePlay(ALuint source); +/** Stop a Source */ +AL_API void AL_APIENTRY alSourceStop(ALuint source); +/** Rewind a Source (set playback postiton to beginning) */ +AL_API void AL_APIENTRY alSourceRewind(ALuint source); +/** Pause a Source */ +AL_API void AL_APIENTRY alSourcePause(ALuint source); + +/** Queue buffers onto a source */ +AL_API void AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint *buffers); +/** Unqueue processed buffers from a source */ +AL_API void AL_APIENTRY alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint *buffers); + + +/** Create Buffer objects */ +AL_API void AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers); +/** Delete Buffer objects */ +AL_API void AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers); +/** Verify a handle is a valid Buffer */ +AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer); + +/** Specifies the data to be copied into a buffer */ +AL_API void AL_APIENTRY alBufferData(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); + +/** Set Buffer parameters, */ +AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum param, ALfloat value); +AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum param, const ALfloat *values); +AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum param, ALint value); +AL_API void AL_APIENTRY alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); +AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum param, const ALint *values); + +/** Get Buffer parameters. */ +AL_API void AL_APIENTRY alGetBufferf(ALuint buffer, ALenum param, ALfloat *value); +AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum param, ALfloat *values); +AL_API void AL_APIENTRY alGetBufferi(ALuint buffer, ALenum param, ALint *value); +AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); +AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum param, ALint *values); + +/** Pointer-to-function type, useful for dynamically getting AL entry points. */ +typedef void (AL_APIENTRY *LPALENABLE)(ALenum capability); +typedef void (AL_APIENTRY *LPALDISABLE)(ALenum capability); +typedef ALboolean (AL_APIENTRY *LPALISENABLED)(ALenum capability); +typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)(ALenum param); +typedef void (AL_APIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *values); +typedef void (AL_APIENTRY *LPALGETINTEGERV)(ALenum param, ALint *values); +typedef void (AL_APIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *values); +typedef void (AL_APIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *values); +typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)(ALenum param); +typedef ALint (AL_APIENTRY *LPALGETINTEGER)(ALenum param); +typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)(ALenum param); +typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)(ALenum param); +typedef ALenum (AL_APIENTRY *LPALGETERROR)(void); +typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname); +typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)(const ALchar *fname); +typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)(const ALchar *ename); +typedef void (AL_APIENTRY *LPALLISTENERF)(ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +typedef void (AL_APIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values); +typedef void (AL_APIENTRY *LPALLISTENERI)(ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALLISTENER3I)(ALenum param, ALint value1, ALint value2, ALint value3); +typedef void (AL_APIENTRY *LPALLISTENERIV)(ALenum param, const ALint *values); +typedef void (AL_APIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value); +typedef void (AL_APIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +typedef void (AL_APIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values); +typedef void (AL_APIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value); +typedef void (AL_APIENTRY *LPALGETLISTENER3I)(ALenum param, ALint *value1, ALint *value2, ALint *value3); +typedef void (AL_APIENTRY *LPALGETLISTENERIV)(ALenum param, ALint *values); +typedef void (AL_APIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources); +typedef void (AL_APIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources); +typedef ALboolean (AL_APIENTRY *LPALISSOURCE)(ALuint source); +typedef void (AL_APIENTRY *LPALSOURCEF)(ALuint source, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALSOURCE3F)(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +typedef void (AL_APIENTRY *LPALSOURCEFV)(ALuint source, ALenum param, const ALfloat *values); +typedef void (AL_APIENTRY *LPALSOURCEI)(ALuint source, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALSOURCE3I)(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); +typedef void (AL_APIENTRY *LPALSOURCEIV)(ALuint source, ALenum param, const ALint *values); +typedef void (AL_APIENTRY *LPALGETSOURCEF)(ALuint source, ALenum param, ALfloat *value); +typedef void (AL_APIENTRY *LPALGETSOURCE3F)(ALuint source, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +typedef void (AL_APIENTRY *LPALGETSOURCEFV)(ALuint source, ALenum param, ALfloat *values); +typedef void (AL_APIENTRY *LPALGETSOURCEI)(ALuint source, ALenum param, ALint *value); +typedef void (AL_APIENTRY *LPALGETSOURCE3I)(ALuint source, ALenum param, ALint *value1, ALint *value2, ALint *value3); +typedef void (AL_APIENTRY *LPALGETSOURCEIV)(ALuint source, ALenum param, ALint *values); +typedef void (AL_APIENTRY *LPALSOURCEPLAYV)(ALsizei n, const ALuint *sources); +typedef void (AL_APIENTRY *LPALSOURCESTOPV)(ALsizei n, const ALuint *sources); +typedef void (AL_APIENTRY *LPALSOURCEREWINDV)(ALsizei n, const ALuint *sources); +typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)(ALsizei n, const ALuint *sources); +typedef void (AL_APIENTRY *LPALSOURCEPLAY)(ALuint source); +typedef void (AL_APIENTRY *LPALSOURCESTOP)(ALuint source); +typedef void (AL_APIENTRY *LPALSOURCEREWIND)(ALuint source); +typedef void (AL_APIENTRY *LPALSOURCEPAUSE)(ALuint source); +typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint source, ALsizei nb, const ALuint *buffers); +typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint source, ALsizei nb, ALuint *buffers); +typedef void (AL_APIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers); +typedef void (AL_APIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers); +typedef ALboolean (AL_APIENTRY *LPALISBUFFER)(ALuint buffer); +typedef void (AL_APIENTRY *LPALBUFFERDATA)(ALuint buffer, ALenum format, const ALvoid *data, ALsizei size, ALsizei freq); +typedef void (AL_APIENTRY *LPALBUFFERF)(ALuint buffer, ALenum param, ALfloat value); +typedef void (AL_APIENTRY *LPALBUFFER3F)(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); +typedef void (AL_APIENTRY *LPALBUFFERFV)(ALuint buffer, ALenum param, const ALfloat *values); +typedef void (AL_APIENTRY *LPALBUFFERI)(ALuint buffer, ALenum param, ALint value); +typedef void (AL_APIENTRY *LPALBUFFER3I)(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); +typedef void (AL_APIENTRY *LPALBUFFERIV)(ALuint buffer, ALenum param, const ALint *values); +typedef void (AL_APIENTRY *LPALGETBUFFERF)(ALuint buffer, ALenum param, ALfloat *value); +typedef void (AL_APIENTRY *LPALGETBUFFER3F)(ALuint buffer, ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3); +typedef void (AL_APIENTRY *LPALGETBUFFERFV)(ALuint buffer, ALenum param, ALfloat *values); +typedef void (AL_APIENTRY *LPALGETBUFFERI)(ALuint buffer, ALenum param, ALint *value); +typedef void (AL_APIENTRY *LPALGETBUFFER3I)(ALuint buffer, ALenum param, ALint *value1, ALint *value2, ALint *value3); +typedef void (AL_APIENTRY *LPALGETBUFFERIV)(ALuint buffer, ALenum param, ALint *values); +typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)(ALfloat value); +typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)(ALfloat value); +typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)(ALfloat value); +typedef void (AL_APIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel); + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +#endif /* AL_AL_H */ diff --git a/openal-soft/include/AL/alc.h b/openal-soft/include/AL/alc.h new file mode 100644 index 00000000..5786bad2 --- /dev/null +++ b/openal-soft/include/AL/alc.h @@ -0,0 +1,237 @@ +#ifndef AL_ALC_H +#define AL_ALC_H + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef ALC_API + #if defined(AL_LIBTYPE_STATIC) + #define ALC_API + #elif defined(_WIN32) + #define ALC_API __declspec(dllimport) + #else + #define ALC_API extern + #endif +#endif + +#if defined(_WIN32) + #define ALC_APIENTRY __cdecl +#else + #define ALC_APIENTRY +#endif + + +/** Deprecated macro. */ +#define ALCAPI ALC_API +#define ALCAPIENTRY ALC_APIENTRY +#define ALC_INVALID 0 + +/** Supported ALC version? */ +#define ALC_VERSION_0_1 1 + +/** Opaque device handle */ +typedef struct ALCdevice ALCdevice; +/** Opaque context handle */ +typedef struct ALCcontext ALCcontext; + +/** 8-bit boolean */ +typedef char ALCboolean; + +/** character */ +typedef char ALCchar; + +/** signed 8-bit 2's complement integer */ +typedef signed char ALCbyte; + +/** unsigned 8-bit integer */ +typedef unsigned char ALCubyte; + +/** signed 16-bit 2's complement integer */ +typedef short ALCshort; + +/** unsigned 16-bit integer */ +typedef unsigned short ALCushort; + +/** signed 32-bit 2's complement integer */ +typedef int ALCint; + +/** unsigned 32-bit integer */ +typedef unsigned int ALCuint; + +/** non-negative 32-bit binary integer size */ +typedef int ALCsizei; + +/** enumerated 32-bit value */ +typedef int ALCenum; + +/** 32-bit IEEE754 floating-point */ +typedef float ALCfloat; + +/** 64-bit IEEE754 floating-point */ +typedef double ALCdouble; + +/** void type (for opaque pointers only) */ +typedef void ALCvoid; + + +/* Enumerant values begin at column 50. No tabs. */ + +/** Boolean False. */ +#define ALC_FALSE 0 + +/** Boolean True. */ +#define ALC_TRUE 1 + +/** Context attribute: Hz. */ +#define ALC_FREQUENCY 0x1007 + +/** Context attribute: Hz. */ +#define ALC_REFRESH 0x1008 + +/** Context attribute: AL_TRUE or AL_FALSE. */ +#define ALC_SYNC 0x1009 + +/** Context attribute: requested Mono (3D) Sources. */ +#define ALC_MONO_SOURCES 0x1010 + +/** Context attribute: requested Stereo Sources. */ +#define ALC_STEREO_SOURCES 0x1011 + +/** No error. */ +#define ALC_NO_ERROR 0 + +/** Invalid device handle. */ +#define ALC_INVALID_DEVICE 0xA001 + +/** Invalid context handle. */ +#define ALC_INVALID_CONTEXT 0xA002 + +/** Invalid enum parameter passed to an ALC call. */ +#define ALC_INVALID_ENUM 0xA003 + +/** Invalid value parameter passed to an ALC call. */ +#define ALC_INVALID_VALUE 0xA004 + +/** Out of memory. */ +#define ALC_OUT_OF_MEMORY 0xA005 + + +/** Runtime ALC version. */ +#define ALC_MAJOR_VERSION 0x1000 +#define ALC_MINOR_VERSION 0x1001 + +/** Context attribute list properties. */ +#define ALC_ATTRIBUTES_SIZE 0x1002 +#define ALC_ALL_ATTRIBUTES 0x1003 + +/** String for the default device specifier. */ +#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 +/** + * String for the given device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known device specifiers (list ends with an empty string). + */ +#define ALC_DEVICE_SPECIFIER 0x1005 +/** String for space-separated list of ALC extensions. */ +#define ALC_EXTENSIONS 0x1006 + + +/** Capture extension */ +#define ALC_EXT_CAPTURE 1 +/** + * String for the given capture device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known capture device specifiers (list ends with an empty string). + */ +#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 +/** String for the default capture device specifier. */ +#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 +/** Number of sample frames available for capture. */ +#define ALC_CAPTURE_SAMPLES 0x312 + + +/** Enumerate All extension */ +#define ALC_ENUMERATE_ALL_EXT 1 +/** String for the default extended device specifier. */ +#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 +/** + * String for the given extended device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known extended device specifiers (list ends with an empty string). + */ +#define ALC_ALL_DEVICES_SPECIFIER 0x1013 + + +/** Context management. */ +ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist); +ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context); +ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context); +ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context); +ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context); +ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void); +ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context); + +/** Device management. */ +ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename); +ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device); + + +/** + * Error support. + * + * Obtain the most recent Device error. + */ +ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device); + +/** + * Extension support. + * + * Query for the presence of an extension, and obtain any appropriate + * function pointers and enum values. + */ +ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname); +ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname); +ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname); + +/** Query function. */ +ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param); +ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); + +/** Capture function. */ +ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); +ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device); +ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device); +ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device); +ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); + +/** Pointer-to-function type, useful for dynamically getting ALC entry points. */ +typedef ALCcontext* (ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); +typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context); +typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context); +typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); +typedef ALCcontext* (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)(void); +typedef ALCdevice* (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context); +typedef ALCdevice* (ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); +typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); +typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)(ALCdevice *device); +typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname); +typedef void* (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname); +typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname); +typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); +typedef void (ALC_APIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values); +typedef ALCdevice* (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); +typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)(ALCdevice *device); +typedef void (ALC_APIENTRY *LPALCCAPTURESTART)(ALCdevice *device); +typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)(ALCdevice *device); +typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); + +#if defined(__cplusplus) +} +#endif + +#endif /* AL_ALC_H */ diff --git a/openal-soft/include/AL/alext.h b/openal-soft/include/AL/alext.h new file mode 100644 index 00000000..bfc7c104 --- /dev/null +++ b/openal-soft/include/AL/alext.h @@ -0,0 +1,537 @@ +/** + * OpenAL cross platform audio library + * Copyright (C) 2008 by authors. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * Or go to http://www.gnu.org/copyleft/lgpl.html + */ + +#ifndef AL_ALEXT_H +#define AL_ALEXT_H + +#include +/* Define int64_t and uint64_t types */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif + +#include "alc.h" +#include "al.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef AL_LOKI_IMA_ADPCM_format +#define AL_LOKI_IMA_ADPCM_format 1 +#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 +#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001 +#endif + +#ifndef AL_LOKI_WAVE_format +#define AL_LOKI_WAVE_format 1 +#define AL_FORMAT_WAVE_EXT 0x10002 +#endif + +#ifndef AL_EXT_vorbis +#define AL_EXT_vorbis 1 +#define AL_FORMAT_VORBIS_EXT 0x10003 +#endif + +#ifndef AL_LOKI_quadriphonic +#define AL_LOKI_quadriphonic 1 +#define AL_FORMAT_QUAD8_LOKI 0x10004 +#define AL_FORMAT_QUAD16_LOKI 0x10005 +#endif + +#ifndef AL_EXT_float32 +#define AL_EXT_float32 1 +#define AL_FORMAT_MONO_FLOAT32 0x10010 +#define AL_FORMAT_STEREO_FLOAT32 0x10011 +#endif + +#ifndef AL_EXT_double +#define AL_EXT_double 1 +#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012 +#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013 +#endif + +#ifndef AL_EXT_MULAW +#define AL_EXT_MULAW 1 +#define AL_FORMAT_MONO_MULAW_EXT 0x10014 +#define AL_FORMAT_STEREO_MULAW_EXT 0x10015 +#endif + +#ifndef AL_EXT_ALAW +#define AL_EXT_ALAW 1 +#define AL_FORMAT_MONO_ALAW_EXT 0x10016 +#define AL_FORMAT_STEREO_ALAW_EXT 0x10017 +#endif + +#ifndef ALC_LOKI_audio_channel +#define ALC_LOKI_audio_channel 1 +#define ALC_CHAN_MAIN_LOKI 0x500001 +#define ALC_CHAN_PCM_LOKI 0x500002 +#define ALC_CHAN_CD_LOKI 0x500003 +#endif + +#ifndef AL_EXT_MCFORMATS +#define AL_EXT_MCFORMATS 1 +/* Provides support for surround sound buffer formats with 8, 16, and 32-bit + * samples. + * + * QUAD8: Unsigned 8-bit, Quadraphonic (Front Left, Front Right, Rear Left, + * Rear Right). + * QUAD16: Signed 16-bit, Quadraphonic. + * QUAD32: 32-bit float, Quadraphonic. + * REAR8: Unsigned 8-bit, Rear Stereo (Rear Left, Rear Right). + * REAR16: Signed 16-bit, Rear Stereo. + * REAR32: 32-bit float, Rear Stereo. + * 51CHN8: Unsigned 8-bit, 5.1 Surround (Front Left, Front Right, Front Center, + * LFE, Side Left, Side Right). Note that some audio systems may label + * 5.1's Side channels as Rear or Surround; they are equivalent for the + * purposes of this extension. + * 51CHN16: Signed 16-bit, 5.1 Surround. + * 51CHN32: 32-bit float, 5.1 Surround. + * 61CHN8: Unsigned 8-bit, 6.1 Surround (Front Left, Front Right, Front Center, + * LFE, Rear Center, Side Left, Side Right). + * 61CHN16: Signed 16-bit, 6.1 Surround. + * 61CHN32: 32-bit float, 6.1 Surround. + * 71CHN8: Unsigned 8-bit, 7.1 Surround (Front Left, Front Right, Front Center, + * LFE, Rear Left, Rear Right, Side Left, Side Right). + * 71CHN16: Signed 16-bit, 7.1 Surround. + * 71CHN32: 32-bit float, 7.1 Surround. + */ +#define AL_FORMAT_QUAD8 0x1204 +#define AL_FORMAT_QUAD16 0x1205 +#define AL_FORMAT_QUAD32 0x1206 +#define AL_FORMAT_REAR8 0x1207 +#define AL_FORMAT_REAR16 0x1208 +#define AL_FORMAT_REAR32 0x1209 +#define AL_FORMAT_51CHN8 0x120A +#define AL_FORMAT_51CHN16 0x120B +#define AL_FORMAT_51CHN32 0x120C +#define AL_FORMAT_61CHN8 0x120D +#define AL_FORMAT_61CHN16 0x120E +#define AL_FORMAT_61CHN32 0x120F +#define AL_FORMAT_71CHN8 0x1210 +#define AL_FORMAT_71CHN16 0x1211 +#define AL_FORMAT_71CHN32 0x1212 +#endif + +#ifndef AL_EXT_MULAW_MCFORMATS +#define AL_EXT_MULAW_MCFORMATS 1 +#define AL_FORMAT_MONO_MULAW 0x10014 +#define AL_FORMAT_STEREO_MULAW 0x10015 +#define AL_FORMAT_QUAD_MULAW 0x10021 +#define AL_FORMAT_REAR_MULAW 0x10022 +#define AL_FORMAT_51CHN_MULAW 0x10023 +#define AL_FORMAT_61CHN_MULAW 0x10024 +#define AL_FORMAT_71CHN_MULAW 0x10025 +#endif + +#ifndef AL_EXT_IMA4 +#define AL_EXT_IMA4 1 +#define AL_FORMAT_MONO_IMA4 0x1300 +#define AL_FORMAT_STEREO_IMA4 0x1301 +#endif + +#ifndef AL_EXT_STATIC_BUFFER +#define AL_EXT_STATIC_BUFFER 1 +typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); +#ifdef AL_ALEXT_PROTOTYPES +AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); +#endif +#endif + +#ifndef ALC_EXT_EFX +#define ALC_EXT_EFX 1 +#include "efx.h" +#endif + +#ifndef ALC_EXT_disconnect +#define ALC_EXT_disconnect 1 +#define ALC_CONNECTED 0x313 +#endif + +#ifndef ALC_EXT_thread_local_context +#define ALC_EXT_thread_local_context 1 +typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); +typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); +ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); +#endif +#endif + +#ifndef AL_EXT_source_distance_model +#define AL_EXT_source_distance_model 1 +#define AL_SOURCE_DISTANCE_MODEL 0x200 +#endif + +#ifndef AL_SOFT_buffer_sub_data +#define AL_SOFT_buffer_sub_data 1 +#define AL_BYTE_RW_OFFSETS_SOFT 0x1031 +#define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 +typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); +#ifdef AL_ALEXT_PROTOTYPES +AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); +#endif +#endif + +#ifndef AL_SOFT_loop_points +#define AL_SOFT_loop_points 1 +#define AL_LOOP_POINTS_SOFT 0x2015 +#endif + +#ifndef AL_EXT_FOLDBACK +#define AL_EXT_FOLDBACK 1 +#define AL_EXT_FOLDBACK_NAME "AL_EXT_FOLDBACK" +#define AL_FOLDBACK_EVENT_BLOCK 0x4112 +#define AL_FOLDBACK_EVENT_START 0x4111 +#define AL_FOLDBACK_EVENT_STOP 0x4113 +#define AL_FOLDBACK_MODE_MONO 0x4101 +#define AL_FOLDBACK_MODE_STEREO 0x4102 +typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); +typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); +typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); +AL_API void AL_APIENTRY alRequestFoldbackStop(void); +#endif +#endif + +#ifndef ALC_EXT_DEDICATED +#define ALC_EXT_DEDICATED 1 +#define AL_DEDICATED_GAIN 0x0001 +#define AL_EFFECT_DEDICATED_DIALOGUE 0x9001 +#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000 +#endif + +#ifndef AL_SOFT_buffer_samples +#define AL_SOFT_buffer_samples 1 +/* Channel configurations */ +#define AL_MONO_SOFT 0x1500 +#define AL_STEREO_SOFT 0x1501 +#define AL_REAR_SOFT 0x1502 +#define AL_QUAD_SOFT 0x1503 +#define AL_5POINT1_SOFT 0x1504 +#define AL_6POINT1_SOFT 0x1505 +#define AL_7POINT1_SOFT 0x1506 + +/* Sample types */ +#define AL_BYTE_SOFT 0x1400 +#define AL_UNSIGNED_BYTE_SOFT 0x1401 +#define AL_SHORT_SOFT 0x1402 +#define AL_UNSIGNED_SHORT_SOFT 0x1403 +#define AL_INT_SOFT 0x1404 +#define AL_UNSIGNED_INT_SOFT 0x1405 +#define AL_FLOAT_SOFT 0x1406 +#define AL_DOUBLE_SOFT 0x1407 +#define AL_BYTE3_SOFT 0x1408 +#define AL_UNSIGNED_BYTE3_SOFT 0x1409 + +/* Storage formats */ +#define AL_MONO8_SOFT 0x1100 +#define AL_MONO16_SOFT 0x1101 +#define AL_MONO32F_SOFT 0x10010 +#define AL_STEREO8_SOFT 0x1102 +#define AL_STEREO16_SOFT 0x1103 +#define AL_STEREO32F_SOFT 0x10011 +#define AL_QUAD8_SOFT 0x1204 +#define AL_QUAD16_SOFT 0x1205 +#define AL_QUAD32F_SOFT 0x1206 +#define AL_REAR8_SOFT 0x1207 +#define AL_REAR16_SOFT 0x1208 +#define AL_REAR32F_SOFT 0x1209 +#define AL_5POINT1_8_SOFT 0x120A +#define AL_5POINT1_16_SOFT 0x120B +#define AL_5POINT1_32F_SOFT 0x120C +#define AL_6POINT1_8_SOFT 0x120D +#define AL_6POINT1_16_SOFT 0x120E +#define AL_6POINT1_32F_SOFT 0x120F +#define AL_7POINT1_8_SOFT 0x1210 +#define AL_7POINT1_16_SOFT 0x1211 +#define AL_7POINT1_32F_SOFT 0x1212 + +/* Buffer attributes */ +#define AL_INTERNAL_FORMAT_SOFT 0x2008 +#define AL_BYTE_LENGTH_SOFT 0x2009 +#define AL_SAMPLE_LENGTH_SOFT 0x200A +#define AL_SEC_LENGTH_SOFT 0x200B + +typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); +typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); +typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); +typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); +AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); +AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); +AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); +#endif +#endif + +#ifndef AL_SOFT_direct_channels +#define AL_SOFT_direct_channels 1 +#define AL_DIRECT_CHANNELS_SOFT 0x1033 +#endif + +#ifndef ALC_SOFT_loopback +#define ALC_SOFT_loopback 1 +#define ALC_FORMAT_CHANNELS_SOFT 0x1990 +#define ALC_FORMAT_TYPE_SOFT 0x1991 + +/* Sample types */ +#define ALC_BYTE_SOFT 0x1400 +#define ALC_UNSIGNED_BYTE_SOFT 0x1401 +#define ALC_SHORT_SOFT 0x1402 +#define ALC_UNSIGNED_SHORT_SOFT 0x1403 +#define ALC_INT_SOFT 0x1404 +#define ALC_UNSIGNED_INT_SOFT 0x1405 +#define ALC_FLOAT_SOFT 0x1406 + +/* Channel configurations */ +#define ALC_MONO_SOFT 0x1500 +#define ALC_STEREO_SOFT 0x1501 +#define ALC_QUAD_SOFT 0x1503 +#define ALC_5POINT1_SOFT 0x1504 +#define ALC_6POINT1_SOFT 0x1505 +#define ALC_7POINT1_SOFT 0x1506 + +typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); +typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); +typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); +ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); +ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); +#endif +#endif + +#ifndef AL_EXT_STEREO_ANGLES +#define AL_EXT_STEREO_ANGLES 1 +#define AL_STEREO_ANGLES 0x1030 +#endif + +#ifndef AL_EXT_SOURCE_RADIUS +#define AL_EXT_SOURCE_RADIUS 1 +#define AL_SOURCE_RADIUS 0x1031 +#endif + +#ifndef AL_SOFT_source_latency +#define AL_SOFT_source_latency 1 +#define AL_SAMPLE_OFFSET_LATENCY_SOFT 0x1200 +#define AL_SEC_OFFSET_LATENCY_SOFT 0x1201 +typedef int64_t ALint64SOFT; +typedef uint64_t ALuint64SOFT; +typedef void (AL_APIENTRY*LPALSOURCEDSOFT)(ALuint,ALenum,ALdouble); +typedef void (AL_APIENTRY*LPALSOURCE3DSOFT)(ALuint,ALenum,ALdouble,ALdouble,ALdouble); +typedef void (AL_APIENTRY*LPALSOURCEDVSOFT)(ALuint,ALenum,const ALdouble*); +typedef void (AL_APIENTRY*LPALGETSOURCEDSOFT)(ALuint,ALenum,ALdouble*); +typedef void (AL_APIENTRY*LPALGETSOURCE3DSOFT)(ALuint,ALenum,ALdouble*,ALdouble*,ALdouble*); +typedef void (AL_APIENTRY*LPALGETSOURCEDVSOFT)(ALuint,ALenum,ALdouble*); +typedef void (AL_APIENTRY*LPALSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT); +typedef void (AL_APIENTRY*LPALSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT,ALint64SOFT,ALint64SOFT); +typedef void (AL_APIENTRY*LPALSOURCEI64VSOFT)(ALuint,ALenum,const ALint64SOFT*); +typedef void (AL_APIENTRY*LPALGETSOURCEI64SOFT)(ALuint,ALenum,ALint64SOFT*); +typedef void (AL_APIENTRY*LPALGETSOURCE3I64SOFT)(ALuint,ALenum,ALint64SOFT*,ALint64SOFT*,ALint64SOFT*); +typedef void (AL_APIENTRY*LPALGETSOURCEI64VSOFT)(ALuint,ALenum,ALint64SOFT*); +#ifdef AL_ALEXT_PROTOTYPES +AL_API void AL_APIENTRY alSourcedSOFT(ALuint source, ALenum param, ALdouble value); +AL_API void AL_APIENTRY alSource3dSOFT(ALuint source, ALenum param, ALdouble value1, ALdouble value2, ALdouble value3); +AL_API void AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdouble *values); +AL_API void AL_APIENTRY alGetSourcedSOFT(ALuint source, ALenum param, ALdouble *value); +AL_API void AL_APIENTRY alGetSource3dSOFT(ALuint source, ALenum param, ALdouble *value1, ALdouble *value2, ALdouble *value3); +AL_API void AL_APIENTRY alGetSourcedvSOFT(ALuint source, ALenum param, ALdouble *values); +AL_API void AL_APIENTRY alSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT value); +AL_API void AL_APIENTRY alSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT value1, ALint64SOFT value2, ALint64SOFT value3); +AL_API void AL_APIENTRY alSourcei64vSOFT(ALuint source, ALenum param, const ALint64SOFT *values); +AL_API void AL_APIENTRY alGetSourcei64SOFT(ALuint source, ALenum param, ALint64SOFT *value); +AL_API void AL_APIENTRY alGetSource3i64SOFT(ALuint source, ALenum param, ALint64SOFT *value1, ALint64SOFT *value2, ALint64SOFT *value3); +AL_API void AL_APIENTRY alGetSourcei64vSOFT(ALuint source, ALenum param, ALint64SOFT *values); +#endif +#endif + +#ifndef ALC_EXT_DEFAULT_FILTER_ORDER +#define ALC_EXT_DEFAULT_FILTER_ORDER 1 +#define ALC_DEFAULT_FILTER_ORDER 0x1100 +#endif + +#ifndef AL_SOFT_deferred_updates +#define AL_SOFT_deferred_updates 1 +#define AL_DEFERRED_UPDATES_SOFT 0xC002 +typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void); +typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void); +#ifdef AL_ALEXT_PROTOTYPES +AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void); +AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void); +#endif +#endif + +#ifndef AL_SOFT_block_alignment +#define AL_SOFT_block_alignment 1 +#define AL_UNPACK_BLOCK_ALIGNMENT_SOFT 0x200C +#define AL_PACK_BLOCK_ALIGNMENT_SOFT 0x200D +#endif + +#ifndef AL_SOFT_MSADPCM +#define AL_SOFT_MSADPCM 1 +#define AL_FORMAT_MONO_MSADPCM_SOFT 0x1302 +#define AL_FORMAT_STEREO_MSADPCM_SOFT 0x1303 +#endif + +#ifndef AL_SOFT_source_length +#define AL_SOFT_source_length 1 +/*#define AL_BYTE_LENGTH_SOFT 0x2009*/ +/*#define AL_SAMPLE_LENGTH_SOFT 0x200A*/ +/*#define AL_SEC_LENGTH_SOFT 0x200B*/ +#endif + +#ifndef ALC_SOFT_pause_device +#define ALC_SOFT_pause_device 1 +typedef void (ALC_APIENTRY*LPALCDEVICEPAUSESOFT)(ALCdevice *device); +typedef void (ALC_APIENTRY*LPALCDEVICERESUMESOFT)(ALCdevice *device); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device); +ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device); +#endif +#endif + +#ifndef AL_EXT_BFORMAT +#define AL_EXT_BFORMAT 1 +/* Provides support for B-Format ambisonic buffers (first-order, FuMa scaling + * and layout). + * + * BFORMAT2D_8: Unsigned 8-bit, 3-channel non-periphonic (WXY). + * BFORMAT2D_16: Signed 16-bit, 3-channel non-periphonic (WXY). + * BFORMAT2D_FLOAT32: 32-bit float, 3-channel non-periphonic (WXY). + * BFORMAT3D_8: Unsigned 8-bit, 4-channel periphonic (WXYZ). + * BFORMAT3D_16: Signed 16-bit, 4-channel periphonic (WXYZ). + * BFORMAT3D_FLOAT32: 32-bit float, 4-channel periphonic (WXYZ). + */ +#define AL_FORMAT_BFORMAT2D_8 0x20021 +#define AL_FORMAT_BFORMAT2D_16 0x20022 +#define AL_FORMAT_BFORMAT2D_FLOAT32 0x20023 +#define AL_FORMAT_BFORMAT3D_8 0x20031 +#define AL_FORMAT_BFORMAT3D_16 0x20032 +#define AL_FORMAT_BFORMAT3D_FLOAT32 0x20033 +#endif + +#ifndef AL_EXT_MULAW_BFORMAT +#define AL_EXT_MULAW_BFORMAT 1 +#define AL_FORMAT_BFORMAT2D_MULAW 0x10031 +#define AL_FORMAT_BFORMAT3D_MULAW 0x10032 +#endif + +#ifndef ALC_SOFT_HRTF +#define ALC_SOFT_HRTF 1 +#define ALC_HRTF_SOFT 0x1992 +#define ALC_DONT_CARE_SOFT 0x0002 +#define ALC_HRTF_STATUS_SOFT 0x1993 +#define ALC_HRTF_DISABLED_SOFT 0x0000 +#define ALC_HRTF_ENABLED_SOFT 0x0001 +#define ALC_HRTF_DENIED_SOFT 0x0002 +#define ALC_HRTF_REQUIRED_SOFT 0x0003 +#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004 +#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005 +#define ALC_NUM_HRTF_SPECIFIERS_SOFT 0x1994 +#define ALC_HRTF_SPECIFIER_SOFT 0x1995 +#define ALC_HRTF_ID_SOFT 0x1996 +typedef const ALCchar* (ALC_APIENTRY*LPALCGETSTRINGISOFT)(ALCdevice *device, ALCenum paramName, ALCsizei index); +typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index); +ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs); +#endif +#endif + +#ifndef AL_SOFT_gain_clamp_ex +#define AL_SOFT_gain_clamp_ex 1 +#define AL_GAIN_LIMIT_SOFT 0x200E +#endif + +#ifndef AL_SOFT_source_resampler +#define AL_SOFT_source_resampler +#define AL_NUM_RESAMPLERS_SOFT 0x1210 +#define AL_DEFAULT_RESAMPLER_SOFT 0x1211 +#define AL_SOURCE_RESAMPLER_SOFT 0x1212 +#define AL_RESAMPLER_NAME_SOFT 0x1213 +typedef const ALchar* (AL_APIENTRY*LPALGETSTRINGISOFT)(ALenum pname, ALsizei index); +#ifdef AL_ALEXT_PROTOTYPES +AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index); +#endif +#endif + +#ifndef AL_SOFT_source_spatialize +#define AL_SOFT_source_spatialize +#define AL_SOURCE_SPATIALIZE_SOFT 0x1214 +#define AL_AUTO_SOFT 0x0002 +#endif + +#ifndef ALC_SOFT_output_limiter +#define ALC_SOFT_output_limiter +#define ALC_OUTPUT_LIMITER_SOFT 0x199A +#endif + +#ifndef ALC_SOFT_device_clock +#define ALC_SOFT_device_clock 1 +typedef int64_t ALCint64SOFT; +typedef uint64_t ALCuint64SOFT; +#define ALC_DEVICE_CLOCK_SOFT 0x1600 +#define ALC_DEVICE_LATENCY_SOFT 0x1601 +#define ALC_DEVICE_CLOCK_LATENCY_SOFT 0x1602 +#define AL_SAMPLE_OFFSET_CLOCK_SOFT 0x1202 +#define AL_SEC_OFFSET_CLOCK_SOFT 0x1203 +typedef void (ALC_APIENTRY*LPALCGETINTEGER64VSOFT)(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values); +#ifdef AL_ALEXT_PROTOTYPES +ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALsizei size, ALCint64SOFT *values); +#endif +#endif + +#ifndef AL_SOFT_direct_channels_remix +#define AL_SOFT_direct_channels_remix 1 +#define AL_DROP_UNMATCHED_SOFT 0x0001 +#define AL_REMIX_UNMATCHED_SOFT 0x0002 +#endif + +#ifndef AL_SOFT_bformat_ex +#define AL_SOFT_bformat_ex 1 +#define AL_AMBISONIC_LAYOUT_SOFT 0x1997 +#define AL_AMBISONIC_SCALING_SOFT 0x1998 + +/* Ambisonic layouts */ +#define AL_FUMA_SOFT 0x0000 +#define AL_ACN_SOFT 0x0001 + +/* Ambisonic scalings (normalization) */ +/*#define AL_FUMA_SOFT*/ +#define AL_SN3D_SOFT 0x0001 +#define AL_N3D_SOFT 0x0002 +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/openal-soft/include/AL/efx-creative.h b/openal-soft/include/AL/efx-creative.h new file mode 100644 index 00000000..0a04c982 --- /dev/null +++ b/openal-soft/include/AL/efx-creative.h @@ -0,0 +1,3 @@ +/* The tokens that would be defined here are already defined in efx.h. This + * empty file is here to provide compatibility with Windows-based projects + * that would include it. */ diff --git a/openal-soft/include/AL/efx-presets.h b/openal-soft/include/AL/efx-presets.h new file mode 100644 index 00000000..8539fd51 --- /dev/null +++ b/openal-soft/include/AL/efx-presets.h @@ -0,0 +1,402 @@ +/* Reverb presets for EFX */ + +#ifndef EFX_PRESETS_H +#define EFX_PRESETS_H + +#ifndef EFXEAXREVERBPROPERTIES_DEFINED +#define EFXEAXREVERBPROPERTIES_DEFINED +typedef struct { + float flDensity; + float flDiffusion; + float flGain; + float flGainHF; + float flGainLF; + float flDecayTime; + float flDecayHFRatio; + float flDecayLFRatio; + float flReflectionsGain; + float flReflectionsDelay; + float flReflectionsPan[3]; + float flLateReverbGain; + float flLateReverbDelay; + float flLateReverbPan[3]; + float flEchoTime; + float flEchoDepth; + float flModulationTime; + float flModulationDepth; + float flAirAbsorptionGainHF; + float flHFReference; + float flLFReference; + float flRoomRolloffFactor; + int iDecayHFLimit; +} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; +#endif + +/* Default Presets */ + +#define EFX_REVERB_PRESET_GENERIC \ + { 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PADDEDCELL \ + { 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, { 0.0000f, 0.0000f, 0.0000f }, 1.2691f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ROOM \ + { 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.0629f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_BATHROOM \ + { 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 3.2734f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_LIVINGROOM \ + { 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2805f, 0.0040f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_STONEROOM \ + { 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1003f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_AUDITORIUM \ + { 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7170f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CONCERTHALL \ + { 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.9977f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CAVE \ + { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.7063f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_ARENA \ + { 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.0186f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_HANGAR \ + { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2560f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CARPETEDHALLWAY \ + { 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.1531f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_HALLWAY \ + { 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.6615f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_STONECORRIDOR \ + { 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 1.5758f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ALLEY \ + { 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.9954f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FOREST \ + { 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, { 0.0000f, 0.0000f, 0.0000f }, 0.7682f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CITY \ + { 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1427f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_MOUNTAINS \ + { 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, { 0.0000f, 0.0000f, 0.0000f }, 0.1919f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_QUARRY \ + { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PLAIN \ + { 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, { 0.0000f, 0.0000f, 0.0000f }, 0.1089f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PARKINGLOT \ + { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, { 0.0000f, 0.0000f, 0.0000f }, 0.2652f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_SEWERPIPE \ + { 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, { 0.0000f, 0.0000f, 0.0000f }, 3.2471f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_UNDERWATER \ + { 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 7.0795f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DRUGGED \ + { 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 3.1081f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_DIZZY \ + { 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4937f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_PSYCHOTIC \ + { 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 2.4378f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +/* Castle Presets */ + +#define EFX_REVERB_PRESET_CASTLE_SMALLROOM \ + { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 1.2200f, 0.8300f, 0.3100f, 0.8913f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE \ + { 1.0000f, 0.8900f, 0.3162f, 0.3162f, 0.1000f, 2.3200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_MEDIUMROOM \ + { 1.0000f, 0.9300f, 0.3162f, 0.2818f, 0.1000f, 2.0400f, 0.8300f, 0.4600f, 0.6310f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1550f, 0.0300f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_LARGEROOM \ + { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.1259f, 2.5300f, 0.8300f, 0.5000f, 0.4467f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1850f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_LONGPASSAGE \ + { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 3.4200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_HALL \ + { 1.0000f, 0.8100f, 0.3162f, 0.2818f, 0.1778f, 3.1400f, 0.7900f, 0.6200f, 0.1778f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_CUPBOARD \ + { 1.0000f, 0.8900f, 0.3162f, 0.2818f, 0.1000f, 0.6700f, 0.8700f, 0.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 3.5481f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CASTLE_COURTYARD \ + { 1.0000f, 0.4200f, 0.3162f, 0.4467f, 0.1995f, 2.1300f, 0.6100f, 0.2300f, 0.2239f, 0.1600f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3700f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_CASTLE_ALCOVE \ + { 1.0000f, 0.8900f, 0.3162f, 0.5012f, 0.1000f, 1.6400f, 0.8700f, 0.3100f, 1.0000f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } + +/* Factory Presets */ + +#define EFX_REVERB_PRESET_FACTORY_SMALLROOM \ + { 0.3645f, 0.8200f, 0.3162f, 0.7943f, 0.5012f, 1.7200f, 0.6500f, 1.3100f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.1190f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE \ + { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 2.5300f, 0.6500f, 1.3100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_MEDIUMROOM \ + { 0.4287f, 0.8200f, 0.2512f, 0.7943f, 0.5012f, 2.7600f, 0.6500f, 1.3100f, 0.2818f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1740f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_LARGEROOM \ + { 0.4287f, 0.7500f, 0.2512f, 0.7079f, 0.6310f, 4.2400f, 0.5100f, 1.3100f, 0.1778f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2310f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_LONGPASSAGE \ + { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 4.0600f, 0.6500f, 1.3100f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_HALL \ + { 0.4287f, 0.7500f, 0.3162f, 0.7079f, 0.6310f, 7.4300f, 0.5100f, 1.3100f, 0.0631f, 0.0730f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_CUPBOARD \ + { 0.3071f, 0.6300f, 0.2512f, 0.7943f, 0.5012f, 0.4900f, 0.6500f, 1.3100f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.1070f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_COURTYARD \ + { 0.3071f, 0.5700f, 0.3162f, 0.3162f, 0.6310f, 2.3200f, 0.2900f, 0.5600f, 0.2239f, 0.1400f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2900f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_FACTORY_ALCOVE \ + { 0.3645f, 0.5900f, 0.2512f, 0.7943f, 0.5012f, 3.1400f, 0.6500f, 1.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1140f, 0.1000f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } + +/* Ice Palace Presets */ + +#define EFX_REVERB_PRESET_ICEPALACE_SMALLROOM \ + { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 1.5100f, 1.5300f, 0.2700f, 0.8913f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1640f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ + { 1.0000f, 0.7500f, 0.3162f, 0.5623f, 0.2818f, 1.7900f, 1.4600f, 0.2800f, 0.5012f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM \ + { 1.0000f, 0.8700f, 0.3162f, 0.5623f, 0.4467f, 2.2200f, 1.5300f, 0.3200f, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_LARGEROOM \ + { 1.0000f, 0.8100f, 0.3162f, 0.5623f, 0.4467f, 3.1400f, 1.5300f, 0.3200f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE \ + { 1.0000f, 0.7700f, 0.3162f, 0.5623f, 0.3981f, 3.0100f, 1.4600f, 0.2800f, 0.7943f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.0400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_HALL \ + { 1.0000f, 0.7600f, 0.3162f, 0.4467f, 0.5623f, 5.4900f, 1.5300f, 0.3800f, 0.1122f, 0.0540f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0520f, { 0.0000f, 0.0000f, 0.0000f }, 0.2260f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_CUPBOARD \ + { 1.0000f, 0.8300f, 0.3162f, 0.5012f, 0.2239f, 0.7600f, 1.5300f, 0.2600f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1430f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_COURTYARD \ + { 1.0000f, 0.5900f, 0.3162f, 0.2818f, 0.3162f, 2.0400f, 1.2000f, 0.3800f, 0.3162f, 0.1730f, { 0.0000f, 0.0000f, 0.0000f }, 0.3162f, 0.0430f, { 0.0000f, 0.0000f, 0.0000f }, 0.2350f, 0.4800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_ICEPALACE_ALCOVE \ + { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 2.7600f, 1.4600f, 0.2800f, 1.1220f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1610f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } + +/* Space Station Presets */ + +#define EFX_REVERB_PRESET_SPACESTATION_SMALLROOM \ + { 0.2109f, 0.7000f, 0.3162f, 0.7079f, 0.8913f, 1.7200f, 0.8200f, 0.5500f, 0.7943f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 0.1880f, 0.2600f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ + { 0.2109f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 3.5700f, 0.5000f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1720f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM \ + { 0.2109f, 0.7500f, 0.3162f, 0.6310f, 0.8913f, 3.0100f, 0.5000f, 0.5500f, 0.3981f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2090f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_LARGEROOM \ + { 0.3645f, 0.8100f, 0.3162f, 0.6310f, 0.8913f, 3.8900f, 0.3800f, 0.6100f, 0.3162f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2330f, 0.2800f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE \ + { 0.4287f, 0.8200f, 0.3162f, 0.6310f, 0.8913f, 4.6200f, 0.6200f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_HALL \ + { 0.4287f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 7.1100f, 0.3800f, 0.6100f, 0.1778f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2500f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_CUPBOARD \ + { 0.1715f, 0.5600f, 0.3162f, 0.7079f, 0.8913f, 0.7900f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1810f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPACESTATION_ALCOVE \ + { 0.2109f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.1600f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1920f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } + +/* Wooden Galleon Presets */ + +#define EFX_REVERB_PRESET_WOODEN_SMALLROOM \ + { 1.0000f, 1.0000f, 0.3162f, 0.1122f, 0.3162f, 0.7900f, 0.3200f, 0.8700f, 1.0000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE \ + { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.7500f, 0.5000f, 0.8700f, 0.8913f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_MEDIUMROOM \ + { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.2818f, 1.4700f, 0.4200f, 0.8200f, 0.8913f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_LARGEROOM \ + { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.2818f, 2.6500f, 0.3300f, 0.8200f, 0.8913f, 0.0660f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_LONGPASSAGE \ + { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.3162f, 1.9900f, 0.4000f, 0.7900f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4467f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_HALL \ + { 1.0000f, 1.0000f, 0.3162f, 0.0794f, 0.2818f, 3.4500f, 0.3000f, 0.8200f, 0.8913f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_CUPBOARD \ + { 1.0000f, 1.0000f, 0.3162f, 0.1413f, 0.3162f, 0.5600f, 0.4600f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_COURTYARD \ + { 1.0000f, 0.6500f, 0.3162f, 0.0794f, 0.3162f, 1.7900f, 0.3500f, 0.7900f, 0.5623f, 0.1230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_WOODEN_ALCOVE \ + { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.2200f, 0.6200f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } + +/* Sports Presets */ + +#define EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM \ + { 1.0000f, 1.0000f, 0.3162f, 0.4467f, 0.7943f, 6.2600f, 0.5100f, 1.1000f, 0.0631f, 0.1830f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPORT_SQUASHCOURT \ + { 1.0000f, 0.7500f, 0.3162f, 0.3162f, 0.7943f, 2.2200f, 0.9100f, 1.1600f, 0.4467f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1260f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ + { 1.0000f, 0.7000f, 0.3162f, 0.7943f, 0.8913f, 2.7600f, 1.2500f, 1.1400f, 0.6310f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL \ + { 1.0000f, 0.8200f, 0.3162f, 0.7943f, 1.0000f, 5.4900f, 1.3100f, 1.1400f, 0.4467f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2220f, 0.5500f, 1.1590f, 0.2100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_SPORT_GYMNASIUM \ + { 1.0000f, 0.8100f, 0.3162f, 0.4467f, 0.8913f, 3.1400f, 1.0600f, 1.3500f, 0.3981f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0450f, { 0.0000f, 0.0000f, 0.0000f }, 0.1460f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPORT_FULLSTADIUM \ + { 1.0000f, 1.0000f, 0.3162f, 0.0708f, 0.7943f, 5.2500f, 0.1700f, 0.8000f, 0.1000f, 0.1880f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SPORT_STADIUMTANNOY \ + { 1.0000f, 0.7800f, 0.3162f, 0.5623f, 0.5012f, 2.5300f, 0.8800f, 0.6800f, 0.2818f, 0.2300f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +/* Prefab Presets */ + +#define EFX_REVERB_PRESET_PREFAB_WORKSHOP \ + { 0.4287f, 1.0000f, 0.3162f, 0.1413f, 0.3981f, 0.7600f, 1.0000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_PREFAB_SCHOOLROOM \ + { 0.4022f, 0.6900f, 0.3162f, 0.6310f, 0.5012f, 0.9800f, 0.4500f, 0.1800f, 1.4125f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PREFAB_PRACTISEROOM \ + { 0.4022f, 0.8700f, 0.3162f, 0.3981f, 0.5012f, 1.1200f, 0.5600f, 0.1800f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PREFAB_OUTHOUSE \ + { 1.0000f, 0.8200f, 0.3162f, 0.1122f, 0.1585f, 1.3800f, 0.3800f, 0.3500f, 0.8913f, 0.0240f, { 0.0000f, 0.0000f, -0.0000f }, 0.6310f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.1210f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_PREFAB_CARAVAN \ + { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.1259f, 0.4300f, 1.5000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +/* Dome and Pipe Presets */ + +#define EFX_REVERB_PRESET_DOME_TOMB \ + { 1.0000f, 0.7900f, 0.3162f, 0.3548f, 0.2239f, 4.1800f, 0.2100f, 0.1000f, 0.3868f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 1.6788f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_PIPE_SMALL \ + { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 5.0400f, 0.1000f, 0.1000f, 0.5012f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 2.5119f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DOME_SAINTPAULS \ + { 1.0000f, 0.8700f, 0.3162f, 0.3548f, 0.2239f, 10.4800f, 0.1900f, 0.1000f, 0.1778f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0420f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PIPE_LONGTHIN \ + { 0.2560f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 9.2100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_PIPE_LARGE \ + { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 8.4500f, 0.1000f, 0.1000f, 0.3981f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_PIPE_RESONANT \ + { 0.1373f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 6.8100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } + +/* Outdoors Presets */ + +#define EFX_REVERB_PRESET_OUTDOORS_BACKYARD \ + { 1.0000f, 0.4500f, 0.3162f, 0.2512f, 0.5012f, 1.1200f, 0.3400f, 0.4600f, 0.4467f, 0.0690f, { 0.0000f, 0.0000f, -0.0000f }, 0.7079f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ + { 1.0000f, 0.0000f, 0.3162f, 0.0112f, 0.6310f, 2.1300f, 0.2100f, 0.4600f, 0.1778f, 0.3000f, { 0.0000f, 0.0000f, -0.0000f }, 0.4467f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON \ + { 1.0000f, 0.7400f, 0.3162f, 0.1778f, 0.6310f, 3.8900f, 0.2100f, 0.4600f, 0.3162f, 0.2230f, { 0.0000f, 0.0000f, -0.0000f }, 0.3548f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_OUTDOORS_CREEK \ + { 1.0000f, 0.3500f, 0.3162f, 0.1778f, 0.5012f, 2.1300f, 0.2100f, 0.4600f, 0.3981f, 0.1150f, { 0.0000f, 0.0000f, -0.0000f }, 0.1995f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_OUTDOORS_VALLEY \ + { 1.0000f, 0.2800f, 0.3162f, 0.0282f, 0.1585f, 2.8800f, 0.2600f, 0.3500f, 0.1413f, 0.2630f, { 0.0000f, 0.0000f, -0.0000f }, 0.3981f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } + +/* Mood Presets */ + +#define EFX_REVERB_PRESET_MOOD_HEAVEN \ + { 1.0000f, 0.9400f, 0.3162f, 0.7943f, 0.4467f, 5.0400f, 1.1200f, 0.5600f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0800f, 2.7420f, 0.0500f, 0.9977f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_MOOD_HELL \ + { 1.0000f, 0.5700f, 0.3162f, 0.3548f, 0.4467f, 3.5700f, 0.4900f, 2.0000f, 0.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1100f, 0.0400f, 2.1090f, 0.5200f, 0.9943f, 5000.0000f, 139.5000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_MOOD_MEMORY \ + { 1.0000f, 0.8500f, 0.3162f, 0.6310f, 0.3548f, 4.0600f, 0.8200f, 0.5600f, 0.0398f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.4740f, 0.4500f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +/* Driving Presets */ + +#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ + { 1.0000f, 0.0000f, 0.3162f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ + { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_DRIVING_INCAR_RACER \ + { 0.0832f, 0.8000f, 0.3162f, 1.0000f, 0.7943f, 0.1700f, 2.0000f, 0.4100f, 1.7783f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS \ + { 0.0832f, 0.8000f, 0.3162f, 0.6310f, 1.0000f, 0.1700f, 0.7500f, 0.4100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY \ + { 0.2560f, 1.0000f, 0.3162f, 0.1000f, 0.5012f, 0.1300f, 0.4100f, 0.4600f, 0.7943f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND \ + { 1.0000f, 1.0000f, 0.3162f, 0.2818f, 0.6310f, 3.0100f, 1.3700f, 1.2800f, 0.3548f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.1778f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ + { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 0.7943f, 4.6200f, 1.7500f, 1.4000f, 0.2082f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_DRIVING_TUNNEL \ + { 1.0000f, 0.8100f, 0.3162f, 0.3981f, 0.8913f, 3.4200f, 0.9400f, 1.3100f, 0.7079f, 0.0510f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.0500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0000f, 0x1 } + +/* City Presets */ + +#define EFX_REVERB_PRESET_CITY_STREETS \ + { 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 0.1995f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CITY_SUBWAY \ + { 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CITY_MUSEUM \ + { 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_CITY_LIBRARY \ + { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } + +#define EFX_REVERB_PRESET_CITY_UNDERPASS \ + { 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CITY_ABANDONED \ + { 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +/* Misc. Presets */ + +#define EFX_REVERB_PRESET_DUSTYROOM \ + { 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0060f, { 0.0000f, 0.0000f, 0.0000f }, 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_CHAPEL \ + { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } + +#define EFX_REVERB_PRESET_SMALLWATERROOM \ + { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } + +#endif /* EFX_PRESETS_H */ diff --git a/openal-soft/include/AL/efx.h b/openal-soft/include/AL/efx.h new file mode 100644 index 00000000..34085651 --- /dev/null +++ b/openal-soft/include/AL/efx.h @@ -0,0 +1,762 @@ +#ifndef AL_EFX_H +#define AL_EFX_H + +#include + +#include "alc.h" +#include "al.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" + +#define ALC_EFX_MAJOR_VERSION 0x20001 +#define ALC_EFX_MINOR_VERSION 0x20002 +#define ALC_MAX_AUXILIARY_SENDS 0x20003 + + +/* Listener properties. */ +#define AL_METERS_PER_UNIT 0x20004 + +/* Source properties. */ +#define AL_DIRECT_FILTER 0x20005 +#define AL_AUXILIARY_SEND_FILTER 0x20006 +#define AL_AIR_ABSORPTION_FACTOR 0x20007 +#define AL_ROOM_ROLLOFF_FACTOR 0x20008 +#define AL_CONE_OUTER_GAINHF 0x20009 +#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A +#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B +#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C + + +/* Effect properties. */ + +/* Reverb effect parameters */ +#define AL_REVERB_DENSITY 0x0001 +#define AL_REVERB_DIFFUSION 0x0002 +#define AL_REVERB_GAIN 0x0003 +#define AL_REVERB_GAINHF 0x0004 +#define AL_REVERB_DECAY_TIME 0x0005 +#define AL_REVERB_DECAY_HFRATIO 0x0006 +#define AL_REVERB_REFLECTIONS_GAIN 0x0007 +#define AL_REVERB_REFLECTIONS_DELAY 0x0008 +#define AL_REVERB_LATE_REVERB_GAIN 0x0009 +#define AL_REVERB_LATE_REVERB_DELAY 0x000A +#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B +#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C +#define AL_REVERB_DECAY_HFLIMIT 0x000D + +/* EAX Reverb effect parameters */ +#define AL_EAXREVERB_DENSITY 0x0001 +#define AL_EAXREVERB_DIFFUSION 0x0002 +#define AL_EAXREVERB_GAIN 0x0003 +#define AL_EAXREVERB_GAINHF 0x0004 +#define AL_EAXREVERB_GAINLF 0x0005 +#define AL_EAXREVERB_DECAY_TIME 0x0006 +#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 +#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 +#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 +#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A +#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B +#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C +#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D +#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E +#define AL_EAXREVERB_ECHO_TIME 0x000F +#define AL_EAXREVERB_ECHO_DEPTH 0x0010 +#define AL_EAXREVERB_MODULATION_TIME 0x0011 +#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 +#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 +#define AL_EAXREVERB_HFREFERENCE 0x0014 +#define AL_EAXREVERB_LFREFERENCE 0x0015 +#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 +#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 + +/* Chorus effect parameters */ +#define AL_CHORUS_WAVEFORM 0x0001 +#define AL_CHORUS_PHASE 0x0002 +#define AL_CHORUS_RATE 0x0003 +#define AL_CHORUS_DEPTH 0x0004 +#define AL_CHORUS_FEEDBACK 0x0005 +#define AL_CHORUS_DELAY 0x0006 + +/* Distortion effect parameters */ +#define AL_DISTORTION_EDGE 0x0001 +#define AL_DISTORTION_GAIN 0x0002 +#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 +#define AL_DISTORTION_EQCENTER 0x0004 +#define AL_DISTORTION_EQBANDWIDTH 0x0005 + +/* Echo effect parameters */ +#define AL_ECHO_DELAY 0x0001 +#define AL_ECHO_LRDELAY 0x0002 +#define AL_ECHO_DAMPING 0x0003 +#define AL_ECHO_FEEDBACK 0x0004 +#define AL_ECHO_SPREAD 0x0005 + +/* Flanger effect parameters */ +#define AL_FLANGER_WAVEFORM 0x0001 +#define AL_FLANGER_PHASE 0x0002 +#define AL_FLANGER_RATE 0x0003 +#define AL_FLANGER_DEPTH 0x0004 +#define AL_FLANGER_FEEDBACK 0x0005 +#define AL_FLANGER_DELAY 0x0006 + +/* Frequency shifter effect parameters */ +#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 +#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 +#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 + +/* Vocal morpher effect parameters */ +#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 +#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 +#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 +#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 +#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 +#define AL_VOCAL_MORPHER_RATE 0x0006 + +/* Pitchshifter effect parameters */ +#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 +#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 + +/* Ringmodulator effect parameters */ +#define AL_RING_MODULATOR_FREQUENCY 0x0001 +#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 +#define AL_RING_MODULATOR_WAVEFORM 0x0003 + +/* Autowah effect parameters */ +#define AL_AUTOWAH_ATTACK_TIME 0x0001 +#define AL_AUTOWAH_RELEASE_TIME 0x0002 +#define AL_AUTOWAH_RESONANCE 0x0003 +#define AL_AUTOWAH_PEAK_GAIN 0x0004 + +/* Compressor effect parameters */ +#define AL_COMPRESSOR_ONOFF 0x0001 + +/* Equalizer effect parameters */ +#define AL_EQUALIZER_LOW_GAIN 0x0001 +#define AL_EQUALIZER_LOW_CUTOFF 0x0002 +#define AL_EQUALIZER_MID1_GAIN 0x0003 +#define AL_EQUALIZER_MID1_CENTER 0x0004 +#define AL_EQUALIZER_MID1_WIDTH 0x0005 +#define AL_EQUALIZER_MID2_GAIN 0x0006 +#define AL_EQUALIZER_MID2_CENTER 0x0007 +#define AL_EQUALIZER_MID2_WIDTH 0x0008 +#define AL_EQUALIZER_HIGH_GAIN 0x0009 +#define AL_EQUALIZER_HIGH_CUTOFF 0x000A + +/* Effect type */ +#define AL_EFFECT_FIRST_PARAMETER 0x0000 +#define AL_EFFECT_LAST_PARAMETER 0x8000 +#define AL_EFFECT_TYPE 0x8001 + +/* Effect types, used with the AL_EFFECT_TYPE property */ +#define AL_EFFECT_NULL 0x0000 +#define AL_EFFECT_REVERB 0x0001 +#define AL_EFFECT_CHORUS 0x0002 +#define AL_EFFECT_DISTORTION 0x0003 +#define AL_EFFECT_ECHO 0x0004 +#define AL_EFFECT_FLANGER 0x0005 +#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 +#define AL_EFFECT_VOCAL_MORPHER 0x0007 +#define AL_EFFECT_PITCH_SHIFTER 0x0008 +#define AL_EFFECT_RING_MODULATOR 0x0009 +#define AL_EFFECT_AUTOWAH 0x000A +#define AL_EFFECT_COMPRESSOR 0x000B +#define AL_EFFECT_EQUALIZER 0x000C +#define AL_EFFECT_EAXREVERB 0x8000 + +/* Auxiliary Effect Slot properties. */ +#define AL_EFFECTSLOT_EFFECT 0x0001 +#define AL_EFFECTSLOT_GAIN 0x0002 +#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 + +/* NULL Auxiliary Slot ID to disable a source send. */ +#define AL_EFFECTSLOT_NULL 0x0000 + + +/* Filter properties. */ + +/* Lowpass filter parameters */ +#define AL_LOWPASS_GAIN 0x0001 +#define AL_LOWPASS_GAINHF 0x0002 + +/* Highpass filter parameters */ +#define AL_HIGHPASS_GAIN 0x0001 +#define AL_HIGHPASS_GAINLF 0x0002 + +/* Bandpass filter parameters */ +#define AL_BANDPASS_GAIN 0x0001 +#define AL_BANDPASS_GAINLF 0x0002 +#define AL_BANDPASS_GAINHF 0x0003 + +/* Filter type */ +#define AL_FILTER_FIRST_PARAMETER 0x0000 +#define AL_FILTER_LAST_PARAMETER 0x8000 +#define AL_FILTER_TYPE 0x8001 + +/* Filter types, used with the AL_FILTER_TYPE property */ +#define AL_FILTER_NULL 0x0000 +#define AL_FILTER_LOWPASS 0x0001 +#define AL_FILTER_HIGHPASS 0x0002 +#define AL_FILTER_BANDPASS 0x0003 + + +/* Effect object function types. */ +typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); +typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); +typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); +typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); +typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); +typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); +typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); +typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); + +/* Filter object function types. */ +typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); +typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); +typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); +typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); +typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); +typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); +typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); +typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); + +/* Auxiliary Effect Slot object function types. */ +typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); +typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); +typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); +typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); +typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); + +#ifdef AL_ALEXT_PROTOTYPES +AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); +AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); +AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); +AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); +AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); +AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); +AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); +AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); +AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); +AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); +AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); + +AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); +AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); +AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); +AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); +AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); +AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); +AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); +AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); +AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); +AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); +AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); + +AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); +AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); +AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); +AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); +AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); +AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); +AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); +AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); +AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); +AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); +AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); +#endif + +/* Filter ranges and defaults. */ + +/* Lowpass filter */ +#define AL_LOWPASS_MIN_GAIN (0.0f) +#define AL_LOWPASS_MAX_GAIN (1.0f) +#define AL_LOWPASS_DEFAULT_GAIN (1.0f) + +#define AL_LOWPASS_MIN_GAINHF (0.0f) +#define AL_LOWPASS_MAX_GAINHF (1.0f) +#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) + +/* Highpass filter */ +#define AL_HIGHPASS_MIN_GAIN (0.0f) +#define AL_HIGHPASS_MAX_GAIN (1.0f) +#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) + +#define AL_HIGHPASS_MIN_GAINLF (0.0f) +#define AL_HIGHPASS_MAX_GAINLF (1.0f) +#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) + +/* Bandpass filter */ +#define AL_BANDPASS_MIN_GAIN (0.0f) +#define AL_BANDPASS_MAX_GAIN (1.0f) +#define AL_BANDPASS_DEFAULT_GAIN (1.0f) + +#define AL_BANDPASS_MIN_GAINHF (0.0f) +#define AL_BANDPASS_MAX_GAINHF (1.0f) +#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) + +#define AL_BANDPASS_MIN_GAINLF (0.0f) +#define AL_BANDPASS_MAX_GAINLF (1.0f) +#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) + + +/* Effect parameter ranges and defaults. */ + +/* Standard reverb effect */ +#define AL_REVERB_MIN_DENSITY (0.0f) +#define AL_REVERB_MAX_DENSITY (1.0f) +#define AL_REVERB_DEFAULT_DENSITY (1.0f) + +#define AL_REVERB_MIN_DIFFUSION (0.0f) +#define AL_REVERB_MAX_DIFFUSION (1.0f) +#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) + +#define AL_REVERB_MIN_GAIN (0.0f) +#define AL_REVERB_MAX_GAIN (1.0f) +#define AL_REVERB_DEFAULT_GAIN (0.32f) + +#define AL_REVERB_MIN_GAINHF (0.0f) +#define AL_REVERB_MAX_GAINHF (1.0f) +#define AL_REVERB_DEFAULT_GAINHF (0.89f) + +#define AL_REVERB_MIN_DECAY_TIME (0.1f) +#define AL_REVERB_MAX_DECAY_TIME (20.0f) +#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) + +#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) +#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) +#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) + +#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) +#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) +#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) + +#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) +#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) +#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) + +#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) +#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) +#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) + +#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) +#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) +#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) + +#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) +#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) +#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) + +#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) + +#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE +#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE +#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE + +/* EAX reverb effect */ +#define AL_EAXREVERB_MIN_DENSITY (0.0f) +#define AL_EAXREVERB_MAX_DENSITY (1.0f) +#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) + +#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) +#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) +#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) + +#define AL_EAXREVERB_MIN_GAIN (0.0f) +#define AL_EAXREVERB_MAX_GAIN (1.0f) +#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) + +#define AL_EAXREVERB_MIN_GAINHF (0.0f) +#define AL_EAXREVERB_MAX_GAINHF (1.0f) +#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) + +#define AL_EAXREVERB_MIN_GAINLF (0.0f) +#define AL_EAXREVERB_MAX_GAINLF (1.0f) +#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) + +#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) +#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) +#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) + +#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) +#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) +#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) + +#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) +#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) +#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) + +#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) +#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) + +#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) +#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) + +#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) + +#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) +#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) + +#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) +#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) + +#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) + +#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) +#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) +#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) + +#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) +#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) +#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) + +#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) +#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) +#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) + +#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) +#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) +#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) + +#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) +#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) +#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) + +#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) +#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) +#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) + +#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) +#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) +#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) + +#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) + +#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE +#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE +#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE + +/* Chorus effect */ +#define AL_CHORUS_WAVEFORM_SINUSOID (0) +#define AL_CHORUS_WAVEFORM_TRIANGLE (1) + +#define AL_CHORUS_MIN_WAVEFORM (0) +#define AL_CHORUS_MAX_WAVEFORM (1) +#define AL_CHORUS_DEFAULT_WAVEFORM (1) + +#define AL_CHORUS_MIN_PHASE (-180) +#define AL_CHORUS_MAX_PHASE (180) +#define AL_CHORUS_DEFAULT_PHASE (90) + +#define AL_CHORUS_MIN_RATE (0.0f) +#define AL_CHORUS_MAX_RATE (10.0f) +#define AL_CHORUS_DEFAULT_RATE (1.1f) + +#define AL_CHORUS_MIN_DEPTH (0.0f) +#define AL_CHORUS_MAX_DEPTH (1.0f) +#define AL_CHORUS_DEFAULT_DEPTH (0.1f) + +#define AL_CHORUS_MIN_FEEDBACK (-1.0f) +#define AL_CHORUS_MAX_FEEDBACK (1.0f) +#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) + +#define AL_CHORUS_MIN_DELAY (0.0f) +#define AL_CHORUS_MAX_DELAY (0.016f) +#define AL_CHORUS_DEFAULT_DELAY (0.016f) + +/* Distortion effect */ +#define AL_DISTORTION_MIN_EDGE (0.0f) +#define AL_DISTORTION_MAX_EDGE (1.0f) +#define AL_DISTORTION_DEFAULT_EDGE (0.2f) + +#define AL_DISTORTION_MIN_GAIN (0.01f) +#define AL_DISTORTION_MAX_GAIN (1.0f) +#define AL_DISTORTION_DEFAULT_GAIN (0.05f) + +#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) +#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) +#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) + +#define AL_DISTORTION_MIN_EQCENTER (80.0f) +#define AL_DISTORTION_MAX_EQCENTER (24000.0f) +#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) + +#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) +#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) +#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) + +/* Echo effect */ +#define AL_ECHO_MIN_DELAY (0.0f) +#define AL_ECHO_MAX_DELAY (0.207f) +#define AL_ECHO_DEFAULT_DELAY (0.1f) + +#define AL_ECHO_MIN_LRDELAY (0.0f) +#define AL_ECHO_MAX_LRDELAY (0.404f) +#define AL_ECHO_DEFAULT_LRDELAY (0.1f) + +#define AL_ECHO_MIN_DAMPING (0.0f) +#define AL_ECHO_MAX_DAMPING (0.99f) +#define AL_ECHO_DEFAULT_DAMPING (0.5f) + +#define AL_ECHO_MIN_FEEDBACK (0.0f) +#define AL_ECHO_MAX_FEEDBACK (1.0f) +#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) + +#define AL_ECHO_MIN_SPREAD (-1.0f) +#define AL_ECHO_MAX_SPREAD (1.0f) +#define AL_ECHO_DEFAULT_SPREAD (-1.0f) + +/* Flanger effect */ +#define AL_FLANGER_WAVEFORM_SINUSOID (0) +#define AL_FLANGER_WAVEFORM_TRIANGLE (1) + +#define AL_FLANGER_MIN_WAVEFORM (0) +#define AL_FLANGER_MAX_WAVEFORM (1) +#define AL_FLANGER_DEFAULT_WAVEFORM (1) + +#define AL_FLANGER_MIN_PHASE (-180) +#define AL_FLANGER_MAX_PHASE (180) +#define AL_FLANGER_DEFAULT_PHASE (0) + +#define AL_FLANGER_MIN_RATE (0.0f) +#define AL_FLANGER_MAX_RATE (10.0f) +#define AL_FLANGER_DEFAULT_RATE (0.27f) + +#define AL_FLANGER_MIN_DEPTH (0.0f) +#define AL_FLANGER_MAX_DEPTH (1.0f) +#define AL_FLANGER_DEFAULT_DEPTH (1.0f) + +#define AL_FLANGER_MIN_FEEDBACK (-1.0f) +#define AL_FLANGER_MAX_FEEDBACK (1.0f) +#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) + +#define AL_FLANGER_MIN_DELAY (0.0f) +#define AL_FLANGER_MAX_DELAY (0.004f) +#define AL_FLANGER_DEFAULT_DELAY (0.002f) + +/* Frequency shifter effect */ +#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) +#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) +#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) + +#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) +#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) +#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) + +#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) +#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) +#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) + +#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) +#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) +#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) + +/* Vocal morpher effect */ +#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) +#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) + +#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) +#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) + +#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) +#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) + +#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) +#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) +#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) + +#define AL_VOCAL_MORPHER_PHONEME_A (0) +#define AL_VOCAL_MORPHER_PHONEME_E (1) +#define AL_VOCAL_MORPHER_PHONEME_I (2) +#define AL_VOCAL_MORPHER_PHONEME_O (3) +#define AL_VOCAL_MORPHER_PHONEME_U (4) +#define AL_VOCAL_MORPHER_PHONEME_AA (5) +#define AL_VOCAL_MORPHER_PHONEME_AE (6) +#define AL_VOCAL_MORPHER_PHONEME_AH (7) +#define AL_VOCAL_MORPHER_PHONEME_AO (8) +#define AL_VOCAL_MORPHER_PHONEME_EH (9) +#define AL_VOCAL_MORPHER_PHONEME_ER (10) +#define AL_VOCAL_MORPHER_PHONEME_IH (11) +#define AL_VOCAL_MORPHER_PHONEME_IY (12) +#define AL_VOCAL_MORPHER_PHONEME_UH (13) +#define AL_VOCAL_MORPHER_PHONEME_UW (14) +#define AL_VOCAL_MORPHER_PHONEME_B (15) +#define AL_VOCAL_MORPHER_PHONEME_D (16) +#define AL_VOCAL_MORPHER_PHONEME_F (17) +#define AL_VOCAL_MORPHER_PHONEME_G (18) +#define AL_VOCAL_MORPHER_PHONEME_J (19) +#define AL_VOCAL_MORPHER_PHONEME_K (20) +#define AL_VOCAL_MORPHER_PHONEME_L (21) +#define AL_VOCAL_MORPHER_PHONEME_M (22) +#define AL_VOCAL_MORPHER_PHONEME_N (23) +#define AL_VOCAL_MORPHER_PHONEME_P (24) +#define AL_VOCAL_MORPHER_PHONEME_R (25) +#define AL_VOCAL_MORPHER_PHONEME_S (26) +#define AL_VOCAL_MORPHER_PHONEME_T (27) +#define AL_VOCAL_MORPHER_PHONEME_V (28) +#define AL_VOCAL_MORPHER_PHONEME_Z (29) + +#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) +#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) +#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) + +#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) +#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) +#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) + +#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) +#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) +#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) + +/* Pitch shifter effect */ +#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) +#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) +#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) + +#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) +#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) +#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) + +/* Ring modulator effect */ +#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) +#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) +#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) + +#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) +#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) +#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) + +#define AL_RING_MODULATOR_SINUSOID (0) +#define AL_RING_MODULATOR_SAWTOOTH (1) +#define AL_RING_MODULATOR_SQUARE (2) + +#define AL_RING_MODULATOR_MIN_WAVEFORM (0) +#define AL_RING_MODULATOR_MAX_WAVEFORM (2) +#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) + +/* Autowah effect */ +#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) +#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) +#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) + +#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) +#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) +#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) + +#define AL_AUTOWAH_MIN_RESONANCE (2.0f) +#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) +#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) + +#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) +#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) +#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) + +/* Compressor effect */ +#define AL_COMPRESSOR_MIN_ONOFF (0) +#define AL_COMPRESSOR_MAX_ONOFF (1) +#define AL_COMPRESSOR_DEFAULT_ONOFF (1) + +/* Equalizer effect */ +#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) +#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) +#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) + +#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) +#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) +#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) + +#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) +#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) +#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) + +#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) +#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) +#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) + +#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) +#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) +#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) + +#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) +#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) +#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) + +#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) +#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) +#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) + +#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) +#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) +#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) + +#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) +#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) +#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) + +#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) +#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) +#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) + + +/* Source parameter value ranges and defaults. */ +#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) +#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) +#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) + +#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) + +#define AL_MIN_CONE_OUTER_GAINHF (0.0f) +#define AL_MAX_CONE_OUTER_GAINHF (1.0f) +#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) + +#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE +#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE +#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE + +#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE +#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE +#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE + +#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE +#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE +#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE + + +/* Listener parameter value ranges and defaults. */ +#define AL_MIN_METERS_PER_UNIT FLT_MIN +#define AL_MAX_METERS_PER_UNIT FLT_MAX +#define AL_DEFAULT_METERS_PER_UNIT (1.0f) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* AL_EFX_H */ diff --git a/openal-soft/libs/Win32/OpenAL32.def b/openal-soft/libs/Win32/OpenAL32.def new file mode 100644 index 00000000..32820731 --- /dev/null +++ b/openal-soft/libs/Win32/OpenAL32.def @@ -0,0 +1,96 @@ +EXPORTS + alBuffer3f + alBuffer3i + alBufferData + alBufferf + alBufferfv + alBufferi + alBufferiv + alDeleteBuffers + alDeleteSources + alDisable + alDistanceModel + alDopplerFactor + alDopplerVelocity + alEnable + alGenBuffers + alGenSources + alGetBoolean + alGetBooleanv + alGetBuffer3f + alGetBuffer3i + alGetBufferf + alGetBufferfv + alGetBufferi + alGetBufferiv + alGetDouble + alGetDoublev + alGetEnumValue + alGetError + alGetFloat + alGetFloatv + alGetInteger + alGetIntegerv + alGetListener3f + alGetListener3i + alGetListenerf + alGetListenerfv + alGetListeneri + alGetListeneriv + alGetProcAddress + alGetSource3f + alGetSource3i + alGetSourcef + alGetSourcefv + alGetSourcei + alGetSourceiv + alGetString + alIsBuffer + alIsEnabled + alIsExtensionPresent + alIsSource + alListener3f + alListener3i + alListenerf + alListenerfv + alListeneri + alListeneriv + alSource3f + alSource3i + alSourcePause + alSourcePausev + alSourcePlay + alSourcePlayv + alSourceQueueBuffers + alSourceRewind + alSourceRewindv + alSourceStop + alSourceStopv + alSourceUnqueueBuffers + alSourcef + alSourcefv + alSourcei + alSourceiv + alSpeedOfSound + alcCaptureCloseDevice + alcCaptureOpenDevice + alcCaptureSamples + alcCaptureStart + alcCaptureStop + alcCloseDevice + alcCreateContext + alcDestroyContext + alcGetContextsDevice + alcGetCurrentContext + alcGetEnumValue + alcGetError + alcGetIntegerv + alcGetProcAddress + alcGetString + alcGetThreadContext + alcIsExtensionPresent + alcMakeContextCurrent + alcOpenDevice + alcProcessContext + alcSetThreadContext + alcSuspendContext diff --git a/openal-soft/libs/Win32/OpenAL32.lib b/openal-soft/libs/Win32/OpenAL32.lib new file mode 100644 index 00000000..542f441a Binary files /dev/null and b/openal-soft/libs/Win32/OpenAL32.lib differ diff --git a/openal-soft/libs/Win32/libOpenAL32.dll.a b/openal-soft/libs/Win32/libOpenAL32.dll.a new file mode 100644 index 00000000..12c69099 Binary files /dev/null and b/openal-soft/libs/Win32/libOpenAL32.dll.a differ diff --git a/openal-soft/libs/Win64/OpenAL32.def b/openal-soft/libs/Win64/OpenAL32.def new file mode 100644 index 00000000..32820731 --- /dev/null +++ b/openal-soft/libs/Win64/OpenAL32.def @@ -0,0 +1,96 @@ +EXPORTS + alBuffer3f + alBuffer3i + alBufferData + alBufferf + alBufferfv + alBufferi + alBufferiv + alDeleteBuffers + alDeleteSources + alDisable + alDistanceModel + alDopplerFactor + alDopplerVelocity + alEnable + alGenBuffers + alGenSources + alGetBoolean + alGetBooleanv + alGetBuffer3f + alGetBuffer3i + alGetBufferf + alGetBufferfv + alGetBufferi + alGetBufferiv + alGetDouble + alGetDoublev + alGetEnumValue + alGetError + alGetFloat + alGetFloatv + alGetInteger + alGetIntegerv + alGetListener3f + alGetListener3i + alGetListenerf + alGetListenerfv + alGetListeneri + alGetListeneriv + alGetProcAddress + alGetSource3f + alGetSource3i + alGetSourcef + alGetSourcefv + alGetSourcei + alGetSourceiv + alGetString + alIsBuffer + alIsEnabled + alIsExtensionPresent + alIsSource + alListener3f + alListener3i + alListenerf + alListenerfv + alListeneri + alListeneriv + alSource3f + alSource3i + alSourcePause + alSourcePausev + alSourcePlay + alSourcePlayv + alSourceQueueBuffers + alSourceRewind + alSourceRewindv + alSourceStop + alSourceStopv + alSourceUnqueueBuffers + alSourcef + alSourcefv + alSourcei + alSourceiv + alSpeedOfSound + alcCaptureCloseDevice + alcCaptureOpenDevice + alcCaptureSamples + alcCaptureStart + alcCaptureStop + alcCloseDevice + alcCreateContext + alcDestroyContext + alcGetContextsDevice + alcGetCurrentContext + alcGetEnumValue + alcGetError + alcGetIntegerv + alcGetProcAddress + alcGetString + alcGetThreadContext + alcIsExtensionPresent + alcMakeContextCurrent + alcOpenDevice + alcProcessContext + alcSetThreadContext + alcSuspendContext diff --git a/openal-soft/libs/Win64/OpenAL32.lib b/openal-soft/libs/Win64/OpenAL32.lib new file mode 100644 index 00000000..2ea3cd9d Binary files /dev/null and b/openal-soft/libs/Win64/OpenAL32.lib differ diff --git a/openal-soft/libs/Win64/libOpenAL32.dll.a b/openal-soft/libs/Win64/libOpenAL32.dll.a new file mode 100644 index 00000000..cbbd230d Binary files /dev/null and b/openal-soft/libs/Win64/libOpenAL32.dll.a differ diff --git a/openal-soft/readme.txt b/openal-soft/readme.txt new file mode 100644 index 00000000..ca30a1bc --- /dev/null +++ b/openal-soft/readme.txt @@ -0,0 +1,32 @@ +OpenAL Soft Binary Distribution + +These binaries are provided as a convenience. Users and developers may use it +so they can use OpenAL Soft without having to build it from source. + +Note that it is still expected to install the OpenAL redistributable provided +by Creative Labs (at http://openal.org/), as that will provide the "router" +OpenAL32.dll that applications talk to, and may provide extra drivers for the +user's system. The DLLs provided here will simply add additional devices for +applications to select from. If you do not wish to use the redistributable, +then rename soft_oal.dll to OpenAL32.dll (note: even the 64-bit DLL should be +named OpenAL32.dll). Just be aware this will prevent other system-installed +OpenAL implementations from working. + +To use the 32-bit DLL, copy it from the bin\Win32 folder to the folder that +the 32-bit OpenAL32.dll router is installed in. +For 32-bit Windows, the Win32 DLL will typically go into the system32 folder. +For 64-bit Windows, the Win32 DLL will typically go into the SysWOW64 folder. + +To use the 64-bit DLL, copy it from the bin\Win64 folder to the folder that +the 64-bit OpenAL32.dll router is installed in. +For 64-bit Windows, this will typically be the system32 folder. + +The included openal-info32.exe and openal-info64.exe programs can be used to +tell if the OpenAL Soft DLL is being detected. It should be run from a command +shell, as the program will exit as soon as it's done printing information. + +A configuration GUI app is provided in the alsoft-config folder. It is a front- +end to editing %AppData%\alsoft.ini, which can be used to modify certain +behaviors for OpenAL Soft devices. + +Have fun! diff --git a/src/audio/oal/oal_utils.cpp b/src/audio/oal/oal_utils.cpp index a2df61c1..4119672f 100644 --- a/src/audio/oal/oal_utils.cpp +++ b/src/audio/oal/oal_utils.cpp @@ -39,26 +39,20 @@ LPALGETFILTERFV alGetFilterfv; void EFXInit() { - if (alIsExtensionPresent((ALchar*)"EAX3.0")) - DEV("\nBIG EAX IN TOWN\n"); - else - DEV("\nNO EAX\n"); - - - /* Define a macro to help load the function pointers. */ + /* Define a macro to help load the function pointers. */ #define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x)) - LOAD_PROC(LPALGENEFFECTS, alGenEffects); - LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); - LOAD_PROC(LPALISEFFECT, alIsEffect); - LOAD_PROC(LPALEFFECTI, alEffecti); - LOAD_PROC(LPALEFFECTIV, alEffectiv); - LOAD_PROC(LPALEFFECTF, alEffectf); - LOAD_PROC(LPALEFFECTFV, alEffectfv); - LOAD_PROC(LPALGETEFFECTI, alGetEffecti); - LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv); - LOAD_PROC(LPALGETEFFECTF, alGetEffectf); - LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv); - + LOAD_PROC(LPALGENEFFECTS, alGenEffects); + LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); + LOAD_PROC(LPALISEFFECT, alIsEffect); + LOAD_PROC(LPALEFFECTI, alEffecti); + LOAD_PROC(LPALEFFECTIV, alEffectiv); + LOAD_PROC(LPALEFFECTF, alEffectf); + LOAD_PROC(LPALEFFECTFV, alEffectfv); + LOAD_PROC(LPALGETEFFECTI, alGetEffecti); + LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv); + LOAD_PROC(LPALGETEFFECTF, alGetEffectf); + LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv); + LOAD_PROC(LPALGENFILTERS, alGenFilters); LOAD_PROC(LPALDELETEFILTERS, alDeleteFilters); LOAD_PROC(LPALISFILTER, alIsFilter); @@ -70,22 +64,21 @@ void EFXInit() LOAD_PROC(LPALGETFILTERIV, alGetFilteriv); LOAD_PROC(LPALGETFILTERF, alGetFilterf); LOAD_PROC(LPALGETFILTERFV, alGetFilterfv); - - LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots); - LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots); - LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot); - LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti); - LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv); - LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf); - LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv); - LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti); - LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv); - LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf); - LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv); + + LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots); + LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots); + LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf); + LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf); + LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv); #undef LOAD_PROC } - void SetEffectsLevel(ALuint uiFilter, float level) { alFilteri(uiFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); @@ -103,7 +96,7 @@ static inline float mB_to_gain(float millibels) return (millibels > -10000.0f) ? powf(10.0f, millibels/2000.0f) : 0.0f; } -static inline FLOAT clampF(FLOAT val, FLOAT minval, FLOAT maxval) +static inline float clampF(float val, float minval, float maxval) { if(val >= maxval) return maxval; if(val <= minval) return minval; @@ -113,35 +106,35 @@ static inline FLOAT clampF(FLOAT val, FLOAT minval, FLOAT maxval) void EAX3_Set(ALuint effect, const EAXLISTENERPROPERTIES *props) { alEffecti (effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); - alEffectf (effect, AL_EAXREVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)); - alEffectf (effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion); - alEffectf (effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom)); - alEffectf (effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF)); - alEffectf (effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF)); - alEffectf (effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime); - alEffectf (effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio); - alEffectf (effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio); - alEffectf (effect, AL_EAXREVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN)); - alEffectf (effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay); - alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x); - alEffectf (effect, AL_EAXREVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN)); - alEffectf (effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay); - alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x); - alEffectf (effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime); - alEffectf (effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth); - alEffectf (effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime); - alEffectf (effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth); - alEffectf (effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)); - alEffectf (effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference); - alEffectf (effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference); - alEffectf (effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor); - alEffecti (effect, AL_EAXREVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE); + alEffectf (effect, AL_EAXREVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)); + alEffectf (effect, AL_EAXREVERB_DIFFUSION, props->flEnvironmentDiffusion); + alEffectf (effect, AL_EAXREVERB_GAIN, mB_to_gain((float)props->lRoom)); + alEffectf (effect, AL_EAXREVERB_GAINHF, mB_to_gain((float)props->lRoomHF)); + alEffectf (effect, AL_EAXREVERB_GAINLF, mB_to_gain((float)props->lRoomLF)); + alEffectf (effect, AL_EAXREVERB_DECAY_TIME, props->flDecayTime); + alEffectf (effect, AL_EAXREVERB_DECAY_HFRATIO, props->flDecayHFRatio); + alEffectf (effect, AL_EAXREVERB_DECAY_LFRATIO, props->flDecayLFRatio); + alEffectf (effect, AL_EAXREVERB_REFLECTIONS_GAIN, clampF(mB_to_gain((float)props->lReflections), AL_EAXREVERB_MIN_REFLECTIONS_GAIN, AL_EAXREVERB_MAX_REFLECTIONS_GAIN)); + alEffectf (effect, AL_EAXREVERB_REFLECTIONS_DELAY, props->flReflectionsDelay); + alEffectfv(effect, AL_EAXREVERB_REFLECTIONS_PAN, &props->vReflectionsPan.x); + alEffectf (effect, AL_EAXREVERB_LATE_REVERB_GAIN, clampF(mB_to_gain((float)props->lReverb), AL_EAXREVERB_MIN_LATE_REVERB_GAIN, AL_EAXREVERB_MAX_LATE_REVERB_GAIN)); + alEffectf (effect, AL_EAXREVERB_LATE_REVERB_DELAY, props->flReverbDelay); + alEffectfv(effect, AL_EAXREVERB_LATE_REVERB_PAN, &props->vReverbPan.x); + alEffectf (effect, AL_EAXREVERB_ECHO_TIME, props->flEchoTime); + alEffectf (effect, AL_EAXREVERB_ECHO_DEPTH, props->flEchoDepth); + alEffectf (effect, AL_EAXREVERB_MODULATION_TIME, props->flModulationTime); + alEffectf (effect, AL_EAXREVERB_MODULATION_DEPTH, props->flModulationDepth); + alEffectf (effect, AL_EAXREVERB_AIR_ABSORPTION_GAINHF, clampF(mB_to_gain(props->flAirAbsorptionHF), AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF, AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF)); + alEffectf (effect, AL_EAXREVERB_HFREFERENCE, props->flHFReference); + alEffectf (effect, AL_EAXREVERB_LFREFERENCE, props->flLFReference); + alEffectf (effect, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, props->flRoomRolloffFactor); + alEffecti (effect, AL_EAXREVERB_DECAY_HFLIMIT, (props->ulFlags&EAXLISTENERFLAGS_DECAYHFLIMIT) ? AL_TRUE : AL_FALSE); } void EFX_Set(ALuint effect, const EAXLISTENERPROPERTIES *props) { alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); - + alEffectf(effect, AL_REVERB_DENSITY, clampF(powf(props->flEnvironmentSize, 3.0f) / 16.0f, 0.0f, 1.0f)); alEffectf(effect, AL_REVERB_DIFFUSION, props->flEnvironmentDiffusion); alEffectf(effect, AL_REVERB_GAIN, mB_to_gain((float)props->lRoom)); diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 3eb296ae..a73bc2bd 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -26,11 +26,11 @@ #include "Frontend.h" #include "Timer.h" -//todo max channals -//todo queue -//todo loop count -//todo mp3/wav stream -//todo mp3 player +//TODO: fix eax3 reverb +//TODO: max channals +//TODO: loop count +//TODO: mp3/wav stream +//TODO: mp3 player #pragma comment( lib, "OpenAL32.lib" ) diff --git a/src/core/config.h b/src/core/config.h index 23fe9993..6896a7ba 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -193,8 +193,8 @@ enum Config { #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define USE_TXD_CDIMAGE // generate and load textures from txd.img //#define USE_TEXTURE_POOL -#define AUDIO_OAL -//#define AUDIO_MSS +//#define AUDIO_OAL +#define AUDIO_MSS // Particle //#define PC_PARTICLE diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp index 20e5c49c..288788c0 100644 --- a/src/skel/win/win.cpp +++ b/src/skel/win/win.cpp @@ -1773,12 +1773,13 @@ WinMain(HINSTANCE instance, StaticPatcher::Apply(); SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); - +/* // TODO: make this an option somewhere AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); +*/ /* * Initialize the platform independent data. -- cgit v1.2.3 From 6382b6d2fc467fa188793433563a1d20c80b9c9e Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 4 May 2020 21:32:42 +0300 Subject: fix typo --- src/audio/DMAudio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index 8681f345..f1b9707b 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -119,7 +119,7 @@ int8 cDMAudio::AutoDetect3DProviders(void) if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") ) return i; #elif defined(AUDIO_OAL) - if ( !strcmp(providername, "OPEANAL SOFT") ) + if ( !strcmp(providername, "OPENAL SOFT") ) return i; #endif } -- cgit v1.2.3 From 73c809f616b15cd1eb41c5642ee1242d18275e0d Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Mon, 4 May 2020 22:02:54 +0300 Subject: bb std::string --- src/audio/sampman_oal.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index a73bc2bd..6ae1bf79 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -54,7 +54,7 @@ ALuint ALEffect = AL_EFFECT_NULL; ALuint ALEffectSlot = AL_EFFECTSLOT_NULL; struct { - std::string id; + char id[256]; char name[256]; int sources; }providers[MAXPROVIDERS]; @@ -137,7 +137,7 @@ add_providers() { if ( n < MAXPROVIDERS ) { - providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); providers[n].sources = pDeviceList->GetMaxNumSources(i); SampleManager.Set3DProviderName(n, providers[n].name); @@ -152,7 +152,7 @@ add_providers() { if ( n < MAXPROVIDERS ) { - providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); strcat(providers[n].name, " EAX"); providers[n].sources = pDeviceList->GetMaxNumSources(i); @@ -162,7 +162,7 @@ add_providers() if ( n < MAXPROVIDERS ) { - providers[n].id=std::string(pDeviceList->GetDeviceName(i), strlen(pDeviceList->GetDeviceName(i))); + strcpy(providers[n].id, pDeviceList->GetDeviceName(i)); strncpy(providers[n].name, pDeviceList->GetDeviceName(i), sizeof(providers[n].name)); strcat(providers[n].name, " EAX3"); providers[n].sources = pDeviceList->GetMaxNumSources(i); @@ -263,7 +263,7 @@ set_new_provider(int index) ALCint attr[] = {ALC_FREQUENCY,MAX_FREQ,0}; - ALDevice = alcOpenDevice(providers[index].id.c_str()); + ALDevice = alcOpenDevice(providers[index].id); ASSERT(ALDevice != NULL); ALContext = alcCreateContext(ALDevice, attr); -- cgit v1.2.3 From 12a3499ca365756a77958d616423aca39a23234b Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Thu, 7 May 2020 09:26:16 +0300 Subject: oal wav/mp3 stream update --- libsndfile/ChangeLog | 9764 +++++++++++++++++++++++++++++++++++ libsndfile/NEWS | 199 + libsndfile/dist/libsndfile-1.dll | Bin 0 -> 1679360 bytes libsndfile/include/sndfile.h | 857 +++ libsndfile/include/sndfile.hh | 446 ++ libsndfile/lib/libsndfile-1.def | 47 + libsndfile/lib/libsndfile-1.lib | Bin 0 -> 9948 bytes libsndfile/lib/pkgconfig/sndfile.pc | 12 + mpg123/dist/libmpg123.dll | Bin 0 -> 150528 bytes mpg123/include/mpg123.h | 1034 ++++ mpg123/include/mpg123_pre.h | 40 + mpg123/lib/libmpg123.lib | Bin 0 -> 19996 bytes src/audio/oal/channel.cpp | 59 +- src/audio/oal/channel.h | 4 +- src/audio/oal/stream.cpp | 476 +- src/audio/oal/stream.h | 89 +- src/audio/sampman_oal.cpp | 71 +- src/core/common.h | 2 + src/core/re3.cpp | 14 + 19 files changed, 13007 insertions(+), 107 deletions(-) create mode 100644 libsndfile/ChangeLog create mode 100644 libsndfile/NEWS create mode 100644 libsndfile/dist/libsndfile-1.dll create mode 100644 libsndfile/include/sndfile.h create mode 100644 libsndfile/include/sndfile.hh create mode 100644 libsndfile/lib/libsndfile-1.def create mode 100644 libsndfile/lib/libsndfile-1.lib create mode 100644 libsndfile/lib/pkgconfig/sndfile.pc create mode 100644 mpg123/dist/libmpg123.dll create mode 100644 mpg123/include/mpg123.h create mode 100644 mpg123/include/mpg123_pre.h create mode 100644 mpg123/lib/libmpg123.lib diff --git a/libsndfile/ChangeLog b/libsndfile/ChangeLog new file mode 100644 index 00000000..62576177 --- /dev/null +++ b/libsndfile/ChangeLog @@ -0,0 +1,9764 @@ +2013-04-05 Erik de Castro Lopo + + * Makefile.am + Make sure checkprograms are built as part of 'make test-tarball'. + Closes: https://github.com/erikd/libsndfile/issues/37 + +2013-03-29 Erik de Castro Lopo + + * tests/dft_cmp.c + Fix a buffer overflow detected using GCC 4.8's -fsantiize=address runtime + error checking functionality. This was a buffer overflow in libsndfile's + test suite, not in the actual library code. + +2013-03-09 Erik de Castro Lopo + + * M4/gcc_version.m4 + Fix to work with OpenBSD's sed. + +2013-03-07 Erik de Castro Lopo + + * src/ALAC/alac_encoder.c + Patch from Michael Pruett (author of libaudiofile) to add correct byte + swapping for the mChannelLayoutTag field. + +2013-03-02 Erik de Castro Lopo + + * doc/bugs.html + Bugs should bt reported on the github issue tracker. + +2013-02-22 Erik de Castro Lopo + + * configure.ac + Improve sanitization of FLAC_CFLAGS value. + +2013-02-21 Erik de Castro Lopo + + * src/Makefile.am + Call python interpreter instead of using '#!' in script. Thanks to Jan + Stary for reporting this. + + * doc/index.html doc/FAQ.html + Make internal links relative. Patch from Jan Stary. + +2013-02-13 Erik de Castro Lopo + + * src/test_endswap.def src/test_endswap.tpl + Add tests for psf_put_be32() and psf_put_be64(). + + * src/sfendian.h src/test_endswap.(def|tpl) + Add functions psf_get_be(16|32|64) with tests. + These are needed for platforms where un-aligned accesses cause bus faults. + + * src/ALAC/ag_enc.c src/ALAC/alac_decoder.c + Replace all un-aligned accesses with safe alternatives. + Closes: https://github.com/erikd/libsndfile/issues/19 + +2013-02-12 Erik de Castro Lopo + + * src/sfendian.h + Add big endian versions of H2BE_16 and H2BE_32. + +2013-02-11 Erik de Castro Lopo + + * src/ALAC/ + Replace Apple endswap routines with ones from libsndfile. + + * merge from libsndfile-cart repo + Add ability to set and get a cart chunk with WAV and RF64. + Orignal patch by Chris Roberts required a number of + tweaks. + +2013-02-10 Erik de Castro Lopo + + * src/common.h + Bump SF_HEADER_LEN from 8192 to 12292, the value it was in the 1.0.25 + release. + +2013-02-09 Erik de Castro Lopo + + * src/alac.c + Fix segfault when encoding 8 channel files. + Closes: https://github.com/erikd/libsndfile/issues/30 + +2013-02-07 Erik de Castro Lopo + + * src/ALAC/EndianPortable.c + Fall back to compiler's __BYTE_ORDER__ for endian-ness detection. + +2013-02-06 Erik de Castro Lopo + + * configure.ac src/common.h src/ima_adpcm.c src/ms_adpcm.c src/paf.c + Drop tests for and #ifdef hackery for C99 struct flexible array feature. + libsndfile assumes the compiler supports most of the ISO C99 standard. + + * src/alac.c + Fix valgrind invalid realloc. Reported by nu774. + Closes: https://github.com/erikd/libsndfile/issues/31 + +2013-02-05 Erik de Castro Lopo + + * src/alac.c + The 'pakt' chunk header should now be written correctly. + Closes: https://github.com/erikd/libsndfile/issues/24 + + * configure.ac Makefile.am + Use PKG_INSTALLDIR when it exists. Suggestion from Christoph Thompson. + Closes: https://github.com/erikd/libsndfile/pull/28 + +2013-02-03 Erik de Castro Lopo + + * src/common.h src/caf.c + Read the ALAC 'pakt' header and stash the values. + + * src/sfendian.h + Add functions psf_put_be64() and psf_put_be32(). + + * src/alac.c + Start work on filling on the 'pakt' chunk header. + +2013-02-02 Erik de Castro Lopo + + * doc/FAQ.html + Add missing opening

tag. + + * src/alac.c + Increase ALAC_BYTE_BUFFER_SIZE to 82000. + +2013-01-27 Erik de Castro Lopo + + * doc/FAQ.html + Improve question #8. + +2013-01-02 Erik de Castro Lopo + + * src/ogg_opus.c + Add skeleton implementation so someone else can run with it. + +2012-12-12 Erik de Castro Lopo + + * src/common.h src/dwd.c src/rx2.c src/txw.c + Fix for compiling when configured with --enable-experimental. Thanks to + Eric Wong for reporting this. + +2012-12-01 Erik de Castro Lopo + + * configure.ac programs/sndfile-play.c + OS X 10.8 uses a different audio API to previous versions. + Fix compile failure on by disabling sndfile-play on this version. + Someone needs to supply code for the new API. + +2012-11-30 Erik de Castro Lopo + + * Octave/Makefile.am Octave/octave_test.sh + Fix 'make distcheck'. + +2012-10-13 Erik de Castro Lopo + + * M4/octave.m4 + Relax constraints on Octave version. + +2012-10-11 Erik de Castro Lopo + + * tests/utils.tpl + Improve compare_*_or_die() functions. + + * src/command.c + Fix bug reported by Keiler Florian. When reading short or int data from a + file containing float data, and setting SFC_SET_SCALE_FLOAT_INT_READ to + SF_TRUE would fail 3, 5, 7 and other channels counts. Problem was that + psf_calc_signal_max() was not calculating the signal max correctly. + Calculation of the signal max was failing because it was trying to read + a sample count that was not an integer multiple of the channel count. + + * tests/channel_test.c tests/Makefile.am tests/test_wrapper.sh.in + Add test for the above. + +2012-09-25 Erik de Castro Lopo + + * src/sndfile.hh + Added a constructor to allow the use of SF_VIRTUAL_IO. Patch from + DannyDaemonic : https://github.com/erikd/libsndfile/pull/20 + +2012-08-23 Erik de Castro Lopo + + * doc/octave.html + Fix link to octave.sourceforge.net. Thanks to IOhannes m zmoelnig. + + * src/mat5.c + Allow reading of mat5 files without a specified sample rate (default to + 44.1kHz). Thanks to IOhannes m zmoelnig. + +2012-08-19 Erik de Castro Lopo + + * src/paf.c + Error out if channel count is zero. Bug report from William ELla via + launchpad: + https://bugs.launchpad.net/ubuntu/+source/libsndfile/+bug/1036831 + +2012-08-04 Erik de Castro Lopo + + * configure.ac programs/sndfile-play.c + Patch from Ricci Adams to use OSX's AudioQueues on OSX 10.7 and greater. + +2012-07-09 Erik de Castro Lopo + + * programs/common.c + Accept "ogg" as a file extention for Ogg/Vorbis files. + +2012-06-22 Erik de Castro Lopo + + * src/flac.c + Make sure any previously allocated FLAC stream encoder and stream decoder + objects are deleted before a new one is allocated. + +2012-06-20 Erik de Castro Lopo + + * tests/utils.tpl + Rename gen_lowpass_noise_float() to gen_lowpass_signal_float() and add a + sine wave component so that different FLAC compression levels can be + tested. + + * src/sndfile.h.in doc/command.html + Add SFC_SET_COMPRESSION_LEVEL and document it. + + * src/sndfile.c + Catch SFC_SET_VBR_ENCODING_QUALITY command and implement it as the inverse + of SFC_SET_COMPRESSION_LEVEL. + + * src/ogg_vorbis.c src/flac.c + Implement SFC_SET_COMPRESSION_LEVEL command. + + * tests/test_wrapper.sh.in tests/compression_size_test.c + Use the compression_size_test on FLAC as well. + +2012-06-19 Erik de Castro Lopo + + * tests/ + Rename vorbis_test.c -> compression_size_test.c so it can be extended to + test FLAC as well. + +2012-06-18 Erik de Castro Lopo + + * src/broadcast.c + Fix a bug where a file with a 'bext' chunk with a zero length coding + history field would get corrupted when the file was closed. + Reported by Paul Davis of the Ardour project. + + * src/test_broadcast_var.c + Add a test for the above. + +2012-05-19 Erik de Castro Lopo + + * src/sndfile.c + sf_format_check: For SF_FORMAT_AIFF, reject endian-ness setttings for + non-PCM formats. + +2012-04-12 Erik de Castro Lopo + + * src/aiff.c + Fix regression in handling of odd length SSND chunks. + Thanks Olivier Tristan for the example file. + + * src/aiff.c src/wav.c + Exit parser loop when marker == 0. + +2012-04-04 Erik de Castro Lopo + + * doc/FAQ.html + Fix text. Thanks to Richard Collins. + +2012-03-24 Erik de Castro Lopo + + * src/caf.c + Exit parse loop if the marker is zero. Pass jump offsets as size_t instead + of int. + +2012-03-20 Erik de Castro Lopo + + * src/alac.c + Fix segfault when decoding CAF/ALAC file with more than 4 channels. + Fixes github issue #8 reported by Charles Van Winkle. + +2012-03-20 Erik de Castro Lopo + + * src/common.h + Change 'typedef SF_CHUNK_ITERATOR { ... } SF_CHUNK_ITERATOR' into 'struct + SF_CHUNK_ITERATOR { ... }' to prevent older compilers from complaining of + re-typedef-ing of SF_CHUNK_ITERATOR. + + * configure.ac + Fix if test for empty $prefix. + +2012-03-18 Erik de Castro Lopo + + * src/*.c tests/chunk_test.c + Reworking of custom chunk handling code. + - Memory for the iterator is now attached to the SF_PRIVATE struct and + freed one sf_close(). + - Rename sf_create_chunk_iterator() -> sf_get_chunk_iterator(). + - Each SNDFILE handle never has more than one SF_CHUNK_ITERATOR handle. + + * tests/string_test.c + Fix un-initialised char buffer. + +2012-03-17 Erik de Castro Lopo + + * src/*.c tests/chunk_test.c + Add improved handling of custom chunk getting and settings. Set of patches + from IOhannes m zmoelnig submitted via github pull request #6. + + * src/alac.c + Fix calculated frame count for files with zero block length. + +2012-03-13 Erik de Castro Lopo + + * src/avr.c + Remove double assignment to psf->endian. Thanks Kao Dome. + + * src/gsm610.c + Fix clearing of buffers. Thanks Kao Dome. + + * src/paf.c + Remove duplicate code. Thanks Kao Dome. + + * src/test_strncpy_crlf.c + Fix minor error in test. Thanks Kao Dome. + + * src/common.h src/*.c + Fix a bunch of valgrind errors. + +2012-03-13 Erik de Castro Lopo + + * src/sndfile.c + Fix typo in error string 'Uknown' -> 'Unknown'. + + * tests/fix_this.c + Fix potential int overflow. + +2012-03-10 Erik de Castro Lopo + + * src/alac.c + Fix decoding of last block so that the decode length is not a multiple of + the block length. Fixes github issue #4 reported by Charles Van Winkle. + + * src/sfconfig.h src/sfendian.h + Fix for MinGW cross compiling. Use '#if (defined __*66__)' instead of + '#if __*86__' because the MinGW header use '#ifdef __x86_64__'. + +2012-03-10 Erik de Castro Lopo + + * src/ALAC/ src/alac.c + Unify the interface between libsndfile and Apple ALAC codec. Regardless of + file bit width samples are now passed between the two as int32_t that are + justified towards the most significant bit. Without this modification, 16 + conversion functions would have been needed between the libsndfile (short, + int, float, double) types and the ALAC types (16, 20, 24 and 32 bit). With + this mod, only 4 are needed. + + * tests/floating_point_test.tpl tests/write_read_test.(def|tpl) + Add tests for 20 and 24 bit ALAC/CAF files. + + * src/command.c + Add ALAC/CAF to the SFC_GET_FORMAT_* commands. Fixes github issue #5. + + * configure.ac + Only use automake AM_SLIENT_RULES where supported. Thanks Dave Yeo. + + * tests/pipe_test.tpl + Disable tests on OS/2. Thanks Dave Yeo. + +2012-03-09 Erik de Castro Lopo + + * configure.ac src/sfconfig.h src/sfendian.h + For GCC, use inline assembler for endian swapping. This should work with + older versions of GCC like the one currently used in OS/2. + +2012-03-06 Erik de Castro Lopo + + * src/alac.c + Make sure temp file gets opened in binary mode. + + * src/alac.c src/common.c src/common.h + Fix function alac_write16_d(). + + * tests/floating_point_test.tpl + Add tests for 16 bit ALAC/CAF. + + * src/alac.c src/common.c src/common.h + Add support for 32 bit ALAC/CAF files. + + * tests/floating_point_test.tpl tests/write_read_test.tpl + Add tests for 32 bit ALAC/CAF files. + +2012-03-05 Erik de Castro Lopo + + * src/ + Refactor chunk storage so it work on big as well as little endian CPUs. + + * tests/chunk_test.c + Clean up error messages. + + * src/sfendian.h src/*.c + Rename endian swapping macros and add ENDSWAP_64 and BE2H_64. + + * configure.ac + Detect presence of header file. + + * src/sfendian.h + Use intrinsics (ie for MinGW) when is not + present. + Make ENDSWAP_64() work with i686-w64-mingw32 compiler. + + * src/ALAC/EndianPortable.c + Add support for __powerpc__. + + * src/sfconfig.h + Make sure HAVE_X86INTRIN_H is either 1 or 0. + +2012-03-03 Erik de Castro Lopo + + * src/ALAC/* + Big dump of code for Apple's ALAC file format. The copyyright to this code + is owned by Apple who have released it under an Apache style license. A few + small modifications were made to allow this to be integrated into libsndfile + but unfortunately the history of those changes were lost because they were + developed in a Bzr tree and during that time libsndfile moved to Git. + + * src/alac.c src/caf.c src/common.[ch] src/Makefile.am src/sndfile.h.in + src/sndfile.c + Hook new ALAC codec in. + + * programs/sndfile-convert.c + Add support for alac codec. + + * tests/write_read_test.tpl + Expand tests to cover ALAC. + +2012-03-02 Erik de Castro Lopo + + * src/aiff.c src/wav.c + Fix a couple of regressions from version 1.0.25. + +2012-03-01 Erik de Castro Lopo + + * src/strings.c + Minor refactoring. Make sure that the memory allocation size if always > 0 + to avoid undefined behaviour. + +2012-02-29 Erik de Castro Lopo + + * src/chunk.c + Fix buffer overrun introduced in recently added chunk logging. This chunk + logging has not yet made it to a libsndfile release version. Thanks to + Olivier Tristan for providing an example file. + + * src/wav.c + Fix handling of odd sized chunks which was causing the parser to lose some + chunks. Thanks to Olivier Tristan for providing an example file. + +2012-02-26 Erik de Castro Lopo + + * tests/util.tpl + Used gnu_printf format checking with mingw-w64 compiler. + + * tests/header_test.tpl + Printf format fixes. + +2012-02-25 Erik de Castro Lopo + + * M4/extra_pkg.m4 + Update PKG_CHECK_MOD_VERSION macro to add an AC_TRY_LINK step. This fix + allows the configure process to catch attempts to link incompatible + libraries. For example, linking 32 bit version of eg libFLAC to a 64 bit + version of libsndfile will now fail. Similarly, when cross compiling + libsndfile from Linux to Windows linking the Linux versions of a library + to the Windows version of libsndfile will now also fail. + + * src/sndfile.h.in src/sndfile.c src/common.h src/create_symbols_file.py + Add API function sf_current_byterate(). + + * src/dwvw.c src/flac.c src/ogg_vorbis.c src/sds.c + Add codec specific handlers for current byterate. + + * tests/floating_point_test.tpl + Add initial test for sf_current_byterate(). + +2012-02-24 Erik de Castro Lopo + + * src/common.[ch] + Add function psf_decode_frame_count(). + + * src/dwvw.c + Fix a termnation bug that caused the decoder to go into an infinite loop. + +2012-02-24 Erik de Castro Lopo + + * src/wav.c + Fix a regression in the WAV header parser. Thanks to Olivier Tristan for + bug report and the example file. + +2012-02-21 Erik de Castro Lopo + + * src/sndfile.c + Return error when SF_BROADCAST_INFO struct has bad coding_history_size. + Thanks to Alex Weiss for the report. + +2012-02-20 Erik de Castro Lopo + + * src/au.c src/flac.c src/g72x.c src/ogg_vorbis.c src/wav_w64.c + Don't fake psf->bytewidth values. + +2012-02-19 Erik de Castro Lopo + + * tests/string_test.c + Fix valgrind warnings. + + * src/common.h src/sndfile.c src/strings.c + Make string storage dynamically allocated. + + * src/sndfile.c + Add extra validation for custom chunk handling. + +2012-02-18 Erik de Castro Lopo + + * src/wav.c + Improve handlling unknown chunk types. Thanks to Olivier Tristan for sending + example files. + + * src/utils.tpl + Add GCC specific testing for format string parameters for exit_if_true(). + + * tests/*.c tests/*.tpl + Fix all printf format warnings. + + * programs/sndfile-play.c + Remove un-needed OSX include . Thanks jamesfmilne for github + issue #3. + + * tests/chunk_test.c + Extend custom chunk test. + +2012-02-12 Erik de Castro Lopo + + * src/wav.c + Jump over some more chunk types while parsing. + +2012-02-04 Erik de Castro Lopo + + * src/common.h src/strings.c + Change way strings are stored in SF_PRIVATE in preparation for dynamically + allocating the storage. + +2012-02-02 Erik de Castro Lopo + + * src/common.h src*.c + Improve encapsulation of string data in SF_PRIVATE. + +2012-02-01 Erik de Castro Lopo + + * src/common.h src*.c + Remove the buffer union from SF_PRIVATE. Most uses of this have been + replaced with a BUF_UNION that is allocated on the stack. + +2012-01-31 Erik de Castro Lopo + + * src/common.h src*.c + Rename logbuffer field of SF_PRIVATE to parselog and reduce its size. + Put the parselog buffer and the index inside a struct within SF_PRIVATE. + +2012-01-26 Erik de Castro Lopo + + * configure.ac + Fix typo, FLAC_CLFAGS -> FLAC_CFLAGS. Thanks to Jeremy Friesner. + +2012-01-21 Erik de Castro Lopo + + * src/sndfile.c src/ogg.c + Fix misleading error message when trying to create an SF_FORMAT_OGG file + with anything other than SF_FORMAT_FILE. Thanks to Charles Van Winkle for + the bug report. Github issue #1. + +2012-01-20 Erik de Castro Lopo + + * src/sndfile.c src/wav.c + Allow files opened in RDWR mode with string data in the tailer to be + extended. Thanks to Bodo for the patch. + + * tests/string_test.c + Add tests for the above changes (patch from Bodo). + +2012-01-09 Erik de Castro Lopo + + * src/aiff.c + Refactor reading of chunk size and use of psf_store_read_chunk(). + + * src/(caf|wav).c + Correct storing of chunk offset. + +2012-01-05 Erik de Castro Lopo + + * src/aiff.c src/wav.c src/common.h + Refactor common code into src/common.h. + + * src/caf.c + Make custom chunks work for CAF files. + + * tests/chunk_test.c tests/test_wrapper.sh.in + Test CAF files with custom chunks. + + * src/sndfile.c + Prevent psf->codec_close() being called more than once. + +2012-01-04 Erik de Castro Lopo + + * programs/sndfile-cmp.c + Catch the case where the second file has more frames than the first. + +2012-01-02 Erik de Castro Lopo + + * src/create_symbols_file.py + Add sf_set_chunk/sf_get_chunk_size/sf_get_chunk_data. + +2011-12-31 Erik de Castro Lopo + + * tests/chunk_test.c tests/Makefile.am + New test for custom chunks. + + * src/aiff.c src/chunk.c src/common.h src/sndfile.c + Make custom chunks work on AIFF files. + + * src/wav.c + Make custom chunks work on WAV files (includes refactoring). + +2011-11-12 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c + Start working on setting/getting chunks. + +2011-11-24 Erik de Castro Lopo + + * src/binheader_writef_check.py src/create_symbols_file.py + Make it work for Python 2 and 3. Thanks Michael. + +2011-11-19 Erik de Castro Lopo + + * libsndfile.spec.in + Change field name 'URL' to 'Url'. + + * src/sndfile.h.in + Add SF_SEEK_SET/CUR/END. + +2011-11-05 Erik de Castro Lopo + + * src/id3.c + Fix a stack overflow that can occur when parsing a file with multiple + ID3 headers which would cause libsndfile to go into an infinite recursion + until it blew the stack. Thanks to Anders Svensson for supplying an example + file. + +2011-10-30 Erik de Castro Lopo + + * src/double64.c src/float32.c src/common.h + Make (float32|double_64)_(be|le)_read() functions const correct. + +2011-10-28 Erik de Castro Lopo + + * src/sfendian.h + Minor tweaking of types. Cast to ptr to correct final type rather void*. + + * programs/sndfile-play.c tests/utils.tpl + Fix compiler warnings with latest MinGW cross compiler. + +2011-10-13 Erik de Castro Lopo + + * src/file_io.c + Use the non-deprecated resource fork name on OSX. Thanks to Olivier Tristan. + +2011-10-12 Erik de Castro Lopo + + * src/wav.c + Jump over the 'olym' chunks when parsing. + +2011-10-06 Erik de Castro Lopo + + * tests/write_read_test.tpl + Remove windows only truncate() implementation. + +2011-09-04 Erik de Castro Lopo + + * src/sd2.c src/sndfile.c + Make sure 23 bit PCM SD2 files are readable/writeable. + + * tests/write_read_test.tpl + Add tests for 32 bit PCM SD2 files. + +2011-08-23 Erik de Castro Lopo + + * configure.ac + Use AC_SYS_LARGEFILE instead of AC_SYS_EXTRA_LARGEFILE as suggested by + Jan Willies. + +2011-08-07 Erik de Castro Lopo + + * configure.ac Makefile.am + Move ACLOCAL_AMFLAGS setup to Makefile.am. + +2011-07-15 Erik de Castro Lopo + + * doc/command.html + Merge two separate blocks of SFC_SET_VBR_ENCODING_QUALITY documentation. + + * src/paf.c + Replace ppaf24->samplesperblock with a compile time constant. + +2011-07-13 Erik de Castro Lopo + + * src/ogg_vorbis.c + Fix return value of SFC_SET_VBR_ENCODING_QUALITY command. + + * doc/command.html + Document SFC_SET_VBR_ENCODING_QUALITY, SFC_GET/SET_LOOP_INFO and + SFC_GET_INSTRUMENT. + + * NEWS README configure.ac doc/*.html + Updates for 1.0.25. + +2011-07-07 Erik de Castro Lopo + + * src/sfconfig.h + Add handling for HAVE_SYS_WAIT_H. + + * Makefile.am src/Makefile.am tests/Makefile.am + Add 'checkprograms' target. + +2011-07-05 Erik de Castro Lopo + + * src/common.h src/sndfile.c + Purge SF_ASSERT macro. Use standard C assert instead. + + * src/paf.c src/common.h src/sndfile.c + Fix for Secunia Advisory SA45125, heap overflow (heap gets overwritten with + byte value of 0) due to integer overflow if PAF file handler. + + * src/ima_adpcm.c src/ms_adpcm.c src/paf.c + Use calloc instead of malloc followed by memset. + + * tests/utils.tpl + Clean up use of memset. + +2011-07-05 Erik de Castro Lopo + + * src/ogg.c + Fix log message. + + * tests/format_check_test.c + Fix compiler warnings. + +2011-07-04 Erik de Castro Lopo + + * src/sndfile.c + Fix error message for erro code SFE_ZERO_MINOR_FORMAT. + + * tests/format_check_test.c + Add a test to for SF_FINFO format field validation. + + * src/ogg.c src/ogg_vorbis.c src/ogg.h src/ogg_pcm.c src/ogg_speex.c + src/common.h src/Makefile.am + Move vorbis specific code to ogg_vorbis.c, add new files for handling PCM + and Speex codecs in an Ogg container. The later two are only enabled with + ENABLE_EXPERIMENTAL_CODE config variable. + +2011-06-28 Erik de Castro Lopo + + * src/strings.c + Clean up and refactor storage of SF_STR_SOFTWARE. + +2011-06-23 Erik de Castro Lopo + + * src/sndfile.h.in doc/api.html + Fix definition of SF_STR_LAST and update SF_STR_* related docs. Thanks to + Tim van der Molen for the patch. + +2011-06-21 Erik de Castro Lopo + + * programs/sndfile-interleave.c + Fix handling of argc. Thanks to Marius Hennecke. + + * src/wav_w64.c + Accept broken WAV files with blockalign == 0. Thanks to Olivier Tristan for + providing example files. + + * src/wav.c + Jump over 'FLLR' chunks. + +2011-06-14 Erik de Castro Lopo + + * src/sndfile.h.in + Fix -Wundef warning due to ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + + * configure.ac + Add -Wundef to CFLAGS. + + * src/ogg.c + Fix -Wunder warning. + +2011-05-18 Erik de Castro Lopo + + * configure.ac + Use int64_t instead of off_t when they are the same size. + + * src/Makefile.am tests/Makefile.am + Use check_PROGRAMS instead of noinst_PROGRAMS where appropriate. + +2011-05-08 Erik de Castro Lopo + + * src/wav.c + Don't allow unknown and/or un-editable chunks to prevent the file from being + opened in SFM_RDWR mode. + +2011-04-25 Erik de Castro Lopo + + * tests/format_check_test.c + Fix segfault in test program. + +2011-04-25 Erik de Castro Lopo + + * tests/format_check_test.c + New test program to check to make sure that sf_open() and sf_check_format() + agree as to what is a valid program. + + * tests/Makefile.am tests/test_wrapper.sh.in + Hook into build and test runner. + + * src/sndfile.c + Fix some sf_format_check() problems. Thanks to Charles Van Winkle for the + notification. + +2011-04-06 Erik de Castro Lopo + + * src/caf.c + Add validation to size of 'data' chunk and fix size of written 'data' + chunk. Thanks to Michael Pruett for reporting this. + +2011-03-28 Erik de Castro Lopo + + * src/* tests/* programs/* + Fix a bunch of compiler warnings with gcc-4.6. + +2011-03-25 Erik de Castro Lopo + + * tests/util.tpl + Add NOT macro to util.h. + + * src/strings.c + Fix handling of SF_STR_SOFTWARE that resulted in a segfault due to calling + strlen() on an unterminated string. Thanks to Francois Thibaud for reporting + this problem. + + * tests/string_test.c + Add test for SF_STR_SOFTWARE segfault bug. + + * configure.ac + Sanitize FLAC_CFLAGS value supplied by pkg-config which returns a value of + '-I${includedir}/FLAC'. However FLAC also provides an include file + which clashes with the Standard C header of the same name. The + solution is strip the 'FLAC' part off the end and include all FLAC headers + as . + + * configure.ac src/Makefile.am + Use non-recursive make in src/ directory. + +2011-03-23 Erik de Castro Lopo + + * NEWS README docs/*.html + Updates for 1.0.24 release. + +2011-03-22 Erik de Castro Lopo + + * configure.ac + Fix up usage of sed (should not assume GNU sed). + + * M4/add_(c|cxx)flags.m4 + Test flags in isolation. + + * tests/cpp_test.cc + Fix a broken test (test segfaults). Report by Dave Flogeras. + +2011-03-21 Erik de Castro Lopo + + * programs/common.[ch] + Add function program_name() which returns the program name minus the path + from argv [0]. + + * programs/*.c programs/Makefile.am + Use program_name() where appropriate. Fix build. + +2011-03-20 Erik de Castro Lopo + + * src/wav.c + For u-law and A-law files, write an 18 byte 'fmt ' chunk instead of a 16 + byte one. Win98 accepts files with a 16 but not 18 byte 'fmt' chunk. Later + version accept 18 byte but not 16 byte. + +2011-03-15 Erik de Castro Lopo + + * doc/FAQ.html + Add examples for question 12. + + * doc/libsndfile.css.in + Add tweaks for h4 element. + + * doc/api.html + Add documentation for virtual I/O functionality. Thanks to Uli Franke. + + * tests/util.tpl + Add static inline functions sf_info_clear() and sf_info_setup(). + + * tests/(alaw|dwvw|ulaw)_test.c + Use functions sf_info_clear() and sf_info_setup(). + +2011-03-08 Erik de Castro Lopo + + * configure.ac + Fail more gracefully if pkg-config is missing. Suggestion from Brian + Willoughby. + +2011-02-27 Erik de Castro Lopo + + * src/common.c + Use size_t instead of int for size params with varargs. + +2011-02-09 Erik de Castro Lopo + + * doc/index.html + Update supported platforms with more Debian platforms and Android. + +2011-01-27 Erik de Castro Lopo + + * src/sndfile.hh + Add an LPCWSTR version of the SndfileHandle constructor to the SndfileHandle + class definition. Thanks to Eric Eizenman for pointing out this was missing. + + * tests/cpp_test.cc + Add test for LPCWSTR version of the SndfileHandle constructor. + +2011-01-19 Erik de Castro Lopo + + * programs/sndfile-play.c + Remove cruft. + +2010-12-01 Erik de Castro Lopo + + * src/sndfile.hh + Add methods rawHandle() and takeOwnership(). Thanks to Tim Blechmann for + the patch. + + * tests/cpp_test.cc + Add tests for above two methods. Also supplied by Tim Blechmann. + +2010-11-11 Erik de Castro Lopo + + * doc/api.html + Add mention of use of sf_strerror() when sf_open() fails. + +2010-11-01 Erik de Castro Lopo + + * configure.ac + Make TYPEOF_SF_COUNT_T int64_t where possible. This may fix problems where + people are compiling on a 64 bit system with the GCC -m32 flag. + + * src/sndfile.h.in + Fix comments on sf_count_t. + +2010-10-26 Erik de Castro Lopo + + * src/aiff.c + Handle non-zero offset field in SSND chunk. Thanks to Michael Chinen. + +2010-10-20 Erik de Castro Lopo + + * configure.ac + Sed fix for FreeBSD. Thanks Tony Theodore. + +2010-10-14 Erik de Castro Lopo + + * shave.in M4/shave.m4 + Fix shave invocation of windres compiler. Thanks Damien Lespiau (upstream + shave author). + + * configure.ac M4/shave.m4 shave-libtool.in shave.in + Switch from shave to automake-1.11's AM_SILENT_RULES. + +2010-10-13 Erik de Castro Lopo + + * shave-libtool.in shave.in + Sync to upstream version. + + * src/rf64.c + More work to make the parser more robust and accepting of mal-formed files. + +2010-10-12 Erik de Castro Lopo + + * src/common.h + Add functions psf_strlcpy() and psf_strlcat(). + + * src/broadcast.c src/sndfile.c src/strings.c src/test_main.c + src/test_main.h src/test_strncpy_crlf.c + Use functions psf_strlcpy() and psf_strlcat() as appropriate. + + * tests/string_test.c + Add tests for SF_STR_GENRE and SF_STR_TRACKNUMBER. + + * src/rf64.c + Fix size of 'ds64' chunk when writing RF64. + +2010-10-10 Erik de Castro Lopo + + * programs/*.c + Add the libsndfile version to the usage message of all programs. + +2010-10-10 Erik de Castro Lopo + + * configure.ac src/version-metadata.rc.in src/Makefile.am + Add version string resources to the windows DLL. + + * doc/api.html + Update to add missing SF_FORMAT_* values. Closed Debian bug #545257. + + * NEWS README configure.ac doc/*.html + Updates for 1.0.23 release. + +2010-10-09 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + Handle unusual values of CC environment variable. + + * src/rf64.c + Minor tweaks and additional sanity checking. + + * src/Makefile.am src/binheader_writef_check.py + Use python 2.6. + +2010-10-08 Erik de Castro Lopo + + * src/sndfile.hh + Add a missing 'inline' before a constructor defintion. + +2010-10-06 Erik de Castro Lopo + + * src/common.h + Add macro NOT. + + * src/rf64.c + Minor tweaks. + + * Makefile.am */Makefile.am + Add *~ to CLEANFILES. + +2010-10-05 Erik de Castro Lopo + + * src/sndfile.c + Fix a typo in the error string for SFE_OPEN_PIPE_RDWR. Thanks to Charles + Van Winkle for the report. + +2010-10-04 Erik de Castro Lopo + + * src/flac.c src/ogg.c src/sndfile.h.in src/strings.c src/wav.c + Add ability to read/write tracknumber and genre to flac/ogg/wav files. + Thanks to Matti Nykyri for the patch. + + * src/common.h src/broadcast.c src/strings.c + Add function psf_safe_strncpy() and use where appropriate. + +2010-10-04 Erik de Castro Lopo + + * NEWS README configure.ac doc/*.html + Updates for 1.0.22 release. + +2010-10-03 Erik de Castro Lopo + + * src/common.h src/broadcast.c src/rf64.c src/sndfile.c src/wav.c + Rewrite of SF_BROADCAST_INFO handling. + + * src/test_broadcast_var.c tests/command_test.c + Tweak SF_BROADCAST_INFO tests. + + * src/test_broadcast_var.c + Fix OSX stack check error. + +2010-09-30 Erik de Castro Lopo + + * src/sds.c + Set sustain_loop_end to 0 as suggested by Brian Lewis. + +2010-09-29 Erik de Castro Lopo + + * src/sds.c + Make sure the correct frame count gets written into the header. + + * tests/write_read_test.tpl + Don't allow SDS files to have a long frame count. + +2010-09-17 Erik de Castro Lopo + + * src/sds.c + Apply a pair of patches from Brian Lewis to fix the packet number location + and the checksum. + +2010-09-10 Erik de Castro Lopo + + * src/aiff.c src/file_io.c src/ogg.c src/rf64.c src/sndfile.c + src/strings.c src/test_audio_detect.c src/test_strncpy_crlf.c + src/wav.c tests/pcm_test.tpl + Fix a bunch of minor issues found using static analysis. + +2010-08-23 Erik de Castro Lopo + + * src/test_broadcast_var.c + New file containing tests for broadcast_set_var(). + + * src/Makefile.am src/test_main.[ch] + Hook test_broadcast_var.c into tests. + +2010-08-22 Erik de Castro Lopo + + * src/broadcast.c src/common.(c|h) + Move function strncpy_crlf() to src/common.c so the function can be tested + in isolation. + + * src/test_strncpy_crlf.c + New file. + + * src/Makefile.am src/test_main.[ch] + Hook test_strncpy_crlf.c into tests. + +2010-08-18 Erik de Castro Lopo + + * src/common.h + Move code around to make comments make sense. + + * src/broadcast.c + Add debugging code that is disabled by default. + +2010-08-02 Erik de Castro Lopo + + * src/flac.c + When the file meta data says the file has zero frames set psf->sf.frames + to SF_COUNT_MAX. Fixes Debian bug #590752. + + * programs/sndfile-info.c + Print 'unknown' if frame count == SF_COUNT_MAX. + +2010-06-27 Erik de Castro Lopo + + * src/sndfile.c + Only support writing mono SVX files. Multichannel SVX files are not + interleaved and there is no support infrastructure to cache and write + multiple channels to create a non-interleaved file. + + * src/file_io.c + Don't call close() on a file descriptor of -1. Thanks to Jeremy Friesner + for the bug report. + +2010-06-09 Erik de Castro Lopo + + * src/common.h + Add macro SF_ASSERT. + + * src/sndfile.c + Use SF_ASSERT to ensure sizeof (sf_count_t) == 8. + + * src/svx.c + Add support for reading and writing stereo SVX files. + +2010-05-07 Erik de Castro Lopo + + * configure.ac + When compiling with x86_64-w64-mingw32-gcc link with -static-libgcc flags. + + * programs/common.c programs/sndfile-metadata-set.c + Update metadata after the audio data is copied. Other minor fixes. Patch + from Marius Hennecke. + +2010-05-04 Erik de Castro Lopo + + * src/nist.c + Fix a regression reported by Hugh Secker-Walker. + + * src/api.html + Add comment about sf_open_fd() not working on Windows if the application + and the libsndfile DLL are linked to different versions of the Microsoft + C runtime DLL. + +2010-04-23 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + Fix 'make distcheck'. + +2010-04-21 Erik de Castro Lopo + + * tests/pedantic-header-test.sh.in + New file to test whether sndfile.h can be compiled with gcc's -pedantic + flag. + + * configure.ac tests/test_wrapper.sh.in + Hook pedantic-header-test into test suite. + + * src/sndfile.h.in + Fix -pedantic warning. + +2010-04-19 Erik de Castro Lopo + + * programs/sndfile-salvage.c programs/Makefile.am + New program to salvage the audio data from WAV/WAVEX/AIFF files which are + greater than 4Gig in size. + +2010-04-09 Erik de Castro Lopo + + * programs/sndfile-convert.c + Fix valgrind warning. + +2010-04-06 Erik de Castro Lopo + + * programs/sndfile-cmp.c + When files differ in the PCM data, also print the difference offset. + Minor cleanup. + +2010-03-19 Erik de Castro Lopo + + * src/aiff.c + Don't use the 'twos' marker for 24 and 32 bit PCM, use 'in24' and 'in32' + instead. Thanks to Paul Davis (Ardour) for this suggestion. + +2010-02-28 Erik de Castro Lopo + + * configure.ac + Clean up configure report. + + * tests/utils.tpl + Add functions test_read_raw_or_die and test_write_raw_or_die. + + * tests/rdwr_test.(def|tpl) tests/Makefile.am + Add new test program and hook into build. + + * src/sndfile.c + Fix minor issues with sf_read/write_raw(). Bug reported by Milan Křápek. + + * tests/test_wrapper.sh.in + Add rdwr_test to the test wrapper script. + +2010-02-22 Erik de Castro Lopo + + * configure.ac + Remove -fpascal-strings from OSX's OS_SPECIFIC_CFLAGS. + + * programs/common.[ch] programs/sndfile-metadata-set.c + Apply a patch from Robin Gareus allowing the setting of the time reference + field of the BEXT chunk. + +2010-02-06 Erik de Castro Lopo + + * src/ima_adpcm.c + Add a fix from Jonatan Liljedahl to handle predictor overflow when decoding + IMA4. + +2010-01-26 Erik de Castro Lopo + + * src/sndfile.hh + Add a constructor which takes an existing file descriptor and then calls + sf_open_fd(). Patch from Sakari Bergen. + +2010-01-10 Erik de Castro Lopo + + * programs/sndfile-deinterleave.c programs/sndfile-interleave.c + Improve usage messages. + +2010-01-09 Erik de Castro Lopo + + * src/id3.c src/Makefile.am + Add new file src/id3.c and hook into build. + + * src/sndfile.c src/common.h + Detect and skip and ID3 header at the start of the file. + +2010-01-07 Erik de Castro Lopo + + * programs/common.c + Fix update_strings() copyright, comment, album and license are correctly + written. Thanks to Todd Allen for reporting this. + + * man/Makefile.am + Change GNU makeism to something more widely supported. Thanks to Christian + Weisgerber for reporting this. + + * configure.ac programs/Makefile.am programs/sndfile-play.c + Apply patch from Christian Weisgerber and Jacob Meuserto add support for + OpenBSD's sndio. + +2010-01-05 Erik de Castro Lopo + + * doc/api.html + Discourage the use of sf_read/write_raw(). + +2009-12-28 Erik de Castro Lopo + + * configure.ac + Test for Unix pipe() and waitpid() functions. + + * src/sfconfig.h tests/pipe_test.tpl + Disable pipe_test if pipe() and waitpid() aren't available. + +2009-12-16 Erik de Castro Lopo + + * configure.ac src/Makefile.am src/create_symbols_file.py + src/make-static-lib-hidden-privates.sh + Change name of generated file src/Symbols.linux to Symbols.gnu-binutils and + and use the same symbols file for other systems which use GNU binutils like + Debian's kfreebsd. + + * M4/shave.m4 shave.in + Update shave files from upstream. + +2009-12-15 Erik de Castro Lopo + + * man/sndfile-metadata-get.1 + Fix typo. + + * man/sndfile-interleave.1 man/Makefile.am + New man page. + +2009-12-13 Erik de Castro Lopo + + * src/ogg.c + When decoding to short or int, clip the decoded signal to [-1.0, 1.0] if + its too hot. Thanks to Dmitry Baikov for suggesting this. + + * NEWS README doc/*.html + Updates for 1.0.21. + +2009-12-09 Erik de Castro Lopo + + * programs/sndfile-jackplay.c man/sndfile-jackplay.1 + Remove these which will now be in found in the sndfile-tools package. + + * programs/Makefile.am man/Makefile.am + Remove build rules for sndfile-jackplay. + + * configure.ac + Remove detection of JACK Audio Connect Kit. + + * programs/sndfile-concat.c man/sndfile-concat.1 + Add new program with man page. + + * man/Makefile.am programs/Makefile.am + Hook sndfile-concat into build system. + +2009-12-08 Erik de Castro Lopo + + * tests/error_test.c + Don't terminate when sf_close() returns zero in error_close_test(). + It seems that Windows 7 behaves differently from earlier versions of + Windows. + +2009-12-03 Erik de Castro Lopo + + * configure.ac M4/*.m4 + Rename all custom macros from AC_* to MN_*. + + * programs/sndfile-interleave.c + Make it actually work. + +2009-12-02 Erik de Castro Lopo + + * doc/*.html configure.ac + Corrections and clarifications courtesy of Robin Forder. + + * programs/sndfile-convert.c programs/common.[ch] + Move some code from convert to common for reuse. + + * programs/sndfile-interleave.c programs/sndfile-interleave.c + Add new programs sndfile-interleave and sndfile-deinterleave. + + * programs/Makefile.am + Hook new programs into build. + +2009-12-01 Erik de Castro Lopo + + * src/create_symbols_file.py tests/stdio_test.c tests/win32_test.c + Minor OS/2 tweaks as suggested by David Yeo. + + * tests/multi_file_test.c + Fix file creation flags on windows. Thanks to Bruce Sharpe. + + * src/sf_unistd.h + Set all group and other file create permssions to zero. + + * tests/win32_test.c + Add a new test. + +2009-11-30 Erik de Castro Lopo + + * doc/print.css doc/*.html + Add a print stylesheet and update all HTML documents to reference it. + Thanks to Aditya Bhargava for suggesting this. + + * doc/index.html + Minor corrections. + +2009-11-29 Erik de Castro Lopo + + * sndfile.pc.in + Add a Libs.private entry to assist with static linking. + +2009-11-28 Erik de Castro Lopo + + * src/make-static-lib-hidden-privates.sh src/Makefile.am + Add a script to hide all non-public symbols in the libsndfile.a static + library. + +2009-11-22 Erik de Castro Lopo + + * tests/locale_test.c + Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + +2009-11-20 Erik de Castro Lopo + + * src/windows.c + Correct usage of ENABLE_SNDFILE_WINDOWS_PROTOTYPES. + +2009-11-16 Erik de Castro Lopo + + * programs/sndfile-convert.c + Allow the program to read from stdin by specifying '-' on the command line + as the input file. + + * src/sndfile.h.in + Hash define ENABLE_SNDFILE_WINDOWS_PROTOTYPES to 1 for greater safety. + + * tests/virtual_io_test.c + Add a PAF/PCM_24 test and verify the file length is not negative + immediately after openning the file for write. + +2009-10-18 Erik de Castro Lopo + + * src/wav.c + When writing loop lengths, adjust the end position by one to make up for + Microsoft's screwed up spec. Thanks to Olivier Tristan for the patch. + +2009-10-14 Erik de Castro Lopo + + * src/flac.c + Apply patch from Uli Franke allowing FLAC files to be encoded at any sample + rate. + +2009-10-09 Erik de Castro Lopo + + * src/nist.c + Fix parsing of odd ulaw encoded file provided by Jan Silovsky. + + * configure.ac + Insist on libvorbis >= 1.2.3. Earlier verions have bugs that cause the + libsndfile test suite to fail on MIPS, PowerPC and others. + See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899 + +2009-10-06 Erik de Castro Lopo + + * man/sndfile-convert.1 + Fix warning from Debian's lintian checks. + + * man/sndfile-cmp.1 man/sndfile-jackplay.1 man/sndfile-metadata-get.1 + man/Makefile.am + Add three new minimal manpages and hook into build. + +2009-10-05 Erik de Castro Lopo + + * tests/test_wrapper.sh.in + Don't run cpp_test on x86_64-w64-mingw32. + +2009-09-28 Erik de Castro Lopo + + * tests/utils.tpl + On windows, make sure the open() function doesn't get called with a third + parameter of 0 which fails for no good reason. Also make sure this third + parameter doesn't get called with S_IRGRP when compiling for windows because + Wine complains. + + * src/sndfile.hh + Add a SndfileHandle constructor for windows that takes a 'const wchar_t *' + string. + + * doc/FAQ.html + Add Q/A : I'm cross compiling libsndfile for another platform. How can I + run the test suite? + + * src/create_symbols_file.py src/Makefile.am + Add Symbols.static target, a list of symbols, one per line. + +2009-09-27 Erik de Castro Lopo + + * tests/test_wrapper.sh.in + Update to allow all tests to be gathered up into a testsuite tarball and + then be run using this script. + + * build-test-tarball.mk.in + Add a Make script to build a tarball of all the test binaries and the test + wrapper script. This is useful for cross compiling; you can build the + binaries, build test test tarball and transfer the test tarball to the + target machine for testing. + +2009-09-26 Erik de Castro Lopo + + * src/common.h src/*.c + Modify SF_FILE struct to allow it to carry either 8-bit or 16-bit strings + for the file path, directory and name. Fixes for this change throughout. + + * src/windows.c src/Makefile.am + New file defining new windows only public function sf_wchar_open() which + takes a 'const wchar_t *' string (LPCWSTR) for the file name parameter. + + * src/sndfile.h.in + Add SF_CHANNEL_MAP_ABISONIC_* entries. + Add windows only defintion for sf_wchar_open(). + + * src/create_symbols_file.py + Add sf_wchar_open() to the list of public symbols (windows only). + + * tests/locale_test.c + Add a wchar_test() to test sf_wchar_open(). + +2009-09-25 Erik de Castro Lopo + + * src/common.h src/*.c + Split file stuff into PSF_FILE struct within the SF_PRIVATE struct. + +2009-09-23 Erik de Castro Lopo + + * src/aiff.c src/voc.c + When a byte is needed, use unsigned char. + + * src/ima_oki_adpcm.c src/broadcast.c src/test_ima_oki_adpcm.c + Include sfconfig.h to prevent compile errors with MinGW compilers. + + * configure.ac + Remove AM_CONFIG_HEADER due to warnings from autoconf 2.64. + + * tests/locale_test.c + Update to work with xx_XX.UTF-8 style locales. Refactoring. + +2009-09-22 Erik de Castro Lopo + + * configure.ac + Set __USE_MINGW_ANSI_STDIO to 1 when compiling using MinGW compilers. + Remove unneeded AC_SUBST. + Report Host CPU/OS/vendor. + +2009-09-19 Erik de Castro Lopo + + * src/sndfile.c + Fix error message string. + + * src/flac.c + Add 88200 to the list of supported sample rates. + + * src/ogg.c + Fix compiler warning when using gcc-4.5.0. + + * programs/sndfile-info.c tests/utils.tpl + Remove WIN32 snprintf #define. + + * src/ima_adpcm.c + Fix minor bug in aiff_ima_encode_block. Thanks to Denis Fileev for finding + this. + +2009-09-16 Erik de Castro Lopo + + * src/caf.c + Use the correct C99 format specifier for int64_t. + + * M4/endian.m4 + Fix detection of CPU endian-ness when cross compiling. Thanks to Pierre + Ossman for the bug report. + + * src/caf.c src/sndfile.c + Fix reading and writing of PEAK chunks in CAF files. + + * tests/peak_chunk_test.c tests/test_wrapper.sh.in + Run peak_chunk_test on CAF files. + +2009-09-15 Erik de Castro Lopo + + * src/aiff.c src/wav.c + Use the correct C99 format specifier for int64_t. + +2009-08-30 Erik de Castro Lopo + + * src/rf64.c src/sndfile.c src/wav.c src/wav_w64.h + Apply a patch (massaged slightly) from Uli Franke adding handling of the + BEXT chunk in RF64 files. + + * tests/command_test.c + Update channel_map_test() function so WAV test passes. + + * src/rf64.c + Add channel mapping and ambisonic support. + + * src/sndfile.h + Add comments showing correspondance between libsndfile channel map + defintiions and those used by Apple and MS. + + Add handling of reading/writing channel map info. + + * tests/command_test.c tests/test_wrapper.sh.in + Update channel map tests. + +2009-07-29 Erik de Castro Lopo + + * src/common.h + Add function psf_isprint() a replacement for the standard C isprint() + function which ignores any locale settings and treats all input as ASCII. + + * src/(aiff|common|rf64|sd2|strings|svx|wav).c + Use psf_isprint() instead of isprint(). + +2009-07-13 Erik de Castro Lopo + + * src/command.c + Add string descriptions for SF_FORMAT_RF64 and SF_FORMAT_MPC2K. + +2009-06-30 Erik de Castro Lopo + + * programs/sndfile-play.c + Allow use of Open Sound System audio output under FreeBSD. + +2009-06-24 Erik de Castro Lopo + + * configure.ac + Add patch from Conrad Parker to add --disable-jack. + +2009-05-28 Erik de Castro Lopo + + * src/alaw.c src/float32.c src/htk.c src/pcm.c src/sds.c src/ulaw.c + Fix bugs where invalid files can cause a divide by zero error (SIGFPE). + Thanks to Sami Liedes for reporting this a Debian bug #530831. + +2009-05-26 Erik de Castro Lopo + + * src/chanmap.[ch] + New files for channel map decoding/encoding. + +2009-05-25 Erik de Castro Lopo + + * configure.ac src/sndfile.h.in + Fix MSVC definition of sf_count_t. + +2009-05-24 Erik de Castro Lopo + + * src/wav_w64.[ch] + Add wavex_channelmask to WAV_PRIVATE struct and add a function to convert + an array of SF_CHANNEL_MASK_* values into a bit mask for use in WAV files. + + * src/wav.c + Add ability to write the channel mask. + +2009-05-23 Erik de Castro Lopo + + * programs/sndfile-info.c + Add -c command line option to dump the channel map information. + + * src/wav_w64.c + Don't bail from parser if channel map bitmask is faulty. + + * src/common.h src/sndfile.c + Remove error code SFE_W64_BAD_CHANNEL_MAP which is not needed any more. + + * src/sndfile.c + On SFC_SET_CHANNEL_MAP_INFO pass the channel map command down to container's + command handler. + +2009-05-22 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c src/wav_w64.c + Apply a patch from Lennart Poettering (PulseAudio) to allow reading of + channel data in WAV and W64 files. + Add a test for the above. + +2009-05-20 Erik de Castro Lopo + + * src/FAQ.html + Update the section about pre-compiled binaries for Win64. + +2009-05-14 Erik de Castro Lopo + + * src/common.h src/test_conversions.c + Be more careful when including so compiling on pre-C99 platforms + (hello Slowlaris) might actually work. + + * NEWS README doc/*.html + Updates for 1.0.20. + +2009-04-21 Erik de Castro Lopo + + * src/voc.c + Fix a bug whereby opening a specially crafted VOC file could result in a + heap overflow. Thanks to Tobias Klein (http://www.trapkit.de) for reporting + this issue. + + * src/aiff.c + Fix potential (heap) buffer overflow when parsing 'MARK' chunk. + +2009-04-12 Erik de Castro Lopo + + * tests/stdin_test.c + Check psf->error after opening file. + + * src/file_io.c + Fix obscure seeking bug reported by Hugh Secker-Walker. + + * tests/utils.tpl + Add check of sf_error to test_open_file_or_die(). + + * src/sndfile.c + Clear error if opening resource fork fails. + +2009-04-11 Erik de Castro Lopo + + * tests/alaw_test.c tests/locale_test.c tests/ulaw_test.c + Cleanup output. + +2009-03-25 Erik de Castro Lopo + + * src/float32.c + Fix f2s_clip_array. + +2009-03-24 Erik de Castro Lopo + + * src/float32.c + In host_read_f2s call convert instead of f2s_array. + + * src/ima_adpcm.c + Remove dead code. + + * src/test_ima_oki_adpcm.c examples/generate.c tests/dither_test.c + tests/dwvw_test.c tests/fix_this.c tests/generate.c + tests/multi_file_test.c + Minor fixes. + +2009-03-23 Erik de Castro Lopo + + * M4/shave.m4 shave.in + Pulled update from upstream. + +2009-03-19 Erik de Castro Lopo + + * doc/api.html + Add pointers to example programs in source code tarball. + +2009-03-17 Erik de Castro Lopo + + * src/common.h + Define SF_PLATFORM_S64 for non-gcc compilers with 'long long' type. + + * configure.ac + Add documentation for --disable-external-libs and improve error handling + for that option. + + * src/sndfile.c src/sndfile.h.in src/create_symbols_file.py + Add public function sf_version_string. + + * tests/sfversion.c + Test function sf_version_string. + + * M4/shave.m4 shave-libtool.in shave.in + Add new files from 'git clone git://git.lespiau.name/shave'. + + * configure.ac + Enable shave. + + * src/Makefile.am src/binheader_writef_check.py Octave/* + Shave related tweaks. + +2009-03-15 Erik de Castro Lopo + + * src/common.h src/caf.c src/sndfile.c + Add SF_MAX_CHANNELS (set to 256) and use it. + + * src/sndfile.h.in + Check for either _MSCVER or _MSC_VER being defined. + +2009-03-04 Erik de Castro Lopo + + * tests/vorbis_test.c + Relax test slighly to allow test to pass on more CPUs etc. + +2009-03-03 Erik de Castro Lopo + + * configure.ac + Detect vorbis_version_string() correctly. + +2009-03-02 Erik de Castro Lopo + + * doc/index.html + Add a 'See Also' section with a link to sndfile-tools. + + * NEWS README doc/*.html + Updates for 1.0.19 release. + + * configure.ac + Fix --enable-external-libs logic. + +2009-03-01 Erik de Castro Lopo + + * src/aiff.c + Fix resource leak and potential read beyond end of buffer. + + * src/nist.c + Fix reading of header value sample_n_bytes. + + * src/sd2.c src/wav.c + Fix potential read beyond end of buffer. + + * src/sndfile.c src/svx.c + Check return values of file_io functions. + + * tests/win32_test.c + Fix resource leak. + + * configure.ac + Detect the presence/absence of vorbis_version_string() in libvorbis. + + * src/ogg.c + Only call vorbis_version_string() from libvorbis if present. + +2009-02-24 Erik de Castro Lopo + + * tests/win32_test.c + Don't use sprintf, even on windows. + + * src/aiff.c src/rf64.c src/wav.c + Eliminate dead code, more validation of data read from file. + +2009-02-22 Erik de Castro Lopo + + * src/ima_adpcm.c + Clamp values to a valid range before indexing ima_step_size array. + + * src/GSM610/*.c tests/*c programs/*.c src/audio_detect.c + Don't include un-needed headers. + + * programs/sndfile-info.c + Remove dead code. + + * tests/test_wrapper.sh.in + Add 'set -e' so the script exits on error. + + * src/test_ima_oki_adpcm.c + Fix read beyond end of array. + + * tests/win32_test.c + Add missing close on file descriptor. + + * src/nist.c programs/sndfile-metadata-set.c + Fix 'unused variable' warnings. + + * src/aiff.c + Fix potential memory leak in handling of 'MARK' chunk. + Remove un-needed test (unsigned > 0). + + * src/sd2.c + Improve handling of heap allocated buffer. + + * src/sndfile.c + Remove un-needed test (always true). + + * src/wav.c src/rf64.c + Ifdef out dead code that will be resurected some time in the future. + + * src/wav.c src/w64.c src/xi.c + Handle error return values from psf_ftell. + + * src/wav_w64.c + Fix handling and error checking of MSADPCM coefficient arrays. + + * regtest/*.c + Bunch of fixes. + + * src/test_file_io.c + Use snprintf instead of strncpy in test program. + +2009-02-21 Erik de Castro Lopo + + * src/sd2.c + Validate data before using. + + * src/caf.c + Validate channels per frame value before using, fixing a possible integer + overflow bug, leading to a possible heap overflow. Found by Alin Rad Pop of + Secunia Research (CVE-2009-0186). + +2009-02-20 Erik de Castro Lopo + + * Octave/octave_test.sh + Unset TERM environment variable and export LD_LIBRARY_PATH. + +2009-02-16 Erik de Castro Lopo + + * src/file_io.c + In windows code, cast LPVOID to 'char*' in printf. + +2009-02-15 Erik de Castro Lopo + + * M4/octave.m4 + Clear the TERM environment before evaluating anything in Octave. This works + around problems that might occur if a users TERM settings are incorrect. + Thanks to Rob Til Freedmen for helping to debug this. + + * src/wav.c + Handle four zero bytes as a marker within a LIST or INFO chunk. + Thanks to Rogério Brito for supplying an example file. + +2009-02-14 Erik de Castro Lopo + + * src/common.h src/*.c + Use C99 snprintf everywhere. + +2009-02-11 Erik de Castro Lopo + + * tests/test_wrapper.sh.in + New file to act as the template for the test wrapper script. + + * configure.ac + Generate tests/test_wrapper.sh from the template. + + * tests/Makefile.am + Replace all tests with a single invocation of the test wrapper script. + +2009-02-09 Erik de Castro Lopo + + * src/ogg.c + Record vorbis library version string. + + * configure.ac + Require libvorbis >= 1.2.2. + + * M4/endian.m4 + Fix bracketing of function for autoconf 2.63. Thanks to Richard Ash. + + * M4/octave.m4 M4/mkoctfile_version.m4 + Clean up AC_WITH_ARG usage using AC_HELP_STRING. + +2009-02-08 Erik de Castro Lopo + + * Octave/Makefile.am + Use $(top_buildir) instead of $(builddir) which may not be defined. + + * M4/octave.m4 + Improve logic and status reporting. + +2009-02-07 Erik de Castro Lopo + + * configure.ac AUTHORS NEWS README doc/*.html + Final tweaks for 1.0.18 release. + +2009-02-03 Erik de Castro Lopo + + * programs/sndfile-convert.c + Add 'htk' to the list of convert formats. + + * programs/sndfile-info.c + Simplify get_signal_max using SFC_CALC_SIGNAL_MAX command. + Increase size of files for which signal max will be calculated. + +2009-01-14 Erik de Castro Lopo + + * doc/index.html + Fix links for SoX and WavPlay. Thanks to Daniel Griscom. + +2009-01-11 Erik de Castro Lopo + + * programs/sndfile-metadata-get.c + Make valgrind clean. + Clean up temp string array usage. + Error out if trying to update coding history in RDWR mode. + +2009-01-10 Erik de Castro Lopo + + * doc/index.html + Fix links to versions of the LGPL. + +2008-12-14 Erik de Castro Lopo + + * tests/string_test.c + Add test for RDWR mode where the file ends up shorter than when it was + opened. + + * src/wav.c + Truncate the file on close for RDWR mode where the file ends up shorter + than when it was opened. + +2008-11-30 Erik de Castro Lopo + + * M4/add_cflags.m4 + Fix problem with quoting of '#include'. + + * M4/add_cxxflags.m4 configure.ac + Add new file M4/add_cxxflags.m4 and use it in configure.ac. + +2008-11-19 Erik de Castro Lopo + + * programs/sndfile-info.c + Apply patch from Conrad Parker to calculate and display total duration when + more than one file is dumped. + +2008-11-10 Erik de Castro Lopo + + * configure.ac src/Makefile.am + Tweaks to generation of Symbols files. + + * tests/win32_ordinal_test.c + Update tests for above changes. + +2008-11-06 Erik de Castro Lopo + + * programs/common.c + When merging broadcast info, make sure to clear the destination field + before copying in the new data. + + * programs/test-sndfile-metadata-set.py + Add test for the above. + + * src/broadcast.c + Fix checking of required coding_history_size. + +2008-10-28 Erik de Castro Lopo + + * tests/command_test.c + Add test to detect if coding history is truncated. + + * src/broadcast.c + Fix truncation of coding history. + +2008-10-27 Erik de Castro Lopo + + * tests/command_test.c + Add broadcast_coding_history_size test. + + * programs/*.[ch] + Use SF_BROADCAST_INFO_VAR to manipulate larger 'bext' chunks. + + * src/rf64.c + Add code to prevent infinite loop on malformed file. + + * src/common.h src/sndfile.c src/w64.c src/wav_w64.c + Rationalize and improve error handling when parsing 'fmt ' chunk. + + * M4/octave.m4 + Simplify and remove cruft. + Check for correct Octave version. + + * Octave/* + Reduce 3 C++ files to one, fix build for octave 3.0, fix build. + + * Octave/sndfile.cc Octave/PKG_ADD + Add Octave function sfversion which returns the libsndfile version that the + module is linked against. + + * Octave/Makefile.am + Bunch of build and 'make distcheck' fixes. + +2008-10-26 Erik de Castro Lopo + + * programs/common.c + Return 1 if SFC_SET_BROADCAST_INFO fails. + + * programs/test-sndfile-metadata-set.py + Update for new programs directory, exit on any error. + + * tests/error_test.c + Fix failure behaviour in error_number_test. + + * src/common.h src/sndfile.c + Add error number SFE_BAD_BROADCAST_INFO_SIZE. + + * src/* + Reimplement handling of broadcast extentioon chunk in WAV/WAVEX files. + + * src/broadcast.c + Fix generation of added coding history. + +2008-10-25 Erik de Castro Lopo + + * programs/sndfile-metadata-get.c programs/sndfile-info.c + Exit with non-zero on errors. + +2008-10-21 Erik de Castro Lopo + + * examples/sndfile-to-text.c examples/Makefile.am + Add a new example program and hook it into the build. + + * examples/ programs/ + Add a new directory programs and move sndfile-info, sndfile-play and other + real programs to the new directory, leaving example programs where they + were. + +2008-10-20 Erik de Castro Lopo + + * tests/Makefile.am + Automake 1.10 MinGW cross compiling fixes. + +2008-10-19 Erik de Castro Lopo + + * examples/sndfile-play.c + Remove call to deprecated function snd_pcm_sw_params_get_xfer_align. + Fix gcc-4.3 compiler warnings. + + * tests/command_test.c + Fix a valgrind warning. + + * tests/error_test.c tests/multi_file_test.c tests/peak_chunk_test.c + tests/pipe_test.tpl tests/stdio_test.c tests/win32_test.c + Fix gcc-4.3 compiler warnings. + +2008-10-17 Erik de Castro Lopo + + * src/broadcast.c + Fix termination of desitination string in strncpy_crlf. + When copying BROADCAST_INFO chunk, make sure destination gets correct line + endings. + + * examples/common.c + Fix copying of BROADCAST_INFO coding_history field. + +2008-10-13 Erik de Castro Lopo + + * tests/command_test.c + Add test function instrument_rw_test, but don't hook it into the testing + yet. + + * src/common.h src/command.c src/sndfile.c src/flac.c + Error code rationalization. + + * src/common.h src/sndfile.c + Set psf->error to SFE_CMD_HAS_DATA when adding metadata via sf_command() + fails due to psf->have_written being true. + + * doc/command.html + Document the SFC_GET/SET_BROADCAST_INFO comamnds. + +2008-10-10 Erik de Castro Lopo + + * tests/command_test.c + Improve error reporting when '\0' is found in coding history. + Fix false failure. + +2008-10-09 Erik de Castro Lopo + + * src/broadcast.c + Convert all coding history line endings to \r\n. + + * tests/command_test.c + Add test to make sure all line endings are converted to \r\n. + +2008-10-08 Erik de Castro Lopo + + * src/broadcast.c + Changed the order of coding history fields. + + * tests/command_test.c + Update bextch test to cope with previous change. + + * examples/common.c + Add extra length check when copying broadcast info data. + +2008-10-05 Erik de Castro Lopo + + * tests/utils.tpl tests/pcm_test.tpl + Update check_file_hash_or_die to use 64 bit hash. + + * tests/checksum_test.c tests/Makefile.am + Add new checksum_test specifically for lossy compression of headerless + files. + +2008-10-04 Erik de Castro Lopo + + * src/gsm610.c + Seek to psf->dataoffset before decoding first block. + + * src/sndfile.c + Fix detection of mpc2k files on big endian systems. + +2008-10-03 Erik de Castro Lopo + + * src/broadcast.c + Use '\r\n' newlines in Coding History as required by spec. + +2008-10-02 Erik de Castro Lopo + + * src/test_conversions.c + Use int64_t instead of 'long long'. + +2008-10-01 Erik de Castro Lopo + + * examples/sndfile-metadata-set.c + Remove --bext-coding-history-append command line option because it didn't + really make sense. + + * examples/sndfile-metadata-(get|set).c + Add usage messages. + + * examples/test-sndfile-metadata-set.py + Start work on test coding history. + +2008-09-30 Erik de Castro Lopo + + * README doc/win32.html + Bring these up to date. + + * src/aiff.c + Fix parsing of REX files. + +2008-09-29 Erik de Castro Lopo + + * src/file_io.c + Use intptr_t instead of long for return value of _get_osfhandle. + + * src/test_conversions.c src/test_endswap.tpl + Fix printing of int64_t values. + + * examples/sndfile-play.c + Fix win64 issues. + + * tests/win32_ordinal_test.c + Fix calling of GetProcAddress with ordinal under win64. + + * tests/utils.tpl + Fix win64 issues. + +2008-09-25 Erik de Castro Lopo + + * examples/* + Rename copy_data.[ch] to common.[ch]. Fix build. + Move code from sndfile-metadata-set.c to common.c. + + * examples/Makefile.am tests/Makefile.am regtest/Makefile.am + Clean paths. + +2008-09-19 Erik de Castro Lopo + + * doc/tutorial.html doc/Makefile.am + Add file doc/tutorial.html and hook into build/dist system. + +2008-09-14 Erik de Castro Lopo + + * examples/sndfile-metadata-set.c + Clean up handling of bext command line params. + +2008-09-13 Erik de Castro Lopo + + * src/w64.c + Add handling/skipping of a couple of new chunk types. + +2008-09-09 Erik de Castro Lopo + + * configure.ac + Add -funsigned-char to CFLAGS if the compiler supports it. + + * examples/sndfile-metadata-(get|set).c + Add handling for more metadata types. + +2008-09-04 Erik de Castro Lopo + + * src/common.h + Add macros SF_CONTAINER, SF_CODEC and SF_ENDIAN useful for splitting format + field of SF_INFO into component parts. + + * src/*.c + Use new macros everywhere it is appropriate. + +2008-09-02 Erik de Castro Lopo + + * examples/sndfile-bwf-set.c + Massive reworking. + +2008-08-24 Erik de Castro Lopo + + * examples/sndfile-bwf-set.c + Add --info-auto-create-date command line option. + + * examples/sndfile-metadata-set.c examples/sndfile-metadata-get.c + examples/Makefile.am examples/test-sndfile-bwf-set.py + Rename sndfile-bwf-(set|get).c to sndfile-metadata-(set|get).c. + Change command line args. + +2008-08-23 Erik de Castro Lopo + + * src/wav.c + Allow 'PAD ' chunk to be modified in RDWR mode. + + * src/sndfile.h.in src/sndfile.c + Add handling (incomplete) for SFC_SET_ADD_HEADER_PAD_CHUNK. + + * tests/Makefile.am tests/write_read_test.tpl tests/header_test.tpl + tests/misc_test.c + Add tests for RF64. + + * src/rf64.c + Fixes to make sure all tests pass. + + * tests/Makefile.am tests/string_test.c + Add string tests (not yet passing). + +2008-08-22 Erik de Castro Lopo + + * src/rf64.c + First pass at writing RF64 now working. + +2008-08-21 Erik de Castro Lopo + + * examples/sndfile-convert.c + Add SF_FORMAT_RF64 to format_map. + + * src/common.h src/sndfile.c + More RF64 support code. + + * examples/sndfile-bwf-set.c + Fix the month number in autogenerated date string and use hypen in date + instead of slash. + + * examples/test-sndfile-bwf-set.py + Update tests. + + * examples/sndfile-info.c + When called with -i or -b option, operate on all files on command line, not + just the first. + +2008-08-19 Erik de Castro Lopo + + * src/rf64.c + New file to handle RF64 (WAV like format supportting > 4Gig files). + + * src/sndfile.h.in src/common.h src/sndfile.c src/Makefile.am + Hook the above into build so hacking can begin. + + * src/pcm.c + Improve log message when pcm_init fails. + + * src/sndfile-info.c + Only calculate and print 'Signal Max' if file is less than 10 megabytes in + length. + +2008-08-18 Erik de Castro Lopo + + * tests/string_test.c + Polish string_multi_set_test. + + * src/wav.c + In RDWR mode, pad the header if necessary (ie LIST chunk has moved or + length has changed). + Minor fixes in wav_write_strings. + Write PAD chunk with default endian-ness, not a specific endian-ness. + + * examples/test-sndfile-bwf-set.py + Add Python script to test sndfile-bwf-set/get. + + * examples/sndfile-bwf-set.c + Clean up and fixes. + + * src/wav.c + Merge function wavex_write_header into wav_write_header, deleting about 70 + lines of code. + + * src/common.h + Double value of SF_MAX_STRINGS. + + * tests/string_test.c + Add string tests for WAVEX and RIFX files. + + * tests/command_test.c + Add broadcast test for WAVEX files. + +2008-08-17 Erik de Castro Lopo + + * tests/string_test.c + Add a new string_rdwr_test (currently failing for WAV). + Add a new string_multi_set_test (currently failing). + + * tests/command_test.c + Add new broadcast_rdwr_test (currently failing). + + * src/wav.c + Fix to WAV parser to allow 'bext' chunk to be updated in place. + In wav_write_tailer, seek to psf->dataend if its greater than zero. + + * src/sndfile.c + Make sure psf->have_written gets set correctly in mode SFM_RDWR. + + * configure.ac + Test for and gettimeofday. + + * src/common.c + Use gettimeofday() to initialize psf_rand_int32. + + * src/common.h src/sndfile.c + Add unique_id field to SF_PRIVATE struct. + + * src/common.h src/sndfile.c src/wav.c src/wav_w64.[ch] + Move wavex_ambisonic field from SF_PRIVATE struct to WAV_PRIVATE struct. + + * src/common.h src/strings.c + Add function psf_location_string_count. + +2008-08-16 Erik de Castro Lopo + + * configure.ac + Test for localtime and localtime_r. + + * examples/sndfile-convert.c + In function copy_metadata(), copy broadcast info if present. + + * examples/copy_data.[ch] examples/Makefile.am + Break some functionality out of sndfile-convert.c so it can be used in + examples/sndfile-bwf-set.c. + + * tests/utils.tpl + Add new function create_short_sndfile(). + + * examples/sndfile-bwf-set.c examples/sndfile-bwf-get.c + examples/Makefile.am + Add new files and hook into build. + +2008-08-11 Erik de Castro Lopo + + * src/sndfile.h.in + Fix comments. Patch from Mark Glines. + +2008-07-30 Erik de Castro Lopo + + * tests/misc_test.c + Use zero_data_test on Ogg/Vorbis files. + + * src/ogg.c + Fix segfault when closing an Ogg/Vorbis file that has been opened for write + but had no actual data written to it. Bug reported by Chinoy Gupta. + + * tests/Makefile.am + Make sure to run mist_test on Ogg/Vorbis files. + +2008-07-19 Erik de Castro Lopo + + * regtest/Makefile.am + Use SQLITE3_CFLAGS to locate sqlite headers. + +2008-07-10 Erik de Castro Lopo + + * doc/index.html doc/FAQ.html + Add notes about which versions of windows libsndfile works on. + +2008-07-03 Erik de Castro Lopo + + * tests/misc_test.c + Add a test for correct handling of Ambisonic files. Thanks to Fons + Adriaensen for the test. + + * src/wav.c src/wav_w64.c + Fix handling of Ambisonic files. Thanks to Fons Adriaensen for the patch. + +2008-06-29 Erik de Castro Lopo + + * configure.ac + Fix detection/enabling of external libs. + + * M4/extra_pkg.m4 M4/Makefile.am + Add m4 macro PKG_CHECK_MOD_VERSION which is a hacked version + PKG_CHECK_MODULES. The new macro prints the version number of the package + it is searching for. + +2008-06-14 Erik de Castro Lopo + + * src/aiff.c + Apply a fix from Axel Röbel where if the second loop in the instrument + chunk is none, the loop mode is written into the first loop. + +2008-05-31 Erik de Castro Lopo + + * src/test_float.c src/test_main.(c|h) src/Makefile.am + Add new file to test functions float32_(le|be)_(read|write) and + double64_(le|be)_(read|write). Hook into build and testsuite. + + * src/double64.c src/float32.c + Fix bugs in functions found by test added above. Thanks to Nicolas Castagne + for reporting this bug. + + * src/sndfile.h.in + Change time_reference_(low|high) entries of SF_BROADCAST_INFO struct to + unsigned. + + * examples/sndfile-info.c + Print out the BEXT time reference in a sensible format. + +2008-05-21 Erik de Castro Lopo + + * src/*.c + Fuzz fixes. + + * src/ogg.c + Add call to ogg_stream_clear to fix valgrind warning. + + * src/aiff.c + Fix x86_64 compile issue. + + * configure.ac src/Makefile.am src/flac.c src/ogg.c + Link to external versions of FLAC, Ogg and Vorbis. + + * tests/lossy_comp_test.c tests/ogg_test.c tests/string_test.c + tests/vorbis_test.c tests/write_read_test.tpl + Fix tests when configured with --disable-external-libs. + + * tests/external_libs_test.c tests/Makefile.am + Add new test and hook into build and test suite. + + * src/command.c + Use HAVE_EXTERNAL_LIBS to ensure that the SFC_GET_FORMAT_* commands return + the right data when external libs are disabled. + +2008-05-11 Erik de Castro Lopo + + * tests/write_read_test.tpl + Add a test for extending a file during write by seeking past the current + end of file. + + * src/sndfile.c + Allow seeking past end of file during write. + +2008-05-10 Erik de Castro Lopo + + * doc/api.html doc/command.html + Move all information about the sf_command function to command.html and add + a link from documentation of the sf_read/write_raw function to the + SFC_RAW_NEEDS_ENDSWAP command. + + * doc/index.html doc/FAQ.html doc/libsndfile.css + Minor documentation tweaks. + +2008-05-09 Erik de Castro Lopo + + * configure.ac + Add AM_PROG_CC_C_O. + +2008-04-27 Erik de Castro Lopo + + * tests/error_test.c + Add a test to make sure if file opened with sf_open_fd, and then the file + descriptor is closed, then sf_close will return an error code. Thanks to + Dave Flogeras for the bug report. + + * src/sndfile.c + Make sf_close return an error is the file descriptor is already closed. + +2008-04-19 Erik de Castro Lopo + + * configure.ac + Set object format to aout for OS/2. Thanks to David Yeo. + + * src/mpc2k.c src/sndfile.c src/sndfile.h.in src/common.h src/Makefile.am + Add ability to read MPC 2000 file. + + * tests/write_read_test.tpl tests/misc_test.c tests/header_test.tpl + tests/Makefile.am + Add tests for MPC 2000 file format. + + * examples/sndfile-convert.c + Allow conversion to MPC 2000 file format. + +2008-04-17 Erik de Castro Lopo + + * src/VORBIS/lib/codebook.c + Sync from upstream SVN. + + * autogen.sh configure.ac + Minor tweaks. + +2008-04-13 Erik de Castro Lopo + + * src/ogg.c + Add a patch that fixes finding the length in samples of an Ogg/Vorbis file. + The patch as supplied segfaulted and required many hours of debugging. + + * src/OGG/bitwise.c + Sync from upstream SVN. + +2008-04-09 Erik de Castro Lopo + + * src/aiff.c + Fix up handling of 'APPL' chunk. Thanks to Axel Röbel for bringing up + this issue. + +2008-04-06 Erik de Castro Lopo + + * tests/*.c + Add calls to sf_close() where needed. + + * tests/utils.tpl tests/multi_file_test.c + Always pass 0 as the third argument to open when OS_IS_WIN32. + +2008-04-03 Erik de Castro Lopo + + * src/test_* + Add files test_main.[ch]. + Collapse all tests into a single executable. + +2008-03-30 Erik de Castro Lopo + + * src/FLAC + Sync to upstream CVS. + +2008-03-25 Erik de Castro Lopo + + * src/common.h + Make SF_MIN and SF_MAX macros MinGW friendly. + + * examples/sndfile-(info|play).c + Use Sleep function from instead of _sleep. + + * tests/locale_test.c + Disable some tests when OS_IS_WIN32. + + * src/FLAC/src/share/replaygain_anal/replaygain_analysis.c + src/FLAC/src/share/utf8/utf8.c + MinGW fixes. + +2008-03-11 Erik de Castro Lopo + + * doc/FAQ.html + Tweaks to pcm16 <-> float conversion answer. + +2008-02-10 Erik de Castro Lopo + + * src/OGG + Sync to SVN upstream. + + * Makefile.am + Add 'DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror'. + +2008-02-05 Erik de Castro Lopo + + * examples/sndfile-jackplay.c + Minor tweaks to warning message printed when compiled without libjack. + +2008-01-27 Erik de Castro Lopo + + * tests/peak_chunk_test.c + Improve read_write_peak_test to find more errors. Inspired by example + provided by Nicolas Castagne. + + * src/aiff.c + Another SFM_RDWR fix shown up by above test. + +2008-01-24 Erik de Castro Lopo + + * src/aiff.c + Fix reading of COMM encoding string. + + * src/chunk.c src/common.h src/Makefile.am + New file for storing and retrieving info about header chunks. Hook into + build. + + * src/aiff.c + Use new chunk logging to fix problem with AIFF in RDWR mode. + +2008-01-22 Erik de Castro Lopo + + * src/command.c + Add WVE to the list of major formats. + + * tests/aiff_rw_test.c + Fix error reporting. + +2008-01-21 Erik de Castro Lopo + + * src/common.[ch] + Add internal functions str_of_major_format, str_of_minor_format, + str_of_open_mode and str_of_endianness. + + * tests/write_read_test.tpl + Fix reporting of errors in new_rdwr_XXXX_test. + +2008-01-20 Erik de Castro Lopo + + * examples/sndfile-play.c + Apply patch from Yair K. to fix compiles with OSS v4. + + * src/common.h src/float32.c src/double64.c + Rename psf->float_enswap to psf->data_endswap. + + * src/sndfile.h.in src/sndfile.c src/pcm.c + Add command SFC_RAW_NEEDS_ENDSWAP. + + * tests/command.c + Add test for SFC_RAW_NEEDS_ENDSWAP. + + * doc/command.html + Document SFC_RAW_NEEDS_ENDSWAP. + + * tests/peak_chunk_test.c + Add test function read_write_peak_test. Thanks to Nicolas Castagne for the + bug report. + +2008-01-09 Erik de Castro Lopo + + * examples/sndfile-cmp.c + Add new example program contributed by Conrad Parker. + + * examples/Makefile.am + Hook into build. + + * doc/development.html + Change use or reconfigure.mk to autogen.sh. + +2008-01-08 Erik de Castro Lopo + + * tests/win32_test.c + Add another win32 test. + + * tests/util.tpl + Add function file_length_fd which wraps fstat. + + * tests/Makefile.am + Run the multi_file_test on AU files. + + * tests/multi_file_test.c + Use function file_length_fd() instead of file_length() to overcome stupid + win32 bug. Fscking hell Microsoft sucks so much. + +2008-01-05 Erik de Castro Lopo + + * src/sd2.c + Fix a rsrc parsing bug. Example file supplied by Uli Franke. + +2007-12-28 Erik de Castro Lopo + + * doc/index.html + Allow use of either LGPL v2.1 or LGPL v3. + + * tests/header_test.tpl + Add header_shrink_test from Axel Röbel. + + * src/wav.c + Add fix from Axel Röbel for writing files with float data but no peak + chunk (ie peak chunk gets removed after the file is opened). + + * src/aiff.c tests/header_test.tpl + Apply similar fix to above for AIFF files. + + * src/wav.c tests/header_test.tpl + Apply similar fix to above for WAVEX files. + + * src/command.c + Add Ogg/Vorbis to 'get format' commands. + +2007-12-16 Erik de Castro Lopo + + * src/ogg.c + Fix seeking on multichannel Ogg Vorbis files. Reported by Bodo. + Set the default encoding quality to 0.4 instead of 4.0 (Bodo again). + + * tests/ogg_test.c + Add stereo seek tests. + +2007-12-14 Erik de Castro Lopo + + * tests/ogg_test.c + Add a test (currently failing) for stereo seeking on Ogg Vorbis files. Test + case supplied by Bodo. + + * tests/utils.(def|tpl) + Add compare_XXX_or_die functions. + +2007-12-05 Erik de Castro Lopo + + * src/aiff.c + Fix a bug where ignoring ssnd_fmt.offset and ssnd_fmt.blocksize caused + misaligned reading of 24 bit data. Thanks to Uli Franke for reporting this. + +2007-12-03 Erik de Castro Lopo + + * src/vox_adpcm.c src/ima_oki_adpcm.[ch] src/Makefile.am + Merge in code from the vox-patch branch. Thanks to Robs for the patch + which fixes a long standing bug in the VOX codec. + +2007-12-01 Erik de Castro Lopo + + * examples/sndfile-convert.c + Fix handling of -override-sample-rate=X option. + +2007-11-25 Erik de Castro Lopo + + * src/ogg.c src/VORBIS + Merge in Ogg Vorbis support from John ffitch of the Csound project. + +2007-11-24 Erik de Castro Lopo + + * src/sndfile.c + Recognise files with 'vox6' extension as 6kHz OKI VOX ADPCM files. Also + recognise 'vox8' as and 'vox' as 8kHz files. + + * configure.ac + Detect libjack (JACK Audio Connect Kit). + + * examples/sndfile-jackplay.c examples/Makefile.am + Add new example program to play sound files using the JACK audio server. + Thanks to Jonatan Liljedahl for allowing this to be included. + +2007-11-21 Erik de Castro Lopo + + * doc/index.html + Update support table with SD2 and FLAC. + +2007-11-17 Erik de Castro Lopo + + * src/sndfile.c + Fix calculation of internal value psf->read_current when attempting to read + past end of audio data. + Remove redundant code. + + * tests/lossy_comp_test.c + Add read_raw_test to check that raw reads do not go past the end of the + audio data section. + Clean up error output messages. + + * src/sndfile.c + Add code to prevent sf_read_raw from reading past the end of the audio data. + + * tests/Makefile.am + Add the wav_pcm lossy_comp_test. + +2007-11-16 Erik de Castro Lopo + + * configure.ac src/Makefile.am src/create_symbols_file.py + More OS/2 fixes from David Yeo. + +2007-11-12 Erik de Castro Lopo + + * src/file_io.c tests/utils.tpl tests/benchmark.tpl + Improve handling of requirements for O_BINARY as suggested by Ed Schouten. + +2007-11-11 Erik de Castro Lopo + + * src/common.h + Fix symbol class when SF_MIN is nested inside SF_MAX or vice versa. + + * src/create_symbols_file.py + Add support for OS/2 contributed by David Yeo. + +2007-11-05 Erik de Castro Lopo + + * M4/gcc_version.m4 + Add macro AC_GCC_VERSION to detect GCC_MAJOR_VERSION and GCC_MINOR_VERSION. + + * configure.ac + Use AC_GCC_VERSION to work around gcc-4.2 inline warning stupidity. + See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 + Use -fgnu-inline to prevent stupid warnings. + +2007-11-03 Erik de Castro Lopo + + * tests/util.tpl + Increase the printing width for print_test_name(). + + * tests/command_test.c tests/Makefile.am + Add tests for correct updating of broadcast WAV coding history. + + * examples/sndfilehandle.cc examples/Makefile.am + Add example program using the C++ SndfileHandle class. + +2007-10-29 Erik de Castro Lopo + + * src/common.h src/sndfile.c + Add error codes SFE_ZERO_MAJOR_FORMAT and SFE_ZERO_MINOR_FORMAT. + +2007-10-26 Erik de Castro Lopo + + * src/sd2.c + Identify sample-rate/sample-size/channels by resource id. + +2007-10-25 Erik de Castro Lopo + + * src/broadcast.c src/common.h src/sndfile.c + Improvements to handling of broadcast info in WAV files. Thanks to Frederic + Cornu and other for their input. + +2007-10-24 Erik de Castro Lopo + + * src/FLAC/include/share/alloc.h + Mingw fix for SIZE_T_MAX from Uli Franke. + +2007-10-23 Erik de Castro Lopo + + * tests/open_fail_test.c tests/error_test.c tests/Makefile.am + Move tests from open_fail_test.c to error_test.c and remove the former. + +2007-10-22 Erik de Castro Lopo + + * tests/scale_clip_test.(def|tpl) + Add tests for SFC_SET_INT_FLOAT_WRITE command. + + * doc/command.html + Add docs for SFC_SET_INT_FLOAT_WRITE command. + + * examples/sndfile-play.c tests/dft_cmp.c + Fix gcc-4.2 warning messages. + +2007-10-21 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c + Add command SFC_GET_CURRENT_SF_INFO. + + * src/sndfile.h.in src/sndfile.c src/create_symbols_file.py + Remove function sf_get_info (only ever in pre-release code). + + * tests/command_test.c + Add test for SFC_GET_CURRENT_SF_INFO. + +2007-10-15 Erik de Castro Lopo + + * src/wav.c + Add parsing of 'exif' chunks. Originally coded by Trent Apted. + + * configure.ac + Put config stuff in Cfg directory. + Remove check for inttypes.h. + +2007-10-10 Erik de Castro Lopo + + * src/w64.c + Fix writing of 'riff' chunk length and check for correct value in parser. + +2007-09-20 Erik de Castro Lopo + + * doc/index.html + Link to MP3 FAQ entry. + +2007-09-18 Erik de Castro Lopo + + * src/flac.c + Move the blocksize check to an earlier stage of flac_buffer_copy. + +2007-09-12 Erik de Castro Lopo + + * src/FLAC + Huge merge from FLAC upstream. + +2007-09-10 Erik de Castro Lopo + + * examples/*.c + Change license to all example programs to BSD. + +2007-09-08 Erik de Castro Lopo + + * src/FLAC/include/FLAC/metadata.h + Include to prevent compile error on OSX. + + * Octave/octave_test.sh + Disable test on OSX. Can't get it to work. + + * src/flac.c + Check the blocksize returned from the FLAC decoder to prevent buffer + overruns. Reported by Jeremy Friesner. Thanks. + +2007-09-07 Erik de Castro Lopo + + * Makefile.am M4/octave.m4 + Fix build when Octave headers are not present. + +2007-08-27 Erik de Castro Lopo + + * doc/development.html + Add note about bzr repository directory looking empty. + +2007-08-26 Erik de Castro Lopo + + * configure.ac Octave/* M4/octave_* + Bunch of changes to add ability to build GNU Octave modules to read/write + sound files using libsndfile from Octave. + +2007-08-23 Erik de Castro Lopo + + * acinclude.m4 configure.ac ... + Get rid of acinclude.m4 and replace it with an M4 directory. + +2007-08-21 Erik de Castro Lopo + + * src/sndfile.h.in + Remove crufty Metrowerks compiler support. Allow header file to be compiled + on windows with both GCC and microsoft compiler. + +2007-08-19 Erik de Castro Lopo + + * tests/dft_cmp.[ch] tests/floating_point_test.tpl + Clean up floating point tests. + +2007-08-14 Erik de Castro Lopo + + * src/aiff.c + Fix segfault when COMM chunk length is byte swapped. + +2007-08-09 Erik de Castro Lopo + + * src/common.h src/mat4.c src/mat5.c src/sndfile.c + Add a generic SFE_CHANNEL_COUNT_ZERO error, remove format specific errors. + + * src/au.c + Fix crash on AU files with zero channel count. Reported by Ben Alison. + +2007-08-08 Erik de Castro Lopo + + * src/voc.c + Fix bug in handling file supplied by Matt Olenik. + +2007-07-31 Erik de Castro Lopo + + * src/OGG + Merge from OGG upstream sources. + +2007-07-25 Erik de Castro Lopo + + * src/FLAC + Merge from FLAC upstream sources. + +2007-07-15 Erik de Castro Lopo + + * src/flac.c + Fix memory leak; set copy parameter to FALSE in call to + FLAC__metadata_object_vorbiscomment_append_comment. + + * src/common.[ch] + Add function psf_rand_int32(). + +2007-07-14 Erik de Castro Lopo + + * src/FLAC + Merge from FLAC upstream sources. + + * src/strings.c tests/string_test.c tests/Makefile.am + Make sure string tests for SF_STR_LICENSE actually works. + +2007-07-13 Erik de Castro Lopo + + * tests/string_test.c + Add ability to test strings stored in metadata secion of FLAC files. + + * src/string.c + Fix logic for testing if audio data has been written and string is added. + Make sure SF_STR_ALBUM actually works. + + * src/flac.c + Finalize reading/writing string metadata. Tests pass. + + * src/sndfile.h.in tests/string_test.c src/flac.c + Add string type SF_STR_LICENSE, update test and use for FLAC files. + + * src/sndfile.h.in + Add definition for SFC_SET_SCALE_FLOAT_INT_WRITE command. + + * src/common.h src/double64.c src/float32.c src/sndfile.c + Add support for SFC_SET_SCALE_FLOAT_INT_WRITE (still needs testing). + +2007-07-12 Erik de Castro Lopo + + * src/flac.c + Apply patch from Ed Schouten to read artist and title metadata from FLAC + files. + Improve reporting of FLAC metadata. + + * src/sndfile.h.in tests/string_test.c src/flac.c + Add string type SF_STR_ALBUM, update test and use for FLAC files. + +2007-06-28 Erik de Castro Lopo + + * src/FLAC/* + Merge from upstream CVS. + +2007-06-16 Erik de Castro Lopo + + * src/FLAC/* + Update from upstream CVS. + +2007-06-14 Erik de Castro Lopo + + * tests/cpp_test.cc + Add extra tests for when the SndfileHandle constructor fails. + + * src/sndfile.hh + Make sure failure to open the file in the constructor does not allow later + calls to other methods to fail. + +2007-06-10 Erik de Castro Lopo + + * tests/util.tpl + Add function write_mono_file. + + * tests/generate.[ch] tests/Makefile.am + Add files generate.[ch] and hook into build. + + * tests/write_read_test.tpl + Add multi_seek_test. + + * src/flac.c + Fix buffer overflow bug. Test provided by Jeremy Friesner and fix provided + by David Viens. + +2007-06-07 Erik de Castro Lopo + + * doc/FAQ.html + Minor update. + + * configure.ac src/FLAC/src/libFLAC/ia32/Makefile.am src/Makefile.am + Apply patch from Trent Apted make it compile on Intel MacOSX. Thanks Trent. + +2007-05-28 Erik de Castro Lopo + + * src/wav.c + Fix writing of MSGUID subtypes. Thanks to Bruce Sharpe. + +2007-05-22 Erik de Castro Lopo + + * src/wav.c + Fix array indexing bug raised by Bruce Sharpe. + +2007-05-12 Erik de Castro Lopo + + * src/FLAC/src/share/getopt/getopt.c + Fix Mac OSX / PowerPC compile warnings. + + * configure.ac + Make sure WORDS_BIGENDIAN gets correctly defined for FLAC code. + +2007-05-04 Erik de Castro Lopo + + * doc/FAQ.html + Add Q/A about MP3 support. + +2007-05-03 Erik de Castro Lopo + + * doc/new_file_type.HOWTO + Minor updates. + +2007-05-02 Erik de Castro Lopo + + * src/wve.c + Fix a couple bad parameters with psf_log_printf. + + * src/pcm.c + Improve error reporting. + + * src/common.h src/common.c + Constify psf_hexdump. + +2007-04-30 Erik de Castro Lopo + + * src/FLAC + Ditch and re-import required FLAC code. + + * configure.ac + Force FLAC__HAS_OGG variable to 1. + + * src/FLAC/src/libFLAC/stream_encoder.c + Fix compiler warnings. + +2007-04-23 Erik de Castro Lopo + + * configure.ac tests/win32_ordinal_test.c + Detect if win32 DLL is beging generated and only run win32_ordinal_test if + true. + + * src/G72x/Makefile.am src/Makefile.am + Use $(EXEEXT) where possible. + +2007-04-18 Erik de Castro Lopo + + * src/wve.c src/common.h src/sndfile.c + Complete definition of SfE_WVE_NO_WVE error message. + + * src/wve.c + Fix error in files generated on big endian systems. Robustify parsing. + +2007-04-16 Erik de Castro Lopo + + * src/double64.c + Fix clipping of double to short conversions on 64 bit systems. + + * src/flac.c regtest/database.c tests/cpp_test.cc + Fix compile warnings for 64 bit systems. + +2007-04-15 Erik de Castro Lopo + + * src/wav.c src/wav_w64.c + Use audio detect function when 'fmt ' chunk data is suspicious. + + * configure.ac + Add ugly hack to remove -Werror from some Makefiles. + +2007-04-14 Erik de Castro Lopo + + * src/GSM610/long_term.c src/macbinary3.c tests/cpp_test.cc + Add patch from André Pang to clean up compiles on OSX. + + * src/wve.c src/common.h src/sndfile.c src/sndfile.h.in + examples/sndfile-convert.c + Merge changes from Reuben Thomas to improve WVE support. + + * tests/lossy_comp_test.c tests/Makefile.am + Add tests for WVE files. + +2007-04-11 Erik de Castro Lopo + + * src/sndfile.hh + Add a static SndfileHandle::formatCheck method as suggested by Jorge + Jiménez. + +2007-04-09 Erik de Castro Lopo + + * src/sndfile.c + Fixed a bug in sf_error() where the function itself was being compared + against zero. Add a check for a NULL return from peak_info_calloc. Fix a + possible NULL dereference. + +2007-04-07 Erik de Castro Lopo + + * src/flac.c + Turn off seekable flag when writing, return SFE_BAD_RDWR_FORMAT when + opening file for RDWR. + + * src/sndfile.c + Improve error message for SFE_BAD_RDWR_FORMAT. + + * src/mat4.c + Fix array indexing issue. Thanks to Ben Allison (Nullsoft) for alerting me. + +2007-03-05 Erik de Castro Lopo + + * doc/FAQ.html + Add Q/A 19 on project files. + +2007-03-01 Erik de Castro Lopo + + * src/sndfile.c + Guard agains MacOSX universal binary compiles. + + * doc/FAQ.html + Add Q/A 18 and clean up Q3. + +2007-02-22 Erik de Castro Lopo + + * src/aiff.c + Add support for 'in24' files. + +2007-02-13 Erik de Castro Lopo + + * src/wav.c src/wav_w64.c src/wav_w64.h + Start work towards detecting ausio codec type from the actual audio data. + + * src/audio_detect.c src/test_audio_detect.c + Add new file and its unit test. + +2007-02-07 Erik de Castro Lopo + + * examples/cooledit-fixer.c examples/Makefile.am + Remove old broken example program. + +2007-02-06 Erik de Castro Lopo + + * src/sndfile.c src/sndfile.h.in src/create_symbols_file.py + Add function sf_get_info. + +2007-01-25 Erik de Castro Lopo + + * examples/sndfile-play.c + For ALSA, use the 'default' device instead of 'plughw:0'. + +2007-01-22 Erik de Castro Lopo + + * src/sndfile.c + Allow writing of WAV/WAVEX 'BEXT' chunks in SFM_RDWR mode. + +2007-01-21 Erik de Castro Lopo + + * doc/development.html doc/embedded_files.html man/sndfile-play.1 + Minor documentation fixes. Thanks Reuben Thomas. + +2006-12-16 Erik de Castro Lopo + + * examples/sndfile-convert.c + Add -override-sample-rate command line option. + +2006-11-19 Erik de Castro Lopo + + * tests/misc_test.c + Force errno to zero at start of some tests. + + * src/sndfile.c + Minor clean up of error handling. + + * configure.ac + Remove an assembler test which was failing on OSX. + +2006-11-15 Erik de Castro Lopo + + * src/common.h + Fix the definition of SF_PLATFORM_S64 for MinGW. + + * src/FLAC/Makefile.am src/FLAC/share/grabbag/Makefile.am + Fix path problems for MinGW. + +2006-11-13 Erik de Castro Lopo + + * src/sfendian.h + Add include guard. + + * src/Makefile.am src/flac.c + Clean up include paths. + + * src/test_conversions.c + New file to test psf_binheader_readf/writef functions. + + * src/Makefile.am src/test_file_io.c src/test_log_printf.c src/common.c + Clean up unit testing. + + * src/common.c + Fix a bug reading/writing 64 bit header fields. Thanks to Jonathan Woithe + for reporting this. + + * src/test_conversions.c + Complete unit test for above fix. + +2006-11-11 Erik de Castro Lopo + + * src/sndfile.c + More refactoring to clean up psf_open_file() and vairous sf_open() + functions. + +2006-11-09 Erik de Castro Lopo + + * src/wav.c + Apply a patch from Jonathan Woithe to allow opening of (malformed) WAV + files of over 4 gigabytes. + +2006-11-05 Erik de Castro Lopo + + * src/sndfile.c + Refactor function psf_open_file() to provide a single return point. + + * tests/misc_test.c + Fix permission_test to ensure that read only file can be created. + +2006-11-03 Erik de Castro Lopo + + * src/common.h + Add SF_PLATFORM_S64 macro as a platform independant way of doing signed 64 + bit integers. + + * src/aiff.c src/svx.c src/wav.c + Add warning in log if files are larger than 4 gigabytes in size. + +2006-11-01 Erik de Castro Lopo + + * src/FLAC src/OGG confgure.ac src/Makefile.am + Pull in all required FLAC and OGG code so external libraries are not + needed. This makes compiling on stupid fscking Windoze easier. + +2006-10-27 Erik de Castro Lopo + + * src/sd2.c + Add workaround for switched sample rate and sample size. + + * src/wav.c + Add workaround for excessively long coding history in the 'bext' chunk. + +2006-10-23 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c src/wav.c doc/command.html + Use SF_AMBISONIC_* instead of SF_TRUE/SF_FALSE. + +2006-10-22 Erik de Castro Lopo + + * src/sndfile.h.in src/wav.c src/wav_w64.c src/common.h doc/command.html + Apply a patch from Fons Adriaensen to allow writing on WAVEX Ambisonic + files. Still needs a little tweaking before its ready for release. + + * src/*.c + Use the UNUSED macro to prevent compiler warnings. + +2006-10-19 Erik de Castro Lopo + + * src/aiff.c + Fix a bug in parsing AIFF files with a slightly unusual 'basc' chunk. Thanks + to David Viens for providing two example files. + + * src/common.(c|h) src/aiff.c + Add a function psf_sanitize_string and use it in aiff.c. + +2006-10-18 Erik de Castro Lopo + + * src/wav_w64.c + Apply a patch from Fons Adriaensen which fixes a minor WAVEX GUID issue. + +2006-10-17 Erik de Castro Lopo + + * src/Makefile.am + Fix problem related to recent test coverage changes. + +2006-10-15 Erik de Castro Lopo + + * configure.ac tests/Makefile.am + Add --enable-test-coverage configure option. + +2006-10-05 Erik de Castro Lopo + + * src/sndfile.hh + Add an std::string SndfileHandle constructor. + + * tests/scale_clip_test.tpl + Fix the 'make distcheck' target. + +2006-10-03 Erik de Castro Lopo + + * src/double64.c src/float32.c + Add optional clipping on float file data to int read data conversions. + + * tests/tests/scale_clip_test.(def|tpl) + Add test for above new code. + +2006-09-06 Erik de Castro Lopo + + * tests/aiff_rw_test.c + Add 'MARK' chunks to make sure they are parsed correctly. + +2006-09-05 Erik de Castro Lopo + + * src/aiff.c + Fix parsing of MARK chunks. Many thanks to Sciss for generating files to + help debug the problem. + +2006-09-02 Erik de Castro Lopo + + * src/common.h + Make the SF_MIN and SF_MAX macros at least partially type safe. + + * tests/lossy_comp_test.c + Fix overflow problems when ensuring that signalis not zero. + +2006-08-31 Erik de Castro Lopo + + * configure.ac docs/*.html + Changes for release 1.0.17. + +2006-08-08 Erik de Castro Lopo + + * src/flac.c + Remove inline from functions called by pointer. Thanks to Sampo Savolainen + for notifying me of this. + +2006-07-31 Erik de Castro Lopo + + * src/sndfile.hh + Add writeSync method. + Add copy constructor and assignment operator (thanks Daniel Schmitt). + Add methods readRaw and writeRaw. + Make read/write/readf/writef simple overlaods instead of templates (thanks + to Trent Apted for suggesting this). + + * tests/cpp_test.cc + Cleanup. Add tests. + +2006-07-30 Erik de Castro Lopo + + * src/sndfile.hh + Templatize the read/write/readf/writef methods as suggested by Lars Luthman. + Prevent the potential leak of SNDFILE* pointers in the openRead/openWrite/ + openReadWrite methods. + Add const to SF_INFO pointer in Sndfile constructor. + Make the destrictor call the close() method. + + * tests/cpp_test.cc + Add more tests. + +2006-07-29 Erik de Castro Lopo + + * tests/cpp_test.cc + Remove the generated file so "make distcheck" passes. + + * src/Makefile.am + Add sndfile.hh to distributed header files. + + * src/sndfile.hh + Change the license for the C++ wrapper to modified BSD. + +2006-07-28 Erik de Castro Lopo + + * src/sndfile.hh + Complete it. + + * tests/cpp_test.cc + Add more tests. + +2006-07-27 Erik de Castro Lopo + + * tests/utils.tpl + Add extern C to generated header file. + + * src/sndfile.hh + Work towards completing this. + + * tests/cpp_test.cc tests/Makefile.am + Add a C++ test and hook into build. + + * configure.ac + Add appropriate CXXFLAGS. + +2006-07-26 Erik de Castro Lopo + + * configure.ac + Test if compiler supports -Wpointer-arith. + + * src/common.c + Fix a warning resulting from -Wpointer-arith. + +2006-07-15 Erik de Castro Lopo + + * examples/sndfile-play.c + Explicitly set endian-ness as well as setting 16 bit output. + + * examples/sndfile-info.c + Make sure to parse info if file fails to open. + + * src/sndfile.c + Handle parse error a little better. + + * src/wav_w64.[ch] + Minor clean up, add detection of IPP ITU G723.1. + +2006-06-23 Erik de Castro Lopo + + * src/sndfile.c + Make sure psf->dataoffset gets reset to zero when openning headersless + files based on the file name extension. + +2006-06-21 Erik de Castro Lopo + + * tests/(command|lossy_comp|pcm|scale_clip)_test.c tests/fix_this.c + tests/write_read_test.(tpl|def) + Fix gcc-4.1 compiler warnings about "dereferencing type-punned pointer will + break strict-aliasing rules". + + * examples/cooledit-fixer.c + More fixes like above. + +2006-06-20 Erik de Castro Lopo + + * src/file_io.c + Fix a windows bug where the syserr string of SF_PRIVATE was not being set + correctly. + + * src/sndfile.c + Fixed a logic bug in sf_seek(). Thanks to Paul Davis for finding this. + +2006-06-04 Erik de Castro Lopo + + * configure.ac + Fixed detection of S_IRGRP. + +2006-05-30 Erik de Castro Lopo + + * sndfile-convert.c + Add conversion SF_INSTRUMENT data when present. + +2006-05-22 Erik de Castro Lopo + + * doc/development.html + Removed references to tla on windows. + + * src/common.h src/sndfile.c + Add separate void pointers for file containter and file codec data to + SF_PRIVATE struct. Still need to move all existing fdata pointers. + + * tests/write_read_test.tpl + Change the order of some tests. + + * src/aiff.c + When writing 'AIFC' files, make sure get an 'FVER' gets added. + + * src/common.h src/(dwvw|flac|g72x|gsm610|ima_adpcm|ms_adpcm|paf|sds).c + src/(sndfile|voc|vox_adpcm|xi).c + Remove fdata field from SF_PRIVATE struct and replace it with codec_data. + +2006-05-10 Erik de Castro Lopo + + * Win32/testprog.c Win32/Makefile.am + Add a minimal win32 test program. + + * Win32/README-precompiled-dll.txt Mingw-make-dist.sh + Update readme and Mingw build script. + +2006-05-09 Erik de Castro Lopo + + * configure.ac acinclude.m4 + Minor fixes for Solaris. + +2006-05-05 Erik de Castro Lopo + + * src/test_endswap.(def|tpl) + Fix printf formatting for int64_t on 64 bit machines. + +2006-05-04 Erik de Castro Lopo + + * src/binhead_check.py + New file to check for bad parameters passed to psf_binheader_writef(). + + * src/Makefile.am + Hook into test suite. + + * src/voc.c src/caf.c src/wav.c src/mat5.c src/mat4.c + Fix bugs found by new test program. + + * src/double64.c + Clean up double64_get_capability(). + +2006-05-03 Erik de Castro Lopo + + * src/wav_w64.c + Fix a bug on x86_64 where an int was being passed via stdargs and being + read using size_t which is 64 bits. Thenks to John ffitch for giving me a + login on his box. + +2006-05-02 Erik de Castro Lopo + + * src/caf.c src/double64.c examples/sndfile-info.c tests/virtual_io_test.c + tests/utils.tpl + Fix a couple of signed/unsigned problems. + +2006-05-01 Erik de Castro Lopo + + * tests/command_test.c + Add channel map tests. + + * src/common.h src/sndfile.c + Add a pointer to the SF_PRIVATE struct and make sure it gets freed in + sf_close(). + +2006-04-30 Erik de Castro Lopo + + * configure.ac doc/(command|index|api).html NEWS README + Updates for 1.0.16 release. + + * src/sndfile.h.in + Define enums for channel mapping. + + * examples/sndfile-info.c + Clean up usage of SF_INFO struct. + +2006-04-29 Erik de Castro Lopo + + * tests/util.tpl + Add function testing function exit_if_true(). + + * tests/floating_point_test.tpl + Fix a problem where the test program was not exiting when the test failed. + +2006-04-15 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c src/common.h src/command.c + Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS. + + * doc/commands.html + Document new commands. Other minor updates. + + * tests/peak_chunk_test.c + Update tests for new commands. + +2006-04-02 Erik de Castro Lopo + + * tests/peak_chunk_test.c + Add test for RIFX and WAVEX files. + Try and confuse the PEAK chunk writing by enabling and disabling it. + + * src/sndfile.c + Fix a bug where enabling and disabling PEAK chunk was screwing up. + +2006-03-31 Erik de Castro Lopo + + * src/sndfile.h.in + Add the block of 190 reserved bytes into this struct to allow for + future expansion. + + * src/wav.c src/sndfile.c src/broadcast.c + Significant cleanup of broadcast wave stuff. + + * examples/sndfile-info.c + Fix print message. + + * tests/command_test.c tests/Makefile.am + Complete bext tests, hook test in test suite. + +2006-03-30 Erik de Castro Lopo + + * src/sndfile.h.in + Make coding_history field of SF_BROADCAST_INFO struct a char array instead + of a char pointer. + + * src/sndfile.c src/common.h src/wav.c + Clean up knock on effects of above chnage. + + * examples/sndfile-info.c + Add -b command line option to usage message. + Clean up output of broadcast wave info. + + * src/wav.c + Ignore and skip the 'levl' chunk. + +2006-03-26 Erik de Castro Lopo + + * configure.ac + Fix handling of --enable and --disable configure args. Thanks to Diego + 'Flameeyes' Pettenò who sent the patch. + +2006-03-22 Erik de Castro Lopo + + * doc/win32.html + Make it really clear that although the MSVC++ cannot compile libsndfile, + the precompiled DLL can be used in C++ programs compiled with MSVC++. + +2006-03-18 Erik de Castro Lopo + + * src/aiff.c + Fix bug in writing of INST chunk in AIFF files. + Fix potential bug in writing MARK chunks. + + * src/sndfile.c + Make sure the instrument chunk can only be written at the start of the file. + + * tests/command_test.c + Add check of log buffer. + + * tests/utils.tpl + Add usage of space character to psf_binheader_writef. + +2006-03-17 Erik de Castro Lopo + + * src/Makefile.am tests/Makefile.am + Remove --source-time argument from autogen command lines. + + * src/broadcast.c + New file for EBU Broadcast chunk in WAV files. + + * src/sndfile.c src/sndfile.h.in src/wav.c src/common.h + Add patch from Paul Davis implementing read/write of the BEXT chunk. + +2006-03-16 Erik de Castro Lopo + + * Win32/README-precompiled-dll.txt + New file descibing how to use the precompiled DLL. + + * Win32/Makefile.am + Add Win32/README-precompiled-dll.txt to EXTRA_DIST files. + + * configure.ac + Bump version to 1.0.15. + +2006-03-11 Erik de Castro Lopo + + * src/wav.c + On read, only add the endian flag if the file is big endian. + + * src/ms_adpcm.c + Fixed writing of APDCM coeffs in RIFX files. + + * tests/write_read_test.tpl tests/lossy_comp_test.c + Add tests for RIFX files. + +2006-03-10 Erik de Castro Lopo + + * Mingw-make-dist.sh + Bunch of improvements. + + * doc/win32.html + Update MinGW program versions. + +2006-03-09 Erik de Castro Lopo + + * src/create_symbols_file.py + Fix the library name in created win32 DEF file. Add correct DLL name for + Cygwin DLL. + + * Win32/Makefile.am tests/Makefile.am + Remove redundant files, add win32_ordinal_test to test suite. + + * tests/win32_ordinal_test.c + Update to do test in cygsndfile-1.dll as well. + + * doc/win32.html + Fix typo, mention that -mno-cygwin with the Cygwin compiler does not work. + + * src/wav.c src/wav_w64.c src/sndfile.c src/sndfile.h.in + Apply large patch from Jesse Chappell which adds support for RIFX files. + +2006-03-08 Erik de Castro Lopo + + * Makefile.am + Add Mingw-make-dist.sh to the extra dist files. + + * configure.ac + Fix setting SHLIB_VERSION_ARG for MinGW. + + * tests/win32_ordinal_test.c + New test program to test that the win32 DLL ordinals agree with the DEF + file. + +2006-03-04 Erik de Castro Lopo + + * src/common.h + Add a static inline function to convert an int to a size_t. This will be + a compile to nothing on 32 bit CPUs and a sign extension on 64 bit CPUs. + + * src/aiff.c src/avr.c src/common.c src/xi.c src/gsm610.c + Fix an ia64 problem where a varargs function was being passed an int in + some places and a size_t in other places. + + * src/sd2.c + Add a workaround for situations where OSX seems to add an extra 0x52 bytes + to the start of the resource fork. + +2006-02-19 Erik de Castro Lopo + + * Mingw-make-dist.sh + Add a shell script to build the windows binary/source ZIP file. + + * doc/index.html + Add download link for windows binary/source ZIP file. Add links for GPG + signatures. + + * doc/win32.html + Remove info about building using microsoft compiler. + + * configure.ac + Bump version to 1.0.14. + +2006-02-11 Erik de Castro Lopo + + * src/sd2.c + Improve logging of errors in resource fork parser. + +2006-01-31 Erik de Castro Lopo + + * Win32/Makefile.msvc + Replace au_g72x.* with g72x.*. Thanks to ussell Borogove. + +2006-01-29 Erik de Castro Lopo + + * src/common.c + Make sure return values are initialised header buffer is full. + + * src/wav.c + Add workarounds for messed up WAV files. + +2006-01-21 Erik de Castro Lopo + + * Win32/config.h + Undef HAVE_INTTYPES_H for win32. + + * tests/command_test.c + Don't exit on error in instrument test for XI files. + + * configure.ac + Bump version to 1.0.13. + + * doc/*.html NEWS README + Update version numbers. + +2006-01-19 Erik de Castro Lopo + + * src/xi.c + Start work on add read/write of instrument chunks. + + * src/command_test.c + Add tests for XI instrument chunk. + + * tests/largefile_test.c tests/Makefile.am + Add new test and hook it into the build system. This test will not be run + automatically because it requires 3 Gig of disk space and takes 3 minutes + to run. + +2006-01-10 Erik de Castro Lopo + + * examples/sndfile-play.c + Fix calculation of samples remaining in win32 code. Thanks Axel Röbel. + + * src/common.h + Make sure length of header buffer can hold header plus strings. Thanks Axel + Röbel. + +2006-01-09 Erik de Castro Lopo + + * src/sndfile.h.in src/aiff.c src/wav.c + Apply a patch from John ffitch (Csound project). + Add detune field to SF_INSTRUMENT struct. + Add reading/writing instrument chunks to WAV files. + + * tests/command_test.c + Update SF_INSTRUMENT tests. + + * tests/Makefile.am + Hook instrument tests into test suite. + +2006-01-05 Erik de Castro Lopo + + * configure.ac + Check for because some broken systems (like Solaris) don't have + which is the 1999 ISO C standard file containing int64_t. + + * src/sfendian.h src/common.h + Use if is not available. + +2005-12-30 Erik de Castro Lopo + + * tests/peak_chunk_test.c + Extend and clean up tests. + + * src/sndfile.c + Fix a bug that prevented the turning off of PEAK chunks. + +2005-12-29 Erik de Castro Lopo + + * tests/error_test.c + Make the test distclean correct. + + * src/file_io.c + Fix an SD2 MacOSX bug (reported by vince schwarzinger). + +2005-12-28 Erik de Castro Lopo + + * src/aiff.c tests/command_test.c + Apply a big patch from John ffitch (Csound project) to add reading and + writing of instrument chunks to AIFF files. Also update the test. + +2005-12-10 Erik de Castro Lopo + + * tests/aiff_rw_test.c tests/virtual_io_test.c tests/utils.tpl + Move test function dump_data_to_file() to utils.tpl. + + * tests/error_test.c tests/Makefile.am + Updates, including a new test to test that sf_error() returns a valid error + number. + +2005-12-07 Erik de Castro Lopo + + * examples/list_formats.c + Make sure the SF_INFO struct is memset to all zero before being used. + Thanks to Stephen F. Booth. + + * src/sndfile.c + Make the return value of sf_error() match the API documentation. + +2005-11-19 Erik de Castro Lopo + + * examples/sndfile-convert.c + Allow conversion to raw gsm610. + + * src/common.h src/sndfile.c src/au.c + Remove au_nh_open() and all references to it (wasn't working anyway). + + * tests/headerless_test.c + Add new test for file extension based detection. + + * src/sndfile.c + Rejig file extension based file type detection. + +2005-11-16 Erik de Castro Lopo + + * src/sndfile.c + Add "gsm" as a recognised file extension when no magic number can be found. + + * tests/lossy_comp_test.c tests/Makefile.am + Test headerless GSM610. + +2005-11-13 Erik de Castro Lopo + + * doc/api.html + Fix a minor typo and a minor error. Thanks Christoph Kobe and John Pavel. + +2005-10-30 Erik de Castro Lopo + + * src/wav_w64.c + Add more reporting of 'fmt ' chunk for G721 encoded files. + + * src/wav.c + Gernerate a more correct 20 byte 'fmt ' chunk rather than a 16 byte one. + +2005-10-29 Erik de Castro Lopo + + * src/G72x/g72x.[ch] + Minor cleanup of interface. + +2005-10-28 Erik de Castro Lopo + + * src/ogg.c + Removed the horribly broken and non-functional OGG implementation when + --enable-experimental was enabled. When OGG does finally work it will be + merged. + + * src/caf.c + Fix a memory leak. + +2005-10-27 Erik de Castro Lopo + + * src/g72x.c src/G72x/*.(c|h) src/common.h src/sndfile.c src/wav.c src/au.c + Add support for G721 encoded WAV files. + + * doc/index.html + Update support matrix. + + * tests/lossy_comp_test.c + For file formats that support it, add string data after the audio data and + make sure it isn't treated as audio data on read. + + * src/gsm610.c + Add code to ensure that the container close function (ie for WAV files) gets + called after the codec's close function. This allows GSM610 encoded WAV files + to have string data following the audio data. + Add an AIFF specific check on psf->datalength. + + * src/wav.c + Simplify wav_close function. + + * src/aiff.c + Make sure the tailer data gets written at an even file offset. Pad if + necessary. + + * src/common.h + Replace the close function pointer in SF_PRIVATE with separate functions + codec_close and container_close. The former is always called first. + + * src/*.c + Fix knock on effects of above. + +2005-10-26 Erik de Castro Lopo + + * examples/sndfile-info.c + Complete dumping SF_INSTRUMENT data. + + * src/dwvw.c src/ima_adpcm.c src/gsm610.c src/ms_adpcm.c + Add extra checks in *_init function. + + * tests/lossy_comp_test.c + Add a string comment to the end of the files to make sure that the decoder + doesn't decode beyond the end of the audio data section. + +2005-10-25 Erik de Castro Lopo + + * examples/sndfile-info.c + Minor code cleanup. + Start work on dumping SF_INSTRUMENT data. + +2005-10-23 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/common.c + Update definition of SF_INSTRUMENT struct and create a function to allocate + and initialize the struct (input from David Viens). + Clean up definition of SF_INSTRUMENT struct. + + * src/wav.c src/wav_w64.c + Add support for Ambisoncs B WAVEX files (David Viens). + + * src/aiff.c src/wav.c src/wav_w64.c + Start work on reading/writing the SF_INSTRUMENT data. + + * src/sndfile.c + Add code to get and set SF_INSTRUMENT data. + + * tests/command_test.* tests/Makefile.am + Add test for set and getof SF_INSTRUMENT data. + The file command_test.c is no longer autogen generated. + +2005-10-15 Erik de Castro Lopo + + * src/gsm610.c + Minor cleanup. + +2005-10-14 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Minor cleanup. + +2005-10-13 Erik de Castro Lopo + + * src/*.c + Ensure sfconfig.h is included before any other header file. + + * src/file_io.c + Add comments documenting the three sections of the file. + + * src/gsm610.c + Make sure SF_FORMAT_WAVEX are handled correctly. + +2005-10-07 Erik de Castro Lopo + + * configure.ac + Add options to allow disabling of FLAC and ALSA. Suggested by Ben Greear. + +2005-09-30 Erik de Castro Lopo + + * tests/locale_test.c + Modify the way the unicode strings were encoded so that older compilers + do not complain. Thanks Axel Röbel. + + * configure.ac + Bump the version to 1.0.12 for release. + + * NEWS README Win32/config.h doc/(FAQ|index.html|command|api).html + Update version numbers. + +2005-09-26 Erik de Castro Lopo + + * src/flac.c + Fix valgrind error and minor cleanup. + +2005-09-25 Erik de Castro Lopo + + * src/(au|paf|aiff|w64|wav|svx).c + Make sure structs are initialised. + +2005-09-24 Erik de Castro Lopo + + * configure.ac + Make -Wdeclaration-after-statement work with --enable-gcc-werror configure + option. + Add -std=gnu99 (C99 plus posix style stuff like gmtime_r) to CFLAGS if the + compiler supports it. + +2005-09-23 Erik de Castro Lopo + + * configure.ac acinclude.m4 + Add -Wdeclaration-after-statement to CFLAGS if the compilers supports it. + +2005-09-22 Erik de Castro Lopo + + * tests/util.(tpl|def) + Make the test_write_*_or_die() functions const safe. + +2005-09-21 Erik de Castro Lopo + + * src/nist.c + Make sure the data offset is read from the file header. Thanks to + David A. van Leeuwen for a patch. + +2005-09-20 Erik de Castro Lopo + + * configure.ac src/sfconfig.h + Check for and the function setlocale(). + Set config variables to zero if not found. + + * tests/locale_test.c tests/Makefile.am + Add new test program and hook into build/test system. + +2005-09-18 Erik de Castro Lopo + + * src/common.h src/file_io.c + On windows, use windows specific types for file handles. + Add functions psf_init_files() and psf_use_rsrc(). + + * src/sd2.c + Make resource fork handling independant of file desciptor/handles. + + * src/sndfile.c src/test_file_io.c + Fix knock on effects. + +2005-09-06 Erik de Castro Lopo + + * src/float_cast.h + The lrint and lrintf implementations in Cygwin are both buggy and slow. + Add replacements which were pulled from the Public Domain MinGW math.h + header file. + +2005-09-05 Erik de Castro Lopo + + * tests/(lossy_comp_test|virtual_io_test).c + More Valgrind fixups. + + * configure.ac + Simplify and correct configuring for Cygwin. + + * Win32/config.h Win32/sndfile.h Win32/Makefile.msvc + Update build for MSVC. + +2005-09-04 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Make sure to close SNDFILE when exiting test when file format is not seekable. + + * tests/(aiff_rw_test|virtual_io_test).c + Do a few valgrind fix ups. + +2005-09-03 Erik de Castro Lopo + + * src/float32.c src/double64.c + Replace floating point equality comparisons with greater/less comparisons. + Found by John Pavel using the Intel compiler. + + * src/sfconfig.h + New file to clean up issues surrounding autoconf generated preprocessor + symbols. + + * src/*.(c|h) tests/*.(c|tpl) examples/*.c + Fixed a bunch of other stuff found by John Pavel using the Intel compiler. + + * src/file_io.c + Remove Mac OS9 Metrowerks compiler specific hacks. + +2005-08-31 Erik de Castro Lopo + + * src/w64.c + Cast integer literal to sf_count_t in call to psf_binheader_writef() to + prevent Valgrind error. + +2005-08-30 Erik de Castro Lopo + + * doc/command.html + Improve documentation of SF_GET_FORMAT_SUBTYPE. + +2005-08-26 Erik de Castro Lopo + + * examples/sndfile-convert.c + Allow files to be converted to SD2 format. + + * src/sd2.c + Fix a bug in reading and writing of SD2 files on little endian CPUs. + Thanks to Matthew Willis for finding this. + +2005-08-25 Erik de Castro Lopo + + * doc/api.html + Update Note2 to point to SFC_SET_SCALE_FLOAT_INT_READ. + +2005-08-16 Erik de Castro Lopo + + * configure.ac + Use $host_os instead of $target_os (thanks to Mo De Jong). + +2005-08-15 Erik de Castro Lopo + + * src/Makefile.am + Apply a patch from Mo DeJong to allow building outside of the source dir. + + * src/file_io.c + Fix psf_fsync() for win32. + + * src/wav.c src/wav_w64.(c|h) + Move some code from wav.c to wav_w64.c to improve the log output of files of + type WAVE_FORMAT_EXTENSIBLE. + +2005-08-10 Erik de Castro Lopo + + * src/create_symbols_file.py + Make sure sf_write_fsync is an exported symbol. + + * examples/sndfile-convert.c + Add support for writing VOX adpcm files. + +2005-07-31 Erik de Castro Lopo + + * doc/api.html + Document the new function sf_write_sync(). + + * doc/FAQ.html + Do you plan to support XYZ codec. + +2005-07-28 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c + Add function sf_write_sync() to the API. + + * src/common.h src/file_io.c + Low level implementation (win32 not done yet). + + * tests/write_read_test.tpl + Use the new function in the tests. + +2005-07-24 Erik de Castro Lopo + + * src/common.h src/double64.c src/float32.c src/sndfile.c + Change the way PEAK chunk info is stored. Peaks now stored as an sf_count_t + for position and a double as the value. + + * src/aiff.c src/caf.c src/wav.c + Fix knock on effects of above changes. + + * src/caf.c + Implement 'peak' chunk for file wuth data in SF_FORMAT_FLOAT or + SF_FORMAT_DOUBLE format. + +2005-07-23 Erik de Castro Lopo + + * src/nist.c + Fix a bug where a variable was being used without being initialized. + + * src/flac.c + Add extra debug in sf_flac_meta_callback. + Make a bunch of private functions static. + + * src/aiff.c src/wav.c + Fix allocation for PEAK_CHUNK (bug found using valgrind). + +2005-07-21 Erik de Castro Lopo + + * src/common.h + Move the peak_loc field of SF_PRIVATE to the PEAK_CHUNK struct. + Remove had_peak field of SF_PRIVATE, use pchunk != NULL instead. + Rename PEAK_CHUNK and PEAK_POS to PEAK_CHUNK_32 and PEAK_POS_32. + + * src/aiff.c src/caf.c src/wav.c src/float32.c src/double64.c + Fix knock on effects from above. + +2005-07-19 Erik de Castro Lopo + + * src/wav.c + Prevent files with unknown chunks from being opened read/write. + +2005-07-14 Erik de Castro Lopo + + * src/flac.c + Do not use psf->end_of_file because it never gets set to anything. + + * src/common.h + Remove unused SF_PRIVATE field end_of_file. + +2005-07-12 Erik de Castro Lopo + + * src/common.c + Change the 'S' format specifier of psf_binheader_writef() to write AIFF + style strings (no terminating character). + + * src/aiff.c + Move to new (correct) AIFF string style. Thanks to Axel Röbel for being + so persistent on this issue. + +2005-07-11 Erik de Castro Lopo + + * src/sndfile.c + Allow SFE_UNSUPPORTED_FORMAT as an error from sf_open(). + + * doc/api.html doc/command.html + Documentation updates (thanks to Kyroz for promoting these updates). + + * src/mat5.c + Modify the way the header is written. + +2005-07-10 Erik de Castro Lopo + + * src/caf.c + Add a 'free' chunk to the written file so that the audio data starts at + an offset of 0x1000. + + * src/sndfile.c + Allow SFE_UNSUPPORTED_FORMAT as an error from sf_open(). + +2005-07-09 Erik de Castro Lopo + + * src/caf.c src/sndfile.c + Add support for signed 8 bit integers. + + * tests/write_read_test.tpl + Add test for signed 8 bit integers in CAF files. + + * doc/index.html + Update matrix for signed 8 bit integers in CAF files. + +2005-07-08 Erik de Castro Lopo + + * src/sndfile.c + Update sf_check_format() to support CAF. + + * examples/sndfile-convert.c + Add support for ".caf" file extension. + + * doc/index.html + Add Apple CAF to the support matrix. + + * src/caf.c + Add file write support. + + * src/common.c + Fix printing of Frames. + + * tests/Makefile.am tests/write_read_test.tpl tests/lossy_comp_test.c + tests/header_test.tpl misc_test.c + Add tests for CAF files. + +2005-07-07 Erik de Castro Lopo + + * doc/FAQ.html + Fix Q/A about reading/writing memory buffers. + + * src/caf.c + Bunch of work to support reading of CAF files. + +2005-07-04 Erik de Castro Lopo + + * src/(aiff|ima_adpcm|mat4|mat5|ms_adpcm).c examples/sndfile-play.c + Fix sign conversion errors reported by gcc-4.0. + + * src/caf.c + New file for Apple's Core Audio File format. + + * src/sndfile.c src/common.h src/sndfile.h.in src/Makefile.am + Hook new file into build system. + +2005-06-21 Erik de Castro Lopo + + * src_wav_w64.c + Fix handling of stupidly large 'fmt ' chunks. Thanks to Vadim Berezniker + for supplying an example file. + + * src/common.h src/sndfile.c + Remove redundant error code SFE_WAV_FMT_TOO_BIG. + +2005-06-20 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c + Add public error value SF_ERR_MALFORMED_FILE. + + * src/sndfile.c + When parsing a file header fails and we don't have a system error, then set + the error number to SF_ERR_MALFORMED_FILE (suggested by Kyroz). + + * configure.ac + Allow sqlite support to be disabled in configure script. + + * regtest/database.c regtest/sndfile-regtest.c + Fix compiling when sqlite is missing. + +2005-06-11 Erik de Castro Lopo + + * src/file_io.c + Fix psf_is_pipe() and return value of psf_fread() when using virtual i/o. + + * src/sndfile.c + Fix VALIDATE_AND_ASSIGN_PSF macro for virtual i/o. + + * tests/virtual_io_test.c + Fill in skeleton test program. + + * tests/Makefile.am + Move virtual i/o tests to end of tests with stdio/pipe tests. + + * src/(sndfile.h.in|file_io.c|common.h|sndfile.c) tests/virtual_io_test.c + Rename some of the virtual i/o functions and data types. + +2005-06-10 Erik de Castro Lopo + + * src/sndfile.c + Fix the return values of sf_commands : SFC_SET_NORM_DOUBLE, + SFC_SET_NORM_FLOAT, SFC_GET_LIB_VERSION and SFC_GET_LOG_INFO. Thanks to + Kyroz for pointing out these errors. + + * doc/command.html + Correct documented return values for SFC_SET_NORM_DOUBLE and + SFC_SET_NORM_FLOAT. Thanks to Kyroz again. + +2005-05-17 Erik de Castro Lopo + + * regtest/* + Add new files for sndfile-regtest program. + + * configure.ac Makefile.am + Hook regetest into build. + + * src/wav.c src/common.c + Fix a regression where long ICMT chunks were causing the WAV parser + to exit. + +2005-05-15 Erik de Castro Lopo + + * libsndfile.spec.in + Add html docs to the files section as suggested by Karsten Jeppesen. + + * src/aiff.c + Fix parsing of odd length ANNO chunks. + +2005-05-13 Erik de Castro Lopo + + * src/common.h + Change the include guard to prevent clashes with other code. + +2005-05-12 Erik de Castro Lopo + + * examples/sndfile-play.c + Improve error handling in code for playback under Linux/ALSA. + +2005-05-10 Erik de Castro Lopo + + * src/ircam.c + Fix writing of IRCAM files on big endian systems (thanks to Axel Röbel). + + * src/wav.c + Add workaround for files created by the Peak audio editor on Mac which can + produce files with very short LIST chunks (thanks to Jonathan Segel who + supplied the file). + +2005-04-30 Erik de Castro Lopo + + * src/aiff.c + Apply a patch From David Viens to make the parsing of basc chunks more + robust. + + * src/wav.c + Another patch from David Viens to write correct wavex channel masks for + the most common channel configurations. + +2005-04-08 Erik de Castro Lopo + + * src/command.c + Only allow FLAC in the format arrays if FLAC is enabled. Thanks to + Leigh Smith. + +2005-03-09 Erik de Castro Lopo + + * src/common.h + Add a directory field for storing the file directory to the SF_PRIVATE + struct. + + * src/sndfile.c + Grab the directory name when copying the file path. + + * src/file_io.c + Cleanup psf_open_rsrc() and also check for resource fork in + .AppleDouble/filename. + +2005-03-01 Erik de Castro Lopo + + * src/svx.c + Fix a bug in the printing of the channel count. Bug reported by Michael + Schwendt. Thanks. + +2005-01-26 Erik de Castro Lopo + + * src/paf.c + Fix a seek bug for 24 bit PAF files. + + * tests/write_read_test.tpl + Update write_read_test to trigger the previously hidden PAF seek bug. + +2005-01-25 Erik de Castro Lopo + + * src/aiff.c src/w64.c src/wav.c + Do not return a header parse error when the log buffer overflows. + Continuing parsing works even on files where the log buffer does overflow. + This avoids a bug on some weirdo WAV (and other) files. + + * src/common.h src/sndfile.c + Remove SFE_LOG_OVERRIN error and its associated error message. + + * src/file_io.c + Fix a rsrc fork problem on MacOSX. + +2004-12-31 Erik de Castro Lopo + + * src/sndfile-play.c + In the ALSA output code, added call to snd_pcm_drain() just before + snd_pcm_close() as suggested by Thomas Kaeding. + In the OSS output code, added two ioctls (SNDCTL_DSP_POST and + SNDCTL_DSP_SYNC) just before the close of the audio device. + + * tests/virtual_io_test.c tests/Makefile.am + Add a new test program (currently empty) and add it to the build. + +2004-12-29 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.h src/common.h src/file_io.c + src/create_symbols_file.py + Apply patch from Steve Baker which is the beginnings of a virtual + I/O interface. + +2004-12-23 Erik de Castro Lopo + + * src/*.c src/sndfile.h.in + Const-ify the write path throughout the library. + +2004-12-14 Erik de Castro Lopo + + * doc/development.html + Minor improvements. + +2004-11-29 Erik de Castro Lopo + + * doc/bugs.html + Minor improvements. + +2004-11-18 Erik de Castro Lopo + + * src/aiff.c + Add workaround for Logic Platinum AIFF files with broken COMT chunks. + +2004-11-16 Erik de Castro Lopo + + * doc/FAQ.html + Remove some ambiguities in the SD2 FAQ answer. + +2004-11-15 Erik de Castro Lopo + + * Win32/sndfile.h Win32/config.h MacOS9/sndfile.h MacOS9/config.h + Updates from autoconfig versions. + +2004-11-13 Erik de Castro Lopo + + * src/aiff.c + Fix parsing of COMT chunks. Store SF_STR_COMMENT data in ANNO chunks + instead of COMT chunk. + +2004-11-07 Erik de Castro Lopo + + * src/file_io.c src/common.h + Change the ptr argument to psf_write() from "void*" to a "const void*". + Thanks to Tobias Gehrig for suggesting this. + +2004-10-31 Erik de Castro Lopo + + * src/file_io.c src/common.h + Add functions psf_close_rsrc() and read length of resourse fork into + rsrclength field of SF_PRIVATE. + + * src/sd2.c + Make sure resource fork gets closed. + + * tests/util.tpl + Add functions to check for file descriptor leakage. + + * src/write_read_test.tpl + Use the file descriptor leak checks. + + * src/sndfile.h.in + Add SFC_GET_LOOP_INFO and SF_LOOP_INFO struct. + + * src/common.h + Add SF_LOOP_INFO pointer to SF_PRIVATE. + + * src/wav.c src/aiff.c + Improve and add parsing of 'ACID' and 'basc' chunks, filling in + SF_LOOP_INFO data in SF_PRIVATE. + +2004-10-30 Erik de Castro Lopo + + * src/sd2.c + Further cleanup: remove printfs, change snprintf to LSF_SNPRINTF. + + * Win32/config.h Win32/sndfile.h + Updates. + + * tests/util.tpl + Add win32 macro for snprintf. + +2004-10-29 Erik de Castro Lopo + + * src/sfendian.h + Add macros : H2BE_SHORT, H2BE_INT, H2LE_SHORT and H2LE_INT. + + * src/sd2.c + Use macros to make sure writing SD2 files on little endian machines works + correctly. + + * tests/util.tpl + Add a delete_file() function which also deletes the resource fork of SD2 + files. + + * tests/write_read_test.tpl + Use delete_file() so that "make distcheck" works. + +2004-10-28 Erik de Castro Lopo + + * src/sndfile.c src/file_io.c + Move resource filename construction and testing to psf_open_rsrc(). + + * src/common.h src/sndfile.c + Add error SFE_SD2_FD_DISALLOWED. + + * tests/util.tpl tests/*.(c|tpl) + Add and allow_fd parameter to test_open_file_or_die() so that use of + sf_open_fd() can be avoided when opening SD2 files. + +2004-10-27 Erik de Castro Lopo + + * src/wav.c + Update ACID chunk parsing. + + * src/sd2.c + More fixes for files with large resource forks. + +2004-10-23 Erik de Castro Lopo + + * src/common.h src/sndfile.c + Add error numbers and messages for sd2 files. + + * src/sd2.c + Reading of sd2 (resource fork version) now seems to be working. + +2004-10-17 Erik de Castro Lopo + + * src/file_io.h + Update file_io.c to include win32 psf_rsrc_open(). + + * tests/floating_point_test.tpl + Remove use of __func__ in test programs (MSVC++ doesn't grok this). + + * Win32/(config|sndfile).h MacOS9/(config|sndfile).h + Updates. + +2004-10-13 Erik de Castro Lopo + + * src/sfendian.h + Fix endswap_int64_t_(array|copy). + + * src/test_endswap.(tpl|def) + Add tests for above and inprove all tests. + +2004-10-12 Erik de Castro Lopo + + * src/sfendian.h + Improve type safety, add endswap_double_array(). + + * src/double64.c + Use endswap_double_array() instead of endswap_long_array(). + + * src/test_endswap.(tpl|def) src/Makefile.am + Add preliminary endswap tests and hook into build system. + +2004-10-06 Erik de Castro Lopo + + * src/configure.ac src/makefile.am + Finally fix the bulding of DLLs on Win32/MinGW. + + * tests/makefile.am + Fix running of tests on Win32/MinGW. + +2004-10-01 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c tests/floating_point_test.tpl + Rename SFC_SET_FLOAT_INT_MULTIPLIER to SFC_SET_SCALE_FLOAT_INT_READ. + + * doc/command.html + Document SFC_SET_SCALE_FLOAT_INT_READ. + +2004-09-30 Erik de Castro Lopo + + * tests/floating_point_test.(tpl|def) + Derived from floating_point_test.c. + Add (float|double)_(short|int)_test functions. + + * tests/util.(tpl|def) + Make separate float and double versions of gen_windowed_sine(). + + * tests/write_read_test.tpl + Fix after changes to gen_windowed_sine(). + + * src/(float32|double64).c + Implement SFC_SET_FLOAT_INT_MULTIPPLIER. + +2004-09-29 Erik de Castro Lopo + + * acinclude.m4 + Fix warnings from automake 1.8 and later. + + * examples/sndfile-info.c + Add a "fflush (stdout)" after printing Win32 message. + +2004-09-28 Erik de Castro Lopo + + * Win32/Makefile.mingw.in + Add a "make install" target. + +2004-09-24 Erik de Castro Lopo + + * src/sndfile.h.in src/common.h src/sndfile.c src/command.c + Start work on adding command SFC_SET_FLOAT_INT_MULTIPLIER. + +2004-09-22 Erik de Castro Lopo + + * examples/sndfile-convert.c + Fix a bug converting stereo integer PCM files to float. + +2004-09-22 Erik de Castro Lopo + + * examples/sndfile-play.c + Appy patch from Conrad Parker to make Mac OSX error messages more + consistent and informative. + + * doc/api.html + Fix a HTML HREF which was wrong. + + * doc/win32.html + Add information about when nmake fails. + +2004-09-05 Erik de Castro Lopo + + * examples/sndfile-play.c + Another patch from Denis Cote to prevent race conditions. + +2004-09-02 Erik de Castro Lopo + + * src/common.h src/ms_adpcm.c src/ima_adpcm.c + Fix alternative to ISO standard flexible struct array feature for broken + compilers. + +2004-08-31 Erik de Castro Lopo + + * src/common.h src/string.c src/sndfile.c + Make sf_set_string() return an error if trying to set a string when in + read mode. + +2004-08-29 Erik de Castro Lopo + + * src/common.h + Change the unnamed union into a named union so gcc-2.95 will compile it. + + * src/*.c + Fixes to allow for the above change. + +2004-08-20 Erik de Castro Lopo + + * examples/sndfile-play.c + Fixes for Win32. Thanks to Denis Cote. + + * Win32/Win32/Makefile.(msvc|mingw.in) + Fix build system after removal of sfendian.h. + Build sndfile-convert. + + * src/Makefile.am + Remove sfendian.c from dependancies. + +2004-08-10 Erik de Castro Lopo + + * src/sndfile.h.in + Fix typo in comments (thanks Tommi Sakari Uimonen). + +2004-07-31 Erik de Castro Lopo + + * tests/(a|u)law_test.c + Minor cleanup. + +2004-07-29 Erik de Castro Lopo + + * src/(pcm|float|double64|ulaw|alaw|xi).c + Optimise read/write loops by removing a redundant variable. + +2004-07-24 Erik de Castro Lopo + + * src/file_io.c + Remove call to fsync() in psf_close(). + +2004-07-19 Erik de Castro Lopo + + * src/pcm.c + Inline x2y_array() functions where possible. + + * configure.ac + Detect presence of type int64_t. + + * src/sfendian.c src/sfendian.h + Move functions in the first file to the sfendian.h as static inline + functions. + Improve endswap_long_*() where possible. + +2004-07-17 Erik de Castro Lopo + + * src/pcm.c + When converting from unsigned char to float or double, subtract 128 before + converting to float/double rather than after to save a floating point + operation as suggested by Stefan Briesenick. + + * src/(pcm|sfendian|alaw|ulaw|double64|float32).c + Optimize inner loops by changing the loop counting slightly as suggested + by Stefan Briesenick. + + * configure.ac + Detect presence of . + + * src/sfendian.h + Use if present as suggested by Stefan Briesenick. + + * src/pcm.c + Update bytewapping. + +2004-07-02 Erik de Castro Lopo + + * src/common.h src/*.c + Change the psf->buffer field of SF_PRIVATE into a more type safe union with + double, float, int etc elements. + +2004-06-28 Erik de Castro Lopo + + * examples/sndfile-play.c + Merge slightly modifed patch from Stanko Juzbasic which allows playback of + mono files on MacOSX. + +2004-06-25 Erik de Castro Lopo + + * examples/sndfile-convert.c + Move copy_metadata() after the second sf_open(). + +2004-06-21 Erik de Castro Lopo + + * examples/sndfile-convert.c + Fix a bug which caused the program to go into an infinite loop if the source + file has no meta-data. Thanks to Ron Parker for reporting this. + + * src/sndfile.h.in + Add SF_STR_FIRST and SF_STR_LAST to allow enumeration of string types. + + * Win32/sndfile.h MacOS9/sndfile.h + Update these as per the above file. + +2004-06-17 Erik de Castro Lopo + + * configure.ac src/common.h src/ogg.c src/sndfile.c src/sndfile.h.in + src/Makefile.am + Apply large patch from Conrad Parker implementing Ogg Vorbis, Ogg Speex and + Annodex support via liboggz and libfishsound. Thanks Conrad. + +2004-06-15 Erik de Castro Lopo + + * src/avr.c src/ircam.c src/nist.c src/paf.c src/xi.c + Add cast to size_t for some parameters passed to psf_binheader_writef. This + is Debian bug number 253490. Thanks to Anand Kumria and Andreas Jochens. + + * src/w64.c + Found and fixed a bug resulting from use of size_t when writing W64 'fmt ' + chunk. + +2004-06-14 Erik de Castro Lopo + + * configure.ac + Bump version to 1.0.10 ready for release. + + * Makefile.am + Remove redundant files (check_libsndfile.py libsndfile_version_convert.py) + from distribution tarball. + + * tests/header_test.tpl + Fix uninitialised variable. + + * src/GSM610/short_term.c + Fix compiler warning on MSVC++. + +2004-05-23 Erik de Castro Lopo + + * src/wav.c + Improve record keeping of chunks seen and return an error if a file with + unusual chunks is opened in mode SFM_RDWR. + + * src/mmreg.h + This file not needed so remove it. + +2004-05-22 Erik de Castro Lopo + + * tests/header_test.tpl + Add extra_header_test(). + + * src/common.h src/sndfile.c + Add SFE_RDWR_BAD_HEADER error number and string. + +2004-05-21 Erik de Castro Lopo + + * tests/utils.tpl tests/*.c tests/*.tpl + Add a line number argument to check_log_buffer_or_die() and update all + files that use that function. + + * tests/header_test.tpl + Modify/update tests for files opened SFM_RDWR and SFC_UPDATE_HEADER_AUTO. + + * src/aiff.c src/wav.c + Fix another bug in AIFF and WAV files opened in SFM_RDWR and using + SFC_UPDATE_HEADER_AUTO. + + * src/test_file_io.c + Add a test for psf_ftruncate() function. + +2004-05-19 Erik de Castro Lopo + + * src/sndfile.c + Fix another weird corner case bug found by Martin Rumori. Thanks. + + * tests/header_test.(tpl|def) + Two new files to test for the absence of the above bug and include tests + moved from tests/misc_test.c. + + * tests/Makefile.am + Hook new tests into build/test system. + + * tests/misc_test.c + Remove update_header_test() which has been moved to the new files above. + +2004-05-16 Erik de Castro Lopo + + * src/aiff.c + Fixed a bug reported by Martin Rumori on the LAD list. If a file created + with a format of SF_FORMAT_FLOAT and then closed before any data is written + to it, the header can get screwed up (PEAK chunk gets overwritten). + + * tests/write_read_test.tpl + Add a test (empty_file_test) for the above bug. + +2004-05-13 Erik de Castro Lopo + + * Win32/Makefile.mingw.in + Added a Makefile for MinGW (needs to be processed by configure). + + * src/mmsystem.h src/mmreg.h + Add files from the Wine project (under the LGPL) to allow build of + sndfile-play.exe under MinGW. + +2004-05-12 Erik de Castro Lopo + + * src/GSM610/gsm610_priv.h + Replace ugly macros with inline functions. + + * src/GSM610/*.c + Remove temporary variables used by macros and other minor fixes required by + above change. + +2004-05-10 Erik de Castro Lopo + + * tests/pipe_test.tpl tests/stdio_test.c Win32/Makefile.msvc + Make sure these programs compile (even though they do nothing) on Win32 + and add them to the "make check" target. + + * src/sfendian.h + Fix warning on Sparc CPU and code cleanup. + +2004-05-09 Erik de Castro Lopo + + * src/file_io.c + Fix warning messages when compiling under MinGW. + +2004-05-01 Erik de Castro Lopo + + * configure.ac + Set HAVE_FLEXIBLE_ARRAY in src/config.h depending on whether the compiler + accepts the flexible array struct member as per 1999 ISO C standard. + + * src/common.h src/ima_adpcm.c src/paf.c src/ms_adpcm.c + Added ugly #if HAVE_FLEXIBLE_ARRAY and provided a non-standards compliant + hack for non 1999 ISO C compliant compilers. + +2004-04-26 Erik de Castro Lopo + + * src/strings.c + If adding an SF_STR_SOFTWARE string, only append libsndfile-X.Y.Z if the + string does not already have libsndfile in the string. Thanks to Conrad + Parker. + + * tests/string_test.c + Add test to verify the above. + + * examples/sndfile-convert.c + Add ability to transcode meta data as well (Conrad Parker). + +2004-04-25 Erik de Castro Lopo + + * doc/command.html + Fix minor error. Thanks to Simon Burton. + + * doc/win32.html + Started adding instructions for compiling libsndfile under MinGW. + + * configure.ac + Add --enable-bow-docs to enable black text on a white background HTML docs. + + * doc/libsndfile.css.in + This is now a template file for configure which sets the foreground and + background colours. + +2004-04-20 Erik de Castro Lopo + + * configure.ac + Do some MinGW fixes. + + * configure.ac doc/Makefile.am + Install HTML docs when doing make install. + +2004-04-19 Erik de Castro Lopo + + * examples/sndfile-info.c + Print out the dB level with the signal max. + +2004-04-15 Erik de Castro Lopo + + * src/file_io.c + Define S_ISSOCK in src/file_io.c if required. + +2004-04-03 Erik de Castro Lopo + + * configure.ac + Improve printout configuration summary (as suggested by Axel Röbel). + + * doc/index.html + Add link to pre-release location. + + * src/sndfile.h.in + Remove comma after last element of enum. + + * src/float32.c src/double64.c + Fix read/write of float/double encoded raw files to/from pipes. + + * tests/pipe_test.c tests/pipe_test.tpl tests/pipe_test.def + Turn pipe_test.c into an autogenerated file and add tests for reading/ + writing floats and doubles. + + * tests/Makefile.am + Hook tests/pipe_test.* into build system. + +2004-04-02 Erik de Castro Lopo + + * configure.ac acinclude.m4 + Rename AC_C_STRUCT_HACK macro to AC_C99_FLEXIBLE_ARRAY. + +2004-03-31 Erik de Castro Lopo + + * tests/misc_test.c + Perform update_header_test in RDWR mode as well. + + * src/aiff.c + Fix problems when updating header in RDWR mode. + +2004-03-30 Erik de Castro Lopo + + * src/wav.c src/w64.c src/wav_w64.c + Integrate code supplied by David Viens for supporting microsoft's + WAVEFORMATEXTENSIBLE stuff. Thanks David for supplying this. + + * configure.ac doc/*.html + Bump version to 1.0.9. + +2004-03-28 Erik de Castro Lopo + + * src/command.c src/sndfile.c src/sndfile.h.in src/wav.c + Started work on supporting microsoft's WAVEFORMATEXTENSIBLE gunk. + +2004-03-26 Erik de Castro Lopo + + * src/avr.c + New file to handle Audio Visual Resaerch files. + + * src/sndfile.h.in src/common.h src/sndfile.c src/command.c + Hook AVR into everything else. + + * tests/Makefile.am tests/write_read_test.tpl tests/misc_test.c + Add testing for AVR files. + +2004-03-22 Erik de Castro Lopo + + * src/file_io.c + Fix psf_set_file() for win32. Thanks to Vincent Trussart (Plogue Art et + Technologie) for coming up with the solution. + +2004-03-21 Erik de Castro Lopo + + * tests/write_read_test.tpl + Fixed a bug that was causing valgrind to report a memory leak. The bug was + in the test code itself, not the library. + +2004-03-20 Erik de Castro Lopo + + * examples/generate.cs + An example showing how to use libsndfile from C#. Thanks to James Robson + for providing this. + +2004-03-19 Erik de Castro Lopo + + * src/common.c + Fix problems with WAV files containing large chunks after the 'data' + chunk. Thanks to Koen Tanghe for providing a sample file. + +2004-03-17 Erik de Castro Lopo + + * configure.ac + Detect presense of ALSA (Advanced Linux Sound Architecture). + + * examples/sndfile-play.c + Add ALSA output support. + + * examples/Makefile.am + Add ALSA_LIBS to link line of sndfile-play.c. + +2004-03-15 Erik de Castro Lopo + + * acinclude.m4 + Add new macro (AC_C_STRUCT_HACK) to detect whether the C compiler allows + the use of the what is known as the struct hack introduced by the 1999 ISO + C Standard. + + * configure.ac + The last release would not compile with gcc-2.95 due to the use of features + (ie struct hack) introduced by the 1999 ISO C Standard. + Add check to make sure compiler handles this and bomb out if it doesn't. + +2004-03-14 Erik de Castro Lopo + + * tests/write_read_test.tpl + Fix compiler warning on Win32. + + * src/file_io.c + Fix use of an un-initialised variable in Win32 stuff. + + * Win32/config.h examples/sndfile-play.c + Win32 fixes. + +2004-03-10 Erik de Castro Lopo + + * configure.ac + Fix bug which occurres when configuring for MinGW. + If compiler is gcc and cross compiling use -nostdinc. + +2004-03-09 Erik de Castro Lopo + + * src/common.h src/aiff.c src/wav.c src/float32.c src/double64.c + src/sndfile.c + Fix a bug with PEAK chunk handling for files with more than 16 channels. + Thanks to Remy Bruno for finding this. + +2004-03-08 Erik de Castro Lopo + + * src/common.c + Fix a bug which was preventing WAV files being openned correctly if the + file had a very large header. Thanks to Eldad Zack for finding this. + +2004-03-04 Erik de Castro Lopo + + * configure.ac src/file_io.c + Fix cross-compiling from Linux to Win32 using the MinGW tools. + +2004-03-01 Erik de Castro Lopo + + * src/create_symbols_file.sh + Christian Weisgerber pointed out that the shell script did not run on a + real Bourne shell although it did run under Bash in Bourne shell mode. + + * src/create_symbols_file.py + Rewrite of above in Python. Also add support for writing Win32 .def files. + The Python script generates Symbols.linux, Symbols.darwin and + libsndfile.def (Win32 version). These files get shipped with the tarball + so there should not be necessary to run the Python script when building + the code from the tarball. + + * configure.ac src/Makefile.am Win32/Makefile.am + Hook new Python script into the build system. + +2004-02-25 Erik de Castro Lopo + + * src/configure.ac + Add --enable-gcc-werror option and move GCC specific stuff down. + +2004-02-24 Erik de Castro Lopo + + * acinclude.m4 configure.ac + Fix clip mode detection (tested in one of HP's testdrive Itanium II boxes). + + * src/file_io.c + Added check for sizeof (off_t) != sizeof (sf_count_t) to prevent recurrence + of missing large file support on Linux and Solaris. + +2004-02-19 Erik de Castro Lopo + + * examples/sndfile-play.c + Fix a MacOSX specific bug which was caused by a space being inserted in + the middle of a file name. + + * configure.ac src/Makefile.am examples/Makefile.am + Fix a couple of MacOSX build issues. + +2004-02-17 Erik de Castro Lopo + + * doc/command.html + Document SFC_SET_CLIPPING and SFC_GET_CLIPPING. + +2004-02-14 Erik de Castro Lopo + + * doc/*.html + Applied patch from Frank Neumann (author of lakai) which fixes many minor + typos in documentation. Thanks Frank. + +2004-02-13 Erik de Castro Lopo + + * ChangeLog + Changed my email address throughout source and docs. + +2004-02-08 Erik de Castro Lopo + + * src/file_io.c + Make sure config.h is included before stdio.h to make sure large file + support is enabled on Linux (and Solaris). + + * tests/misc_test.c + Disable update_header test on Win32. This should work but doesn't and + I'm not sure why. + + * Make.bat Win32/Makefile.msvc + Updates. + +2004-01-07 Erik de Castro Lopo + + * src/common.h + Changed logindex, headindex and headend files of SF_PRIVATE from unsigned + int to int to prevent weird arithmetic bugs. + + * src/common.c src/aiff.c src/wav.c src/w64.c + Fixed compiler warnings resulting from above change. + +2004-01-06 Erik de Castro Lopo + + * src/common.c + Fixed a bug in header reader for some files with data after the sample data. + +2003-12-29 Erik de Castro Lopo + + * tests/lossy_comp_test.c tests/Makefile.am + Add tests for AIFF/IMA files. + +2003-12-26 Erik de Castro Lopo + + * src/macbinary3.c src/macos.c + Two new files required for handling SD2 files. + + * src/common.h + Add prototypes for functions in above two files. + + * src/Makefile.am + Hook new files into build system. + +2003-12-21 Erik de Castro Lopo + + * configure.ac + Add checks for mmap() and getpagesize() which might be used at some time + for faster file reads. + Add detection of MacOSX. + +2003-12-13 Erik de Castro Lopo + + * doc/FAQ.html + Minor mods to pkg-config section. + +2003-12-12 Erik de Castro Lopo + + * src/create_symbols_file.sh + Andre Pang (also known as Ozone) pointed out that on MacOSX, all non + static symbols are exported causing troubles when trying to link + libsndfile with another library which has any of the same symbols. + He fixed this by supplying the MacOSX linker with a file containing + all the public symbols so that only they would be exported and then + supplied a patch for libsndfile. + This wasn't quite ideal, because I would have to maintain two (3 if + you include Win32) separate files containing the exported symbols. + A better solution was to create this script which can generate a + Symbols file for Linux, MacoSX and any other OS that supports + minimising the number of exported symbols. + + * configure.ac src/Makefile.am + Hook the new script into the build process. + +2003-12-10 Erik de Castro Lopo + + * doc/index.html + Added comments about Steve Dekorte's SoundConverter scam. + +2003-12-07 Erik de Castro Lopo + + * src/file_io.c + Axel Röbel pointed out that on Mac OSX a pipe is not considered a fifo + (S_ISFIFO (st.st_mode) is false) but a socket (S_ISSOCK (st.st_mode) is + true). The test has therefore been changed to is S_ISREG and anything + which which does not return true for S_ISREG is considered a pipe. + +2003-11-25 Erik de Castro Lopo + + * tests/misc_test.c + Fix update_header_test to pass SDS. + + * src/sds.c + More minor fixes. + + * tests/floating_point_test.c + Add test for SDS files. + + * src/command.c + Add SDS to major_formats array. + +2003-11-24 Erik de Castro Lopo + + * tests/write_read_test.tpl tests/misc_test.c + Add tests for SDS files. + + * src/sds.c + Fix a bug in header update code. + +2003-11-23 Erik de Castro Lopo + + * src/sds.c + Get file write working. + + * src/paf.c + Fix a potential bug in paf24_seek(). + +2003-11-04 Erik de Castro Lopo + + * doc/FAQ.html + Add Q/A about u-law encoded WAV files. + + * Win32/*.h + Updated so it compiles on Win32. + +2003-11-03 Erik de Castro Lopo + + * examples/sndfile-convert.c + Add -alaw and -ulaw command line arguments. + + * configure.ac + Add library versioning comments. + Add arguments to AC_INIT. + +2003-10-28 Erik de Castro Lopo + + * src/file_io.c + Ross Bencina has contributed code to replace all of the (mostly broken) + Win32 POSIX emulation calls with calls the native Win32 file I/O API. + This code still needs testing but is likely to be a huge improvemnt + of support for Win32. Thanks Ross. + +2003-10-27 Erik de Castro Lopo + + * src/dwvw.c + Removed filedes field from the DWVW_PRIVATE struct. + + * src/file_io.c + Change psf_fopen() so it returns psf->error instead of the file descriptor. + Add new functions psf_set_stdio() and psf_set_file(). + + * src/sndfile.c + Change these to work with changed psf_fopen() return value. + Remove all uses of psf->filedes from sndfile, making it easier to slot native + Win32 API file handling functions. + + * src/test_file_io.c + Minor changes to make it compile with new file_io.c stuff. + +2003-10-26 Erik de Castro Lopo + + * src/gsm610.h + Rename a variable from true to true_flag. As Ross Bencina points out, + true is defined in the C99 header . + + * src/file_io.c + If fstat() fails, return SF_TRUE instead of -1 (Ross Bencina). + +2003-10-09 Erik de Castro Lopo + + * src/common.h + Increase the size of SF_BUFFER_LEN and SF_HEADER_LEN. + + * src/sndfile.c + Fix sf_read/write_raw which were dividing by psf->bytwidth and + psf->blockwidth which can both be zero. + + * examples/sndfile-info.c + Increase size of BUFFER_LEN. + +2003-09-21 Erik de Castro Lopo + + * configure.ac + Add checks for and ssize_t. + Other Win32/MinGW checks. + + * src/aiff.c src/au_g72x.c src/file_io.c src/gsm610.c src/interleave.c + src/paf.c src/sds.c src/svx.c src/voc.c src/w64.c src/wav.c src/xi.c + Fix compiler warnings. + +2003-09-20 Erik de Castro Lopo + + * tests/scale_clip_test.tpl + Add definition of M_PI if needed. + +2003-09-19 Erik de Castro Lopo + + * configure.ac + Detect if S_IRGRP is declared in . + + * src/file_io.c tests/*.tpl tests/*.c + More fixes for Win32/MSVC++ and MinGW. MinGW does have but that + file doesn't declare S_IRGRP. + +2003-10-18 Erik de Castro Lopo + + * src/config.h.in + Add comment stating that the sf_count_t typedef is determined when + libsndfile is being compiled. + + * tests/utils.tpl + Modified so that utils.c gets one copy of the GPL and not two. + + +2003-09-17 Erik de Castro Lopo + + * Win32/unistd.h src/sf_unistd.h + Move first file to the second. This will help for Win32/MSVC++ and MinGW. + + * Win32/Makefile.am src/Makefile.am + Changed in line with above. + + * Win32/Makefile.msvc + Removed "/I Win32" which is no longer required. + + * src/file_io.c src/test_file_io.c tests/*.tpl tests/*.c + If HAVE_UNISTD_H include else include . This should + work for Win32, MinGW and other fakes Unix-like OSes. + + * src/*.c + Removed #include from files which didn't need it. + +2003-09-16 Erik de Castro Lopo + + * libsndfile.spec.in + Apply fix from Andrew Schultz. + +2003-09-07 Erik de Castro Lopo + + * src/vox_adpcm.c + Only set psf->sf.samplerate if the existing value is invalid. + +2003-09-06 Erik de Castro Lopo + + * examples/sndfile-play.c + Started adding support for ALSA output. + +2003-09-04 Erik de Castro Lopo + + * src/sndfile.h.in + Removed from sndfile.h. + + * src/*.c examples/*.c tests/*.c tests/*.tpl + Added where needed. + +2003-09-02 Erik de Castro Lopo + + * src/common.h + Added ARRAY_LEN, SF_MAX and SF_MIN macros. + +2003-08-19 Erik de Castro Lopo + + * doc/index.html + Remove statements about alternative licensing arrangements. + +2003-08-17 Erik de Castro Lopo + + * MacOS MacOS9 Makefile.am configure.ac + Change directory name from MacOS to MacOS9 + + * MacOS9/MacOS9-readme.txt + Change name to make it really obvious, add text to top of file to make it + still more obvious again. + +2003-08-16 Erik de Castro Lopo + + * src/test_log_printf.c + Add tests for %u conversions. + + * src/common.c + Fix psf_log_printf() %u conversions. + +2003-08-15 Erik de Castro Lopo + + * src/aiff.c + Fixed a bug where opening a file with a non-trival header in SFM_RDWR mode + would over-write part of the header. Thanks to Axel Röbel for pointing + this out. Axel also provided a patch to fix this but I came up with a + neater and more general solution. + Return error when openning an AIFF file with data after the SSND chunk + (Thanks Axel Röbel). + + * tests/aiff_rw_test.c + Improvements to test program which will later allow it to be generalised to + test WAV, SVX and others as required. + +2003-08-14 Erik de Castro Lopo + + * tests/pipe_test.c + Add useek_pipe_rw_test() submitted by Russell Francis. + + * src/sndfile.c + In sf_open_fd(), check if input file descriptor is a pipe. + + * src/sndfile.[ch] + Fix typo in variable name do_not_close_descriptor. + +2003-08-13 Erik de Castro Lopo + + * src/test_log_printf.c + Improve the tests for %d and %s conversions. + + * src/common.c + Fixed a few problems in psf_log_printf() found using new tests. + +2003-08-06 Erik de Castro Lopo + + * configure.ac + Add -Wwrite-strings warning to CFLAGS if the compiler is GCC. Thanks to + Peter Miller (Aegis author) for suggesting this and supplying a patch. + + * src/*.c examples/*.c tests/*.c + Fix all compiler warnings arising from the above. + +2003-08-02 Erik de Castro Lopo + + * tests/aiff_rw_test.c tests/Makefile.am + New test program to check for errors re-writing the headers of AIFC files + opened in mode SFM_RDWR. + +2003-07-21 Erik de Castro Lopo + + * examples/sndfile-play.c + Applied a patch from Tero Pelander to allow this program to run on systems + using devfs which used /dev/sound/dsp instead of /dev/dsp. + +2003-07-11 Erik de Castro Lopo + + * doc/new_file_type.HOWTO + Updated document. Still incomplete. + +2003-06-29 Erik de Castro Lopo + + * src/sndfile.c + Fix VALIDATE_SNDFILE_AND_ASSIGN_PSF which was returning an error rather + than saving it and returning zero. + +2003-06-25 Erik de Castro Lopo + + * src/file_io.c + Two fixes for Mac OS9. + Fix all casts from sf_count_t to ssize_t (not size_t). + +2003-06-22 Erik de Castro Lopo + + * src/wav.c + Fix for reading files with RIFF length of 8 and data length of 0. + +2003-06-14 Erik de Castro Lopo + + * src/*.c tests/*.c tests/*.tpl + Added comments to mark code for removal when make Lite version of + libsndfile. + +2003-06-09 Erik de Castro Lopo + + * examples/sndfile-convert.c + Add extra error checking for unrecognised arguments. + +2003-06-08 Erik de Castro Lopo + + * src/ima_adpcm.c + Started adding code to write IMA ADPCM encoded AIFF files. + + * src/test_log_printf.c src/Makefile.am + New file to test psf_log_printf() function and add hooks into build system. + + * src/common.c + Move psf_log_printf() function to top of the file and only compile the rest + of the file if if PSF_LOG_PRINTF_ONLY is not defined. + +2003-06-03 Erik de Castro Lopo + + * Win32/config.h Win32/sndfile.h + Updated with new config variables. + + * Win32/unistd.h src/file_io.c + Added implementation of S_ISFIFO macro which Win32 seems to lack and is + used in src/file_io.c. + + * tests/utils.tpl + Added #include to pull in Win32/unistd.h so it compiles for + Win32. + + * src/Makefile.msvc + Added src\test_file_io.exe build target and run this as the very first + test. + + * tests/win32_test.c + Add support for testing Cygwin32. + + * configure.ac + Detect POSIX fsync() and fdatasync() functions. + + * src/file_io.c + If compiling for Cygwin, call fsync() before calling fstat() to retrieve + file length. + + * tests/pcm_test.tpl + Add a test for lrintf() function. This was required to detect a really + broken lrint() and lrintf() on Cygwin. + + * tests/misc_test.c + Don't run permission test when compiling under Cygwin. + + * src/float_cast.h + Fix fallback macro for lrint() and lrintf() to cast to long instead of int + to match official function prototypes. + +2003-06-02 Erik de Castro Lopo + + * examples/sndfile-convert.c + Modifications to improve accuracy of conversions; use double data for + floating point and int for everything else. + + * src/ima_apdcm.c + Completed work on decoding IMA ADPCM encoded AIFF files. Still need to + get encoding working. + +2003-05-28 Erik de Castro Lopo + + * src/aiff.c src/ima_adpcm.c + Start working on getting IMA ADPCM encoded AIFF files working. + +2003-05-27 Erik de Castro Lopo + + * configure.ac + Fixed the touch command for when the autogen program is not found (Matt + Flax). + + * src/ulaw.c src/alaw.c + Made these pipe-able. + +2003-05-24 Erik de Castro Lopo + + * src/paf.c src/ircam.c + Fixed writing to pipe. + + * src/wav.c src/aiff.c src/nist.c src/mat*.c src/svx.c src/w64.c + Return SFE_NO_PIPE_WRITE if an attempt is made to write to a pipe. + +2003-05-23 Erik de Castro Lopo + + * examples/sndfile-info.c + Modified to detect unknown file lengths. + + * src/mat4.c + Fix reading from a pipe. + +2003-05-22 Erik de Castro Lopo + + * tests/pipe_test.c + Add more file types to tests. + + * src/mat4.c + Removed explicit setting of psf->sf.seekable to SF_TRUE. + + * tests/utils.tpl + Add macro for generating and check data in the stdio and pipe tests. + + * tests/stdout_test.c tests/stdin_test.c + Use the above macro to generate known data on output and check data on + input. + + * src/voc.c src/htk.c common.h sndfile.c + Disallow reading/writing VOC and HTK files from/to pipes be returning new + error values. + + * src/w64.c + Fixes to allow reading from a pipe. + +2003-05-21 Erik de Castro Lopo + + * configure.ac src/sndfile.h.in + When the configure script determines the sizeof (sf_count_t), also set the + value of SF_COUNT_MAX in sndfile.h. + + * configure.ac + Remove -pedantic flag from default GCC compiler flags. + + * tests/pipe_test.c + Add a pipe_read_test() before doing pipe_write_test(). + + * tests/scale_clip_test.c + Add test to make sure non-normalized values also clip in the right way. + +2003-05-18 Erik de Castro Lopo + + * configure.ac + Add test to detect processor clipping capabilities. + + * tests/stdin_test.c tests/stdout_test.c + Fix a pair of compiler warnings. + + * src/common.h + Add new pipeoffset field to SF_PRIVATE. This will contain the current file + offset when operating on a pipe. + + * src/common.c + Removed direct calls to psf_fread()/psf_fseek()/psf_fgets() etc from + psf_binheader_readf and redirect them to new buffered versions + header_read(), header_seek() and header_gets(). + Add "G" format specifier to emulate fgets() functionality with buffering. + This will allow reading some file types from pipes. + + * src/file_io.c + When the file descriptor is a pipe, manintain psf->pipeoffset. + + * src/pvf.c + Change use of psf_fgets() to psf_binheader_readf() as required but changes to header re + + * src/au.c + Fix reading from a pipe. + +2003-05-17 Erik de Castro Lopo + + * src/pcm.c + Add clipping versions of the f2XXX_array() functions to allow option of + clipping data that would otherwise overflow. + + * tests/scale_clip_test.tpl tests/scale_clip_test.def + New files test that clipping option does actually work. + +2003-05-14 Erik de Castro Lopo + + * doc/index.html + Fixed a typo ("OS(" instead of "OS9"). + +2003-05-13 Erik de Castro Lopo + + * tests/open_fail_test.c + Include to prevent warning message of missing declaration of + memset(). + +2003-05-12 Erik de Castro Lopo + + * src/common.h + Add new "add_clipping" field to SF_PRIVATE. + + * src/sndfile.h.in src/sndfile.c + Add command SFC_SET_CLIPPING which sets/resets add_clipping field. + +2003-05-11 Erik de Castro Lopo + + * doc/api.html + Add docs for sf_set_string() and sf_get_string(). + + * src/common.h src/sndfile.c + Add new SFE_STR_BAD_STRING error. + + * tests/stdin_test.c tests/stdout_test.c + Removed all non-error print statements. + + * tests/stdio_test.c tests/pipe_test.c tests/Makefile.am + Add print statements removed from two files above. + +2003-05-10 Erik de Castro Lopo + + * libsndfile.spec.in + Fixed a coulpe of minor errors discovered by someone calling themselves + Agent Smith. + + * src/common.c src/common.h src/file_io.h + Added is_pipe field to SF_PRIVATE and declaration of psf_is_pipe() + function. (Axel Röbel) + + * src/sndfile.c + Fixed determination of whether the file is a pipe. (Axel Röbel) + + * src/paf.c + Force paf24 to start with undefined mode. (Axel Röbel) + + * tests/pipe_test.c + Mods to make this test work and actually do the test on RAW files. (Axel + Röbel). + +2003-05-05 Erik de Castro Lopo + + * src/sndfile.c + Fixed a potential bug where psf->sf.seekable was being set to FALSE when + operating on stdin or stdout but then the default initialiser was reseting + it to TRUE. Thanks to Axel Röbel. + + * src/aiff.c + Fixed a bug in the header parser where it was not handling an odd length + COMM chunk correctly. Thanks to Axel Röbel. + + * src/test_file_io.c + Add more tests. + + * tests/win32_test.c + New file for showing the bugs in the Win32 implementation of the POSIX API. + It also runs on Linux for sanity checking. + + * tests/Makefile.am Win32/Makefile.msvc + Hook the new test program into the build system. + +2003-05-04 Erik de Castro Lopo + + * src/test_file_io.c + New test program to test operation of functions defined in file_io.c. This + should make supporting win32 significantly easier. + + * src/Makefile.am + Hook new test program into the build system. + + * src/file_io.c + Add compile/run time check that sizeof statbuf.st_size and sf_count_t are + the same. + + * src/common.h src/sndfile.c + Added new error code and error message for new check. + + * tests/benchmark.tpl + Fix to use frames instead of samples in SF_INFO. + +2003-05-03 Erik de Castro Lopo + + * src/file_io.c + More stuffing about working around PLAIN OLD-FASHIONED **BUGS** in Win32. + + * examples/sndfile-info.c + Applied patch from Conrad Parker to add "--help" and "-h" options as + well as an improved usage message. + +2003-05-02 Erik de Castro Lopo + + * src/au.c + Added embedded file support. + + * tests/multi_file_test.c + Added tests for embedded AU files. + Added verbose testing mode. + + * src/common.h src/sndfile.c + Added an embedded AU specific error code and message. + + * src/wav.c + Added patch from Conrad Parker which filled in a little more information + about ACIDized WAV files. + +2003-04-30 Erik de Castro Lopo + + * src/file_io.c + Fixed Win32 version of psf_fseek() which was calling psf_get_filelen() + which was in turn calling psf_fseek() which in the end blew the stack. + Now of course this would have been easy to find on Linux, but this blow + up was happening in kernel32.dll and the fscking MSVC++ debugger couldn't + figure out what call caused this (it couldn't even tell me the stack had + overflowed) and was absolutley useless for this debugging exercise. + On top of that, the reason I got into this mess was that windoze doesn't + have a working fstat() function which can return file lengths > 2 Gig. It + HAS a fscking _fstati64() but the file length value is only updated AFTER + the bloody file is closed. That makes it completely useless. + How the hell do people stand working on this crap excuse of an OS? + +2003-04-29 Erik de Castro Lopo + + * Win32/unistd.h src/file_io.c + Moved definitions of S_IGRP etc from file_io.c to unistd.h so that these + can be used in the test programs. + + * Win32/libsndfile.def + Added sf_open_fd. + + * Win32/sndfile.h + Updated to match src/sndfile.h.in. + + * Win32/Makefile.msvc + Added dither.c and htk.c to libsndfile.dll target. + +2003-04-28 Erik de Castro Lopo + + * src/file_io.c + First attempt at getting the Win32 versions of the these functions working. + They still need to be tested. + +2003-04-27 Erik de Castro Lopo + + * src/strings.c + Found and fixed a bug which was causing psf_store_string() to fail on + Motorola 68k processors. Many thanks to Joshua Haberman (Debian maintainer + of libsndfile) for compiling and running debug code to help me debug the + problem. + +2003-04-26 Erik de Castro Lopo + + * src/sndfile.c src/file_io.c src/wav.c src/aiff.c + Much hacking to get reading and writing of embedded files working (ie sound + files at a non-zero files offset). + + * doc/embedded_files.html + First pass atempt at documenting reading/writing embedded files. + +2003-04-21 Erik de Castro Lopo + + * doc/FAQ.html + Updated answer to "Why doesn't libsndfile do interleaving/de-interleaving?" + +2003-04-19 Erik de Castro Lopo + + * src/wav.c src/aiff.c + Fix retrieving and storing of string data from files. Need to be careful + about using psf->buffer for strings. + +2003-04-18 Erik de Castro Lopo + + * src/file_io.c + Fix psf_fseek() for seeks withing embedded files. + +2003-04-15 Erik de Castro Lopo + + * src/sndfile.h.in + Changed the definition of SNDFILE slightly to produce warnings when it isn't + used correctly. This should have zero affect in code which uses the SNDFILE + type correctly. + + * src/sndfile.c + Fixed a few compiler warnings cause by the changes to the SNDFILE type. + +2003-04-12 Erik de Castro Lopo + + * doc/FAQ.html + Added question and answer to the question "How about adding the ability + to write/read sound files to/from memory buffers?". + +2003-04-08 Erik de Castro Lopo + + * tests/write_read_test.tpl + Removed un-needed enums declaring TRUE and FALSE and replaced usage of + these with SF_TRUE and SF_FALSE. + + * tests/multi_file_test.c + New test program to test sf_open_fd() on files containing data other than + a single sound file. + +2003-04-06 Erik de Castro Lopo + + * src/file_io.c + When creating files, set the readable by others flag. This still allows + further restrictions to be enforced by use of the user's umask. Fix + suggested by Eric Lyon. + +2003-04-05 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c + Changed sf_open_fd(). Dropped offset parameter and added a close_desc + parameter. If close desc is TRUE, the file descritpor passed into the + library will be closed when sf_close() is called. + + * tests/utils.tpl + Modified call to sf_open_fd() to set close_desc parameter to SF_TRUE. + +2003-04-04 Erik de Castro Lopo + + * tests/write_read_test.tpl + Add a string (using sf_set_string() function) before and after data section + of all files. This will make sure that if string data can be added, it + doesn't overwrite real audio data. + +2003-04-02 Erik de Castro Lopo + + * src/sndfile.c + Started work on supporting a non-zero offset parameter for sf_open_fd (). + + * src/.c + Removed many uses of psf_fseek (SEEK_END) which to allow for future use of + sf_open_fd() with non-zero offset. + Associated refactoring. + + * src/aiff.c + Implemented functionality required to get sf_get_string() and + sf_set_string() working for AIFF files. + +2003-04-01 Erik de Castro Lopo + + * tests/utils.tpl + Modified test_open_file_or_die() to alternately use sf_open() and + sf_open_fd(). + + * src/svx.c + Fixed a bug which occurred when openning an existing file for read/write + using sf_open_fd(). In this case, the existing NAME chunk needs to be + read into psf->filename. + Fixed printing of sf_count_t types to logbuffer. + +2003-03-31 Erik de Castro Lopo + + * src/sndfile.h.in + Added prototype for new function sf_open_fd(). + + * src/sndfile.c + Moved most of the code in sf_open() to a new function psf_open_file(). + Created new function sf_open_fd() which also uses psf_open_file() but + does not currently support the offset parameter. + + * doc/api.html + Document sf_open_fd(). + +2003-03-09 Erik de Castro Lopo + + * src/sndfile.c + Fixed a memory leak reported by Evgeny Karpov. Memory leak only occurred + when an attempt was made to read and the open() call fails. + +2003-03-08 Erik de Castro Lopo + + * tests/open_fail_test.c + New test program to check for memory leaks when sf_open fails on a valid + file. Currently this must be run manually under valgrid. + + * tests/Makefile.am + Hook new test program into build. + +2003-03-03 Erik de Castro Lopo + + * Octave/sndfile_save.m Octave/sndfile_play.m + Added a -mat-binary option to the octave save command to force the output + to binary mode even if the user has set ascii data as the default. Found + by Christopher Moore. + +2003-02-27 Erik de Castro Lopo + + * doc/dither.html + New file which will document the interface which allows the addition of + audio dither when sample word sizes are being reduced. + + * src/dither.c + More work. + +2003-02-26 Erik de Castro Lopo + + * tests/misc_test.c + In update_header_test(), make HTK files a special case. + + * doc/index.html + Added HTK to the feature matrix. + +2003-02-25 Erik de Castro Lopo + + * src/htk.c + New file for reading/writing HMM Tool Kit files. + + * src/sndfile.h.in src/sndfile.c src/command.c src/Makefile.am + Hook in htk.c + + * tests/write_read_test.tpl tests/misc_test.c tests/Makefile.am + Add tests for HTK files. + +2003-02-22 Erik de Castro Lopo + + * src/wav.c + Fixed a bug where the LIST chunk length was being written incorrectly. + + * tests/string_test.c + Added call to check_log_buffer(). + Minor cleanups. + +2003-02-10 Erik de Castro Lopo + + * src/wav_w64.h + Applied patch from Antoine Mathys to add extra WAV format definitions and + a G72x_ADPCM_WAV_FMT struct definition. + + * src/wav_w64.c + Applied patch from Antoine Mathys which converts wav_w64_format_str() from + one huge inefficient switch statement to a binary search. + + * tests/string_test.c + Dump log buffer if tests fail. + +2003-02-07 Erik de Castro Lopo + + * tests/string_test.c + David Viens supplied some modifications to this file which showed up a bug + when using sf_set_string() and the sf_writef_float() functions. + + * src/sndfile.c + Fixed the above bug. + +2003-02-06 Erik de Castro Lopo + + * doc/FAQ.html + Added Q and A on how to detect libsndfile in configure.in (at the suggestion + of Davy Durham). + +2003-02-05 Erik de Castro Lopo + + * src/sndfile.h.in + Add enums and typedefs for dither. + Deprecate SFC_SET_ADD_DITHER_ON_WRITE and SFC_SET_ADD_DITHER_ON_READ, to be + replaced with SFC_SET_DITHER_ON_WRITE and SFC_SET_DITHER_ON_READ which will + allow different dither algorithms to be enabled. + Added SFC_GET_DITHER_INFO_COUNT and SFC_GET_DITHER_INFO. + + * src/sndfile.h.in src/Version_script.in Win32/libsndfile.def. + Added public sf_dither_*() functions. + + * src/sndfile.c + Implement commands above. + + * src/dither.c + More work. Framework and external hooks into dither algorithms complete. + +2003-02-03 Erik de Castro Lopo + + * doc/version-1.html libsndfile_version_convert.py + Remove redundant files. + + * doc/index.html doc/api.html + Remove links to version-1.html. + + * src/dither.c + New file to allow the addition of audio dither on input and output. + + * src/common.h + Add prototype for dither_init() function. + + * Makefile.am doc/Makefile.am + Changes for added and removed files. + +2003-02-02 Erik de Castro Lopo + + * Win32/Makefile.msvc + Changes to force example binaries to be placed in the top level directory + instead of the examples/ directory. + Add src/strings.c and src/xi.c to the build. + Add string_test to build and to tests on WAV files. + + * doc/index.html + Added XI to support matrix. + +2003-01-27 Erik de Castro Lopo + + * src/sndfile.h.in + Added prototypes for sf_get_string() and sf_set_string() and SF_STR_* + enum values. + + * src/sndfile.c + Added public interface to sf_get_string() and sf_set_string(). + + * src/wav.c + Added code for setting and getting strings in WAV files. + + * tests/string_test.c + New test program for sf_get_string() and sf_set_string() functionality. + + * tests/Makefile.am + Hook new test program into build and test framework. + +2003-01-26 Erik de Castro Lopo + + * src/common.h + Added fields to SF_PRIVATE for string data needed to implement + sf_get_string() and sf_set_string(). + + * src/strings.c + New file for storing and retrieving strings to/from files. + + * src/Makefile.am + Added strings.c to build. + +2003-01-25 Erik de Castro Lopo + + * src/xi.c + Read seems to be working so looking at write. + + * src/sndfile.h.in + Added SF_FORMAT_XI, SF_FORMAT_DPCM_8 and SF_FORMAT_DPCM_16 enum values. + + * tests/floating_point_test.c tests/lossy_comp_test.c tests/Makefile.am + Added test for 8 and 16 bit XI format files. + +2003-01-24 Erik de Castro Lopo + + * doc/index.html + Added a non-lawyer readable summary of the licensing provisions as + suggested by Steve Dekorte. + +2003-01-23 Erik de Castro Lopo + + * src/wav.c + Fixed a compiler warning found by Alexander Lerch. + +2003-01-18 Erik de Castro Lopo + + * configure.ac + Fixed the multiple linking of libm. + +2003-01-17 Erik de Castro Lopo + + * Win32/Makefile.mcvs + Added comments on the correct way to set up the MSVCDir environment + variable. + + * doc/win32.html + Add on how to set up the MSVCDir environment variable. + +2003-01-15 Erik de Castro Lopo + + * examples/sndfile-play.c examples/sndfile-info.c + When run on Win32 without any command line parameters print a message and + then sleep for 5 seconds. This means the when somebody double clicks on + these programs in explorer the user will actually see the message. + +2003-01-14 Erik de Castro Lopo + + * tests/misc_test.c + Bypass permission test if running as root because root is allowed to open + a readonly file for write. + +2003-01-08 Erik de Castro Lopo + + * Win32/Makefile.msvc + Added pvf.c and xi.c source files to project. + + * src/sndfile.h + Updated for PVF files. + +2003-01-07 Erik de Castro Lopo + + * src/sndfile.c + Modified validate_sfinfo() to force samplerate, channels and sections + to be >= 1. + In format_from_extension() replaced calls to does_extension_match() + with strcmp(). + + * src/xi.c + More work. + +2003-01-06 Erik de Castro Lopo + + * doc/Makefile.am + Added octave.html which had been left out. Found by Jan Weil. + +2003-01-05 Erik de Castro Lopo + + * src/pvf.c src/common.h src/sndfile.c + Fixed error handling for PVF files. + + * src/xi.c + New file for handling Fasttracker 2 Extended Instrument files. Not working + yet and included when configured with --enable-experimental. + + * src/sndfile.c src/common.h + Hooked in new file xi.c. + +2002-12-30 Erik de Castro Lopo + + * src/rx2.c + Added a patch from Marek Peteraj which sheds a little more light on the + slices within an RX2 file. Still need to find out data encoding. + +2002-12-20 Erik de Castro Lopo + + * src/wav.c + Started work on decoding 'acid' and 'strc' chunks. + +2002-12-14 Erik de Castro Lopo + + * tests/peak_check_test.c + Minor cleanup. + +2002-12-12 Erik de Castro Lopo + + * tests/write_read_test.tpl + Added check to make sure no error was generated when an attempt was made to + read past the end of the file. + +2002-12-11 Erik de Castro Lopo + + * doc/lists.html + Added "mailto" links for all three lists. + + * src/pvf.c + New file for Portable Voice Format files. + + * src/sndfile.h.in src/sndfile.c src/common.h src/command.c src/Makefile.am + Added hooks for SF_FORMAT_PVF format files. + + * tests/write_read_test.tpl tests/std*.c + Add tests for SF_FORMAT_PVF. + + * doc/index.html + Add PVF to the compatibility matrix. + + * src/pcm.c src/alaw.c src/ulaw.c src/float32.c src/double64.c + Previously, attempts to read beyond the end of a file would set psf->error + to SFE_SHORT_ERROR. This behaviour diverged from the behaviour of the POSIX + read() call but has now been fixed. + Attempts to read beyond the end of the file will return a short read count + but will not longer set any error. + +2002-12-09 Erik de Castro Lopo + + * src/sndfile.c + Add more sanity checking when opening a RAW file for read. When format is + not RAW, zero out all members of the SF_INFO struct. + + * tests/raw_test.c + Add bad_raw_test() to check for above problem. + + * tests/stdin_test.c examples/sndfile-info.c + Set the format field of the SF_INFO struct to zero before calling + sf_open(). + + * doc/api.html + Add information about the need to set the format field of the SF_INFO struct + to zero when opening non-RAW files for read. + + * configure.ac + Removed use of conversion script on Solaris. Not all Solaris versions + support it. + + * doc/lists.html + New file containg details of the mailing lists. + + * doc/index.html + Add a link to the above new file. + +2002-12-04 Erik de Castro Lopo + + * tests/dft_cmp.c + Fixed a SIGFPE on Alpha caused by a log10 (0.0). Thanks to Joshua Haberman + for providing the gdb traceback. + +2002-11-28 Erik de Castro Lopo + + * src/wav.c + Added more capabilities to 'smpl' chunk parser. + + * src/sndfile.c + Fixed some (not all) possible problems found with Flawfinder. + +2002-11-24 Erik de Castro Lopo + + * src/sndfile.c + Fixed a bug in sf_seek(). This bug could only occur when an attempt was + made to read beyond the end and then sf_seek() was called with a whence + parameter of SEEK_CUR. + + * src/file_io.c + Win32's _fstati64() does not work, it returns BS. Re-implemented + psf_get_filelen() in terms of psf_fseek(). + + * tests/write_read_test.tpl + Add a test to detect above bug. + + * src/float_cast.h + Modification to prevent compiler warnings on Mac OS X. + + * src/file_io.c + Fixes for windows (what a f**ked OS). + +2002-11-08 Erik de Castro Lopo + + * configure.ac + Disable use of native lrint()/lrintf() on Mac OSX. These functions exist on + Mac OSX 10.2 but not on 10.1. Forcing the use of the versions in + src/float_cast.h means that a library compiled on 10.2 will still work on + 10.1. + +2002-11-06 Erik de Castro Lopo + + * configure.in configure.ac + Renamed configure.in to configure.ac as expected by later versions of + autoconf. + Slight hacking of configure.ac to work with version 2.54 of autoconf. + Changed to using -dumpversion instead of --version for determining GCC + version numer as suggested by Anand Kumria. + + * src/G72x/Makefile.am + Slight hacking required for operation with automake 1.6.3. + +2002-11-05 Erik de Castro Lopo + + * src/common.c + In psf_binheader_readf() changed type parameter type "b" type from size_t + to int to prevent errors on IA64 CPU where sizeof (size_t) != sizeof (int). + Thanks to Enrique Robledo Arnuncio for debugging this. + +2002-11-04 Erik de Castro Lopo + + * test/command_test.tpl + Changed test value so test would pass on Solaris. + + * src/Version_script.in + Modified version numbering so that later versions of 1.0.X can replace + earlier versions without recompilation. + + * src/vox_adpcm.c + Fixed bug causing short reads. + +2002-11-03 Erik de Castro Lopo + + * test/floating_point_test.c + Code cleanup using functions from util.c. + Add test for IEEE replacement floats and doubles. + +2002-11-01 Erik de Castro Lopo + + * src/wav.c + Fixed a possible divide by zero error when read the 'smpl' chunk. Thanks to + Serg Repalov for the example file. + + * tests/pcm_test.tpl + Used sf_command (SFC_TEST_IEEE_FLOAT_REPLACE) to test IEEE replacement code. + Clean up pcm_double_test(). + + * src/float32.c src/double64.c + Force use of IEEE replacement code using psf->ieee_replace is TRUE, + Print message to log_buffer as well. + Rename all broken_read_* and broken_write* functions to replace_read_* and + replace_write_*. + + * tests/util.tpl + Added string_in_log_buffer(). + + * tests/pcm_test.tpl + Use string_in_log_buffer() to ensure that IEEE replacement code has been + used. + + * configure.in + Removed --enable-force-broken-float option. IEEE replacement code is now + always tested. + +2002-10-31 Erik de Castro Lopo + + * src/double64.c + Implement code for read/writing IEEE doubles on platforms where the native + double format is not IEEE. + + * src/float32.c src/common.h + Remove float32_read() and float32_write(). Replace with float32_le_read(), + float32_be_read(), float32_le_write() and float32_be_write() to match stuff + in src/double64.c. + + * src/common.c + Fix all usage of float32_write(). + + * src/sndfile.h.in + Added SFC_TEST_IEEE_FLOAT_REPLACE command (testing only). + + * src/common.h + Added SF_PRIVATE field ieee_replace. + + * src/sndfile.c + In sf_command() set/reset psf->ieee_replace. + +2002-10-26 Erik de Castro Lopo + + * tests/pcm_test.tpl + Fixed a problem when testing with --enable-force-broken-float. The test was + generating a value of negative zero and the broken float code is not able + to write negative zero. Removing the negative zero fixed the test. + +2002-10-25 Erik de Castro Lopo + + * src/file_io.c + Added fix for Cygwin (suggested by Maros Michalik). + +2002-10-23 Erik de Castro Lopo + + * src/file_io.c + Improved error detection and handling. + + * src/file_io.c src/common.h + Removed functions psf_ferror() and psf_clearerr() which were redundant + after above improvements. + + * src/aiff.c src/svx.c src/w64.c src/wav.c + Removed all use of psf_ferror() and psf_clearerr(). + + * src/sndfile.c + Removed #include of , , and which + are no longer needed. + + * tests/misc_test.c + Added test to make sure the correct error message is returned with an + existing read-only file is openned for write. + +2002-10-21 Erik de Castro Lopo + + * doc/index.html doc/api.html + Updated for OKI Dialogic ADPCM files. + + * src/command.c + Added VOX ADPCM to sub_fomats. + +2002-10-20 Erik de Castro Lopo + + * src/vox_adpcm.c src/Makefile.am + New file for handling OKI Dialogic ADPCM files. + + * src/sndfile.h + Add new subtype SF_FORMAT_VOX_ADPCM. + + * src/sndfile.c + Renamed function is_au_snd_file () to format_from_extenstion () and expanded + its functionality to detect headerless VOX files. + + * src/raw.c + Added hooks for SF_FORMAT_VOX_ADPCM. + + * examples/sndfile-info.c + Print out file duration (suggested by Conrad Parker). + + * libsndfile.spec.in + Force installation of sndfile.pc file (found by John Thompson). + + * tests/Makefile.am tests/lossy_comp_test.c tests/floating_point_test.c + Add tests for SF_FORMAT_VOX_ADPCM. + +2002-10-18 Erik de Castro Lopo + + * tests/misc_test.c + Add test which attempts to write to /dev/full (on Linux anyway) to check + for correct handling of writing to a full filesystem. + + * src/sndfile.c + Return correct error message if the header cannot be written because the + filesystem is full. + + * tests/util.tpl + Corrected printing of file mode in error reporting. + + * src/mat5.c + Fixed a bug where a MAT5 file written by libsndfile could not be opened by + Octave 2.1.36. + +2002-10-13 Erik de Castro Lopo + + * src/common.h src/file_io.c + All low level file I/O have been modified to be better able to report + system errors resulting from calling system level open/read/write etc. + + * src/*.c + Updated for compatibility with above changes. + + * examples/cooledit-fixer.c + New example program which fixes badly broken file created by Syntrillium's + Cooledit which are marked as containing PCM samples but actually contain + floating point data. + + * examples/Makefile.am + Hooked cooledit-fixer into the build system. + +2002-10-10 Erik de Castro Lopo + + * doc/command.html + Document SFC_GET_FORMAT_INFO. + +2002-10-09 Erik de Castro Lopo + + * examples/wav32_aiff24.c examples/sndfile2oct.c examples/sfhexdump.c + examples/sfdump.c + Removed these files because they weren't interesting. + + * examples/sfconvert.c examples/sndfile-convert.c + Renamed the first to the latter. + + * examples/Makefile.am + Added sndfile-convert to the bin_PROGRAMS, so it is installed when the lib + is installed. + Removed old programs wav32_aiff24 and sndfile2oct. + + * man/sndfile-convert.1 + New man page. + + * examples/sndfile-convert.c + Added some gloss now that sndfile-convert.c is an installed program. + + * src/sndfile.h.in src/sndfile.c src/common.h src/command.h + Added command SFC_GET_FORMAT_INFO. + + * tests/command_test.c + Added tests form SFC_GET_FORMAT_INFO. + +2002-10-08 Erik de Castro Lopo + + * src/sndfile.c + In sf_format_check() return error if samplerate < 0. + +2002-10-07 Erik de Castro Lopo + + * src/aiff.c + Fixed bug in handling of COMM chunks with a 4 byte encoding byte but no + encoding string. + +2002-10-06 Erik de Castro Lopo + + * src/sndfile.c + Fixed repeated word in an error message. + +2002-10-05 Erik de Castro Lopo + + * doc/index.html + Improved advertising in Features section. + +2002-10-04 Erik de Castro Lopo + + * src/wav.c + Added decoding of 'labl' chunks within 'LIST' chunks. + + * src/common.h + Added (experimental only) SF_FORMAT_OGG and SF_FORMAT_VORBIS and definition + of ogg_open(). This is nowhere near working yet. + + * src/sndfile.c + Added detection of 'OggS' file marker and added call to ogg_open() to + switch statement. + + * src/ogg.c + New file. Very early start of Ogg Vorbis support. + + * src/wav.c + Added handling of brain-damaged and broken Cooledit "32 bit 24.0 float + type 1" files. These files are marked as being 24 bit WAVE_FORMAT_PCM with + a block alignment of 4 times the numbers of channels but are in fact 32 bit + floating point. + +2002-10-02 Erik de Castro Lopo + + * configure.in + Modified option --enable-experimental to set ENABLE_EXPERIMENTAL_CODE in + config.h to either 0 or 1. + + * src/sndfile.c + Modify sf_command (SFC_GET_LIB_VERSION) to append "-exp" to the version + string if experimental code has been enabled. + +2002-10-01 Erik de Castro Lopo + + * src/Makefile.am + Added -lm to libsndfile_la_LIBADD. This means that -lm is not longer needed + in the link line when linking something to libsndfile. + + * tests/Makefile.am examples/Makefile.am + Removed -lm from all link lines. + + * sndfile.pc.in + Removed -lm from Libs line. + +2002-09-24 Erik de Castro Lopo + + * src/file_io.c + Removed all perror() calls. + + * src/nist.c + Removed calls to exit() function. + Added check to detect NIST files dammaged from Unix CR -> Win32 CRLF + conversion process. + +2002-09-24 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c + New function sf_strerror() which will eventually replace functions + sf_perror() and sf_error_str(). + Function sf_error_number() has also been changed, but this was documented + as being for testing only. + + * doc/api.html + Documented above changes. + + * tests/*.c examples/*.c + Changed to new error functions. + +2002-09-22 Erik de Castro Lopo + + * configure.in + Detect GCC version, and print a warning message about writeable strings + it GCC major version number is less than 3. + +2002-09-21 Erik de Castro Lopo + + * src/sndfile.h.in doc/api.html + Documentation fixes. + +2002-09-19 Erik de Castro Lopo + + * src/Version_script.in src/Makefile.am configure.in + Use the version script to prevent the exporting of all non public symbols. + This currently only works with Linux. Will test on Solaris as well. + + * src/float_cast.h + Added #ifndef to prevent the #warning directives killing the SGI MIPSpro + compiler. + + * src/au_g72x.c src/double64.c src/float32.c src/gsm610.c src/ima_adpcm.c + src/ms_adpcm.c + Fix benign compiler warnings arising from previously added compiler + flags. + +2002-09-18 Erik de Castro Lopo + + * src/sndfile.c + Fixed a bug in sf_error_str() where errnum was used as the index instead + of k. Found by Tim Hockin. + + * examples/sndfile-play.c + Fixed a compiler warning resulting from a variable shadowing a previously + defined local. + +2002-09-17 Erik de Castro Lopo + + * src/sndfile.h.in src/sndfile.c + Added command SFC_SET_RAW_START_OFFSET. + + * doc/command.html + Document SFC_SET_RAW_START_OFFSET. + + * tests/raw_test.c tests/Makefile.am + Add new file for testing SF_FORMAT_RAW specific functionality. + + * tests/dwvw_test.c + Updates. + +2002-09-16 Erik de Castro Lopo + + * src/wav.c + Modified reading of 'smpl' chunk to take account of the sampler data field. + + * tests/utils.tpl tests/utils.h + Added function print_test_name(). + + * tests/misc_test.c tests/write_read_test.tpl tests/lossy_comp_test.c + tests/pcm_test.tpl tests/command_test.tpl tests/floating_point_test.c + Convert to use function print_test_name(). + +2002-09-15 Erik de Castro Lopo + + * doc/octave.html + Added a link to some other Octave scripts for reading and writing sound + files. + + * src/paf.c + Change type of dummy data field to int. This should fix a benign compiler + warning on some CPUs. + Removed superfluous casts resulting from the above change. + + * src/rx2.c + More hacking. + +2002-09-14 Erik de Castro Lopo + + * src/mat5.c src/common.c + Changed usage of snprintf() to LSF_SNPRINTF(). + + * Win32/Makefile.msvc + Updated to include new files and add new tests. + + * Win32/config.h Win32/sndfile.h + Updated. + + * doc/api.html + Added note about the possibility of "missing" features actually being + implemented as an sf_command(). + +2002-09-13 Erik de Castro Lopo + + * tests/misc_test.c + Added previously missing update_header_test and zero_data_tests for PAF, + MAT4 and MAT5 formats. + + * src/paf.c src/mat4.c src/mat5.c + Fixed bugs uncovered by new tests above. + + * src/mat5.c + Generalised parsing of name fields of MAT5 files. + + * src/mat5.c src/sndfile.c + Added support for unsigned 8 bit PCM MAT5 files. + + * tests/write_read_test.tpl + Added test for unsigned 8 bit PCM MAT5 files. + + * doc/index.html + Added unsigned 8 bit PCM MAT5 to capabilities matrix. + +2002-09-12 Erik de Castro Lopo + + * test/update_header_test.c tests/misc_test.c + Renamed update_header_test.c to misc_test.c. + Added zero_data_test() to check for case where file is opened for write and + closed immediately. The resulting file can be left in a state where + libsndfile cannot open it. Problem reported by Werner Schweer, the author + of Muse. + + * src/aiff.c + Removed superfluous cast. + + * src/wav.c src/svx.c + Fixed case of file generated with no data. + Removed superfluous cast. + + * src/sndfile.c + Fixed error on IA64 platform caused by incorrect termination of + SndfileErrors struct array. This problem was found in the Debian buildd + logs (http://buildd.debian.org/). + + * configure.in + Added Octave directory. + + * Octave/Makefile.ma + New Makfile.am for Octave directory. + + * Octave/sndfile_load.m Octave/sndfile_save.m Octave/sndfile_play.m + New files for working with Octave. + + * doc/octave.html + Document explaining the use of the above three Octave scripts. + +2002-09-10 Erik de Castro Lopo + + * src/sndfile.c + Fixed bug in RDWR mode. + +2002-09-09 Erik de Castro Lopo + + * src/common.c + Fixed psf_get_date_str() for systems which don't have gmtime_r() or + gmtime(). + + * src/file_io.c + Added #include for Win32. Reported by Koen Tanghe. + +2002-09-08 Erik de Castro Lopo + + * src/common.c + Added 'S' format specifier for psf_binheader_writef() which writes a C + string, including single null terminator to the header. + Added 'j' format specifier to allow jumping forwards or backwards in the + header. + Added function psf_get_date_str(). + + * src/mat5.c + Complete read and write support. + + * doc/index.html + Added entries for MAT4 and MAT5 in capabilities matrix. + +2002-09-06 Erik de Castro Lopo + + * src/mat4.c + Completed read and write support. + + * src/common.h src/sndfile.c + Added MAT4 and MAT5 specific error messages. + + * tests/write_read_test.tpl tests/Makefile.am + Added tests for MAT4 and MAT5 files. + + * tests/stdio_test.c tests/stdout_test.c tests/stdin_test.c + Added tests for MAT4 and MAT5 files. + +2002-09-05 Erik de Castro Lopo + + * src/command.c + Added elements for SF_FORMAT_MAT4 and SF_FORMAT_MAT5 to major_formats + array. + + * examples/sfconvert.c + Added mat4 and mat5 output targets. + +2002-09-04 Erik de Castro Lopo + + * src/sndfile.c + Added check to prevent errors openning read only formats for read/write. + + * src/interleave.c + New file for interleaving non-interleaved data. Non-interleaved data is + only supported on read. + + * src/Makefile.am + Added src/interleave.c to build. + +2002-09-03 Erik de Castro Lopo + + * src/double64.c src/common.h + Added double64_be_read(), double64_le_read(), double64_be_write() and + double64_le_write() which replace double64_read() and double64_write(). + + * src/common.c + Cleanup of psf_binheader_readf() and add ability to read big and little + endian doubles (required by mat4.c and mat5.c). + Add ability for psf_binheader_writef() to write doubles to sound file + headers. + +2002-09-01 Erik de Castro Lopo + + * src/mat5.c + New file for reading Matlab (tm) version 5 data files. This is also the + native binary file format for version 2.1.X of GNU Octave which will be + used for testing. + Not complete yet. + + * src/mat4.c + New file for reading Matlab (tm) version 4.2 data files. This is also the + native binary file format for version 2.0.X of GNU Octave which will be + used for testing. + Not complete yet. + + * src/sndfile.h.in src/sndfile.c src/common.h src/command.c src/Makefile.am + Mods to add Matlab files. + + * src/common.[ch] + Added readf_endian field to SF_PRIVATE struct allowing endianness to + remembered across calls to sf_binheader_readf(). + Fixed bug in width_specifier behaviour for printing hex values. + +2002-08-31 Erik de Castro Lopo + + * src/file_io.c + Check return value of close() call in psf_fclose(). + +2002-08-24 Erik de Castro Lopo + + * src/ms_adpcm.c + Commented out some code where 0x10000 was being subtracted from a short + and the result assigned to a short again. Andrew Zaja found this. + +2002-08-23 Erik de Castro Lopo + + * doc/command.html + Fixed typo found by Tommi Ilmonen. + + * src/ima_adpcm.c + Changed type of diff from short to int to prevent errors which can occur + during very rare circumstances. Thanks to FUWAFUWA. + +2002-08-16 Erik de Castro Lopo + + * tests/floating_point_test.c + Disable testing on machines without lrintf(). + + * Win32/Makefile.msvc + Added dwd.c and wve.c to build. + + * configure.in + Bumped version to 1.0.0. + +2002-08-15 Erik de Castro Lopo + + * src/file_io.c + Add a #include for Mac OS 9. Thanks to Stephane Letz. + + * src/wav.c + Changed an snprintf to LSF_SNPRINTF. + + * doc/Makefile.am + Added version-1.html. + +2002-08-14 Erik de Castro Lopo + + * configure.in + Bumped version to 1.0.rc6. + + * src/*.c + Modified scaling of normalised floats and doubles to integers. Until now + this has been done by multiplying by 0x8000 for short output, 0x80000000 + for 32 bit ints and so on. Unfortunately this can cause an overflow and + wrap around in the target value. All thes values have therefore been + reduced to 0x7FFF, 0x7FFFFFFF and so on. The conversion from ints to + normalised floats and doubles remains unchanged. This does mean that for + repeated conversions normalised float -> pcm16 -> normalised float would + result in a decrease in amplitude of 0x7FFF/0x8000 on every round trip. + This is undesirable but less undesireable than the wrap around I am trying + to avoid. + + * tests/floating_point_test.c + Removed file hash checking because new float scaling procedure introduced + above prevented the ability to crate a has on both x86 and PowerPC systems. + +2002-08-13 Erik de Castro Lopo + + * src/txw.c + Completed reading of TXW files. Seek doesn't work yet. + + * src/file_io.c + Added a MacOS 9 replacement for ftruncate(). + + * MacOS/sndfile.h + Added MacOS 9 header file. This should be copied into src/ to compile + libsndfile for MacOS9. + +2002-08-12 Erik de Castro Lopo + + * src/sndfile.c + Fixed commands SF_SET_NORM_DOUBLE and SFC_SET_NORM_FLOAT to return their + values after being set. Reported by Jussi Laako. + + * configure.in + If autogen is not found, touch all .c and .h files in tests/. + + * src/common.c + Added format width specifier to psf_log_printf() for %u, %d, %D and %X. + + * src/dwd.c + Completed implementation of read only access to these files. + + * src/common.h src/*.c src/pcm.c + Removed redundant field chars from SF_PRIVATE struct and modified + pcm_init() to do without it. + +2002-08-11 Erik de Castro Lopo + + * src/wve.c + New file implementing read of Psion Alaw files. This will be a read only + format. Implementation complete. + + * src/dwd/c + Started implementation of DiamondWare Digitized files. Also read only, not + complete. + + * src/wav.c + Add parsing of 'smpl' chunk. + + * src/paf.c + Fixed reading on un-normalized doubles and floats from 24 bit PAF files. + This brings it into line with the reading of 8 bit files into + un-normalized doubles which returns values in the range [-128, 127]. + + * src/common.c + Modified psf_log_printf() to accept the %% conversion specifier to allow + printing of a single '%'. + + * src/sds.c + Read only of 16 bit samples is working. Need to build a test harness for + this and other read only formats. + +2002-08-10 Erik de Castro Lopo + + * configure.in + Added --enable-experimental configure option. + Removed pkg-config message at the end of the configure process. + + * src/sds.c src/txw.c src/rx2.c src/sd2.c + Moved all the code in these files inside #if ENABLE_EXPERIMENTAL_CODE + blocks and added new *_open() function for the case where experimental is + not enabled. These new functions just return SFE_UNIMPLMENTED. + + * Win32/sndfile.h src/sndfile.h.in src/common.h + Removed un-necessary #pragma pack commands. + + * src/file_io.c + Implemented psf_ftruncate() and much other hacking for Win32. + + * Win32/Makefile.msvc + Updated. + + * doc/win32.html + Updated to include the copying of the sndfile.h file from the Win32/ + directory to the src/ directory. + + * Make.bat + Batch file to make compiling on Wi32 a little easier. Implements "make" and + "make check". + +2002-08-09 Erik de Castro Lopo + + * src/file_io.c + Add place holder for ftruncate() on Win32 which doesn't have ftruncate(). + This will need to be fixed later. + + * src/sndfile.h.in + New file (copy of sndfile.h) with sets up @TYPEOF_SF_COUNT_T@ which will be + replaced by the correct type during configure. + + * configure.in + Modified to find a good type for TYPEOF_SF_COUNT_T. + + * src/aiff.c + Fixed a bug when reading malformed headers. + + * src/common.c + Set read values to zero before performing read. + +2002-08-08 Erik de Castro Lopo + + * doc/command.html + Fixed some HTML tags which were not allowing jumps to links within the + page. + + * src/sds.c + Massive hacking on this. + + * src/wav.c + Added recognition of 'clm ' tag. + +2002-08-07 Erik de Castro Lopo + + * doc/index.html + Added beginning of a capabilities list beyond simple file formats which + can be read/written. + + * src/aiff.c + Added parsing of INST and MARK chunks of AIFF files. At the moment this + data is simply recorded in the log buffer. Later it will be possible to + read this data from an application using sf_command(). + + * src/wav.c + Added parsing of 'cue ' chunk which contains loop information in WAV files. + + * exampes/sndfile-info.c + Changed reporting of Samples to Frames. + + * src/wav.c src/w64.c src/aiff.c src/wav_w64.h + Moved from a samples to a frames nomenclature to avoid confusion. + + * doc/FAQ.html + What's the best format for storing temporary files? + + * src/sds.c + New file for reading/writing Midi Sample Dump Standard files. + + * src/Makefile.am src/sndfile.c src/common.[ch] + Added hooks for sds.c. + + * examples/sndfile-info.c + Changed from using sf_perror() to using sf_error_str(). + +2002-08-06 Erik de Castro Lopo + + * doc/api.html + Added explanation of mode parameter for sf_open(). + Added explanation of usage of SFM_* values in sf_seek(). + + * src/sndfile.[ch] src/command.c src/file_io.c src/common.h + Implemented SFC_FILE_TRUNCATE to allow a file to be truncated. File + truncation was suggested by James McCartney. + + * src/command.html + Documented SFC_FILE_TRUNCATE. + + * tests/command_test.c + Add tests for SFC_FILE_TRUNCATE. + + * src/sndfile.c + Added a thrid parameter to the VALIDATE_SNDFILE_AND_ASSIGN_PSF macro to + make resetting the error number optional. All uses of the macro other than + in error reporting functions were changed to reset the error number. + + * src/pcm.c + Fixed a bug were sf_read_* was logging an SFE_SHORT_READ even when no error + occurred. + + * tests/write_read_test.tpl + Added tests of internal error state. + +2002-08-05 Erik de Castro Lopo + + * src/GSM610/private.h src/GSM610/*.c src/GSM610/Makefile.am + Renamed private.h to gsm610_priv.h to prevent clash with other headers + named private.h in other directories. (Probably only a problem on MacOS 9). + + * src/G72x/private.h src/G72x/*.c src/G72x/Makefile.am + Renamed private.h to g72x_priv.h to prevent clash with other headers + named private.h in other directories. (Probably only a problem on MacOS 9). + + * MacOS/config.h + Changed values of HAVE_LRINT and HAVE_LRINTF to force use of code in + float_cash.h. + + * src/sndfile.h + Changes the name of samples field of the SF_INFO to frames. The old name + had caused too much confusion and it simply had to be changed. There will + be at least one more pre-release. + +2002-08-04 Erik de Castro Lopo + + * doc/index.html + Updated formats matrix to include RAW (header-less) GSM 6.10. + Fix specificaltion of table and spelling mistakes. + + * src/sndfile.c src/command.c + Fixed bug in SFC_CALC_MAX_SIGNAL family and psf_calc_signal_max (). + + * tests/command.c + Removed cruft. + Added test for SFC_CALC_MAX_SIGNAL and SFC_CALC_NORM_MAX_SIGNAL. + + * configure.in + Update version to 1.0.0rc5. + + * sfendian.h + Removed inclusion of un-necessary header. + +2002-08-03 Erik de Castro Lopo + + * src/aiff.c + Minor fixes of info written to log buffer. + + * src/float_cast.h + Add definition of HAVE_LRINT_REPLACEMENT. + + * tests/floating_point_test.c + Fix file hash check on systems without lrint/lrintf. + + * tests/dft_cmp.c + Limit SNR to less than -500.0dB. + + * examples/sndfile2oct.c + Fixed compiler warnings. + + * doc/api.html + Fixed error where last parameter of sf_error_str() was sf_count_t instead + of size_t. + +2002-08-02 Erik de Castro Lopo + + * doc/FAQ.html + Why doesn't libsndfile do interleaving/de-interleaving. + + * tests/pcm_test.tpl + On Win32 do not perform hash check on files containing doubles. + +2002-08-01 Erik de Castro Lopo + + * src/common.h + Defined SF_COUNT_MAX_POSITIVE() macro, a portable way of setting variables + of type sf_count_t to their maximum positive value. + + * src/dwvw.c src/w64.c + Used SF_COUNT_MAX_POSITIVE(). + +2002-07-31 Erik de Castro Lopo + + * src/paf.c + Fixed bug in reading/writing of 24 bit PCM PAF files on big endian systems. + + * tests/floating_point_tests.c + Fixed hash values for 24 bit PCM PAF files. + Disabled file has check if lrintf() function is not available and added + warning. + Decreased level of signal from a peak of 1.0 to a value of 0.95 to prevent + problems on platforms without lrintf() ie Solaris. + +2002-07-30 Erik de Castro Lopo + + * src/wav.c + Fixed a problem with two different kinds of mal-formed WAV file header. The + first had the 'fact' chunk before the 'fmt ' chunk, the other had an + incomplete 'INFO' chunk at the end of the file. + + * src/w64.c + Added fix to allow differentiation between W64 files and ACID files. + + * src/au_g72x.c src/common.h src/sndfile.c + Added error for G72x encoded files with more than one channel. + + * tests/pcm_test.tpl tests/utils.tpl + Moved function check_file_hash_or_die() to utils.tpl. Function was then + modified to calculate the has of the whole file. + + * src/wav.c + Fixed problem writing the 'fact' chunk on big endian systems. + + * tests/sfconvert.c + Fixed bug where .paf files were being written as Sphere NIST. + +2002-07-29 Erik de Castro Lopo + + * src/voc.c + Fix for reading headers generated using SFC_UPDATE_HEADER_NOW. + + * doc/command.html + Add docs for SFC_UPDATE_HEADER_NOW and SFC_SET_UPDATE_HEADER_AUTO. + +2002-07-28 Erik de Castro Lopo + + * man/sndfile-info.1 man/sndfile-play.1 + Added manpages supplied by Joshua Haberman the Debian maintainer for + libsndfile. Additional tweaks by me. + + * configure.in man/Makefile.am + Hooked manpages into autoconf/automake system. + + * src/sndfile.c + Added hooks for SFC_SET_UPDATE_HEADER_AUTO. + + * tests/update_header_test.c + Improved rigor of testing. + + * src/*.c + Fixed problem with *_write_header() functions. + +2002-07-27 Erik de Castro Lopo + + * doc/*.html + Updates to documentation to fix problems found by wdg-html-validator. + + * src/common.h src/command.c + Added normalize parameter to calls to psf_calc_signal_max() and + psf_calc_max_all_channels(). + + * src/sndfile.c + Added handling for commands SFC_CALC_NORM_SIGNAL_MAX and + SFC_CALC_NORM_MAX_ALL_CHANNELS. + + * doc/command.html + Added entry for SFC_CALC_NORM_SIGNAL_MAX and SFC_CALC_NORM_MAX_ALL_CHANNELS. + +2002-07-26 Erik de Castro Lopo + + * examples/sndfile-play.c Win32/Makefile.msvc + Get sndfile-play program working on Win32. The Win32 PCM sample I/O API + sucks. The sndfile-play program now works on Linux, MacOSX, Solaris and + Win32. + +2002-07-25 Erik de Castro Lopo + + * doc/FAQ.html + New file for frequently asked questsions. + +2002-07-22 Erik de Castro Lopo + + * doc/api.html + Documentation fixes. + + * src/au.[ch] src/au_g72x.c src/G72x/g72x.h + Add support of 40kbps G723 ADPCM encoding. + + * tests/lossy_comp_test.c tests/floating_point_test.c + Add tests for 40kbps G723 ADPCM encoding. + + * doc/index.html + Update support matrix. + +2002-07-21 Erik de Castro Lopo + + * doc/command.html + Documented SFC_GET_SIMPLE_FORMAT_COUNT, SFC_GET_SIMPLE_FORMAT, + SFC_GET_FORMAT_* and SFC_SET_ADD_PEAK_CHUNK. + + * src/sndfile.c src/pcm.c + Add ability to turn on and off the addition of a PEAK chunk for floating + point WAV and AIFF files. + + * src/sndfile.[ch] src/common.h src/command.c + Added sf_command SFC_CALC_MAX_ALL_CHANNELS. Implemented by Maurizio Umberto + Puxeddu. + + * doc/command.html + Docs for SFC_CALC_MAX_ALL_CHANNELS (assisted by Maurizio Umberto Puxeddu). + +2002-07-18 Erik de Castro Lopo + + * src/sndfile.c src/gsm610.c + Finalised support for GSM 6.10 AIFF files and added support for GSM 6.10 + encoded RAW (header-less) files. + + * src/wav.c + Add support for IBM_FORMAT_MULAW and IBM_FORMAT_ALAW encodings. + + * src/api.html + Fixed more documentation bugs. + +2002-07-17 Erik de Castro Lopo + + * src/sndfile.h src/common.h + Moved some yet-to-be-implelmented values for SF_FORMAT_* from the public + header file sndfile.h to the private header file common.h to avoid + confusion about the actual capabilities of libsndfile. + +2002-07-16 Erik de Castro Lopo + + * src/aiff.c src/wav.c + Fixed file parsing for WAV and AIFF files containing non-audio data after + the data chunk. + + * src/aiff.c src/sndfile.c + Add support for GSM 6.10 encoded AIFF files. + + * tests/lossy_comp_test.c tests/Makefile.am + Add tests for GSM 6.10 encoded AIFF files. + + * src/*.c + Fix compiler warnings. + +2002-07-15 Erik de Castro Lopo + + * tests/command_test.c + For SFC_SET_NORM_* tests, change the file format from SF_FORMAT_WAV to + SF_FORMAT_RAW. + + * src/sndfile.c + Added sf_command(SFC_TEST_ADD_TRAILING_DATA) to allow testing of reading + from AIFF and WAV files with non-audio data after the audio chunk. + + * src/common.h + Add test commands SFC_TEST_WAV_ADD_INFO_CHUNK and + SFC_TEST_AIFF_ADD_INST_CHUNK. When these commands are working, they will be + moved to src/sndfile.h + + * src/aiff.c src/wav.c + Begin implementation of XXXX_command() hook for sf_command(). + + * tests/write_read_test.tpl + Added sf_command (SFC_TEST_ADD_TRAILING_DATA) to ensure above new code was + working. + +2002-07-13 Erik de Castro Lopo + + * tests/update_header_test.c + Allow read sample count == write sample count - 1 to fix problems with VOC + files. + + * tests/write_read_test.tpl tests/pcm_test.tpl + Fixed some problems in the test suite discovered by using Valgrind. + +2002-07-12 Erik de Castro Lopo + + * tests/utils.[ch] tests/*.c + Renamed check_log_buffer() to check_log_buffer_or_die(). + + * src/sndfile.c + SFC_UPDATE_HEADER_NOW and SFC_SETUPDATE_HEADER_AUTO almost finished. Works + for all file formats other than VOC. + +2002-07-11 Erik de Castro Lopo + + * src/sndfile.[ch] src/common.h + Started adding functionality to allow the file header to be updated before + the file is closed on files open for SFM_WRITE. This was requested by + Maurizio Umberto Puxeddu who is using libsndfile for file I/O in iCSound. + + * tests/update_header_test.c + New test program to test that the above functionality is working correctly. + + * tests/peak_chunk_test.c tests/floating_point_test.c + Cleanups. + +2002-07-10 Erik de Castro Lopo + + * src/sfendian.[ch] + Changed length count parameters for all endswap_XXX() functions from + sf_count_t (which can be 64 bit even on 32 bit architectures) to int. These + functions are only called frin inside the library, are always called with + integer parameters and doing the actual calculation on 64 bit values is + slow in comparision to doing it on ints. + + * examples/sndfile-play.c + More playback hacking for Win32. + +2002-07-09 Erik de Castro Lopo + + * src/common.c + In psf_log_printf(), changed %D format conversion specifier to %M (marker) and + added %D specifier for printing the sf_count_t type. + + * src/*.c + Changed all usage of psf_log_printf() with %D format conversion specifiers + to use %M conversion instead. + + * tests/pcm_test.tpl tests/pcm_test.def + New files to autogen pcm_test.c. + + * src/pcm.c + Fixed bug in scaling floats and doubles to 24 bit PCM and vice versa. + +2002-07-08 Erik de Castro Lopo + + * configure.in + Fix setup of $ac_cv_sys_largefile_CFLAGS so that sndfile.pc gets valid + values for CFLAGS. + + * examples/sndfile-play.c + Start adding playback support for Win32. + +2002-07-07 Erik de Castro Lopo + + * src/*.c + Worked to removed compiler warnings. + Extensive refactoring. + + * src/common.[ch] + Added function psf_memset() which works like the standard C function memset + but takes and sf_count_t as the length parameter. + + * src/sndfile.c + Replaced calls to memset(0 with calls to psf_memset() as required. + +2002-07-06 Erik de Castro Lopo + + * src/sndfile.c + Added "libsndfile : " to the start of all error messages. This was suggested + by Conrad Parker author of Sweep ( http://sweep.sourceforge.net/ ). + + * src/sfendian.[ch] + Added endswap_XXXX_copy() functions. + + * src/pcm.c src/float32.c src/double64.c + Use endswap_XXXX_copy() functions and removed dead code. + Cleanups and optimisations. + +2002-07-05 Erik de Castro Lopo + + * src/sndfile.c src/sndfile.h + Gave values to all the SFC_* enum values to allow better control of the + interface as commands are added and removed. + Added new command SFC_SET_ADD_PEAK_CHUNK. + + * src/wav.c src/aiff.c + Modified wav_write_header and aiff_write_header to make addition of a PEAK + chunk optional, even on floating point files. + + * tests/benchmark.tpl + Added call to sf_command(SFC_SET_ADD_PEAK_CHUNK) to turn off addition of a + PEAK chunk for the benchmark where we are trying to miximize speed. + + * src.pcm.c + Changed tribyte typedef to something more sensible. + Further conversion speed ups. + +2002-07-03 Erik de Castro Lopo + + * src/command.c + In major_formats rename "Sphere NIST" to "NIST Sphere". + + * src/common.c src/sfendian.c + Moved all endswap_XXX_array() functions to sfendian.c. These functions will + be tweaked to provide maximum performance. Since maximum performance on one + platform does not guarantee maximum performance on another, a small set of + functions will be written and the optimal one chosen at compile time. + + * src/common.h src/sfendian.h + Declarations of all endswap_XXX_array() functions moved to sfendian.h. + + * src/Makefile.am + Add sfendian.c to build targets. + +2002-07-01 Erik de Castro Lopo + + * src/pcm.c src/sfendian.h + Re-coded PCM encoders and decoders to match or better the speed of + libsndfile version 0.0.28. + +2002-06-30 Erik de Castro Lopo + + * src/wav.c + Add checking for WAVPACK data in standard PCM WAV file. Return error if + found. This WAVPACK is *WAY* broken. It uses the same PCM WAV file header + and then stores non-PCM data. + + * tests/benchmark.tpl + Added more tests. + +2002-06-29 Erik de Castro Lopo + + * tests/benchmark.tpl + Added conditional definition of M_PI. + For Win32, set WRITE_PERMS to 0777. + + * Win32/Makefile.msvc + Added target to make generate program on Win32. + + * src/samplitude.c + Removed handler for Samplitude RAP file format. This file type seems rarer + than hens teeth and is completely undocumented. + + * src/common.h src/sndfile.c src/Makefile.am Win32/Makefile.msvc + Removed references to sampltiude RAP format. + + * tests/benchmark.tpl + Benchmark program now prints the libsndfile version number when run. This + program was also backported to version 0 to compare results. Version + 1.0.0rc2 is faster than version 0.0.28 on most conversions but slower on + some. The slow ones need to be fixed before final release. + +2002-06-28 Erik de Castro Lopo + + * tests/benchmark.def tests/benchmark.tpl + New files which generate tests/benchmark.c using Autogen. Added int -> + SF_FORMAT_PCM_24 test. + + * tests/benchmark.c + Now and Autogen output file. + + * tests/Makefile.am + Updated for above changes. + +2002-06-27 Erik de Castro Lopo + + * tests/benchmark.c + Basic benchmark program complete. Need to convert it to Autogen. + + * Win32/Makefile.msvc + Added benchmark.exe target. + +2002-06-26 Erik de Castro Lopo + + * examples/generate.c + New program to generate a number of different output file formats from a + single input file. This allows testing of the created files. + + * tests/benchmark.c + New test program to benchmark libsndfile. Nowhere near complete yet. + + * examples/Makefile.am tests/Makefile.am + New make rules for the two new programs. + +2002-06-25 Erik de Castro Lopo + + * Win32/libsndfile.def + Removed definition for sf_signal_max(). + + * src/sndfile.c + Removed cruft. + + * doc/index.html + A number of documentation bugs were fixed. Thanks to Anand Kumria. + + * doc/version-1.html + Minor doc updates. + + * configure.in + Bumped version to 1.0.0rc2. + + * src/sf_command.h src/Makefile.am + Removed the header file as it was no longer being used. Thanks to Anand + Kunria for spotting this. + + * doc/index.html + A number of documentation bugs were fixed. Thanks to Anand Kumria. + +2002-06-24 Erik de Castro Lopo + + * src/common.h + Test for Win32 before testing SIZEOF_OFF_T so that it works correctly + on Win32.. + + * src/file_io.c + Win32 fixes to ensure O_BINARY is used for file open. + + * doc/win32.html + New file documenting the building libsndfile on Win32. + + * doc/*.html + Updating of documentation. + +2002-06-23 Erik de Castro Lopo + + * tests/pcm_test.c + Minor changes to allow easier determination of test file name. + + * src/sndfile.[ch] + Removed function sf_signal_max(). + + * examples/sndfile-play.c + Changed call to sf_signal_max() to a call to sf_command(). + +2002-06-22 Erik de Castro Lopo + + * src/format.c src/command.c + Renamed format.c to command.c which will now include code for sf_command() + calls to perform operations other than format commands. + + * src/sndfile.c src/sndfile.h + Removed function sf_get_signal_max() which is replaced by commands passed + to sf_command(). + + * src/command.c + Implement commands SFC_CALC_SIGNAL_MAX. + + * doc/command.html + Documented SFC_CALC_SIGNAL_MAX. + +2002-06-21 Erik de Castro Lopo + + * examples/sndfile-play.c + Mods to make sndfile-play work on Solaris. The program sndfile-play now + runs on Linux, MaxOSX and Solaris. Win32 to come. + + * src/format.c + Added SF_FORMAT_DWVW_* to subtype_formats array. + + * src/nist.c + Added support for 8 bit NIST Sphere files. Example file supplied by Anand + Kumria. + +2002-06-20 Erik de Castro Lopo + + * examples/sndfile-info.c + Tidy up of output format. + + * examnples/sndfile-play.c + Mods to make sndfile-play work on MacOSX using Apple's CoreAudio API. + + * configure.in + Add new variables OS_SPECIFIC_INCLUDES and OS_SPECIFIC_LINKS which were + required to supply extra include paths and link parameters to get + sndfile-play working on MacOSX. + + * examples/Makefile.am + Use OS_SPOECIFIC_INCLUDES and OS_SPECIFIC_LINKS to build commands for + sndfile-play. + +2002-06-19 Erik de Castro Lopo + + * src/nist.c + Added ability to read/write new NIST Sphere file types (A-law, u-law). + Header parser was re-written from scratch. Example files supplied by Anand + Kumria. + + * src/sndfile.c + Support for A-law and u-law NIST files. + + * tests/Makefile.am tests/lossy_comp_test.c + Tests for A-law and u-law NIST files. + +2002-06-18 Erik de Castro Lopo + + * tests/utils.c + Fixed an error in error string. + +2002-06-17 Erik de Castro Lopo + + * acinclude.m4 + Removed exit command to allow cross-compiling. + + * Win32/unistd.h src/file_io.c + Moved contents of first file into the second file (enclosed in #ifdef). + Win32/unistd.h is now an empty file but still must be there for libsndfile + to compile on Win32. + + * src/sd2.c, src/sndfile.c: + Fixes for Sound Designer II files on big endian systems. + +2002-06-16 Erik de Castro Lopo + + * configure.in + Modified to work around problems with crappy MacOSX version of sed. + Added sanity check for proper values for CFLAGS. + +2002-06-14 Erik de Castro Lopo + + * src/sndfile.c + Code clean up in sf_open (). + + * Win32/Makefile.msvc + Michael Fink's contributed MSVC++ makefile was hacked to bits and put back + together in a new improved form. + + * src/file_io.c + Fixes for Win32; _lseeki64() returns an invalid argument for calls like + _lseeki64(fd, 0, SEEK_CUR) so need to use _telli64 (fd) instead. + + * src/common.h src/sndfile.c src/wav.c src/aiff.c + Added SFE_LOG_OVERRUN error. + Added termination for potential infinite loop when parsing file headers. + + * src/wav.c src/w64.c + Fixed bug casuing incorrect header generation when opening file read/write. + +2002-06-12 Erik de Castro Lopo + + * doc/api.html + Improved the documentation to make it clearer that the file read method + and the underlying file format are completely disconnected. Suggested + by Josh Green. + + * doc/command.html + Started correcting docs to take into account changes made to the + operations of the sf_command () function. Not complete yet. + + * src/sndfile.c + Reverted some changes which had broken the partially working SDII header + parsing. Now have access to an iBook with OS X so reading and writing SDII + files on all platforms should be a reality in the near future. On Mac this + will involve reading the resource fork via the standard MacOS API. To move + a file from Mac to another OS, the resource and data forks will need to be + combined before transfer. The combined file will be read on both Mac and + other OSes like any other file. + +2002-06-08 Erik de Castro Lopo + + * ltmain.sh + Applied a patch from http://fink.sourceforge.net/doc/porting/libtool.php + which allows libsndfile to compile on MacOSX 10.1. This patch should not + interfere with compiling on other OSes. + + * src/GSM610/private.h + Changes to fix compile problems on MacOSX (see src/GSM610/ChangeLog). + + * src/float_cast.h + Added MacOSX replacements for lrint() and lrintf(). + +2002-06-05 Erik de Castro Lopo + + * src/sndfile.c + Replaced the code to print the filename to the log buffer when a file is + opened. This code seems to have been left out during the merge of + sf_open_read() and sf_open_write() to make a single functions sf_open(). + +2002-06-01 Erik de Castro Lopo + + * src/wav.c + Fixed a bug where the WAV header parser was going into an infinite loop + on a badly formed LIST chunk. File supplied by David Viens. + +2002-05-25 Erik de Castro Lopo + + * configure.in + Added a message at the end of the configuration process to warn about the + need for the use of pkg-config when linking programs against version 1 of + libsndfile. + + * doc/pkg-config.html + New documentation file containing details of how to use pkg-config to + retrieve settings for CFLAGS and library locations for linking files + against version 1 of libsndfile. + +2002-05-17 Erik de Castro Lopo + + * src/wav.c + Fixed minor bug in handling of so-called ACIDized WAV files. + +2002-05-16 Erik de Castro Lopo + + * Win32/libsndfile.def Win32/Makefile.msvc + Two new files contributed by Michael Fink (from the winLAME project) + which allows libsndfile to be built on windows in a MSDOS box by doing + "nmake -f Makefile.msvc". Way cool! + +2002-05-15 Erik de Castro Lopo + + * configure.in + MacOSX is SSSOOOOOOO screwed up!!! I can't believe how hard it is to + generate a tarball which will configure and compile on that platform. + Joined the libtool mailing list to try and get some answers. + +2002-05-13 Erik de Castro Lopo + + * configure.in + Changed to autoconf version 2.50. MacOSX uses autoconf version 2.53 which + is incompatible with with version 2.13 which had been using until now. + The AC_SYS_LARGE_FILE macro distributed withe autoconf 2.50 is missing a + few features so AC_SYS_EXTRA_LARGE file was defined to replace it. + + * configure.in + Changed to automake version 1.5 to try and make a tarball which will + work on MacOSX. + +2002-05-12 Erik de Castro Lopo + + * src/wav_gsm610.c + Changed name to gsm610.c. Added reading/writing of headerless files. + + * src/sndfile.c src/raw.c + Added ability to read/write headerless (SF_FORMAT_RAW) GSM 6.10 files. + +2002-05-11 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Clean up in preparation for Autogen-ing this file. + + * src/GSM610/*.[ch] + Code cleanup and prepartion forgetting file seek working. Details in + src/GSM610/ChangeLog. + + * sndfile.pc.in + Testing complete. Is sndfile.m4 still needed? + +2002-05-09 Erik de Castro Lopo + + * tests/write_read_test.tpl tests/rdwr_test.tpl + Merged tests from these two programs into write_read_test.tpl and deleted + rdwr_test.tpl. + +2002-05-08 Erik de Castro Lopo + + * src/w64.c src/svx.c src/paf.c + Fixed bugs in read/write mode. + +2002-05-07 Erik de Castro Lopo + + * examples/Makefile.am + Renamed sfplay.c to sndfile-play.c and sndfile_info.c to sndfile-info.c for + consistency when these programs become part of the Debian package + sndfile-programs. + + * sndfile.pc.in + New file to replace sndfile-config.in. Libsndfile now uses the pkg-config + model for providing installation parameters to dependant programs. + + * src/sndfile.c + Cleanup of code in sf_open(). + +2002-05-06 Erik de Castro Lopo + + * tests/utils.tpl tests/write_read_test.tpl + More conversion to Autogen fixes and enchancements. + + * src/*.c + Read/write mode is now working for 16, 24 and 32 bit PCM as well as 32 + bit float and 64 bit double data. More tests still required. + + * src/Makefile.am + Added DISTCLEANFILES target to remove config.status and config.last. + + * Win32/Makefile.am MacOS/Makefile.am + Added DISTCLEANFILES target to remove Makefile. + +2002-05-05 Erik de Castro Lopo + + * src/*.[ch] tests/rdwr_test.c + More verifying workings of read/write mode. Fixing bugs found. + + * tests/utils.[ch] + Made these files Autogen generated files. + + * tests/util.tpl tests/util.def + New Autogen files to generate utils.[ch]. Moved some generic test functions + into this file. Autogen is such a great tool! + +2002-05-03 Erik de Castro Lopo + + * src/pcm.c src/float_cast.h Win32/config.h + Fixed a couple of Win32 specific bugs pointed out by Michael Fink + (maintainer of WinLAME) and David Viens. + + * tests/check_log_buffer.[ch] tests/utils.[ch] + Moved check_log_buffer() to utils.[ch] and deleted old file. + +2002-05-02 Erik de Castro Lopo + + * src/common.[ch] src/sndfile.c + New function psf_default_seek() which will be the default seek function + for things like PCM and floating point data. This default is set for + both read and write in sf_open() but can be over-ridden by any codec + during it's initialisation. + +2002-05-01 Erik de Castro Lopo + + * src/au.c + AU files use a data size value of -1 to mean unknown. Fixed au_open_read() + to allow opening files like this. + + * tests/rdwr_test .c + Added more tests. + + * src/sndfile.c + Fixed bugs in read/write mode found due to improvements in the test + program. + +2002-04-30 Erik de Castro Lopo + + * tests/rdwr_test .c + New file for testing read/write mode. + +2002-04-29 Erik de Castro Lopo + + * m4/* + Removed all m4 macros from this directory as they get concatenated to form + the file aclocal.m4 anyway. + + * sndfile.m4 + Moved this from the m4 directory to the root directory asn this is part of + the distribution and is installed during "make install". + +2002-04-29 Erik de Castro Lopo + + * src/float32.c + Removed logging of peaks for all file formats other than AIFF and WAV. + + * tests/write_read_test.tpl tests/write_read_test.def + New files which autogen uses to generate write_read_test.c. Doing it this + way makes write_read_test.c far easier to maintain. Other test programs + will be converted to autogen in the near future. + + * src/*.c + Fixed a few bugs found when testing on Sparc (bug endian) Solaris. + +2002-04-28 Erik de Castro Lopo + + * doc/*.html + Fixed documention versioning. + + * configure.in + Fixed a bug in the routines which search for Large File Support on systems + which have large file support by defualt. + +2002-04-27 Erik de Castro Lopo + + * src/*.[ch] + Found and fixed an issue which can cause a bug in other software (I was + porting Conrad Parker's Sweep program from version 0 of the library to + version 1). When opening a file for write, the libsndfile code would + set the sfinfo.samples field to a maximum value. + + * tests/write_read_test.c + Added tests to detect the above problem. + +2002-04-25 Erik de Castro Lopo + + * src/*.[ch] + Finished base implementation of read/write mode. Much more testing still + needed. + + * m4/largefile.m4 + Macro for detecting Large File Standard capabilities. This macro was ripped + out of the aclocal.m4 file of GNU tar-1.13. + + * configure.in + Added detection of large file support. Files larger than 2 Gigabytes should + now be supported on 64 bit platforms and many 32 bit platforms including + Linux (2.4 kernel, glibc-2.2), *BSD, MacOS, Win32. + + * libsndfile_convert_version.py + A Python script which attempts to autoconvert code written to use version 0 + to version 1. + +2002-04-24 Erik de Castro Lopo + + * src/*.[ch] + Finished base implementation of read/write mode. Much more testing still + needed. + + * tests/write_read_test.c + Preliminary tests for read/write mode added. More needed. + +2002-04-20 Erik de Castro Lopo + + * src/sndfile.[ch] + Removed sf_open_read() and sf_open_write() functions,replacting them with + sf_open() which takes an extra mode parameter (SF_OPEN_READ, SF_OPEN_WRITE, + or SF_OPEN_RDWR). This new function sf_open can now be modified to allow + opening a file formodification (RDWR). + +2002-04-19 Erik de Castro Lopo + + * src/*.c + Completed merging of separate xxx_open_read() and xxx_open_write() + functions. All tests pass. + +2002-04-18 Erik de Castro Lopo + + * src/au.c + Massive refactoring required to merge au_open_read() with au_open_write() + to create au_open(). + +2002-04-17 Erik de Castro Lopo + + * src/*.c + Started changes required to allow a sound file to be opened in read/write + mode, with separate file pointers for read and write. This involves merging + of encoder/decoder functions like pcm_read_init() and pcm_write_init() + int a new function pcm_init() as well as doing something similar for all + the file type specific functions ie aiff_open_read() and aiff_open_write() + were merged to make the function aiff_open(). + +2002-04-15 Erik de Castro Lopo + + * src/file_io.c + New file containing psf_fopen(), psf_fread(), psf_fwrite(), psf_fseek() and + psf_ftell() functions. These function will replace use of fopen/fread/fwrite + etc and allow access to files larger than 2 gigabytes on a number of 32 bit + OSes (Linux on x86, 32 bit Solaris user space apps, Win32 and MacOS). + + * src/*.c + Replaced all instances of fopen with psf_open, fread with psd_read, fwrite + with psf_write and so on. + +2002-03-11 Erik de Castro Lopo + + * src/dwvw.c + Finally fixed all known problems with 12, 16 and 24 bit DWVW encoding. + + * tests/floating_point_test.c + Added tests for 12, 16 and 24 bit DWVW encoding. + +2002-03-03 Erik de Castro Lopo + + * m4/endian.m4 + Defines a new m4 macro AC_C_FIND_ENDIAN, for determining the endian-ness of + the target CPU. It first checks for the definition of BYTE_ORDER in + , then in and . If none of these work + and the C compiler is not a cross compiler it compiles and runs a program + to test for endian-ness. If the compiler is a cross compiler it makes a + guess based on $target_cpu. + + * configure.in + Modified to use AC_C_FIND_ENDIAN. + + * src/sfendian.h + Simplified. + +2002-02-23 Erik de Castro Lopo + + * tests/floating_point_test.c + Tests completely rewritten using the dft_cmp function. Now able to + calculate a quick guesstimate of the Signal to Noise Ratio of the encoder. + +2002-02-15 Erik de Castro Lopo + + * tests/dft_cmp.[ch] + New files containing functions for comparing pre and post lossily + compressed data using a quickly hacked DFT. + + * tests/utils.[ch] + New files containing functions for saving pre and post encoded data in a + file readable by the GNU Octave package. + +2002-02-13 Erik de Castro Lopo + + * m4/lrint.m4 m4/lrintf.m4 + Fixed m4 macros to define HAVE_LRINT and HAVE_LRINTF even when the test + is cached. + +2002-02-12 Erik de Castro Lopo + + * tests/floating_point_test.c + Fixed improper use of strncat (). + +2002-02-11 Erik de Castro Lopo + + * tests/headerless_test.c + New test program to test the ability to open and read a known file type as a + RAW header-less file. + +2002-02-07 Erik de Castro Lopo + + * tests/losy_comp_test.c + Added a test to ensure that the data read from a file is not all zeros. + + * examples/sfconvert.c + Added "-gsm610" encoding types. + +2002-01-29 Erik de Castro Lopo + + * examples/sfconvert.c + Added "-dwvw12", "-dwvw16" and "-dwvw24" encoding types. + + * tests/dwvw_test.c + New file for testing DWVW encoder/decoder. + +2002-01-28 Erik de Castro Lopo + + * src/dwvw.c + Implemented writing of DWVW. 12 bit seems to work, 16 and 24 bit still broken. + + * src/aiff.c + Improved reporting of encoding types. + + * src/voc.c + Clean up. + +2002-01-27 Erik de Castro Lopo + + * src/dwvw.c + New file implementing lossless Delta Word Variable Width (DWVW) encoding. + Reading 12 bit DWVW is now working. + + * src/aiff.c common.h sndfile.c + Added hooks for DWVW encoded AIFF and RAW files. + +2002-01-15 Erik de Castro Lopo + + * src/w64.c + Robustify header parsing. + + * src/wav_w64.h + Header file wav.h was renamed to wav_w64.h to signify sharing of + definitions across the two file types. + + * src/wav.c src/w64.c src/wav_w64.c + Refactoring. + Modified and moved functions with a high degree of similarity between + wav.c and w64.c to wav_w64.c. + +2002-01-14 Erik de Castro Lopo + + * src/w64.c + Completed work on getting read and write working. + + * examples/sfplay.c + Added code to scale floating point data so it plays at a reasonable volume. + + * tests/Makefile.am tests/write_read_test.c + Added tests for W64 files. + +2002-01-13 Erik de Castro Lopo + + * src/*.c + Modded all code in file header writing routines to use + psf_new_binheader_writef(). + Removed psf_binheader_writef() from src/common.c. + Globally replaced psf_new_binheader_writef with psf_binheader_writef. + +2002-01-12 Erik de Castro Lopo + + * src/*.c + Modded all code in file parsing routines to use psf_new_binheader_readf(). + Removed psf_binheader_readf() from src/common.c. + Globally replaced psf_new_binheader_readf with psf_binheader_readf. + + * src/common.[ch] + Added new function psf_new_binheader_writef () which will soon replace + psf_binheader_writef (). The new function has basically the same function + as the original but has a more flexible and capable interface. It also + allows the writing of 64 bit integer values for files contains 64 bit file + offsets. + +2002-01-11 Erik de Castro Lopo + + * src/formats.c src/sndfile.c src/sndfile.h + Added code allowing full enumeration of supported file formats via the + sf_command () interface. + This feature will allow applications to avoid needing recompilation when + support for new file formats are added to libsndfile. + + * tests/command_test.c + Added test code for the above feature. + + * examples/list_formats.c + New file. An example of the use of the supported file enumeration + interface. This program lists all the major formats and for each major + format the supported subformats. + +2002-01-10 Erik de Castro Lopo + + * src/*.[ch] tests/*.c + Changed command parameter of sf_command () function from a test string to + an int. The valid values for the command parameter begin with SFC_ and are + listed in src/sndfile.h. + +2001-12-20 Erik de Castro Lopo + + * src/formats.c src/sndfile.c + Added an way of enumerating a set of common file formats using the + sf_command () interface. This interface was suggested by Dominic Mazzoni, + one of the main authors of Audacity (http://audacity.sourceforge.net/). + +2001-12-26 Erik de Castro Lopo + + * src/sndfile.c + Added checking of filename parameter in sf_open_read (). Previousy, if a + NULL pointer was passed the library would segfault. + +2001-12-18 Erik de Castro Lopo + + * src/common.c src/common.h + Changed the len parameter of the endswap_*_array () functions from type + int to type long. + + * src/pcm.c + Fixed a problem which + +2001-12-15 Erik de Castro Lopo + + * src/sndfile.c + Added conditional #include for EMX/gcc on OS/2. Thanks to + Paul Hartman for pointing this out. + + * tests/lossy_comp_test.c tests/floating_point_test.c + Added definitions for M_PI for when it isn't defined in . + +2001-11-30 Erik de Castro Lopo + + * src/ircam.c + Re-implemented the header reader. Old version was making incorrect + assumptions about the endian-ness of the file from the magic number at the + start of the file. The new code looks at the integer which holds the + number of channels and determines the endian-ness from that. + +2001-11-30 Erik de Castro Lopo + + * src/aiff.c + Added support for other AIFC types ('raw ', 'in32', '23ni'). + Further work on IMA ADPCM encoding. + +2001-11-29 Erik de Castro Lopo + + * src/ima_adpcm.c + Renamed from wav_ima_adpcm.c. This file will soon handle IMA ADPCM + encodings for both WAV and AIFF files. + + * src/aiff.c + Started adding IMA ADPCM support. + +2001-11-28 Erik de Castro Lopo + + * src/double.c + New file for handling double precision floating point (SF_FORMAT_DOUBLE) + data. + + * src/wav.c src/aiff.c src/au.c src/raw.c + Added support for SF_FORMAT_DOUBLE data. + + * src/common.[ch] + Addition of endswap_long_array () for endian swapping 64 bit integers. This + function will work correctly on processors with 32 bit and 64 bit longs. + Optimised endswap_short_array () and endswap_int_array (). + + * tests/pcm_test.c + Added and extra check. After the first file of each type is written to disk + a checksum is performed of the first 64 bytes and checked against a pre- + calculated value. This will work whatever the endian-ness of the host + machine. + +2001-11-27 Erik de Castro Lopo + + * src/aiff.c + Added handling of u-law, A-law encoded AIFF files. Thanks to Tom Erbe for + supplying example files. + + * tests/lossy_comp_test.c + Added tests for above. + + * src/common.h src/*.c + Removed function typedefs from common.h and function pointer casting in all + the other files. This allows the compiler to perform proper type checking. + Hopefully this will prevernt problems like the sf_seek bug for OpenBSD, + BeOS etc. + + * src/common.[ch] + Added new function psf_new_binheader_readf () which will eventually replace + psf_binheader_readf (). The new function has basically the same function as + the original but has a more flexible and capable interface. It also allows + the reading of 64 bit integer values for files contains 64 bit file + offsets. + +2001-11-26 Erik de Castro Lopo + + * src/voc.c + Completed implementation of VOC file handling. Can now handle 8 and 16 bit + PCM, u-law and A-law files with one or two channels. + + * src/write_read_test.c tests/lossy_comp_test.c + Added tests for VOC files. + +2001-11-22 Erik de Castro Lopo + + * src/float_cast.h + Added inline asm version of lrint/lrintf for MacOS. Solution provided by + Stephane Letz. + + * src/voc.c + More work on this braindamaged format. The VOC files produced by SoX also + have a number of inconsistencies. + +2001-11-19 Erik de Castro Lopo + + * src/paf.c + Added support for 8 bit PCM PAF files. + + * tests/write_read_test.c + Added tests for 8 bit PAF files. + +2001-11-18 Erik de Castro Lopo + + * tests/pcm_test.c + New test program to test for correct scaling of integer values between + different sized integer containers (ie short -> int). + The new specs for libsndfile state that when the source and destination + containers are of a different size, the most significant bit of the source + value becomes the most significant bit of the destination container. + + * src/pcm.c src/paf.c + Modified to pass the above test program. + + * tests/write_read_test.c tests/lossy_comp_test.c + Modified to work with the new scaling rules. + +2001-11-17 Erik de Castro Lopo + + * src/raw.c tests/write_read_test.c tests/write_read_test.c + Added ability to do raw reads/writes of float, u-law and A-law files. + + * src/*.[ch] examples/*.[ch] tests/*.[ch] + Removed dependance on pcmbitwidth field of SF_INFO struct and moved to new + SF_FORMAT_* types and use of SF_ENDIAN_BIG/LITTLE/CPU. + +2001-11-12 Erik de Castro Lopo + + * src/*.[ch] + Started implmentation of major changes documented in doc/version1.html. + + Removed all usage of off_t which is not part of the ISO C standard. All + places which were using it are now using type long which is the type of + the offset parameter for the fseek function. + This should fix problems on BeOS, MacOS and *BSD like systems which were + failing "make check" because sizeof (long) != sizeof (off_t). + +-------------------------------------------------------------------------------- +This is the boundary between version 1 of the library above and version 0 below. +-------------------------------------------------------------------------------- + +2001-11-11 Erik de Castro Lopo + + * examples/sfplay_beos.cpp + Added BeOS version of sfplay.c. This needs to be compiled using a C++ + compiler so is therefore not built by default. Thanks to Marcus Overhagen + for providing this. + +2001-11-10 Erik de Castro Lopo + + * examples/sfplay.c + New example file showing how libsndfile can be used to read and play a + sound file. + At the moment on Linux is supported. Others will follow in the near future. + +2001-11-09 Erik de Castro Lopo + + * src/pcm.c + Fixed problem with normalisation code where a value of 1.0 could map to + a value greater than MAX_SHORT or MAX_INT. Thanks to Roger Dannenberg for + pointing this out. + +2001-11-08 Erik de Castro Lopo + + * src/pcm.c + Fixed scaling issue when reading/writing 8 bit files using + sf_read/sf_write_short (). + On read, values are scaled so that the most significant bit in the char + ends up in the most significant bit of the short. On write, values are + scaled so that most significant bit in the short ends up as the most + significant bit in the char. + +2001-11-07 Erik de Castro Lopo + + * src/au.c src/sndfile.c + Added support for 32 bit float data in big and little endian AU files. + + * tests/write_read_test.c + Added tests for 32 bit float data in AU files. + +2001-11-06 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Finalised testing of stereo files where possible. + +2001-11-05 Erik de Castro Lopo + + * src/wav_ms_adpcm.c + Fixed bug in writing stereo MS ADPCM WAV files. Thanks to Xu Xin for + pointing out this problem. + +2001-10-24 Erik de Castro Lopo + + * src/wav_ms_adpcm.c + Modified function srate2blocksize () to handle 44k1Hz stereo files. + +2001-10-21 Erik de Castro Lopo + + * src/w64.c + Added support for Sonic Foundry 64 bit WAV format. As Linux (my main + development platform) does not yet support 64 bit file offsets by default, + current handling of this file format treats everything as 32 bit and fails + openning the file, if it finds anything that goes beyond 32 bit values. + + * src/sndfile.[hc] src/common.h src/Makefile.am + Added hooks for W64 support. + +2001-10-21 Erik de Castro Lopo + + * configure.in + Added more warnings options to CFLAGS when the gcc compiler is detected. + + * src/*.[ch] tests/*.c examples/*.c + Started fixing the warning messages due to the new CFLASG. + + * src/voc.c + More work on VOC file read/writing. + + * src/paf.c + Found that PAF files were not checking the normalisation flag when reading + or writing floats and doubles. Fixed it. + + * tests/floating_point_test.c + Added specific test for the above problem. + + * src/float_cast.h src/pcm.c + Added a section for Win32 to define lrint () and lrintf () in the header + and implement it in the pcm.c + +2001-10-20 Erik de Castro Lopo + + * sndfile-config.in m4/sndfile.m4 + These files were donated by Conrad Parker who also provided instructions + on how to install them using autoconf/automake. + + * src/float_cast.h + Fiddled around with this file some more. On Linux and other gcc supported + OSes use the C99 functions lrintf() and lrint() for casting from floating + point to int without incurring the huge perfromance penalty (particularly + on the i386 family) caused by the regular C cast from float to int. + These new C99 functions replace the FLOAT_TO_* and DOUBLE_TO_* macros which + I had been playing with. + + * configure.in m4/lrint.m4 m4/lrintf.m4 + Add detection of these functions. + +2001-10-17 Erik de Castro Lopo + + * src/voc.c + Completed code for reading VOC files containing a single audio data + segment. + Started implementing code to handle files with multiple VOC_SOUND_DATA + segments but couldn't be bothered finishing it. Multiple segment files can + have different sample rates for different sections and other nasties like + silence and repeat segments. + +2001-10-16 Erik de Castro Lopo + + * src/common.h src/*.c + Removed SF_PRIVATE struct field fdata and replaced it with extra_data. + + * src/voc.c + Further development of the read part of this woefult file format. + +2001-10-04 Erik de Castro Lopo + + * src/float_cast.h + Implemented gcc and i386 floating point to int cast macros. Standard cast + will be used when not on gcc for i385. + + * src/pcm.c + Modified all uses of FLOAT/DOUBLE_TO_INT and FLOAT/DOUBLE_TO_SHORT casts to + comply with macros in float_cast.h. + +2001-10-04 Erik de Castro Lopo + + * src/voc.c + Changed the TYPE_xxx enum names to VOC_TYPE_xxx to prevent name clashes + on MacOS with CodeWarrior 6.0. + + * MacOS/MacOS-readme.txt + Updated the compile instructions. Probably still need work as I don't have + access to a Mac. + +2001-10-01 Erik de Castro Lopo + + * src/wav.c src/aiff.c common.c + Changed all references to snprintf to LSF_SNPRINTF and all vsnprintf to + LSF_VSNPRINTF. LSF_VSNPRINTF and LSF_VSNPRINTF are defined in common.h. + + * src/common.h + Added checking of HAVE_SNPRINTF and HAVE_VSNPRINTF and defining + LSF_VSNPRINTF and LSF_VSNPRINTF to appropriate values. + + * src/missing.c + New file containing a minimal implementation of snprintf and vsnprintf + functions named missing_snprintf and missing_vsnprintf respectively. These + are only compliled into the binary if snprintf and/or vsnprintf are not + available. + +2001-09-29 Erik de Castro Lopo + + * src/ircam.c + New file to handle Berkeley/IRCAM/CARL files. + + * src/sndfile.c src/common.h + Modified for IRCAM handling. + + * tests/*.c + Added tests for IRCAM files. + +2001-09-27 Erik de Castro Lopo + + * src/wav.c + Apparently microsoft windows (tm) doesn't like ulaw and Alaw WAV files with + 20 byte format chunks (contrary to ms's own documentation). Fixed the WAV + header writing code to generate smaller ms compliant ulaw and Alaw WAV + files. + +2001-09-17 Erik de Castro Lopo + + * tests/stdio_test.sh tests/stdio_test.c + Shell script was rewritten as a C program due to incompatibilities of the + sh shell on Linux and Solaris. + +2001-09-16 Erik de Castro Lopo + + * tests/stdio_test.sh tests/stdout_test.c tests/stdin_test.c + New test programs to verify the correct operation of reading from stdin and + writing to stdout. + + * src/sndfile.c wav.c au.c nist.c paf.c + Fixed a bugs uncovered by the new test programs above. + +2001-09-15 Erik de Castro Lopo + + * src/sndfile.c wav.c + Fixed a bug preventing reading a file from stdin. Found by T. Narita. + +2001-09-12 Erik de Castro Lopo + + * src/common.h + Fixed a problem on OpenBSD 2.9 which was causing sf_seek() to fail on IMA + WAV files. Root cause was the declaration of the func_seek typedef not + matching the functions it was actually being used to point to. In OpenBSD + sizeof (off_t) != sizeof (int). Thanks to Heikki Korpela for allowing me + to log into his OpenBSD machine to debug this problem. + +2001-09-03 Erik de Castro Lopo + + * src/sndfile.c + Implemented sf_command ("norm float"). + + * src/*.c + Implemented handling of sf_command ("set-norm-float"). Float normalization + can now be turned on and off. + + * tests/double_test.c + Renamed to floating_point_test.c. Modified to include tests for all scaled + reads and writes of floats and doubles. + + * src/au_g72x.c + Fixed bug in normalization code found with improved floating_point_test + program. + + * src/wav.c + Added code for parsing 'INFO' and 'LIST' chunks. Will be used for extract + text annotations from WAV files. + + * src/aiff.c + Added code for parsing '(c) ' and 'ANNO' chunks. Will be used for extract + text annotations from WAV files. + +2001-09-02 Erik de Castro Lopo + + * examples/sf_info.c example/Makefile.am + Renamed to sndfile_info.c. The program sndfile_info will now be installed + when the library is installed. + + * src/float_cast.h + New file defining floating point to short and int casts. These casts will + eventually replace all flot and double casts to short and int. See comments + at the top of the file for the reasoning. + + * src/*.c + Changed all default float and double casts to short or int with macros + defined in floatcast.h. At the moment these casts do nothing. They will be + replaced with faster float to int cast operations in the near future. + +2001-08-31 Erik de Castro Lopo + + * tests/command_test.c + New file for testing sf_command () functionality. + + * src/sndfile.c + Revisiting of error return values of some functions. + Started implementing sf_command () a new function will allow on-the-fly + modification of library behaviour, or instance, sample value scaling. + + * src/common.h + Added hook for format specific sf_command () calls to SNDFILE struct. + + * doc/api.html + Updated and errors corrected. + + * doc/command.html + New documentation file explaining new sf_command () function. + +2001-08-11 Erik de Castro Lopo + + * src/sndfile.c + Fixed error return values from sf_read*() and sf_write*(). There were + numerous instances of -1 being returned through size_t. These now all set + error int the SF_PRIVATE struct and return 0. Thanks to David Viens for + spotting this. + +2001-08-01 Erik de Castro Lopo + + * src/common.c + Fixed use of va_arg() calls that were causing warning messages with the + latest version of gcc (thanks Maurizio Umberto Puxeddu). + +2001-07-25 Erik de Castro Lopo + + * src/*.c src/sfendian.h + Moved definition of MAKE_MARKER macro to sfendian.h + +2001-07-23 Erik de Castro Lopo + + * src/sndfile.c + Modified sf_get_lib_version () so that version string will be visible using + the Unix strings command. + + * examples/Makefile.am examples/sfinfo.c + Renamed sfinfo program and source code to sf_info. This prevents a name + clash with the program included with libaudiofile. + +2001-07-22 Erik de Castro Lopo + + * tests/read_seek_test.c tests/lossy_comp_test.c + Added tests for sf_read_float () and sf_readf_float (). + + * src/voc.c + New files for handling Creative Voice files (not complete). + + * src/samplitude.c + New files for handling Samplitude files (not complete). + +2001-07-21 Erik de Castro Lopo + + * src/aiff.c src/au.c src/paf.c src/svx.c src/wav.c + Converted these files to using psf_binheader_readf() function. Will soon be + ready to attempt to make reading writing from pipes work reliably. + + * src/*.[ch] + Added code for sf_read_float () and sf_readf_float () methods of accessing + file data. + +2001-07-20 Erik de Castro Lopo + + * src/paf.c src/wav_gsm610.c + Removed two printf()s which had escaped notice for some time (thanks + Sigbjørn Skjæret). + +2001-07-19 Erik de Castro Lopo + + * src/wav_gsm610.c + Fixed a bug which prevented GSM 6.10 encoded WAV files generated by + libsndfile from being played in Windoze (thanks klay). + +2001-07-18 Erik de Castro Lopo + + * src/common.[ch] + Implemented psf_binheader_readf() which will do for file header reading what + psf_binheader_writef() did for writing headers. Will eventually allow + libsndfile to read and write from pipes, including named pipes. + +2001-07-16 Erik de Castro Lopo + + * MacOS/config.h Win32/config.h + Attempted to bring these two files uptodate with src/config.h. As I don't + have access to either of these systems support for them may be completely + broken. + +2001-06-18 Erik de Castro Lopo + + * src/float32.c + Fixed bug for big endian processors that can't read 32 bit IEEE floats. Now + tested on Intel x86 and UltraSparc processors. + +2001-06-13 Erik de Castro Lopo + + * src/aiff.c + Modified to allow REX files (from Propellorhead's Recycle and Reason + programs) to be read. + REX files are basically an AIFF file with slightly unusual sequence of + chunks (AIFF files are supposed to allow any sequence) and some extra + application specific information. + Not yet able to write a REX file as the details of the application specific + data is unknown. + +2001-06-12 Erik de Castro Lopo + + * src/wav.c + Fixed endian bug when reading PEAK chunk on big endian machines. + + * src/common.c + Fixed endian bug when reading PEAK chunk on big endian machines with + --enable-force-broken-float configure option. + Fix psf_binheader_writef for (FORCE_BROKEN_FLOAT ||______) + +2001-06-07 Erik de Castro Lopo + + * configure.in src/config.h.in + Removed old CAN_READ_WRITE_x86_IEEE configure variable now that float + capabilities are detected at run time. + Added FORCE_BROKEN_FLOAT to allow testing of broken float code on machines + where the processor can in fact handle floats correctly. + + * src/float32.c + Rejigged code reading and writing of floats on broken processors. + + * m4/ + Removed this directory and all its files as they are no longer needed. + +2001-06-05 Erik de Castro Lopo + + * tests/peak_chunk_test.c + New test to validate reading and writing of peak chunk. + + * examples/sfconvert + Added -float32 option. + + * src/*.c + Changed all error return values to negative values (ie the negative of what + they were). + + * src/sndfile.c tests/error_test.c + Modified to take account of the previous change. + +2001-06-04 Erik de Castro Lopo + + * src/float32.c + File renamed from wav_float.c and renamed function to something more + general. + Added runtime detection of floating point capabilities. + Added recording of peaks during write for generation of PEAK chunk. + + * src/wav.c src/aiff.c + Added handing for PEAK chunk for floating point files. PEAK is read when the + file headers are read and generated when the file is closed. Logic is in + place for adding PEAK chunk to end of file when writing to a pipe (reading + and writing from/to pipe to be implemented soon). + + * src/sndfile.c + Modified sf_signal_max () to use PEAK values if present. + +2001-06-03 Erik de Castro Lopo + + * src/*.c + Added pcm_read_init () and pcm_write_init () to src/pcm.c and removed all + other calls to functions in this file from the filetype specific files. + + * src/*.c + Added alaw_read_init (), alaw_write_int (), ulaw_read_init () and + ulaw_write_init () and removed all other calls to functions in alaw.c and + ulaw.c from the filetype specific files. + + * tests/write_read_test.c + Added tests to validate sf_seek () on all file types. + + * src/raw.c + Implemented raw_seek () function to fix a bug where + sf_seek (file, 0, SEEK_SET) on a RAW file failed. + + * src/paf.c + Fixed a bug in paf24_seek () found due to added seeks tests in + tests/write_read_test.c + +2001-06-01 Erik de Castro Lopo + + * tests/read_seek_test.c + Fixed a couple of broken binary files. + + * src/aiff.c src/wav.c + Added handling of PEAK chunks on file read. + +2001-05-31 Erik de Castro Lopo + + * check_libsndfile.py + New file for the regression testing of libsndfile. + check_libsndfile.py is a Python script which reads in a file containing + filenames of audio files. Each file is checked by running the examples/sfinfo + program on them and checking for error or warning messages in the libsndfile + log buffer. + + * check_libsndfile.list + This is an example list of audio files for use with check_libsndfile.py + + * tests/lossy_comp_test.c + Changed the defined value of M_PI for math header files which don't have it. + This fixed validation test failures on MetroWerks compilers. Thanks to Lord + Praetor Satanus of Acheron for bringing this to my attention. + +2001-05-30 Erik de Castro Lopo + + * src/common.[ch] + Removed psf_header_setf () which was no longer required after refactoring + and simplification of header writing. + Added 'z' format specifier to psf_binheader_writef () for zero filling header + with N bytes. Used by paf.c and nist.c + + * tests/check_log_buffer.c + New file implementing check_log_buffer () which reads the log buffer of a + SNDFILE* object and searches for error and warning messages. Calls exit () + if any are found. + + * tests/*.c + Added calls to check_log_buffer () after each call to sf_open_XXX (). + +2001-05-29 Erik de Castro Lopo + + * src/wav.c src/wav_ms_adpcm.c src/wav_gsm610.c + Major rehack of header writing using psf_binheader_writef (). + +2001-05-28 Erik de Castro Lopo + + * src/wav.c src/wav_ima_adpcm.c + Major rehack of header writing using psf_binheader_writef (). + +2001-05-27 Erik de Castro Lopo + + * src/wav.c + Changed return type of get_encoding_str () to prevent compiler warnings on + Mac OSX. + + * src/aiff.c src/au.c + Major rehack of header writing using psf_binheader_writef (). + +2001-05-25 Erik de Castro Lopo + + * src/common.h src/common.c + Added comments. + Name of log buffer changed from strbuffer to logbuffer. + Name of log buffer index variable changed from strindex to logindex. + + * src/*.[ch] + Changed name of internal logging function from psf_sprintf () to + psf_log_printf (). + Changed name of internal header generation functions from + psf_[ab]h_printf () to psf_asciiheader_printf () and + psf_binheader_writef (). + Changed name of internal header manipulation function psf_hsetf () to + psf_header_setf (). + +2001-05-24 Erik de Castro Lopo + + * src/nist.c + Fixed reading and writing of sample_byte_format header. "01" means little + endian and "10" means big endian regardless of bit width. + + * configure.in + Detect Mac OSX and disable -Wall and -pedantic gcc options. Mac OSX is + way screwed up and spews out buckets of warning messages from the system + headers. + Added --disable-gcc-opt configure option (sets gcc optimisation to -O0 ) for + easier debugging. + Made decision to harmonise source code version number and .so library + version number. Future releases will stick to this rule. + + * doc/new_file_type.HOWTO + New file to document the addition of new file types to libsndfile. + +2001-05-23 Erik de Castro Lopo + + * src/nist.c + New file for reading/writing Sphere NIST audio file format. + Originally requested by Elis Pomales in 1999. + Retrieved from unstable (and untouched for 18 months) branch of libsndfile. + Some vital information gleaned from the source code to Bill Schottstaedt's + sndlib library : ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz + Currently reading and writing 16, 24 and 32 bit, big-endian and little + endian, stereo and mono files. + + * src/common.h src/common.c + Added psf_ah_printf () function to help construction of ASCII headers (ie NIST). + + * configure.in + Added test for vsnprintf () required by psf_ah_printf (). + + * tests/write_read_test.c + Added tests for supported NIST files. + +2001-05-22 Erik de Castro Lopo + + * tests/write_read_test.c + Added tests for little endian AIFC files. + + * src/aiff.c + Minor re-working of aiff_open_write (). + Added write support for little endian PCM encoded AIFC files. + +2001-05-13 Erik de Castro Lopo + + * src/aiff.c + Minor re-working of aiff_open_read (). + Added read support for little endian PCM encoded AIFC files from the Mac + OSX CD ripper program. Guillaume Lessard provided a couple of sample files + and a working patch. + The patch was not used as is but gave a good guide as to what to do. + +2001-05-11 Erik de Castro Lopo + + * src/sndfile.h + Fixed comments about endian-ness of WAV and AIFF files. Guillaume Lessard + pointed out the error. + +2001-04-23 Erik de Castro Lopo + + * examples/make_sine.c + Re-write of this example using sample rate and required frequency in Hz. + +2001-02-11 Erik de Castro Lopo + + * src/sndfile.c + Fixed bug that prevented known file types from being read as RAW PCM data. + +2000-12-16 Erik de Castro Lopo + + * src/aiff.c + Added handing of COMT chunk. + +2000-11-16 Erik de Castro Lopo + + * examples/sfconvert.c + Fixed bug in normalisatio code. Pointed out by Johnny Wu. + +2000-11-08 Erik de Castro Lopo + + * Win32/config.h + Fixed the incorrect setting of HAVE_ENDIAN_H parameter. Win32 only issue. + +2000-10-27 Erik de Castro Lopo + + * tests/Makefile.am + Added -lm for write_read_test_LDADD. + +2000-10-16 Erik de Castro Lopo + + * src/sndfile.c src/au.c + Fixed bug which prevented writing of G723 24kbps AU files. + + * tests/lossy_comp_test.c + Corrrection to options for G723 tests. + + * configure.in + Added --disable-gcc-pipe option for DJGPP compiler (gcc on MS-DOS) which + doesn't allow gcc -pipe option. + +2000-09-03 Erik de Castro Lopo + + * src/ulaw.c src/alaw.c src/wav_imaadpcm.c src/msadpcm.c src/wav_gsm610.c + Fixed normailsation bugs shown up by new double_test program. + +2000-08-31 Erik de Castro Lopo + + * src/pcm.c + Fixed bug in normalisation code (spotted by Steve Lhomme). + + * tests/double_test.c + New file to test scaled and unscaled sf_read_double() and sf_write_double() + functions. + +2000-08-28 Erik de Castro Lopo + + * COPYING + Changed to the LGPL COPYING file (spotted by H. S. Teoh). + +2000-08-21 Erik de Castro Lopo + + * src/sndfile.h + Removed prototype of unimplemented function sf_get_info(). Added prototype + for sf_error_number() Thanks to Sigbjørn Skjæret for spotting these. + +2000-08-18 Erik de Castro Lopo + + * src/newpcm.h + New file to contain a complete rewrite of the PCM data handling. + +2000-08-15 Erik de Castro Lopo + + * src/sndfile.c + Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbjørn + Skjæret for spotting this one. + +2000-08-13 Erik de Castro Lopo + + * src/au_g72x.c src/G72x/g72x.c + Added G723 encoded AU file support. + + * tests/lossy_comp_test.c + Added tests for G721 and G723 encoded AU files. + +2000-08-06 Erik de Castro Lopo + + * all files + Changed the license to LGPL. Albert Faber who had copyright on + Win32/unistd.h gave his permission to change the license on that file. All + other files were either copyright erikd AT mega-nerd DOT com or copyright + under a GPL/LGPL compatible license. + +2000-08-06 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Fixed incorrect error message. + + * src/au_g72x.c src/G72x/* + G721 encoded AU files now working. + + * Win32/README-Win32.txt + Replaced this file with a new one which gives a full explanation + of how to build libsndfile under Win32. Thanks to Mike Ricos. + +2000-08-05 Erik de Castro Lopo + + * src/*.[ch] + Removed double leading underscores from the start of all variable and + function names. Identifiers with a leading underscores are reserved + for use by the compiler. + + * src/au_g72x.c src/G72x/* + Continued work on G721 encoded AU files. + +2000-07-12 Erik de Castro Lopo + + * src/G72x/* + New files for reading/writing G721 and G723 ADPCM audio. These files + are from a Sun Microsystems reference implementation released under a + free software licence. + Extensive changes to this code to make it fit in with libsndfile. + See the ChangeLog in this directory for details. + + * src/au_g72x.c + New file for G721 encoded AU files. + +2000-07-08 Erik de Castro Lopo + + * libsndfile.spec.in + Added a spec file for making RPMs. Thanks to Josh Green for supplying this. + +2000-06-28 Erik de Castro Lopo + + * src/sndfile.c src/sndfile.h + Add checking for and handling of header-less u-law encoded AU/SND files. + Any file with a ".au" or ".snd" file extension and without the normal + AU file header is treated as an 8kHz, u-law encoded file. + + * src/au.h + New function for opening a headerless u-law encoded file for read. + +2000-06-04 Erik de Castro Lopo + + * src/paf.c + Add checking for files shorter than minimal PAF file header length. + +2000-06-02 Erik de Castro Lopo + + * tests/write_read_test.c + Added extra sf_perror() calls when sf_write_XXXX fails. + +2000-05-29 Erik de Castro Lopo + + * src/common.c + Modified usage of va_arg() macro to work correctly on PowerPC + Linux. Thanks to Kyle Wheeler for giving me ssh access to his + machine while I was trying to track this down. + + * configure.in src/*.[ch] + Sorted out some endian-ness issues brought up by PowerPC Linux. + + * tests/read_seek_test.c + Added extra debugging for when tests fail. + +2000-05-18 Erik de Castro Lopo + + * src/wav.c + Fixed bug in GSM 6.10 handling for big-endian machines. Thanks + to Sigbjørn Skjæret for reporting this. + +2000-04-25 Erik de Castro Lopo + + * src/sndfile.c src/wav.c src/wav_gsm610.c + Finallised writing of GSM 6.10 WAV files. + + * tests/lossy_comp_test.c + Wrote new test code for GSM 6.10 files. + + * examples/sfinfo.c + Fixed incorrect format in printf() statement. + +2000-04-06 Erik de Castro Lopo + + * src/sndfile.h.in + Fixed comments about sf_perror () and sf_error_str (). + +2000-03-14 Erik de Castro Lopo + + * configure.in + Fixed --enable-justsrc option. + +2000-03-07 Erik de Castro Lopo + + * wav.c + Fixed checking of bytespersec field of header. Still some weirdness + with some files. + +2000-03-05 Erik de Castro Lopo + + * tests/lossy_comp_test.c + Added option to test PCM WAV files (sanity check). + Fixed bug in sf_seek() tests. + +2000-02-29 Erik de Castro Lopo + + * src/sndfile.c src/wav.c + Minor changes to allow writing of GSM 6.10 WAV files. + +2000-02-28 Erik de Castro Lopo + + * configure.in Makefile.am src/Makefile.am + Finally got around to figuring out how to build a single library from + multiple source directories. + Reading GSM 6.10 files now seems to work. + +2000-01-03 Erik de Castro Lopo + + * src/wav.c + Added more error reporting in read_fmt_chunk(). + +1999-12-21 Erik de Castro Lopo + + * examples/sfinfo.c + Modified program to accept multiple filenames from the command line. + +1999-11-27 Erik de Castro Lopo + + * src/wav_ima_adpcm.c + Moved code around in preparation to adding ability to read/write IMA ADPCM + encoded AIFF files. + +1999-11-16 Erik de Castro Lopo + + * src/common.c + Fixed put_int() and put_short() macros used by _psf_hprintf() which were + causing seg. faults on Sparc Solaris. + +1999-11-15 Erik de Castro Lopo + + * src/common.c + Added string.h to includes. Thanks to Sigbjxrn Skjfret. + + * src/svx.c + Fixed __svx_close() function to ensure FORM and BODY chunks are correctly + set. + +1999-10-01 Erik de Castro Lopo + + * src/au.c + Fixed handling of incorrect size field in AU header on read. Thanks to + Christoph Lauer for finding this problem. + +1999-09-28 Erik de Castro Lopo + + * src/aiff.c + Fixed a bug with incorrect SSND chunk length being written. This also lead + to finding an minor error in AIFF header parsing. Thanks to Dan Timis for + pointing this out. + +1999-09-24 Erik de Castro Lopo + + * src/paf.c + Fixed a bug with reading and writing 24 bit stereo PAF files. This problem + came to light when implementing tests for the new functions which operate + in terms of frames rather than items. + +1999-09-23 Erik de Castro Lopo + + * src/sndfile.c + Modified file type detection to use first 12 bytes of file rather than + file name extension. Required this because NIST files use the same + filename extension as Microsoft WAV files. + + * src/sndfile.c src/sndfile.h + Added short, int and double read/write functions which work in frames + rather than items. This was originally suggested by Maurizio Umberto + Puxeddu. + +1999-09-22 Erik de Castro Lopo + + * src/svx.c + Finished off implementation of write using __psf_hprintf(). + +1999-09-21 Erik de Castro Lopo + + * src/common.h + Added a buffer to SF_PRIVATE for writing the header. This is required + to make generating headers for IFF/SVX files easier as well as making + it easier to do re-write the headers which will be required when + sf_rewrite_header() is implemented. + + * src/common.c + Implemented __psf_hprintf() function. This is an internal function + which is documented briefly just above the code. + +1999-09-05 Erik de Castro Lopo + + * src/sndfile.c + Fixed a bug in sf_write_raw() where it was returning incorrect values + (thanks to Richard Dobson for finding this one). Must put in a test + routine for sf_read_raw and sf_write_raw. + + * src/aiff.c + Fixed default FORMsize in __aiff_open_write (). + + * src/sndfile.c + Added copy of filename to internal data structure. IFF/SVX files + contain a NAME header chunk. Both sf_open_read() and sf_open_write() + copy the file name (less the leading path information) to the + filename field. + + * src/svx.c + Started implementing writing of files. + +1999-08-04 Erik de Castro Lopo + + * src/svx.c + New file for reading/writing 8SVX and 16SVX files. + + * src/sndfile.[ch] src/common.h + Changes for SVX files. + + * src/aiff.c + Fixed header parsing when unknown chunk is found. + +1999-08-01 Erik de Castro Lopo + + * src/paf.c + New file for reading/writing Ensoniq PARIS audio file format. + + * src/sndfile.[ch] src/common.h + Changes for PAF files. + + * src/sndfile.[ch] + Added stuff for sf_get_lib_version() function. + + +1999-07-31 Erik de Castro Lopo + + * src/sndfile.h MacOS/config.h + Fixed minor MacOS configuration issues. + +1999-07-30 Erik de Castro Lopo + + * MacOS/ + Added a new directory for the MacOS config.h file and the + readme file. + + * src/aiff.c + Fixed calculation of datalength when reading SSND chunk. Thanks to + Sigbjørn Skjæret for pointing out this error. + +1999-07-29 Erik de Castro Lopo + + * src/sndfile.c src/sndfile.h src/raw.c + Further fixing of #includes for MacOS. + +1999-07-25 Erik de Castro Lopo + + * src/wav.c src/aiff.c + Added call to ferror () in main header parsing loop of __XXX_open_read + functions. This should fix problems on platforms (MacOS, AmigaOS) where + fseek()ing or fread()ing beyond the end of the file puts the FILE* + stream in an error state until clearerr() is called. + + * tests/write_read_test.c + Added tests for RAW header-less PCM files. + + * src/common.h + Moved definition of struct tribyte to pcm.c which is the only place + which needs it. + + * src/pcm.c + Modified all code which assumed sizeof (struct tribyte) == 3. This code + did not work on MacOS. Thanks to Ben "Jacobs" for pointing this out. + + * src/au.c + Removed from list of #includes (not being used). + + * src/sndfile.c + Added MacOS specific #ifdef to replace . + + * src/sndfile.h + Added MacOS specific #ifdef to replace . + + * src/sndfile.h + Added MacOS specific typedef for off_t. + + * MacOS-readme.txt + New file with instructions for building libsndfile under MacOS. Thanks + to Ben "Jacobs" for supplying these instructions. + +1999-07-24 Erik de Castro Lopo + + * configure.in + Removed sndfile.h from generated file list as there were no longer + any autoconf substitutions being made. + + * src/raw.c + New file for handling raw header-less PCM files. In order to open these + for read, the user must specify format, pcmbitwidth and channels in the + SF_INFO struct when calling sf_open_read (). + + * src/sndfile.c + Added support for raw header-less PCM files. + +1999-07-22 Erik de Castro Lopo + + * examples/sfinfo.c + Removed options so the sfinfo program always prints out all the information. + +1999-07-19 Erik de Castro Lopo + + * src/alaw.c + New file for A-law encoding (similar to u-law). + + * tests/alaw_test.c + New test program to test the A-law encode/decode lookup tables. + + * tests/lossy_comp_test.c + Added tests for a-law encoded WAV, AU and AULE files. + +1999-07-18 Erik de Castro Lopo + + * src/sndfile.c src/au.c + Removed second "#include ". Thanks to Ben "Jacobs" for pointing + this out. + +1999-07-18 Erik de Castro Lopo + + * tests/ulaw_test.c + New test program to test the u-law encode/decode lookup tables. + +1999-07-16 Erik de Castro Lopo + + * src/sndfile.h + Made corrections to comments on the return values from sf_seek (). + + * src/sndfile.c + Fixed boundary condition checking bug and accounting bug in sf_read_raw (). + +1999-07-15 Erik de Castro Lopo + + * src/au.c src/ulaw.c + Finished implementation of u-law encoded AU files. + + * src/wav.c + Implemented reading and writing of u-law encoded WAV files. + + * tests/ + Changed name of adpcm_test.c to lossy_comp_test.c. This test program + will now be used to test Ulaw and Alaw encoding as well as APDCM. + Added tests for Ulaw encoded WAV files. + +1999-07-14 Erik de Castro Lopo + + * tests/adpcm_test.c + Initialised amp variable in gen_signal() to remove compiler warning. + +1999-07-12 Erik de Castro Lopo + + * src/aiff.c + In __aiff_open_read () prevented fseek()ing beyond end of file which + was causing trouble on MacOS with the MetroWerks compiler. Thanks to + Ben "Jacobs" for pointing this out. + + *src/wav.c + Fixed as above in __wav_open_read (). + +1999-07-01 Erik de Castro Lopo + + * src/wav_ms_adpcm.c + Implemented MS ADPCM encoding. Code cleanup of decoder. + + * tests/adpcm_test.c + Added tests for MS ADPCM WAV files. + + * src/wav_ima_adpcm.c + Fixed incorrect parameter in call to srate2blocksize () from + __ima_writer_init (). + +1999-06-23 Erik de Castro Lopo + + * tests/read_seek_test.c + Added test for 8 bit AIFF files. + +1999-06-18 Erik de Castro Lopo + + * tests/write_read_test.c + Removed test for IMA ADPCM WAV files which is now done in adpcm_test.c + + * configure.in + Added -Wconversion to CFLAGS. + + * src/*.c tests/*.c examples/*.c + Fixed all warnings resulting from use of -Wconversion. + +1999-06-17 Erik de Castro Lopo + + * src/wav.c + Added fact chunk handling on read and write for all non WAVE_FORMAT_PCM + WAV files. + + * src/wav_ima.c + Changed block alignment to be dependant on sample rate. This should make + WAV files created with libsndfile compatible with the MS Windows media + players. + + * tests/adpcm_test.c + Reimplemented adpcm_test_short and implemented adpcm_test_int and + adpcm_test_double. + Now have full testing of IMA ADPCM WAV file read, write and seek. + +1999-06-15 Erik de Castro Lopo + + * src/wav_float.c + Fixed function prototype for x86f2d_array () which was causing ocassional + seg. faults on Sparc Solaris machines. + +1999-06-14 Erik de Castro Lopo + + * src/aiff.c + Fixed bug in __aiff_close where the length fields in the header were + not being correctly calculated before writing. + + * tests/write_read_test.c + Modified to detect the above bug in WAV, AIFF and AU files. + +1999-06-12 Erik de Castro Lopo + + * Win32/* + Added a contribution from Albert Faber to allow libsndfile to compile + under Win32 systems. libsndfile will now be used as part of LAME the + the MPEG 1 Layer 3 encoder (http://internet.roadrunner.com/~mt/mp3/). + +1999-06-11 Erik de Castro Lopo + + * configure.in + Changed to reflect previous changes. + + * src/wav_ima_adpcm.c + Fixed incorrect calculation of bytespersec header field (IMA ADPCM only). + + Fixed bug when writing from int or double data to IMA ADPCM file. Will need + to write test code for this. + + Fixed bug in __ima_write () whereby the length of the current block was + calculated incorrectly. Thanks to Jongcheon Park for pointing this out. + +1999-03-27 Erik de Castro Lopo + + * src/*.c + Changed all read/write/lseek function calls to fread/fwrite/ + fseek/ftell and added error checking of return values from + fread and fwrite in critical areas of the code. + + * src/au.c + Fixed incorrect datasize element in AU header on write. + + * tests/error_test.c + Add new test to check all error values have an associated error + string. This will avoid embarrassing real world core dumps. + +1999-03-23 Erik de Castro Lopo + + * src/wav.c src/aiff.c + Added handling for unknown chunk markers in the file. + +1999-03-22 Erik de Castro Lopo + + * src/sndfile.c + Filled in missing error strings in SndfileErrors array. Missing entries + can cause core dumps when calling sf_error-str (). Thanks to Sam + for finding this problem. + +1999-03-21 Erik de Castro Lopo + + * src/wav_ima_adpcm.c + Work on wav_ms_adpcm.c uncovered a bug in __ima_read () when reading + stereo files. Caused by not adjusting offset into buffer of decoded + samples for 2 channels. A similar bug existed in __ima_write (). + Need a test for stereo ADPCM files. + + * src/wav_ms_adpcm.c + Decoder working correctly. + +1999-03-18 Erik de Castro Lopo + + * configure.in Makefile.am + Added --enable-justsrc configuration variable sent by Sam + . + + * src/wav_ima_adpcm.c + Fixed bug when reading beyond end of data section due to not + checking pima->blockcount. + This uncovered __ima_seek () bug due to pima->blockcount being set + before calling __ima_init_block (). + +1999-03-17 Erik de Castro Lopo + + * src/wav.c + Started implementing MS ADPCM decoder. + If file is WAVE_FORMAT_ADPCM and length of data chunk is odd, this + encoder seems to add an extra byte. Why not just give an even data + length? + +1999-03-16 Erik de Castro Lopo + + * src/wav.c + Split code out of wav.c to create wav_float.c and wav_ima_adpcm.c. + This will make it easier to add and debug other kinds of WAV files + in future. + +1999-03-14 Erik de Castro Lopo + + * tests/ + Added adpcm_test.c which implements test functions for + IMA ADPCM reading/writing/seeking etc. + + * src/wav.c + Fixed many bugs in IMA ADPCM encoder and decoder. + +1999-03-11 Erik de Castro Lopo + + * src/wav.c + Finished implementing IMA ADPCM encoder and decoder (what a bitch!). + +1999-03-03 Erik de Castro Lopo + + * src/wav.c + Started implementing IMA ADPCM decoder. + +1999-03-02 Erik de Castro Lopo + + * src/sndfile.c + Fixed bug where the sf_read_XXX functions were returning a + incorrect read count when reading past end of file. + Fixed bug in sf_seek () when seeking backwards from end of file. + + * tests/read_seek_test.c + Added multiple read test to short_test(), int_test () and + double_test (). + Added extra chunk to all test WAV files to test that reading + stops at end of 'data' chunk. + +1999-02-21 Erik de Castro Lopo + + * tests/write_read_test.c + Added tests for little DEC endian AU files. + + * src/au.c + Add handling for DEC format little endian AU files. + +1999-02-20 Erik de Castro Lopo + + * src/aiff.c src/au.c src/wav.c + Add __psf_sprintf calls during header parsing. + + * src/sndfile.c src/common.c + Implement sf_header_info (sndfile.c) function and __psf_sprintf (common.c). + + * tests/write_read_test.c + Added tests for 8 bit PCM files (WAV, AIFF and AU). + + * src/au.c src/aiff.c + Add handling of 8 bit PCM data format. + + * src/aiff.c + On write, set blocksize in SSND chunk to zero like everybody else. + +1999-02-16 Erik de Castro Lopo + + * src/pcm.c: + Fixed bug in let2s_array (cptr was not being initialised). + + * src/sndfile.c: + Fixed bug in sf_read_raw and sf_write_raw. sf_seek should + now work when using these functions. + +1999-02-15 Erik de Castro Lopo + + * tests/write_read_test.c: + Force test_buffer array to be double aligned. Sparc Solaris + requires this. + +1999-02-14 Erik de Castro Lopo + + * src/pcm.c: + Fixed a bug which was causing errors in the reading + and writing of 24 bit PCM files. + + * doc/api.html + Finished of preliminary documentaion. + +1999-02-13 Erik de Castro Lopo + + * src/aiff.c: + Changed reading of 'COMM' chunk to avoid reading an int + which overlaps an int (4 byte) boundary. diff --git a/libsndfile/NEWS b/libsndfile/NEWS new file mode 100644 index 00000000..d8f549f4 --- /dev/null +++ b/libsndfile/NEWS @@ -0,0 +1,199 @@ +Version 1.0.28 (2017-04-02) + * Fix buffer overruns in FLAC and ID3 handling code. + * Move to variable length header storage. + * Fix detection of Large File Support for 32 bit systems. + * Remove large stack allocations in ALAC handling code. + * Remove all use of Variable Length Arrays. + * Minor bug fixes and improvements. + +Version 1.0.27 (2016-06-19) + * Fix an SF_INFO seekable flag regression introduced in 1.0.26. + * Fix potential infinite loops on malformed input files. + * Add string metadata read/write for CAF and RF64. + * Add handling of CUE chunks. + * Fix endian-ness issues in PAF files. + * Minor bug fixes and improvements. + +Version 1.0.26 (2015-11-22) + * Fix for CVE-2014-9496, SD2 buffer read overflow. + * Fix for CVE-2014-9756, file_io.c divide by zero. + * Fix for CVE-2015-7805, AIFF heap write overflow. + * Add support for ALAC encoder in a CAF container. + * Add support for Cart chunks in WAV files. + * Minor bug fixes and improvements. + +Version 1.0.25 (2011-07-13) + * Fix for Secunia Advisory SA45125, heap overflow in PAF file handler. + * Accept broken WAV files with blockalign == 0. + * Minor bug fixes and improvements. + +Version 1.0.24 (2011-03-23) + * WAV files now have an 18 byte u-law and A-law fmt chunk. + * Document virtual I/O functionality. + * Two new methods rawHandle() and takeOwnership() in sndfile.hh. + * AIFF fix for non-zero offset value in SSND chunk. + * Minor bug fixes and improvements. + +Version 1.0.23 (2010-10-10) + * Add version metadata to Windows DLL. + * Add a missing 'inline' to sndfile.hh. + * Update docs. + * Minor bug fixes and improvements. + +Version 1.0.22 (2010-10-04) + * Couple of fixes for SDS file writer. + * Fixes arising from static analysis. + * Handle FLAC files with ID3 meta data at start of file. + * Handle FLAC files which report zero length. + * Other minor bug fixes and improvements. + +Version 1.0.21 (2009-12-13) + * Add a couple of new binary programs to programs/ dir. + * Remove sndfile-jackplay (now in sndfile-tools package). + * Add windows only function sf_wchar_open(). + * Bunch of minor bug fixes. + +Version 1.0.20 (2009-05-14) + * Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/). + +Version 1.0.19 (2009-03-02) + * Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research). + * Huge number of minor bug fixes as a result of static analysis. + +Version 1.0.18 (2009-02-07) + * Add Ogg/Vorbis support (thanks to John ffitch). + * Remove captive FLAC library. + * Many new features and bug fixes. + * Generate Win32 and Win64 pre-compiled binaries. + +Version 1.0.17 (2006-08-31) + * Add sndfile.hh C++ wrapper. + * Update Win32 MinGW build instructions. + * Minor bug fixes and cleanups. + +Version 1.0.16 (2006-04-30) + * Add support for Broadcast (BEXT) chunks in WAV files. + * Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS. + * Add support for RIFX (big endian WAV variant). + * Fix configure script bugs. + * Fix bug in INST and MARK chunk writing for AIFF files. + +Version 1.0.15 (2006-03-16) + * Fix some ia64 issues. + * Fix precompiled DLL. + * Minor bug fixes. + +Version 1.0.14 (2006-02-19) + * Really fix MinGW compile problems. + * Minor bug fixes. + +Version 1.0.13 (2006-01-21) + * Fix for MinGW compiler problems. + * Allow readin/write of instrument chunks from WAV and AIFF files. + * Compile problem fix for Solaris compiler. + * Minor cleanups and bug fixes. + +Version 1.0.12 (2005-09-30) + * Add support for FLAC and Apple's Core Audio Format (CAF). + * Add virtual I/O interface (still needs docs). + * Cygwin and other Win32 fixes. + * Minor bug fixes and cleanups. + +Version 1.0.11 (2004-11-15) + * Add support for SD2 files. + * Add read support for loop info in WAV and AIFF files. + * Add more tests. + * Improve type safety. + * Minor optimisations and bug fixes. + +Version 1.0.10 (2004-06-15) + * Fix AIFF read/write mode bugs. + * Add support for compiling Win32 DLLS using MinGW. + * Fix problems resulting in failed compiles with gcc-2.95. + * Improve test suite. + * Minor bug fixes. + +Version 1.0.9 (2004-03-30) + * Add handling of AVR (Audio Visual Research) files. + * Improve handling of WAVEFORMATEXTENSIBLE WAV files. + * Fix for using pipes on Win32. + +Version 1.0.8 (2004-03-14) + * Correct peak chunk handing for files with > 16 tracks. + * Fix for WAV files with huge number of CUE chunks. + +Version 1.0.7 (2004-02-25) + * Fix clip mode detection on ia64, MIPS and other CPUs. + * Fix two MacOSX build problems. + +Version 1.0.6 (2004-02-08) + * Added support for native Win32 file access API (Ross Bencina). + * New mode to add clippling then a converting from float/double to integer + would otherwise wrap around. + * Fixed a bug in reading/writing files > 2Gig on Linux, Solaris and others. + * Many minor bug fixes. + * Other random fixes for Win32. + +Version 1.0.5 (2003-05-03) + * Added support for HTK files. + * Added new function sf_open_fd() to allow for secure opening of temporary + files as well as reading/writing sound files embedded within larger + container files. + * Added string support for AIFF files. + * Minor bug fixes and code cleanups. + +Version 1.0.4 (2003-02-02) + * Added suport of PVF and XI files. + * Added functionality for setting and retreiving strings from sound files. + * Minor code cleanups and bug fixes. + +Version 1.0.3 (2002-12-09) + * Minor bug fixes. + +Version 1.0.2 (2002-11-24) + * Added support for VOX ADPCM. + * Improved error reporting. + * Added version scripting on Linux and Solaris. + * Minor bug fixes. + +Version 1.0.1 (2002-09-14) + * Added MAT and MAT5 file formats. + * Minor bug fixes. + +Version 1.0.0 (2002-08-16) + * Final release for 1.0.0. + +Version 1.0.0rc6 (2002-08-14) + * Release candidate 6 for the 1.0.0 series. + * MacOS9 fixes. + +Version 1.0.0rc5 (2002-08-10) + * Release candidate 5 for the 1.0.0 series. + * Changed the definition of sf_count_t which was causing problems when + libsndfile was compiled with other libraries (ie WxWindows). + * Minor bug fixes. + * Documentation cleanup. + +Version 1.0.0rc4 (2002-08-03) + * Release candidate 4 for the 1.0.0 series. + * Minor bug fixes. + * Fix broken Win32 "make check". + +Version 1.0.0rc3 (2002-08-02) + * Release candidate 3 for the 1.0.0 series. + * Fix bug where libsndfile was reading beyond the end of the data chunk. + * Added on-the-fly header updates on write. + * Fix a couple of documentation issues. + +Version 1.0.0rc2 (2002-06-24) + * Release candidate 2 for the 1.0.0 series. + * Fix compile problem for Win32. + +Version 1.0.0rc1 (2002-06-24) + * Release candidate 1 for the 1.0.0 series. + +Version 0.0.28 (2002-04-27) + * Last offical release of 0.0.X series of the library. + +Version 0.0.8 (1999-02-16) + * First offical release. diff --git a/libsndfile/dist/libsndfile-1.dll b/libsndfile/dist/libsndfile-1.dll new file mode 100644 index 00000000..95ce5bd0 Binary files /dev/null and b/libsndfile/dist/libsndfile-1.dll differ diff --git a/libsndfile/include/sndfile.h b/libsndfile/include/sndfile.h new file mode 100644 index 00000000..8a60fb09 --- /dev/null +++ b/libsndfile/include/sndfile.h @@ -0,0 +1,857 @@ +/* +** Copyright (C) 1999-2016 Erik de Castro Lopo +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU Lesser General Public License as published by +** the Free Software Foundation; either version 2.1 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +** sndfile.h -- system-wide definitions +** +** API documentation is in the doc/ directory of the source code tarball +** and at http://www.mega-nerd.com/libsndfile/api.html. +*/ + +#ifndef SNDFILE_H +#define SNDFILE_H + +/* This is the version 1.0.X header file. */ +#define SNDFILE_1 + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* The following file types can be read and written. +** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise +** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and +** SF_FORMAT_SUBMASK can be used to separate the major and minor file +** types. +*/ + +enum +{ /* Major formats. */ + SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian default). */ + SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */ + SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */ + SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */ + SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */ + SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */ + SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */ + SF_FORMAT_VOC = 0x080000, /* VOC files. */ + SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */ + SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */ + SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */ + SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */ + SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */ + SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */ + SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */ + SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */ + SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */ + SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */ + SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */ + SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */ + SF_FORMAT_CAF = 0x180000, /* Core Audio File format */ + SF_FORMAT_WVE = 0x190000, /* Psion WVE format */ + SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */ + SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */ + SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */ + + /* Subtypes from here on. */ + + SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */ + SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */ + SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */ + SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */ + + SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */ + + SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */ + SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */ + + SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */ + SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */ + SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */ + SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */ + + SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */ + SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */ + + SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */ + SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */ + SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */ + + SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */ + SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */ + + SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ + SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ + + SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ + + SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */ + SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */ + SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */ + SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */ + + /* Endian-ness options. */ + + SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ + SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ + SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ + SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */ + + SF_FORMAT_SUBMASK = 0x0000FFFF, + SF_FORMAT_TYPEMASK = 0x0FFF0000, + SF_FORMAT_ENDMASK = 0x30000000 +} ; + +/* +** The following are the valid command numbers for the sf_command() +** interface. The use of these commands is documented in the file +** command.html in the doc directory of the source code distribution. +*/ + +enum +{ SFC_GET_LIB_VERSION = 0x1000, + SFC_GET_LOG_INFO = 0x1001, + SFC_GET_CURRENT_SF_INFO = 0x1002, + + + SFC_GET_NORM_DOUBLE = 0x1010, + SFC_GET_NORM_FLOAT = 0x1011, + SFC_SET_NORM_DOUBLE = 0x1012, + SFC_SET_NORM_FLOAT = 0x1013, + SFC_SET_SCALE_FLOAT_INT_READ = 0x1014, + SFC_SET_SCALE_INT_FLOAT_WRITE = 0x1015, + + SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, + SFC_GET_SIMPLE_FORMAT = 0x1021, + + SFC_GET_FORMAT_INFO = 0x1028, + + SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, + SFC_GET_FORMAT_MAJOR = 0x1031, + SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, + SFC_GET_FORMAT_SUBTYPE = 0x1033, + + SFC_CALC_SIGNAL_MAX = 0x1040, + SFC_CALC_NORM_SIGNAL_MAX = 0x1041, + SFC_CALC_MAX_ALL_CHANNELS = 0x1042, + SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, + SFC_GET_SIGNAL_MAX = 0x1044, + SFC_GET_MAX_ALL_CHANNELS = 0x1045, + + SFC_SET_ADD_PEAK_CHUNK = 0x1050, + SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051, + + SFC_UPDATE_HEADER_NOW = 0x1060, + SFC_SET_UPDATE_HEADER_AUTO = 0x1061, + + SFC_FILE_TRUNCATE = 0x1080, + + SFC_SET_RAW_START_OFFSET = 0x1090, + + SFC_SET_DITHER_ON_WRITE = 0x10A0, + SFC_SET_DITHER_ON_READ = 0x10A1, + + SFC_GET_DITHER_INFO_COUNT = 0x10A2, + SFC_GET_DITHER_INFO = 0x10A3, + + SFC_GET_EMBED_FILE_INFO = 0x10B0, + + SFC_SET_CLIPPING = 0x10C0, + SFC_GET_CLIPPING = 0x10C1, + + SFC_GET_CUE_COUNT = 0x10CD, + SFC_GET_CUE = 0x10CE, + SFC_SET_CUE = 0x10CF, + + SFC_GET_INSTRUMENT = 0x10D0, + SFC_SET_INSTRUMENT = 0x10D1, + + SFC_GET_LOOP_INFO = 0x10E0, + + SFC_GET_BROADCAST_INFO = 0x10F0, + SFC_SET_BROADCAST_INFO = 0x10F1, + + SFC_GET_CHANNEL_MAP_INFO = 0x1100, + SFC_SET_CHANNEL_MAP_INFO = 0x1101, + + SFC_RAW_DATA_NEEDS_ENDSWAP = 0x1110, + + /* Support for Wavex Ambisonics Format */ + SFC_WAVEX_SET_AMBISONIC = 0x1200, + SFC_WAVEX_GET_AMBISONIC = 0x1201, + + /* + ** RF64 files can be set so that on-close, writable files that have less + ** than 4GB of data in them are converted to RIFF/WAV, as per EBU + ** recommendations. + */ + SFC_RF64_AUTO_DOWNGRADE = 0x1210, + + SFC_SET_VBR_ENCODING_QUALITY = 0x1300, + SFC_SET_COMPRESSION_LEVEL = 0x1301, + + /* Cart Chunk support */ + SFC_SET_CART_INFO = 0x1400, + SFC_GET_CART_INFO = 0x1401, + + /* Following commands for testing only. */ + SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, + + /* + ** SFC_SET_ADD_* values are deprecated and will disappear at some + ** time in the future. They are guaranteed to be here up to and + ** including version 1.0.8 to avoid breakage of existing software. + ** They currently do nothing and will continue to do nothing. + */ + SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, + SFC_SET_ADD_DITHER_ON_READ = 0x1071 +} ; + + +/* +** String types that can be set and read from files. Not all file types +** support this and even the file types which support one, may not support +** all string types. +*/ + +enum +{ SF_STR_TITLE = 0x01, + SF_STR_COPYRIGHT = 0x02, + SF_STR_SOFTWARE = 0x03, + SF_STR_ARTIST = 0x04, + SF_STR_COMMENT = 0x05, + SF_STR_DATE = 0x06, + SF_STR_ALBUM = 0x07, + SF_STR_LICENSE = 0x08, + SF_STR_TRACKNUMBER = 0x09, + SF_STR_GENRE = 0x10 +} ; + +/* +** Use the following as the start and end index when doing metadata +** transcoding. +*/ + +#define SF_STR_FIRST SF_STR_TITLE +#define SF_STR_LAST SF_STR_GENRE + +enum +{ /* True and false */ + SF_FALSE = 0, + SF_TRUE = 1, + + /* Modes for opening files. */ + SFM_READ = 0x10, + SFM_WRITE = 0x20, + SFM_RDWR = 0x30, + + SF_AMBISONIC_NONE = 0x40, + SF_AMBISONIC_B_FORMAT = 0x41 +} ; + +/* Public error values. These are guaranteed to remain unchanged for the duration +** of the library major version number. +** There are also a large number of private error numbers which are internal to +** the library which can change at any time. +*/ + +enum +{ SF_ERR_NO_ERROR = 0, + SF_ERR_UNRECOGNISED_FORMAT = 1, + SF_ERR_SYSTEM = 2, + SF_ERR_MALFORMED_FILE = 3, + SF_ERR_UNSUPPORTED_ENCODING = 4 +} ; + + +/* Channel map values (used with SFC_SET/GET_CHANNEL_MAP). +*/ + +enum +{ SF_CHANNEL_MAP_INVALID = 0, + SF_CHANNEL_MAP_MONO = 1, + SF_CHANNEL_MAP_LEFT, /* Apple calls this 'Left' */ + SF_CHANNEL_MAP_RIGHT, /* Apple calls this 'Right' */ + SF_CHANNEL_MAP_CENTER, /* Apple calls this 'Center' */ + SF_CHANNEL_MAP_FRONT_LEFT, + SF_CHANNEL_MAP_FRONT_RIGHT, + SF_CHANNEL_MAP_FRONT_CENTER, + SF_CHANNEL_MAP_REAR_CENTER, /* Apple calls this 'Center Surround', Msft calls this 'Back Center' */ + SF_CHANNEL_MAP_REAR_LEFT, /* Apple calls this 'Left Surround', Msft calls this 'Back Left' */ + SF_CHANNEL_MAP_REAR_RIGHT, /* Apple calls this 'Right Surround', Msft calls this 'Back Right' */ + SF_CHANNEL_MAP_LFE, /* Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' */ + SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER, /* Apple calls this 'Left Center' */ + SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER, /* Apple calls this 'Right Center */ + SF_CHANNEL_MAP_SIDE_LEFT, /* Apple calls this 'Left Surround Direct' */ + SF_CHANNEL_MAP_SIDE_RIGHT, /* Apple calls this 'Right Surround Direct' */ + SF_CHANNEL_MAP_TOP_CENTER, /* Apple calls this 'Top Center Surround' */ + SF_CHANNEL_MAP_TOP_FRONT_LEFT, /* Apple calls this 'Vertical Height Left' */ + SF_CHANNEL_MAP_TOP_FRONT_RIGHT, /* Apple calls this 'Vertical Height Right' */ + SF_CHANNEL_MAP_TOP_FRONT_CENTER, /* Apple calls this 'Vertical Height Center' */ + SF_CHANNEL_MAP_TOP_REAR_LEFT, /* Apple and MS call this 'Top Back Left' */ + SF_CHANNEL_MAP_TOP_REAR_RIGHT, /* Apple and MS call this 'Top Back Right' */ + SF_CHANNEL_MAP_TOP_REAR_CENTER, /* Apple and MS call this 'Top Back Center' */ + + SF_CHANNEL_MAP_AMBISONIC_B_W, + SF_CHANNEL_MAP_AMBISONIC_B_X, + SF_CHANNEL_MAP_AMBISONIC_B_Y, + SF_CHANNEL_MAP_AMBISONIC_B_Z, + + SF_CHANNEL_MAP_MAX +} ; + + +/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */ + +typedef struct SNDFILE_tag SNDFILE ; + +/* The following typedef is system specific and is defined when libsndfile is +** compiled. sf_count_t will be a 64 bit value when the underlying OS allows +** 64 bit file offsets. +** On windows, we need to allow the same header file to be compiler by both GCC +** and the Microsoft compiler. +*/ + +#if (defined (_MSCVER) || defined (_MSC_VER) && (_MSC_VER < 1310)) +typedef __int64 sf_count_t ; +#define SF_COUNT_MAX 0x7fffffffffffffffi64 +#else +typedef __int64 sf_count_t ; +#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL +#endif + + +/* A pointer to a SF_INFO structure is passed to sf_open () and filled in. +** On write, the SF_INFO structure is filled in by the user and passed into +** sf_open (). +*/ + +struct SF_INFO +{ sf_count_t frames ; /* Used to be called samples. Changed to avoid confusion. */ + int samplerate ; + int channels ; + int format ; + int sections ; + int seekable ; +} ; + +typedef struct SF_INFO SF_INFO ; + +/* The SF_FORMAT_INFO struct is used to retrieve information about the sound +** file formats libsndfile supports using the sf_command () interface. +** +** Using this interface will allow applications to support new file formats +** and encoding types when libsndfile is upgraded, without requiring +** re-compilation of the application. +** +** Please consult the libsndfile documentation (particularly the information +** on the sf_command () interface) for examples of its use. +*/ + +typedef struct +{ int format ; + const char *name ; + const char *extension ; +} SF_FORMAT_INFO ; + +/* +** Enums and typedefs for adding dither on read and write. +** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE +** and SFC_SET_DITHER_ON_READ. +*/ + +enum +{ SFD_DEFAULT_LEVEL = 0, + SFD_CUSTOM_LEVEL = 0x40000000, + + SFD_NO_DITHER = 500, + SFD_WHITE = 501, + SFD_TRIANGULAR_PDF = 502 +} ; + +typedef struct +{ int type ; + double level ; + const char *name ; +} SF_DITHER_INFO ; + +/* Struct used to retrieve information about a file embedded within a +** larger file. See SFC_GET_EMBED_FILE_INFO. +*/ + +typedef struct +{ sf_count_t offset ; + sf_count_t length ; +} SF_EMBED_FILE_INFO ; + +/* +** Struct used to retrieve cue marker information from a file +*/ + +typedef struct +{ int32_t indx ; + uint32_t position ; + int32_t fcc_chunk ; + int32_t chunk_start ; + int32_t block_start ; + uint32_t sample_offset ; + char name [256] ; +} SF_CUE_POINT ; + +#define SF_CUES_VAR(count) \ + struct \ + { uint32_t cue_count ; \ + SF_CUE_POINT cue_points [count] ; \ + } + +typedef SF_CUES_VAR (100) SF_CUES ; + +/* +** Structs used to retrieve music sample information from a file. +*/ + +enum +{ /* + ** The loop mode field in SF_INSTRUMENT will be one of the following. + */ + SF_LOOP_NONE = 800, + SF_LOOP_FORWARD, + SF_LOOP_BACKWARD, + SF_LOOP_ALTERNATING +} ; + +typedef struct +{ int gain ; + char basenote, detune ; + char velocity_lo, velocity_hi ; + char key_lo, key_hi ; + int loop_count ; + + struct + { int mode ; + uint32_t start ; + uint32_t end ; + uint32_t count ; + } loops [16] ; /* make variable in a sensible way */ +} SF_INSTRUMENT ; + + + +/* Struct used to retrieve loop information from a file.*/ +typedef struct +{ + short time_sig_num ; /* any positive integer > 0 */ + short time_sig_den ; /* any positive power of 2 > 0 */ + int loop_mode ; /* see SF_LOOP enum */ + + int num_beats ; /* this is NOT the amount of quarter notes !!!*/ + /* a full bar of 4/4 is 4 beats */ + /* a full bar of 7/8 is 7 beats */ + + float bpm ; /* suggestion, as it can be calculated using other fields:*/ + /* file's length, file's sampleRate and our time_sig_den*/ + /* -> bpms are always the amount of _quarter notes_ per minute */ + + int root_key ; /* MIDI note, or -1 for None */ + int future [6] ; +} SF_LOOP_INFO ; + + +/* Struct used to retrieve broadcast (EBU) information from a file. +** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. +*/ +#define SF_BROADCAST_INFO_VAR(coding_hist_size) \ + struct \ + { char description [256] ; \ + char originator [32] ; \ + char originator_reference [32] ; \ + char origination_date [10] ; \ + char origination_time [8] ; \ + uint32_t time_reference_low ; \ + uint32_t time_reference_high ; \ + short version ; \ + char umid [64] ; \ + char reserved [190] ; \ + uint32_t coding_history_size ; \ + char coding_history [coding_hist_size] ; \ + } + +/* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ +typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; + +struct SF_CART_TIMER +{ char usage [4] ; + int32_t value ; +} ; + +typedef struct SF_CART_TIMER SF_CART_TIMER ; + +#define SF_CART_INFO_VAR(p_tag_text_size) \ + struct \ + { char version [4] ; \ + char title [64] ; \ + char artist [64] ; \ + char cut_id [64] ; \ + char client_id [64] ; \ + char category [64] ; \ + char classification [64] ; \ + char out_cue [64] ; \ + char start_date [10] ; \ + char start_time [8] ; \ + char end_date [10] ; \ + char end_time [8] ; \ + char producer_app_id [64] ; \ + char producer_app_version [64] ; \ + char user_def [64] ; \ + int32_t level_reference ; \ + SF_CART_TIMER post_timers [8] ; \ + char reserved [276] ; \ + char url [1024] ; \ + uint32_t tag_text_size ; \ + char tag_text [p_tag_text_size] ; \ + } + +typedef SF_CART_INFO_VAR (256) SF_CART_INFO ; + +/* Virtual I/O functionality. */ + +typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; +typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; +typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ; +typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ; +typedef sf_count_t (*sf_vio_tell) (void *user_data) ; + +struct SF_VIRTUAL_IO +{ sf_vio_get_filelen get_filelen ; + sf_vio_seek seek ; + sf_vio_read read ; + sf_vio_write write ; + sf_vio_tell tell ; +} ; + +typedef struct SF_VIRTUAL_IO SF_VIRTUAL_IO ; + + +/* Open the specified file for read, write or both. On error, this will +** return a NULL pointer. To find the error number, pass a NULL SNDFILE +** to sf_strerror (). +** All calls to sf_open() should be matched with a call to sf_close(). +*/ + +SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; + + +/* Use the existing file descriptor to create a SNDFILE object. If close_desc +** is TRUE, the file descriptor will be closed when sf_close() is called. If +** it is FALSE, the descriptor will not be closed. +** When passed a descriptor like this, the library will assume that the start +** of file header is at the current file offset. This allows sound files within +** larger container files to be read and/or written. +** On error, this will return a NULL pointer. To find the error number, pass a +** NULL SNDFILE to sf_strerror (). +** All calls to sf_open_fd() should be matched with a call to sf_close(). + +*/ + +SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; + +SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ; + + +/* sf_error () returns a error number which can be translated to a text +** string using sf_error_number(). +*/ + +int sf_error (SNDFILE *sndfile) ; + + +/* sf_strerror () returns to the caller a pointer to the current error message for +** the given SNDFILE. +*/ + +const char* sf_strerror (SNDFILE *sndfile) ; + + +/* sf_error_number () allows the retrieval of the error string for each internal +** error number. +** +*/ + +const char* sf_error_number (int errnum) ; + + +/* The following two error functions are deprecated but they will remain in the +** library for the foreseeable future. The function sf_strerror() should be used +** in their place. +*/ + +int sf_perror (SNDFILE *sndfile) ; +int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; + + +/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ + +int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; + + +/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */ + +int sf_format_check (const SF_INFO *info) ; + + +/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses +** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as +** stdio.h function fseek (). +** An offset of zero with whence set to SEEK_SET will position the +** read / write pointer to the first data sample. +** On success sf_seek returns the current position in (multi-channel) +** samples from the start of the file. +** Please see the libsndfile documentation for moving the read pointer +** separately from the write pointer on files open in mode SFM_RDWR. +** On error all of these functions return -1. +*/ + +enum +{ SF_SEEK_SET = SEEK_SET, + SF_SEEK_CUR = SEEK_CUR, + SF_SEEK_END = SEEK_END +} ; + +sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; + + +/* Functions for retrieving and setting string data within sound files. +** Not all file types support this features; AIFF and WAV do. For both +** functions, the str_type parameter must be one of the SF_STR_* values +** defined above. +** On error, sf_set_string() returns non-zero while sf_get_string() +** returns NULL. +*/ + +int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; + +const char* sf_get_string (SNDFILE *sndfile, int str_type) ; + + +/* Return the library version string. */ + +const char * sf_version_string (void) ; + +/* Return the current byterate at this point in the file. The byte rate in this +** case is the number of bytes per second of audio data. For instance, for a +** stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate +** would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec. +** For some file formats the returned value will be accurate and exact, for some +** it will be a close approximation, for some it will be the average bitrate for +** the whole file and for some it will be a time varying value that was accurate +** when the file was most recently read or written. +** To get the bitrate, multiple this value by 8. +** Returns -1 for unknown. +*/ +int sf_current_byterate (SNDFILE *sndfile) ; + +/* Functions for reading/writing the waveform data of a sound file. +*/ + +sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; +sf_count_t sf_write_raw (SNDFILE *sndfile, const void *ptr, sf_count_t bytes) ; + + +/* Functions for reading and writing the data chunk in terms of frames. +** The number of items actually read/written = frames * number of channels. +** sf_xxxx_raw read/writes the raw data bytes from/to the file +** sf_xxxx_short passes data in the native short format +** sf_xxxx_int passes data in the native int format +** sf_xxxx_float passes data in the native float format +** sf_xxxx_double passes data in the native double format +** All of these read/write function return number of frames read/written. +*/ + +sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; +sf_count_t sf_writef_short (SNDFILE *sndfile, const short *ptr, sf_count_t frames) ; + +sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; +sf_count_t sf_writef_int (SNDFILE *sndfile, const int *ptr, sf_count_t frames) ; + +sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; +sf_count_t sf_writef_float (SNDFILE *sndfile, const float *ptr, sf_count_t frames) ; + +sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; +sf_count_t sf_writef_double (SNDFILE *sndfile, const double *ptr, sf_count_t frames) ; + + +/* Functions for reading and writing the data chunk in terms of items. +** Otherwise similar to above. +** All of these read/write function return number of items read/written. +*/ + +sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; +sf_count_t sf_write_short (SNDFILE *sndfile, const short *ptr, sf_count_t items) ; + +sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; +sf_count_t sf_write_int (SNDFILE *sndfile, const int *ptr, sf_count_t items) ; + +sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; +sf_count_t sf_write_float (SNDFILE *sndfile, const float *ptr, sf_count_t items) ; + +sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; +sf_count_t sf_write_double (SNDFILE *sndfile, const double *ptr, sf_count_t items) ; + + +/* Close the SNDFILE and clean up all memory allocations associated with this +** file. +** Returns 0 on success, or an error number. +*/ + +int sf_close (SNDFILE *sndfile) ; + + +/* If the file is opened SFM_WRITE or SFM_RDWR, call fsync() on the file +** to force the writing of data to disk. If the file is opened SFM_READ +** no action is taken. +*/ + +void sf_write_sync (SNDFILE *sndfile) ; + + + +/* The function sf_wchar_open() is Windows Only! +** Open a file passing in a Windows Unicode filename. Otherwise, this is +** the same as sf_open(). +** +** In order for this to work, you need to do the following: +** +** #include +** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1 +** #including +*/ + +#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES) +SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; +#endif + + + + +/* Getting and setting of chunks from within a sound file. +** +** These functions allow the getting and setting of chunks within a sound file +** (for those formats which allow it). +** +** These functions fail safely. Specifically, they will not allow you to overwrite +** existing chunks or add extra versions of format specific reserved chunks but +** should allow you to retrieve any and all chunks (may not be implemented for +** all chunks or all file formats). +*/ + +struct SF_CHUNK_INFO +{ char id [64] ; /* The chunk identifier. */ + unsigned id_size ; /* The size of the chunk identifier. */ + unsigned datalen ; /* The size of that data. */ + void *data ; /* Pointer to the data. */ +} ; + +typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ; + +/* Set the specified chunk info (must be done before any audio data is written +** to the file). This will fail for format specific reserved chunks. +** The chunk_info->data pointer must be valid until the file is closed. +** Returns SF_ERR_NO_ERROR on success or non-zero on failure. +*/ +int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* +** An opaque structure to an iterator over the all chunks of a given id +*/ +typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ; + +/* Get an iterator for all chunks matching chunk_info. +** The iterator will point to the first chunk matching chunk_info. +** Chunks are matching, if (chunk_info->id) matches the first +** (chunk_info->id_size) bytes of a chunk found in the SNDFILE* handle. +** If chunk_info is NULL, an iterator to all chunks in the SNDFILE* handle +** is returned. +** The values of chunk_info->datalen and chunk_info->data are ignored. +** If no matching chunks are found in the sndfile, NULL is returned. +** The returned iterator will stay valid until one of the following occurs: +** a) The sndfile is closed. +** b) A new chunk is added using sf_set_chunk(). +** c) Another chunk iterator function is called on the same SNDFILE* handle +** that causes the iterator to be modified. +** The memory for the iterator belongs to the SNDFILE* handle and is freed when +** sf_close() is called. +*/ +SF_CHUNK_ITERATOR * +sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ; + +/* Iterate through chunks by incrementing the iterator. +** Increments the iterator and returns a handle to the new one. +** After this call, iterator will no longer be valid, and you must use the +** newly returned handle from now on. +** The returned handle can be used to access the next chunk matching +** the criteria as defined in sf_get_chunk_iterator(). +** If iterator points to the last chunk, this will free all resources +** associated with iterator and return NULL. +** The returned iterator will stay valid until sf_get_chunk_iterator_next +** is called again, the sndfile is closed or a new chunk us added. +*/ +SF_CHUNK_ITERATOR * +sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ; + + +/* Get the size of the specified chunk. +** If the specified chunk exists, the size will be returned in the +** datalen field of the SF_CHUNK_INFO struct. +** Additionally, the id of the chunk will be copied to the id +** field of the SF_CHUNK_INFO struct and it's id_size field will +** be updated accordingly. +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + +/* Get the specified chunk data. +** If the specified chunk exists, up to chunk_info->datalen bytes of +** the chunk data will be copied into the chunk_info->data buffer +** (allocated by the caller) and the chunk_info->datalen field +** updated to reflect the size of the data. The id and id_size +** field will be updated according to the retrieved chunk +** If the chunk doesn't exist chunk_info->datalen will be zero, and the +** id and id_size fields will be undefined. +** The function will return SF_ERR_NO_ERROR on success or non-zero on +** failure. +*/ +int +sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* SNDFILE_H */ + diff --git a/libsndfile/include/sndfile.hh b/libsndfile/include/sndfile.hh new file mode 100644 index 00000000..0e1c1c20 --- /dev/null +++ b/libsndfile/include/sndfile.hh @@ -0,0 +1,446 @@ +/* +** Copyright (C) 2005-2012 Erik de Castro Lopo +** +** 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. +** * Neither the author nor the names of any 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 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. +*/ + +/* +** The above modified BSD style license (GPL and LGPL compatible) applies to +** this file. It does not apply to libsndfile itself which is released under +** the GNU LGPL or the libsndfile test suite which is released under the GNU +** GPL. +** This means that this header file can be used under this modified BSD style +** license, but the LGPL still holds for the libsndfile library itself. +*/ + +/* +** sndfile.hh -- A lightweight C++ wrapper for the libsndfile API. +** +** All the methods are inlines and all functionality is contained in this +** file. There is no separate implementation file. +** +** API documentation is in the doc/ directory of the source code tarball +** and at http://www.mega-nerd.com/libsndfile/api.html. +*/ + +#ifndef SNDFILE_HH +#define SNDFILE_HH + +#include + +#include +#include // for std::nothrow + +class SndfileHandle +{ private : + struct SNDFILE_ref + { SNDFILE_ref (void) ; + ~SNDFILE_ref (void) ; + + SNDFILE *sf ; + SF_INFO sfinfo ; + int ref ; + } ; + + SNDFILE_ref *p ; + + public : + /* Default constructor */ + SndfileHandle (void) : p (NULL) {} ; + SndfileHandle (const char *path, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + SndfileHandle (std::string const & path, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + SndfileHandle (int fd, bool close_desc, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; + +#ifdef ENABLE_SNDFILE_WINDOWS_PROTOTYPES + SndfileHandle (LPCWSTR wpath, int mode = SFM_READ, + int format = 0, int channels = 0, int samplerate = 0) ; +#endif + + ~SndfileHandle (void) ; + + SndfileHandle (const SndfileHandle &orig) ; + SndfileHandle & operator = (const SndfileHandle &rhs) ; + + /* Mainly for debugging/testing. */ + int refCount (void) const { return (p == NULL) ? 0 : p->ref ; } + + operator bool () const { return (p != NULL) ; } + + bool operator == (const SndfileHandle &rhs) const { return (p == rhs.p) ; } + + sf_count_t frames (void) const { return p ? p->sfinfo.frames : 0 ; } + int format (void) const { return p ? p->sfinfo.format : 0 ; } + int channels (void) const { return p ? p->sfinfo.channels : 0 ; } + int samplerate (void) const { return p ? p->sfinfo.samplerate : 0 ; } + + int error (void) const ; + const char * strError (void) const ; + + int command (int cmd, void *data, int datasize) ; + + sf_count_t seek (sf_count_t frames, int whence) ; + + void writeSync (void) ; + + int setString (int str_type, const char* str) ; + + const char* getString (int str_type) const ; + + static int formatCheck (int format, int channels, int samplerate) ; + + sf_count_t read (short *ptr, sf_count_t items) ; + sf_count_t read (int *ptr, sf_count_t items) ; + sf_count_t read (float *ptr, sf_count_t items) ; + sf_count_t read (double *ptr, sf_count_t items) ; + + sf_count_t write (const short *ptr, sf_count_t items) ; + sf_count_t write (const int *ptr, sf_count_t items) ; + sf_count_t write (const float *ptr, sf_count_t items) ; + sf_count_t write (const double *ptr, sf_count_t items) ; + + sf_count_t readf (short *ptr, sf_count_t frames) ; + sf_count_t readf (int *ptr, sf_count_t frames) ; + sf_count_t readf (float *ptr, sf_count_t frames) ; + sf_count_t readf (double *ptr, sf_count_t frames) ; + + sf_count_t writef (const short *ptr, sf_count_t frames) ; + sf_count_t writef (const int *ptr, sf_count_t frames) ; + sf_count_t writef (const float *ptr, sf_count_t frames) ; + sf_count_t writef (const double *ptr, sf_count_t frames) ; + + sf_count_t readRaw (void *ptr, sf_count_t bytes) ; + sf_count_t writeRaw (const void *ptr, sf_count_t bytes) ; + + /**< Raw access to the handle. SndfileHandle keeps ownership. */ + SNDFILE * rawHandle (void) ; + + /**< Take ownership of handle, if reference count is 1. */ + SNDFILE * takeOwnership (void) ; +} ; + +/*============================================================================== +** Nothing but implementation below. +*/ + +inline +SndfileHandle::SNDFILE_ref::SNDFILE_ref (void) +: sf (NULL), sfinfo (), ref (1) +{} + +inline +SndfileHandle::SNDFILE_ref::~SNDFILE_ref (void) +{ if (sf != NULL) sf_close (sf) ; } + +inline +SndfileHandle::SndfileHandle (const char *path, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open (path, mode, &p->sfinfo) ; + } ; + + return ; +} /* SndfileHandle const char * constructor */ + +inline +SndfileHandle::SndfileHandle (std::string const & path, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open (path.c_str (), mode, &p->sfinfo) ; + } ; + + return ; +} /* SndfileHandle std::string constructor */ + +inline +SndfileHandle::SndfileHandle (int fd, bool close_desc, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + if (fd < 0) + return ; + + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open_fd (fd, mode, &p->sfinfo, close_desc) ; + } ; + + return ; +} /* SndfileHandle fd constructor */ + +inline +SndfileHandle::SndfileHandle (SF_VIRTUAL_IO &sfvirtual, void *user_data, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_open_virtual (&sfvirtual, mode, &p->sfinfo, user_data) ; + } ; + + return ; +} /* SndfileHandle std::string constructor */ + +inline +SndfileHandle::~SndfileHandle (void) +{ if (p != NULL && --p->ref == 0) + delete p ; +} /* SndfileHandle destructor */ + + +inline +SndfileHandle::SndfileHandle (const SndfileHandle &orig) +: p (orig.p) +{ if (p != NULL) + ++p->ref ; +} /* SndfileHandle copy constructor */ + +inline SndfileHandle & +SndfileHandle::operator = (const SndfileHandle &rhs) +{ + if (&rhs == this) + return *this ; + if (p != NULL && --p->ref == 0) + delete p ; + + p = rhs.p ; + if (p != NULL) + ++p->ref ; + + return *this ; +} /* SndfileHandle assignment operator */ + +inline int +SndfileHandle::error (void) const +{ return sf_error (p->sf) ; } + +inline const char * +SndfileHandle::strError (void) const +{ return sf_strerror (p->sf) ; } + +inline int +SndfileHandle::command (int cmd, void *data, int datasize) +{ return sf_command (p->sf, cmd, data, datasize) ; } + +inline sf_count_t +SndfileHandle::seek (sf_count_t frame_count, int whence) +{ return sf_seek (p->sf, frame_count, whence) ; } + +inline void +SndfileHandle::writeSync (void) +{ sf_write_sync (p->sf) ; } + +inline int +SndfileHandle::setString (int str_type, const char* str) +{ return sf_set_string (p->sf, str_type, str) ; } + +inline const char* +SndfileHandle::getString (int str_type) const +{ return sf_get_string (p->sf, str_type) ; } + +inline int +SndfileHandle::formatCheck (int fmt, int chans, int srate) +{ + SF_INFO sfinfo ; + + sfinfo.frames = 0 ; + sfinfo.channels = chans ; + sfinfo.format = fmt ; + sfinfo.samplerate = srate ; + sfinfo.sections = 0 ; + sfinfo.seekable = 0 ; + + return sf_format_check (&sfinfo) ; +} + +/*---------------------------------------------------------------------*/ + +inline sf_count_t +SndfileHandle::read (short *ptr, sf_count_t items) +{ return sf_read_short (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::read (int *ptr, sf_count_t items) +{ return sf_read_int (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::read (float *ptr, sf_count_t items) +{ return sf_read_float (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::read (double *ptr, sf_count_t items) +{ return sf_read_double (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::write (const short *ptr, sf_count_t items) +{ return sf_write_short (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::write (const int *ptr, sf_count_t items) +{ return sf_write_int (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::write (const float *ptr, sf_count_t items) +{ return sf_write_float (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::write (const double *ptr, sf_count_t items) +{ return sf_write_double (p->sf, ptr, items) ; } + +inline sf_count_t +SndfileHandle::readf (short *ptr, sf_count_t frame_count) +{ return sf_readf_short (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::readf (int *ptr, sf_count_t frame_count) +{ return sf_readf_int (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::readf (float *ptr, sf_count_t frame_count) +{ return sf_readf_float (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::readf (double *ptr, sf_count_t frame_count) +{ return sf_readf_double (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::writef (const short *ptr, sf_count_t frame_count) +{ return sf_writef_short (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::writef (const int *ptr, sf_count_t frame_count) +{ return sf_writef_int (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::writef (const float *ptr, sf_count_t frame_count) +{ return sf_writef_float (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::writef (const double *ptr, sf_count_t frame_count) +{ return sf_writef_double (p->sf, ptr, frame_count) ; } + +inline sf_count_t +SndfileHandle::readRaw (void *ptr, sf_count_t bytes) +{ return sf_read_raw (p->sf, ptr, bytes) ; } + +inline sf_count_t +SndfileHandle::writeRaw (const void *ptr, sf_count_t bytes) +{ return sf_write_raw (p->sf, ptr, bytes) ; } + +inline SNDFILE * +SndfileHandle::rawHandle (void) +{ return (p ? p->sf : NULL) ; } + +inline SNDFILE * +SndfileHandle::takeOwnership (void) +{ + if (p == NULL || (p->ref != 1)) + return NULL ; + + SNDFILE * sf = p->sf ; + p->sf = NULL ; + delete p ; + p = NULL ; + return sf ; +} + +#ifdef ENABLE_SNDFILE_WINDOWS_PROTOTYPES + +inline +SndfileHandle::SndfileHandle (LPCWSTR wpath, int mode, int fmt, int chans, int srate) +: p (NULL) +{ + p = new (std::nothrow) SNDFILE_ref () ; + + if (p != NULL) + { p->ref = 1 ; + + p->sfinfo.frames = 0 ; + p->sfinfo.channels = chans ; + p->sfinfo.format = fmt ; + p->sfinfo.samplerate = srate ; + p->sfinfo.sections = 0 ; + p->sfinfo.seekable = 0 ; + + p->sf = sf_wchar_open (wpath, mode, &p->sfinfo) ; + } ; + + return ; +} /* SndfileHandle const wchar_t * constructor */ + +#endif + +#endif /* SNDFILE_HH */ + diff --git a/libsndfile/lib/libsndfile-1.def b/libsndfile/lib/libsndfile-1.def new file mode 100644 index 00000000..4194ff3e --- /dev/null +++ b/libsndfile/lib/libsndfile-1.def @@ -0,0 +1,47 @@ +; Auto-generated by create_symbols_file.py + +LIBRARY libsndfile-1.dll +EXPORTS + +sf_command @1 +sf_open @2 +sf_close @3 +sf_seek @4 +sf_error @7 +sf_perror @8 +sf_error_str @9 +sf_error_number @10 +sf_format_check @11 +sf_read_raw @16 +sf_readf_short @17 +sf_readf_int @18 +sf_readf_float @19 +sf_readf_double @20 +sf_read_short @21 +sf_read_int @22 +sf_read_float @23 +sf_read_double @24 +sf_write_raw @32 +sf_writef_short @33 +sf_writef_int @34 +sf_writef_float @35 +sf_writef_double @36 +sf_write_short @37 +sf_write_int @38 +sf_write_float @39 +sf_write_double @40 +sf_strerror @50 +sf_get_string @60 +sf_set_string @61 +sf_version_string @68 +sf_open_fd @70 +sf_wchar_open @71 +sf_open_virtual @80 +sf_write_sync @90 +sf_set_chunk @100 +sf_get_chunk_size @101 +sf_get_chunk_data @102 +sf_get_chunk_iterator @103 +sf_next_chunk_iterator @104 +sf_current_byterate @110 + diff --git a/libsndfile/lib/libsndfile-1.lib b/libsndfile/lib/libsndfile-1.lib new file mode 100644 index 00000000..cc266ecd Binary files /dev/null and b/libsndfile/lib/libsndfile-1.lib differ diff --git a/libsndfile/lib/pkgconfig/sndfile.pc b/libsndfile/lib/pkgconfig/sndfile.pc new file mode 100644 index 00000000..428d708a --- /dev/null +++ b/libsndfile/lib/pkgconfig/sndfile.pc @@ -0,0 +1,12 @@ +prefix=c:/devel/target/libsndfile +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: sndfile +Description: A library for reading and writing audio files +Requires: +Version: 1.0.28 +Libs: -L${libdir} -lsndfile +Libs.private: Ext/libflac.la Ext/libvorbis.la Ext/libogg.la +Cflags: -I${includedir} diff --git a/mpg123/dist/libmpg123.dll b/mpg123/dist/libmpg123.dll new file mode 100644 index 00000000..ccb429bf Binary files /dev/null and b/mpg123/dist/libmpg123.dll differ diff --git a/mpg123/include/mpg123.h b/mpg123/include/mpg123.h new file mode 100644 index 00000000..03cf9197 --- /dev/null +++ b/mpg123/include/mpg123.h @@ -0,0 +1,1034 @@ +/* + libmpg123: MPEG Audio Decoder library (version 1.13.4) + + copyright 1995-2010 by the mpg123 project - free software under the terms of the LGPL 2.1 + see COPYING and AUTHORS files in distribution or http://mpg123.org +*/ + +#ifndef MPG123_LIB_H +#define MPG123_LIB_H + +/** \file mpg123.h The header file for the libmpg123 MPEG Audio decoder */ + +/* A macro to check at compile time which set of API functions to expect. + This should be incremented at least each time a new symbol is added to the header. */ +#define MPG123_API_VERSION 29 + +/* These aren't actually in use... seems to work without using libtool. */ +#ifdef BUILD_MPG123_DLL +/* The dll exports. */ +#define EXPORT __declspec(dllexport) +#else +#ifdef LINK_MPG123_DLL +/* The exe imports. */ +#define EXPORT __declspec(dllimport) +#else +/* Nothing on normal/UNIX builds */ +#define EXPORT +#endif +#endif + +#ifndef MPG123_NO_CONFIGURE /* Enable use of this file without configure. */ +#include +#include + +/* Simplified large file handling. + I used to have a check here that prevents building for a library with conflicting large file setup + (application that uses 32 bit offsets with library that uses 64 bits). + While that was perfectly fine in an environment where there is one incarnation of the library, + it hurt GNU/Linux and Solaris systems with multilib where the distribution fails to provide the + correct header matching the 32 bit library (where large files need explicit support) or + the 64 bit library (where there is no distinction). + + New approach: When the app defines _FILE_OFFSET_BITS, it wants non-default large file support, + and thus functions with added suffix (mpg123_open_64). + Any mismatch will be caught at link time because of the _FILE_OFFSET_BITS setting used when + building libmpg123. Plus, there's dual mode large file support in mpg123 since 1.12 now. + Link failure is not the expected outcome of any half-sane usage anymore. + + More complication: What about client code defining _LARGEFILE64_SOURCE? It might want direct access to the _64 functions, along with the ones without suffix. Well, that's possible now via defining MPG123_NO_LARGENAME and MPG123_LARGESUFFIX, respectively, for disabling or enforcing the suffix names. +*/ + +/* + Now, the renaming of large file aware functions. + By default, it appends underscore _FILE_OFFSET_BITS (so, mpg123_seek_64 for mpg123_seek), if _FILE_OFFSET_BITS is defined. You can force a different suffix via MPG123_LARGESUFFIX (that must include the underscore), or you can just disable the whole mess by defining MPG123_NO_LARGENAME. +*/ +#if (!defined MPG123_NO_LARGENAME) && ((defined _FILE_OFFSET_BITS) || (defined MPG123_LARGESUFFIX)) + +/* Need some trickery to concatenate the value(s) of the given macro(s). */ +#define MPG123_MACROCAT_REALLY(a, b) a ## b +#define MPG123_MACROCAT(a, b) MPG123_MACROCAT_REALLY(a, b) +#ifndef MPG123_LARGESUFFIX +#define MPG123_LARGESUFFIX MPG123_MACROCAT(_, _FILE_OFFSET_BITS) +#endif +#define MPG123_LARGENAME(func) MPG123_MACROCAT(func, MPG123_LARGESUFFIX) + +#define mpg123_open MPG123_LARGENAME(mpg123_open) +#define mpg123_open_fd MPG123_LARGENAME(mpg123_open_fd) +#define mpg123_open_handle MPG123_LARGENAME(mpg123_open_handle) +#define mpg123_framebyframe_decode MPG123_LARGENAME(mpg123_framebyframe_decode) +#define mpg123_decode_frame MPG123_LARGENAME(mpg123_decode_frame) +#define mpg123_tell MPG123_LARGENAME(mpg123_tell) +#define mpg123_tellframe MPG123_LARGENAME(mpg123_tellframe) +#define mpg123_tell_stream MPG123_LARGENAME(mpg123_tell_stream) +#define mpg123_seek MPG123_LARGENAME(mpg123_seek) +#define mpg123_feedseek MPG123_LARGENAME(mpg123_feedseek) +#define mpg123_seek_frame MPG123_LARGENAME(mpg123_seek_frame) +#define mpg123_timeframe MPG123_LARGENAME(mpg123_timeframe) +#define mpg123_index MPG123_LARGENAME(mpg123_index) +#define mpg123_set_index MPG123_LARGENAME(mpg123_set_index) +#define mpg123_position MPG123_LARGENAME(mpg123_position) +#define mpg123_length MPG123_LARGENAME(mpg123_length) +#define mpg123_set_filesize MPG123_LARGENAME(mpg123_set_filesize) +#define mpg123_replace_reader MPG123_LARGENAME(mpg123_replace_reader) +#define mpg123_replace_reader_handle MPG123_LARGENAME(mpg123_replace_reader_handle) + +#endif /* largefile hackery */ + +#endif /* MPG123_NO_CONFIGURE */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** \defgroup mpg123_init mpg123 library and handle setup + * + * Functions to initialise and shutdown the mpg123 library and handles. + * The parameters of handles have workable defaults, you only have to tune them when you want to tune something;-) + * Tip: Use a RVA setting... + * + * @{ + */ + +/** Opaque structure for the libmpg123 decoder handle. */ +struct mpg123_handle_struct; + +/** Opaque structure for the libmpg123 decoder handle. + * Most functions take a pointer to a mpg123_handle as first argument and operate on its data in an object-oriented manner. + */ +typedef struct mpg123_handle_struct mpg123_handle; + +/** Function to initialise the mpg123 library. + * This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library. + * + * \return MPG123_OK if successful, otherwise an error number. + */ +EXPORT int mpg123_init(void); + +/** Function to close down the mpg123 library. + * This function is not thread-safe. Call it exactly once per process, before any other (possibly threaded) work with the library. */ +EXPORT void mpg123_exit(void); + +/** Create a handle with optional choice of decoder (named by a string, see mpg123_decoders() or mpg123_supported_decoders()). + * and optional retrieval of an error code to feed to mpg123_plain_strerror(). + * Optional means: Any of or both the parameters may be NULL. + * + * \return Non-NULL pointer when successful. + */ +EXPORT mpg123_handle *mpg123_new(const char* decoder, int *error); + +/** Delete handle, mh is either a valid mpg123 handle or NULL. */ +EXPORT void mpg123_delete(mpg123_handle *mh); + +/** Enumeration of the parameters types that it is possible to set/get. */ +enum mpg123_parms +{ + MPG123_VERBOSE, /**< set verbosity value for enabling messages to stderr, >= 0 makes sense (integer) */ + MPG123_FLAGS, /**< set all flags, p.ex val = MPG123_GAPLESS|MPG123_MONO_MIX (integer) */ + MPG123_ADD_FLAGS, /**< add some flags (integer) */ + MPG123_FORCE_RATE, /**< when value > 0, force output rate to that value (integer) */ + MPG123_DOWN_SAMPLE, /**< 0=native rate, 1=half rate, 2=quarter rate (integer) */ + MPG123_RVA, /**< one of the RVA choices above (integer) */ + MPG123_DOWNSPEED, /**< play a frame N times (integer) */ + MPG123_UPSPEED, /**< play every Nth frame (integer) */ + MPG123_START_FRAME, /**< start with this frame (skip frames before that, integer) */ + MPG123_DECODE_FRAMES, /**< decode only this number of frames (integer) */ + MPG123_ICY_INTERVAL, /**< stream contains ICY metadata with this interval (integer) */ + MPG123_OUTSCALE, /**< the scale for output samples (amplitude - integer or float according to mpg123 output format, normally integer) */ + MPG123_TIMEOUT, /**< timeout for reading from a stream (not supported on win32, integer) */ + MPG123_REMOVE_FLAGS, /**< remove some flags (inverse of MPG123_ADD_FLAGS, integer) */ + MPG123_RESYNC_LIMIT, /**< Try resync on frame parsing for that many bytes or until end of stream (<0 ... integer). */ + MPG123_INDEX_SIZE /**< Set the frame index size (if supported). Values <0 mean that the index is allowed to grow dynamically in these steps (in positive direction, of course) -- Use this when you really want a full index with every individual frame. */ + ,MPG123_PREFRAMES /**< Decode/ignore that many frames in advance for layer 3. This is needed to fill bit reservoir after seeking, for example (but also at least one frame in advance is needed to have all "normal" data for layer 3). Give a positive integer value, please.*/ +}; + +/** Flag bits for MPG123_FLAGS, use the usual binary or to combine. */ +enum mpg123_param_flags +{ + MPG123_FORCE_MONO = 0x7 /**< 0111 Force some mono mode: This is a test bitmask for seeing if any mono forcing is active. */ + ,MPG123_MONO_LEFT = 0x1 /**< 0001 Force playback of left channel only. */ + ,MPG123_MONO_RIGHT = 0x2 /**< 0010 Force playback of right channel only. */ + ,MPG123_MONO_MIX = 0x4 /**< 0100 Force playback of mixed mono. */ + ,MPG123_FORCE_STEREO = 0x8 /**< 1000 Force stereo output. */ + ,MPG123_FORCE_8BIT = 0x10 /**< 00010000 Force 8bit formats. */ + ,MPG123_QUIET = 0x20 /**< 00100000 Suppress any printouts (overrules verbose). */ + ,MPG123_GAPLESS = 0x40 /**< 01000000 Enable gapless decoding (default on if libmpg123 has support). */ + ,MPG123_NO_RESYNC = 0x80 /**< 10000000 Disable resync stream after error. */ + ,MPG123_SEEKBUFFER = 0x100 /**< 000100000000 Enable small buffer on non-seekable streams to allow some peek-ahead (for better MPEG sync). */ + ,MPG123_FUZZY = 0x200 /**< 001000000000 Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC) */ + ,MPG123_FORCE_FLOAT = 0x400 /**< 010000000000 Force floating point output (32 or 64 bits depends on mpg123 internal precision). */ + ,MPG123_PLAIN_ID3TEXT = 0x800 /**< 100000000000 Do not translate ID3 text data to UTF-8. ID3 strings will contain the raw text data, with the first byte containing the ID3 encoding code. */ + ,MPG123_IGNORE_STREAMLENGTH = 0x1000 /**< 1000000000000 Ignore any stream length information contained in the stream, which can be contained in a 'TLEN' frame of an ID3v2 tag or a Xing tag */ + ,MPG123_SKIP_ID3V2 = 0x2000 /**< 10 0000 0000 0000 Do not parse ID3v2 tags, just skip them. */ +}; + +/** choices for MPG123_RVA */ +enum mpg123_param_rva +{ + MPG123_RVA_OFF = 0 /**< RVA disabled (default). */ + ,MPG123_RVA_MIX = 1 /**< Use mix/track/radio gain. */ + ,MPG123_RVA_ALBUM = 2 /**< Use album/audiophile gain */ + ,MPG123_RVA_MAX = MPG123_RVA_ALBUM /**< The maximum RVA code, may increase in future. */ +}; + +/* TODO: Assess the possibilities and troubles of changing parameters during playback. */ + +/** Set a specific parameter, for a specific mpg123_handle, using a parameter + * type key chosen from the mpg123_parms enumeration, to the specified value. */ +EXPORT int mpg123_param(mpg123_handle *mh, enum mpg123_parms type, long value, double fvalue); + +/** Get a specific parameter, for a specific mpg123_handle. + * See the mpg123_parms enumeration for a list of available parameters. */ +EXPORT int mpg123_getparam(mpg123_handle *mh, enum mpg123_parms type, long *val, double *fval); + +/** Feature set available for query with mpg123_feature. */ +enum mpg123_feature_set +{ + MPG123_FEATURE_ABI_UTF8OPEN = 0 /**< mpg123 expects path names to be given in UTF-8 encoding instead of plain native. */ + ,MPG123_FEATURE_OUTPUT_8BIT /**< 8bit output */ + ,MPG123_FEATURE_OUTPUT_16BIT /**< 16bit output */ + ,MPG123_FEATURE_OUTPUT_32BIT /**< 32bit output */ + ,MPG123_FEATURE_INDEX /**< support for building a frame index for accurate seeking */ + ,MPG123_FEATURE_PARSE_ID3V2 /**< id3v2 parsing */ + ,MPG123_FEATURE_DECODE_LAYER1 /**< mpeg layer-1 decoder enabled */ + ,MPG123_FEATURE_DECODE_LAYER2 /**< mpeg layer-2 decoder enabled */ + ,MPG123_FEATURE_DECODE_LAYER3 /**< mpeg layer-3 decoder enabled */ + ,MPG123_FEATURE_DECODE_ACCURATE /**< accurate decoder rounding */ + ,MPG123_FEATURE_DECODE_DOWNSAMPLE /**< downsample (sample omit) */ + ,MPG123_FEATURE_DECODE_NTOM /**< flexible rate decoding */ + ,MPG123_FEATURE_PARSE_ICY /**< ICY support */ + ,MPG123_FEATURE_TIMEOUT_READ /**< Reader with timeout (network). */ +}; + +/** Query libmpg123 feature, 1 for success, 0 for unimplemented functions. */ +EXPORT int mpg123_feature(const enum mpg123_feature_set key); + +/* @} */ + + +/** \defgroup mpg123_error mpg123 error handling + * + * Functions to get text version of the error numbers and an enumeration + * of the error codes returned by libmpg123. + * + * Most functions operating on a mpg123_handle simply return MPG123_OK on success and MPG123_ERR on failure (setting the internal error variable of the handle to the specific error code). + * Decoding/seek functions may also return message codes MPG123_DONE, MPG123_NEW_FORMAT and MPG123_NEED_MORE (please read up on these on how to react!). + * The positive range of return values is used for "useful" values when appropriate. + * + * @{ + */ + +/** Enumeration of the message and error codes and returned by libmpg123 functions. */ +enum mpg123_errors +{ + MPG123_DONE=-12, /**< Message: Track ended. Stop decoding. */ + MPG123_NEW_FORMAT=-11, /**< Message: Output format will be different on next call. Note that some libmpg123 versions between 1.4.3 and 1.8.0 insist on you calling mpg123_getformat() after getting this message code. Newer verisons behave like advertised: You have the chance to call mpg123_getformat(), but you can also just continue decoding and get your data. */ + MPG123_NEED_MORE=-10, /**< Message: For feed reader: "Feed me more!" (call mpg123_feed() or mpg123_decode() with some new input data). */ + MPG123_ERR=-1, /**< Generic Error */ + MPG123_OK=0, /**< Success */ + MPG123_BAD_OUTFORMAT, /**< Unable to set up output format! */ + MPG123_BAD_CHANNEL, /**< Invalid channel number specified. */ + MPG123_BAD_RATE, /**< Invalid sample rate specified. */ + MPG123_ERR_16TO8TABLE, /**< Unable to allocate memory for 16 to 8 converter table! */ + MPG123_BAD_PARAM, /**< Bad parameter id! */ + MPG123_BAD_BUFFER, /**< Bad buffer given -- invalid pointer or too small size. */ + MPG123_OUT_OF_MEM, /**< Out of memory -- some malloc() failed. */ + MPG123_NOT_INITIALIZED, /**< You didn't initialize the library! */ + MPG123_BAD_DECODER, /**< Invalid decoder choice. */ + MPG123_BAD_HANDLE, /**< Invalid mpg123 handle. */ + MPG123_NO_BUFFERS, /**< Unable to initialize frame buffers (out of memory?). */ + MPG123_BAD_RVA, /**< Invalid RVA mode. */ + MPG123_NO_GAPLESS, /**< This build doesn't support gapless decoding. */ + MPG123_NO_SPACE, /**< Not enough buffer space. */ + MPG123_BAD_TYPES, /**< Incompatible numeric data types. */ + MPG123_BAD_BAND, /**< Bad equalizer band. */ + MPG123_ERR_NULL, /**< Null pointer given where valid storage address needed. */ + MPG123_ERR_READER, /**< Error reading the stream. */ + MPG123_NO_SEEK_FROM_END,/**< Cannot seek from end (end is not known). */ + MPG123_BAD_WHENCE, /**< Invalid 'whence' for seek function.*/ + MPG123_NO_TIMEOUT, /**< Build does not support stream timeouts. */ + MPG123_BAD_FILE, /**< File access error. */ + MPG123_NO_SEEK, /**< Seek not supported by stream. */ + MPG123_NO_READER, /**< No stream opened. */ + MPG123_BAD_PARS, /**< Bad parameter handle. */ + MPG123_BAD_INDEX_PAR, /**< Bad parameters to mpg123_index() and mpg123_set_index() */ + MPG123_OUT_OF_SYNC, /**< Lost track in bytestream and did not try to resync. */ + MPG123_RESYNC_FAIL, /**< Resync failed to find valid MPEG data. */ + MPG123_NO_8BIT, /**< No 8bit encoding possible. */ + MPG123_BAD_ALIGN, /**< Stack aligmnent error */ + MPG123_NULL_BUFFER, /**< NULL input buffer with non-zero size... */ + MPG123_NO_RELSEEK, /**< Relative seek not possible (screwed up file offset) */ + MPG123_NULL_POINTER, /**< You gave a null pointer somewhere where you shouldn't have. */ + MPG123_BAD_KEY, /**< Bad key value given. */ + MPG123_NO_INDEX, /**< No frame index in this build. */ + MPG123_INDEX_FAIL, /**< Something with frame index went wrong. */ + MPG123_BAD_DECODER_SETUP, /**< Something prevents a proper decoder setup */ + MPG123_MISSING_FEATURE /**< This feature has not been built into libmpg123. */ + ,MPG123_BAD_VALUE /**< A bad value has been given, somewhere. */ + ,MPG123_LSEEK_FAILED /**< Low-level seek failed. */ + ,MPG123_BAD_CUSTOM_IO /**< Custom I/O not prepared. */ + ,MPG123_LFS_OVERFLOW /**< Offset value overflow during translation of large file API calls -- your client program cannot handle that large file. */ +}; + +/** Return a string describing that error errcode means. */ +EXPORT const char* mpg123_plain_strerror(int errcode); + +/** Give string describing what error has occured in the context of handle mh. + * When a function operating on an mpg123 handle returns MPG123_ERR, you should check for the actual reason via + * char *errmsg = mpg123_strerror(mh) + * This function will catch mh == NULL and return the message for MPG123_BAD_HANDLE. */ +EXPORT const char* mpg123_strerror(mpg123_handle *mh); + +/** Return the plain errcode intead of a string. */ +EXPORT int mpg123_errcode(mpg123_handle *mh); + +/*@}*/ + + +/** \defgroup mpg123_decoder mpg123 decoder selection + * + * Functions to list and select the available decoders. + * Perhaps the most prominent feature of mpg123: You have several (optimized) decoders to choose from (on x86 and PPC (MacOS) systems, that is). + * + * @{ + */ + +/** Return a NULL-terminated array of generally available decoder names (plain 8bit ASCII). */ +EXPORT const char **mpg123_decoders(void); + +/** Return a NULL-terminated array of the decoders supported by the CPU (plain 8bit ASCII). */ +EXPORT const char **mpg123_supported_decoders(void); + +/** Set the chosen decoder to 'decoder_name' */ +EXPORT int mpg123_decoder(mpg123_handle *mh, const char* decoder_name); + +/** Get the currently active decoder engine name. + The active decoder engine can vary depening on output constraints, + mostly non-resampling, integer output is accelerated via 3DNow & Co. but for other modes a fallback engine kicks in. + Note that this can return a decoder that is ony active in the hidden and not available as decoder choice from the outside. + \return The decoder name or NULL on error. */ +EXPORT const char* mpg123_current_decoder(mpg123_handle *mh); + +/*@}*/ + + +/** \defgroup mpg123_output mpg123 output audio format + * + * Functions to get and select the format of the decoded audio. + * + * @{ + */ + +/** An enum over all sample types possibly known to mpg123. + * The values are designed as bit flags to allow bitmasking for encoding families. + * + * Note that (your build of) libmpg123 does not necessarily support all these. + * Usually, you can expect the 8bit encodings and signed 16 bit. + * Also 32bit float will be usual beginning with mpg123-1.7.0 . + * What you should bear in mind is that (SSE, etc) optimized routines may be absent + * for some formats. We do have SSE for 16, 32 bit and float, though. + * 24 bit integer is done via postprocessing of 32 bit output -- just cutting + * the last byte, no rounding, even. If you want better, do it yourself. + * + * All formats are in native byte order. If you need different endinaness, you + * can simply postprocess the output buffers (libmpg123 wouldn't do anything else). + * mpg123_encsize() can be helpful there. + */ +enum mpg123_enc_enum +{ + MPG123_ENC_8 = 0x00f /**< 0000 0000 1111 Some 8 bit integer encoding. */ + ,MPG123_ENC_16 = 0x040 /**< 0000 0100 0000 Some 16 bit integer encoding. */ + ,MPG123_ENC_24 = 0x4000 /**< 0100 0000 0000 0000 Some 24 bit integer encoding. */ + ,MPG123_ENC_32 = 0x100 /**< 0001 0000 0000 Some 32 bit integer encoding. */ + ,MPG123_ENC_SIGNED = 0x080 /**< 0000 1000 0000 Some signed integer encoding. */ + ,MPG123_ENC_FLOAT = 0xe00 /**< 1110 0000 0000 Some float encoding. */ + ,MPG123_ENC_SIGNED_16 = (MPG123_ENC_16|MPG123_ENC_SIGNED|0x10) /**< 1101 0000 signed 16 bit */ + ,MPG123_ENC_UNSIGNED_16 = (MPG123_ENC_16|0x20) /**< 0110 0000 unsigned 16 bit */ + ,MPG123_ENC_UNSIGNED_8 = 0x01 /**< 0000 0001 unsigned 8 bit */ + ,MPG123_ENC_SIGNED_8 = (MPG123_ENC_SIGNED|0x02) /**< 1000 0010 signed 8 bit */ + ,MPG123_ENC_ULAW_8 = 0x04 /**< 0000 0100 ulaw 8 bit */ + ,MPG123_ENC_ALAW_8 = 0x08 /**< 0000 1000 alaw 8 bit */ + ,MPG123_ENC_SIGNED_32 = MPG123_ENC_32|MPG123_ENC_SIGNED|0x1000 /**< 0001 0001 1000 0000 signed 32 bit */ + ,MPG123_ENC_UNSIGNED_32 = MPG123_ENC_32|0x2000 /**< 0010 0001 0000 0000 unsigned 32 bit */ + ,MPG123_ENC_SIGNED_24 = MPG123_ENC_24|MPG123_ENC_SIGNED|0x1000 /**< 0101 0000 1000 0000 signed 24 bit */ + ,MPG123_ENC_UNSIGNED_24 = MPG123_ENC_24|0x2000 /**< 0110 0000 0000 0000 unsigned 24 bit */ + ,MPG123_ENC_FLOAT_32 = 0x200 /**< 0010 0000 0000 32bit float */ + ,MPG123_ENC_FLOAT_64 = 0x400 /**< 0100 0000 0000 64bit float */ + ,MPG123_ENC_ANY = ( MPG123_ENC_SIGNED_16 | MPG123_ENC_UNSIGNED_16 | MPG123_ENC_UNSIGNED_8 + | MPG123_ENC_SIGNED_8 | MPG123_ENC_ULAW_8 | MPG123_ENC_ALAW_8 + | MPG123_ENC_SIGNED_32 | MPG123_ENC_UNSIGNED_32 + | MPG123_ENC_SIGNED_24 | MPG123_ENC_UNSIGNED_24 + | MPG123_ENC_FLOAT_32 | MPG123_ENC_FLOAT_64 ) /**< Any encoding on the list. */ +}; + +/** They can be combined into one number (3) to indicate mono and stereo... */ +enum mpg123_channelcount +{ + MPG123_MONO = 1 + ,MPG123_STEREO = 2 +}; + +/** An array of supported standard sample rates + * These are possible native sample rates of MPEG audio files. + * You can still force mpg123 to resample to a different one, but by default you will only get audio in one of these samplings. + * \param list Store a pointer to the sample rates array there. + * \param number Store the number of sample rates there. */ +EXPORT void mpg123_rates(const long **list, size_t *number); + +/** An array of supported audio encodings. + * An audio encoding is one of the fully qualified members of mpg123_enc_enum (MPG123_ENC_SIGNED_16, not MPG123_SIGNED). + * \param list Store a pointer to the encodings array there. + * \param number Store the number of encodings there. */ +EXPORT void mpg123_encodings(const int **list, size_t *number); + +/** Return the size (in bytes) of one mono sample of the named encoding. + * \param encoding The encoding value to analyze. + * \return positive size of encoding in bytes, 0 on invalid encoding. */ +EXPORT int mpg123_encsize(int encoding); + +/** Configure a mpg123 handle to accept no output format at all, + * use before specifying supported formats with mpg123_format */ +EXPORT int mpg123_format_none(mpg123_handle *mh); + +/** Configure mpg123 handle to accept all formats + * (also any custom rate you may set) -- this is default. */ +EXPORT int mpg123_format_all(mpg123_handle *mh); + +/** Set the audio format support of a mpg123_handle in detail: + * \param mh audio decoder handle + * \param rate The sample rate value (in Hertz). + * \param channels A combination of MPG123_STEREO and MPG123_MONO. + * \param encodings A combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16 | MPG123_ENC_ULAW_8 (or 0 for no support). Please note that some encodings may not be supported in the library build and thus will be ignored here. + * \return MPG123_OK on success, MPG123_ERR if there was an error. */ +EXPORT int mpg123_format(mpg123_handle *mh, long rate, int channels, int encodings); + +/** Check to see if a specific format at a specific rate is supported + * by mpg123_handle. + * \return 0 for no support (that includes invalid parameters), MPG123_STEREO, + * MPG123_MONO or MPG123_STEREO|MPG123_MONO. */ +EXPORT int mpg123_format_support(mpg123_handle *mh, long rate, int encoding); + +/** Get the current output format written to the addresses givenr. */ +EXPORT int mpg123_getformat(mpg123_handle *mh, long *rate, int *channels, int *encoding); + +/*@}*/ + + +/** \defgroup mpg123_input mpg123 file input and decoding + * + * Functions for input bitstream and decoding operations. + * Decoding/seek functions may also return message codes MPG123_DONE, MPG123_NEW_FORMAT and MPG123_NEED_MORE (please read up on these on how to react!). + * @{ + */ + +/* reading samples / triggering decoding, possible return values: */ +/** Enumeration of the error codes returned by libmpg123 functions. */ + +/** Open and prepare to decode the specified file by filesystem path. + * This does not open HTTP urls; libmpg123 contains no networking code. + * If you want to decode internet streams, use mpg123_open_fd() or mpg123_open_feed(). + */ +EXPORT int mpg123_open(mpg123_handle *mh, const char *path); + +/** Use an already opened file descriptor as the bitstream input + * mpg123_close() will _not_ close the file descriptor. + */ +EXPORT int mpg123_open_fd(mpg123_handle *mh, int fd); + +/** Use an opaque handle as bitstream input. This works only with the + * replaced I/O from mpg123_replace_reader_handle()! + * mpg123_close() will call the cleanup callback for your handle (if you gave one). + */ +EXPORT int mpg123_open_handle(mpg123_handle *mh, void *iohandle); + +/** Open a new bitstream and prepare for direct feeding + * This works together with mpg123_decode(); you are responsible for reading and feeding the input bitstream. + */ +EXPORT int mpg123_open_feed(mpg123_handle *mh); + +/** Closes the source, if libmpg123 opened it. */ +EXPORT int mpg123_close(mpg123_handle *mh); + +/** Read from stream and decode up to outmemsize bytes. + * \param outmemory address of output buffer to write to + * \param outmemsize maximum number of bytes to write + * \param done address to store the number of actually decoded bytes to + * \return error/message code (watch out for MPG123_DONE and friends!) */ +EXPORT int mpg123_read(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done); + +/** Feed data for a stream that has been opened with mpg123_open_feed(). + * It's give and take: You provide the bytestream, mpg123 gives you the decoded samples. + * \param in input buffer + * \param size number of input bytes + * \return error/message code. */ +EXPORT int mpg123_feed(mpg123_handle *mh, const unsigned char *in, size_t size); + +/** Decode MPEG Audio from inmemory to outmemory. + * This is very close to a drop-in replacement for old mpglib. + * When you give zero-sized output buffer the input will be parsed until + * decoded data is available. This enables you to get MPG123_NEW_FORMAT (and query it) + * without taking decoded data. + * Think of this function being the union of mpg123_read() and mpg123_feed() (which it actually is, sort of;-). + * You can actually always decide if you want those specialized functions in separate steps or one call this one here. + * \param inmemory input buffer + * \param inmemsize number of input bytes + * \param outmemory output buffer + * \param outmemsize maximum number of output bytes + * \param done address to store the number of actually decoded bytes to + * \return error/message code (watch out especially for MPG123_NEED_MORE) + */ +EXPORT int mpg123_decode(mpg123_handle *mh, const unsigned char *inmemory, size_t inmemsize, unsigned char *outmemory, size_t outmemsize, size_t *done); + +/** Decode next MPEG frame to internal buffer + * or read a frame and return after setting a new format. + * \param num current frame offset gets stored there + * \param audio This pointer is set to the internal buffer to read the decoded audio from. + * \param bytes number of output bytes ready in the buffer + */ +EXPORT int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); + +/** Decode current MPEG frame to internal buffer. + * Warning: This is experimental API that might change in future releases! + * Please watch mpg123 development closely when using it. + * \param num last frame offset gets stored there + * \param audio this pointer is set to the internal buffer to read the decoded audio from. + * \param bytes number of output bytes ready in the buffer + */ +EXPORT int mpg123_framebyframe_decode(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); + +/** Find, read and parse the next mp3 frame + * Warning: This is experimental API that might change in future releases! + * Please watch mpg123 development closely when using it. + */ +EXPORT int mpg123_framebyframe_next(mpg123_handle *mh); + +/*@}*/ + + +/** \defgroup mpg123_seek mpg123 position and seeking + * + * Functions querying and manipulating position in the decoded audio bitstream. + * The position is measured in decoded audio samples, or MPEG frame offset for the specific functions. + * If gapless code is in effect, the positions are adjusted to compensate the skipped padding/delay - meaning, you should not care about that at all and just use the position defined for the samples you get out of the decoder;-) + * The general usage is modelled after stdlib's ftell() and fseek(). + * Especially, the whence parameter for the seek functions has the same meaning as the one for fseek() and needs the same constants from stdlib.h: + * - SEEK_SET: set position to (or near to) specified offset + * - SEEK_CUR: change position by offset from now + * - SEEK_END: set position to offset from end + * + * Note that sample-accurate seek only works when gapless support has been enabled at compile time; seek is frame-accurate otherwise. + * Also, really sample-accurate seeking (meaning that you get the identical sample value after seeking compared to plain decoding up to the position) is only guaranteed when you do not mess with the position code by using MPG123_UPSPEED, MPG123_DOWNSPEED or MPG123_START_FRAME. The first two mainly should cause trouble with NtoM resampling, but in any case with these options in effect, you have to keep in mind that the sample offset is not the same as counting the samples you get from decoding since mpg123 counts the skipped samples, too (or the samples played twice only once)! + * Short: When you care about the sample position, don't mess with those parameters;-) + * Also, seeking is not guaranteed to work for all streams (underlying stream may not support it). + * + * @{ + */ + +/** Returns the current position in samples. + * On the next read, you'd get that sample. */ +EXPORT off_t mpg123_tell(mpg123_handle *mh); + +/** Returns the frame number that the next read will give you data from. */ +EXPORT off_t mpg123_tellframe(mpg123_handle *mh); + +/** Returns the current byte offset in the input stream. */ +EXPORT off_t mpg123_tell_stream(mpg123_handle *mh); + +/** Seek to a desired sample offset. + * Set whence to SEEK_SET, SEEK_CUR or SEEK_END. + * \return The resulting offset >= 0 or error/message code */ +EXPORT off_t mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence); + +/** Seek to a desired sample offset in data feeding mode. + * This just prepares things to be right only if you ensure that the next chunk of input data will be from input_offset byte position. + * \param input_offset The position it expects to be at the + * next time data is fed to mpg123_decode(). + * \return The resulting offset >= 0 or error/message code */ +EXPORT off_t mpg123_feedseek(mpg123_handle *mh, off_t sampleoff, int whence, off_t *input_offset); + +/** Seek to a desired MPEG frame index. + * Set whence to SEEK_SET, SEEK_CUR or SEEK_END. + * \return The resulting offset >= 0 or error/message code */ +EXPORT off_t mpg123_seek_frame(mpg123_handle *mh, off_t frameoff, int whence); + +/** Return a MPEG frame offset corresponding to an offset in seconds. + * This assumes that the samples per frame do not change in the file/stream, which is a good assumption for any sane file/stream only. + * \return frame offset >= 0 or error/message code */ +EXPORT off_t mpg123_timeframe(mpg123_handle *mh, double sec); + +/** Give access to the frame index table that is managed for seeking. + * You are asked not to modify the values... Use mpg123_set_index to set the + * seek index + * \param offsets pointer to the index array + * \param step one index byte offset advances this many MPEG frames + * \param fill number of recorded index offsets; size of the array */ +EXPORT int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill); + +/** Set the frame index table + * Setting offsets to NULL and fill > 0 will allocate fill entries. Setting offsets + * to NULL and fill to 0 will clear the index and free the allocated memory used by the index. + * \param offsets pointer to the index array + * \param step one index byte offset advances this many MPEG frames + * \param fill number of recorded index offsets; size of the array */ +EXPORT int mpg123_set_index(mpg123_handle *mh, off_t *offsets, off_t step, size_t fill); + +/** Get information about current and remaining frames/seconds. + * WARNING: This function is there because of special usage by standalone mpg123 and may be removed in the final version of libmpg123! + * You provide an offset (in frames) from now and a number of output bytes + * served by libmpg123 but not yet played. You get the projected current frame + * and seconds, as well as the remaining frames/seconds. This does _not_ care + * about skipped samples due to gapless playback. */ +EXPORT int mpg123_position( mpg123_handle *mh, off_t frame_offset, off_t buffered_bytes, off_t *current_frame, off_t *frames_left, double *current_seconds, double *seconds_left); + +/*@}*/ + + +/** \defgroup mpg123_voleq mpg123 volume and equalizer + * + * @{ + */ + +enum mpg123_channels +{ + MPG123_LEFT=0x1 /**< The Left Channel. */ + ,MPG123_RIGHT=0x2 /**< The Right Channel. */ + ,MPG123_LR=0x3 /**< Both left and right channel; same as MPG123_LEFT|MPG123_RIGHT */ +}; + +/** Set the 32 Band Audio Equalizer settings. + * \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for both. + * \param band The equaliser band to change (from 0 to 31) + * \param val The (linear) adjustment factor. */ +EXPORT int mpg123_eq(mpg123_handle *mh, enum mpg123_channels channel, int band, double val); + +/** Get the 32 Band Audio Equalizer settings. + * \param channel Can be MPG123_LEFT, MPG123_RIGHT or MPG123_LEFT|MPG123_RIGHT for (arithmetic mean of) both. + * \param band The equaliser band to change (from 0 to 31) + * \return The (linear) adjustment factor. */ +EXPORT double mpg123_geteq(mpg123_handle *mh, enum mpg123_channels channel, int band); + +/** Reset the 32 Band Audio Equalizer settings to flat */ +EXPORT int mpg123_reset_eq(mpg123_handle *mh); + +/** Set the absolute output volume including the RVA setting, + * vol<0 just applies (a possibly changed) RVA setting. */ +EXPORT int mpg123_volume(mpg123_handle *mh, double vol); + +/** Adjust output volume including the RVA setting by chosen amount */ +EXPORT int mpg123_volume_change(mpg123_handle *mh, double change); + +/** Return current volume setting, the actual value due to RVA, and the RVA + * adjustment itself. It's all as double float value to abstract the sample + * format. The volume values are linear factors / amplitudes (not percent) + * and the RVA value is in decibels. */ +EXPORT int mpg123_getvolume(mpg123_handle *mh, double *base, double *really, double *rva_db); + +/* TODO: Set some preamp in addition / to replace internal RVA handling? */ + +/*@}*/ + + +/** \defgroup mpg123_status mpg123 status and information + * + * @{ + */ + +/** Enumeration of the mode types of Variable Bitrate */ +enum mpg123_vbr { + MPG123_CBR=0, /**< Constant Bitrate Mode (default) */ + MPG123_VBR, /**< Variable Bitrate Mode */ + MPG123_ABR /**< Average Bitrate Mode */ +}; + +/** Enumeration of the MPEG Versions */ +enum mpg123_version { + MPG123_1_0=0, /**< MPEG Version 1.0 */ + MPG123_2_0, /**< MPEG Version 2.0 */ + MPG123_2_5 /**< MPEG Version 2.5 */ +}; + + +/** Enumeration of the MPEG Audio mode. + * Only the mono mode has 1 channel, the others have 2 channels. */ +enum mpg123_mode { + MPG123_M_STEREO=0, /**< Standard Stereo. */ + MPG123_M_JOINT, /**< Joint Stereo. */ + MPG123_M_DUAL, /**< Dual Channel. */ + MPG123_M_MONO /**< Single Channel. */ +}; + + +/** Enumeration of the MPEG Audio flag bits */ +enum mpg123_flags { + MPG123_CRC=0x1, /**< The bitstream is error protected using 16-bit CRC. */ + MPG123_COPYRIGHT=0x2, /**< The bitstream is copyrighted. */ + MPG123_PRIVATE=0x4, /**< The private bit has been set. */ + MPG123_ORIGINAL=0x8 /**< The bitstream is an original, not a copy. */ +}; + +/** Data structure for storing information about a frame of MPEG Audio */ +struct mpg123_frameinfo +{ + enum mpg123_version version; /**< The MPEG version (1.0/2.0/2.5). */ + int layer; /**< The MPEG Audio Layer (MP1/MP2/MP3). */ + long rate; /**< The sampling rate in Hz. */ + enum mpg123_mode mode; /**< The audio mode (Mono, Stereo, Joint-stero, Dual Channel). */ + int mode_ext; /**< The mode extension bit flag. */ + int framesize; /**< The size of the frame (in bytes). */ + enum mpg123_flags flags; /**< MPEG Audio flag bits. Just now I realize that it should be declared as int, not enum. It's a bitwise combination of the enum values. */ + int emphasis; /**< The emphasis type. */ + int bitrate; /**< Bitrate of the frame (kbps). */ + int abr_rate; /**< The target average bitrate. */ + enum mpg123_vbr vbr; /**< The VBR mode. */ +}; + +/** Get frame information about the MPEG audio bitstream and store it in a mpg123_frameinfo structure. */ +EXPORT int mpg123_info(mpg123_handle *mh, struct mpg123_frameinfo *mi); + +/** Get the safe output buffer size for all cases (when you want to replace the internal buffer) */ +EXPORT size_t mpg123_safe_buffer(void); + +/** Make a full parsing scan of each frame in the file. ID3 tags are found. An accurate length + * value is stored. Seek index will be filled. A seek back to current position + * is performed. At all, this function refuses work when stream is + * not seekable. + * \return MPG123_OK or MPG123_ERR. + */ +EXPORT int mpg123_scan(mpg123_handle *mh); + +/** Return, if possible, the full (expected) length of current track in samples. + * \return length >= 0 or MPG123_ERR if there is no length guess possible. */ +EXPORT off_t mpg123_length(mpg123_handle *mh); + +/** Override the value for file size in bytes. + * Useful for getting sensible track length values in feed mode or for HTTP streams. + * \return MPG123_OK or MPG123_ERR */ +EXPORT int mpg123_set_filesize(mpg123_handle *mh, off_t size); + +/** Returns the time (seconds) per frame; <0 is error. */ +EXPORT double mpg123_tpf(mpg123_handle *mh); + +/** Get and reset the clip count. */ +EXPORT long mpg123_clip(mpg123_handle *mh); + + +/** The key values for state information from mpg123_getstate(). */ +enum mpg123_state +{ + MPG123_ACCURATE = 1 /**< Query if positons are currently accurate (integer value, 0 if false, 1 if true) */ +}; + +/** Get various current decoder/stream state information. + * \param key the key to identify the information to give. + * \param val the address to return (long) integer values to + * \param fval the address to return floating point values to + * \return MPG123_OK or MPG123_ERR for success + */ +EXPORT int mpg123_getstate(mpg123_handle *mh, enum mpg123_state key, long *val, double *fval); + +/*@}*/ + + +/** \defgroup mpg123_metadata mpg123 metadata handling + * + * Functions to retrieve the metadata from MPEG Audio files and streams. + * Also includes string handling functions. + * + * @{ + */ + +/** Data structure for storing strings in a safer way than a standard C-String. + * Can also hold a number of null-terminated strings. */ +typedef struct +{ + char* p; /**< pointer to the string data */ + size_t size; /**< raw number of bytes allocated */ + size_t fill; /**< number of used bytes (including closing zero byte) */ +} mpg123_string; + +/** Create and allocate memory for a new mpg123_string */ +EXPORT void mpg123_init_string(mpg123_string* sb); + +/** Free-up mempory for an existing mpg123_string */ +EXPORT void mpg123_free_string(mpg123_string* sb); + +/** Change the size of a mpg123_string + * \return 0 on error, 1 on success */ +EXPORT int mpg123_resize_string(mpg123_string* sb, size_t news); + +/** Increase size of a mpg123_string if necessary (it may stay larger). + * Note that the functions for adding and setting in current libmpg123 use this instead of mpg123_resize_string(). + * That way, you can preallocate memory and safely work afterwards with pieces. + * \return 0 on error, 1 on success */ +EXPORT int mpg123_grow_string(mpg123_string* sb, size_t news); + +/** Copy the contents of one mpg123_string string to another. + * \return 0 on error, 1 on success */ +EXPORT int mpg123_copy_string(mpg123_string* from, mpg123_string* to); + +/** Append a C-String to an mpg123_string + * \return 0 on error, 1 on success */ +EXPORT int mpg123_add_string(mpg123_string* sb, const char* stuff); + +/** Append a C-substring to an mpg123 string + * \return 0 on error, 1 on success + * \param from offset to copy from + * \param count number of characters to copy (a null-byte is always appended) */ +EXPORT int mpg123_add_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count); + +/** Set the conents of a mpg123_string to a C-string + * \return 0 on error, 1 on success */ +EXPORT int mpg123_set_string(mpg123_string* sb, const char* stuff); + +/** Set the contents of a mpg123_string to a C-substring + * \return 0 on error, 1 on success + * \param from offset to copy from + * \param count number of characters to copy (a null-byte is always appended) */ +EXPORT int mpg123_set_substring(mpg123_string *sb, const char *stuff, size_t from, size_t count); + +/** Count characters in a mpg123 string (non-null bytes or UTF-8 characters). + * \return character count + * \param sb the string + * \param utf8 a flag to tell if the string is in utf8 encoding + * Even with the fill property, the character count is not obvious as there could be multiple trailing null bytes. +*/ +EXPORT size_t mpg123_strlen(mpg123_string *sb, int utf8); + +/** The mpg123 text encodings. This contains encodings we encounter in ID3 tags or ICY meta info. */ +enum mpg123_text_encoding +{ + mpg123_text_unknown = 0 /**< Unkown encoding... mpg123_id3_encoding can return that on invalid codes. */ + ,mpg123_text_utf8 = 1 /**< UTF-8 */ + ,mpg123_text_latin1 = 2 /**< ISO-8859-1. Note that sometimes latin1 in ID3 is abused for totally different encodings. */ + ,mpg123_text_icy = 3 /**< ICY metadata encoding, usually CP-1252 but we take it as UTF-8 if it qualifies as such. */ + ,mpg123_text_cp1252 = 4 /**< Really CP-1252 without any guessing. */ + ,mpg123_text_utf16 = 5 /**< Some UTF-16 encoding. The last of a set of leading BOMs (byte order mark) rules. + * When there is no BOM, big endian ordering is used. Note that UCS-2 qualifies as UTF-8 when + * you don't mess with the reserved code points. If you want to decode little endian data + * without BOM you need to prepend 0xff 0xfe yourself. */ + ,mpg123_text_utf16bom = 6 /**< Just an alias for UTF-16, ID3v2 has this as distinct code. */ + ,mpg123_text_utf16be = 7 /**< Another alias for UTF16 from ID3v2. Note, that, because of the mess that is reality, + * BOMs are used if encountered. There really is not much distinction between the UTF16 types for mpg123 + * One exception: Since this is seen in ID3v2 tags, leading null bytes are skipped for all other UTF16 + * types (we expect a BOM before real data there), not so for utf16be!*/ + ,mpg123_text_max = 7 /**< Placeholder for the maximum encoding value. */ +}; + +/** The encoding byte values from ID3v2. */ +enum mpg123_id3_enc +{ + mpg123_id3_latin1 = 0 /**< Note: This sometimes can mean anything in practice... */ + ,mpg123_id3_utf16bom = 1 /**< UTF16, UCS-2 ... it's all the same for practical purposes. */ + ,mpg123_id3_utf16be = 2 /**< Big-endian UTF-16, BOM see note for mpg123_text_utf16be. */ + ,mpg123_id3_utf8 = 3 /**< Our lovely overly ASCII-compatible 8 byte encoding for the world. */ + ,mpg123_id3_enc_max = 3 /**< Placeholder to check valid range of encoding byte. */ +}; + +/** Convert ID3 encoding byte to mpg123 encoding index. */ +EXPORT enum mpg123_text_encoding mpg123_enc_from_id3(unsigned char id3_enc_byte); + +/** Store text data in string, after converting to UTF-8 from indicated encoding + * \return 0 on error, 1 on success (on error, mpg123_free_string is called on sb) + * \param sb target string + * \param enc mpg123 text encoding value + * \param source source buffer with plain unsigned bytes (you might need to cast from char *) + * \param source_size number of bytes in the source buffer + * + * A prominent error can be that you provided an unknown encoding value, or this build of libmpg123 lacks support for certain encodings (ID3 or ICY stuff missing). + * Also, you might want to take a bit of care with preparing the data; for example, strip leading zeroes (I have seen that). + */ +EXPORT int mpg123_store_utf8(mpg123_string *sb, enum mpg123_text_encoding enc, const unsigned char *source, size_t source_size); + +/** Sub data structure for ID3v2, for storing various text fields (including comments). + * This is for ID3v2 COMM, TXXX and all the other text fields. + * Only COMM and TXXX have a description, only COMM and USLT have a language. + * You should consult the ID3v2 specification for the use of the various text fields ("frames" in ID3v2 documentation, I use "fields" here to separate from MPEG frames). */ +typedef struct +{ + char lang[3]; /**< Three-letter language code (not terminated). */ + char id[4]; /**< The ID3v2 text field id, like TALB, TPE2, ... (4 characters, no string termination). */ + mpg123_string description; /**< Empty for the generic comment... */ + mpg123_string text; /**< ... */ +} mpg123_text; + +/** Data structure for storing IDV3v2 tags. + * This structure is not a direct binary mapping with the file contents. + * The ID3v2 text frames are allowed to contain multiple strings. + * So check for null bytes until you reach the mpg123_string fill. + * All text is encoded in UTF-8. */ +typedef struct +{ + unsigned char version; /**< 3 or 4 for ID3v2.3 or ID3v2.4. */ + mpg123_string *title; /**< Title string (pointer into text_list). */ + mpg123_string *artist; /**< Artist string (pointer into text_list). */ + mpg123_string *album; /**< Album string (pointer into text_list). */ + mpg123_string *year; /**< The year as a string (pointer into text_list). */ + mpg123_string *genre; /**< Genre String (pointer into text_list). The genre string(s) may very well need postprocessing, esp. for ID3v2.3. */ + mpg123_string *comment; /**< Pointer to last encountered comment text with empty description. */ + /* Encountered ID3v2 fields are appended to these lists. + There can be multiple occurences, the pointers above always point to the last encountered data. */ + mpg123_text *comment_list; /**< Array of comments. */ + size_t comments; /**< Number of comments. */ + mpg123_text *text; /**< Array of ID3v2 text fields (including USLT) */ + size_t texts; /**< Numer of text fields. */ + mpg123_text *extra; /**< The array of extra (TXXX) fields. */ + size_t extras; /**< Number of extra text (TXXX) fields. */ +} mpg123_id3v2; + +/** Data structure for ID3v1 tags (the last 128 bytes of a file). + * Don't take anything for granted (like string termination)! + * Also note the change ID3v1.1 did: comment[28] = 0; comment[19] = track_number + * It is your task to support ID3v1 only or ID3v1.1 ...*/ +typedef struct +{ + char tag[3]; /**< Always the string "TAG", the classic intro. */ + char title[30]; /**< Title string. */ + char artist[30]; /**< Artist string. */ + char album[30]; /**< Album string. */ + char year[4]; /**< Year string. */ + char comment[30]; /**< Comment string. */ + unsigned char genre; /**< Genre index. */ +} mpg123_id3v1; + +#define MPG123_ID3 0x3 /**< 0011 There is some ID3 info. Also matches 0010 or NEW_ID3. */ +#define MPG123_NEW_ID3 0x1 /**< 0001 There is ID3 info that changed since last call to mpg123_id3. */ +#define MPG123_ICY 0xc /**< 1100 There is some ICY info. Also matches 0100 or NEW_ICY.*/ +#define MPG123_NEW_ICY 0x4 /**< 0100 There is ICY info that changed since last call to mpg123_icy. */ + +/** Query if there is (new) meta info, be it ID3 or ICY (or something new in future). + The check function returns a combination of flags. */ +EXPORT int mpg123_meta_check(mpg123_handle *mh); /* On error (no valid handle) just 0 is returned. */ + +/** Point v1 and v2 to existing data structures wich may change on any next read/decode function call. + * v1 and/or v2 can be set to NULL when there is no corresponding data. + * \return Return value is MPG123_OK or MPG123_ERR, */ +EXPORT int mpg123_id3(mpg123_handle *mh, mpg123_id3v1 **v1, mpg123_id3v2 **v2); + +/** Point icy_meta to existing data structure wich may change on any next read/decode function call. + * \return Return value is MPG123_OK or MPG123_ERR, */ +EXPORT int mpg123_icy(mpg123_handle *mh, char **icy_meta); /* same for ICY meta string */ + +/** Decode from windows-1252 (the encoding ICY metainfo used) to UTF-8. + * Note that this is very similar to mpg123_store_utf8(&sb, mpg123_text_icy, icy_text, strlen(icy_text+1)) . + * \param icy_text The input data in ICY encoding + * \return pointer to newly allocated buffer with UTF-8 data (You free() it!) */ +EXPORT char* mpg123_icy2utf8(const char* icy_text); + + +/* @} */ + + +/** \defgroup mpg123_advpar mpg123 advanced parameter API + * + * Direct access to a parameter set without full handle around it. + * Possible uses: + * - Influence behaviour of library _during_ initialization of handle (MPG123_VERBOSE). + * - Use one set of parameters for multiple handles. + * + * The functions for handling mpg123_pars (mpg123_par() and mpg123_fmt() + * family) directly return a fully qualified mpg123 error code, the ones + * operating on full handles normally MPG123_OK or MPG123_ERR, storing the + * specific error code itseld inside the handle. + * + * @{ + */ + +/** Opaque structure for the libmpg123 decoder parameters. */ +struct mpg123_pars_struct; + +/** Opaque structure for the libmpg123 decoder parameters. */ +typedef struct mpg123_pars_struct mpg123_pars; + +/** Create a handle with preset parameters. */ +EXPORT mpg123_handle *mpg123_parnew(mpg123_pars *mp, const char* decoder, int *error); + +/** Allocate memory for and return a pointer to a new mpg123_pars */ +EXPORT mpg123_pars *mpg123_new_pars(int *error); + +/** Delete and free up memory used by a mpg123_pars data structure */ +EXPORT void mpg123_delete_pars(mpg123_pars* mp); + +/** Configure mpg123 parameters to accept no output format at all, + * use before specifying supported formats with mpg123_format */ +EXPORT int mpg123_fmt_none(mpg123_pars *mp); + +/** Configure mpg123 parameters to accept all formats + * (also any custom rate you may set) -- this is default. */ +EXPORT int mpg123_fmt_all(mpg123_pars *mp); + +/** Set the audio format support of a mpg123_pars in detail: + \param rate The sample rate value (in Hertz). + \param channels A combination of MPG123_STEREO and MPG123_MONO. + \param encodings A combination of accepted encodings for rate and channels, p.ex MPG123_ENC_SIGNED16|MPG123_ENC_ULAW_8 (or 0 for no support). + \return 0 on success, -1 if there was an error. / +*/ +EXPORT int mpg123_fmt(mpg123_pars *mh, long rate, int channels, int encodings); /* 0 is good, -1 is error */ + +/** Check to see if a specific format at a specific rate is supported + * by mpg123_pars. + * \return 0 for no support (that includes invalid parameters), MPG123_STEREO, + * MPG123_MONO or MPG123_STEREO|MPG123_MONO. */ +EXPORT int mpg123_fmt_support(mpg123_pars *mh, long rate, int encoding); + +/** Set a specific parameter, for a specific mpg123_pars, using a parameter + * type key chosen from the mpg123_parms enumeration, to the specified value. */ +EXPORT int mpg123_par(mpg123_pars *mp, enum mpg123_parms type, long value, double fvalue); + +/** Get a specific parameter, for a specific mpg123_pars. + * See the mpg123_parms enumeration for a list of available parameters. */ +EXPORT int mpg123_getpar(mpg123_pars *mp, enum mpg123_parms type, long *val, double *fval); + +/* @} */ + + +/** \defgroup mpg123_lowio mpg123 low level I/O + * You may want to do tricky stuff with I/O that does not work with mpg123's default file access or you want to make it decode into your own pocket... + * + * @{ */ + +/** Replace default internal buffer with user-supplied buffer. + * Instead of working on it's own private buffer, mpg123 will directly use the one you provide for storing decoded audio. */ +EXPORT int mpg123_replace_buffer(mpg123_handle *mh, unsigned char *data, size_t size); + +/** The max size of one frame's decoded output with current settings. + * Use that to determine an appropriate minimum buffer size for decoding one frame. */ +EXPORT size_t mpg123_outblock(mpg123_handle *mh); + +/** Replace low-level stream access functions; read and lseek as known in POSIX. + * You can use this to make any fancy file opening/closing yourself, + * using mpg123_open_fd() to set the file descriptor for your read/lseek (doesn't need to be a "real" file descriptor...). + * Setting a function to NULL means that the default internal read is + * used (active from next mpg123_open call on). + * Note: As it would be troublesome to mess with this while having a file open, + * this implies mpg123_close(). */ +EXPORT int mpg123_replace_reader(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), off_t (*r_lseek)(int, off_t, int)); + +/** Replace I/O functions with your own ones operating on some kind of handle instead of integer descriptors. + * The handle is a void pointer, so you can pass any data you want... + * mpg123_open_handle() is the call you make to use the I/O defined here. + * There is no fallback to internal read/seek here. + * Note: As it would be troublesome to mess with this while having a file open, + * this mpg123_close() is implied here. + * \param r_read The callback for reading (behaviour like posix read). + * \param r_lseek The callback for seeking (like posix lseek). + * \param cleanup A callback to clean up an I/O handle on mpg123_close, can be NULL for none (you take care of cleaning your handles). */ +EXPORT int mpg123_replace_reader_handle(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*)); + +/* @} */ + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mpg123/include/mpg123_pre.h b/mpg123/include/mpg123_pre.h new file mode 100644 index 00000000..9c668075 --- /dev/null +++ b/mpg123/include/mpg123_pre.h @@ -0,0 +1,40 @@ +/* + mpg123_msvc: MPEG Audio Decoder library wrapper header for MS VC++ 2005 + + copyright 2008 by the mpg123 project - free software under the terms of the LGPL 2.1 + initially written by Patrick Dehne and Thomas Orgis. +*/ +#ifndef MPG123_MSVC_H +#define MPG123_MSVC_H + +#include +#include +#include + +typedef long ssize_t; +typedef __int32 int32_t; +typedef unsigned __int32 uint32_t; + +#define PRIiMAX "I64i" +typedef __int64 intmax_t; +// ftell returns long, _ftelli64 returns __int64 +// off_t is long, not __int64, use ftell +#define ftello ftell + +#define MPG123_NO_CONFIGURE +#include "mpg123.h" /* Yes, .h.in; we include the configure template! */ + +#ifdef __cplusplus +extern "C" { +#endif + + // Wrapper around mpg123_open that supports path names with unicode + // characters + EXPORT int mpg123_topen(mpg123_handle *fr, const _TCHAR *path); + EXPORT int mpg123_tclose(mpg123_handle *fr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mpg123/lib/libmpg123.lib b/mpg123/lib/libmpg123.lib new file mode 100644 index 00000000..e3555655 Binary files /dev/null and b/mpg123/lib/libmpg123.lib differ diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp index d8b50161..7742a06a 100644 --- a/src/audio/oal/channel.cpp +++ b/src/audio/oal/channel.cpp @@ -1,20 +1,21 @@ #include "channel.h" #ifdef AUDIO_OAL +#include "common.h" #include "sampman.h" extern bool IsFXSupported(); CChannel::CChannel() { - alChannel = AL_NONE; + alSource = AL_NONE; alFilter = AL_FILTER_NULL; SetDefault(); } void CChannel::SetDefault() { - Buffer = AL_NONE; + alBuffer = AL_NONE; Pitch = 1.0f; Gain = 1.0f; @@ -37,17 +38,17 @@ void CChannel::Reset() void CChannel::Init(bool Is2D) { ASSERT(!HasSource()); - alGenSources(1, &alChannel); + alGenSources(1, &alSource); if ( HasSource() ) { - alSourcei(alChannel, AL_SOURCE_RELATIVE, AL_TRUE); + alSourcei(alSource, AL_SOURCE_RELATIVE, AL_TRUE); if ( IsFXSupported() ) - alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); if ( Is2D ) { - alSource3f(alChannel, AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef (alChannel, AL_GAIN, 1.0f); + alSource3f(alSource, AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef (alSource, AL_GAIN, 1.0f); } else { @@ -64,15 +65,15 @@ void CChannel::Term() { if ( IsFXSupported() ) { - alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); if(alFilter != AL_FILTER_NULL) alDeleteFilters(1,&alFilter); } - alDeleteSources(1, &alChannel); + alDeleteSources(1, &alSource); } - alChannel = AL_NONE; + alSource = AL_NONE; alFilter = AL_FILTER_NULL; } @@ -81,22 +82,22 @@ void CChannel::Start() if ( !HasSource() ) return; if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 ) - alBufferiv(Buffer, AL_LOOP_POINTS_SOFT, LoopPoints); - alSourcei (alChannel, AL_BUFFER, Buffer); - alSourcePlay(alChannel); + alBufferiv(alBuffer, AL_LOOP_POINTS_SOFT, LoopPoints); + alSourcei (alSource, AL_BUFFER, alBuffer); + alSourcePlay(alSource); } void CChannel::Stop() { if ( HasSource() ) - alSourceStop(alChannel); + alSourceStop(alSource); Reset(); } bool CChannel::HasSource() { - return alChannel != AL_NONE; + return alSource != AL_NONE; } bool CChannel::IsUsed() @@ -104,7 +105,7 @@ bool CChannel::IsUsed() if ( HasSource() ) { ALint sourceState; - alGetSourcei(alChannel, AL_SOURCE_STATE, &sourceState); + alGetSourcei(alSource, AL_SOURCE_STATE, &sourceState); return sourceState == AL_PLAYING; } return false; @@ -113,13 +114,13 @@ bool CChannel::IsUsed() void CChannel::SetPitch(float pitch) { if ( !HasSource() ) return; - alSourcef(alChannel, AL_PITCH, pitch); + alSourcef(alSource, AL_PITCH, pitch); } void CChannel::SetGain(float gain) { if ( !HasSource() ) return; - alSourcef(alChannel, AL_GAIN, gain); + alSourcef(alSource, AL_GAIN, gain); } void CChannel::SetVolume(int32 vol) @@ -145,7 +146,7 @@ void CChannel::SetCurrentFreq(uint32 freq) void CChannel::SetLoopCount(int32 loopCount) // fake. TODO: { if ( !HasSource() ) return; - alSourcei(alChannel, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); + alSourcei(alSource, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE); } void CChannel::SetLoopPoints(ALint start, ALint end) @@ -157,33 +158,33 @@ void CChannel::SetLoopPoints(ALint start, ALint end) void CChannel::SetPosition(float x, float y, float z) { if ( !HasSource() ) return; - alSource3f(alChannel, AL_POSITION, x, y, z); + alSource3f(alSource, AL_POSITION, x, y, z); } void CChannel::SetDistances(float max, float min) { if ( !HasSource() ) return; - alSourcef (alChannel, AL_MAX_DISTANCE, max); - alSourcef (alChannel, AL_REFERENCE_DISTANCE, min); - alSourcef (alChannel, AL_MAX_GAIN, 1.0f); - alSourcef (alChannel, AL_ROLLOFF_FACTOR, 1.0f); + alSourcef (alSource, AL_MAX_DISTANCE, max); + alSourcef (alSource, AL_REFERENCE_DISTANCE, min); + alSourcef (alSource, AL_MAX_GAIN, 1.0f); + alSourcef (alSource, AL_ROLLOFF_FACTOR, 1.0f); } void CChannel::SetPan(uint32 pan) { - SetPosition((pan-63)/64.0f, 0.0f, sqrtf(1.0f-SQR((pan-63)/64.0f))); + SetPosition((pan-63)/64.0f, 0.0f, Sqrt(1.0f-SQR((pan-63)/64.0f))); } void CChannel::SetBuffer(ALuint buffer) { - Buffer = buffer; + alBuffer = buffer; } void CChannel::ClearBuffer() { if ( !HasSource() ) return; SetBuffer(AL_NONE); - alSourcei(alChannel, AL_BUFFER, AL_NONE); + alSourcei(alSource, AL_BUFFER, AL_NONE); } void CChannel::SetReverbMix(ALuint slot, float mix) @@ -194,7 +195,7 @@ void CChannel::SetReverbMix(ALuint slot, float mix) Mix = mix; EAX3_SetReverbMix(alFilter, mix); - alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); + alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); } void CChannel::UpdateReverb(ALuint slot) @@ -203,7 +204,7 @@ void CChannel::UpdateReverb(ALuint slot) if ( !HasSource() ) return; if ( alFilter == AL_FILTER_NULL ) return; EAX3_SetReverbMix(alFilter, Mix); - alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); + alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter); } #endif \ No newline at end of file diff --git a/src/audio/oal/channel.h b/src/audio/oal/channel.h index d9ffea22..4dd09ca1 100644 --- a/src/audio/oal/channel.h +++ b/src/audio/oal/channel.h @@ -10,9 +10,9 @@ class CChannel { - ALuint alChannel; + ALuint alSource; ALuint alFilter; - ALuint Buffer; + ALuint alBuffer; float Pitch, Gain; float Mix; int32 Frequency; diff --git a/src/audio/oal/stream.cpp b/src/audio/oal/stream.cpp index a65c9794..9bca0546 100644 --- a/src/audio/oal/stream.cpp +++ b/src/audio/oal/stream.cpp @@ -1,48 +1,223 @@ #include "stream.h" -#include "common.h" #ifdef AUDIO_OAL +#include "common.h" +#include "sampman.h" + +typedef long ssize_t; + +#include +#include + +#pragma comment( lib, "libsndfile-1.lib" ) +#pragma comment( lib, "libmpg123.lib" ) + +class CSndFile : public IDecoder +{ + SNDFILE *m_pfSound; + SF_INFO m_soundInfo; +public: + CSndFile(const char *path) : + m_pfSound(nil) + { + memset(&m_soundInfo, 0, sizeof(m_soundInfo)); + m_pfSound = sf_open(path, SFM_READ, &m_soundInfo); + } + + ~CSndFile() + { + if ( m_pfSound ) + { + sf_close(m_pfSound); + m_pfSound = nil; + } + } + + bool IsOpened() + { + return m_pfSound != nil; + } + + uint32 GetSampleSize() + { + return sizeof(uint16); + } + + uint32 GetSampleCount() + { + return m_soundInfo.frames; + } + + uint32 GetSampleRate() + { + return m_soundInfo.samplerate; + } + + uint32 GetChannels() + { + return m_soundInfo.channels; + } + + void Seek(uint32 milliseconds) + { + if ( !IsOpened() ) return; + sf_seek(m_pfSound, ms2samples(milliseconds), SF_SEEK_SET); + } + + uint32 Tell() + { + if ( !IsOpened() ) return 0; + return samples2ms(sf_seek(m_pfSound, 0, SF_SEEK_CUR)); + } + + uint32 Decode(void *buffer) + { + if ( !IsOpened() ) return 0; + return sf_read_short(m_pfSound, (short *)buffer, GetBufferSamples()) * GetSampleSize(); + } +}; + +class CMP3File : public IDecoder +{ + mpg123_handle *m_pMH; + bool m_bOpened; + uint32 m_nRate; + uint32 m_nChannels; +public: + CMP3File(const char *path) : + m_pMH(nil), + m_bOpened(false), + m_nRate(0), + m_nChannels(0) + { + m_pMH = mpg123_new(nil, nil); + if ( m_pMH ) + { + long rate = 0; + int channels = 0; + int encoding = 0; + + m_bOpened = mpg123_open(m_pMH, path) == MPG123_OK + && mpg123_getformat(m_pMH, &rate, &channels, &encoding) == MPG123_OK; + m_nRate = rate; + m_nChannels = channels; + + if ( IsOpened() ) + { + mpg123_format_none(m_pMH); + mpg123_format(m_pMH, rate, channels, encoding); + } + } + } + + ~CMP3File() + { + if ( m_pMH ) + { + mpg123_close(m_pMH); + mpg123_delete(m_pMH); + m_pMH = nil; + } + } + + bool IsOpened() + { + return m_bOpened; + } + + uint32 GetSampleSize() + { + return sizeof(uint16); + } + + uint32 GetSampleCount() + { + if ( !IsOpened() ) return 0; + return mpg123_length(m_pMH); + } + + uint32 GetSampleRate() + { + return m_nRate; + } + + uint32 GetChannels() + { + return m_nChannels; + } + + void Seek(uint32 milliseconds) + { + if ( !IsOpened() ) return; + mpg123_seek(m_pMH, ms2samples(milliseconds)*GetSampleSize(), SEEK_SET); + } + + uint32 Tell() + { + if ( !IsOpened() ) return 0; + return samples2ms(mpg123_tell(m_pMH)/GetSampleSize()); + } + + uint32 Decode(void *buffer) + { + if ( !IsOpened() ) return 0; + + size_t size; + int err = mpg123_read(m_pMH, (unsigned char *)buffer, GetBufferSize(), &size); + if (err != MPG123_OK && err != MPG123_DONE) return 0; + return size; + } +}; void CStream::Initialise() { - //mpg123_init(); + mpg123_init(); } void CStream::Terminate() { - //mpg123_exit(); + mpg123_exit(); } CStream::CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]) : m_alSource(source), m_alBuffers(buffers), - m_nBitRate(0), - m_nFormat(0), - m_nFreq(0), - m_nLength(0), - m_nLengthMS(0), - m_nBufferSize(0), - m_pBuffer(NULL), - m_bIsOpened(false), - m_bPaused(true) + m_pBuffer(nil), + m_bPaused(false), + m_bActive(false), + m_pSoundFile(nil), + m_bReset(false), + m_nVolume(0), + m_nPan(0), + m_nPosBeforeReset(0) { strcpy(m_aFilename, filename); - //DEV("Stream %s\n", m_aFilename); - - /* - if ( true ) - { - m_nBitRate = (wBitsPerSample * nChannels * wfex.nSamplesPerSec)/1000; - m_nLength = ulDataSize; - m_nLengthMS = m_nLength*8 / m_nBitRate; - m_nBufferSize = nAvgBytesPerSec >> 2; - m_nBufferSize -= (m_nLength % wfex.nBlockAlign); - m_pBuffer = malloc(m_nBufferSize); - m_bIsOpened = true; + DEV("Stream %s\n", m_aFilename); + + if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".mp3")], ".mp3")) + m_pSoundFile = new CMP3File(m_aFilename); + else if (!strcasecmp(&m_aFilename[strlen(m_aFilename) - strlen(".wav")], ".wav")) + m_pSoundFile = new CSndFile(m_aFilename); + else + m_pSoundFile = nil; + ASSERT(m_pSoundFile != nil); + if (m_pSoundFile && m_pSoundFile->IsOpened() ) + { + m_pBuffer = malloc(m_pSoundFile->GetBufferSize()); + ASSERT(m_pBuffer!=nil); + + DEV("AvgSamplesPerSec: %d\n", m_pSoundFile->GetAvgSamplesPerSec()); + DEV("SampleCount: %d\n", m_pSoundFile->GetSampleCount()); + DEV("SampleRate: %d\n", m_pSoundFile->GetSampleRate()); + DEV("Channels: %d\n", m_pSoundFile->GetChannels()); + DEV("Buffer Samples: %d\n", m_pSoundFile->GetBufferSamples()); + DEV("Buffer sec: %f\n", (float(m_pSoundFile->GetBufferSamples()) / float(m_pSoundFile->GetChannels())/ float(m_pSoundFile->GetSampleRate()))); + DEV("Length MS: %02d:%02d\n", (m_pSoundFile->GetLength() / 1000) / 60, (m_pSoundFile->GetLength() / 1000) % 60); + return; - }*/ + } } CStream::~CStream() @@ -51,68 +226,295 @@ CStream::~CStream() } void CStream::Delete() -{ +{ + Stop(); + ClearBuffers(); + + if ( m_pSoundFile ) + { + delete m_pSoundFile; + m_pSoundFile = nil; + } + if ( m_pBuffer ) { free(m_pBuffer); - m_pBuffer = NULL; + m_pBuffer = nil; } } +bool CStream::HasSource() +{ + return m_alSource != AL_NONE; +} + bool CStream::IsOpened() { - return m_bIsOpened; + return m_pSoundFile->IsOpened(); } bool CStream::IsPlaying() { + if ( !HasSource() || !IsOpened() ) return false; + + if ( m_pSoundFile->IsOpened() && !m_bPaused ) + { + ALint sourceState; + alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + if ( m_bActive || sourceState == AL_PLAYING ) + return true; + } + return false; } +void CStream::Pause() +{ + if ( !HasSource() ) return; + ALint sourceState = AL_PAUSED; + alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_PAUSED ) + alSourcePause(m_alSource); +} + void CStream::SetPause(bool bPause) { + if ( !HasSource() ) return; + if ( bPause ) + { + Pause(); + m_bPaused = true; + } + else + { + if (m_bPaused) + SetPlay(true); + m_bPaused = false; + } +} + +void CStream::SetPitch(float pitch) +{ + if ( !HasSource() ) return; + alSourcef(m_alSource, AL_PITCH, pitch); +} + +void CStream::SetGain(float gain) +{ + if ( !HasSource() ) return; + alSourcef(m_alSource, AL_GAIN, gain); +} + +void CStream::SetPosition(float x, float y, float z) +{ + if ( !HasSource() ) return; + alSource3f(m_alSource, AL_POSITION, x, y, z); } void CStream::SetVolume(uint32 nVol) { - + m_nVolume = nVol; + SetGain(ALfloat(nVol) / MAX_VOLUME); } void CStream::SetPan(uint8 nPan) { + m_nPan = nPan; + SetPosition((nPan - 63)/64.0f, 0.0f, Sqrt(1.0f-SQR((nPan-63)/64.0f))); } -void CStream::SetPos(uint32 nPos) +void CStream::SetPosMS(uint32 nPos) { + if ( !m_pSoundFile->IsOpened() ) return; + m_pSoundFile->Seek(nPos); + ClearBuffers(); } -uint32 CStream::GetPos() +uint32 CStream::GetPosMS() { - return 0; + if ( !HasSource() ) return 0; + if ( !m_pSoundFile->IsOpened() ) return 0; + + ALint offset; + //alGetSourcei(m_alSource, AL_SAMPLE_OFFSET, &offset); + alGetSourcei(m_alSource, AL_BYTE_OFFSET, &offset); + + return m_pSoundFile->Tell() + - m_pSoundFile->samples2ms(m_pSoundFile->GetBufferSamples() * (NUM_STREAMBUFFERS-1)) + + m_pSoundFile->samples2ms(offset/m_pSoundFile->GetSampleSize()); } -uint32 CStream::GetLength() +uint32 CStream::GetLengthMS() { - return m_nLengthMS; + if ( !m_pSoundFile->IsOpened() ) return 0; + return m_pSoundFile->GetLength(); } -bool CStream::Setup() +bool CStream::FillBuffer(ALuint alBuffer) { - if ( !IsOpened() ) + if ( !HasSource() ) return false; - + if ( !m_pSoundFile->IsOpened() ) + return false; + if ( !(alBuffer != AL_NONE && alIsBuffer(alBuffer)) ) + return false; + + uint32 size = m_pSoundFile->Decode(m_pBuffer); + if( size == 0 ) + return false; + + alBufferData(alBuffer, m_pSoundFile->GetChannels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, + m_pBuffer, size, m_pSoundFile->GetSampleRate()); + + return true; +} + +int32 CStream::FillBuffers() +{ + int32 i = 0; + for ( i = 0; i < NUM_STREAMBUFFERS; i++ ) + { + if ( !FillBuffer(m_alBuffers[i]) ) + break; + alSourceQueueBuffers(m_alSource, 1, &m_alBuffers[i]); + } + + return i; +} + +void CStream::ClearBuffers() +{ + if ( !HasSource() ) return; + + ALint buffersQueued; + alGetSourcei(m_alSource, AL_BUFFERS_QUEUED, &buffersQueued); + + ALuint value; + while (buffersQueued--) + alSourceUnqueueBuffers(m_alSource, 1, &value); +} + +bool CStream::Setup() +{ + if ( m_pSoundFile->IsOpened() ) + { + m_pSoundFile->Seek(0); + alSourcei(m_alSource, AL_SOURCE_RELATIVE, AL_TRUE); + //SetPosition(0.0f, 0.0f, 0.0f); + SetPitch(1.0f); + //SetPan(m_nPan); + //SetVolume(100); + } + return IsOpened(); } +void CStream::SetPlay(bool state) +{ + if ( !HasSource() ) return; + if ( state ) + { + ALint sourceState = AL_PLAYING; + alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_PLAYING ) + alSourcePlay(m_alSource); + m_bActive = true; + } + else + { + ALint sourceState = AL_STOPPED; + alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + if (sourceState != AL_STOPPED ) + alSourceStop(m_alSource); + m_bActive = false; + } +} + void CStream::Start() { + if ( !HasSource() ) return; + if ( FillBuffers() != 0 ) + SetPlay(true); +} +void CStream::Stop() +{ + if ( !HasSource() ) return; + SetPlay(false); } void CStream::Update() { if ( !IsOpened() ) return; + + if ( !HasSource() ) + return; + + if ( m_bReset ) + return; + + if ( !m_bPaused ) + { + ALint sourceState; + ALint buffersProcessed = 0; + + alGetSourcei(m_alSource, AL_SOURCE_STATE, &sourceState); + alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed); + + ALint looping = AL_FALSE; + alGetSourcei(m_alSource, AL_LOOPING, &looping); + + if ( looping == AL_TRUE ) + { + TRACE("stream set looping"); + alSourcei(m_alSource, AL_LOOPING, AL_TRUE); + } + + while( buffersProcessed-- ) + { + ALuint buffer; + + alSourceUnqueueBuffers(m_alSource, 1, &buffer); + + if ( m_bActive && FillBuffer(buffer) ) + alSourceQueueBuffers(m_alSource, 1, &buffer); + } + + if ( sourceState != AL_PLAYING ) + { + alGetSourcei(m_alSource, AL_BUFFERS_PROCESSED, &buffersProcessed); + SetPlay(buffersProcessed!=0); + } + } } +void CStream::ProviderInit() +{ + if ( m_bReset ) + { + if ( Setup() ) + { + SetPan(m_nPan); + SetVolume(m_nVolume); + SetPosMS(m_nPosBeforeReset); + if (m_bActive) + FillBuffers(); + SetPlay(m_bActive); + if ( m_bPaused ) + Pause(); + } + + m_bReset = false; + } +} + +void CStream::ProviderTerm() +{ + m_bReset = true; + m_nPosBeforeReset = GetPosMS(); + + ClearBuffers(); +} + #endif \ No newline at end of file diff --git a/src/audio/oal/stream.h b/src/audio/oal/stream.h index 666d42e0..f1e5f458 100644 --- a/src/audio/oal/stream.h +++ b/src/audio/oal/stream.h @@ -4,8 +4,56 @@ #ifdef AUDIO_OAL #include -#define NUM_STREAMBUFFERS 5 -#define STREAMBUFFER_SIZE 0x4000 +#define NUM_STREAMBUFFERS 4 + +class IDecoder +{ +public: + virtual ~IDecoder() { } + + virtual bool IsOpened() = 0; + + virtual uint32 GetSampleSize() = 0; + virtual uint32 GetSampleCount() = 0; + virtual uint32 GetSampleRate() = 0; + virtual uint32 GetChannels() = 0; + + uint32 GetAvgSamplesPerSec() + { + return GetChannels() * GetSampleRate(); + } + + uint32 ms2samples(uint32 ms) + { + return float(ms) / 1000.0f * float(GetChannels()) * float(GetSampleRate()); + } + + uint32 samples2ms(uint32 sm) + { + return float(sm) * 1000.0f / float(GetChannels()) / float(GetSampleRate()); + } + + uint32 GetBufferSamples() + { + //return (GetAvgSamplesPerSec() >> 2) - (GetSampleCount() % GetChannels()); + return (GetAvgSamplesPerSec() / 4); // 250ms + } + + uint32 GetBufferSize() + { + return GetBufferSamples() * GetSampleSize(); + } + + virtual void Seek(uint32 milliseconds) = 0; + virtual uint32 Tell() = 0; + + uint32 GetLength() + { + return float(GetSampleCount()) * 1000.0f / float(GetSampleRate()); + } + + virtual uint32 Decode(void *buffer) = 0; +}; class CStream { @@ -13,30 +61,34 @@ class CStream ALuint &m_alSource; ALuint (&m_alBuffers)[NUM_STREAMBUFFERS]; - bool m_bIsOpened; bool m_bPaused; - - uint32 m_nLength; - uint32 m_nLengthMS; - uint32 m_nBitRate; - - unsigned long m_nFormat; - unsigned long m_nFreq; + bool m_bActive; - uint32 m_nBufferSize; void *m_pBuffer; - ALint iTotalBuffersProcessed; + bool m_bReset; + uint32 m_nVolume; + uint8 m_nPan; + uint32 m_nPosBeforeReset; + + IDecoder *m_pSoundFile; + + bool HasSource(); + void SetPosition(float x, float y, float z); + void SetPitch(float pitch); + void SetGain(float gain); + void Pause(); + void SetPlay(bool state); bool FillBuffer(ALuint alBuffer); int32 FillBuffers(); + void ClearBuffers(); public: static void Initialise(); static void Terminate(); CStream(char *filename, ALuint &source, ALuint (&buffers)[NUM_STREAMBUFFERS]); ~CStream(); - void Delete(); bool IsOpened(); @@ -44,14 +96,17 @@ public: void SetPause (bool bPause); void SetVolume(uint32 nVol); void SetPan (uint8 nPan); - void SetPos (uint32 nPos); - - uint32 GetPos(); - uint32 GetLength(); + void SetPosMS (uint32 nPos); + uint32 GetPosMS(); + uint32 GetLengthMS(); bool Setup(); void Start(); + void Stop(); void Update(void); + + void ProviderInit(); + void ProviderTerm(); }; #endif \ No newline at end of file diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 6ae1bf79..ccddaa73 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -29,7 +29,6 @@ //TODO: fix eax3 reverb //TODO: max channals //TODO: loop count -//TODO: mp3/wav stream //TODO: mp3 player #pragma comment( lib, "OpenAL32.lib" ) @@ -179,9 +178,9 @@ add_providers() defaultProvider = pDeviceList->GetDefaultDevice(); if ( defaultProvider > MAXPROVIDERS ) defaultProvider = 0; - - delete pDeviceList; } + + delete pDeviceList; } static void @@ -211,6 +210,10 @@ release_existing() for ( int32 i = 0; i < MAX_STREAMS; i++ ) { + CStream *stream = aStream[i]; + if (stream) + stream->ProviderTerm(); + alDeleteSources(1, &ALStreamSources[i]); alDeleteBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); } @@ -298,6 +301,10 @@ set_new_provider(int index) { alGenSources(1, &ALStreamSources[i]); alGenBuffers(NUM_STREAMBUFFERS, ALStreamBuffers[i]); + + CStream *stream = aStream[i]; + if (stream) + stream->ProviderInit(); } for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) @@ -523,6 +530,18 @@ cSampleManager::Initialise(void) nChannelVolume[i] = 0; } + { + for ( int32 i = 0; i < MAX_STREAMS; i++ ) + { + aStream[i] = NULL; + nStreamVolume[i] = 100; + nStreamPan[i] = 63; + } + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + nStreamLength[i] = 0; + } + { add_providers(); @@ -545,17 +564,6 @@ cSampleManager::Initialise(void) ASSERT(nSampleBankMemoryStartAddress[SAMPLEBANK_PED] != NULL); } - { - for ( int32 i = 0; i < MAX_STREAMS; i++ ) - { - aStream[i] = NULL; - nStreamVolume[i] = 100; - nStreamPan[i] = 63; - } - - for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) - nStreamLength[i] = 3600000; - } { _bSampmanInitialised = true; @@ -571,6 +579,25 @@ cSampleManager::Initialise(void) } } + { + + for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) + { + aStream[0] = new CStream(StreamedNameTable[i], ALStreamSources[0], ALStreamBuffers[0]); + + if ( aStream[0] && aStream[0]->IsOpened() ) + { + uint32 tatalms = aStream[0]->GetLengthMS(); + delete aStream[0]; + aStream[0] = NULL; + + nStreamLength[i] = tatalms; + } + else + USERERROR("Can't open '%s'\n", StreamedNameTable[i]); + } + } + LoadSampleBank(SAMPLEBANK_MAIN); return true; @@ -653,7 +680,7 @@ cSampleManager::UpdateEffectsVolume(void) if ( GetChannelUsedFlag(i) ) { if ( nChannelVolume[i] != 0 ) - aChannel[i].SetVolume(m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); + aChannel[i].SetVolume(m_nEffectsFadeVolume*nChannelVolume[i]*m_nEffectsVolume >> 14); } } } @@ -853,7 +880,7 @@ uint32 cSampleManager::GetSampleLength(uint32 nSample) { ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); - return m_aSamples[nSample].nSize >> 1; + return m_aSamples[nSample].nSize / sizeof(uint16); } bool cSampleManager::UpdateReverb(void) @@ -1018,7 +1045,7 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] >>= 2; + nChannelVolume[nChannel] = vol / 4; } // no idea, does this one looks like a bug or it's SetChannelVolume ? @@ -1060,7 +1087,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) { - nChannelVolume[nChannel] >>= 2; + nChannelVolume[nChannel] = vol / 4; } aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); @@ -1209,11 +1236,11 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream) if ( stream->IsOpened() ) { - nStreamLength[nFile] = stream->GetLength(); + nStreamLength[nFile] = stream->GetLengthMS(); if ( stream->Setup() ) { if ( nPos != 0 ) - stream->SetPos(nPos); + stream->SetPosMS(nPos); stream->Start(); } @@ -1253,7 +1280,7 @@ cSampleManager::GetStreamedFilePosition(uint8 nStream) if ( stream ) { - return stream->GetPos(); + return stream->GetPosMS(); } return 0; @@ -1270,7 +1297,7 @@ cSampleManager::SetStreamedVolumeAndPan(uint8 nVolume, uint8 nPan, uint8 nEffect if ( nPan > MAX_VOLUME ) nPan = MAX_VOLUME; - nStreamVolume[nStream] = m_nMusicFadeVolume * nVolume; + nStreamVolume[nStream] = nVolume; nStreamPan [nStream] = nPan; CStream *stream = aStream[nStream]; diff --git a/src/core/common.h b/src/core/common.h index 18f4715c..66a3ad81 100644 --- a/src/core/common.h +++ b/src/core/common.h @@ -209,6 +209,7 @@ void mysrand(unsigned int seed); void re3_debug(const char *format, ...); void re3_trace(const char *filename, unsigned int lineno, const char *func, const char *format, ...); void re3_assert(const char *expr, const char *filename, unsigned int lineno, const char *func); +void re3_usererror(const char *format, ...); #define DEBUGBREAK() __debugbreak(); @@ -216,6 +217,7 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con #define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__) #define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__) #define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__) +#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__) #define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) ) #define ASSERT assert diff --git a/src/core/re3.cpp b/src/core/re3.cpp index 2a9cbc77..b7eb6480 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -456,6 +456,20 @@ void re3_trace(const char *filename, unsigned int lineno, const char *func, cons OutputDebugStringA(buff); } +void re3_usererror(const char *format, ...) +{ + va_list va; + va_start(va, format); + vsprintf_s(re3_buff, re3_buffsize, format, va); + va_end(va); + + ::MessageBoxA(nil, re3_buff, "RE3 Error!", + MB_OK|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); + + raise(SIGABRT); + _exit(3); +} + #ifdef VALIDATE_SAVE_SIZE int32 _saveBufCount; #endif -- cgit v1.2.3 From 35da74e0b474398f1e3be7f4f61df642f5f4d2a0 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Thu, 7 May 2020 09:35:34 +0300 Subject: rem mpg123_pre header --- mpg123/include/mpg123_pre.h | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 mpg123/include/mpg123_pre.h diff --git a/mpg123/include/mpg123_pre.h b/mpg123/include/mpg123_pre.h deleted file mode 100644 index 9c668075..00000000 --- a/mpg123/include/mpg123_pre.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - mpg123_msvc: MPEG Audio Decoder library wrapper header for MS VC++ 2005 - - copyright 2008 by the mpg123 project - free software under the terms of the LGPL 2.1 - initially written by Patrick Dehne and Thomas Orgis. -*/ -#ifndef MPG123_MSVC_H -#define MPG123_MSVC_H - -#include -#include -#include - -typedef long ssize_t; -typedef __int32 int32_t; -typedef unsigned __int32 uint32_t; - -#define PRIiMAX "I64i" -typedef __int64 intmax_t; -// ftell returns long, _ftelli64 returns __int64 -// off_t is long, not __int64, use ftell -#define ftello ftell - -#define MPG123_NO_CONFIGURE -#include "mpg123.h" /* Yes, .h.in; we include the configure template! */ - -#ifdef __cplusplus -extern "C" { -#endif - - // Wrapper around mpg123_open that supports path names with unicode - // characters - EXPORT int mpg123_topen(mpg123_handle *fr, const _TCHAR *path); - EXPORT int mpg123_tclose(mpg123_handle *fr); - -#ifdef __cplusplus -} -#endif - -#endif -- cgit v1.2.3 From 875c77e8b15c5014ee356c8413273c509daa5bda Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Thu, 7 May 2020 10:13:59 +0300 Subject: oal update --- src/audio/sampman_oal.cpp | 59 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index ccddaa73..bbaeae4c 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -88,6 +88,32 @@ struct { ALuint buffer; ALuint timer; + + bool IsEmpty() { return timer == 0; } + void Set(ALuint buf) { buffer = buf; } + void Wait() { timer = 10000; } + void Init() + { + buffer = 0; + timer = 0; + } + void Term() + { + if ( buffer != 0 && alIsBuffer(buffer) ) + alDeleteBuffers(1, &buffer); + timer = 0; + } + void Update() + { + if ( !(timer > 0) ) return; + timer -= ALuint(CTimer::GetTimeStepInMilliseconds()); + if ( timer > 0 ) return; + if ( buffer != 0 && alIsBuffer(buffer) ) + { + alDeleteBuffers(1, &buffer); + timer = ( alGetError() == AL_NO_ERROR ) ? 0 : 10000; + } + } }ALBuffers[SAMPLEBANK_MAX]; uint32 nNumMP3s; @@ -222,10 +248,7 @@ release_existing() for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) { - if ( ALBuffers[i].buffer != 0 && alIsBuffer(ALBuffers[i].buffer) ) - alDeleteBuffers(1, &ALBuffers[i].buffer); - - ALBuffers[i].timer = 0; + ALBuffers[i].Term(); } if ( ALContext ) @@ -309,8 +332,7 @@ set_new_provider(int index) for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) { - ALBuffers[i].buffer = 0; - ALBuffers[i].timer = 0; + ALBuffers[i].Init(); } alGenBuffers(MAX_PEDSFX, pedBuffers); @@ -640,23 +662,7 @@ cSampleManager::UpdateSoundBuffers(void) { for ( int32 i = 0; i < SAMPLEBANK_MAX; i++ ) { - if ( ALBuffers[i].timer > 0 ) - { - ALBuffers[i].timer -= ALuint(CTimer::GetTimeStepInMilliseconds()); - - if ( ALBuffers[i].timer <= 0 ) - { - if ( ALBuffers[i].buffer != 0 && alIsBuffer(ALBuffers[i].buffer) ) - { - alDeleteBuffers(1, &ALBuffers[i].buffer); - - if ( alGetError() == AL_NO_ERROR ) - ALBuffers[i].timer = 0; - else - ALBuffers[i].timer = 10000; - } - } - } + ALBuffers[i].Update(); } } @@ -981,15 +987,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) int32 addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; - if ( ALBuffers[nSfx].timer == 0 ) + if ( ALBuffers[nSfx].IsEmpty() ) { ALuint buf; - alGenBuffers(1, &buf); alBufferData(buf, AL_FORMAT_MONO16, (void *)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); - ALBuffers[nSfx].buffer = buf; - ALBuffers[nSfx].timer = 10000; + ALBuffers[nSfx].Set(buf); } + ALBuffers[nSfx].Wait(); buffer = ALBuffers[nSfx].buffer; } -- cgit v1.2.3