mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Finished PubUtilLib cmakification
--HG-- rename : MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plOGGCodec.cpp => MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.cpp rename : MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plOGGCodec.h => MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.h rename : MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plWavFile.cpp => MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudioCore/plWavFile.cpp rename : MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudio/plWavFile.h => MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAudioCore/plWavFile.h
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
#TODO: This should probably be an external dependancy
|
||||
include_directories("../../../../SDKs/Win32/HawkVoice/src")
|
||||
|
||||
include_directories(${OPENAL_INCLUDE_DIR})
|
||||
include_directories(${Speex_INCLUDE_DIR})
|
||||
|
||||
set(plAudio_SOURCES
|
||||
plAudioCaps.cpp
|
||||
plAudioSystem.cpp
|
||||
plDSoundBuffer.cpp
|
||||
plEAXEffects.cpp
|
||||
plEAXListenerMod.cpp
|
||||
plSound.cpp
|
||||
plSoundEvent.cpp
|
||||
plVoiceChat.cpp
|
||||
plWAVClipBuffer.cpp
|
||||
plWin32GroupedSound.cpp
|
||||
plWin32Sound.cpp
|
||||
plWin32StaticSound.cpp
|
||||
plWin32StreamingSound.cpp
|
||||
plWinMicLevel.cpp
|
||||
)
|
||||
|
||||
set(plAudio_HEADERS
|
||||
plAudioCaps.h
|
||||
plAudioCreatable.h
|
||||
plAudioSystem.h
|
||||
plDSoundBuffer.h
|
||||
plEAXEffects.h
|
||||
plEAXListenerMod.h
|
||||
plSound.h
|
||||
plSoundEvent.h
|
||||
plVoiceChat.h
|
||||
plWAVClipBuffer.h
|
||||
plWin32GroupedSound.h
|
||||
plWin32Sound.h
|
||||
plWin32StaticSound.h
|
||||
plWin32StreamingSound.h
|
||||
plWinMicLevel.h
|
||||
)
|
||||
|
||||
add_library(plAudio STATIC ${plAudio_SOURCES} ${plAudio_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plAudio_SOURCES})
|
||||
source_group("Header Files" FILES ${plAudio_HEADERS})
|
@ -30,8 +30,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "HeadSpin.h"
|
||||
#include "al.h"
|
||||
#include "alc.h"
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "plEAXEffects.h"
|
||||
|
||||
#include "plAudioCaps.h"
|
||||
@ -41,7 +41,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
#include <DShow.h>
|
||||
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#define MAX_NUM_SOURCES 128
|
||||
#define kLogMe if( fLog != nil ) fLog->AddLineF(
|
||||
|
@ -27,7 +27,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#ifndef plAudioCreatable_inc
|
||||
#define plAudioCreatable_inc
|
||||
|
||||
#include "../pnFactory/plCreator.h"
|
||||
#include "pnFactory/plCreator.h"
|
||||
|
||||
#include "plAudioSystem.h"
|
||||
|
||||
|
@ -24,9 +24,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
#include "al.h"
|
||||
#include "alc.h"
|
||||
#include "efx.h"
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include <efx.h>
|
||||
#include <MMREG.H>
|
||||
#ifdef EAX_SDK_AVAILABLE
|
||||
#include <eax.h>
|
||||
@ -36,7 +36,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsGeometry3.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plProfile.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#include "plSound.h"
|
||||
#include "plAudioCaps.h"
|
||||
@ -46,14 +46,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plEAXListenerMod.h"
|
||||
#include "plVoiceChat.h"
|
||||
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "../plMessage/plRenderMsg.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "../plMessage/plAgeLoadedMsg.h"
|
||||
#include "../pnMessage/plTimeMsg.h"
|
||||
#include "pnMessage/plAudioSysMsg.h"
|
||||
#include "plMessage/plRenderMsg.h"
|
||||
#include "pnMessage/plRefMsg.h"
|
||||
#include "plMessage/plAgeLoadedMsg.h"
|
||||
#include "pnMessage/plTimeMsg.h"
|
||||
|
||||
#include "../pnKeyedObject/plFixedKey.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "pnKeyedObject/plFixedKey.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
|
||||
|
||||
#define SAFE_RELEASE(p) if(p){ p->Release(); p = nil; }
|
||||
|
@ -30,7 +30,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsWindowHndl.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "pnKeyedObject/hsKeyedObject.h"
|
||||
|
||||
#define DEFAULT_AUDIO_DEVICE_NAME "Generic Software"
|
||||
|
||||
|
@ -34,17 +34,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsTypes.h"
|
||||
#include "hsThread.h"
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "al.h"
|
||||
#include <al.h>
|
||||
|
||||
#include "plgDispatch.h"
|
||||
#include "plAudioSystem.h"
|
||||
#include "../plAudioCore/plAudioCore.h"
|
||||
#include "../plAudioCore/plAudioFileReader.h"
|
||||
#include "plAudioCore/plAudioCore.h"
|
||||
#include "plAudioCore/plAudioFileReader.h"
|
||||
#include "plEAXEffects.h"
|
||||
|
||||
#include "plProfile.h"
|
||||
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#include <dsound.h>
|
||||
|
||||
|
@ -36,7 +36,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include <EFX-Util.h>
|
||||
#endif
|
||||
#include "plEAXEffects.h"
|
||||
#include "../plAudioCore/plAudioCore.h"
|
||||
#include "plAudioCore/plAudioCore.h"
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "plEAXListenerMod.h"
|
||||
@ -44,14 +44,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plAudioSystem.h"
|
||||
#include <al.h>
|
||||
|
||||
#include <dmusici.h>
|
||||
#include <dxerr9.h>
|
||||
#ifdef EAX_SDK_AVAILABLE
|
||||
#include <eax.h>
|
||||
#include <eax-util.h>
|
||||
#include <eaxlegacy.h>
|
||||
#endif
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#define kDebugLog if( myLog != nil ) myLog->AddLineF(
|
||||
|
||||
|
@ -34,11 +34,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
#include "hsTypes.h"
|
||||
#include "plEAXListenerMod.h"
|
||||
#include "../plIntersect/plSoftVolume.h"
|
||||
#include "plIntersect/plSoftVolume.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plAudioSystem.h"
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "pnMessage/plAudioSysMsg.h"
|
||||
|
||||
#ifdef EAX_SDK_AVAILABLE
|
||||
#include <eax-util.h>
|
||||
|
@ -33,7 +33,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#define _plEAXListenerMod_h
|
||||
|
||||
|
||||
#include "../pnModifier/plSingleModifier.h"
|
||||
#include "pnModifier/plSingleModifier.h"
|
||||
|
||||
class plMessage;
|
||||
class plSoftVolume;
|
||||
|
@ -1,342 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plOGGCodec - Plasma codec support for the OGG/Vorbis file format. //
|
||||
// //
|
||||
//// Notes ///////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// 2.7.2003 - Created by mcn. If only life were really this simple... //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <vorbis/codec.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plOGGCodec.h"
|
||||
|
||||
#include "hsTimer.h"
|
||||
#include "../pnNetCommon/plNetApp.h"
|
||||
|
||||
plOGGCodec::DecodeFormat plOGGCodec::fDecodeFormat = plOGGCodec::k16bitSigned;
|
||||
UInt8 plOGGCodec::fDecodeFlags = 0;
|
||||
|
||||
//// Constructor/Destructor //////////////////////////////////////////////////
|
||||
|
||||
plOGGCodec::plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
|
||||
{
|
||||
fOggFile = nil;
|
||||
IOpen( path, whichChan );
|
||||
fCurHeaderPos = 0;
|
||||
fHeadBuf = nil;
|
||||
}
|
||||
|
||||
void plOGGCodec::BuildActualWaveHeader()
|
||||
{
|
||||
// Build an actual WAVE header for this ogg
|
||||
int fmtSize = 16;
|
||||
short fmt = 1;
|
||||
int factsize = 4;
|
||||
int factdata = 0;
|
||||
int size = fDataSize+48; // size of data with header except for first four bytes
|
||||
|
||||
fHeadBuf = (UInt8 *) ALLOC(56);
|
||||
memcpy(fHeadBuf, "RIFF", 4);
|
||||
memcpy(fHeadBuf+4, &size, 4);
|
||||
memcpy(fHeadBuf+8, "WAVE", 4);
|
||||
memcpy(fHeadBuf+12, "fmt ", 4);
|
||||
memcpy(fHeadBuf+16, &fmtSize, 4);
|
||||
memcpy(fHeadBuf+20, &fmt, 2); /* format */
|
||||
memcpy(fHeadBuf+22, &fHeader.fNumChannels, 2);
|
||||
memcpy(fHeadBuf+24, &fHeader.fNumSamplesPerSec, 4);
|
||||
memcpy(fHeadBuf+28, &fHeader.fAvgBytesPerSec, 4);
|
||||
memcpy(fHeadBuf+32, &fHeader.fBlockAlign, 4);
|
||||
memcpy(fHeadBuf+34, &fHeader.fBitsPerSample, 2);
|
||||
memcpy(fHeadBuf+36, "fact", 4);
|
||||
memcpy(fHeadBuf+40, &factsize, 4);
|
||||
memcpy(fHeadBuf+44, &factdata, 4);
|
||||
memcpy(fHeadBuf+48, "data", 4);
|
||||
memcpy(fHeadBuf+52, &fDataSize, 4);
|
||||
}
|
||||
|
||||
bool plOGGCodec::ReadFromHeader(int numBytes, void *data)
|
||||
{
|
||||
if(fCurHeaderPos < 56)
|
||||
{
|
||||
memcpy(data, fHeadBuf+fCurHeaderPos, numBytes);
|
||||
fCurHeaderPos += numBytes;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void plOGGCodec::IOpen( const char *path, plAudioCore::ChannelSelect whichChan )
|
||||
{
|
||||
hsAssert( path != nil, "Invalid path specified in plOGGCodec reader" );
|
||||
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Open %s, t=%f, start", path, hsTimer::GetSeconds());
|
||||
|
||||
strncpy( fFilename, path, sizeof( fFilename ) );
|
||||
fWhichChannel = whichChan;
|
||||
|
||||
/// Open the file as a plain binary stream
|
||||
fFileHandle = fopen( path, "rb" );
|
||||
if( fFileHandle != nil )
|
||||
{
|
||||
/// Create the OGG data struct
|
||||
fOggFile = TRACKED_NEW OggVorbis_File;
|
||||
|
||||
/// Open the OGG decompressor
|
||||
if( ov_open( fFileHandle, fOggFile, NULL, 0 ) < 0 )
|
||||
{
|
||||
IError( "Unable to open OGG source file" );
|
||||
return;
|
||||
}
|
||||
|
||||
/// Construct some header info from the ogg info
|
||||
vorbis_info *vInfo = ov_info( fOggFile, -1 );
|
||||
|
||||
fHeader.fFormatTag = 1;
|
||||
fHeader.fNumChannels = vInfo->channels;
|
||||
fHeader.fNumSamplesPerSec = vInfo->rate;
|
||||
|
||||
// Funny thing about the bits per sample: we get to CHOOSE. Go figure!
|
||||
fHeader.fBitsPerSample = ( fDecodeFormat == k8bitUnsigned ) ? 8 : 16;
|
||||
|
||||
// Why WAV files hold this info when it can be calculated is beyond me...
|
||||
fHeader.fBlockAlign = ( fHeader.fBitsPerSample * fHeader.fNumChannels ) >> 3;
|
||||
fHeader.fAvgBytesPerSec = fHeader.fNumSamplesPerSec * fHeader.fBlockAlign;
|
||||
|
||||
|
||||
/// The size in bytes of our PCM data stream
|
||||
/// Note: OGG sometimes seems to be off by 1 sample, which causes our reads to suck
|
||||
/// because we end up waiting for 1 more sample than we actually have. So, on the
|
||||
/// assumption that OGG is just slightly wrong sometimes, we just subtract 1 sample
|
||||
/// from what it tells us. As Brice put it, who's going to miss 1/40,000'ths of a second?
|
||||
fDataSize = (UInt32)(( ov_pcm_total( fOggFile, -1 ) - 1 ) * fHeader.fBlockAlign);
|
||||
|
||||
/// Channel select
|
||||
if( fWhichChannel != plAudioCore::kAll )
|
||||
{
|
||||
fChannelAdjust = 2;
|
||||
fChannelOffset = ( fWhichChannel == plAudioCore::kLeft ) ? 0 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fChannelAdjust = 1;
|
||||
fChannelOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
/// Construct our fake header for channel adjustment
|
||||
fFakeHeader = fHeader;
|
||||
fFakeHeader.fAvgBytesPerSec /= fChannelAdjust;
|
||||
fFakeHeader.fNumChannels /= (UInt16)fChannelAdjust;
|
||||
fFakeHeader.fBlockAlign /= (UInt16)fChannelAdjust;
|
||||
|
||||
SetPosition( 0 );
|
||||
}
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Open %s, t=%f, end", path, hsTimer::GetSeconds());
|
||||
}
|
||||
|
||||
plOGGCodec::~plOGGCodec()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
void plOGGCodec::Close( void )
|
||||
{
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Close, t=%f, start", hsTimer::GetSeconds());
|
||||
FREE(fHeadBuf);
|
||||
fHeadBuf = nil;
|
||||
if( fOggFile != nil )
|
||||
{
|
||||
ov_clear( fOggFile );
|
||||
DEL(fOggFile);
|
||||
fOggFile = nil;
|
||||
}
|
||||
|
||||
if( fFileHandle != nil )
|
||||
{
|
||||
fclose( fFileHandle );
|
||||
fFileHandle = nil;
|
||||
}
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Close, t=%f, end", hsTimer::GetSeconds());
|
||||
}
|
||||
|
||||
void plOGGCodec::IError( const char *msg )
|
||||
{
|
||||
hsAssert( false, msg );
|
||||
Close();
|
||||
}
|
||||
|
||||
plWAVHeader &plOGGCodec::GetHeader( void )
|
||||
{
|
||||
hsAssert( IsValid(), "GetHeader() called on an invalid OGG file" );
|
||||
|
||||
return fFakeHeader;
|
||||
}
|
||||
|
||||
float plOGGCodec::GetLengthInSecs( void )
|
||||
{
|
||||
hsAssert( IsValid(), "GetLengthInSecs() called on an invalid OGG file" );
|
||||
|
||||
// Just query ogg directly...starting to see how cool ogg is yet?
|
||||
return (float)ov_time_total( fOggFile, -1 );
|
||||
}
|
||||
|
||||
hsBool plOGGCodec::SetPosition( UInt32 numBytes )
|
||||
{
|
||||
hsAssert( IsValid(), "GetHeader() called on an invalid OGG file" );
|
||||
|
||||
|
||||
if( !ov_seekable( fOggFile ) )
|
||||
{
|
||||
hsAssert( false, "Trying to set position on an unseekable OGG stream!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// The numBytes position is in uncompressed space and should be sample-aligned anyway,
|
||||
// so this should be just fine here.
|
||||
ogg_int64_t newSample = ( numBytes / (fFakeHeader.fBlockAlign * fChannelAdjust) );
|
||||
|
||||
// Now please note how freaking easy it is here to do accurate or fast seeking...
|
||||
// Also note that if we're doing our channel extraction, we MUST do it the accurate way
|
||||
if( ( fDecodeFlags & kFastSeeking ) && fChannelAdjust == 1 )
|
||||
{
|
||||
if( ov_pcm_seek_page( fOggFile, newSample ) != 0 )
|
||||
{
|
||||
IError( "Unable to seek OGG stream" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ov_pcm_seek( fOggFile, newSample ) != 0 )
|
||||
{
|
||||
IError( "Unable to seek OGG stream" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool plOGGCodec::Read( UInt32 numBytes, void *buffer )
|
||||
{
|
||||
hsAssert( IsValid(), "GetHeader() called on an invalid OGG file" );
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Read, t=%f, start", hsTimer::GetSeconds());
|
||||
|
||||
int bytesPerSample = ( fDecodeFormat == k16bitSigned ) ? 2 : 1;
|
||||
int isSigned = ( fDecodeFormat == k16bitSigned ) ? 1 : 0;
|
||||
int currSection;
|
||||
|
||||
if( fWhichChannel == plAudioCore::kAll )
|
||||
{
|
||||
// Easy, just a straight read
|
||||
char *uBuffer = (char *)buffer;
|
||||
|
||||
while( numBytes > 0 )
|
||||
{
|
||||
// Supposedly we should pay attention to currSection in case of bitrate changes,
|
||||
// but hopefully we'll never have those....
|
||||
|
||||
long bytesRead = ov_read( fOggFile, uBuffer, numBytes, 0, bytesPerSample, isSigned, &currSection );
|
||||
|
||||
// Since our job is so simple, do some extra error checking
|
||||
if( bytesRead == OV_HOLE )
|
||||
{
|
||||
IError( "Unable to read from OGG file: missing data" );
|
||||
return false;
|
||||
}
|
||||
else if( bytesRead == OV_EBADLINK )
|
||||
{
|
||||
IError( "Unable to read from OGG file: corrupt link" );
|
||||
return false;
|
||||
}
|
||||
else if( bytesRead == 0 )
|
||||
{
|
||||
IError( "Unable to finish reading from OGG file: end of stream" );
|
||||
return false;
|
||||
}
|
||||
else if( bytesRead < 0 )
|
||||
{
|
||||
IError( "Unable to read from OGG file: unknown error" );
|
||||
return false;
|
||||
}
|
||||
|
||||
numBytes -= bytesRead;
|
||||
uBuffer += bytesRead;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Read in 4k chunks and extract
|
||||
static char trashBuffer[ 4096 ];
|
||||
|
||||
long toRead, i, thisRead, sampleSize = fFakeHeader.fBlockAlign;
|
||||
|
||||
for( ; numBytes > 0; )
|
||||
{
|
||||
/// Read 4k worth of samples
|
||||
toRead = ( sizeof( trashBuffer ) < numBytes * fChannelAdjust ) ? sizeof( trashBuffer ) : numBytes * fChannelAdjust;
|
||||
|
||||
|
||||
thisRead = ov_read( fOggFile, (char *)trashBuffer, toRead, 0, bytesPerSample, isSigned, &currSection );
|
||||
if( thisRead < 0 )
|
||||
return false;
|
||||
|
||||
/// Copy every other sample out
|
||||
int sampleOffset = (fChannelOffset == 1) ? sampleSize : 0;
|
||||
for (i = 0; i < thisRead; i += sampleSize * 2)
|
||||
{
|
||||
memcpy(buffer, &trashBuffer[i + sampleOffset], sampleSize);
|
||||
buffer = (void*)((UInt8*)buffer + sampleSize);
|
||||
|
||||
numBytes -= sampleSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// plNetClientApp::StaticDebugMsg("Ogg Read, t=%f, end", hsTimer::GetSeconds());
|
||||
return true;
|
||||
}
|
||||
|
||||
UInt32 plOGGCodec::NumBytesLeft( void )
|
||||
{
|
||||
if(!IsValid())
|
||||
{
|
||||
hsAssert( false, "GetHeader() called on an invalid OGG file" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (UInt32)(( fDataSize - ( ov_pcm_tell( fOggFile ) * fHeader.fBlockAlign ) ) / fChannelAdjust);
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// plOGGCodec - Plasma codec support for the OGG/Vorbis file format. //
|
||||
// //
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _plOGGCodec_h
|
||||
#define _plOGGCodec_h
|
||||
|
||||
#include "../plAudioCore/plAudioFileReader.h"
|
||||
|
||||
|
||||
//// Class Definition ////////////////////////////////////////////////////////
|
||||
|
||||
struct OggVorbis_File;
|
||||
|
||||
class plOGGCodec : public plAudioFileReader
|
||||
{
|
||||
public:
|
||||
|
||||
plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
|
||||
virtual ~plOGGCodec();
|
||||
|
||||
enum DecodeFormat
|
||||
{
|
||||
k8bitUnsigned,
|
||||
k16bitSigned
|
||||
};
|
||||
|
||||
enum DecodeFlags
|
||||
{
|
||||
kFastSeeking = 0x01
|
||||
};
|
||||
|
||||
virtual plWAVHeader &GetHeader( void );
|
||||
|
||||
virtual void Close( void );
|
||||
|
||||
virtual UInt32 GetDataSize( void ) { return fDataSize / fChannelAdjust; }
|
||||
virtual float GetLengthInSecs( void );
|
||||
|
||||
virtual hsBool SetPosition( UInt32 numBytes );
|
||||
virtual hsBool Read( UInt32 numBytes, void *buffer );
|
||||
virtual UInt32 NumBytesLeft( void );
|
||||
|
||||
virtual hsBool IsValid( void ) { return ( fOggFile != nil ) ? true : false; }
|
||||
|
||||
static void SetDecodeFormat( DecodeFormat f ) { fDecodeFormat = f; }
|
||||
static void SetDecodeFlag( UInt8 flag, hsBool on ) { if( on ) fDecodeFlags |= flag; else fDecodeFlags &= ~flag; }
|
||||
static UInt8 GetDecodeFlags( void ) { return fDecodeFlags; }
|
||||
void ResetWaveHeaderRef() { fCurHeaderPos = 0; }
|
||||
void BuildActualWaveHeader();
|
||||
bool ReadFromHeader(int numBytes, void *data); // read from Actual wave header
|
||||
|
||||
protected:
|
||||
|
||||
enum
|
||||
{
|
||||
kPCMFormatTag = 1
|
||||
};
|
||||
|
||||
char fFilename[ 512 ];
|
||||
FILE *fFileHandle;
|
||||
OggVorbis_File *fOggFile;
|
||||
|
||||
plWAVHeader fHeader, fFakeHeader;
|
||||
UInt32 fDataStartPos, fCurrDataPos, fDataSize;
|
||||
|
||||
plAudioCore::ChannelSelect fWhichChannel;
|
||||
UInt32 fChannelAdjust, fChannelOffset;
|
||||
|
||||
static DecodeFormat fDecodeFormat;
|
||||
static UInt8 fDecodeFlags;
|
||||
UInt8 * fHeadBuf;
|
||||
int fCurHeaderPos;
|
||||
|
||||
void IError( const char *msg );
|
||||
void IOpen( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
|
||||
};
|
||||
|
||||
#endif //_plOGGCodec_h
|
@ -36,22 +36,22 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plSound.h"
|
||||
#include "plWin32Sound.h"
|
||||
|
||||
#include "../plAudioCore/plSoundBuffer.h"
|
||||
#include "../plDrawable/plDrawableGenerator.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "../pnMessage/plTimeMsg.h"
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "../plMessage/plListenerMsg.h"
|
||||
#include "../plIntersect/plSoftVolume.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "../pnNetCommon/plSDLTypes.h"
|
||||
#include "../plAvatar/plScalarChannel.h"
|
||||
#include "../plAvatar/plAGModifier.h"
|
||||
#include "../pnSceneObject/plSceneObject.h"
|
||||
#include "../pnSceneObject/plAudioInterface.h"
|
||||
#include "plAudioCore/plSoundBuffer.h"
|
||||
#include "plDrawable/plDrawableGenerator.h"
|
||||
#include "pnMessage/plRefMsg.h"
|
||||
#include "pnMessage/plTimeMsg.h"
|
||||
#include "pnMessage/plAudioSysMsg.h"
|
||||
#include "pnMessage/plSoundMsg.h"
|
||||
#include "plMessage/plListenerMsg.h"
|
||||
#include "plIntersect/plSoftVolume.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plPipeline/plPlates.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "pnNetCommon/plSDLTypes.h"
|
||||
#include "plAvatar/plScalarChannel.h"
|
||||
#include "plAvatar/plAGModifier.h"
|
||||
#include "pnSceneObject/plSceneObject.h"
|
||||
#include "pnSceneObject/plAudioInterface.h"
|
||||
|
||||
plProfile_CreateCounterNoReset( "Loaded", "Sound", SoundNumLoaded );
|
||||
plProfile_CreateCounterNoReset( "Waiting to Die", "Sound", WaitingToDie );
|
||||
|
@ -41,10 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsTemplates.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "plEAXEffects.h"
|
||||
#include "../pnNetCommon/plSynchedObject.h"
|
||||
#include "../plAvatar/plAGChannel.h"
|
||||
#include "../plAvatar/plAGApplicator.h"
|
||||
#include "../plAudioCore/plSoundBuffer.h"
|
||||
#include "pnNetCommon/plSynchedObject.h"
|
||||
#include "plAvatar/plAGChannel.h"
|
||||
#include "plAvatar/plAGApplicator.h"
|
||||
#include "plAudioCore/plSoundBuffer.h"
|
||||
|
||||
class hsResMgr;
|
||||
class hsStream;
|
||||
|
@ -37,8 +37,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plSoundEvent.h"
|
||||
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnMessage/plEventCallbackMsg.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "pnMessage/plEventCallbackMsg.h"
|
||||
#include "pnMessage/plSoundMsg.h"
|
||||
#include "plSound.h"
|
||||
|
||||
plSoundEvent::plSoundEvent( Types type, plSound *owner )
|
||||
|
@ -27,28 +27,28 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsWindows.h"
|
||||
#include "hsTimer.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "al.h"
|
||||
#include "alc.h"
|
||||
#include <al.h>
|
||||
#include <alc.h>
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "speex.h"
|
||||
#include "speex_bits.h"
|
||||
#include <speex.h>
|
||||
#include <speex_bits.h>
|
||||
#include "hsGeometry3.h"
|
||||
#include "plVoiceChat.h"
|
||||
#include "plAudioSystem.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../plAudible/plWinAudible.h"
|
||||
#include "../plNetMessage/plNetMessage.h"
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "plAudible/plWinAudible.h"
|
||||
#include "plNetMessage/plNetMessage.h"
|
||||
#include "plPipeline/plPlates.h"
|
||||
#include "hsConfig.h"
|
||||
#include "../plAvatar/plAvatarMgr.h"
|
||||
#include "../plAvatar/plArmatureMod.h"
|
||||
#include "plAvatar/plAvatarMgr.h"
|
||||
#include "plAvatar/plArmatureMod.h"
|
||||
#include "hsQuat.h"
|
||||
#include "../plAudioCore/plAudioCore.h"
|
||||
#include "plAudioCore/plAudioCore.h"
|
||||
|
||||
// DEBUG for printing to the console
|
||||
#include "../plMessage/plConsoleMsg.h"
|
||||
#include "../plPipeline/plDebugText.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plMessage/plConsoleMsg.h"
|
||||
#include "plPipeline/plDebugText.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#define MICROPHONE 121
|
||||
#define TALKING 122
|
||||
|
@ -47,7 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsStream.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
#include "plWavFile.h"
|
||||
#include "plAudioCore/plWavFile.h"
|
||||
|
||||
|
||||
//// Constructor/Destructor //////////////////////////////////////////////////
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,114 +0,0 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plWavFile_H
|
||||
#define plWavFile_H
|
||||
|
||||
#define WAVEFILE_READ 1
|
||||
#define WAVEFILE_WRITE 2
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsWindows.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include <mmsystem.h>
|
||||
#include "../plAudioCore/plAudioFileReader.h"
|
||||
|
||||
|
||||
struct plSoundMarker
|
||||
{
|
||||
char *fName;
|
||||
double fOffset; // in Secs
|
||||
|
||||
plSoundMarker () { fName = NULL;fOffset = 0.0; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CWaveFile
|
||||
// Desc: Encapsulates reading or writing sound data to or from a wave file
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
class CWaveFile : public plAudioFileReader
|
||||
{
|
||||
public:
|
||||
CWaveFile();
|
||||
~CWaveFile();
|
||||
|
||||
HRESULT Open(const char *strFileName, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
HRESULT OpenFromMemory( BYTE* pbData, ULONG ulDataSize, WAVEFORMATEX* pwfx, DWORD dwFlags );
|
||||
|
||||
HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
|
||||
HRESULT AdvanceWithoutRead( DWORD dwSizeToRead, DWORD* pdwSizeRead );
|
||||
HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );
|
||||
|
||||
DWORD GetSize();
|
||||
HRESULT ResetFile();
|
||||
WAVEFORMATEX* GetFormat() { return m_pwfx; };
|
||||
|
||||
DWORD GetNumMarkers() { return fMarkers.size() ; };
|
||||
plSoundMarker *GetSoundMarker(int i) { return fMarkers[i]; }
|
||||
|
||||
|
||||
// Overloads for plAudioFileReader
|
||||
CWaveFile( const char *path, plAudioCore::ChannelSelect whichChan );
|
||||
virtual hsBool OpenForWriting( const char *path, plWAVHeader &header );
|
||||
virtual plWAVHeader &GetHeader( void );
|
||||
virtual void Close( void );
|
||||
virtual UInt32 GetDataSize( void );
|
||||
virtual float GetLengthInSecs( void );
|
||||
|
||||
virtual hsBool SetPosition( UInt32 numBytes );
|
||||
virtual hsBool Read( UInt32 numBytes, void *buffer );
|
||||
virtual UInt32 NumBytesLeft( void );
|
||||
virtual UInt32 Write( UInt32 bytes, void *buffer );
|
||||
|
||||
virtual hsBool IsValid( void );
|
||||
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
|
||||
HMMIO m_hmmio; // MM I/O handle for the WAVE
|
||||
MMCKINFO m_ck; // Multimedia RIFF chunk
|
||||
MMCKINFO m_ckRiff; // Use in opening a WAVE file
|
||||
DWORD m_dwSize; // The size of the wave file
|
||||
MMIOINFO m_mmioinfoOut;
|
||||
DWORD m_dwFlags;
|
||||
BOOL m_bIsReadingFromMemory;
|
||||
BYTE* m_pbData;
|
||||
BYTE* m_pbDataCur;
|
||||
ULONG m_ulDataSize;
|
||||
|
||||
plWAVHeader fHeader;
|
||||
|
||||
std::vector<plSoundMarker*> fMarkers;
|
||||
double fSecsPerSample;
|
||||
|
||||
protected:
|
||||
HRESULT ReadMMIO();
|
||||
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );
|
||||
HRESULT IClose();
|
||||
};
|
||||
|
||||
#endif // plWavFile_H
|
@ -38,12 +38,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plDSoundBuffer.h"
|
||||
|
||||
#include "plAudioSystem.h"
|
||||
#include "../plAudioCore/plSoundBuffer.h"
|
||||
#include "../plAudioCore/plSoundDeswizzler.h"
|
||||
#include "plAudioCore/plSoundBuffer.h"
|
||||
#include "plAudioCore/plSoundDeswizzler.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "pnMessage/plSoundMsg.h"
|
||||
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
#include "plProfile.h"
|
||||
#include "hsResMgr.h"
|
||||
|
||||
|
@ -35,15 +35,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plWin32Sound.h"
|
||||
#include "plAudioSystem.h"
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "plWavFile.h"
|
||||
#include "plAudioCore/plWavFile.h"
|
||||
|
||||
#include "../plAudible/plWinAudible.h"
|
||||
#include "../plNetMessage/plNetMessage.h"
|
||||
#include "../pnNetCommon/plNetApp.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "../pnMessage/plEventCallbackMsg.h"
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plAudible/plWinAudible.h"
|
||||
#include "plNetMessage/plNetMessage.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnMessage/plSoundMsg.h"
|
||||
#include "pnMessage/plEventCallbackMsg.h"
|
||||
#include "plPipeline/plPlates.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
plProfile_CreateMemCounter("Sounds", "Memory", MemSounds);
|
||||
plProfile_Extern(SoundPlaying);
|
||||
|
@ -32,15 +32,15 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plWin32Sound.h"
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "plAudioSystem.h"
|
||||
#include "../plAudioCore/plSoundBuffer.h"
|
||||
#include "../plAudioCore/plSoundDeswizzler.h"
|
||||
#include "../pnMessage/plEventCallbackMsg.h"
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "../plMessage/plLinkToAgeMsg.h"
|
||||
#include "../plMessage/plAvatarMsg.h"
|
||||
#include "plAudioCore/plSoundBuffer.h"
|
||||
#include "plAudioCore/plSoundDeswizzler.h"
|
||||
#include "pnMessage/plEventCallbackMsg.h"
|
||||
#include "pnMessage/plAudioSysMsg.h"
|
||||
#include "plMessage/plLinkToAgeMsg.h"
|
||||
#include "plMessage/plAvatarMsg.h"
|
||||
|
||||
#include "../plPipeline/plPlates.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plPipeline/plPlates.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
plProfile_Extern(MemSounds);
|
||||
plProfile_CreateAsynchTimer( "Static Shove Time", "Sound", StaticSndShoveTime );
|
||||
|
@ -35,12 +35,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "plDSoundBuffer.h"
|
||||
#include "plAudioSystem.h"
|
||||
|
||||
#include "../plAudioCore/plAudioFileReader.h"
|
||||
#include "../plAudioCore/plSoundBuffer.h"
|
||||
#include "../plAudioCore/plSoundDeswizzler.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "../pnMessage/plEventCallbackMsg.h"
|
||||
#include "../plStatusLog/plStatusLog.h"
|
||||
#include "plAudioCore/plAudioFileReader.h"
|
||||
#include "plAudioCore/plSoundBuffer.h"
|
||||
#include "plAudioCore/plSoundDeswizzler.h"
|
||||
#include "pnMessage/plSoundMsg.h"
|
||||
#include "pnMessage/plEventCallbackMsg.h"
|
||||
#include "plStatusLog/plStatusLog.h"
|
||||
|
||||
#define STREAMING_UPDATE_MS 200
|
||||
|
||||
|
@ -27,7 +27,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#define plWin32StreamingSound_h
|
||||
|
||||
#include "plWin32Sound.h"
|
||||
#include "../pnUtils/pnUtils.h"
|
||||
#include "pnUtils/pnUtils.h"
|
||||
|
||||
class plDSoundBuffer;
|
||||
class DSoundCallbackHandle;
|
||||
|
Reference in New Issue
Block a user