From: Andrew M. <rh...@us...> - 2006-01-15 21:48:11
|
Update of /cvsroot/planeshift/planeshift/src/client/sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30944 Modified Files: pssoundmngr.cpp pssoundmngr.h Log Message: Conversion of planeshift from old CS sound interfaces (iSound*) to new CS sound interfaces (iSndSys*). Added: Wailing and gnashing of teeth by developers. Index: pssoundmngr.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** pssoundmngr.cpp 10 Jan 2006 00:57:59 -0000 1.122 --- pssoundmngr.cpp 15 Jan 2006 21:47:57 -0000 1.123 *************** *** 47,58 **** #include <csutil/xmltiny.h> - //Sound - #include <isound/renderer.h> - #include <isound/listener.h> - #include <isound/handle.h> - #include <isound/wrapper.h> - #include <isound/source.h> - #include <isound/data.h> - // PS includes #include "pssoundmngr.h" --- 47,50 ---- *************** *** 77,80 **** --- 69,75 ---- #define MAX_VOLUME 0.90 + csRef<SOUND_RENDER_TYPE> psSoundManager::soundSystem; + + psSoundManager::psSoundManager(iBase* iParent) : sndmngr(this) *************** *** 164,190 **** void psSoundManager::Update( iView* view ) { ! if (!snd) ! return; ! ! iSoundListener *sndListener = snd->GetListener(); ! if (sndListener) ! { ! if (!ListenerInitialized) ! { ! // 15 centimeters - average head size. Keep this at a real person's head size, not character head size ! sndListener->SetHeadSize(0.15f); ! // The rolloff factor is used in the calculation: vol = max_volume / ((distance/minimum_distance) ^ (2 * rolloff_factor)) ! sndListener->SetRollOffFactor(1.0f); ! ListenerInitialized=true; ! } ! ! // take position/direction from view->GetCamera () ! csVector3 v = view->GetCamera ()->GetTransform ().GetOrigin (); ! csMatrix3 m = view->GetCamera ()->GetTransform ().GetT2O(); ! csVector3 f = m.Col3(); ! csVector3 t = m.Col2(); ! sndListener->SetPosition(v); ! sndListener->SetDirection(f,t); ! } } --- 159,177 ---- void psSoundManager::Update( iView* view ) { ! if (!soundSystem) ! return; ! SOUND_LISTENER_TYPE *sndListener = soundSystem->GetListener(); ! if (sndListener) ! { ! ListenerInitialized=true; ! ! // take position/direction from view->GetCamera () ! csVector3 v = view->GetCamera ()->GetTransform ().GetOrigin (); ! csMatrix3 m = view->GetCamera ()->GetTransform ().GetT2O(); ! csVector3 f = m.Col3(); ! csVector3 t = m.Col2(); ! sndListener->SetPosition(v); ! sndListener->SetDirection(f,t); ! } } *************** *** 214,219 **** bool psSoundManager::Setup() { ! if (snd) ! return true; engine = CS_QUERY_REGISTRY(object_reg, iEngine); --- 201,206 ---- bool psSoundManager::Setup() { ! if (soundSystem.IsValid()) ! return true; engine = CS_QUERY_REGISTRY(object_reg, iEngine); *************** *** 236,241 **** } ! snd = CS_QUERY_REGISTRY(object_reg, iSoundRender); ! if (!snd) { Error1("Couldn't find iSoundRender!"); --- 223,228 ---- } ! soundSystem = CS_QUERY_REGISTRY(object_reg, iSndSysRenderer); ! if (!soundSystem) { Error1("Couldn't find iSoundRender!"); *************** *** 246,250 **** } ! csRef<iSoundSource> psSoundManager::StartMusicSound(const char* name,bool loop) { if(musicEnabled) --- 233,237 ---- } ! csRef<iSndSysSource> psSoundManager::StartMusicSound(const char* name,bool loop) { if(musicEnabled) *************** *** 254,258 **** } ! csRef<iSoundSource> psSoundManager::StartAmbientSound(const char* name,bool loop) { if(soundEnabled) --- 241,245 ---- } ! csRef<iSndSysSource> psSoundManager::StartAmbientSound(const char* name,bool loop) { if(soundEnabled) *************** *** 262,266 **** } ! csRef<iSoundSource> psSoundManager::StartGUISound(const char* name,bool loop) { if(guiEnabled) --- 249,253 ---- } ! csRef<iSndSysSource> psSoundManager::StartGUISound(const char* name,bool loop) { if(guiEnabled) *************** *** 270,274 **** } ! csRef<iSoundSource> psSoundManager::StartActionsSound(const char* name,bool loop) { if(actionsEnabled) --- 257,261 ---- } ! csRef<iSndSysSource> psSoundManager::StartActionsSound(const char* name,bool loop) { if(actionsEnabled) *************** *** 278,287 **** } ! csRef<iSoundSource> psSoundManager::StartSound(const char* name,float volume,bool loop) { if ( !name ) return NULL; ! if (!snd) return NULL; --- 265,274 ---- } ! csRef<iSndSysSource> psSoundManager::StartSound(const char* name,float volume,bool loop) { if ( !name ) return NULL; ! if (!soundSystem) return NULL; *************** *** 296,306 **** } ! handle->src->ResetStream(); ! csRef<iSoundSource> sndhandle = handle->src->Play(loop); ! sndhandle->SetVolume(volume); ! handle->src->StartStream(loop); ! return sndhandle; } void psSoundManager::HandleSoundType(int type) --- 283,312 ---- } ! csRef<iSndSysStream> sndstream = soundSystem->CreateStream(handle->snddata, CS_SND3D_DISABLE); ! if (!sndstream) ! { ! Error2("Failed to create stream for '%s'!", name); ! return NULL; ! } ! csRef<iSndSysSource> sndsource = soundSystem->CreateSource(sndstream); ! if (!sndsource.IsValid()) ! { ! Error2("Failed to create source for '%s'!", name); ! return NULL; ! } ! ! if (loop) ! sndstream->SetLoopState(CS_SNDSYS_STREAM_LOOP); ! else ! sndstream->SetLoopState(CS_SNDSYS_STREAM_DONTLOOP); ! sndstream->ResetPosition(); ! sndstream->SetAutoUnregister(true); ! sndsource->SetVolume(volume); ! sndstream->Unpause(); ! ! return sndsource; } + void psSoundManager::HandleSoundType(int type) *************** *** 321,334 **** void psSoundManager::SetVolume(float vol) { ! if (!snd) return; ! snd->SetVolume(vol); } float psSoundManager::GetVolume() { ! if (!snd) return -1; ! return snd->GetVolume(); } --- 327,340 ---- void psSoundManager::SetVolume(float vol) { ! if (!soundSystem) return; ! soundSystem->SetVolume(vol); } float psSoundManager::GetVolume() { ! if (!soundSystem) return -1; ! return soundSystem->GetVolume(); } *************** *** 398,402 **** bool psSoundManager::OverrideBGSong(const char* name, bool loop, float fadeTime) { ! if (!snd || !musicEnabled) return false; --- 404,408 ---- bool psSoundManager::OverrideBGSong(const char* name, bool loop, float fadeTime) { ! if (!soundSystem || !musicEnabled) return false; *************** *** 404,430 **** if ( !backgroundSong ) { ! csRef<iSoundHandle> handle = GetSoundResource( name ); ! backgroundSong = new psSoundObject( handle,mapSoundSystem, 1.0, 0.0, false, (int)fadeTime, 0, 0 ); ! backgroundSong->SetVolume( musicVolume ); ! backgroundSong->SetResource( name ); ! backgroundSong->StartFade( FADE_UP ); } else { ! csRef<iSoundHandle> handle = GetSoundResource( name ); ! psSoundObject* backgroundSongNew = new psSoundObject( handle,mapSoundSystem, 1.0, 0.0, false, (int)fadeTime, 0, 0 ); ! backgroundSongNew->SetVolume( musicVolume ); ! backgroundSongNew->SetResource( name ); ! if ( backgroundSongNew->Same(backgroundSong) ) ! { ! delete backgroundSongNew; backgroundSongNew = NULL; ! return true; ! } ! else ! { ! StopOverrideBG(); ! backgroundSong = backgroundSongNew; ! backgroundSong->StartFade( FADE_UP ); ! } } --- 410,453 ---- if ( !backgroundSong ) { ! csRef<iSndSysData> snddata = GetSoundResource( name ); ! if (!snddata.IsValid()) ! return false; ! csRef<iSndSysStream> sndstream = psSoundManager::soundSystem->CreateStream(snddata, CS_SND3D_DISABLE); ! if (!sndstream.IsValid()) ! return false; ! ! backgroundSong = new psSoundObject(sndstream,mapSoundSystem, 1.0, 0.0, (int)fadeTime, 0, 0 ); ! backgroundSong->SetVolume( musicVolume ); ! backgroundSong->SetResource( name ); ! backgroundSong->StartFade( FADE_UP ); } else { ! ! csRef<iSndSysData> snddata = GetSoundResource( name ); ! if (!snddata.IsValid()) ! return false; ! csRef<iSndSysStream> sndstream = psSoundManager::soundSystem->CreateStream(snddata, CS_SND3D_DISABLE); ! if (!sndstream.IsValid()) ! return false; ! ! psSoundObject* backgroundSongNew = new psSoundObject( sndstream,mapSoundSystem, 1.0, 0.0, (int)fadeTime, 0, 0 ); ! backgroundSongNew->SetVolume( musicVolume ); ! backgroundSongNew->SetResource( name ); ! ! // TODO: Comparing sources or streams wont work here, probably want to compare the data element ! /* ! if ( backgroundSongNew->Same(backgroundSong) ) ! { ! delete backgroundSongNew; backgroundSongNew = NULL; ! return true; ! } ! else ! */ ! { ! StopOverrideBG(); ! backgroundSong = backgroundSongNew; ! backgroundSong->StartFade( FADE_UP ); ! } } *************** *** 435,439 **** void psSoundManager::ToggleMusic(bool toggle) { ! if (!snd) return; --- 458,462 ---- void psSoundManager::ToggleMusic(bool toggle) { ! if (!soundSystem) return; *************** *** 475,479 **** void psSoundManager::ToggleSounds(bool toggle) { ! if (!snd) return; --- 498,502 ---- void psSoundManager::ToggleSounds(bool toggle) { ! if (!soundSystem) return; *************** *** 540,544 **** } ! csRef<iSoundHandle> psSoundManager::GetSoundResource(const char *name) { csRef<psSoundHandle> soundhandle; --- 563,567 ---- } ! csRef<iSndSysData> psSoundManager::GetSoundResource(const char *name) { csRef<psSoundHandle> soundhandle; *************** *** 547,551 **** return NULL; ! return soundhandle->src; } --- 570,574 ---- return NULL; ! return soundhandle->snddata; } *************** *** 575,582 **** bool psSoundManager::psSndSourceMngr::Initialize() { ! sndloader = CS_QUERY_REGISTRY(parent->object_reg, iSoundLoader); if (!sndloader) { ! Error1("Could not initialize with iSoundLoader"); return false; } --- 598,605 ---- bool psSoundManager::psSndSourceMngr::Initialize() { ! sndloader = CS_QUERY_REGISTRY(parent->object_reg, iSndSysLoader); if (!sndloader) { ! Error1("psSndSourceMngr: Could not initialize. Cannot find iSndSysLoader"); return false; } *************** *** 585,589 **** if (!vfs) { ! Error1("Could not initialize with iVFS"); return false; } --- 608,612 ---- if (!vfs) { ! Error1("psSndSourceMngr: Could not initialize. Cannot find iVFS"); return false; } *************** *** 646,653 **** } ! csPtr<iSoundHandle> psSoundManager::psSndSourceMngr::LoadSound(const char* fname) { ! if (!parent->snd) return NULL; csRef<iDataBuffer> buf = vfs->ReadFile(fname); --- 669,676 ---- } ! csRef<iSndSysData> psSoundManager::psSndSourceMngr::LoadSound(const char* fname) { ! if (!parent->soundSystem) return NULL; csRef<iDataBuffer> buf = vfs->ReadFile(fname); *************** *** 658,663 **** } ! csRef<iSoundData> sounddata = ! sndloader->LoadSound (buf->GetData(), buf->GetSize ()); if (!sounddata) { --- 681,685 ---- } ! csRef<iSndSysData> sounddata = sndloader->LoadSound (buf); if (!sounddata) { *************** *** 665,679 **** return NULL; } - sounddata->IsStatic (); - - csRef<iSoundHandle> sndhandle = parent->snd->RegisterSound(sounddata); ! if (!sndhandle) ! { ! Error2("Cannot register sound '%s'", fname); ! return NULL; ! } ! ! return csPtr<iSoundHandle>( sndhandle ); } --- 687,692 ---- return NULL; } ! return sounddata; } *************** *** 746,754 **** } ! csRef<iSoundHandle> handle = LoadSound(info->file); ! if (!handle) ! return NULL; ! return csPtr <psTemplateRes> (new psSoundHandle(handle)); } --- 759,767 ---- } ! csRef<iSndSysData> snddata = LoadSound(info->file); ! if (!snddata) ! return NULL; ! return csPtr <psTemplateRes> (new psSoundHandle(snddata)); } *************** *** 961,974 **** trigSector = GetOrCreateSector(sec); ! csRef<iSoundHandle> handle = sndmngr->GetSoundResource( resource ); ! if ( !handle ) { ! Error2("Failed to load Sound Handle: %s", resource.GetData()); ! continue; } ! psSoundObject* obj = new psSoundObject (handle, this, maxVol, minVol, - false, fadeDelay, timeOfDay, --- 974,996 ---- trigSector = GetOrCreateSector(sec); ! ! csRef<iSndSysData> snddata = sndmngr->GetSoundResource( resource ); ! ! if (!snddata.IsValid()) { ! Error2("Failed to load Sound Handle: %s", resource.GetData()); ! continue; } ! ! csRef<iSndSysStream> sndstream = psSoundManager::soundSystem->CreateStream(snddata, CS_SND3D_DISABLE); ! if (!sndstream.IsValid()) ! { ! Error2("Failed to load Sound Handle: %s", resource.GetData()); ! continue; ! } ! ! psSoundObject* obj = new psSoundObject (sndstream, this, maxVol, minVol, fadeDelay, timeOfDay, *************** *** 993,1004 **** float minRange = emitter->GetAttributeValueAsFloat("MIN_RANGE"); ! csRef<iSoundHandle> handle = sndmngr->GetSoundResource( resource ); ! if ( !handle ) { ! Error2("Failed to load Sound Handle: %s", resource.GetData()); ! continue; } ! psSoundObject* obj = new psSoundObject (handle, this, maxVol, minVol, true --- 1015,1034 ---- float minRange = emitter->GetAttributeValueAsFloat("MIN_RANGE"); ! csRef<SOUND_DATA_TYPE> snddata = sndmngr->GetSoundResource( resource ); ! if (!snddata) { ! Error2("Failed to load Sound: %s", resource.GetData()); ! continue; ! } ! ! ! csRef<SOUND_STREAM_TYPE> sndstream = sndmngr->soundSystem->CreateStream(snddata, CS_SND3D_ABSOLUTE); ! if ( !sndstream ) ! { ! Error2("Failed to create Sound Stream: %s", resource.GetData()); ! continue; } ! psSoundObject* obj = new psSoundObject (sndstream, this, maxVol, minVol, true *************** *** 1038,1052 **** int weather = background->GetAttributeValueAsInt("WEATHER"); ! csRef<iSoundHandle> handle = sndmngr->GetSoundResource( resource ); ! ! if ( !handle ) { ! Error2("Failed to load Sound Handle: %s", resource.GetData()); ! continue; ! } ! psSoundObject* obj = new psSoundObject (handle, this, maxVol, minVol, - false, fadeDelay, timeOfDay, --- 1068,1088 ---- int weather = background->GetAttributeValueAsInt("WEATHER"); ! csRef<SOUND_DATA_TYPE> snddata = sndmngr->GetSoundResource( resource ); ! if (!snddata) { ! Error2("Failed to load Sound: %s", resource.GetData()); ! continue; ! } ! ! ! csRef<SOUND_STREAM_TYPE> sndstream = sndmngr->soundSystem->CreateStream(snddata, CS_SND3D_DISABLE); ! if ( !sndstream ) ! { ! Error2("Failed to create Sound Stream: %s", resource.GetData()); ! continue; ! } ! psSoundObject* obj = new psSoundObject (sndstream, this, maxVol, minVol, fadeDelay, timeOfDay, *************** *** 1374,1378 **** { mapsoundsystem->RegisterActiveEmitter(emitters[z]); ! emitters[z]->Start3DSound(); } } --- 1410,1414 ---- { mapsoundsystem->RegisterActiveEmitter(emitters[z]); ! emitters[z]->StartSound(); } } *************** *** 1627,1642 **** } ! psSoundObject::psSoundObject(csRef<iSoundHandle> handle, psMapSoundSystem* mapSys, ! float maxVol, float minVol, bool threeDee, int fadeTime, int timeOfDay, int timeOfDayRange, int weather, bool looping, psSectorSoundManager* sector,int connectWith ):loop(looping) { ! this->soundObject = handle; this->maxVol = maxVol; this->minVol = minVol; isPlaying = false; - this->sound = NULL; fadeComplete = false; fadeDelay = fadeTime; --- 1663,1677 ---- } ! psSoundObject::psSoundObject(csRef<iSndSysStream> strm, psMapSoundSystem* mapSys, ! float maxVol, float minVol, int fadeTime, int timeOfDay, int timeOfDayRange, int weather, bool looping, psSectorSoundManager* sector,int connectWith ):loop(looping) { ! this->soundStream = strm; this->maxVol = maxVol; this->minVol = minVol; isPlaying = false; fadeComplete = false; fadeDelay = fadeTime; *************** *** 1644,1648 **** this->timeOfDayRange = timeOfDayRange; this->weatherCondition = weather; - this->threeDee = threeDee; currentVolume = 0; ambientVolume = 1.0; --- 1679,1682 ---- *************** *** 1651,1654 **** --- 1685,1693 ---- connectedWith = connectWith; + if (strm->Get3dMode() == CS_SND3D_DISABLE) + threeDee = false; + else + threeDee = true; + if(sector) sector->ConnectObject(this, connectWith); *************** *** 1666,1687 **** ambientVolume = vol; if( isPlaying) ! sound->SetVolume( currentVolume * ambientVolume ); } ! void psSoundObject::Start3DSound() { ! if ( !sound ) { ! sound = soundObject->CreateSource( SOUND3D_ABSOLUTE ); ! sound->SetMinimumDistance(minRange); ! sound->SetMaximumDistance(rangeToStart); ! sound->SetPosition( position ); ! sound->SetVolume( 0 ); } } void psSoundObject::Start3DSound( csVector3& playerPos ) { ! Start3DSound(); Update( playerPos ); } --- 1705,1740 ---- ambientVolume = vol; if( isPlaying) ! soundSource->SetVolume( currentVolume * ambientVolume ); } ! void psSoundObject::StartSound() { ! if (!soundSource) ! soundSource=psSoundManager::soundSystem->CreateSource(soundStream); ! ! // Failed to create source ! if (!soundSource) ! return; ! ! if (threeDee) ! { ! soundSource3D=SCF_QUERY_INTERFACE(soundSource, SOUND_SOURCE3D_TYPE); ! if (!soundSource3D) ! threeDee=false; ! else { ! soundSource3D->SetMinimumDistance(minRange); ! soundSource3D->SetMaximumDistance(rangeToStart); ! soundSource3D->SetPosition( position ); } + } + + soundSource->SetVolume( 0 ); + soundStream->Unpause(); } void psSoundObject::Start3DSound( csVector3& playerPos ) { ! StartSound(); Update( playerPos ); } *************** *** 1741,1750 **** if ( isPlaying && range > rangeToStart ) { ! sound->Stop(); ! isPlaying = false; } else if ( !isPlaying && range < rangeToStart ) { - sound->Play(SOUND_LOOP); isPlaying = true; } --- 1794,1802 ---- if ( isPlaying && range > rangeToStart ) { ! soundSource->SetVolume(0.0f); ! isPlaying = false; } else if ( !isPlaying && range < rangeToStart ) { isPlaying = true; } *************** *** 1752,1761 **** if ( isPlaying ) { ! currentVolume = maxVol-(range-minRange)*rangeConstant; ! if ( currentVolume > maxVol ) ! currentVolume = maxVol; ! ! //printf("Emitter Sound Vol: %f\n", currentVolume ); ! sound->SetVolume( currentVolume * ambientVolume ); } } --- 1804,1818 ---- if ( isPlaying ) { ! // Emitter volume is based on 3d positional audio calculations handled inside the ! // sound system ! /* ! currentVolume = maxVol-(range-minRange)*rangeConstant; ! if ( currentVolume > maxVol ) ! currentVolume = maxVol; ! */ ! currentVolume=maxVol; ! ! //printf("Emitter Sound Vol: %f\n", currentVolume ); ! soundSource->SetVolume( currentVolume * ambientVolume ); } } *************** *** 1772,1776 **** { isPlaying = false; ! sound->Stop(); } return; --- 1829,1833 ---- { isPlaying = false; ! soundSource->SetVolume(0.0f); } return; *************** *** 1783,1790 **** { isPlaying = true; ! if(loop) ! sound->Play(SOUND_LOOP); ! else ! sound->Play(SOUND_RESTART); } return; --- 1840,1845 ---- { isPlaying = true; ! soundStream->Unpause(); ! soundSource->SetVolume(currentVolume); } return; *************** *** 1795,1833 **** fadeComplete = false; ! if ( sound == NULL ) ! { ! if ( !soundObject ) ! return; ! ! if ( !soundObject->IsStatic() ) ! soundObject->StartStream(loop); ! sound = soundObject->Play(loop); ! sound->SetVolume( minVol * ambientVolume); ! currentVolume = minVol; ! Debug2( LOG_SOUND,"Sound source for %s is NULL. Setting currentVolume to minVol.",GetName().GetData()); ! } ! ! ! if ( sound ) { ! if ( !isPlaying ) ! { ! if ( !soundObject->IsStatic() ) ! soundObject->ResetStream(); ! if(loop) ! sound->Play(SOUND_LOOP); ! else ! sound->Play(SOUND_RESTART); ! isPlaying = true; ! Debug2( LOG_SOUND, "Sound Playing at: %f vol", currentVolume ); ! sound->SetVolume( currentVolume*ambientVolume ); ! } ! else { ! /*This is necessary in order to get rain fading out in the new sector, otherwise ! it doesn't*/ ! Update(); } } } --- 1850,1884 ---- fadeComplete = false; ! ! if (!soundSource.IsValid()) { ! currentVolume = minVol; ! StartSound(); ! if (soundSource.IsValid()) ! soundSource->SetVolume( minVol * ambientVolume); ! Debug2( LOG_SOUND,"Sound source for %s is NULL. Setting currentVolume to minVol.",GetName().GetData()); ! } ! ! if ( soundSource.IsValid() ) ! { ! if (!isPlaying) ! { ! if (soundStream->GetPauseState() == CS_SNDSYS_STREAM_PAUSED) { ! soundStream->ResetPosition(); ! soundStream->Unpause(); } + isPlaying = true; + Debug2( LOG_SOUND, "Sound Playing at: %f vol", currentVolume ); + soundSource->SetVolume( currentVolume*ambientVolume ); + } + else + { + /*This is necessary in order to get rain fading out in the new sector, otherwise + it doesn't*/ + Update(); + + } } } *************** *** 1899,1911 **** - if ( currentVolume <= minVol && fadeDir == FADE_DOWN ) { ! isPlaying = false; ! if (sound) ! sound->Stop(); ! } ! if ( sound ) ! sound->SetVolume( currentVolume * ambientVolume ); } --- 1950,1964 ---- if ( currentVolume <= minVol && fadeDir == FADE_DOWN ) { ! isPlaying = false; ! if ( soundSource.IsValid() ) ! soundSource->SetVolume(0.0f); ! } ! else ! { ! if ( soundSource.IsValid() ) ! soundSource->SetVolume( currentVolume * ambientVolume ); ! } } Index: pssoundmngr.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/client/sound/pssoundmngr.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pssoundmngr.h 7 Jan 2006 15:26:43 -0000 1.60 --- pssoundmngr.h 15 Jan 2006 21:47:58 -0000 1.61 *************** *** 32,37 **** #include <iutil/comp.h> #include "util/prb.h" - #include "isound/loader.h" #include "csutil/hash.h" // PS includes --- 32,41 ---- #include <iutil/comp.h> #include "util/prb.h" #include "csutil/hash.h" + #include "isndsys/ss_structs.h" + #include "isndsys/ss_data.h" + #include "isndsys/ss_stream.h" + #include "isndsys/ss_source.h" + #include "isndsys/ss_renderer.h" // PS includes *************** *** 39,44 **** #include "util/psresmngr.h" - struct iSoundSource; - struct iSoundRender; struct iEngine; struct iObjectRegistry; --- 43,46 ---- *************** *** 109,120 **** // Use these to play sounds. Choose the right method for your intended purpose. This will assure correct volume control ! virtual csRef<iSoundSource> StartMusicSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSoundSource> StartAmbientSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSoundSource> StartActionsSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSoundSource> StartGUISound(const char* name,bool loop = iSoundManager::NO_LOOP); // This one should not be used. I'm leaving it in only because... I'm using it inside the class :-). // And you can insist on controlling volume. ! virtual csRef<iSoundSource> StartSound(const char* name,float volume,bool loop = iSoundManager::NO_LOOP); /** Change the current song to use as the background --- 111,122 ---- // Use these to play sounds. Choose the right method for your intended purpose. This will assure correct volume control ! virtual csRef<iSndSysSource> StartMusicSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSndSysSource> StartAmbientSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSndSysSource> StartActionsSound(const char* name,bool loop = iSoundManager::NO_LOOP); ! virtual csRef<iSndSysSource> StartGUISound(const char* name,bool loop = iSoundManager::NO_LOOP); // This one should not be used. I'm leaving it in only because... I'm using it inside the class :-). // And you can insist on controlling volume. ! virtual csRef<iSndSysSource> StartSound(const char* name,float volume,bool loop = iSoundManager::NO_LOOP); /** Change the current song to use as the background *************** *** 160,164 **** * */ ! virtual csRef<iSoundHandle> GetSoundResource(const char *name); SCF_DECLARE_IBASE; --- 162,170 ---- * */ ! virtual csRef<iSndSysData> GetSoundResource(const char *name); ! ! /// Retrieves a pointer to the sound renderer - the main interface of the sound system ! virtual csRef<iSndSysRenderer> GetSoundSystem() { return soundSystem; } ! SCF_DECLARE_IBASE; *************** *** 258,262 **** bool LoadSoundLib(const char* fname); ! csPtr<iSoundHandle> LoadSound(const char* fname); csRef<psSoundHandle> CreateSound (const char* name); --- 264,268 ---- bool LoadSoundLib(const char* fname); ! csRef<iSndSysData> LoadSound(const char* fname); csRef<psSoundHandle> CreateSound (const char* name); *************** *** 270,286 **** csHash<psSoundFileInfo *> sndfiles; psSoundManager* parent; ! csRef<iSoundLoader> sndloader; csRef<iVFS> vfs; } sndmngr; friend class psSndSourceMngr; ! ! csRef<iSoundRender> snd; ! csRef<iSoundSource> backsound; csRef<psSoundHandle> backhandle; csRef<iEngine> engine; csRef<iObjectRegistry> object_reg; csString currentSectorName; ! csRef<iSoundSource> oldBackSound; csRef<psSoundHandle> oldBackHandle; --- 276,294 ---- csHash<psSoundFileInfo *> sndfiles; psSoundManager* parent; ! csRef<iSndSysLoader> sndloader; csRef<iVFS> vfs; } sndmngr; friend class psSndSourceMngr; ! public: ! static csRef<iSndSysRenderer> soundSystem; ! ! private: ! csRef<iSndSysSource> backsound; csRef<psSoundHandle> backhandle; csRef<iEngine> engine; csRef<iObjectRegistry> object_reg; csString currentSectorName; ! csRef<iSndSysSource> oldBackSound; csRef<psSoundHandle> oldBackHandle; *************** *** 326,330 **** { public: ! psSoundHandle(iSoundHandle* nsrc) : src(nsrc) { } --- 334,338 ---- { public: ! psSoundHandle(iSndSysData* ndata) : snddata(ndata) { } *************** *** 333,339 **** } ! iSoundHandle* operator() () { return src; } ! csRef<iSoundHandle> src; }; --- 341,347 ---- } ! csRef<iSndSysData> operator() () { return snddata; } ! csRef<iSndSysData> snddata; }; *************** *** 348,355 **** { public: ! psSoundObject(csRef<iSoundHandle> handle, psMapSoundSystem* mapSystem, ! float maxVol, float minVol, ! bool threeDee = false,int fadeDelay = 0, int timeOfDay = 0, int timeOfDayRange = 0, int weatherCondition = 0, bool looping = true, psSectorSoundManager* sector = NULL, --- 356,362 ---- { public: ! psSoundObject(csRef<iSndSysStream> soundData, psMapSoundSystem* mapSystem, ! float maxVol, float minVol, int fadeDelay = 0, int timeOfDay = 0, int timeOfDayRange = 0, int weatherCondition = 0, bool looping = true, psSectorSoundManager* sector = NULL, *************** *** 396,401 **** */ void Start3DSound( csVector3 &position ); ! void Start3DSound(); ! void Stop() { if (sound) sound->Stop(); isPlaying = false; } bool MatchTime( int time ); --- 403,408 ---- */ void Start3DSound( csVector3 &position ); ! void StartSound(); ! void Stop() { if (soundStream) soundStream->Pause(); isPlaying = false; } bool MatchTime( int time ); *************** *** 407,411 **** bool Same( const psSoundObject *other ) { ! return (this->soundObject == other->soundObject); } --- 414,418 ---- bool Same( const psSoundObject *other ) { ! return (this->soundStream == other->soundStream); } *************** *** 426,431 **** void UpdateWeather(int weather); ! csRef<iSoundHandle> soundObject; ! csRef<iSoundSource> sound; csString resourceName; --- 433,439 ---- void UpdateWeather(int weather); ! csRef<iSndSysStream> soundStream; ! csRef<iSndSysSource> soundSource; ! csRef<iSndSysSourceSoftware3D> soundSource3D; csString resourceName; |