RageSound -> RageSoundBass
This commit is contained in:
@@ -268,7 +268,7 @@ static void DoEraseEmergencyDump()
|
||||
DeleteFile(szEmergencyDumpName);
|
||||
}
|
||||
|
||||
#include "RageSound.h"
|
||||
#include "RageSoundBass.h"
|
||||
extern HWND g_hWndMain;
|
||||
long __stdcall CrashHandler(EXCEPTION_POINTERS *pExc) {
|
||||
/* If we're fullscreen, the fullscreen d3d window will obscure
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#include "stdafx.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: RageSound
|
||||
|
||||
Desc: See header.
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "RageSound.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "RageException.h"
|
||||
|
||||
|
||||
RageSound* SOUND = NULL;
|
||||
|
||||
/* I use this to turn off sound, since Bass doesn't want to work under
|
||||
* VTune. -glenn */
|
||||
#if 0
|
||||
RageSound::RageSound() { }
|
||||
RageSound::~RageSound() { }
|
||||
void RageSound::PlayOnceStreamed( CString sPath ) { }
|
||||
void RageSound::PlayOnceStreamedFromDir( CString sDir ) { }
|
||||
#else
|
||||
|
||||
#pragma comment(lib, "bass/bass.lib")
|
||||
|
||||
#include "bass/bass.h"
|
||||
|
||||
|
||||
|
||||
RageSound::RageSound()
|
||||
{
|
||||
LOG->Trace( "RageSound::RageSound()" );
|
||||
|
||||
if( BASS_GetVersion() != MAKELONG(1,6) )
|
||||
throw RageException( "BASS version 1.6 DLL could not be loaded. Verify that Bass.dll exists in the program directory.");
|
||||
|
||||
if( !BASS_Init( -1, 44100, BASS_DEVICE_LEAVEVOL|BASS_DEVICE_LATENCY, NULL ) )
|
||||
{
|
||||
throw RageException(
|
||||
"There was an error while initializing your sound card.\n\n"
|
||||
"The most likely cause of this problem is that you do not have a sound card\n"
|
||||
"installed, or that you have not yet installed a driver for your sound card.\n"
|
||||
"Before running this program again, please verify that your sound card is\n"
|
||||
"is working in other applications."
|
||||
);
|
||||
}
|
||||
|
||||
BASS_Start();
|
||||
|
||||
ZeroMemory( &m_info, sizeof(m_info) );
|
||||
m_info.size = sizeof(m_info);
|
||||
BASS_GetInfo( &m_info );
|
||||
|
||||
|
||||
LOG->Trace(
|
||||
"Sound card info:\n"
|
||||
" - play latency is %u ms\n"
|
||||
" - total device hardware memory is %u bytes\n"
|
||||
" - free device hardware memory is %u bytes\n"
|
||||
" - number of free sample slots in the hardware is %u\n"
|
||||
" - number of free 3D sample slots in the hardware is %u\n"
|
||||
" - min sample rate supported by the hardware is %u\n"
|
||||
" - max sample rate supported by the hardware is %u",
|
||||
m_info.latency,
|
||||
m_info.hwsize,
|
||||
m_info.hwfree,
|
||||
m_info.freesam,
|
||||
m_info.free3d,
|
||||
m_info.minrate,
|
||||
m_info.maxrate
|
||||
);
|
||||
}
|
||||
|
||||
RageSound::~RageSound()
|
||||
{
|
||||
LOG->Trace( "RageSound::~RageSound()" );
|
||||
|
||||
BASS_Stop();
|
||||
BASS_Free();
|
||||
}
|
||||
|
||||
void RageSound::PlayOnceStreamed( CString sPath )
|
||||
{
|
||||
HSTREAM hStream = BASS_StreamCreateFile( FALSE, const_cast<char*>((const char *)sPath), 0, 0, BASS_STREAM_AUTOFREE );
|
||||
if( !hStream )
|
||||
throw RageException( "RageSound: Error creating stream." );
|
||||
|
||||
if( FALSE == BASS_StreamPlay( hStream, FALSE, 0 ) )
|
||||
throw RageException( "RageSound: Error playing a sound stream." );
|
||||
|
||||
// this stream will free itself when stopped
|
||||
}
|
||||
|
||||
void RageSound::PlayOnceStreamedFromDir( CString sDir )
|
||||
{
|
||||
if( sDir == "" )
|
||||
return;
|
||||
|
||||
// make sure there's a backslash at the end of this path
|
||||
if( sDir[sDir.GetLength()-1] != '\\' )
|
||||
sDir += "\\";
|
||||
|
||||
CStringArray arraySoundFiles;
|
||||
GetDirListing( sDir + "*.mp3", arraySoundFiles );
|
||||
GetDirListing( sDir + "*.wav", arraySoundFiles );
|
||||
GetDirListing( sDir + "*.ogg", arraySoundFiles );
|
||||
|
||||
if( !arraySoundFiles.empty() )
|
||||
{
|
||||
int index = rand() % arraySoundFiles.size();
|
||||
PlayOnceStreamed( sDir + arraySoundFiles[index] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef RAGESOUND_H
|
||||
#define RAGESOUND_H
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
File: RageSound.h
|
||||
|
||||
Desc: Sound effects library (currently a wrapper around Bass Sound Library).
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include "bass/bass.h"
|
||||
|
||||
|
||||
#define NUM_STREAMS 16
|
||||
|
||||
|
||||
class RageSound
|
||||
{
|
||||
public:
|
||||
RageSound();
|
||||
~RageSound();
|
||||
|
||||
float GetPlayLatency() { return m_info.latency / 1000.0f; }; // latency between when Play() is called and sound starts coming out
|
||||
|
||||
void PlayOnceStreamed( CString sPath );
|
||||
void PlayOnceStreamedFromDir( CString sDir );
|
||||
|
||||
private:
|
||||
BASS_INFO m_info;
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern RageSound* SOUND; // global and accessable from anywhere in our program
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,6 @@
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "RageSound.h"
|
||||
#include "RageSoundSample.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "RageSound.h"
|
||||
#include "RageSoundBass.h"
|
||||
// #include "RageSoundManager.h"
|
||||
#include "RageMusic.h"
|
||||
#include "RageInput.h"
|
||||
@@ -313,7 +313,7 @@ int main(int argc, char* argv[])
|
||||
PREFSMAN = new PrefsManager;
|
||||
GAMEMAN = new GameManager;
|
||||
THEME = new ThemeManager;
|
||||
SOUND = new RageSound;
|
||||
SOUND = new RageSoundBass;
|
||||
MUSIC = new RageSoundStream;
|
||||
ANNOUNCER = new AnnouncerManager;
|
||||
INPUTFILTER = new InputFilter;
|
||||
|
||||
@@ -219,11 +219,11 @@ SOURCE=.\RageNetworkClient.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RageSound.cpp
|
||||
SOURCE=.\RageSoundBass.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RageSound.h
|
||||
SOURCE=.\RageSoundBass.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -1076,10 +1076,10 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
RelativePath="RageNetworkServer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\RageSound.cpp">
|
||||
RelativePath=".\RageSoundBass.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\RageSound.h">
|
||||
RelativePath=".\RageSoundBass.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\RageSoundSample.cpp">
|
||||
|
||||
Reference in New Issue
Block a user