From 600371a8716164915d092c7d6b2a67e965251544 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 10 Dec 2002 08:19:18 +0000 Subject: [PATCH] RageSound -> RageSoundBass --- stepmania/src/Crash.cpp | 2 +- stepmania/src/RageSound.cpp | 121 --------------------------------- stepmania/src/RageSound.h | 40 ----------- stepmania/src/RandomSample.h | 1 - stepmania/src/StepMania.cpp | 4 +- stepmania/src/StepMania.dsp | 4 +- stepmania/src/StepMania.vcproj | 4 +- 7 files changed, 7 insertions(+), 169 deletions(-) delete mode 100644 stepmania/src/RageSound.cpp delete mode 100644 stepmania/src/RageSound.h diff --git a/stepmania/src/Crash.cpp b/stepmania/src/Crash.cpp index 584e4314cd..957ab1a787 100644 --- a/stepmania/src/Crash.cpp +++ b/stepmania/src/Crash.cpp @@ -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 diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp deleted file mode 100644 index b3654c6a53..0000000000 --- a/stepmania/src/RageSound.cpp +++ /dev/null @@ -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((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 diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h deleted file mode 100644 index 13f30dcf79..0000000000 --- a/stepmania/src/RageSound.h +++ /dev/null @@ -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 diff --git a/stepmania/src/RandomSample.h b/stepmania/src/RandomSample.h index 61de576780..8542933f5e 100644 --- a/stepmania/src/RandomSample.h +++ b/stepmania/src/RandomSample.h @@ -11,7 +11,6 @@ ----------------------------------------------------------------------------- */ -#include "RageSound.h" #include "RageSoundSample.h" #include "RageUtil.h" diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index e2ce0a1573..0a4062ef64 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -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; diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index ea6ead6f3e..776579af75 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -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 diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 609f76ac68..32ad985710 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -1076,10 +1076,10 @@ cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ RelativePath="RageNetworkServer.h"> + RelativePath=".\RageSoundBass.cpp"> + RelativePath=".\RageSoundBass.h">